/* ==========================================================================
   MechaTech Design System — Tactile Precision Studio
   Zero purple clichés, zero neon borders, GPU-composited 60 FPS animations.
   ========================================================================== */

:root {
  --bg: #0c0e11;
  --surface: #14171c;
  --surface-2: #1b1f26;
  --surface-3: #232831;
  --code-bg: #101318;
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.16);
  --top-highlight: rgba(255, 255, 255, 0.045);

  --ink: #f2f0eb;
  --ink-muted: #969ea9;
  --ink-subtle: #69727e;

  --accent: #f59e0b;
  --accent-hover: #fbbf24;
  --accent-soft: rgba(245, 158, 11, 0.13);
  --accent-ink: #120d02;

  --good: #22c55e;
  --good-soft: rgba(34, 197, 94, 0.13);
  --bad: #ef4444;
  --bad-soft: rgba(239, 68, 68, 0.14);

  /* Syntax colors — obsidian dark */
  --tok-kw: #fb923c;
  --tok-str: #4ade80;
  --tok-num: #38bdf8;
  --tok-fn: #fde047;
  --tok-cmt: #64748b;
  --tok-op: #cbd5e1;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.35), inset 0 1px 0 var(--top-highlight);
  --shadow-md: 0 10px 28px rgba(0, 0, 0, 0.36), inset 0 1px 0 var(--top-highlight);
}

[data-theme="light"] {
  --bg: #f4f2ed;
  --surface: #ffffff;
  --surface-2: #ece9e2;
  --surface-3: #e2ded5;
  --code-bg: #faf9f6;
  --border: rgba(20, 23, 28, 0.09);
  --border-strong: rgba(20, 23, 28, 0.18);
  --top-highlight: rgba(255, 255, 255, 0.7);

  --ink: #15181d;
  --ink-muted: #525a66;
  --ink-subtle: #78818e;

  --accent: #d97706;
  --accent-hover: #b45309;
  --accent-soft: rgba(217, 119, 6, 0.11);
  --accent-ink: #ffffff;

  --good: #15803d;
  --good-soft: rgba(21, 128, 61, 0.11);
  --bad: #dc2626;
  --bad-soft: rgba(220, 38, 38, 0.11);

  --tok-kw: #c2410c;
  --tok-str: #15803d;
  --tok-num: #0369a1;
  --tok-fn: #92400e;
  --tok-cmt: #78818e;
  --tok-op: #334155;

  --shadow-sm: 0 1px 2px rgba(20, 23, 28, 0.06);
  --shadow-md: 0 10px 24px rgba(20, 23, 28, 0.08);
}

*, *::before, *::after {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background-color: var(--bg);
  background-image:
    radial-gradient(ellipse 90% 42% at 50% -12%, rgba(245, 158, 11, 0.075), transparent 68%);
  color: var(--ink);
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  line-height: 1.5;
  touch-action: manipulation;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }
.mono { font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, monospace; }

button {
  font-family: inherit;
  color: inherit;
  cursor: pointer;
}

button:focus-visible, a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ==========================================================================
   TOP BAR
   ========================================================================== */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}

.topbar-inner {
  max-width: 1060px;
  margin: 0 auto;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  text-decoration: none;
  color: var(--ink);
  flex-shrink: 0;
}

.brand-glyph {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  display: grid;
  place-items: center;
  color: var(--accent);
}

.brand-glyph svg { width: 18px; height: 18px; }

.brand-name {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.08rem;
  letter-spacing: -0.02em;
  font-weight: 600;
}

.brand-name strong { color: var(--accent); font-weight: 700; }

.topbar-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.lang-trigger {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 36px;
  padding: 0 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  font-size: 0.84rem;
  font-weight: 600;
  white-space: nowrap;
  box-shadow: var(--shadow-sm);
  transition: transform 120ms ease, background-color 140ms ease;
}

.lang-trigger:hover { background: var(--surface-2); }
.lang-trigger:active { transform: translateY(1px); }

.inline-svg { width: 15px; height: 15px; color: var(--accent); flex-shrink: 0; }

.hud-readout {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 36px;
  padding: 0 11px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 0.82rem;
  font-variant-numeric: tabular-nums;
}

.hud-item { display: inline-flex; align-items: center; gap: 4px; }
.hud-k { font-size: 0.68rem; color: var(--ink-subtle); font-weight: 700; letter-spacing: 0.05em; }
.hud-sep { width: 1px; height: 14px; background: var(--border-strong); }

.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  display: grid;
  place-items: center;
  color: var(--ink-muted);
  transition: color 140ms ease, background-color 140ms ease, transform 120ms ease;
  flex-shrink: 0;
}

.icon-btn svg { width: 17px; height: 17px; }
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }
.icon-btn:active { transform: translateY(1px); }

