/* Game stage: canvas + overlays + touch pad. Used by the arcade app and the dev harness. */
.arcade-stage { position: relative; width: 100%; height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center;
  touch-action: none; -webkit-user-select: none; user-select: none; }
.arcade-screen { position: relative; box-shadow: 0 0 0 2px #0b2236, 0 0 40px color-mix(in srgb, var(--game-accent, #8ee8ff) 25%, transparent); border-radius: 6px; overflow: hidden; background: #000; }
.arcade-screen canvas { display: block; width: 100%; height: 100%; }
.crt-layer { position: absolute; inset: 0; pointer-events: none; display: none; }
.arcade-stage.crt .crt-layer { display: block;
  background: repeating-linear-gradient(to bottom, rgba(0,0,0,.18) 0 1px, transparent 1px 3px),
              radial-gradient(ellipse at center, transparent 60%, rgba(0,0,0,.45) 100%); }
.arcade-overlay { position: absolute; inset: 0; display: none; align-items: center; justify-content: center; padding: 12px;
  background: rgba(1, 6, 13, .62); backdrop-filter: blur(2px); }
.arcade-overlay.show { display: flex; }
.ov-card { max-width: min(560px, 94%); max-height: 100%; overflow: auto; text-align: center; color: #d6f4ff;
  font: 14px/1.45 ui-monospace, Menlo, Consolas, "DejaVu Sans Mono", monospace;
  background: rgba(4, 16, 30, .92); border: 1px solid color-mix(in srgb, var(--game-accent, #8ee8ff) 55%, transparent);
  border-radius: 12px; padding: 18px 22px; box-shadow: 0 0 30px color-mix(in srgb, var(--game-accent, #8ee8ff) 22%, transparent); }
.ov-kicker { font-size: 12px; letter-spacing: .25em; color: var(--game-accent, #8ee8ff); }
.ov-title { margin: 4px 0 6px; font-size: clamp(22px, 4vw, 34px); letter-spacing: .06em; color: #fff;
  text-shadow: 0 0 14px var(--game-accent, #8ee8ff); }
.arcade-overlay.win .ov-title { color: #b8ffcf; text-shadow: 0 0 16px #39ff88; }
.arcade-overlay.lose .ov-title { color: #ffb3bb; text-shadow: 0 0 16px #ff3355; }
.ov-sub { margin: 0 0 10px; color: #bfefff; }
.ov-warn { color: #ffd34d; }
.ov-pad { margin: 10px 0 0; font-size: 13px; color: #b9e9ff; } .ov-pad b { color: #fff; }
.ov-controls { margin: 8px auto 4px; border-collapse: collapse; text-align: left; }
.ov-controls th { color: var(--game-accent, #8ee8ff); padding: 2px 12px 2px 0; text-align: right; font-weight: 700; white-space: nowrap; }
.ov-controls td { padding: 2px 0; }
.ov-buttons { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 14px; }
.ov-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 8px; margin: 10px 0; }
.ov-stats div { background: rgba(255,255,255,.04); border-radius: 8px; padding: 6px; }
.ov-stats b { display: block; font-size: 20px; color: #fff; }
.ov-events { list-style: none; padding: 0; margin: 8px 0; text-align: left; }
.ov-twist { margin: 6px 0; padding: 7px 10px; border-radius: 8px; border: 1px solid rgba(185, 140, 255, .45); background: rgba(185, 140, 255, .1); }
.ov-twist b { color: #d4b8ff; letter-spacing: .08em; text-transform: uppercase; margin-right: 6px; }
.ov-events li { padding: 6px 8px; margin: 4px 0; border-radius: 8px; background: rgba(255,255,255,.05); display: flex; gap: 10px; align-items: center; }
.ov-events li.unlock { background: linear-gradient(90deg, rgba(255,194,71,.25), rgba(255,111,208,.15)); animation: ovglow 1.2s ease-in-out infinite alternate; }
@keyframes ovglow { to { box-shadow: 0 0 18px rgba(255,194,71,.55); } }
@media (prefers-reduced-motion: reduce) { .ov-events li.unlock { animation: none; } }
.btn { font: 700 14px ui-monospace, Menlo, Consolas, monospace; letter-spacing: .05em; color: #d6f4ff; cursor: pointer;
  background: rgba(40, 110, 150, .22); border: 1px solid rgba(140, 220, 255, .45); border-radius: 10px; padding: 9px 16px; }
.btn:hover, .btn:focus-visible { background: rgba(120, 220, 255, .25); outline: none; box-shadow: 0 0 0 2px rgba(140,220,255,.5); }
.btn-primary { color: #04121f; background: var(--game-accent, #8ee8ff); border-color: transparent; }
.btn-primary:hover, .btn-primary:focus-visible { background: #fff; color: #04121f; }
.btn kbd { font: inherit; font-size: 11px; opacity: .7; border: 1px solid currentColor; border-radius: 4px; padding: 0 4px; margin-left: 4px; }

/* Mobile Arcade touch layer (public/js/touch.js): over the whole stage, only while a level is being played. */
.touch-layer { position: absolute; inset: 0; z-index: 5; display: none; touch-action: none; -webkit-user-select: none; user-select: none;
  -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent; --tl-size: 1; --tl-opacity: .5; --tl-zone: 45%; --tl-big: 78px; }
.arcade-stage.mode-mobile.playing .touch-layer { display: block; }
.tl-zone { position: absolute; top: 0; bottom: 0; left: 0; width: var(--tl-zone); border-right: 2px dashed transparent; display: flex; align-items: center; justify-content: center; }
.touch-layer.left-hand .tl-zone { left: auto; right: 0; border-right: 0; border-left: 2px dashed transparent; }
.tl-hint { font: 700 13px ui-monospace, Menlo, Consolas, monospace; letter-spacing: .15em; color: #d6f4ff; opacity: 0; transition: opacity .4s; text-shadow: 0 0 8px #000; }
.touch-layer.hints .tl-zone { border-color: rgba(142,232,255,.45); background: rgba(142,232,255,.06); }
.touch-layer.hints .tl-hint { opacity: .9; }
.tl-stick { position: absolute; left: 0; top: 0; width: 0; height: 0; opacity: 0; transition: opacity .12s; pointer-events: none; }
.tl-stick::before { content: ''; position: absolute; width: 116px; height: 116px; margin: -58px 0 0 -58px; border-radius: 50%;
  border: 2px solid rgba(160,225,255,.55); background: radial-gradient(circle, rgba(120,210,255,.10), rgba(120,210,255,.02)); }
.tl-knob { position: absolute; width: 50px; height: 50px; margin: -25px 0 0 -25px; border-radius: 50%; background: rgba(170,230,255,.55); box-shadow: 0 0 14px rgba(140,220,255,.5); }
.tl-stick.on { opacity: 1; }
.tl-btns { position: absolute; width: var(--tl-big); height: var(--tl-big); right: calc(18px + env(safe-area-inset-right)); bottom: calc(16px + env(safe-area-inset-bottom)); }
.touch-layer.left-hand .tl-btns { right: auto; left: calc(18px + env(safe-area-inset-left)); }
.tl-btn { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%) translate(var(--tx, 0), var(--ty, 0)); border-radius: 50%; padding: 0;
  font: 700 calc(12px * var(--tl-size)) ui-monospace, Menlo, Consolas, monospace; letter-spacing: .04em; color: #e6f8ff;
  background: rgba(40,110,150,.35); border: 2px solid color-mix(in srgb, var(--game-accent, #8ee8ff) 70%, transparent); opacity: var(--tl-opacity);
  touch-action: none; -webkit-user-select: none; user-select: none; transition: opacity .08s, background .08s; }
.tl-btn.primary { background: color-mix(in srgb, var(--game-accent, #8ee8ff) 28%, transparent); font-size: calc(14px * var(--tl-size)); }
.tl-btn.on { opacity: 1; background: color-mix(in srgb, var(--game-accent, #8ee8ff) 60%, transparent); }
.tl-btn[hidden] { display: none; }
.tl-auto, .tl-pause { position: absolute; top: calc(8px + env(safe-area-inset-top)); font: 700 12px ui-monospace, Menlo, Consolas, monospace; color: #d6f4ff;
  background: rgba(4,16,30,.6); border: 1px solid rgba(140,220,255,.5); border-radius: 999px; touch-action: none; opacity: max(var(--tl-opacity), .6); }
.tl-auto { right: calc(12px + env(safe-area-inset-right)); padding: 8px 12px; min-height: 36px; }
.tl-auto.on { color: #04121f; background: var(--game-accent, #8ee8ff); }
.tl-pause { left: calc(10px + env(safe-area-inset-left)); width: 40px; height: 40px; border-radius: 10px; }
.touch-layer.left-hand .tl-auto { right: auto; left: calc(12px + env(safe-area-inset-left)); }
.touch-layer.left-hand .tl-pause { left: auto; right: calc(10px + env(safe-area-inset-right)); }
/* Mobile Arcade: the game fills the screen edge to edge; overlays sit above the touch layer. */
.arcade-stage.mode-mobile { padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); box-sizing: border-box; }
.arcade-stage.mode-mobile .arcade-screen { box-shadow: none; border-radius: 0; }
.rotate-msg { display: none; position: fixed; inset: 0; z-index: 60; align-items: center; justify-content: center; text-align: center; padding: 24px;
  background: rgba(1,6,13,.94); color: #d6f4ff; font: 15px/1.5 ui-monospace, Menlo, Consolas, monospace; }
.rotate-icon { font-size: 54px; color: var(--game-accent, #8ee8ff); animation: rot 2.4s ease-in-out infinite; }
@keyframes rot { 0%, 30% { transform: rotate(0); } 60%, 100% { transform: rotate(90deg); } }
@media (prefers-reduced-motion: reduce) { .rotate-icon { animation: none; } }
@media (orientation: portrait) { .arcade-stage.mode-mobile:not(.portrait-ok) .rotate-msg { display: flex; } }
.ov-diagram { margin: 8px auto 2px; max-width: 360px; }
.ctl-diagram { width: 100%; height: auto; display: block; font-family: ui-monospace, Menlo, Consolas, monospace; }
.ov-mode { margin: 8px 0 0; font-size: 12px; color: #9fcbe0; } .ov-mode b { color: #fff; }
.ov-tutorial { margin: 8px 0; padding: 8px 10px; border-radius: 8px; border: 1px solid rgba(255,194,71,.45); background: rgba(255,194,71,.1); color: #ffe6b0; }
/* Small screens: overlays escape the (small) canvas and cover the viewport so buttons are always reachable. */
@media (max-width: 720px), (max-height: 520px) {
  .arcade-overlay { position: fixed; z-index: 40; }
  .ov-card { padding: 14px 16px; }
}
.ov-events li > svg:first-child:not(.badge-svg) { width: 16px; height: 16px; flex: none; }
/* Short landscape screens (phones): wider, denser cards; diagram beside the text; buttons always reachable. */
.ov-buttons { clear: both; }
@media (max-height: 520px) and (orientation: landscape) {
  .ov-card { max-width: min(860px, 96%); padding: 10px 16px 6px; font-size: 12.5px; line-height: 1.35; }
  .ov-kicker { font-size: 11px; }
  .ov-title { font-size: 22px; margin: 0 0 2px; }
  .ov-sub { margin: 0 0 6px; }
  .ov-diagram { float: left; width: 44%; max-width: 330px; margin: 2px 14px 4px 0; }
  .ov-controls { margin: 4px auto 2px; }
  .ov-tutorial { margin: 4px 0; padding: 5px 8px; }
  .ov-buttons { position: sticky; bottom: -6px; margin-top: 8px; padding: 6px 0; background: rgba(4, 16, 30, .97); }
  .ov-buttons .btn { padding: 8px 14px; }
}

/* Dive meter: level progress on the left edge of every game (public/js/runtime.js). */
.arcade-frame { position: relative; display: flex; align-items: stretch; gap: 6px; }
.arcade-meter { flex: none; width: 34px; display: flex; flex-direction: column; align-items: center; gap: 4px; box-sizing: border-box; padding: 2px 0;
  font: 700 11px ui-monospace, Menlo, Consolas, monospace; color: #9fcbe0; pointer-events: none; }
.meter-goal { color: #ffc247; letter-spacing: .02em; text-shadow: 0 0 8px rgba(255,194,71,.6); }
.meter-track { position: relative; flex: 1; width: 16px; min-height: 0; border-radius: 9px; overflow: hidden; background: rgba(255,255,255,.06);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--game-accent, #8ee8ff) 40%, transparent); }
.meter-fill { position: absolute; left: 0; right: 0; bottom: 0; height: 0; border-radius: 0 0 7px 7px;
  background: linear-gradient(to top, color-mix(in srgb, var(--game-accent, #8ee8ff) 55%, #04121f), var(--game-accent, #8ee8ff));
  box-shadow: 0 0 12px var(--game-accent, #8ee8ff); }
.meter-fill::after { content: ''; position: absolute; left: 0; right: 0; top: 0; height: 3px; background: #fff; opacity: .85; }
.meter-track i { position: absolute; left: 0; right: 0; height: 1px; background: rgba(255,255,255,.28); }
.meter-pct { color: #fff; }
.arcade-stage.playing .meter-fill { animation: meterpulse 1.6s ease-in-out infinite alternate; }
@keyframes meterpulse { to { box-shadow: 0 0 20px var(--game-accent, #8ee8ff); filter: brightness(1.15); } }
.arcade-meter.full .meter-fill { background: linear-gradient(to top, #ffb347, #ffe27a); box-shadow: 0 0 22px #ffc247; }
.arcade-meter.full .meter-pct { color: #ffe27a; }
.arcade-meter.lost .meter-fill { filter: saturate(.55) brightness(.8); animation: none; }
.meter-call { position: absolute; left: 46px; z-index: 4; display: none; padding: 3px 9px; border-radius: 999px; white-space: nowrap; pointer-events: none;
  font: 700 11px ui-monospace, Menlo, Consolas, monospace; letter-spacing: .12em; color: #04121f; background: var(--game-accent, #8ee8ff);
  box-shadow: 0 0 14px color-mix(in srgb, var(--game-accent, #8ee8ff) 70%, transparent); transform: translateY(50%); }
.meter-call.gold { background: #ffc247; box-shadow: 0 0 16px rgba(255,194,71,.8); }
.meter-call.show { display: block; animation: metercall 1.9s ease-out both; }
@keyframes metercall { 0% { opacity: 0; margin-left: -10px; } 12%, 75% { opacity: 1; margin-left: 0; } 100% { opacity: 0; margin-left: 0; } }
@media (prefers-reduced-motion: reduce) { .arcade-stage.playing .meter-fill, .meter-call.show { animation: none; } }
/* Mobile Arcade: slimmer, and clear of the pause button in the top-left corner. */
.arcade-stage.mode-mobile .arcade-frame { gap: 4px; }
.arcade-stage.mode-mobile .arcade-meter { width: 26px; font-size: 9px; padding-top: 52px; }
.arcade-stage.mode-mobile .meter-track { width: 12px; }
.arcade-stage.mode-mobile .meter-call { left: 34px; }

/* Story campaign (Evacuation): objective line, the evac sub with its passenger portholes, mastery line */
.ov-objective { margin: 6px 0; padding: 7px 10px; border-radius: 8px; border: 1px solid rgba(255, 194, 71, .45); background: rgba(255, 194, 71, .1); color: #ffe6b0; }
.ov-objective b { color: #ffc247; letter-spacing: .12em; text-transform: uppercase; font-size: 11px; margin-right: 6px; }
.ov-mastery { color: #ffc247; font-weight: 700; }
.evac-sub { text-align: center; margin: 6px auto; }
.evac-sub svg { display: block; width: min(220px, 60%); height: auto; margin: 0 auto; }
.evac-sub .hull { fill: #e8f4f8; } .evac-sub .fin { fill: #9fc3d1; } .evac-sub .eye { fill: #0b2a3c; stroke: #8ee8ff; stroke-width: 2; }
.evac-sub circle { fill: #0b2a3c; stroke: #5f8799; stroke-width: 1.5; }
.evac-sub circle.on { fill: #ffc247; stroke: #fff2c9; filter: drop-shadow(0 0 4px #ffc247); }
.evac-count { font-size: 12px; color: #bfefff; margin-top: 2px; } .evac-count b { color: #ffc247; font-size: 15px; }
@media (max-height: 520px) { .evac-sub svg { width: 130px; } .ov-objective { margin: 3px 0; padding: 4px 8px; } }

/* The Evacuation intro (js/evac-intro.js): a layer over the game screen */
.evac-intro { position: absolute; inset: 0; z-index: 5; overflow: hidden; }
.evac-intro canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.ei-bars { position: absolute; inset: 0; pointer-events: none; box-shadow: inset 0 34px 0 #01040a, inset 0 -34px 0 #01040a; transition: box-shadow .8s ease; }
.evac-intro.live .ei-bars { box-shadow: inset 0 0 0 #01040a; }
.ei-caption { position: absolute; left: 50%; bottom: 9%; transform: translateX(-50%); width: min(720px, 88%); text-align: center; padding: 8px 14px 10px; border-radius: 10px;
  background: rgba(1, 6, 13, .78); border: 1px solid rgba(255, 194, 71, .4); color: #f2fbff; font: 16px/1.4 ui-monospace, Menlo, Consolas, "DejaVu Sans Mono", monospace; min-height: 3.6em; }
.evac-intro.live .ei-caption { bottom: auto; top: 16%; }
.ei-who { display: block; font-size: 10px; letter-spacing: .25em; color: #ffc247; margin-bottom: 3px; }
.ei-who::before { content: '● '; color: #7dff8a; animation: blink 1s steps(1) infinite; }
.ei-skip { position: absolute; top: 44px; right: 12px; opacity: .8; }
.ei-skip kbd { font-size: 10px; opacity: .7; }
@media (hover: none) { .ei-skip kbd { display: none; } }
@media (max-height: 420px), (max-width: 560px) { .ei-caption { font-size: 12.5px; padding: 5px 10px 6px; bottom: 5%; } .ei-skip { top: 6px; } .ei-bars { box-shadow: none; } }
/* The mission card that follows it: the live game stays in view behind, the card sits to the left of the sub */
.arcade-overlay.cine { background: linear-gradient(90deg, rgba(1, 6, 13, .7), rgba(1, 6, 13, 0) 52%); backdrop-filter: none; justify-content: flex-start; align-items: flex-start; padding: 13% 0 0 3%; }
.arcade-overlay.cine .ov-card { max-width: min(360px, 44%); text-align: left; background: rgba(4, 16, 30, .86); animation: cinein .6s ease both; }
.arcade-overlay.cine .ov-title { letter-spacing: .14em; color: #ffc247; text-shadow: 0 0 16px rgba(255, 194, 71, .6); }
.arcade-overlay.cine .ov-buttons { justify-content: flex-start; }
.arcade-overlay.cine .ov-buttons .btn-primary { font-size: 16px; padding: 12px 20px; }
.cine-obj { margin: 10px 0; padding: 9px 12px; border-radius: 8px; border: 1px solid rgba(255, 194, 71, .45); background: rgba(255, 194, 71, .1); }
.cine-obj p { margin: 3px 0 0; color: #fff; } .cine-obj .cine-more { color: #ffe6b0; font-size: 12.5px; }
.cine-keys { font-size: 11.5px; color: #9fcbe0; margin: 8px 0 0; } .cine-keys b { color: var(--game-accent, #8ee8ff); }
@keyframes cinein { from { opacity: 0; transform: translateX(-16px); } }
@media (max-width: 700px), (max-height: 420px) {
  .arcade-overlay.cine { background: linear-gradient(0deg, rgba(1, 6, 13, .8), rgba(1, 6, 13, 0) 70%); align-items: flex-end; justify-content: center; padding: 8px; }
  .arcade-overlay.cine .ov-card { max-width: min(560px, 96%); padding: 8px 14px; }
  .arcade-overlay.cine .ov-title { font-size: 18px; } .cine-obj { margin: 5px 0; padding: 5px 10px; } .cine-keys { display: none; }
}
@media (prefers-reduced-motion: reduce) { .arcade-overlay.cine .ov-card { animation: none; } }
