/* Courtroom Live — Video Game UI */
@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&family=Outfit:wght@400;600;700;800&display=swap');

.clg-body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: #0a0f1a;
  color: #e8eef7;
  font-family: 'Outfit', system-ui, sans-serif;
  overflow-x: hidden;
}

.clg-screen {
  min-height: 100vh;
  min-height: 100dvh;
  position: relative;
}

/* ── Title Screen ── */
.clg-title-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.clg-title-bg {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 50% at 50% 0%, rgba(139, 92, 246, 0.35), transparent),
    radial-gradient(ellipse 60% 40% at 80% 80%, rgba(6, 182, 212, 0.15), transparent),
    linear-gradient(180deg, #0f172a 0%, #0a0f1a 100%);
  animation: clg-bg-shift 8s ease-in-out infinite alternate;
}
@keyframes clg-bg-shift {
  0% { filter: hue-rotate(0deg); }
  100% { filter: hue-rotate(12deg); }
}
.clg-nav-mini {
  position: absolute;
  top: 1rem;
  left: 1rem;
  z-index: 2;
}
.clg-nav-mini a {
  color: #94a3b8;
  text-decoration: none;
  font-size: 0.8125rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.clg-title-content {
  position: relative;
  z-index: 2;
  text-align: center;
  padding: 2rem 1.25rem;
  animation: clg-title-in 0.8s cubic-bezier(0.22, 1, 0.36, 1);
}
@keyframes clg-title-in {
  from { opacity: 0; transform: translateY(24px); }
  to { opacity: 1; transform: translateY(0); }
}
.clg-logo-gavel {
  width: 72px;
  height: 72px;
  margin: 0 auto 1rem;
  border-radius: 20px;
  background: linear-gradient(135deg, #7c3aed, #06b6d4);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  color: #fff;
  box-shadow: 0 0 40px rgba(139, 92, 246, 0.5);
  animation: clg-gavel-pulse 2s ease-in-out infinite;
}
@keyframes clg-gavel-pulse {
  0%, 100% { transform: scale(1); box-shadow: 0 0 40px rgba(139, 92, 246, 0.5); }
  50% { transform: scale(1.05); box-shadow: 0 0 60px rgba(139, 92, 246, 0.7); }
}
.clg-title-text {
  font-family: 'Press Start 2P', cursive;
  font-size: clamp(1.1rem, 4.5vw, 1.65rem);
  line-height: 1.5;
  margin: 0 0 0.75rem;
  background: linear-gradient(90deg, #c4b5fd, #67e8f9, #f0abfc);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.clg-title-tag {
  color: #94a3b8;
  font-size: 1rem;
  margin-bottom: 1.25rem;
}
.clg-title-features {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.65rem;
  margin-bottom: 2rem;
  font-size: 0.75rem;
  color: #64748b;
}
.clg-title-features span {
  padding: 0.35rem 0.65rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid #334155;
}
.clg-title-screen .gl-how-to-play {
  --gl-how-accent: #a78bfa;
  max-width: 420px;
  margin: 0 auto 1.25rem;
  text-align: left;
  background: rgba(15, 23, 42, 0.65);
  border-color: rgba(139, 92, 246, 0.35);
}
.clg-title-screen .gl-how-steps li { color: #cbd5e1; }
.clg-btn-start {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  padding: 1rem 2rem;
  border: none;
  border-radius: 14px;
  font-family: 'Outfit', sans-serif;
  font-weight: 800;
  font-size: 1rem;
  letter-spacing: 0.06em;
  color: #fff;
  cursor: pointer;
  background: linear-gradient(135deg, #7c3aed, #db2777);
  box-shadow: 0 4px 0 #5b21b6, 0 8px 24px rgba(124, 58, 237, 0.45);
  transition: transform 0.1s, box-shadow 0.1s;
}
.clg-btn-start:hover { transform: translateY(-2px); }
.clg-btn-start:active {
  transform: translateY(4px);
  box-shadow: 0 0 0 #5b21b6, 0 2px 12px rgba(124, 58, 237, 0.35);
}
.clg-title-characters {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 180px;
  pointer-events: none;
  opacity: 0.5;
}
.clg-title-char { position: absolute; bottom: 0; width: 100px; height: 140px; }
.clg-title-char svg { width: 100%; height: 100%; }
.clg-float-1 { left: 10%; animation: clg-float 3s ease-in-out infinite; }
.clg-float-2 { right: 15%; animation: clg-float 3.5s ease-in-out infinite 0.5s; }
@keyframes clg-float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

/* ── Case Select ── */
.clg-select-screen { padding: 1rem 1rem 2rem; max-width: 640px; margin: 0 auto; }
.clg-select-head {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}
.clg-select-head h2 { font-size: 1.25rem; margin: 0; }
.clg-icon-btn {
  width: 40px; height: 40px;
  border-radius: 10px;
  border: 1px solid #334155;
  background: rgba(255,255,255,0.04);
  color: #e8eef7;
  cursor: pointer;
}
.clg-case-grid { display: grid; gap: 0.85rem; }
.clg-case-opt {
  text-align: left;
  padding: 1.15rem;
  border-radius: 16px;
  border: 2px solid #334155;
  background: linear-gradient(135deg, rgba(30,41,59,0.8), rgba(15,23,42,0.9));
  color: inherit;
  cursor: pointer;
  transition: border-color 0.2s, transform 0.15s;
}
.clg-case-opt:hover {
  border-color: #8b5cf6;
  transform: scale(1.02);
}
.clg-case-opt strong { display: block; font-size: 1.05rem; margin-bottom: 0.25rem; }
.clg-case-opt span { font-size: 0.8125rem; color: #94a3b8; }
.clg-case-opt .clg-case-play {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin-top: 0.75rem;
  font-size: 0.8125rem;
  font-weight: 700;
  color: #a78bfa;
}

/* ── Game HUD ── */
.clg-game-screen {
  display: flex;
  flex-direction: column;
  max-width: 720px;
  margin: 0 auto;
  padding-bottom: env(safe-area-inset-bottom, 0);
}
.clg-hud {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.65rem 0.75rem;
  background: rgba(15, 23, 42, 0.95);
  border-bottom: 2px solid #334155;
  gap: 0.5rem;
  flex-wrap: wrap;
  position: sticky;
  top: 0;
  z-index: 20;
}
.clg-hud-left { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.clg-hud-pill {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.3rem 0.55rem;
  border-radius: 8px;
  background: rgba(255,255,255,0.05);
  border: 1px solid #334155;
  font-size: 0.625rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #64748b;
}
.clg-hud-pill strong { color: #fbbf24; font-size: 0.875rem; }
.clg-hud-combo strong { color: #f97316; }
.clg-hud-combo.clg-combo-hot { animation: clg-combo-flash 0.5s ease; border-color: #f97316; }
@keyframes clg-combo-flash {
  50% { background: rgba(249, 115, 22, 0.2); }
}
.clg-hud-timer {
  position: relative;
  width: 52px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.clg-timer-ring { width: 100%; height: 100%; transform: rotate(-90deg); }
.clg-timer-bg { fill: none; stroke: #334155; stroke-width: 3; }
.clg-timer-fill {
  fill: none;
  stroke: #22c55e;
  stroke-width: 3;
  stroke-linecap: round;
  transition: stroke-dasharray 0.3s, stroke 0.3s;
}
.clg-hud-timer.clg-timer-urgent .clg-timer-fill { stroke: #ef4444; }
.clg-hud-timer.clg-timer-urgent { animation: clg-timer-pulse 0.6s ease infinite; }
@keyframes clg-timer-pulse {
  50% { transform: scale(1.08); }
}
.clg-hud-timer span {
  position: absolute;
  font-size: 0.6875rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

/* ── 2D Stage ── */
.clg-stage {
  position: relative;
  width: 100%;
  aspect-ratio: 8 / 3.2;
  min-height: 200px;
  max-height: 280px;
  overflow: hidden;
  border-bottom: 3px solid #5c3d2e;
}
.clg-scene-bg { position: absolute; inset: 0; }
.clg-scene-bg svg { width: 100%; height: 100%; object-fit: cover; }
.clg-characters {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.clg-char-slot {
  position: absolute;
  transition: transform 0.3s ease;
}
.clg-char-slot svg { width: 100%; height: auto; display: block; filter: drop-shadow(0 4px 8px rgba(0,0,0,0.4)); }
.clg-char-player {
  left: 4%;
  bottom: 8%;
  width: clamp(70px, 18vw, 110px);
  animation: clg-idle 2.5s ease-in-out infinite;
}
.clg-char-judge-slot {
  left: 50%;
  transform: translateX(-50%);
  bottom: 38%;
  width: clamp(60px, 14vw, 90px);
  animation: clg-idle 3s ease-in-out infinite 0.3s;
}
.clg-char-opp {
  right: 4%;
  bottom: 8%;
  width: clamp(70px, 18vw, 110px);
  animation: clg-idle 2.8s ease-in-out infinite 0.6s;
}
@keyframes clg-idle {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}
.clg-char-judge-slot { animation-name: clg-idle-judge; }
@keyframes clg-idle-judge {
  0%, 100% { transform: translateX(-50%) translateY(0); }
  50% { transform: translateX(-50%) translateY(-3px); }
}
.clg-char-player.talking { animation: clg-talk 0.35s ease infinite; }
.clg-char-judge-slot.talking { animation: clg-talk-judge 0.35s ease infinite; }
.clg-char-opp.talking { animation: clg-talk 0.4s ease infinite; }
@keyframes clg-talk {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-2px) scale(1.03); }
}
@keyframes clg-talk-judge {
  0%, 100% { transform: translateX(-50%) scale(1); }
  50% { transform: translateX(-50%) scale(1.04); }
}
.clg-char-judge-slot.gavel .clg-gavel {
  animation: clg-gavel-slam 0.5s ease;
  transform-origin: center top;
}
@keyframes clg-gavel-slam {
  0% { transform: rotate(0deg); }
  40% { transform: rotate(-35deg); }
  100% { transform: rotate(0deg); }
}

.clg-speech-bubble {
  position: absolute;
  max-width: 42%;
  padding: 0.45rem 0.65rem;
  border-radius: 12px;
  font-size: 0.6875rem;
  line-height: 1.4;
  animation: clg-bubble-in 0.35s ease;
  z-index: 5;
}
@keyframes clg-bubble-in {
  from { opacity: 0; transform: scale(0.85); }
  to { opacity: 1; transform: scale(1); }
}
.clg-bubble-opp {
  right: 18%;
  bottom: 42%;
  background: #7f1d1d;
  border: 2px solid #ef4444;
}
.clg-bubble-judge {
  left: 50%;
  transform: translateX(-50%);
  top: 18%;
  background: #1e3a5f;
  border: 2px solid #c9a227;
  text-align: center;
}
.clg-speech-bubble { cursor: pointer; }
.clg-bubble-judge::after {
  content: '';
  position: absolute;
  bottom: -8px;
  left: 50%;
  transform: translateX(-50%);
  border: 8px solid transparent;
  border-top-color: #c9a227;
}

.clg-fx-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}
.clg-score-pop {
  position: absolute;
  font-weight: 800;
  font-size: 1.25rem;
  color: #fbbf24;
  text-shadow: 0 2px 8px rgba(0,0,0,0.6);
  animation: clg-pop-up 1.2s ease forwards;
  z-index: 10;
}
@keyframes clg-pop-up {
  0% { opacity: 1; transform: translateY(0) scale(1); }
  100% { opacity: 0; transform: translateY(-60px) scale(1.3); }
}

/* ── Mission & Input ── */
.clg-mission {
  padding: 0.75rem 0.85rem;
  background: rgba(30, 41, 59, 0.6);
  border-bottom: 1px solid #334155;
}
.clg-mission-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 0.35rem;
}
.clg-mission-level { font-weight: 700; font-size: 0.875rem; color: #a78bfa; }
.clg-mission-case { font-size: 0.6875rem; color: #64748b; }
.clg-mission-brief { font-size: 0.8125rem; color: #cbd5e1; line-height: 1.5; margin: 0 0 0.5rem; }
.clg-facts-fold { font-size: 0.75rem; color: #94a3b8; }
.clg-facts-fold summary { cursor: pointer; font-weight: 600; }
.clg-facts-fold p { margin: 0.35rem 0 0; line-height: 1.5; }

.clg-input-panel {
  padding: 0.75rem;
  background: #0f172a;
  flex: 1;
}
.clg-input-tabs { display: flex; gap: 0.35rem; margin-bottom: 0.5rem; }
.clg-tab {
  flex: 1;
  padding: 0.5rem;
  border: 1px solid #334155;
  border-radius: 8px;
  background: transparent;
  color: #94a3b8;
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
}
.clg-tab.active {
  background: rgba(139, 92, 246, 0.15);
  border-color: #8b5cf6;
  color: #c4b5fd;
}
.clg-input-body textarea {
  width: 100%;
  padding: 0.75rem;
  border-radius: 12px;
  border: 2px solid #334155;
  background: #1e293b;
  color: #e8eef7;
  font-family: inherit;
  font-size: 0.9rem;
  resize: none;
  box-sizing: border-box;
}
.clg-input-body textarea:focus {
  outline: none;
  border-color: #8b5cf6;
}
#clg-input-voice { text-align: center; padding: 0.75rem 0; }
.clg-voice-mic {
  width: 64px; height: 64px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, #7c3aed, #8b5cf6);
  color: #fff;
  font-size: 1.5rem;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(139, 92, 246, 0.4);
}
.clg-voice-mic.listening { animation: clg-mic-pulse 1s ease infinite; }
@keyframes clg-mic-pulse {
  50% { box-shadow: 0 0 0 12px rgba(139, 92, 246, 0.2); }
}
.clg-voice-text { font-size: 0.875rem; color: #cbd5e1; min-height: 2.5rem; margin-top: 0.5rem; }
.clg-btn-submit {
  width: 100%;
  margin-top: 0.65rem;
  padding: 0.85rem;
  border: none;
  border-radius: 12px;
  font-weight: 800;
  font-size: 0.875rem;
  letter-spacing: 0.04em;
  color: #fff;
  cursor: pointer;
  background: linear-gradient(135deg, #059669, #10b981);
  box-shadow: 0 3px 0 #047857;
  transition: transform 0.1s;
}
.clg-btn-submit:active { transform: translateY(3px); box-shadow: none; }
.clg-btn-submit:disabled { opacity: 0.5; cursor: not-allowed; }
.clg-btn-continue {
  width: 100%;
  margin-top: 0.65rem;
  padding: 0.85rem;
  border: none;
  border-radius: 12px;
  font-weight: 800;
  font-size: 0.875rem;
  color: #fff;
  cursor: pointer;
  background: linear-gradient(135deg, #7c3aed, #8b5cf6);
  box-shadow: 0 3px 0 #5b21b6;
}

/* ── Round Overlay ── */
.clg-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 100;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.25s ease;
}
.clg-overlay.is-open {
  display: flex;
  pointer-events: auto;
  opacity: 1;
  animation: clg-fade-in 0.3s ease;
}
.clg-overlay[hidden] {
  display: none !important;
  pointer-events: none !important;
  opacity: 0 !important;
}
.clg-overlay-close {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid #475569;
  background: rgba(15, 23, 42, 0.9);
  color: #94a3b8;
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s, border-color 0.15s;
  z-index: 2;
}
.clg-overlay-close:hover { color: #e8eef7; border-color: #8b5cf6; }
.clg-overlay-card { position: relative; }
.clg-overlay-card {
  width: 100%;
  max-width: 400px;
  max-height: 90vh;
  overflow-y: auto;
  background: linear-gradient(180deg, #1e293b, #0f172a);
  border: 2px solid #334155;
  border-radius: 20px;
  padding: 1.5rem;
  text-align: center;
  animation: clg-card-pop 0.4s cubic-bezier(0.22, 1, 0.36, 1);
}
@keyframes clg-card-pop {
  from { opacity: 0; transform: scale(0.9) translateY(20px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}
.clg-round-badge {
  display: inline-block;
  padding: 0.35rem 1rem;
  border-radius: 999px;
  font-weight: 800;
  font-size: 0.875rem;
  letter-spacing: 0.08em;
  margin-bottom: 0.5rem;
}
.clg-round-card.clg-verdict-good .clg-round-badge { background: rgba(16,185,129,0.2); color: #34d399; border: 1px solid #10b981; }
.clg-round-card.clg-verdict-mid .clg-round-badge { background: rgba(245,158,11,0.2); color: #fbbf24; border: 1px solid #f59e0b; }
.clg-round-card.clg-verdict-low .clg-round-badge { background: rgba(239,68,68,0.2); color: #f87171; border: 1px solid #ef4444; }
.clg-round-score {
  font-size: 3rem;
  font-weight: 800;
  color: #fbbf24;
  line-height: 1;
  margin-bottom: 1rem;
  animation: clg-score-bounce 0.6s ease;
}
@keyframes clg-score-bounce {
  0% { transform: scale(0); }
  60% { transform: scale(1.15); }
  100% { transform: scale(1); }
}
.clg-round-bars { text-align: left; margin-bottom: 1rem; }
.clg-rbar {
  display: grid;
  grid-template-columns: 72px 1fr 28px;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 0.4rem;
  font-size: 0.6875rem;
}
.clg-rbar-track {
  height: 8px;
  background: #334155;
  border-radius: 999px;
  overflow: hidden;
}
.clg-rbar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #8b5cf6, #06b6d4);
  border-radius: 999px;
  transition: width 0.8s cubic-bezier(0.22, 1, 0.36, 1);
}
.clg-rbar em { font-style: normal; font-weight: 700; color: #fbbf24; }
.clg-round-feedback {
  text-align: left;
  font-size: 0.8125rem;
  line-height: 1.55;
  margin-bottom: 0.75rem;
}
.clg-rf-item {
  padding: 0.5rem 0.65rem;
  border-radius: 8px;
  margin-bottom: 0.35rem;
  display: flex;
  gap: 0.4rem;
  align-items: flex-start;
}
.clg-rf-good { background: rgba(16,185,129,0.1); color: #6ee7b7; }
.clg-rf-warn { background: rgba(245,158,11,0.1); color: #fcd34d; }
.clg-rf-cite { background: rgba(139,92,246,0.1); color: #c4b5fd; }
.clg-round-precedent {
  font-size: 0.75rem;
  text-align: left;
  padding: 0.65rem;
  border-radius: 10px;
  background: rgba(30,58,95,0.5);
  border: 1px solid #3b6ea5;
  margin-bottom: 1rem;
  color: #93c5fd;
}
.clg-btn-next { width: 100%; justify-content: center; margin-top: 0.5rem; }

/* ── Victory ── */
.clg-victory-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at center, rgba(251,191,36,0.15), #0a0f1a);
}
.clg-victory-content { text-align: center; padding: 2rem 1.25rem; animation: clg-title-in 0.6s ease; }
.clg-victory-icon {
  font-size: 4rem;
  color: #fbbf24;
  margin-bottom: 1rem;
  animation: clg-trophy-spin 1s ease;
}
@keyframes clg-trophy-spin {
  0% { transform: scale(0) rotate(-20deg); }
  70% { transform: scale(1.2) rotate(5deg); }
  100% { transform: scale(1) rotate(0); }
}
.clg-victory-content h2 {
  font-family: 'Press Start 2P', cursive;
  font-size: clamp(0.9rem, 3.5vw, 1.2rem);
  color: #fbbf24;
  margin-bottom: 0.5rem;
}
.clg-victory-rank { font-size: 1.25rem; font-weight: 700; color: #a78bfa; margin-bottom: 1.5rem; }
.clg-victory-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.65rem;
  margin-bottom: 2rem;
}
.clg-victory-stats div {
  padding: 0.75rem 0.5rem;
  border-radius: 12px;
  background: rgba(255,255,255,0.05);
  border: 1px solid #334155;
}
.clg-victory-stats span { display: block; font-size: 0.625rem; color: #64748b; text-transform: uppercase; }
.clg-victory-stats strong { font-size: 1.25rem; color: #fbbf24; }
.clg-victory-actions { display: flex; flex-direction: column; gap: 0.65rem; align-items: center; }
.clg-btn-ghost-link {
  color: #94a3b8;
  text-decoration: none;
  font-size: 0.875rem;
}
.clg-victory-confetti {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image:
    radial-gradient(circle, #fbbf24 2px, transparent 2px),
    radial-gradient(circle, #a78bfa 2px, transparent 2px),
    radial-gradient(circle, #34d399 2px, transparent 2px);
  background-size: 80px 80px, 120px 120px, 100px 100px;
  background-position: 0 0, 40px 40px, 20px 60px;
  opacity: 0.3;
  animation: clg-confetti-drift 20s linear infinite;
}
@keyframes clg-confetti-drift {
  to { background-position: 0 200px, 40px 240px, 20px 260px; }
}

@media (max-width: 380px) {
  .clg-hud-pill span { display: none; }
  .clg-title-text { font-size: 0.95rem; }
}