/* ==========================================================================
   MAIN SHELL & HERO
   ========================================================================== */
.shell {
  width: 100%;
  max-width: 1060px;
  margin: 0 auto;
  padding: 24px 16px 40px;
  flex: 1;
}

.hero {
  display: flex;
  flex-direction: column;
  gap: 24px;
  margin-bottom: 28px;
}

.hero-copy { max-width: 680px; }

.hero-copy h1 {
  margin: 0 0 10px;
  font-family: 'Space Grotesk', sans-serif;
  font-size: clamp(1.9rem, 4.6vw, 2.85rem);
  line-height: 1.1;
  letter-spacing: -0.03em;
  font-weight: 700;
}

.hero-lead {
  margin: 0 0 20px;
  color: var(--ink-muted);
  font-size: clamp(0.95rem, 2vw, 1.05rem);
  max-width: 60ch;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 18px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-weight: 600;
  font-size: 0.92rem;
  white-space: nowrap;
  flex-shrink: 0;
  transition: transform 110ms ease, background-color 140ms ease, border-color 140ms ease;
}

.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.btn-primary {
  background: var(--accent);
  color: var(--accent-ink);
  box-shadow: 0 2px 10px rgba(245, 158, 11, 0.22);
}
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }

.btn-secondary {
  background: var(--surface-2);
  color: var(--ink);
  border-color: var(--border-strong);
}
.btn-secondary:hover:not(:disabled) { background: var(--surface-3); }

.btn-ghost {
  background: transparent;
  color: var(--ink-muted);
  border-color: var(--border);
}
.btn-ghost:hover:not(:disabled) { background: var(--surface-2); color: var(--ink); }

.btn-sm { min-height: 36px; padding: 0 12px; font-size: 0.84rem; }
.btn-xs { min-height: 30px; padding: 0 10px; font-size: 0.78rem; }
.full-width { width: 100%; }

/* Setup Strip (Difficulty + Languages inline) */
.setup-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 16px 24px;
  padding: 16px;
  border-radius: var(--radius-md);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.setup-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.lang-group { flex: 1; min-width: 260px; }

.setup-label {
  font-size: 0.74rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-subtle);
}

.diff-segment {
  display: inline-flex;
  padding: 3px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: 1px solid var(--border);
  gap: 2px;
  width: fit-content;
}

.diff-btn {
  min-height: 34px;
  padding: 0 14px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--ink-muted);
  font-size: 0.84rem;
  font-weight: 600;
  transition: background-color 140ms ease, color 140ms ease;
}

.diff-btn:hover { color: var(--ink); }
.diff-btn.active {
  background: var(--surface);
  color: var(--accent);
  box-shadow: var(--shadow-sm);
}

.lang-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.lang-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 36px;
  padding: 0 11px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--ink-muted);
  font-size: 0.83rem;
  font-weight: 600;
  transition: background-color 140ms ease, color 140ms ease, border-color 140ms ease, transform 110ms ease;
}

.lang-chip:active { transform: scale(0.97); }
.lang-chip.active {
  background: var(--surface-3);
  color: var(--ink);
  border-color: var(--border-strong);
}

.lang-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  opacity: 0.45;
  transition: opacity 140ms ease;
}
.lang-chip.active .lang-dot, .lang-row.active .lang-dot { opacity: 1; }

/* ==========================================================================
   GAME CATALOG GRID
   ========================================================================== */
.games-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.game-card {
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 18px;
  border-radius: var(--radius-lg);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  transition: transform 160ms cubic-bezier(0.22, 1, 0.36, 1), background-color 160ms ease, border-color 160ms ease;
  will-change: transform;
}

.game-card:hover {
  transform: translateY(-2px);
  background: var(--surface-2);
  border-color: var(--border-strong);
}

.game-card:active { transform: translateY(0); }

.game-card.featured {
  background: linear-gradient(160deg, var(--surface) 0%, color-mix(in srgb, var(--surface) 92%, var(--accent)) 100%);
}

.game-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.game-icon {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  display: grid;
  place-items: center;
  color: var(--accent);
}
.game-icon svg { width: 20px; height: 20px; }

.game-badge {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--ink-subtle);
}

.game-card-title {
  margin: 2px 0 0;
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.15rem;
  letter-spacing: -0.02em;
  color: var(--ink);
}

.game-card-desc {
  margin: 0;
  color: var(--ink-muted);
  font-size: 0.88rem;
  line-height: 1.48;
  flex: 1;
}

.game-card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  font-size: 0.82rem;
}

.best-readout { color: var(--ink-muted); font-variant-numeric: tabular-nums; }
.best-readout strong { color: var(--ink); }
.play-arrow { color: var(--accent); font-weight: 600; }

