/* VONK 2027 · Game-First UI (Blueprint & Workbench)
   Inspired by The Incredible Machine and De zevende dag.
   Self-hosted OFL fonts: Schibsted Grotesk + Inter (tabular-nums). Zero external calls. */

@font-face {
  font-family: 'Schibsted Grotesk';
  src: url('/fonts/SchibstedGrotesk-VF.woff2') format('woff2');
  font-weight: 400 800;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Inter';
  src: url('/fonts/Inter-VF.woff2') format('woff2');
  font-weight: 400 700;
  font-style: normal;
  font-display: swap;
}

:root,
[data-theme="blueprint"] {
  --bg-deep: #071021;
  --bg-surface: #0D1B36;
  --bg-elevated: #14264A;
  --bg-card: #10203F;
  --bg-input: #091429;
  --border: rgba(147, 197, 253, 0.2);
  --border-strong: rgba(229, 179, 57, 0.55);
  --text: #F4F7FC;
  --text-muted: #A6B8D6;
  --gold: #E5B339;
  --gold-deep: #A67916;
  --gold-soft: rgba(229, 179, 57, 0.16);
  --gold-ink: #0B162C;
  --accent: #4DA3FF;
  --ok: #4ADE80;
  --danger: #F05D6C;
  --shadow: 0 14px 36px rgba(2, 8, 23, 0.58);
}

[data-theme="workbench"] {
  --bg-deep: #E8E2D4;
  --bg-surface: #F7F4EC;
  --bg-elevated: #FFFFFF;
  --bg-card: #F2EDE1;
  --bg-input: #FFFFFF;
  --border: rgba(20, 48, 94, 0.16);
  --border-strong: rgba(154, 103, 8, 0.55);
  --text: #132240;
  --text-muted: #4D6082;
  --gold: #9A6708;
  --gold-deep: #6C4704;
  --gold-soft: rgba(154, 103, 8, 0.14);
  --gold-ink: #FFFFFF;
  --accent: #1D5EC4;
  --ok: #15803D;
  --danger: #C82D42;
  --shadow: 0 12px 28px rgba(19, 34, 64, 0.16);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg-deep);
  color: var(--text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, .brand-name {
  font-family: 'Schibsted Grotesk', 'Inter', sans-serif;
  margin: 0;
  letter-spacing: -0.015em;
}

button, input, textarea, select {
  font-family: inherit;
  font-variant-numeric: tabular-nums;
  color: inherit;
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

.hidden {
  display: none !important;
}

/* Opening mode: hide all game HUD chrome so the live contraption stage fills the whole screen */
body.is-opening .topbar,
body.is-opening .subbar,
body.is-opening .toolbox-dock,
body.is-opening .stage-hud {
  display: none !important;
}

body.is-opening .app-shell {
  grid-template-rows: 1fr;
}

/* App Shell — Full-bleed stage with compact top & bottom game bars */
.app-shell {
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  height: 100dvh;
  width: 100vw;
  overflow: hidden;
}

/* Top Game Bar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 14px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  z-index: 20;
  flex-wrap: wrap;
}

.topbar-left,
.topbar-center,
.topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 4px 8px;
  cursor: pointer;
}

.brand-btn:hover {
  border-color: var(--border);
  background: var(--bg-elevated);
}

.brand-hex {
  width: 24px;
  height: 24px;
  color: var(--text);
}

.brand-name {
  font-size: 1.04rem;
  font-weight: 800;
  letter-spacing: 0.05em;
}

.level-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 13px;
  font-size: 0.85rem;
  font-weight: 700;
  min-height: 36px;
  cursor: pointer;
  transition: border-color 0.14s, background 0.14s;
}

.level-pill:hover {
  border-color: var(--gold);
  background: var(--gold-soft);
}

/* Mode Tabs (unlocked cleanly from Puzzle 4 or via Unlock All) */
.mode-tabs {
  display: inline-flex;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 3px;
  gap: 2px;
}

.tab-btn {
  background: transparent;
  border: none;
  border-radius: 7px;
  padding: 5px 10px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  min-height: 32px;
  white-space: nowrap;
}

.tab-btn:hover {
  color: var(--text);
}

.tab-btn.active {
  background: var(--bg-elevated);
  color: var(--gold);
}

/* Tactile Hero Play Button (feels like pressing a real workshop switch) */
.btn-play-hero {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--gold);
  color: var(--gold-ink);
  border: none;
  border-radius: 12px;
  padding: 9px 20px;
  min-height: 40px;
  font-family: 'Schibsted Grotesk', 'Inter', sans-serif;
  font-size: 0.94rem;
  font-weight: 800;
  letter-spacing: 0.01em;
  cursor: pointer;
  box-shadow: 0 3px 0 var(--gold-deep), 0 6px 16px rgba(229, 179, 57, 0.22);
  transition: transform 0.08s ease-out, box-shadow 0.08s ease-out, filter 0.12s;
  white-space: nowrap;
}

.btn-play-hero:hover {
  filter: brightness(1.06);
}

.btn-play-hero:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 var(--gold-deep);
}

