:root {
  color-scheme: dark;
  --bg-0: #02080e;
  --bg-1: #05121c;
  --bg-2: #091c2a;
  --panel: rgba(5, 19, 29, 0.92);
  --panel-strong: rgba(5, 22, 34, 0.98);
  --panel-soft: rgba(8, 31, 45, 0.76);
  --line: rgba(84, 229, 224, 0.24);
  --line-soft: rgba(150, 221, 236, 0.12);
  --text: #f3fbff;
  --muted: #91adbd;
  --muted-2: #5e7d8e;
  --accent: #40f1d0;
  --accent-strong: #12d9bf;
  --accent-blue: #52bfff;
  --warning: #ffcd6b;
  --danger: #ff6f88;
  --shadow-xl: 0 24px 80px rgba(0, 0, 0, 0.48);
  --shadow-inset: inset 0 1px 0 rgba(255, 255, 255, 0.055), inset 0 0 42px rgba(26, 164, 169, 0.035);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
}

* { box-sizing: border-box; }

html,
body {
  margin: 0;
  width: 100%;
  min-height: 100%;
  height: 100%;
  color: var(--text);
  background: var(--bg-0);
}

body {
  min-height: 100vh;
  overflow: hidden;
  letter-spacing: 0.01em;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
}

button,
kbd { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }
button:focus-visible { outline: 2px solid #ffffff; outline-offset: 3px; }

.ambient-layer {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  background:
    radial-gradient(circle at 18% 12%, rgba(37, 190, 202, 0.09), transparent 28%),
    radial-gradient(circle at 82% 6%, rgba(45, 122, 196, 0.1), transparent 31%),
    linear-gradient(155deg, #02070d 0%, #06131d 46%, #030a11 100%);
}

.ambient-grid {
  position: absolute;
  inset: 0;
  opacity: 0.18;
  background-image:
    linear-gradient(rgba(94, 205, 218, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(94, 205, 218, 0.035) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: linear-gradient(to bottom, rgba(0,0,0,.85), transparent 95%);
}

.ambient-orb {
  position: absolute;
  width: 34vw;
  height: 34vw;
  min-width: 360px;
  min-height: 360px;
  border-radius: 50%;
  filter: blur(90px);
  opacity: 0.11;
}
.orb-a { left: -10vw; top: 16vh; background: #0cc9c0; }
.orb-b { right: -12vw; bottom: -18vh; background: #145da8; }

.app-shell {
  position: relative;
  z-index: 1;
  width: min(1680px, 100%);
  height: 100vh;
  margin: 0 auto;
  padding: 14px clamp(14px, 2vw, 34px) 16px;
  display: flex;
  flex-direction: column;
}

.topbar {
  flex: 0 0 auto;
  min-height: 62px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 0 4px 11px;
}

.brand { display: flex; align-items: center; gap: 14px; min-width: 0; }
.brand-mark {
  position: relative;
  display: grid;
  place-items: center;
  width: 50px;
  height: 50px;
  flex: 0 0 auto;
  filter: drop-shadow(0 0 16px rgba(64, 241, 208, 0.36));
}
.brand-mark::before {
  content: "";
  position: absolute;
  inset: 4px;
  background: linear-gradient(145deg, rgba(72,255,220,.18), rgba(20,80,112,.2));
  clip-path: polygon(50% 0, 94% 23%, 94% 77%, 50% 100%, 6% 77%, 6% 23%);
}
.brand-mark svg { position: relative; width: 46px; height: 46px; fill: none; stroke: var(--accent); stroke-width: 2.4; }
.brand-copy { min-width: 0; }
.brand strong {
  display: block;
  font-size: clamp(18px, 2vw, 24px);
  font-weight: 850;
  letter-spacing: .075em;
  white-space: nowrap;
}
.brand small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: .105em;
  white-space: nowrap;
}

.top-actions { display: flex; align-items: center; gap: 9px; }
.icon-btn,
.secondary-btn,
.danger-btn,
.primary-btn,
.fold-btn,
.dpad button,
.level-btn,
.tutorial-skip,
.tutorial-next,
.tutorial-step {
  border: 1px solid var(--line-soft);
  color: var(--text);
  background: linear-gradient(180deg, rgba(15, 42, 57, .8), rgba(5, 19, 29, .92));
  cursor: pointer;
  transition: transform .16s ease, border-color .16s ease, background .16s ease, box-shadow .16s ease, opacity .16s ease, filter .16s ease;
}
.icon-btn:hover,
.secondary-btn:hover,
.fold-btn:hover,
.dpad button:hover,
.level-btn:hover,
.tutorial-skip:hover { transform: translateY(-1px); border-color: rgba(64, 241, 208, .58); }
.icon-btn {
  min-height: 40px;
  padding: 8px 13px;
  border-radius: 11px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  box-shadow: var(--shadow-inset);
}
.button-icon { color: var(--accent); font-weight: 900; }
.button-label { font-size: 12px; font-weight: 750; letter-spacing: .035em; }

.game-layout {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.mission-panel {
  position: relative;
  flex: 0 0 auto;
  overflow: hidden;
  padding: 14px 18px 12px;
  border: 1px solid var(--line);
  border-radius: 18px 18px 8px 18px;
  background:
    linear-gradient(100deg, rgba(7, 28, 42, .98), rgba(4, 18, 29, .96) 65%),
    rgba(4, 18, 29, .96);
  box-shadow: var(--shadow-inset), var(--shadow-xl);
}
.mission-panel::after {
  content: "";
  position: absolute;
  right: -140px;
  top: -180px;
  width: 430px;
  height: 430px;
  border: 1px solid rgba(64, 241, 208, .08);
  border-radius: 50%;
  box-shadow: 0 0 0 42px rgba(64, 241, 208, .014), 0 0 0 82px rgba(64, 241, 208, .012);
  pointer-events: none;
}
.mission-accent {
  position: absolute;
  left: 18px;
  right: 18px;
  top: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent) 12%, rgba(82,191,255,.8) 58%, transparent);
  box-shadow: 0 0 16px rgba(64, 241, 208, .55);
}
.mission-main { display: flex; justify-content: space-between; gap: 20px; align-items: flex-start; }
.mission-copy { min-width: 0; }
.mission-kicker-row { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; }
.eyebrow { color: var(--accent); font-size: 11px; letter-spacing: .17em; font-weight: 850; }
.system-status { color: var(--muted); font-size: 10px; letter-spacing: .07em; text-transform: uppercase; }
.system-status i { display: inline-block; width: 6px; height: 6px; margin-right: 5px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 9px var(--accent); }
h1 { margin: 5px 0 0; font-size: clamp(25px, 3vw, 38px); line-height: 1.02; letter-spacing: -.025em; }
.objective-text { max-width: 980px; margin: 7px 0 0; color: #bdd2de; line-height: 1.38; font-size: 13px; }
.mission-stats { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; position: relative; z-index: 1; }
.mission-stats span {
  min-width: 112px;
  padding: 9px 12px;
  border-radius: 10px 10px 4px 10px;
  color: #b9d2dd;
  background: linear-gradient(180deg, rgba(16, 48, 62, .76), rgba(5, 20, 30, .8));
  border: 1px solid rgba(64, 241, 208, .24);
  box-shadow: inset 0 0 18px rgba(64, 241, 208, .035);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .075em;
  white-space: nowrap;
  text-align: center;
}
.mission-stats b { color: #fff; font-size: 16px; }

.progress-row { display: flex; align-items: center; gap: 12px; margin-top: 11px; position: relative; z-index: 1; }
.progress-label { flex: 0 0 auto; color: var(--muted-2); font-size: 9px; font-weight: 850; letter-spacing: .16em; }
.progress-strip { min-width: 0; overflow-x: auto; padding: 1px 0 2px; scrollbar-width: none; }
.progress-strip::-webkit-scrollbar { display: none; }
.level-buttons { display: flex; gap: 7px; min-width: max-content; }
.level-btn {
  position: relative;
  min-width: 42px;
  height: 31px;
  padding: 0 10px;
  border-radius: 7px 7px 3px 7px;
  font-weight: 850;
  font-size: 11px;
  color: #8eabb9;
}
.level-btn.active {
  color: #02100e;
  background: linear-gradient(180deg, #73ffe2, #31dcbc);
  border-color: var(--accent);
  box-shadow: 0 0 18px rgba(64, 241, 208, .42), inset 0 1px rgba(255,255,255,.55);
}
.level-btn.completed::after { content: ""; position: absolute; right: 3px; top: 3px; width: 4px; height: 4px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 7px var(--accent); }
.level-btn.active.completed::after { background: #063e33; box-shadow: none; }
.level-btn:disabled { opacity: .28; cursor: not-allowed; transform: none; }

.play-area {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 332px;
  gap: 10px;
  align-items: stretch;
}

.canvas-wrap {
  position: relative;
  min-height: 0;
  height: 100%;
  overflow: hidden;
  border: 1px solid rgba(66, 220, 218, .35);
  border-radius: 18px 8px 18px 8px;
  background:
    linear-gradient(rgba(79, 191, 211, .038) 1px, transparent 1px),
    linear-gradient(90deg, rgba(79, 191, 211, .038) 1px, transparent 1px),
    radial-gradient(circle at center, rgba(12, 58, 79, .72), rgba(2, 10, 16, .98) 70%);
  background-size: 24px 24px, 24px 24px, auto;
  box-shadow: var(--shadow-inset), var(--shadow-xl), 0 0 0 1px rgba(3, 9, 14, .7);
  touch-action: manipulation;
}
.canvas-wrap::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 2;
  background: linear-gradient(90deg, rgba(48, 240, 218, .05), transparent 13%, transparent 87%, rgba(48, 240, 218, .05));
}
.canvas-toolbar {
  position: absolute;
  left: 18px;
  right: 18px;
  top: 10px;
  z-index: 4;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: rgba(152, 194, 207, .45);
  font-size: 8px;
  font-weight: 750;
  letter-spacing: .12em;
  text-transform: uppercase;
  pointer-events: none;
}
.canvas-toolbar i { display: inline-block; width: 5px; height: 5px; margin-right: 5px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 8px var(--accent); }
#gameCanvas { display: block; width: 100%; height: 100%; min-height: 0; }
.frame-corner { position: absolute; z-index: 4; width: 24px; height: 24px; pointer-events: none; opacity: .8; }
.frame-corner::before,
.frame-corner::after { content: ""; position: absolute; background: var(--accent); box-shadow: 0 0 8px rgba(64,241,208,.55); }
.frame-corner::before { width: 16px; height: 1px; }
.frame-corner::after { width: 1px; height: 16px; }
.frame-corner-tl { left: 11px; top: 11px; }
.frame-corner-tr { right: 11px; top: 11px; transform: rotate(90deg); }
.frame-corner-bl { left: 11px; bottom: 11px; transform: rotate(-90deg); }
.frame-corner-br { right: 11px; bottom: 11px; transform: rotate(180deg); }

.toast {
  position: absolute;
  left: 50%;
  bottom: 16px;
  z-index: 8;
  transform: translate(-50%, 10px);
  max-width: min(88%, 640px);
  padding: 10px 15px;
  border-radius: 8px;
  color: #dff9ff;
  background: rgba(2, 12, 19, .96);
  border: 1px solid rgba(64, 241, 208, .32);
  box-shadow: 0 12px 40px rgba(0,0,0,.36), inset 0 0 22px rgba(64,241,208,.04);
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s ease, transform .18s ease;
  text-align: center;
  font-size: 12px;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { border-color: rgba(255, 111, 136, .62); color: #ffe6eb; }

.control-panel {
  min-height: 0;
  overflow-y: auto;
  padding: 11px;
  display: flex;
  flex-direction: column;
  gap: 9px;
  border: 1px solid rgba(76, 215, 217, .28);
  border-radius: 8px 18px 8px 18px;
  background: linear-gradient(180deg, rgba(5, 21, 31, .98), rgba(3, 13, 21, .98));
  box-shadow: var(--shadow-inset), var(--shadow-xl);
  scrollbar-width: thin;
  scrollbar-color: rgba(64,241,208,.25) transparent;
}
.control-group {
  position: relative;
  padding: 11px;
  border: 1px solid rgba(117, 207, 219, .13);
  border-radius: 12px 4px 12px 4px;
  background: linear-gradient(180deg, rgba(10, 34, 46, .62), rgba(4, 18, 27, .74));
  box-shadow: var(--shadow-inset);
}
.control-heading { display: flex; justify-content: space-between; gap: 8px; align-items: center; margin-bottom: 9px; }
.control-heading > div,
.legend-heading { display: flex; align-items: center; gap: 8px; }
.control-heading span:not(.section-index),
.legend-heading span:not(.section-index) { color: #d9f8fb; font-size: 11px; font-weight: 850; letter-spacing: .07em; }
.control-heading small { color: var(--muted-2); font-size: 9px; text-align: right; }
.section-index {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 6px 2px 6px 2px;
  color: var(--accent);
  background: rgba(64, 241, 208, .06);
  border: 1px solid rgba(64, 241, 208, .22);
  font-size: 8px;
  font-weight: 900;
}

.fold-buttons { display: grid; gap: 7px; }
.fold-btn {
  width: 100%;
  min-height: 58px;
  padding: 9px 10px;
  text-align: left;
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) 20px;
  align-items: center;
  gap: 9px;
  border-radius: 10px 3px 10px 3px;
  overflow: hidden;
}
.fold-btn::after { content: "›"; color: var(--muted-2); font-size: 19px; text-align: right; }
.fold-btn .fold-icon {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 10px 3px 10px 3px;
  color: var(--accent);
  background: radial-gradient(circle, rgba(64,241,208,.18), rgba(64,241,208,.035));
  border: 1px solid rgba(64,241,208,.25);
  box-shadow: inset 0 0 18px rgba(64,241,208,.06);
  font-size: 18px;
  font-weight: 900;
}
.fold-btn strong { display: block; font-size: 12px; }
.fold-btn small { display: block; margin-top: 3px; color: var(--muted); font-size: 9px; }
.fold-btn.used { opacity: .34; cursor: not-allowed; }
.fold-btn.preview { border-color: rgba(255,205,107,.6); background: linear-gradient(180deg, rgba(69,55,25,.32), rgba(16,24,27,.86)); }
.fold-btn.selected {
  border-color: rgba(64,241,208,.72);
  background: linear-gradient(180deg, rgba(19,92,91,.42), rgba(5,32,39,.88));
  box-shadow: 0 0 0 1px rgba(64,241,208,.12), 0 0 22px rgba(64,241,208,.11), inset 0 0 26px rgba(64,241,208,.055);
}
.fold-btn.selected::after { content: "✓"; color: var(--accent); font-size: 13px; }

.action-group { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.action-group .primary-btn { grid-column: 1 / -1; }
.primary-btn {
  position: relative;
  min-height: 48px;
  padding: 11px 14px;
  overflow: hidden;
  border-color: rgba(81, 255, 220, .78);
  border-radius: 9px 3px 9px 3px;
  color: #02110e;
  background: linear-gradient(180deg, #76ffe0 0%, #39e1c0 56%, #20bea6 100%);
  box-shadow: 0 7px 22px rgba(26, 214, 182, .22), inset 0 1px 0 rgba(255,255,255,.68);
  font-weight: 950;
  font-size: 12px;
  letter-spacing: .055em;
}
.primary-btn:hover { transform: translateY(-1px); filter: brightness(1.06); }
.primary-glint { position: absolute; inset: 0; transform: translateX(-120%) skewX(-20deg); background: linear-gradient(90deg, transparent, rgba(255,255,255,.4), transparent); animation: glint 4.8s ease-in-out infinite; }
.primary-copy { position: relative; }
.secondary-btn,
.danger-btn { min-height: 40px; padding: 9px 10px; border-radius: 8px 3px 8px 3px; font-size: 10px; font-weight: 750; letter-spacing: .04em; }
.secondary-btn span { color: var(--accent); margin-right: 3px; }
.danger-btn { color: #ffdfe5; border-color: rgba(255,111,136,.28); background: rgba(72,20,31,.34); }
kbd { display: inline-grid; place-items: center; min-width: 20px; min-height: 18px; margin-left: 4px; padding: 1px 5px; border: 1px solid rgba(2,23,22,.35); border-bottom-width: 2px; border-radius: 4px; background: rgba(255,255,255,.17); font-size: .78em; font-weight: 900; }
.secondary-btn kbd { border-color: rgba(255,255,255,.12); background: rgba(255,255,255,.035); color: var(--muted); }
button:disabled { opacity: .34; cursor: not-allowed; transform: none !important; filter: none !important; }

.dpad { display: grid; grid-template-columns: repeat(3, 48px); grid-template-rows: repeat(2, 41px); justify-content: center; gap: 6px; }
.dpad button { border-radius: 9px 3px 9px 3px; color: var(--accent); font-size: 15px; box-shadow: inset 0 0 18px rgba(64,241,208,.025); }
.dpad button[data-dir="up"] { grid-column: 2; grid-row: 1; }
.dpad button[data-dir="left"] { grid-column: 1; grid-row: 2; }
.dpad button[data-dir="down"] { grid-column: 2; grid-row: 2; }
.dpad button[data-dir="right"] { grid-column: 3; grid-row: 2; }

.legend { margin-top: auto; }
.legend-heading { margin-bottom: 9px; }
.legend-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 7px 9px; color: var(--muted); font-size: 9px; }
.legend-grid span { min-width: 0; display: flex; gap: 7px; align-items: center; }
.legend-grid b { flex: 0 0 auto; width: 23px; height: 23px; display: grid; place-items: center; color: var(--text); background: rgba(255,255,255,.045); border: 1px solid rgba(255,255,255,.08); border-radius: 6px 2px 6px 2px; }
.legend-grid .battery-symbol { color: var(--warning); }
.legend-grid .exit-symbol { color: var(--accent); }

.tutorial-dock {
  position: relative;
  flex: 0 0 auto;
  min-height: 86px;
  padding: 10px 12px;
  display: grid;
  grid-template-columns: minmax(240px, .85fr) minmax(400px, 1.4fr) auto;
  align-items: center;
  gap: 15px;
  overflow: hidden;
  border: 1px solid rgba(64, 241, 208, .34);
  border-radius: 8px 18px 8px 18px;
  background: linear-gradient(100deg, rgba(6, 31, 40, .98), rgba(3, 16, 25, .98));
  box-shadow: var(--shadow-inset), 0 18px 50px rgba(0,0,0,.35);
}
.tutorial-dock::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--accent); box-shadow: 0 0 14px var(--accent); }
.tutorial-dock[hidden] { display: none; }
.tutorial-intro { min-width: 0; display: flex; align-items: center; gap: 12px; }
.tutorial-emblem { flex: 0 0 auto; width: 48px; height: 48px; display: grid; place-items: center; color: var(--accent); border: 1px solid rgba(64,241,208,.36); border-radius: 14px 4px 14px 4px; background: rgba(64,241,208,.055); box-shadow: inset 0 0 24px rgba(64,241,208,.07); font-size: 24px; }
.tutorial-label { display: block; color: var(--accent); font-size: 8px; font-weight: 900; letter-spacing: .16em; }
.tutorial-intro strong { display: block; margin-top: 2px; font-size: 15px; }
.tutorial-intro p { margin: 3px 0 0; color: var(--muted); font-size: 10px; line-height: 1.35; }
.tutorial-timeline { display: grid; grid-template-columns: 1fr 18px 1fr 18px 1fr; align-items: center; gap: 5px; }
.tutorial-timeline > i { height: 1px; background: linear-gradient(90deg, rgba(64,241,208,.35), rgba(64,241,208,.08)); }
.tutorial-step { min-width: 0; padding: 6px 7px; border-color: transparent; border-radius: 8px 3px 8px 3px; display: flex; align-items: center; gap: 7px; text-align: left; background: transparent; color: var(--muted-2); }
.tutorial-step b { flex: 0 0 auto; width: 25px; height: 25px; display: grid; place-items: center; border-radius: 50%; border: 1px solid rgba(111,164,175,.28); font-size: 10px; }
.tutorial-step span { font-size: 10px; font-weight: 750; }
.tutorial-step.active { color: #dffff9; border-color: rgba(64,241,208,.25); background: rgba(64,241,208,.055); }
.tutorial-step.active b { color: #02110e; border-color: var(--accent); background: var(--accent); box-shadow: 0 0 14px rgba(64,241,208,.38); }
.tutorial-step.done { color: #86afa9; }
.tutorial-step.done b { color: var(--accent); border-color: rgba(64,241,208,.4); }
.tutorial-actions { display: flex; gap: 7px; justify-content: flex-end; }
.tutorial-skip,
.tutorial-next { min-height: 38px; padding: 8px 14px; border-radius: 8px 3px 8px 3px; font-size: 10px; font-weight: 800; white-space: nowrap; }
.tutorial-skip { color: var(--muted); }
.tutorial-next { color: #02110e; border-color: var(--accent); background: linear-gradient(180deg, #75ffe1, #2bd5b7); box-shadow: 0 6px 18px rgba(64,241,208,.17); }

.tutorial-focus {
  isolation: isolate;
  z-index: 9 !important;
  animation: tutorialPulse 1.25s ease-in-out infinite;
}
.tutorial-focus::after {
  content: "";
  position: absolute;
  inset: -5px;
  pointer-events: none;
  border: 1px solid rgba(95,255,225,.72);
  border-radius: inherit;
  box-shadow: 0 0 0 4px rgba(64,241,208,.05), 0 0 25px rgba(64,241,208,.22);
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(0, 5, 9, .78);
  backdrop-filter: blur(10px);
}
.modal[hidden] { display: none; }
.modal-card {
  position: relative;
  width: min(530px, 100%);
  overflow: hidden;
  padding: 26px;
  border: 1px solid rgba(64,241,208,.3);
  border-radius: 18px 5px 18px 5px;
  background: linear-gradient(160deg, rgba(8, 35, 47, .99), rgba(2, 14, 22, .99));
  box-shadow: var(--shadow-inset), 0 30px 100px rgba(0,0,0,.58);
}
.modal-scanline { position: absolute; left: 0; right: 0; top: 0; height: 2px; background: linear-gradient(90deg, transparent, var(--accent), transparent); box-shadow: 0 0 16px rgba(64,241,208,.55); }
.modal-badge { display: inline-flex; padding: 5px 9px; border-radius: 7px 2px 7px 2px; color: var(--accent); border: 1px solid rgba(64,241,208,.28); background: rgba(64,241,208,.055); font-size: 9px; font-weight: 900; letter-spacing: .13em; }
.modal h2 { margin: 11px 0 8px; font-size: 30px; letter-spacing: -.025em; }
.modal p { color: #b8ceda; line-height: 1.55; font-size: 13px; }
.modal-stats { display: flex; gap: 8px; flex-wrap: wrap; margin: 16px 0; }
.modal-stats span { padding: 8px 10px; border-radius: 8px 3px 8px 3px; background: rgba(255,255,255,.04); border: 1px solid rgba(255,255,255,.06); color: #dceefa; font-size: 11px; }
.modal-actions { display: flex; gap: 8px; }
.modal-actions button { flex: 1; }
.help-card { width: min(760px, 100%); }
.help-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; margin: 17px 0; }
.help-grid > div { position: relative; padding: 14px 14px 14px 52px; border-radius: 11px 3px 11px 3px; background: rgba(255,255,255,.032); border: 1px solid rgba(255,255,255,.06); }
.help-grid b { color: #e5fbff; }
.help-grid p { margin: 4px 0 0; font-size: 11px; }
.help-icon { position: absolute; left: 12px; top: 14px; width: 29px; height: 29px; display: grid; place-items: center; border-radius: 8px 2px 8px 2px; color: var(--accent); background: rgba(64,241,208,.06); border: 1px solid rgba(64,241,208,.18); }
.help-actions { display: grid; grid-template-columns: 1.2fr 1fr 1fr; }

@keyframes glint {
  0%, 62% { transform: translateX(-120%) skewX(-20deg); }
  78%, 100% { transform: translateX(140%) skewX(-20deg); }
}
@keyframes tutorialPulse {
  0%, 100% { filter: drop-shadow(0 0 0 rgba(64,241,208,0)); }
  50% { filter: drop-shadow(0 0 10px rgba(64,241,208,.18)); }
}

@media (max-height: 740px) and (min-width: 781px) {
  .app-shell { padding-top: 8px; padding-bottom: 9px; }
  .topbar { min-height: 48px; padding-bottom: 6px; }
  .brand-mark { width: 40px; height: 40px; }
  .brand-mark svg { width: 37px; height: 37px; }
  .brand small { display: none; }
  .icon-btn { min-height: 34px; padding: 6px 10px; }
  .game-layout { gap: 7px; }
  .mission-panel { padding: 9px 14px 8px; }
  .mission-kicker-row { gap: 8px; }
  h1 { margin-top: 3px; font-size: 24px; }
  .objective-text { margin-top: 4px; font-size: 11px; }
  .mission-stats span { min-width: 95px; padding: 6px 8px; font-size: 9px; }
  .mission-stats b { font-size: 13px; }
  .progress-row { margin-top: 6px; }
  .level-btn { min-width: 35px; height: 25px; padding: 0 7px; }
  .play-area { grid-template-columns: minmax(0, 1fr) 292px; gap: 7px; }
  .control-panel { padding: 7px; gap: 6px; }
  .control-group { padding: 7px; }
  .control-heading { margin-bottom: 6px; }
  .fold-btn { min-height: 45px; padding: 6px 7px; grid-template-columns: 32px minmax(0,1fr) 16px; }
  .fold-btn .fold-icon { width: 30px; height: 30px; }
  .primary-btn { min-height: 39px; padding: 8px 10px; }
  .secondary-btn { min-height: 34px; padding: 6px 7px; }
  .dpad { grid-template-columns: repeat(3, 41px); grid-template-rows: repeat(2, 33px); gap: 4px; }
  .legend { display: none; }
  .tutorial-dock { min-height: 66px; padding: 7px 9px; }
  .tutorial-emblem { width: 38px; height: 38px; }
  .tutorial-intro strong { font-size: 12px; }
  .tutorial-intro p { font-size: 9px; }
  .tutorial-step { padding: 4px; }
  .tutorial-step b { width: 21px; height: 21px; }
  .tutorial-next, .tutorial-skip { min-height: 32px; padding: 6px 9px; }
}

@media (max-width: 780px) {
  body { overflow: auto; }
  .app-shell { height: auto; min-height: 100vh; }
  .play-area { grid-template-columns: 1fr; }
  .canvas-wrap { height: min(62vh, 620px); min-height: 420px; }
  .control-panel { overflow: visible; display: grid; grid-template-columns: 1.2fr 1fr; }
  .fold-control { grid-row: span 2; }
  .legend { margin-top: 0; }
  .tutorial-dock { grid-template-columns: 1fr auto; }
  .tutorial-timeline { grid-column: 1 / -1; grid-row: 2; }
  .tutorial-actions { grid-column: 2; grid-row: 1; }
}

@media (max-width: 650px) {
  .app-shell { padding: 8px 8px 14px; }
  .topbar { min-height: 48px; padding: 3px 1px 8px; }
  .brand { gap: 8px; }
  .brand-mark { width: 38px; height: 38px; }
  .brand-mark svg { width: 35px; height: 35px; }
  .brand strong { font-size: 15px; }
  .brand small { display: none; }
  .button-label { display: none; }
  .icon-btn { min-width: 37px; padding: 7px 9px; justify-content: center; }
  .mission-panel { padding: 11px 12px 9px; }
  .mission-main { gap: 10px; }
  .system-status { display: none; }
  h1 { font-size: 24px; }
  .objective-text { font-size: 11px; }
  .mission-stats { max-width: 42%; }
  .mission-stats span { min-width: 84px; padding: 7px 8px; font-size: 8px; }
  .progress-label { display: none; }
  .progress-row { gap: 0; }
  .canvas-wrap { height: 54vh; min-height: 360px; border-radius: 13px 5px 13px 5px; }
  .canvas-toolbar { display: none; }
  .control-panel { display: grid; grid-template-columns: 1fr; padding: 8px; border-radius: 5px 13px 5px 13px; }
  .fold-control { grid-row: auto; }
  .legend { display: none; }
  .tutorial-dock { grid-template-columns: 1fr; gap: 8px; padding: 9px; }
  .tutorial-intro { align-items: flex-start; }
  .tutorial-emblem { width: 39px; height: 39px; }
  .tutorial-timeline { grid-column: auto; grid-row: auto; grid-template-columns: 1fr; gap: 3px; }
  .tutorial-timeline > i { display: none; }
  .tutorial-step { min-height: 32px; }
  .tutorial-actions { grid-column: auto; grid-row: auto; }
  .tutorial-actions button { flex: 1; }
  .help-grid { grid-template-columns: 1fr; }
  .help-actions { grid-template-columns: 1fr; }
  .modal-card { padding: 20px; }
  .modal-actions { flex-direction: column; }
}

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

@media (min-width: 781px) and (max-width: 1000px) {
  .tutorial-dock { grid-template-columns: minmax(170px, .72fr) minmax(300px, 1.28fr) auto; gap: 8px; }
  .tutorial-emblem { display: none; }
  .tutorial-intro { gap: 0; }
  .tutorial-intro p { font-size: 8px; }
  .tutorial-step { padding: 4px; gap: 4px; }
  .tutorial-step b { width: 21px; height: 21px; }
  .tutorial-step span { font-size: 8px; }
  .tutorial-actions { gap: 4px; }
  .tutorial-skip,
  .tutorial-next { padding-left: 8px; padding-right: 8px; font-size: 8px; }
}

@media (max-width: 650px) {
  body.tutorial-running .tutorial-dock {
    order: 1;
    min-height: 0;
    padding: 9px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 7px;
  }
  body.tutorial-running .play-area { order: 2; }
  body.tutorial-running .control-panel { order: -1; }
  body.tutorial-running[data-tutorial-step="2"] .canvas-wrap { order: -2; }
  body.tutorial-running[data-tutorial-step="2"] .control-panel { order: 0; }
  body.tutorial-running .tutorial-emblem { display: none; }
  body.tutorial-running .tutorial-intro { min-width: 0; }
  body.tutorial-running .tutorial-intro p { font-size: 9px; line-height: 1.3; }
  body.tutorial-running .tutorial-timeline {
    grid-column: 1 / -1;
    grid-row: 2;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 4px;
  }
  body.tutorial-running .tutorial-timeline > i { display: none; }
  body.tutorial-running .tutorial-step { min-height: 30px; justify-content: center; }
  body.tutorial-running .tutorial-step span { display: none; }
  body.tutorial-running .tutorial-actions { grid-column: 2; grid-row: 1; align-self: center; }
  body.tutorial-running .tutorial-skip,
  body.tutorial-running .tutorial-next { min-height: 34px; padding: 6px 8px; font-size: 8px; }
}

/* REV004: click-safe interactive onboarding overlay. */
.tutorial-overlay,
.tutorial-spotlight,
.tutorial-hit-target,
.tutorial-connector,
.tutorial-coach {
  position: fixed;
}

.tutorial-overlay {
  inset: 0;
  z-index: 90;
  pointer-events: none;
  background: rgba(0, 6, 11, .78);
  backdrop-filter: blur(3px) saturate(.72);
  animation: tutorialFadeIn .22s ease-out both;
}

.tutorial-overlay[hidden],
.tutorial-spotlight[hidden],
.tutorial-hit-target[hidden],
.tutorial-connector[hidden],
.tutorial-coach[hidden] { display: none !important; }

.tutorial-spotlight {
  left: 0;
  top: 0;
  z-index: 91;
  pointer-events: none;
  border: 2px solid rgba(106, 255, 226, .98);
  border-radius: 16px 6px 16px 6px;
  background: rgba(64, 241, 208, .025);
  box-shadow:
    0 0 0 9999px rgba(0, 6, 11, .76),
    0 0 0 5px rgba(64, 241, 208, .09),
    0 0 34px rgba(64, 241, 208, .46),
    inset 0 0 22px rgba(64, 241, 208, .07);
  transition: left .24s ease, top .24s ease, width .24s ease, height .24s ease, border-radius .24s ease;
  animation: tutorialSpotlightPulse 1.45s ease-in-out infinite;
}

.tutorial-spotlight::before,
.tutorial-spotlight::after {
  content: "";
  position: absolute;
  width: 18px;
  height: 18px;
  border-color: #b8fff2;
  filter: drop-shadow(0 0 7px rgba(64,241,208,.75));
}
.tutorial-spotlight::before {
  left: -4px;
  top: -4px;
  border-left: 3px solid;
  border-top: 3px solid;
}
.tutorial-spotlight::after {
  right: -4px;
  bottom: -4px;
  border-right: 3px solid;
  border-bottom: 3px solid;
}

.tutorial-hit-target {
  left: 0;
  top: 0;
  z-index: 95;
  margin: 0;
  padding: 0;
  overflow: visible;
  border: 0;
  border-radius: 10px 4px 10px 4px;
  cursor: pointer;
  pointer-events: auto;
  background: rgba(64, 241, 208, .018);
  box-shadow: inset 0 0 0 1px rgba(153, 255, 237, .12);
  animation: tutorialHitBreath 1.05s ease-in-out infinite;
  -webkit-tap-highlight-color: transparent;
}
.tutorial-hit-target:hover,
.tutorial-hit-target:focus-visible {
  background: rgba(64, 241, 208, .08);
  box-shadow: inset 0 0 0 2px #9bffed, 0 0 28px rgba(64,241,208,.42);
  outline: none;
}
.tutorial-hit-target span {
  position: absolute;
  right: 8px;
  top: -16px;
  min-width: 72px;
  padding: 4px 8px;
  border: 1px solid rgba(134,255,234,.8);
  border-radius: 8px 2px 8px 2px;
  color: #00130f;
  background: linear-gradient(180deg, #a2fff0, #35dec0);
  box-shadow: 0 0 18px rgba(64,241,208,.45);
  font-size: 8px;
  font-weight: 950;
  letter-spacing: .1em;
  line-height: 1;
  text-align: center;
  pointer-events: none;
}

.tutorial-connector {
  left: 0;
  top: 0;
  z-index: 92;
  width: 0;
  height: 2px;
  pointer-events: none;
  transform-origin: 0 50%;
  background: linear-gradient(90deg, rgba(64,241,208,.18), #78ffe5 45%, rgba(64,241,208,.2));
  box-shadow: 0 0 12px rgba(64,241,208,.66);
}
.tutorial-connector::before,
.tutorial-connector::after {
  content: "";
  position: absolute;
  top: 50%;
  width: 8px;
  height: 8px;
  margin-top: -4px;
  border-radius: 50%;
  background: #82ffe8;
  box-shadow: 0 0 12px rgba(64,241,208,.95);
}
.tutorial-connector::before { left: -2px; }
.tutorial-connector::after { right: -2px; }
.tutorial-connector i {
  position: absolute;
  right: 0;
  top: 50%;
  width: 13px;
  height: 13px;
  border-top: 2px solid #82ffe8;
  border-right: 2px solid #82ffe8;
  transform: translate(1px, -50%) rotate(45deg);
}

.tutorial-coach {
  z-index: 96;
  width: min(390px, calc(100vw - 28px));
  padding: 18px 18px 16px;
  overflow: hidden;
  border: 1px solid rgba(103, 255, 228, .62);
  border-radius: 8px 22px 8px 22px;
  color: var(--text);
  background:
    linear-gradient(145deg, rgba(11, 43, 53, .98), rgba(2, 14, 23, .985) 64%),
    var(--panel-strong);
  box-shadow:
    0 24px 70px rgba(0,0,0,.62),
    0 0 35px rgba(64,241,208,.15),
    inset 0 1px 0 rgba(255,255,255,.08),
    inset 0 0 50px rgba(64,241,208,.04);
  animation: tutorialCoachIn .24s cubic-bezier(.2,.8,.2,1) both;
}
.tutorial-coach::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: linear-gradient(180deg, #8affea, #1ed8bb 60%, transparent);
  box-shadow: 0 0 16px rgba(64,241,208,.8);
}
.tutorial-coach::after {
  content: "";
  position: absolute;
  left: 22px;
  right: 22px;
  top: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, #82ffe8 35%, transparent 88%);
}
.tutorial-coach.is-intro {
  left: 50% !important;
  top: 50% !important;
  width: min(520px, calc(100vw - 28px));
  padding: 25px 25px 22px;
  transform: translate(-50%, -50%);
  text-align: left;
}
.tutorial-coach-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--accent);
  font-size: 9px;
  font-weight: 900;
  letter-spacing: .14em;
}
.tutorial-live {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #d9fff8;
  letter-spacing: .08em;
}
.tutorial-live i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 10px var(--accent);
  animation: tutorialLive 1.15s ease-in-out infinite;
}
.tutorial-coach h2 {
  margin: 10px 0 7px;
  font-size: clamp(22px, 2vw, 30px);
  line-height: 1.08;
  letter-spacing: -.025em;
}
.tutorial-coach p {
  margin: 0;
  color: #b3cbd6;
  font-size: 13px;
  line-height: 1.55;
}
.tutorial-command {
  margin-top: 15px;
  padding: 10px 12px;
  border: 1px solid rgba(64,241,208,.26);
  border-radius: 8px 3px 8px 3px;
  color: #dffff8;
  background: rgba(64,241,208,.065);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: .11em;
  text-transform: uppercase;
}
.tutorial-command::before {
  content: "→";
  display: inline-block;
  margin-right: 8px;
  color: var(--accent);
  animation: tutorialArrow 1s ease-in-out infinite;
}
.tutorial-coach-actions {
  margin-top: 17px;
  display: flex;
  justify-content: flex-end;
  gap: 9px;
}
.tutorial-coach-skip,
.tutorial-coach-primary {
  min-height: 40px;
  padding: 9px 15px;
  border: 1px solid rgba(128, 205, 214, .18);
  border-radius: 9px 3px 9px 3px;
  font-size: 11px;
  font-weight: 850;
  letter-spacing: .025em;
  cursor: pointer;
}
.tutorial-coach-skip {
  color: var(--muted);
  background: rgba(3, 17, 26, .85);
}
.tutorial-coach-primary {
  color: #02120f;
  border-color: #6cffe3;
  background: linear-gradient(180deg, #87ffe9, #2bd8b9);
  box-shadow: 0 7px 24px rgba(64,241,208,.25);
}
.tutorial-coach-primary:hover,
.tutorial-coach-skip:hover { transform: translateY(-1px); }
.tutorial-coach-primary:focus-visible,
.tutorial-coach-skip:focus-visible { outline: 2px solid white; outline-offset: 3px; }

body.tutorial-running .tutorial-step { cursor: default; }
body.tutorial-running .tutorial-step:not(.active):not(.done) { opacity: .48; }
body.tutorial-running .tutorial-target-board,
body.tutorial-running .tutorial-target-folds,
body.tutorial-running .tutorial-target-execute,
body.tutorial-running .tutorial-target-move { transition: filter .18s ease, opacity .18s ease; }

@keyframes tutorialFadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes tutorialCoachIn { from { opacity: 0; transform: translateY(8px) scale(.985); } to { opacity: 1; transform: translateY(0) scale(1); } }
@keyframes tutorialSpotlightPulse {
  0%, 100% { border-color: rgba(102,255,226,.82); box-shadow: 0 0 0 9999px rgba(0,6,11,.76), 0 0 0 5px rgba(64,241,208,.07), 0 0 26px rgba(64,241,208,.34); }
  50% { border-color: #b0fff1; box-shadow: 0 0 0 9999px rgba(0,6,11,.76), 0 0 0 8px rgba(64,241,208,.11), 0 0 42px rgba(64,241,208,.62); }
}
@keyframes tutorialLive { 0%,100% { opacity: .55; transform: scale(.88); } 50% { opacity: 1; transform: scale(1.15); } }
@keyframes tutorialArrow { 0%,100% { transform: translateX(0); } 50% { transform: translateX(5px); } }
@keyframes tutorialHitBreath { 0%,100% { box-shadow: inset 0 0 0 1px rgba(153,255,237,.12), 0 0 0 rgba(64,241,208,0); } 50% { box-shadow: inset 0 0 0 2px rgba(153,255,237,.5), 0 0 24px rgba(64,241,208,.22); } }

@media (max-width: 760px) {
  .tutorial-coach:not(.is-intro) {
    left: 10px !important;
    right: 10px !important;
    bottom: 10px !important;
    top: auto !important;
    width: auto;
    max-height: calc(100vh - 20px);
    overflow: auto;
    padding: 15px 15px 13px;
  }
  .tutorial-coach h2 { font-size: 21px; }
  .tutorial-coach p { font-size: 12px; }
  .tutorial-command { margin-top: 10px; padding: 8px 10px; font-size: 9px; }
  .tutorial-coach-actions { margin-top: 11px; }
  .tutorial-connector { display: none !important; }
  .tutorial-spotlight { border-radius: 12px 4px 12px 4px; }
  .tutorial-hit-target span { top: 5px; right: 6px; }
}

@media (max-height: 590px) and (min-width: 761px) {
  .tutorial-coach { width: min(350px, calc(100vw - 24px)); padding: 13px 14px 12px; }
  .tutorial-coach h2 { margin-top: 7px; font-size: 21px; }
  .tutorial-coach p { font-size: 11px; line-height: 1.42; }
  .tutorial-command { margin-top: 9px; padding: 7px 9px; }
  .tutorial-coach-actions { margin-top: 10px; }
}

.tutorial-coach.is-intro { animation: tutorialIntroIn .26s cubic-bezier(.2,.8,.2,1) both; }
body.tutorial-running .tutorial-step:disabled { opacity: 1; filter: none; }
body.tutorial-running .tutorial-step:disabled:not(.active):not(.done) { opacity: .48; }
@keyframes tutorialIntroIn {
  from { opacity: 0; transform: translate(-50%, calc(-50% + 10px)) scale(.98); }
  to { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

/* REV005: commercial presentation, adaptive board scale, and contextual mechanic guides. */
.mechanic-guide {
  position: absolute;
  left: 18px;
  top: 38px;
  z-index: 12;
  width: min(410px, calc(100% - 36px));
  min-height: 82px;
  padding: 12px 12px 12px 74px;
  border: 1px solid rgba(89, 255, 221, .5);
  border-radius: 13px 4px 13px 4px;
  color: var(--text);
  background:
    linear-gradient(115deg, rgba(7, 38, 46, .97), rgba(3, 17, 26, .94)),
    rgba(3, 17, 26, .96);
  box-shadow: 0 16px 45px rgba(0, 0, 0, .38), inset 0 0 30px rgba(64, 241, 208, .055), 0 0 24px rgba(64, 241, 208, .12);
  backdrop-filter: blur(12px);
  animation: mechanicGuideIn .28s cubic-bezier(.2,.8,.2,1) both;
}
.mechanic-guide[hidden] { display: none !important; }
.mechanic-guide::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  border-radius: 13px 0 0 4px;
  background: linear-gradient(180deg, #9cfff0, #2bd7ba);
  box-shadow: 0 0 18px rgba(64, 241, 208, .7);
}
.mechanic-guide-mark {
  position: absolute;
  left: 15px;
  top: 16px;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 12px 3px 12px 3px;
  color: #03130f;
  background: linear-gradient(180deg, #a6fff0, #35dfbf);
  border: 1px solid #b8fff3;
  box-shadow: 0 0 22px rgba(64, 241, 208, .3);
  font-size: 9px;
  font-weight: 950;
  letter-spacing: .08em;
}
.mechanic-guide-copy { padding-right: 72px; }
.mechanic-guide-copy > span {
  display: block;
  color: var(--accent);
  font-size: 8px;
  font-weight: 900;
  letter-spacing: .15em;
}
.mechanic-guide-copy strong {
  display: block;
  margin-top: 3px;
  font-size: 15px;
  letter-spacing: -.015em;
}
.mechanic-guide-copy p {
  margin: 4px 0 0;
  color: #aac5ce;
  font-size: 10px;
  line-height: 1.42;
}
.mechanic-guide button {
  position: absolute;
  right: 10px;
  bottom: 10px;
  min-height: 30px;
  padding: 6px 9px;
  border-color: rgba(91,255,221,.42);
  border-radius: 7px 2px 7px 2px;
  color: #baffef;
  background: rgba(64, 241, 208, .07);
  font-size: 8px;
  font-weight: 900;
  letter-spacing: .08em;
}
.mechanic-guide button:hover { background: rgba(64, 241, 208, .14); }

.micro-highlight {
  position: relative;
  z-index: 9;
  animation: microHighlight 1.15s ease-in-out infinite;
}
.canvas-wrap.micro-highlight { z-index: 1; }
.primary-btn.awaiting-selection .primary-copy { opacity: .88; }
.primary-btn.awaiting-selection { letter-spacing: .08em; }

.legend-grid { font-size: 10px; gap: 8px 10px; }
.legend-grid b { width: 26px; height: 26px; font-size: 11px; }
.canvas-toolbar { color: rgba(172, 216, 226, .58); }

@keyframes mechanicGuideIn {
  from { opacity: 0; transform: translateY(-8px) scale(.985); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes microHighlight {
  0%, 100% { box-shadow: 0 0 0 1px rgba(64,241,208,.18), 0 0 14px rgba(64,241,208,.1), inset 0 0 18px rgba(64,241,208,.025); }
  50% { box-shadow: 0 0 0 2px rgba(132,255,233,.7), 0 0 32px rgba(64,241,208,.34), inset 0 0 28px rgba(64,241,208,.08); }
}

@media (max-height: 740px) and (min-width: 781px) {
  .mechanic-guide { top: 31px; width: min(360px, calc(100% - 32px)); min-height: 68px; padding: 9px 10px 9px 62px; }
  .mechanic-guide-mark { left: 12px; top: 12px; width: 37px; height: 37px; }
  .mechanic-guide-copy strong { font-size: 13px; }
  .mechanic-guide-copy p { font-size: 9px; }
  .mechanic-guide button { min-height: 27px; padding: 5px 7px; }
}

@media (max-width: 650px) {
  .mechanic-guide {
    left: 9px;
    right: 9px;
    top: 9px;
    width: auto;
    min-height: 76px;
    padding: 10px 10px 10px 62px;
  }
  .mechanic-guide-mark { left: 11px; top: 13px; width: 38px; height: 38px; }
  .mechanic-guide-copy { padding-right: 58px; }
  .mechanic-guide-copy strong { font-size: 13px; }
  .mechanic-guide-copy p { font-size: 9px; }
  .mechanic-guide button { right: 8px; bottom: 8px; }
}

/* F1 REV010 full-game meta layer */
.top-actions { flex-wrap: wrap; justify-content: flex-end; }
.top-actions .icon-btn { min-width: 0; }
.key-symbol { color: #ffe69d !important; border-color: rgba(255, 214, 105, .55) !important; }
.fragile-symbol { color: #ff9da8 !important; border-color: rgba(255, 126, 143, .55) !important; }

.meta-screen {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: grid;
  place-items: center;
  padding: clamp(14px, 3vw, 42px);
  background:
    radial-gradient(circle at 20% 18%, rgba(45, 228, 198, .12), transparent 34%),
    radial-gradient(circle at 80% 78%, rgba(49, 126, 214, .12), transparent 38%),
    rgba(1, 9, 15, .91);
  backdrop-filter: blur(14px) saturate(115%);
}
.meta-screen[hidden] { display: none !important; }
.meta-shell {
  position: relative;
  width: min(1180px, 96vw);
  max-height: min(900px, 94vh);
  overflow: auto;
  border: 1px solid rgba(78, 236, 208, .38);
  border-radius: 24px;
  background:
    linear-gradient(145deg, rgba(8, 34, 44, .98), rgba(2, 15, 24, .98)),
    rgba(4, 18, 27, .98);
  box-shadow: 0 36px 100px rgba(0, 0, 0, .56), inset 0 1px rgba(255, 255, 255, .04), 0 0 54px rgba(38, 229, 196, .08);
  color: #eafcf8;
}
.meta-shell::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  border-radius: inherit;
  background: linear-gradient(110deg, rgba(90, 255, 222, .05), transparent 30%, transparent 70%, rgba(65, 133, 255, .05));
}
.command-shell { display: grid; grid-template-columns: 1.3fr .7fr; gap: 32px; padding: clamp(30px, 5vw, 72px); overflow: hidden; }
.command-hero { position: relative; z-index: 1; align-self: center; }
.meta-kicker { display: block; color: #5ff2d2; font-size: 12px; font-weight: 900; letter-spacing: .17em; margin-bottom: 12px; }
.command-hero h2, .meta-head h2, .compact-shell h2 { margin: 0; font-size: clamp(34px, 5vw, 70px); letter-spacing: -.04em; line-height: .95; }
.command-hero p { max-width: 680px; color: #a8c6cf; font-size: clamp(15px, 1.5vw, 20px); line-height: 1.65; margin: 24px 0 30px; }
.command-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; max-width: 700px; }
.meta-primary, .meta-secondary {
  min-height: 52px;
  border-radius: 12px;
  border: 1px solid rgba(80, 238, 210, .3);
  padding: 0 20px;
  font: 900 13px/1 system-ui, sans-serif;
  letter-spacing: .055em;
  cursor: pointer;
  transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease;
}
.meta-primary { color: #031c18; background: linear-gradient(180deg, #69f4d7, #2dd2b2); box-shadow: 0 12px 34px rgba(34, 222, 186, .2); }
.meta-secondary { color: #dffbf5; background: rgba(9, 37, 48, .8); }
.meta-primary:hover, .meta-secondary:hover { transform: translateY(-1px); border-color: rgba(94, 255, 222, .75); box-shadow: 0 12px 30px rgba(21, 200, 169, .14); }
.command-summary { position: relative; z-index: 1; display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; align-content: center; }
.command-summary > div { min-height: 126px; padding: 24px; border: 1px solid rgba(87, 220, 201, .19); border-radius: 18px; background: linear-gradient(145deg, rgba(14, 49, 60, .78), rgba(4, 22, 31, .82)); display: flex; flex-direction: column; justify-content: space-between; }
.command-summary span { color: #7ba2ad; font-size: 11px; font-weight: 900; letter-spacing: .14em; }
.command-summary strong { font-size: clamp(26px, 3vw, 42px); letter-spacing: -.04em; }
.meta-close { position: absolute; z-index: 4; top: 18px; right: 20px; width: 44px; height: 44px; border-radius: 12px; border: 1px solid rgba(119, 224, 207, .2); color: #bde7df; background: rgba(6, 28, 37, .82); font-size: 26px; cursor: pointer; }
.meta-close.inline-close { position: static; flex: 0 0 auto; }
.mission-shell, .records-shell { padding: 28px; }
.meta-head { position: relative; z-index: 1; display: flex; justify-content: space-between; align-items: center; gap: 20px; margin-bottom: 22px; }
.meta-head h2 { font-size: clamp(28px, 4vw, 48px); }
.sector-tabs { position: relative; z-index: 1; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-bottom: 20px; }
.sector-tab { min-height: 74px; padding: 14px; text-align: left; border: 1px solid rgba(104, 214, 197, .17); border-radius: 14px; background: rgba(5, 27, 37, .78); color: #b8d7dd; cursor: pointer; }
.sector-tab strong { display: block; color: #e9fffa; font-size: 14px; margin-bottom: 6px; }
.sector-tab small { display: block; color: #789ba6; line-height: 1.3; }
.sector-tab.active { border-color: #55e5c7; background: linear-gradient(145deg, rgba(23, 89, 94, .72), rgba(7, 37, 47, .86)); box-shadow: 0 0 28px rgba(58, 230, 199, .09); }
.mission-grid { position: relative; z-index: 1; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.mission-card { min-height: 148px; padding: 16px; border: 1px solid rgba(103, 212, 197, .17); border-radius: 16px; background: rgba(4, 24, 33, .86); color: #d9f4ef; text-align: left; cursor: pointer; position: relative; overflow: hidden; }
.mission-card::after { content: ""; position: absolute; inset: auto -20% -60% 20%; height: 90%; background: radial-gradient(circle, rgba(62, 235, 202, .1), transparent 70%); pointer-events: none; }
.mission-card:hover:not(:disabled) { border-color: rgba(82, 244, 211, .62); transform: translateY(-1px); }
.mission-card:disabled { opacity: .4; cursor: not-allowed; filter: grayscale(.35); }
.mission-card.current { border-color: #65f0d2; box-shadow: inset 0 0 0 1px rgba(96, 242, 211, .2); }
.mission-card .mission-number { color: #5de6ca; font-size: 11px; font-weight: 900; letter-spacing: .13em; }
.mission-card strong { display: block; font-size: 18px; margin: 12px 0 8px; }
.mission-card p { color: #86aab4; font-size: 12px; line-height: 1.45; margin: 0; }
.mission-card .mission-stars { display: flex; gap: 4px; margin-top: 13px; color: #44656d; }
.mission-card .mission-stars .earned { color: #ffdd78; text-shadow: 0 0 10px rgba(255, 211, 104, .36); }
.mission-hub-summary { position: relative; z-index: 1; margin-top: 18px; color: #8fb0b8; font-size: 13px; }
.compact-shell { width: min(620px, 94vw); padding: 34px; }
.compact-shell h2 { font-size: 38px; }
.compact-shell > p { color: #b9d2d8; line-height: 1.7; font-size: 16px; min-height: 74px; }
.hint-progress { display: flex; gap: 8px; margin: 20px 0; }
.hint-progress i { flex: 1; height: 4px; border-radius: 9px; background: rgba(118, 171, 180, .2); }
.hint-progress i.active { background: #54e9ca; box-shadow: 0 0 12px rgba(63, 233, 199, .45); }
.meta-actions-row { display: grid; grid-template-columns: 1.2fr 1fr; gap: 10px; }
.records-stats { position: relative; z-index: 1; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; margin-bottom: 22px; }
.records-stats > div { padding: 16px; border-radius: 14px; border: 1px solid rgba(90, 207, 190, .15); background: rgba(6, 29, 39, .75); }
.records-stats span { display: block; color: #799da7; font-size: 10px; font-weight: 900; letter-spacing: .12em; margin-bottom: 8px; }
.records-stats strong { font-size: 24px; }
.achievement-grid { position: relative; z-index: 1; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.achievement-card { min-height: 110px; padding: 15px; border: 1px solid rgba(91, 197, 182, .14); border-radius: 14px; background: rgba(5, 25, 34, .76); opacity: .45; }
.achievement-card.unlocked { opacity: 1; border-color: rgba(255, 217, 117, .4); background: linear-gradient(145deg, rgba(74, 61, 24, .34), rgba(6, 29, 38, .85)); }
.achievement-card .achievement-icon { float: right; font-size: 22px; color: #ffe183; }
.achievement-card strong { display: block; font-size: 14px; margin-bottom: 8px; }
.achievement-card p { margin: 0; color: #86a9b2; font-size: 12px; line-height: 1.45; }

.challenge-badge { color: #ffd66d !important; }
.level-btn .star-dot { display: none; }
.level-btn.completed { position: relative; }
.level-btn.completed::after { content: "★"; position: absolute; top: -7px; right: -4px; color: #ffe27b; font-size: 9px; }

@media (max-width: 980px) {
  .command-shell { grid-template-columns: 1fr; }
  .command-summary { grid-template-columns: repeat(4, 1fr); }
  .command-summary > div { min-height: 92px; padding: 16px; }
  .mission-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sector-tabs { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .records-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .achievement-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 680px) {
  .top-actions .button-label { display: none; }
  .top-actions .icon-btn { width: 38px; padding-inline: 0; justify-content: center; }
  .command-shell, .mission-shell, .records-shell, .compact-shell { padding: 22px 16px; border-radius: 17px; }
  .command-actions { grid-template-columns: 1fr; }
  .command-summary { grid-template-columns: repeat(2, 1fr); }
  .mission-grid, .achievement-grid { grid-template-columns: 1fr; }
  .sector-tabs { display: flex; overflow-x: auto; padding-bottom: 4px; }
  .sector-tab { flex: 0 0 220px; }
  .records-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .meta-actions-row { grid-template-columns: 1fr; }
}

/* REV010 release-accessibility and route-recovery cues */
.route-deadlock-highlight {
  position: relative;
  z-index: 10;
  border-color: rgba(255, 111, 136, .9) !important;
  box-shadow: 0 0 0 3px rgba(255, 111, 136, .18), 0 0 24px rgba(255, 111, 136, .48) !important;
  animation: routeDeadlockPulse .9s ease-in-out infinite alternate;
}
@keyframes routeDeadlockPulse {
  from { transform: translateY(0); }
  to { transform: translateY(-2px); }
}
.key-symbol, .door-symbol { min-width: 28px !important; font-size: 8px !important; letter-spacing: .02em; }


/* F1 REV011 mobile-readiness hotfix */
.app-shell {
  padding-top: max(14px, env(safe-area-inset-top));
  padding-right: max(clamp(14px, 2vw, 34px), env(safe-area-inset-right));
  padding-bottom: max(16px, env(safe-area-inset-bottom));
  padding-left: max(clamp(14px, 2vw, 34px), env(safe-area-inset-left));
}

#gameCanvas {
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  outline: none;
}

.pointer-pressed {
  transform: scale(.975) !important;
  filter: brightness(1.08);
}

body.external-overlay-active #app,
body.external-overlay-active .modal,
body.external-overlay-active .meta-screen,
body.external-overlay-active .tutorial-coach,
body.external-overlay-active .tutorial-hit-target {
  pointer-events: none !important;
  user-select: none !important;
}

body.low-performance .ambient-orb { display: none; }
body.low-performance .ambient-grid { opacity: .08; }
body.low-performance .primary-glint { display: none; }
body.low-performance .meta-screen,
body.low-performance .modal,
body.low-performance .tutorial-overlay,
body.low-performance .mechanic-guide { backdrop-filter: none !important; }
body.low-performance .canvas-wrap,
body.low-performance .control-panel,
body.low-performance .mission-panel,
body.low-performance .meta-shell { box-shadow: inset 0 1px 0 rgba(255,255,255,.04), 0 12px 34px rgba(0,0,0,.34); }
body.low-performance .route-deadlock-highlight { animation-duration: 1.8s; }

.help-actions { grid-template-columns: repeat(2, minmax(0, 1fr)); }

@media (hover: none) {
  .icon-btn:hover,
  .secondary-btn:hover,
  .fold-btn:hover,
  .dpad button:hover,
  .level-btn:hover,
  .tutorial-skip:hover,
  .primary-btn:hover,
  .meta-primary:hover,
  .meta-secondary:hover,
  .tutorial-coach-primary:hover,
  .tutorial-coach-skip:hover,
  .mechanic-guide button:hover,
  .mission-card:hover:not(:disabled) {
    transform: none;
    filter: none;
  }
  .primary-glint { animation: none; opacity: .22; }
  button:active:not(:disabled) { transform: scale(.975); filter: brightness(1.08); }
}

@media (pointer: coarse) {
  .icon-btn,
  .secondary-btn,
  .danger-btn,
  .primary-btn,
  .tutorial-skip,
  .tutorial-next,
  .tutorial-coach-primary,
  .tutorial-coach-skip,
  .mechanic-guide button,
  .meta-primary,
  .meta-secondary,
  .meta-close,
  .level-btn,
  .dpad button {
    min-width: 48px;
    min-height: 48px;
  }
  .fold-btn { min-height: 64px; }
  .dpad {
    grid-template-columns: repeat(3, 52px);
    grid-template-rows: repeat(2, 52px);
    gap: 7px;
  }
  .top-actions .icon-btn { min-width: 48px; }
  .level-btn { height: 48px; }
  .tutorial-step { min-height: 48px; }
  .sector-tab { min-height: 80px; }
  .mission-card { min-height: 156px; }
}

@media (max-width: 650px) {
  .app-shell {
    padding-top: max(8px, env(safe-area-inset-top));
    padding-right: max(8px, env(safe-area-inset-right));
    padding-bottom: max(14px, env(safe-area-inset-bottom));
    padding-left: max(8px, env(safe-area-inset-left));
  }
  .top-actions .icon-btn { width: 48px; min-width: 48px; padding-inline: 0; }
  .help-actions { grid-template-columns: 1fr; }
}

@media (orientation: landscape) and (max-height: 540px) and (pointer: coarse) {
  html, body { min-width: 0; height: 100%; overflow: hidden; }
  .app-shell {
    width: 100%;
    height: 100dvh;
    min-height: 0;
    padding-top: max(4px, env(safe-area-inset-top));
    padding-right: max(6px, env(safe-area-inset-right));
    padding-bottom: max(5px, env(safe-area-inset-bottom));
    padding-left: max(6px, env(safe-area-inset-left));
  }
  .topbar { min-height: 48px; height: 48px; padding: 0 0 4px; gap: 6px; }
  .brand { gap: 7px; }
  .brand-mark, .brand-mark svg { width: 38px; height: 38px; }
  .brand strong { font-size: 14px; letter-spacing: .05em; }
  .brand small, .button-label { display: none; }
  .top-actions { flex-wrap: nowrap; gap: 5px; }
  .top-actions .icon-btn { width: 48px; min-width: 48px; min-height: 48px; padding: 0; justify-content: center; }
  .game-layout { gap: 5px; }
  .mission-panel { padding: 7px 10px 6px; border-radius: 12px 12px 5px 12px; }
  .mission-main { align-items: center; gap: 8px; }
  .mission-kicker-row { gap: 6px; }
  .eyebrow { font-size: 8px; }
  .system-status { display: none; }
  h1 { margin-top: 2px; font-size: 18px; }
  .objective-text { max-width: 68vw; margin-top: 2px; font-size: 9px; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .mission-stats { flex-wrap: nowrap; }
  .mission-stats span { min-width: 100px; padding: 5px 7px; font-size: 8px; }
  .mission-stats b { font-size: 12px; }
  .progress-row { display: none; }
  .play-area { grid-template-columns: minmax(0, 1fr) minmax(300px, 38vw); gap: 5px; min-height: 0; }
  .canvas-wrap { height: 100%; min-height: 0; border-radius: 12px 5px 12px 5px; }
  .canvas-toolbar, .legend { display: none; }
  .control-panel { height: 100%; min-height: 0; overflow-y: auto; padding: 5px; gap: 5px; display: flex; }
  .control-group { padding: 5px; }
  .control-heading { margin-bottom: 4px; }
  .control-heading small { display: none; }
  .section-index { width: 24px; height: 24px; }
  .fold-buttons { gap: 5px; }
  .fold-btn { min-height: 52px; padding: 5px 7px; grid-template-columns: 38px minmax(0,1fr) 18px; }
  .fold-btn .fold-icon { width: 38px; height: 38px; }
  .fold-btn strong { font-size: 10px; }
  .fold-btn small { font-size: 8px; }
  .action-group { gap: 5px; }
  .primary-btn, .secondary-btn { min-height: 48px; padding: 7px; }
  .movement-group { padding-bottom: 6px; }
  .dpad { grid-template-columns: repeat(3, 48px); grid-template-rows: repeat(2, 48px); gap: 5px; }
  .tutorial-dock { display: none !important; }
  .mechanic-guide { top: 8px; width: min(360px, calc(100% - 16px)); min-height: 64px; }
  .modal { padding: max(6px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-right)) max(6px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left)); }
  .modal-card { max-height: 94dvh; overflow: auto; padding: 16px; }
  .help-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
  .help-grid > div { padding: 9px 9px 9px 42px; }
  .help-icon { left: 8px; top: 9px; }
  .help-grid p { font-size: 9px; line-height: 1.3; }
  .tutorial-coach { max-width: min(380px, 48vw); padding: 12px; }
  .tutorial-coach h3 { font-size: 17px; }
  .tutorial-coach p { font-size: 10px; }
  .meta-screen { padding: max(6px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-right)) max(6px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left)); }
  .meta-shell { max-height: 96dvh; border-radius: 16px; }
}

@media (orientation: portrait) and (max-width: 780px) and (pointer: coarse) {
  #gameCanvas { touch-action: pan-y pinch-zoom; }
}

@media (orientation: landscape) and (max-height: 540px) and (pointer: coarse) {
  #gameCanvas { touch-action: none; }
}

@media (orientation: landscape) and (max-height: 540px) and (pointer: coarse) {
  .play-area { grid-template-columns: minmax(0, 1fr) minmax(354px, 42vw); }
  .control-panel {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr);
    align-content: stretch;
    overflow: hidden;
  }
  .fold-control { grid-column: 1 / -1; grid-row: 1; }
  .action-group { grid-column: 1; grid-row: 2; align-content: start; }
  .movement-group { grid-column: 2; grid-row: 2; min-width: 0; }
  .movement-group .control-heading { justify-content: center; }
  .movement-group .control-heading > div { width: 100%; justify-content: center; }
  .dpad { width: 154px; margin: 0 auto; }
}

/* F1 REV014 retains the REV012 short-landscape control and tutorial closeout */
@media (orientation: landscape) and (max-height: 540px) and (pointer: coarse) {
  .play-area { grid-template-columns: minmax(0, 1fr) minmax(330px, 42vw); }
  .control-panel {
    grid-template-rows: auto minmax(0, 1fr);
    gap: 4px;
    padding: 4px;
  }
  .fold-control,
  .action-group,
  .movement-group { padding: 4px; }
  .fold-control .control-heading,
  .movement-group .control-heading { display: none; }
  .fold-buttons {
    grid-auto-flow: column;
    grid-auto-columns: minmax(0, 1fr);
    gap: 4px;
  }
  .fold-btn {
    min-width: 0;
    min-height: 52px;
    height: 52px;
    padding: 4px 5px;
    grid-template-columns: 28px minmax(0, 1fr);
    gap: 4px;
  }
  .fold-btn::after { display: none; }
  .fold-btn .fold-icon {
    width: 28px;
    height: 38px;
    font-size: 14px;
  }
  .fold-btn strong {
    font-size: 9px;
    line-height: 1.08;
    overflow-wrap: anywhere;
  }
  .fold-btn small { display: none; }
  .action-group,
  .movement-group {
    min-height: 0;
    align-content: start;
  }
  .primary-btn,
  .secondary-btn { min-height: 48px; }
  .tutorial-coach:not(.is-intro) { max-width: min(300px, 46vw); }
}

@media (orientation: landscape) and (max-width: 600px) and (max-height: 360px) and (pointer: coarse) {
  .tutorial-coach.is-compact-landscape {
    width: 168px !important;
    max-width: 168px !important;
    padding: 8px !important;
    border-radius: 7px 15px 7px 15px;
  }
  .tutorial-coach.is-compact-landscape .tutorial-coach-head,
  .tutorial-coach.is-compact-landscape p { display: none; }
  .tutorial-coach.is-compact-landscape h2 {
    margin: 0 0 5px;
    font-size: 14px;
    line-height: 1.05;
  }
  .tutorial-coach.is-compact-landscape .tutorial-command {
    margin-top: 4px;
    padding: 5px 6px;
    font-size: 7px;
    line-height: 1.2;
    letter-spacing: .06em;
  }
  .tutorial-coach.is-compact-landscape .tutorial-command::before { margin-right: 4px; }
  .tutorial-coach.is-compact-landscape .tutorial-coach-actions {
    margin-top: 5px;
    gap: 4px;
  }
  .tutorial-coach.is-compact-landscape .tutorial-coach-primary,
  .tutorial-coach.is-compact-landscape .tutorial-coach-skip {
    min-width: 0;
    min-height: 48px;
    padding: 4px;
    font-size: 7px;
    line-height: 1.15;
  }
}
