:root {
  --ink: #17233d;
  --muted: #69718a;
  --paper: #f8f3e8;
  --cream: #fffaf0;
  --coral: #ff6d5f;
  --yellow: #ffc857;
  --blue: #4e8cff;
  --mint: #4ec9a5;
  --purple: #9b7ef8;
  --shadow: 0 18px 48px rgba(24, 35, 61, .14);
  --border: 3px solid var(--ink);
}

* { box-sizing: border-box; }

html {
  min-width: 320px;
  background: var(--paper);
  color: var(--ink);
  font-family: "Hiragino Kaku Gothic ProN", "Yu Gothic", Meiryo, system-ui, sans-serif;
  overscroll-behavior: none;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  overflow-x: hidden;
  background:
    linear-gradient(rgba(23, 35, 61, .035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(23, 35, 61, .035) 1px, transparent 1px),
    var(--paper);
  background-size: 28px 28px;
  -webkit-tap-highlight-color: transparent;
}

button { font: inherit; color: inherit; }
button:not(:disabled) { cursor: pointer; }
button:focus-visible { outline: 4px solid rgba(78, 140, 255, .45); outline-offset: 3px; }
[hidden] { display: none !important; }

.app-shell { min-height: 100dvh; }

.topbar {
  position: relative;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: min(1180px, calc(100% - 40px));
  height: 80px;
  margin: 0 auto;
  border-bottom: 2px solid rgba(23, 35, 61, .15);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  border: 0;
  padding: 6px 0;
  background: transparent;
  text-align: left;
}

.brand-mark {
  position: relative;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 3px;
  width: 45px;
  height: 45px;
  padding: 8px;
  border: 2px solid var(--ink);
  border-radius: 12px;
  background: var(--yellow);
  box-shadow: 3px 3px 0 var(--ink);
}

.brand-mark i { display: block; width: 6px; border: 2px solid var(--ink); border-bottom: 0; background: var(--cream); }
.brand-mark i:nth-child(1) { height: 12px; }
.brand-mark i:nth-child(2) { height: 22px; }
.brand-mark i:nth-child(3) { height: 17px; }
.brand b { display: block; font-size: 16px; letter-spacing: .08em; }
.brand small { display: block; margin-top: 1px; color: var(--muted); font-size: 9px; font-weight: 800; letter-spacing: .1em; }

.top-actions { display: flex; gap: 8px; }
.icon-button,
.pause-button {
  min-height: 42px;
  border: 2px solid var(--ink);
  border-radius: 13px;
  background: rgba(255, 250, 240, .88);
  box-shadow: 2px 2px 0 var(--ink);
  font-size: 14px;
  font-weight: 900;
}
.icon-button { min-width: 78px; padding: 7px 11px; }
.icon-button:hover, .pause-button:hover { transform: translate(-1px, -1px); box-shadow: 3px 3px 0 var(--ink); }
.icon-button:active, .pause-button:active { transform: translate(2px, 2px); box-shadow: none; }

main { width: min(1180px, calc(100% - 40px)); margin: 0 auto; }
.screen { min-height: calc(100dvh - 80px); }

/* Home */
.home-screen {
  display: grid;
  grid-template-columns: minmax(430px, .9fr) minmax(520px, 1.1fr);
  align-items: center;
  gap: 42px;
  padding: 42px 0 55px;
}

.eyebrow, .modal-eyebrow {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 0 0 16px;
  color: var(--coral);
  font-size: 12px;
  font-weight: 950;
  letter-spacing: .16em;
}
.eyebrow span { width: 28px; height: 4px; border-radius: 9px; background: var(--coral); }

h1 {
  margin: 0;
  font-size: clamp(42px, 5vw, 70px);
  line-height: 1.03;
  letter-spacing: -.055em;
}
h1 em { color: var(--coral); font-style: normal; white-space: nowrap; }
.lead { margin: 21px 0 26px; color: #46506a; font-size: 17px; font-weight: 700; line-height: 1.85; }

.home-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  max-width: 490px;
  margin: 0 0 24px;
  border: 2px solid var(--ink);
  border-radius: 16px;
  background: rgba(255, 250, 240, .84);
  box-shadow: 4px 4px 0 rgba(23, 35, 61, .14);
  overflow: hidden;
}
.home-stats > div { padding: 12px 15px; }
.home-stats > div + div { border-left: 1px dashed rgba(23, 35, 61, .28); }
.home-stats small { display: block; color: var(--muted); font-size: 10px; font-weight: 900; }
.home-stats strong { display: block; margin-top: 2px; font-size: 22px; }
.home-stats strong i { color: var(--muted); font-size: 12px; font-style: normal; }

.mode-actions { display: flex; flex-wrap: wrap; align-items: stretch; gap: 10px; max-width: 560px; }
.primary-button, .secondary-button {
  border: var(--border);
  border-radius: 16px;
  font-weight: 950;
  transition: transform .14s ease, box-shadow .14s ease;
}
.primary-button {
  display: flex;
  flex: 1 1 300px;
  align-items: center;
  justify-content: space-between;
  min-height: 70px;
  padding: 10px 14px 10px 18px;
  background: var(--coral);
  color: white;
  box-shadow: 5px 5px 0 var(--ink);
  text-align: left;
}
.primary-button small { display: block; margin-bottom: 2px; color: #ffe9d9; font-size: 10px; }
.primary-button b { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 11px; background: var(--cream); color: var(--ink); font-size: 22px; }
.secondary-button { flex: 0 1 210px; min-height: 70px; padding: 12px 18px; background: var(--yellow); box-shadow: 5px 5px 0 var(--ink); }
.primary-button:hover, .secondary-button:hover { transform: translate(-2px, -2px); box-shadow: 7px 7px 0 var(--ink); }
.primary-button:active, .secondary-button:active { transform: translate(4px, 4px); box-shadow: 1px 1px 0 var(--ink); }
.control-note { margin: 14px 0 0; color: var(--muted); font-size: 11px; font-weight: 800; }

.hero-terminal {
  position: relative;
  width: min(100%, 610px);
  aspect-ratio: 1.08;
  justify-self: end;
  border: 3px solid var(--ink);
  border-radius: 38px;
  background: #1f2f50;
  box-shadow: 13px 15px 0 #d9cfbc, var(--shadow);
  overflow: hidden;
  isolation: isolate;
}
.hero-terminal::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: radial-gradient(circle at 20% 20%, rgba(255, 255, 255, .12) 0 2px, transparent 3px) 0 0/30px 30px;
  opacity: .5;
}
.terminal-glow { position: absolute; left: 28%; top: 20%; width: 45%; height: 48%; border-radius: 50%; background: rgba(78, 201, 165, .14); filter: blur(30px); }
.input-rack { position: absolute; left: 7%; top: 7%; display: flex; align-items: center; gap: 7px; }
.input-rack small, .output-ticket small { margin-right: 4px; color: #acb8d3; font-size: 10px; font-weight: 900; letter-spacing: .12em; }
.demo-chip, .demo-slots i, .output-ticket b {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 2px solid #0e1830;
  border-radius: 10px;
  color: #17233d;
  box-shadow: 3px 3px 0 #0e1830;
  font-size: 16px;
  font-style: normal;
  font-weight: 950;
}
.chip-coral { background: #ff7f72; }
.chip-yellow { background: #ffd36f; }
.chip-blue { background: #75a7ff; }
.chip-mint { background: #6fdbbd; }

.demo-robot { position: absolute; left: 40%; top: 27%; width: 116px; height: 154px; filter: drop-shadow(0 9px 0 rgba(9, 18, 36, .3)); }
.demo-robot .antenna { position: absolute; left: 54px; top: -20px; width: 8px; height: 26px; border-radius: 5px; background: var(--cream); }
.demo-robot .antenna::before { content: ""; position: absolute; left: -7px; top: -9px; width: 20px; height: 20px; border: 3px solid #0e1830; border-radius: 50%; background: var(--yellow); }
.demo-robot .face { position: relative; display: flex; align-items: center; justify-content: center; gap: 26px; width: 116px; height: 86px; border: 4px solid #0e1830; border-radius: 32px; background: var(--cream); }
.demo-robot .face i { width: 11px; height: 15px; border-radius: 50%; background: var(--ink); }
.demo-robot .face b { position: absolute; bottom: 13px; left: 51px; font-size: 17px; }
.demo-robot .body { display: grid; place-items: center; width: 78px; height: 66px; margin: -3px auto 0; border: 4px solid #0e1830; border-radius: 6px 6px 23px 23px; background: var(--coral); color: white; font-size: 21px; font-weight: 950; }
.demo-robot .ear { position: absolute; top: 30px; width: 18px; height: 33px; border: 3px solid #0e1830; background: var(--blue); }
.demo-robot .ear.left { left: -14px; border-radius: 12px 3px 3px 12px; }
.demo-robot .ear.right { right: -14px; border-radius: 3px 12px 12px 3px; }

.demo-dock { position: absolute; bottom: 15%; width: 40%; min-height: 150px; padding: 14px; border: 3px solid #0e1830; border-radius: 18px; box-shadow: 5px 6px 0 #0e1830; }
.stack-demo { left: 6%; background: #eef4ff; }
.queue-demo { right: 6%; background: #e9fff7; }
.dock-label { display: grid; grid-template-columns: 31px 1fr; align-items: center; column-gap: 7px; }
.dock-label > span { grid-row: span 2; display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: var(--ink); color: white; }
.dock-label b { font-size: 14px; }
.dock-label small { color: var(--muted); font-size: 8px; font-weight: 800; }
.demo-slots { display: flex; flex-direction: column; align-items: center; gap: 3px; min-height: 75px; margin-top: 9px; padding: 6px; border: 2px dashed rgba(23, 35, 61, .28); border-radius: 10px; }
.demo-slots.row { flex-direction: row; justify-content: center; }
.demo-slots i { width: 31px; height: 31px; border-radius: 8px; box-shadow: 2px 2px 0 #0e1830; font-size: 13px; }
.output-ticket { position: absolute; left: 16%; right: 16%; bottom: 4%; display: flex; align-items: center; justify-content: center; gap: 6px; padding: 8px; border: 2px solid #0e1830; border-radius: 12px; background: var(--cream); box-shadow: 4px 4px 0 #0e1830; }
.output-ticket b { width: 25px; height: 25px; border-radius: 6px; box-shadow: none; font-size: 11px; }
.output-ticket b:nth-of-type(1) { background: #75a7ff; }
.output-ticket b:nth-of-type(2) { background: #ff7f72; }
.output-ticket b:nth-of-type(3) { background: #ffd36f; }
.output-ticket b:nth-of-type(4) { background: #6fdbbd; }
.output-ticket > span { color: var(--mint); font-weight: 950; }
.route-line { position: absolute; z-index: -1; height: 3px; background: repeating-linear-gradient(90deg, #94a3be 0 8px, transparent 8px 15px); transform-origin: left; }
.route-line-a { left: 47%; top: 45%; width: 180px; transform: rotate(37deg); }
.route-line-b { left: 47%; top: 48%; width: 180px; transform: rotate(143deg); }
.float-tag { position: absolute; padding: 4px 9px; border: 2px solid #0e1830; border-radius: 999px; background: var(--yellow); font-size: 9px; font-weight: 950; box-shadow: 2px 2px 0 #0e1830; }
.tag-one { left: 4%; top: 45%; transform: rotate(-8deg); }
.tag-two { right: 4%; top: 42%; transform: rotate(7deg); background: var(--mint); }

/* Game */
.game-screen { padding: 18px 0 34px; }
.game-hud { display: grid; grid-template-columns: 1.5fr repeat(3, 1fr) auto; gap: 9px; align-items: stretch; }
.stage-id, .hud-stat, .pause-button {
  border: 2px solid var(--ink);
  border-radius: 14px;
  background: rgba(255, 250, 240, .92);
  box-shadow: 3px 3px 0 rgba(23, 35, 61, .16);
}
.stage-id, .hud-stat { padding: 9px 13px; }
.stage-id small, .hud-stat small { display: block; color: var(--muted); font-size: 9px; font-weight: 900; letter-spacing: .12em; }
.stage-id strong { display: block; margin-top: 1px; font-size: 18px; letter-spacing: .08em; }
.stage-id i { color: var(--muted); font-size: 11px; font-style: normal; }
.hud-stat { text-align: center; }
.hud-stat b { display: block; margin-top: 1px; font-size: 18px; }
.hud-stat b i { color: var(--muted); font-size: 10px; font-style: normal; }
.integrity b { color: var(--coral); letter-spacing: .13em; }
.pause-button { min-width: 48px; }

.mission-card { display: grid; grid-template-columns: minmax(270px, .8fr) minmax(430px, 1.2fr); align-items: center; gap: 18px; margin: 13px 0; padding: 14px 18px; border: var(--border); border-radius: 19px; background: var(--ink); color: white; box-shadow: 5px 5px 0 #d6cbb8; }
.mission-copy { display: grid; grid-template-columns: auto 1fr; align-items: center; column-gap: 12px; }
.mission-copy h2 { grid-column: 2; margin: 0; font-size: 18px; }
.mission-copy p:last-child { grid-column: 2; margin: 3px 0 0; color: #bec7da; font-size: 11px; line-height: 1.5; }
.phase-pill { grid-row: span 2; margin: 0; padding: 7px 9px; border-radius: 10px; background: var(--coral); font-size: 9px; font-weight: 950; letter-spacing: .08em; writing-mode: vertical-rl; transform: rotate(180deg); }
.target-panel { min-width: 0; }
.target-panel small { display: block; margin-bottom: 6px; color: #aebad1; font-size: 9px; font-weight: 900; letter-spacing: .12em; }
.token-row { display: flex; gap: 6px; min-width: 0; }

.data-token {
  position: relative;
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 2px solid var(--ink);
  border-radius: 11px;
  background: var(--token-color, var(--yellow));
  color: var(--ink);
  box-shadow: 3px 3px 0 var(--ink);
  font-size: 16px;
  font-weight: 950;
  transition: transform .18s ease, opacity .18s ease;
}
.target-panel .data-token { width: 36px; height: 36px; border-color: #080f21; box-shadow: 2px 2px 0 #080f21; font-size: 13px; }
.target-panel .data-token.done { opacity: .24; transform: scale(.88); }
.target-panel .data-token.next::after { content: ""; position: absolute; inset: -6px; border: 2px solid white; border-radius: 14px; animation: targetPulse 1s ease-in-out infinite alternate; }
@keyframes targetPulse { to { inset: -9px; opacity: .35; } }

.terminal-board { display: grid; grid-template-columns: 180px 1fr 190px; gap: 12px; align-items: stretch; }
.incoming-panel, .dispatch-panel, .dock-card { border: var(--border); border-radius: 19px; background: rgba(255, 250, 240, .94); box-shadow: 5px 5px 0 rgba(23, 35, 61, .13); }
.incoming-panel, .dispatch-panel { display: flex; flex-direction: column; min-width: 0; padding: 13px; }
.section-heading, .dispatch-copy { display: flex; align-items: center; gap: 8px; }
.section-heading > span, .dispatch-copy > span { display: grid; place-items: center; width: 34px; height: 34px; border: 2px solid var(--ink); border-radius: 50%; background: var(--yellow); font-size: 10px; font-weight: 950; }
.section-heading b, .dispatch-copy b { display: block; font-size: 13px; }
.section-heading small, .dispatch-copy small { display: block; margin-top: 1px; color: var(--muted); font-size: 8px; font-weight: 800; }
.incoming-track { display: flex; flex-wrap: wrap; align-content: flex-start; gap: 5px; min-height: 94px; margin-top: 13px; padding: 9px; border: 2px dashed rgba(23, 35, 61, .2); border-radius: 12px; background: rgba(255, 255, 255, .55); }
.incoming-track .data-token, .delivered-track .data-token { width: 33px; height: 33px; border-width: 2px; border-radius: 8px; box-shadow: 2px 2px 0 var(--ink); font-size: 12px; }
.incoming-track .data-token.processed { opacity: .2; filter: grayscale(.8); }
.current-crate-wrap { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 117px; margin-top: auto; padding-top: 12px; }
.current-crate-wrap > span { margin-bottom: 8px; padding: 3px 9px; border-radius: 999px; background: var(--coral); color: white; font-size: 8px; font-weight: 950; }
.current-crate .data-token { width: 68px; height: 68px; border-width: 3px; border-radius: 18px; box-shadow: 5px 5px 0 var(--ink); font-size: 24px; animation: hoverCrate 1.4s ease-in-out infinite alternate; }
@keyframes hoverCrate { to { transform: translateY(-4px) rotate(1.5deg); } }
.current-crate .waiting-copy { padding: 12px 0; color: var(--muted); font-size: 11px; font-weight: 900; text-align: center; }

.dock-grid { position: relative; display: grid; grid-template-columns: 1fr 32px 1fr; gap: 8px; min-width: 0; }
.dock-card { display: flex; flex-direction: column; min-width: 0; padding: 13px; }
.dock-card header { display: grid; grid-template-columns: 38px 1fr auto; align-items: center; gap: 8px; }
.dock-icon { display: grid; place-items: center; width: 38px; height: 38px; border: 2px solid var(--ink); border-radius: 12px; background: var(--blue); color: white; font-size: 20px; font-weight: 950; }
.queue-card .dock-icon { background: var(--mint); }
.dock-card header b { display: block; font-size: 14px; letter-spacing: .06em; }
.dock-card header small { display: block; color: var(--muted); font-size: 8px; font-weight: 800; }
.dock-card header i { display: grid; place-items: center; min-width: 27px; height: 27px; border: 2px solid var(--ink); border-radius: 999px; background: var(--cream); font-size: 11px; font-style: normal; font-weight: 950; }
.dock-bay { position: relative; display: flex; flex: 1; min-height: 154px; margin: 11px 0; padding: 10px; border: 2px dashed rgba(23, 35, 61, .28); border-radius: 13px; background: #f2f6ff; overflow: hidden; }
.stack-bay { flex-direction: column-reverse; align-items: center; justify-content: flex-start; gap: 3px; }
.queue-bay { align-items: center; justify-content: flex-start; gap: 4px; background: #effcf7; overflow-x: auto; }
.dock-bay:empty::after { content: "EMPTY"; position: absolute; left: 50%; top: 50%; color: rgba(23, 35, 61, .25); font-size: 11px; font-weight: 950; letter-spacing: .12em; transform: translate(-50%, -50%); }
.dock-bay .data-token { width: 37px; height: 37px; border-radius: 9px; box-shadow: 2px 2px 0 var(--ink); font-size: 13px; }
.stack-bay .data-token { width: min(92%, 112px); height: 31px; }
.dock-divider { display: flex; align-items: center; justify-content: center; }
.dock-divider::before { content: ""; position: absolute; top: 18%; bottom: 18%; width: 2px; border-left: 2px dashed rgba(23, 35, 61, .23); }
.dock-divider span { z-index: 1; padding: 6px 4px; border: 2px solid var(--ink); border-radius: 999px; background: var(--paper); font-size: 8px; font-weight: 950; }
.dock-button { display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 51px; border: 2px solid var(--ink); border-radius: 13px; background: var(--blue); color: white; box-shadow: 3px 3px 0 var(--ink); font-size: 12px; font-weight: 950; touch-action: manipulation; }
.queue-button { background: #31ae8b; }
.dock-button kbd { padding: 3px 5px; border: 1px solid rgba(255,255,255,.65); border-radius: 5px; background: rgba(0,0,0,.13); font-family: inherit; font-size: 8px; }
.dock-button:hover:not(:disabled) { transform: translate(-1px, -1px); box-shadow: 4px 4px 0 var(--ink); }
.dock-button:active:not(:disabled) { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--ink); }
.dock-button:disabled { cursor: not-allowed; opacity: .35; filter: grayscale(.6); }
.dock-card.recommended { box-shadow: 0 0 0 5px var(--yellow), 5px 5px 0 rgba(23, 35, 61, .13); animation: recommend 1s ease-in-out infinite alternate; }
@keyframes recommend { to { box-shadow: 0 0 0 8px rgba(255, 200, 87, .5), 5px 5px 0 rgba(23, 35, 61, .13); } }

.dispatch-panel { justify-content: space-between; }
.dispatch-copy > span { background: var(--coral); color: white; }
.delivered-track { display: flex; flex-wrap: wrap; align-content: flex-start; gap: 5px; min-height: 195px; margin-top: 13px; padding: 9px; border: 2px dashed rgba(23, 35, 61, .2); border-radius: 12px; background: rgba(255, 255, 255, .55); }
.delivered-track .data-token { animation: delivered .25s ease both; }
@keyframes delivered { from { transform: translateY(-16px) scale(.6); opacity: 0; } }
.delivered-track .empty-copy { align-self: center; width: 100%; color: rgba(23,35,61,.35); font-size: 10px; font-weight: 900; text-align: center; }

.utility-bar { display: flex; align-items: center; gap: 8px; margin-top: 13px; }
.utility-bar button { min-height: 42px; padding: 8px 12px; border: 2px solid var(--ink); border-radius: 11px; background: var(--cream); box-shadow: 2px 2px 0 var(--ink); font-size: 11px; font-weight: 900; }
.utility-bar button:disabled { opacity: .4; cursor: not-allowed; }
.utility-bar kbd { color: var(--muted); font-family: inherit; font-size: 8px; }
.utility-bar p { flex: 1; min-height: 18px; margin: 0 0 0 8px; color: #58627b; font-size: 11px; font-weight: 800; text-align: right; }
.terminal-board.error { animation: boardError .3s ease; }
@keyframes boardError { 30% { transform: translateX(-7px); } 65% { transform: translateX(7px); } }

/* Modal and overlays */
dialog { width: min(590px, calc(100% - 28px)); max-height: calc(100dvh - 28px); padding: 0; border: 0; background: transparent; overflow: visible; }
dialog::backdrop { background: rgba(11, 18, 34, .68); backdrop-filter: blur(5px); }
.modal-card { position: relative; max-height: calc(100dvh - 28px); padding: 28px; border: var(--border); border-radius: 24px; background: var(--cream); box-shadow: 9px 9px 0 #0d162a; overflow-y: auto; }
.modal-close { position: absolute; right: 15px; top: 15px; display: grid; place-items: center; width: 38px; height: 38px; border: 2px solid var(--ink); border-radius: 50%; background: white; box-shadow: 2px 2px 0 var(--ink); font-size: 22px; font-weight: 950; }
.modal-eyebrow { margin-bottom: 7px; }
.modal-card h2 { margin: 0 42px 17px 0; font-size: clamp(25px, 6vw, 36px); line-height: 1.2; }
.modal-card p { color: #505a72; font-size: 13px; line-height: 1.75; }
.modal-actions { display: flex; flex-wrap: wrap; gap: 9px; margin-top: 20px; }
.modal-actions button { flex: 1 1 150px; min-height: 48px; padding: 9px 14px; border: 2px solid var(--ink); border-radius: 12px; background: white; box-shadow: 3px 3px 0 var(--ink); font-weight: 950; }
.modal-actions button.primary { background: var(--coral); color: white; }
.result-score { display: flex; align-items: end; justify-content: space-between; margin: 8px 0 16px; padding: 15px 18px; border: 2px solid var(--ink); border-radius: 15px; background: var(--yellow); box-shadow: 4px 4px 0 var(--ink); }
.result-score small { font-size: 10px; font-weight: 900; }
.result-score b { font-size: 36px; line-height: 1; }
.result-stars { color: #f5a623; font-size: 34px; letter-spacing: .1em; text-shadow: 2px 2px 0 var(--ink); -webkit-text-stroke: 1px var(--ink); }
.round-summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; margin: 12px 0; }
.round-summary div { padding: 10px; border: 2px solid var(--ink); border-radius: 11px; background: white; text-align: center; }
.round-summary small { display: block; color: var(--muted); font-size: 8px; font-weight: 900; }
.round-summary b { display: block; margin-top: 2px; font-size: 18px; }
.upgrade-grid { display: grid; gap: 9px; }
.upgrade-card { display: grid; grid-template-columns: 48px 1fr auto; align-items: center; gap: 10px; width: 100%; padding: 11px; border: 2px solid var(--ink); border-radius: 14px; background: white; box-shadow: 3px 3px 0 var(--ink); text-align: left; }
.upgrade-card > span { display: grid; place-items: center; width: 48px; height: 48px; border: 2px solid var(--ink); border-radius: 12px; background: var(--yellow); font-size: 24px; }
.upgrade-card b { display: block; font-size: 14px; }
.upgrade-card small { display: block; margin-top: 2px; color: var(--muted); font-size: 10px; line-height: 1.45; }
.upgrade-card i { font-size: 19px; font-style: normal; }
.upgrade-card:hover { transform: translate(-1px, -1px); box-shadow: 4px 4px 0 var(--ink); }
.help-steps { display: grid; gap: 10px; margin: 0; padding: 0; list-style: none; counter-reset: steps; }
.help-steps li { position: relative; padding: 12px 12px 12px 56px; border: 2px solid var(--ink); border-radius: 13px; background: white; font-size: 12px; line-height: 1.6; counter-increment: steps; }
.help-steps li::before { content: "0" counter(steps); position: absolute; left: 11px; top: 11px; display: grid; place-items: center; width: 33px; height: 33px; border-radius: 50%; background: var(--ink); color: white; font-size: 10px; font-weight: 950; }
.mini-lesson { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; margin-top: 13px; }
.mini-lesson div { padding: 11px; border-radius: 12px; background: #edf3ff; font-size: 11px; line-height: 1.55; }
.mini-lesson div:last-child { background: #e9faf4; }
.stamp-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.stamp-card { min-height: 107px; padding: 10px 5px; border: 2px solid var(--ink); border-radius: 13px; background: white; text-align: center; }
.stamp-card.locked { opacity: .34; filter: grayscale(1); }
.stamp-card span { display: block; font-size: 31px; }
.stamp-card b { display: block; margin-top: 4px; font-size: 10px; }
.stamp-card small { display: block; margin-top: 3px; color: var(--muted); font-size: 8px; }
.toast { position: fixed; z-index: 50; left: 50%; bottom: calc(18px + env(safe-area-inset-bottom)); padding: 10px 17px; border: 2px solid var(--ink); border-radius: 999px; background: var(--yellow); box-shadow: 3px 3px 0 var(--ink); font-size: 11px; font-weight: 950; opacity: 0; pointer-events: none; transform: translate(-50%, 20px); transition: opacity .2s ease, transform .2s ease; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.confetti { position: fixed; z-index: 100; top: -15px; width: 11px; height: 16px; border: 2px solid var(--ink); animation: fall 1.3s ease-in forwards; pointer-events: none; }
@keyframes fall { to { transform: translate(var(--drift), 105vh) rotate(760deg); } }

body.thumbnail-mode .topbar { height: 66px; }
body.thumbnail-mode .game-screen { min-height: 609px; padding-top: 12px; }
body.thumbnail-mode .utility-bar { display: none; }
body.thumbnail-mode .mission-card { margin: 10px 0; }
body.thumbnail-mode .dock-bay { min-height: 130px; }
body.thumbnail-mode .terminal-board { grid-template-columns: 170px 1fr 180px; }

@media (max-width: 930px) {
  .home-screen { grid-template-columns: 1fr; gap: 34px; padding-top: 34px; }
  .hero-copy { text-align: center; }
  .eyebrow { justify-content: center; }
  .home-stats, .mode-actions { margin-left: auto; margin-right: auto; }
  .hero-terminal { justify-self: center; width: min(100%, 600px); }
  .terminal-board { grid-template-columns: 150px 1fr; }
  .dock-grid { grid-column: 2; grid-row: span 2; }
  .dispatch-panel { grid-column: 1; }
}

@media (max-width: 680px) {
  body { background-size: 22px 22px; }
  .topbar, main { width: min(100% - 22px, 1180px); }
  .topbar { height: 68px; }
  .brand-mark { width: 39px; height: 39px; }
  .brand b { font-size: 13px; }
  .brand small { font-size: 7px; }
  .icon-button { min-width: 42px; width: 42px; padding: 5px; }
  .icon-button span { display: none; }
  .home-screen { min-height: calc(100dvh - 68px); padding: 28px 0 45px; }
  h1 { font-size: clamp(39px, 12vw, 58px); }
  h1 em { white-space: normal; }
  .lead { font-size: 14px; }
  .desktop-only { display: none; }
  .home-stats > div { padding: 10px 6px; }
  .home-stats small { font-size: 8px; }
  .home-stats strong { font-size: 18px; }
  .mode-actions { display: grid; }
  .primary-button, .secondary-button { min-height: 62px; width: 100%; }
  .hero-terminal { border-radius: 25px; }
  .demo-dock { min-height: 122px; padding: 8px; }
  .demo-robot { top: 25%; transform: scale(.78); transform-origin: top center; }
  .input-rack { transform: scale(.75); transform-origin: left center; }
  .demo-slots { min-height: 55px; }
  .output-ticket { left: 9%; right: 9%; }
  .game-screen { min-height: calc(100dvh - 68px); padding-top: 10px; }
  .game-hud { grid-template-columns: 1.3fr repeat(3, .75fr) auto; gap: 4px; }
  .stage-id, .hud-stat { padding: 7px 5px; }
  .stage-id small, .hud-stat small { font-size: 6px; }
  .stage-id strong, .hud-stat b { font-size: 13px; }
  .pause-button { min-width: 39px; }
  .mission-card { grid-template-columns: 1fr; gap: 10px; margin: 9px 0; padding: 10px 12px; }
  .mission-copy h2 { font-size: 15px; }
  .mission-copy p:last-child { font-size: 9px; }
  .phase-pill { padding: 5px 7px; }
  .target-panel .data-token { width: min(34px, calc((100vw - 79px) / 8)); height: min(34px, calc((100vw - 79px) / 8)); border-radius: 8px; box-shadow: 1px 1px 0 #080f21; font-size: 10px; }
  .token-row { gap: 4px; }
  .terminal-board { display: block; }
  .incoming-panel { display: grid; grid-template-columns: 1fr 78px; min-height: 104px; padding: 9px; }
  .section-heading { grid-column: 1 / -1; }
  .incoming-track { min-height: 48px; margin-top: 7px; padding: 5px; }
  .incoming-track .data-token { width: 27px; height: 27px; font-size: 9px; }
  .current-crate-wrap { grid-column: 2; grid-row: 2; min-height: 55px; padding: 3px 0 0 7px; }
  .current-crate-wrap > span { margin-bottom: 3px; }
  .current-crate .data-token { width: 48px; height: 48px; border-radius: 12px; box-shadow: 3px 3px 0 var(--ink); font-size: 17px; }
  .dock-grid { display: grid; grid-template-columns: 1fr 20px 1fr; margin: 8px 0; }
  .dock-card { padding: 8px; border-radius: 15px; }
  .dock-card header { grid-template-columns: 31px 1fr auto; gap: 4px; }
  .dock-icon { width: 31px; height: 31px; font-size: 15px; }
  .dock-card header b { font-size: 11px; }
  .dock-card header small { font-size: 6px; }
  .dock-card header i { min-width: 22px; height: 22px; font-size: 8px; }
  .dock-bay { min-height: 108px; margin: 7px 0; padding: 6px; }
  .dock-bay .data-token { width: 30px; height: 30px; font-size: 10px; }
  .stack-bay .data-token { width: 86%; height: 24px; }
  .dock-button { min-height: 50px; padding: 5px; font-size: 10px; }
  .dock-button kbd { display: none; }
  .dispatch-panel { min-height: 86px; padding: 8px; }
  .delivered-track { min-height: 42px; margin-top: 7px; padding: 5px; }
  .delivered-track .data-token { width: 27px; height: 27px; font-size: 9px; }
  .utility-bar { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-bottom: calc(12px + env(safe-area-inset-bottom)); }
  .utility-bar button { min-height: 45px; padding: 7px 5px; font-size: 9px; }
  #restart-stage-button { grid-column: 1 / -1; }
  .utility-bar p { grid-column: 1 / -1; margin: 0; font-size: 9px; text-align: center; }
  .modal-card { padding: 23px 18px; border-radius: 20px; }
  .stamp-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 380px) {
  .brand small { display: none; }
  .game-hud { grid-template-columns: 1.3fr repeat(2, .78fr) auto; }
  .hud-stat.integrity { display: none; }
  .dock-card header small { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