/* ==========================================================================
   GAME WORKSPACE
   ========================================================================== */
.quick-switch {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 10px;
  margin-bottom: 14px;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.quick-switch::-webkit-scrollbar { display: none; }

.qs-tab {
  flex-shrink: 0;
  min-height: 34px;
  padding: 0 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink-muted);
  font-size: 0.82rem;
  font-weight: 600;
  transition: background-color 140ms ease, color 140ms ease;
}

.qs-tab:hover { color: var(--ink); background: var(--surface-2); }
.qs-tab.active {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 40%, transparent);
}

.ws-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.ws-title-group {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.ws-title {
  margin: 0;
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.35rem;
  letter-spacing: -0.02em;
}

.ws-sub {
  margin: 2px 0 0;
  color: var(--ink-muted);
  font-size: 0.85rem;
}

.ws-stage {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* Round bar & 60fps progress track */
.round-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.round-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.lang-pill {
  display: inline-flex;
  align-items: center;
  height: 26px;
  padding: 0 9px;
  border-radius: 6px;
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--accent);
  flex-shrink: 0;
}

.round-prompt {
  font-size: 0.92rem;
  color: var(--ink-muted);
  font-weight: 500;
}

.round-right {
  display: flex;
  align-items: center;
  gap: 8px;
  font-variant-numeric: tabular-nums;
}

.stat-chip, .timer-chip {
  height: 28px;
  padding: 0 10px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  font-size: 0.8rem;
  font-weight: 600;
  background: var(--surface);
  border: 1px solid var(--border);
}

.timer-chip { color: var(--accent); font-family: 'JetBrains Mono', monospace; }
.timer-chip.muted { color: var(--ink-subtle); }
.timer-chip.danger { color: var(--bad); background: var(--bad-soft); border-color: transparent; }

.progress-track {
  width: 100%;
  height: 4px;
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
}

.progress-fill {
  width: 100%;
  height: 100%;
  background: var(--accent);
  transform-origin: left center;
  transform: scaleX(1);
  will-change: transform;
}

/* Editor Shell */
.editor-shell {
  border-radius: var(--radius-md);
  background: var(--code-bg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
  overflow: hidden;
  min-width: 0;
}

.editor-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 14px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.editor-meta { display: flex; align-items: center; gap: 8px; min-width: 0; }

.editor-title {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.focus-hint {
  font-size: 0.75rem;
  color: var(--ink-subtle);
  white-space: nowrap;
}

.code-display {
  margin: 0;
  padding: 16px;
  font-family: 'JetBrains Mono', monospace;
  font-size: clamp(0.84rem, 2.3vw, 0.96rem);
  line-height: 1.65;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  tab-size: 2;
}

/* Syntax tokens */
.tok-kw { color: var(--tok-kw); }
.tok-str { color: var(--tok-str); }
.tok-num { color: var(--tok-num); }
.tok-fn { color: var(--tok-fn); }
.tok-cmt { color: var(--tok-cmt); font-style: italic; }
.tok-op { color: var(--tok-op); }

.blank-slot {
  display: inline-block;
  padding: 0 8px;
  border-radius: 5px;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 700;
}

.blank-filled {
  display: inline-block;
  padding: 0 8px;
  border-radius: 5px;
  background: var(--good-soft);
  color: var(--good);
  font-weight: 700;
}

/* ==========================================================================
   CODE TYPE SPRINT
   ========================================================================== */
.typing-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.seg-group {
  display: inline-flex;
  padding: 3px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid var(--border);
  gap: 2px;
}

.seg-btn {
  min-height: 32px;
  padding: 0 12px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--ink-muted);
  font-size: 0.82rem;
  font-weight: 600;
}
.seg-btn.active { background: var(--surface-3); color: var(--accent); }

.typing-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.chip-toggle {
  min-height: 36px;
  padding: 0 11px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink-muted);
  font-size: 0.8rem;
  font-weight: 600;
}
.chip-toggle.active { color: var(--ink); border-color: var(--border-strong); background: var(--surface-2); }

.metrics-bar {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.metric-tile {
  padding: 12px 14px;
  border-radius: var(--radius-md);
  background: var(--surface);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.metric-label {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--ink-subtle);
}

.metric-value {
  font-family: 'Space Grotesk', sans-serif;
  font-size: clamp(1.25rem, 3.5vw, 1.65rem);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1.15;
}
.metric-value.accent { color: var(--accent); }
.metric-value.bad { color: var(--bad); }

.typing-stage {
  position: relative;
  min-height: 210px;
  max-height: 380px;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  padding: 18px 16px;
  cursor: text;
}

.typing-stage.focused {
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 45%, transparent);
}

.typing-code {
  margin: 0;
  font-family: 'JetBrains Mono', monospace;
  font-size: clamp(0.88rem, 2.5vw, 1.05rem);
  line-height: 1.78;
  white-space: pre;
  user-select: none;
  -webkit-user-select: none;
}

.ch {
  opacity: 0.42;
  border-radius: 2px;
}

.ch-nl {
  font-size: 0.78em;
  opacity: 0.28;
}

.ch.ch-ok {
  opacity: 1;
}

.ch.ch-ok.ch-nl {
  opacity: 0.45;
  color: var(--good);
}

.ch.ch-err {
  opacity: 1;
  color: #ffffff !important;
  background: var(--bad);
  border-radius: 3px;
}

.typing-caret {
  position: absolute;
  top: 0;
  left: 0;
  width: 2.5px;
  height: 22px;
  background: var(--accent);
  border-radius: 2px;
  pointer-events: none;
  will-change: transform;
  transition: transform 55ms linear;
}

.typing-hidden-input {
  position: absolute;
  top: 12px;
  left: 12px;
  width: 1px;
  height: 1px;
  opacity: 0;
  border: 0;
  padding: 0;
  margin: 0;
  /* 16px prevents iOS Safari from auto-zooming on focus */
  font-size: 16px;
  pointer-events: none;
}

.symbol-dock {
  display: flex;
  gap: 6px;
  padding: 10px 12px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.symbol-dock::-webkit-scrollbar { display: none; }

.sym-key {
  flex-shrink: 0;
  min-width: 38px;
  height: 36px;
  padding: 0 10px;
  border-radius: 7px;
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ink);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.sym-key:active { background: var(--accent); color: var(--accent-ink); }

/* Typing Results Panel */
.results-panel {
  padding: 20px;
  border-radius: var(--radius-lg);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.results-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.results-kicker {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--ink-subtle);
}

.results-title {
  margin: 2px 0 0;
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.35rem;
}

.pb-badge {
  padding: 5px 10px;
  border-radius: 6px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.05em;
}

.results-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.res-stat {
  padding: 14px;
  border-radius: var(--radius-md);
  background: var(--surface-2);
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.res-stat.primary { background: var(--accent-soft); }
.res-stat.primary .res-val { color: var(--accent); }

.res-label { font-size: 0.75rem; color: var(--ink-muted); font-weight: 600; }
.res-val {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.55rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.res-val.bad { color: var(--bad); }

.chart-wrap {
  padding: 12px 14px;
  border-radius: var(--radius-md);
  background: var(--code-bg);
  border: 1px solid var(--border);
}

.chart-caption {
  display: block;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--ink-subtle);
  margin-bottom: 6px;
}

.wpm-canvas { width: 100%; height: 110px; display: block; }

.results-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

/* ==========================================================================
   BUG HUNTER, CHOICES & SYNTAX SCRAMBLE
   ========================================================================== */
.bug-lines {
  display: flex;
  flex-direction: column;
  padding: 8px 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.code-line-btn {
  width: 100%;
  min-width: max-content;
  border: 0;
  background: transparent;
  padding: 8px 14px;
  display: flex;
  align-items: baseline;
  gap: 14px;
  text-align: left;
  transition: background-color 110ms ease;
}

.code-line-btn:hover:not(:disabled) { background: rgba(245, 158, 11, 0.08); }
.code-line-btn.is-correct { background: var(--good-soft); }
.code-line-btn.is-wrong { background: var(--bad-soft); }

.line-no {
  width: 24px;
  text-align: right;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.78rem;
  color: var(--ink-subtle);
  user-select: none;
  flex-shrink: 0;
}

.line-code {
  font-family: 'JetBrains Mono', monospace;
  font-size: clamp(0.83rem, 2.2vw, 0.94rem);
  white-space: pre;
  line-height: 1.5;
}

.choices-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.choice-btn {
  min-height: 54px;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--surface);
  display: flex;
  align-items: center;
  gap: 12px;
  text-align: left;
  font-size: 0.92rem;
  font-weight: 600;
  transition: transform 110ms ease, background-color 140ms ease, border-color 140ms ease;
}

.choice-btn:hover:not(:disabled) {
  background: var(--surface-2);
  border-color: var(--border-strong);
  transform: translateY(-1px);
}

.choice-btn:active:not(:disabled) { transform: translateY(0); }

.choice-key {
  width: 26px;
  height: 26px;
  border-radius: 6px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  display: grid;
  place-items: center;
  font-size: 0.76rem;
  color: var(--ink-subtle);
  flex-shrink: 0;
}

.choice-text { word-break: break-word; }

.choice-btn.is-correct {
  background: var(--good-soft);
  border-color: var(--good);
  color: var(--ink);
}
.choice-btn.is-wrong {
  background: var(--bad-soft);
  border-color: var(--bad);
}

/* Syntax Scramble */
.scramble-target {
  min-height: 112px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  overflow-x: auto;
}

.scramble-placeholder {
  padding: 28px 12px;
  text-align: center;
  color: var(--ink-subtle);
  font-size: 0.88rem;
}

.scramble-placed-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
}

.scramble-placed-row .line-code {
  flex: 1;
  overflow-x: auto;
}

.row-ctrls {
  display: inline-flex;
  gap: 4px;
  flex-shrink: 0;
}

.mini-ctrl {
  width: 30px;
  height: 30px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  font-size: 0.85rem;
  display: grid;
  place-items: center;
}
.mini-ctrl:disabled { opacity: 0.35; cursor: not-allowed; }
.mini-ctrl.remove:hover:not(:disabled) { color: var(--bad); border-color: var(--bad); }

.scramble-bank-wrap {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.scramble-bank-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.bank-label {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-subtle);
}

.scramble-bank {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.scramble-chip {
  width: 100%;
  min-height: 44px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  text-align: left;
  overflow-x: auto;
  transition: transform 110ms ease, background-color 130ms ease;
}

.scramble-chip:hover:not(:disabled) { background: var(--surface-2); transform: translateX(2px); }
.scramble-chip code { font-family: 'JetBrains Mono', monospace; font-size: 0.86rem; white-space: pre; }

/* Feedback Card */
.feedback-card {
  padding: 14px 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  font-size: 0.9rem;
}

.feedback-card strong { display: block; margin-bottom: 4px; font-size: 0.94rem; }
.feedback-card p { margin: 0; color: var(--ink-muted); }

.feedback-card.good { background: var(--good-soft); border-color: color-mix(in srgb, var(--good) 45%, transparent); }
.feedback-card.good strong { color: var(--good); }

.feedback-card.bad { background: var(--bad-soft); border-color: color-mix(in srgb, var(--bad) 45%, transparent); }
.feedback-card.bad strong { color: var(--bad); }

.solution-pre {
  margin: 8px 0 0;
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--code-bg);
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.8rem;
  overflow-x: auto;
  color: var(--ink);
}

/* ==========================================================================
   LANGUAGE DRAWER & TOAST
   ========================================================================== */
.drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(0, 0, 0, 0.56);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.drawer-panel {
  width: 100%;
  max-width: 460px;
  max-height: 86dvh;
  overflow-y: auto;
  padding: 20px;
  border-radius: var(--radius-lg);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  box-shadow: 0 24px 54px rgba(0, 0, 0, 0.48);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.drawer-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.drawer-title {
  margin: 0;
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.2rem;
}

.drawer-note { margin: 4px 0 0; font-size: 0.84rem; color: var(--ink-muted); }

.drawer-presets { display: flex; flex-direction: column; gap: 8px; }
.preset-row { display: flex; flex-wrap: wrap; gap: 6px; }

.lang-list { display: flex; flex-direction: column; gap: 8px; }

.lang-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 6px 4px 4px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-2);
}

.lang-row.active {
  border-color: var(--border-strong);
  background: var(--surface-3);
}

.lang-row-toggle {
  flex: 1;
  min-height: 40px;
  padding: 0 10px;
  border: 0;
  background: transparent;
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: left;
}

.lang-check {
  width: 20px;
  height: 20px;
  border-radius: 5px;
  border: 1px solid var(--border-strong);
  display: grid;
  place-items: center;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--accent-ink);
}
.lang-row.active .lang-check {
  background: var(--accent);
  border-color: var(--accent);
}