.btn-play-hero.is-running {
  background: #22C55E;
  color: #052E16;
  box-shadow: 0 3px 0 #15803D, 0 6px 16px rgba(34, 197, 94, 0.24);
}

/* Standard Game Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text);
  font-size: 0.83rem;
  font-weight: 600;
  padding: 7px 11px;
  min-height: 36px;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.08s, border-color 0.14s, background 0.14s;
  white-space: nowrap;
}

.btn:hover:not(:disabled) {
  border-color: var(--border-strong);
}

.btn:active:not(:disabled) {
  transform: scale(0.97);
}

.btn:disabled {
  opacity: 0.42;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--gold);
  color: var(--gold-ink);
  border-color: var(--gold);
  font-weight: 700;
}

.btn-ghost {
  background: transparent;
}

.btn-ghost:hover:not(:disabled) {
  background: var(--bg-elevated);
}

.btn-danger {
  border-color: rgba(240, 93, 108, 0.48);
  color: var(--danger);
}

.btn-toggle[aria-pressed="true"] {
  background: var(--gold-soft);
  border-color: var(--gold);
  color: var(--gold);
}

.btn-sm {
  padding: 5px 9px;
  min-height: 32px;
  font-size: 0.78rem;
}

.btn-icon {
  min-width: 36px;
  padding: 6px 8px;
}

/* Guided Pulse Ring (De zevende dag finite attention ring) */
@keyframes pulseRing {
  0%, 100% { box-shadow: 0 0 0 0 rgba(229, 179, 57, 0.65); }
  50% { box-shadow: 0 0 0 8px rgba(229, 179, 57, 0); }
}

.pulse-cta {
  animation: pulseRing 1.6s ease-out 5;
}

/* Music Pill */
.music-pill {
  display: inline-flex;
  align-items: center;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 2px;
  gap: 2px;
}

.music-pill .btn {
  border: none;
  min-height: 30px;
  padding: 4px 8px;
}

/* Context Subbar (only shown for Sandbox presets or AI Lab prompt bar) */
.subbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 7px 14px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.subbar-group {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
}

.ai-prompt-bar {
  display: flex;
  align-items: center;
  gap: 7px;
  flex: 1;
  min-width: 220px;
}

.ai-prompt-input {
  flex: 1;
  min-width: 150px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 7px 11px;
  font-size: 0.86rem;
  min-height: 36px;
}

.chip-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.chip {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
}

.chip:hover,
.chip.active {
  border-color: var(--gold);
  color: var(--gold);
  background: var(--gold-soft);
}

/* Full-bleed Game Stage */
.workspace {
  display: block;
  min-height: 0;
  overflow: hidden;
}

.stage-wrap {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
}

#stage-canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: grab;
}

#stage-canvas.dragging {
  cursor: grabbing;
}

