:root {
  color-scheme: dark;
  --ink: #f7f0de;
  --muted: #b5c4bf;
  --deep: #10283a;
  --panel: #173a49;
  --panel-soft: #204b57;
  --line: #5d8d88;
  --sun: #ffd166;
  --coral: #f17863;
  --mint: #8ad5b3;
  --cream: #f7e6c4;
  font-family: "Trebuchet MS", "Segoe UI", system-ui, sans-serif;
  background: var(--deep);
  color: var(--ink);
  font-size: 16px;
}

* { box-sizing: border-box; }
body { min-width: 0; overflow-x: hidden; margin: 0; background: radial-gradient(circle at 86% 0%, #28586a 0, transparent 38%), var(--deep); }
button { min-height: 44px; border: 1px solid var(--line); border-radius: 12px; color: var(--ink); font: inherit; font-weight: 700; cursor: pointer; touch-action: manipulation; }
button:focus-visible { outline: 3px solid var(--sun); outline-offset: 3px; }
button:disabled { cursor: not-allowed; opacity: .5; }
.shell { width: min(1180px, 100%); margin: 0 auto; padding: clamp(18px, 4vw, 42px) clamp(14px, 4vw, 48px) 26px; }
.masthead { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 22px; }
.brand-lockup { min-width: 0; }
.eyebrow, .screen-kicker, .control-kicker { color: var(--sun); font-size: 11px; font-weight: 800; letter-spacing: .16em; text-transform: uppercase; }
h1 { max-width: 760px; margin: 8px 0 4px; color: var(--cream); font-size: clamp(28px, 5vw, 52px); letter-spacing: -.045em; line-height: .98; }
.brand-lockup p { margin: 0; color: var(--muted); font-size: 15px; }
.header-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
.game-switch { display: flex; gap: 4px; padding: 4px; border: 1px solid #3c6c71; border-radius: 14px; background: #112f3eaa; }
.game-tab { min-width: 62px; border: 0; border-radius: 9px; background: transparent; color: var(--muted); }
.game-tab[aria-pressed="true"] { background: var(--sun); color: #173a49; }
.secondary-button { padding: 9px 15px; background: #173d4a; }
.secondary-button:hover { background: #265564; }
.game-frame { position: relative; height: min(65vw, 620px); min-height: 360px; overflow: hidden; border: 1px solid #60938f; border-radius: 22px; background: #153847; box-shadow: 0 26px 70px #071a28aa, inset 0 1px #ffffff24; isolation: isolate; }
#game-canvas { display: block; width: 100%; height: 100%; outline: none; }
.hud { position: absolute; z-index: 2; top: 16px; left: 16px; right: 16px; display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; pointer-events: none; }
.hud-pill { min-width: 124px; padding: 10px 13px; border: 1px solid #b9d7c355; border-radius: 12px; background: #10283ad9; box-shadow: 0 6px 18px #071a2838; backdrop-filter: blur(8px); }
.hud-pill.compact { min-width: 88px; text-align: right; }
.hud-label { display: block; margin-bottom: 3px; color: var(--muted); font-size: 10px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
.hud-pill strong { display: block; color: var(--cream); font-size: 15px; }
.hud-meter { display: block; height: 3px; margin-top: 7px; overflow: hidden; border-radius: 2px; background: #ffffff24; }
.hud-meter i { display: block; width: 0; height: 100%; border-radius: 2px; background: linear-gradient(90deg, var(--mint), var(--sun)); transition: width .28s ease-out; }
@keyframes hud-bump { 0% { transform: scale(1); } 35% { transform: scale(1.1); } 100% { transform: scale(1); } }
.hud-pill.bump { animation: hud-bump .34s ease-out; border-color: #ffd166aa; }
.toast { position: absolute; z-index: 3; left: 50%; bottom: 26px; transform: translateX(-50%); padding: 10px 16px; border: 1px solid #ffe5a977; border-radius: 999px; background: #132e3de8; color: var(--cream); font-weight: 700; white-space: nowrap; }
.screen { position: absolute; z-index: 4; inset: 0; display: grid; place-items: center; padding: 24px; background: linear-gradient(90deg, #10283ac2, #10283a88); }
.screen[hidden] { display: none; }
.screen-card { width: min(450px, 100%); padding: clamp(24px, 5vw, 42px); border: 1px solid #b9d7c355; border-radius: 20px; background: #173a49ed; box-shadow: 0 18px 50px #071a2870; backdrop-filter: blur(14px); }
.compact-card { width: min(380px, 100%); }
.success-card { border-color: #ffd16688; }
.screen-card h2 { margin: 10px 0 12px; color: var(--cream); font-size: clamp(25px, 4vw, 38px); letter-spacing: -.04em; line-height: 1.04; }
.screen-card p { margin: 0 0 22px; color: var(--muted); line-height: 1.65; }
.primary-button { display: inline-flex; align-items: center; justify-content: space-between; gap: 30px; width: 100%; padding: 12px 17px; border-color: #ffe49b; background: var(--sun); color: #173a49; }
.primary-button:hover { background: #ffe496; }
.screen-note { margin-top: 15px !important; margin-bottom: 0 !important; color: #9fbab2 !important; font-size: 12px; }
.control-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 18px 4px 8px; }
.control-copy { min-width: 0; }
.control-copy p { margin: 4px 0 0; color: var(--muted); font-size: 14px; line-height: 1.45; }
.buttons { display: flex; gap: 8px; flex-shrink: 0; }
.touch-controls { display: none; grid-template-columns: repeat(3, minmax(60px, 76px)); justify-content: center; gap: 8px; padding: 12px 0 4px; }
.touch-controls-topdown { grid-template-columns: repeat(3, minmax(52px, 76px)); grid-template-areas: ". up ." "left down right"; }
.touch-controls-topdown [data-dir="up"] { grid-area: up; }
.touch-controls-topdown [data-dir="left"] { grid-area: left; }
.touch-controls-topdown [data-dir="down"] { grid-area: down; }
.touch-controls-topdown [data-dir="right"] { grid-area: right; }
.touch-controls button { border-color: #7aa49b; background: #1d4a56; font-size: 23px; }
.touch-controls button:active,
.touch-controls button[aria-pressed="true"] { border-color: var(--sun); background: #2f6c70; color: var(--sun); transform: translateY(1px); }
.accessibility-status { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; }
footer { display: flex; justify-content: space-between; gap: 15px; padding-top: 15px; border-top: 1px solid #5d8d8844; color: #88a59e; font-size: 12px; line-height: 1.5; }
footer a { color: #b9d7c3; text-decoration-color: #ffd16688; text-underline-offset: 3px; }
footer a:hover { color: var(--sun); }
footer span:last-child { text-align: right; }
body[data-embed="true"] { min-width: 0; height: 100vh; background: #10283a; overflow: hidden; }
body[data-embed="true"] .shell { width: 100%; max-width: none; padding: 0 0 8px; }
body[data-embed="true"] .masthead,
body[data-embed="true"] footer { display: none; }
body[data-embed="true"] .game-frame { height: min(calc(100vh - 72px), 620px); min-height: 300px; border: 0; border-radius: 0; box-shadow: none; }
body[data-embed="true"] .control-row { padding: 8px 12px 0; }
body[data-embed="true"] .control-copy p { font-size: 12px; }
body[data-embed="true"] .touch-controls { padding-bottom: 0; }
/* Embedded games must keep the canvas, status controls, and touch pad inside
   the iframe. The old min-height on .game-frame consumed the narrow viewport
   and clipped the controls below it. Let the shell own the available height. */
body[data-embed="true"] .shell { display: flex; flex-direction: column; min-height: 100vh; height: 100vh; }
body[data-embed="true"] .game-frame { flex: 1 1 auto; height: auto; min-height: 0; }
@media (max-width: 720px) {
  .masthead { align-items: flex-start; flex-direction: column; }
  .header-actions { width: 100%; justify-content: space-between; }
  .game-frame { height: min(72vw, 540px); min-height: 350px; border-radius: 16px; }
  .hud { top: 10px; left: 10px; right: 10px; gap: 5px; }
  .hud-pill { min-width: 0; padding: 8px 9px; }
  .hud-pill:nth-child(2) { flex: 1; }
  .hud-pill strong { font-size: 12px; }
  .control-row { align-items: flex-start; flex-direction: column; }
  .buttons { width: 100%; }
  .buttons button { flex: 1; }
  .touch-controls:not([hidden]) { display: grid; }
  footer { flex-direction: column; }
  footer span:last-child { text-align: left; }
  body[data-embed="true"] .shell { min-height: 100vh; height: 100vh; }
  body[data-embed="true"] .game-frame { min-height: 0; height: auto; }
}
@media (max-width: 420px) {
  .shell { padding-inline: 10px; }
  h1 { font-size: 32px; }
  .game-frame { min-height: 320px; }
  .screen { padding: 12px; }
  .screen-card { padding: 22px; }
  .hud { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: stretch; }
  .hud-pill { min-width: 0; }
  .hud-pill:nth-child(2) { display: block; grid-column: 1 / -1; order: 3; }
  .hud-pill:nth-child(2) strong { overflow-wrap: anywhere; }
}

.shell:fullscreen { width:100vw; height:100dvh; padding:0; overflow:auto; background:#10283a; }
.shell:fullscreen .game-frame { height:calc(100dvh - 150px); }