.lang-row-name { font-weight: 600; font-size: 0.92rem; }
.lang-row-ext {
  margin-left: auto;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.75rem;
  color: var(--ink-subtle);
}

.lang-solo-btn {
  min-height: 30px;
  padding: 0 10px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink-muted);
  font-size: 0.76rem;
  font-weight: 600;
}
.lang-solo-btn:hover { color: var(--accent); border-color: var(--accent); }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(20px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 95;
  padding: 10px 16px;
  border-radius: 999px;
  background: var(--surface-3);
  border: 1px solid var(--border-strong);
  color: var(--ink);
  font-size: 0.85rem;
  font-weight: 600;
  box-shadow: var(--shadow-md);
}

.site-footer {
  text-align: center;
  padding: 18px 16px calc(18px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--border);
  color: var(--ink-subtle);
  font-size: 0.78rem;
}

/* ==========================================================================
   RESPONSIVE BREAKPOINTS (MOBILE-FIRST ZERO-GLITCH)
   ========================================================================== */
@media (max-width: 860px) {
  .games-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 620px) {
  .topbar-inner { padding: 8px 10px; gap: 6px; }
  .brand { gap: 6px; }
  .brand-glyph { width: 26px; height: 26px; border-radius: 7px; }
  .brand-glyph svg { width: 15px; height: 15px; }
  .brand-name { font-size: 0.92rem; }
  .topbar-controls { gap: 5px; }
  .lang-trigger { height: 32px; padding: 0 8px; gap: 5px; font-size: 0.75rem; }
  .hud-readout { height: 32px; padding: 0 7px; gap: 5px; font-size: 0.74rem; }
  .hud-sep, .hud-item:last-child { display: none; }
  .icon-btn { width: 32px; height: 32px; }
  .icon-btn svg { width: 15px; height: 15px; }

  .shell { padding: 14px 12px 28px; }
  .games-grid { grid-template-columns: 1fr; }
  .metrics-bar { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
  .metric-tile { padding: 8px 6px; text-align: center; }
  .metric-label { font-size: 0.6rem; }
  .metric-value { font-size: 1.08rem; }
  .choices-grid { grid-template-columns: 1fr; }
  .results-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .results-actions { grid-template-columns: 1fr; }

  .typing-stage { min-height: 150px; max-height: 250px; padding: 12px 10px; }
  .ws-header { align-items: center; gap: 10px; margin-bottom: 12px; }
  .ws-title { font-size: 1.12rem; }
  .ws-sub { display: none; }
  .hero-actions .btn { flex: 1 1 auto; padding: 0 16px; }
}

@media (max-width: 400px) {
  .lang-trigger .inline-svg { display: none; }
  .brand-name { font-size: 0.88rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}


/* ==========================================================================
   60 FPS GPU-COMPOSITED ANIMATIONS & FULL-STACK GAME COMPONENTS
   ========================================================================== */
.ambient-orbs {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
}

.orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(72px);
  opacity: 0.14;
  will-change: transform;
}

.orb-a {
  width: 420px;
  height: 420px;
  top: -140px;
  left: -80px;
  background: radial-gradient(circle, var(--accent) 0%, transparent 70%);
  animation: orbDriftA 18s ease-in-out infinite alternate;
}

.orb-b {
  width: 380px;
  height: 380px;
  bottom: -140px;
  right: -90px;
  background: radial-gradient(circle, #38bdf8 0%, transparent 72%);
  animation: orbDriftB 22s ease-in-out infinite alternate;
}

[data-theme="light"] .orb { opacity: 0.1; }

@keyframes orbDriftA {
  0% { transform: translate3d(0, 0, 0) scale(1); }
  100% { transform: translate3d(70px, 45px, 0) scale(1.12); }
}

@keyframes orbDriftB {
  0% { transform: translate3d(0, 0, 0) scale(1); }
  100% { transform: translate3d(-65px, -50px, 0) scale(1.09); }
}

.fx-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 90;
  pointer-events: none;
}

.float-points {
  position: fixed;
  z-index: 92;
  pointer-events: none;
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--accent);
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.45);
  transform: translate3d(-50%, 0, 0);
  animation: floatUpFade 760ms cubic-bezier(0.22, 1, 0.36, 1) forwards;
  will-change: transform, opacity;
}