/* Title / Opening Screen over Live Canvas */
.opening-screen {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: radial-gradient(circle at 50% 45%, rgba(7, 16, 33, 0.56), rgba(7, 16, 33, 0.82));
  z-index: 30;
  transition: opacity 0.28s ease-out;
}

[data-theme="workbench"] .opening-screen {
  background: radial-gradient(circle at 50% 45%, rgba(247, 244, 236, 0.62), rgba(232, 226, 212, 0.88));
}

.opening-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  max-width: 440px;
  width: 100%;
  padding: 32px 28px 26px;
  border-radius: 22px;
  background: var(--bg-surface);
  border: 1.5px solid var(--border-strong);
  box-shadow: var(--shadow);
}

.opening-emblem {
  margin-bottom: 10px;
}

.opening-title {
  font-size: 2.5rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  line-height: 1.05;
}

.opening-sub {
  margin: 10px 0 22px;
  font-size: 1rem;
  color: var(--text-muted);
  line-height: 1.45;
  max-width: 34ch;
}

.btn-opening-cta {
  width: 100%;
  max-width: 260px;
  min-height: 50px;
  font-size: 1.08rem;
  border-radius: 14px;
}

.opening-secondary {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
}

.opening-privacy {
  margin: 16px 0 0;
  font-size: 0.76rem;
  color: var(--text-muted);
  letter-spacing: 0.02em;
}

/* Top-Left Stack (Guide + Melder — flex column guarantees zero overlap at any wrap height) */
.top-left-stack {
  position: absolute;
  top: 12px;
  left: 12px;
  max-width: min(520px, calc(100% - 24px));
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  pointer-events: none;
  z-index: 15;
}

/* Floating Mentor Guide Bar (De zevende dag pattern — clean capsule, zero side-stripe border) */
.guide-bar {
  pointer-events: auto;
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px 8px 12px;
  border-radius: 14px;
  background: rgba(13, 27, 54, 0.94);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow);
}

[data-theme="workbench"] .guide-bar {
  background: rgba(255, 255, 255, 0.96);
}

.guide-avatar {
  position: relative;
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--gold-soft);
  display: flex;
  align-items: center;
  justify-content: center;
}

.guide-waves {
  position: absolute;
  bottom: -4px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 2px;
  opacity: 0;
  transition: opacity 0.18s;
}

.guide-bar.is-speaking .guide-waves {
  opacity: 1;
}

.guide-waves i {
  width: 3px;
  height: 6px;
  border-radius: 2px;
  background: var(--gold);
  display: block;
}

@keyframes voiceWave {
  0%, 100% { transform: scaleY(0.45); }
  50% { transform: scaleY(1.3); }
}

.guide-bar.is-speaking .guide-waves i:nth-child(1) { animation: voiceWave 0.65s infinite 0s; }
.guide-bar.is-speaking .guide-waves i:nth-child(2) { animation: voiceWave 0.65s infinite 0.16s; }
.guide-bar.is-speaking .guide-waves i:nth-child(3) { animation: voiceWave 0.65s infinite 0.32s; }

.guide-copy {
  flex: 1;
  min-width: 0;
}

.guide-text {
  margin: 0;
  font-size: 0.86rem;
  font-weight: 500;
  line-height: 1.38;
  color: var(--text);
}