@keyframes floatUpFade {
  0% { opacity: 0; transform: translate3d(-50%, 6px, 0) scale(0.86); }
  20% { opacity: 1; transform: translate3d(-50%, -8px, 0) scale(1.06); }
  100% { opacity: 0; transform: translate3d(-50%, -44px, 0) scale(0.96); }
}

.view-enter {
  animation: viewEnter 260ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes viewEnter {
  from { opacity: 0; transform: translate3d(0, 10px, 0); }
  to { opacity: 1; transform: translate3d(0, 0, 0); }
}

.card-stagger {
  animation: cardRise 340ms cubic-bezier(0.22, 1, 0.36, 1) both;
  animation-delay: calc(var(--stagger, 0) * 34ms);
}

@keyframes cardRise {
  from { opacity: 0; transform: translate3d(0, 14px, 0) scale(0.985); }
  to { opacity: 1; transform: translate3d(0, 0, 0) scale(1); }
}

.anim-enter {
  animation: roundPop 240ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes roundPop {
  from { opacity: 0; transform: translate3d(0, 8px, 0); }
  to { opacity: 1; transform: translate3d(0, 0, 0); }
}

.anim-shake {
  animation: microShake 300ms cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
}

@keyframes microShake {
  15%, 85% { transform: translate3d(-3px, 0, 0); }
  30%, 70% { transform: translate3d(4px, 0, 0); }
  50% { transform: translate3d(-5px, 0, 0); }
}

.choice-btn.is-correct {
  animation: choicePop 260ms cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes choicePop {
  0% { transform: scale(1); }
  45% { transform: scale(1.022); }
  100% { transform: scale(1); }
}

.hud-readout.streak-hot {
  border-color: color-mix(in srgb, var(--accent) 55%, transparent);
  animation: streakPulse 1.8s ease-in-out infinite;
}

@keyframes streakPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(245, 158, 11, 0); }
  50% { box-shadow: 0 0 0 4px rgba(245, 158, 11, 0.16); }
}

/* Tactile card subtle sheen on hover */
.game-card {
  position: relative;
  overflow: hidden;
}

.game-card::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(115deg, transparent 35%, rgba(255, 255, 255, 0.05) 50%, transparent 65%);
  transform: translate3d(-110%, 0, 0);
  transition: transform 520ms cubic-bezier(0.22, 1, 0.36, 1);
  pointer-events: none;
}

.game-card:hover::after {
  transform: translate3d(110%, 0, 0);
}

.game-card:hover .game-icon {
  transform: scale(1.08);
  border-color: color-mix(in srgb, var(--accent) 45%, transparent);
}

.game-icon {
  transition: transform 180ms cubic-bezier(0.22, 1, 0.36, 1), border-color 180ms ease;
}

/* Setup strip grouped Frontend / Backend layout */
.setup-strip {
  flex-direction: column;
  gap: 14px;
}

.setup-top-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 14px 20px;
}

.lang-sections {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px 20px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.preset-btn.active {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 45%, transparent);
}

.lang-group-head {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-subtle);
  margin-top: 6px;
}

/* Hub category filter tabs */
.cat-filter-row {
  display: flex;
  gap: 7px;
  margin-bottom: 14px;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.cat-filter-row::-webkit-scrollbar { display: none; }

.cat-tab {
  flex-shrink: 0;
  min-height: 36px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink-muted);
  font-size: 0.83rem;
  font-weight: 600;
  transition: background-color 150ms ease, color 150ms ease, transform 110ms ease;
}

.cat-tab:hover { color: var(--ink); background: var(--surface-2); }
.cat-tab:active { transform: scale(0.97); }
.cat-tab.active {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: var(--accent);
}