.guide-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.guide-icon-btn {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  cursor: pointer;
  font-size: 0.92rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.guide-icon-btn:hover {
  border-color: var(--gold);
}

.guide-close-btn {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.8rem;
}

.guide-close-btn:hover {
  color: var(--text);
  background: var(--bg-elevated);
}

/* Red Alert 2-style Melder right below Guide inside top-left-stack */
.melder-toast {
  padding: 7px 14px;
  border-radius: 999px;
  background: var(--gold);
  color: var(--gold-ink);
  font-family: 'Schibsted Grotesk', 'Inter', sans-serif;
  font-size: 0.82rem;
  font-weight: 800;
  box-shadow: var(--shadow);
  pointer-events: none;
}

/* Floating X-Ray Legend (top-right so it never clashes with Guide on top-left) */
.xray-legend {
  position: absolute;
  top: 12px;
  right: 12px;
  background: rgba(10, 22, 45, 0.9);
  color: #F4F7FC;
  border: 1px solid rgba(229, 179, 57, 0.45);
  border-radius: 12px;
  padding: 8px 12px;
  font-size: 0.74rem;
  pointer-events: none;
  z-index: 12;
}

.xray-title {
  font-weight: 700;
  color: #E5B339;
  margin-bottom: 4px;
}

.xray-items {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.xray-items span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.xray-items em {
  font-style: normal;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

.dot-vel { background: #4ADE80; }
.dot-force { background: #E5B339; }
.dot-contact { background: #22D3EE; }
.dot-com { background: #FFFFFF; }

.link-banner {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-elevated);
  border: 1px solid var(--gold);
  border-radius: 12px;
  padding: 8px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.82rem;
  box-shadow: var(--shadow);
  z-index: 16;
  max-width: calc(100% - 24px);
}

/* On-demand Floating Part Inspector Drawer */
.inspector-drawer {
  position: absolute;
  right: 12px;
  bottom: 52px;
  width: min(290px, calc(100% - 24px));
  max-height: 62%;
  overflow-y: auto;
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  padding: 12px 14px;
  box-shadow: var(--shadow);
  z-index: 14;
}

.inspector-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.part-actions {
  position: absolute;
  bottom: 48px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  padding: 6px 8px;
  box-shadow: var(--shadow);
  z-index: 13;
  max-width: calc(100% - 20px);
  overflow-x: auto;
}

.stage-hud {
  position: absolute;
  bottom: 10px;
  left: 12px;
  right: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  pointer-events: none;
}

.stage-hud-right {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
}

.hud-pill {
  background: rgba(10, 22, 45, 0.82);
  color: #E2E8F0;
  border: 1px solid rgba(147, 197, 253, 0.25);
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 0.78rem;
  font-weight: 700;
}

[data-theme="workbench"] .hud-pill {
  background: rgba(255, 255, 255, 0.94);
  color: #132240;
  border-color: rgba(20, 48, 94, 0.22);
}

.hud-gold {
  border-color: var(--border-strong);
  color: var(--gold);
}

.hud-btn {
  pointer-events: auto;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 5px 11px;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
}

/* Win Celebration Overlay */
.win-overlay {
  position: absolute;
  inset: 0;
  background: rgba(7, 16, 33, 0.62);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 20;
}

.win-card {
  background: var(--bg-surface);
  border: 1.5px solid var(--gold);
  border-radius: 18px;
  padding: 26px 28px;
  text-align: center;
  max-width: 430px;
  width: 100%;
  box-shadow: var(--shadow);
}

.win-spark {
  font-size: 2.2rem;
  color: var(--gold);
  margin-bottom: 6px;
}

.win-card h2 {
  font-size: 1.48rem;
  margin-bottom: 6px;
}

.win-card p {
  margin: 0 0 10px;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.win-voice-line {
  color: var(--gold) !important;
  font-weight: 600;
  margin-bottom: 18px !important;
}

.win-buttons {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
}

/* Tactile Bottom Parts Tray */
.toolbox-dock {
  background: var(--bg-surface);
  border-top: 1px solid var(--border);
  padding: 7px 14px calc(9px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 6px;
  z-index: 18;
}

.toolbox-cats {
  display: flex;
  align-items: center;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
}

.toolbox-cats:empty {
  display: none;
}

.toolbox-cats::-webkit-scrollbar {
  display: none;
}

.toolbox-strip {
  display: flex;
  align-items: stretch;
  justify-content: center;
  gap: 10px;
  overflow-x: auto;
  padding: 3px 2px;
}

.part-tile {
  flex: 0 0 auto;
  min-width: 126px;
  min-height: 58px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 13px;
  background: var(--bg-card);
  border: 1.5px solid var(--border);
  border-radius: 13px;
  cursor: grab;
  touch-action: none;
  text-align: left;
  position: relative;
  transition: border-color 0.14s, transform 0.1s;
}

.part-tile:hover:not(:disabled) {
  border-color: var(--gold);
  transform: translateY(-2px);
}

.part-tile:disabled {
  opacity: 0.36;
  cursor: not-allowed;
}

.part-swatch {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.98rem;
  font-weight: 700;
  border: 1.5px solid rgba(255, 255, 255, 0.28);
}

.part-meta {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.part-title {
  font-size: 0.84rem;
  font-weight: 700;
  line-height: 1.15;
}

.part-sub {
  font-size: 0.71rem;
  color: var(--text-muted);
}

.part-count {
  position: absolute;
  top: -7px;
  right: -7px;
  background: var(--gold);
  color: var(--gold-ink);
  font-size: 0.73rem;
  font-weight: 800;
  min-width: 23px;
  height: 23px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
}

/* Shared Panel/Modal Components */
.panel-muted {
  font-size: 0.83rem;
  color: var(--text-muted);
  line-height: 1.46;
  margin: 0;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-top: 8px;
}

.metric-box {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 6px 8px;
}

.metric-label {
  font-size: 0.68rem;
  color: var(--text-muted);
  display: block;
}

.metric-val {
  font-size: 0.86rem;
  font-weight: 700;
}

.slider-row {
  margin-top: 10px;
}

.slider-head {
  display: flex;
  justify-content: space-between;
  font-size: 0.78rem;
  margin-bottom: 4px;
}

.slider-row input[type="range"] {
  width: 100%;
  accent-color: var(--gold);
  cursor: pointer;
}

/* Modals */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(5, 11, 24, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 40;
}

.modal-sheet {
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  border-radius: 18px;
  width: 100%;
  max-width: 720px;
  max-height: 86dvh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}

.modal-header h2 {
  font-size: 1.14rem;
}

.modal-body {
  padding: 16px 18px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* Inventor's Journey World Map (replaces generic puzzle grid) */
.map-progress-wrap {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex-shrink: 0;
}

.map-progress-track {
  width: 100%;
  height: 8px;
  border-radius: 999px;
  background: var(--bg-input);
  overflow: hidden;
  border: 1px solid var(--border);
}

.map-progress-fill {
  height: 100%;
  background: var(--gold);
  border-radius: 999px;
  transition: width 0.25s ease-out;
}

.chapter-stage {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 14px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  flex-shrink: 0;
}

.chapter-stage h3 {
  font-size: 0.92rem;
  color: var(--gold);
}

.map-nodes {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}

.map-node {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 10px 6px;
  border-radius: 12px;
  background: var(--bg-surface);
  border: 1.5px solid var(--border);
  cursor: pointer;
  text-align: center;
  transition: border-color 0.14s, transform 0.1s;
}

.map-node:hover {
  border-color: var(--gold);
  transform: translateY(-1px);
}

.map-node.current {
  border-color: var(--gold);
  background: var(--gold-soft);
}

.map-node.solved .map-badge {
  background: var(--ok);
  color: #052E16;
}

.map-badge {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 800;
}

.map-node-name {
  font-size: 0.74rem;
  font-weight: 600;
  line-height: 1.2;
}

/* Menu Sheet Rows */
.menu-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.menu-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 14px;
  border-radius: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  cursor: pointer;
  text-align: left;
  font-size: 0.9rem;
  font-weight: 600;
}

.menu-row:hover {
  border-color: var(--gold);
}

.menu-row-val {
  font-size: 0.8rem;
  color: var(--gold);
  font-weight: 700;
}

/* Under the Hood */
.hood-metrics {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  flex-shrink: 0;
}

.energy-chart {
  width: 100%;
  height: 92px;
  min-height: 92px;
  flex: 0 0 92px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 10px;
  display: block;
}

.hood-cards {
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex-shrink: 0;
}

.hood-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
}

.hood-card h4 {
  margin: 0 0 6px;
  font-size: 0.95rem;
}

.hood-formula {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 7px;
  background: var(--gold-soft);
  color: var(--gold);
  font-size: 0.8rem;
  font-weight: 600;
  margin-bottom: 6px;
}

.hood-card p {
  margin: 0 0 5px;
  font-size: 0.84rem;
  line-height: 1.48;
}

.hood-card .hood-why {
  color: var(--text-muted);
  margin-bottom: 0;
}

/* Jukebox Track List & Strudel Box */
.track-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex-shrink: 0;
}

.track-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 9px 12px;
  cursor: pointer;
  text-align: left;
}

.track-row:hover,
.track-row.active {
  border-color: var(--gold);
  background: var(--gold-soft);
}

.track-row-title {
  font-size: 0.88rem;
  font-weight: 700;
}

.track-row-sub {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.track-bpm {
  font-size: 0.74rem;
  font-weight: 700;
  color: var(--gold);
  white-space: nowrap;
}

.strudel-box {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 0.78rem;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
  margin: 8px 0;
}

.file-hidden {
  display: none;
}

/* Coach Output Box (clean full border, zero side-stripe) */
.coach-tiers {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.coach-output {
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 0.88rem;
  line-height: 1.48;
}

/* Feedback Form */
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field label {
  font-size: 0.82rem;
  font-weight: 600;
}

.field textarea {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 0.88rem;
  min-height: 96px;
  resize: vertical;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.84rem;
  cursor: pointer;
}

.visitor-bar {
  font-size: 0.82rem;
  color: var(--gold);
  font-weight: 700;
  padding: 9px 12px;
  border-radius: 10px;
  background: var(--gold-soft);
}

/* Toast */
.toast {
  position: fixed;
  bottom: 84px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-elevated);
  border: 1px solid var(--gold);
  color: var(--text);
  padding: 9px 16px;
  border-radius: 999px;
  font-size: 0.84rem;
  font-weight: 600;
  box-shadow: var(--shadow);
  z-index: 50;
}

/* Responsive Tablet & Mobile */
@media (max-width: 760px) {
  .map-nodes {
    grid-template-columns: repeat(3, 1fr);
  }

  .hood-metrics {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 640px) {
  .topbar {
    padding: 6px 8px;
    gap: 6px;
  }

  .brand-name {
    display: none;
  }

  .level-pill {
    display: block;
    padding: 6px 12px;
    font-size: 0.78rem;
    max-width: 168px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .tab-btn {
    padding: 4px 8px;
    font-size: 0.75rem;
    min-height: 28px;
  }

  .btn-play-hero {
    padding: 7px 14px;
    min-height: 36px;
    font-size: 0.84rem;
  }

  .btn {
    padding: 6px 8px;
    min-height: 34px;
    font-size: 0.77rem;
  }

  .top-left-stack {
    top: 8px;
    left: 8px;
    right: 8px;
    max-width: none;
  }

  .guide-bar {
    padding: 7px 8px;
    gap: 8px;
  }

  .guide-text {
    font-size: 0.79rem;
  }

  .melder-toast {
    font-size: 0.76rem;
  }

  .xray-legend {
    top: auto;
    bottom: 44px;
    right: 8px;
    max-width: calc(100% - 16px);
  }

  .stage-wrap.has-part-actions .xray-legend {
    opacity: 0;
    pointer-events: none;
  }

  .toolbox-strip {
    justify-content: flex-start;
  }

  .part-tile {
    min-width: 104px;
    min-height: 50px;
    padding: 6px 9px;
  }

  .part-actions {
    bottom: 56px;
  }

  .hud-pill {
    max-width: 58vw;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
    animation: none !important;
  }
}