/* API Wire Inspector & Incident Telemetry */
.wire-stage {
  padding: 18px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.wire-badge {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  color: var(--accent);
}

.wire-code {
  font-size: clamp(0.88rem, 2.4vw, 1.02rem);
  color: var(--ink);
  line-height: 1.55;
  word-break: break-word;
}

.scenario-text {
  margin: 0;
  font-size: clamp(0.94rem, 2.4vw, 1.04rem);
  line-height: 1.58;
  color: var(--ink);
}

.choices-grid.single-col {
  grid-template-columns: 1fr;
}

/* CSS Layout Lab Live Preview Box */
.css-stage-wrap {
  padding: 16px;
}

.css-live-box {
  width: 100%;
  min-height: 136px;
  padding: 12px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: 1px dashed var(--border-strong);
  overflow: hidden;
}

.css-demo-item {
  padding: 9px 14px;
  border-radius: 7px;
  background: var(--surface-3);
  border: 1px solid var(--border-strong);
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--ink);
  display: grid;
  place-items: center;
  text-align: center;
}

.css-demo-item:first-child {
  background: var(--accent-soft);
  border-color: color-mix(in srgb, var(--accent) 45%, transparent);
  color: var(--accent);
}

/* Regex Lab */
.regex-banner {
  padding: 20px 16px;
  font-size: clamp(0.96rem, 2.8vw, 1.24rem);
  font-weight: 600;
  color: var(--ink);
  overflow-x: auto;
  white-space: nowrap;
  -webkit-overflow-scrolling: touch;
}

.rx-slash { color: var(--ink-subtle); }
.rx-flags { color: var(--accent); font-weight: 700; }

.regex-sample.is-selected {
  background: var(--accent-soft);
  border-color: var(--accent);
}
.regex-sample.is-selected .choice-key {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: var(--accent);
}
.regex-sample.is-missed {
  background: var(--accent-soft);
  border-color: var(--accent);
  border-style: dashed;
}

/* Drawer entrance */
.drawer-backdrop:not(.hidden) .drawer-panel {
  animation: drawerIn 220ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes drawerIn {
  from { opacity: 0; transform: translate3d(0, 16px, 0) scale(0.97); }
  to { opacity: 1; transform: translate3d(0, 0, 0) scale(1); }
}

@media (max-width: 720px) {
  .lang-sections { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  .orb, .view-enter, .card-stagger, .anim-enter, .anim-shake, .hud-readout.streak-hot {
    animation: none !important;
  }
}


/* ==========================================================================
   V3 IMMERSIVE ATMOSPHERE, 12-THEME DROPDOWN, BRAND LOGOS & GLOBAL TIMER UI
   ========================================================================== */
body {
  transition: background-color 260ms ease, color 260ms ease;
  background-image:
    radial-gradient(ellipse 95% 46% at 50% -14%, color-mix(in srgb, var(--accent) 13%, transparent), transparent 68%);
}

.bg-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: -1;
  pointer-events: none;
}

.orb-a { background: radial-gradient(circle, var(--orb-a, var(--accent)) 0%, transparent 70%); opacity: 0.17; }
.orb-b { background: radial-gradient(circle, var(--orb-b, #38bdf8) 0%, transparent 72%); opacity: 0.14; }
.orb-c {
  width: 340px;
  height: 340px;
  top: 38%;
  left: 52%;
  background: radial-gradient(circle, var(--orb-c, #10b981) 0%, transparent 74%);
  opacity: 0.09;
  animation: orbDriftC 26s ease-in-out infinite alternate;
}

@keyframes orbDriftC {
  0% { transform: translate3d(-40px, -25px, 0) scale(0.95); }
  100% { transform: translate3d(55px, 45px, 0) scale(1.12); }
}

/* Theme Picker Dropdown (inspired by pasted.png) */
.theme-dropdown-wrap {
  position: relative;
}

.theme-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 215px;
  max-height: 76dvh;
  overflow-y: auto;
  padding: 6px;
  border-radius: 12px;
  background: color-mix(in srgb, var(--surface) 96%, #000);
  border: 1px solid var(--border-strong);
  box-shadow: 0 18px 46px rgba(0, 0, 0, 0.55);
  z-index: 90;
  display: flex;
  flex-direction: column;
  gap: 2px;
  transform-origin: top right;
  animation: menuPop 170ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes menuPop {
  from { opacity: 0; transform: translate3d(0, -6px, 0) scale(0.96); }
  to { opacity: 1; transform: translate3d(0, 0, 0) scale(1); }
}

.theme-option {
  width: 100%;
  min-height: 35px;
  padding: 6px 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ink-muted);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.86rem;
  font-weight: 500;
  text-align: left;
  transition: background-color 120ms ease, color 120ms ease;
}

.theme-option:hover {
  background: var(--surface-2);
  color: var(--ink);
}

.theme-option.active {
  background: var(--surface-2);
  color: var(--ink);
  font-weight: 600;
}

.theme-opt-left {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
}

.theme-swatch {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  border: 2px solid var(--accent);
  flex-shrink: 0;
}

.theme-check {
  color: var(--accent);
  font-size: 0.88rem;
  font-weight: 700;
}

/* Authentic Brand Language SVG Logos */
.lang-svg {
  width: 19px;
  height: 19px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform 150ms cubic-bezier(0.22, 1, 0.36, 1);
}
.lang-svg svg {
  width: 100%;
  height: 100%;
  display: block;
}
.lang-svg.sm {
  width: 16px;
  height: 16px;
}

.lang-chip:hover .lang-svg {
  transform: scale(1.12);
}

.lang-chip:not(.active) .lang-svg {
  opacity: 0.55;
  filter: grayscale(40%);
}

.lang-pill {
  gap: 6px;
}

/* Global Timer ON/OFF + Custom Duration Bar */
.timer-control-pair {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.timer-select {
  height: 36px;
  padding: 0 26px 0 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  color: var(--ink);
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 150ms ease, border-color 140ms ease;
}

.timer-select:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.ws-controls-right {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

/* Scenario Game Stages (Hacking, AI, CS GK) */
.artifact-pre {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: clamp(0.86rem, 2.35vw, 0.98rem);
  line-height: 1.58;
  color: var(--ink);
}

.stage-hack .editor-topbar {
  border-bottom-color: color-mix(in srgb, var(--bad) 26%, var(--border));
}
.stage-hack .wire-badge {
  color: var(--bad);
}

.stage-ai .editor-topbar {
  border-bottom-color: color-mix(in srgb, var(--accent) 30%, var(--border));
}

.stage-gk .editor-topbar {
  border-bottom-color: color-mix(in srgb, var(--good) 28%, var(--border));
}
.stage-gk .wire-badge {
  color: var(--good);
}

@media (max-width: 620px) {
  .ws-controls-right {
    width: 100%;
    justify-content: space-between;
  }
  .timer-control-pair .chip-toggle {
    min-height: 34px;
    padding: 0 9px;
    font-size: 0.76rem;
  }
  .timer-select {
    height: 34px;
    padding: 0 8px;
    font-size: 0.76rem;
  }
  .theme-menu {
    width: 200px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .orb-c, .theme-menu { animation: none !important; }
  body { transition: none !important; }
}
