:root { color-scheme: light; --ink:#173d42; --teal:#286b68; --paper:#fff7e6; --coral:#ee8565; --gold:#ffce6c; font-family:"Trebuchet MS",system-ui,sans-serif; color:var(--ink); }
* { box-sizing:border-box; }
html,body { height:100%; margin:0; overflow:hidden; }
body { background:#e6ecdc; }
[hidden] { display:none !important; }
.symbols { position:absolute; width:0; height:0; overflow:hidden; }
svg { width:24px; height:24px; fill:none; stroke:currentColor; stroke-width:2; stroke-linecap:round; stroke-linejoin:round; }
button,select { font:inherit; }
button { cursor:pointer; touch-action:manipulation; -webkit-tap-highlight-color:transparent; }
button:disabled { opacity:.45; cursor:default; }
button:focus-visible,select:focus-visible { outline:3px solid #e58a33; outline-offset:3px; }
#game { height:100%; display:grid; grid-template-rows:auto auto minmax(0,1fr) auto; }
header { display:flex; align-items:center; justify-content:space-between; gap:14px; padding:max(8px,env(safe-area-inset-top)) max(14px,env(safe-area-inset-right)) 8px max(14px,env(safe-area-inset-left)); background:var(--ink); color:var(--paper); }
.brand { display:flex; align-items:center; gap:10px; flex-shrink:0; }
.brand>svg { width:33px; height:33px; color:var(--gold); }
.brand small { display:block; font-size:9px; letter-spacing:.12em; text-transform:uppercase; color:#b7d4c6; }
.brand strong { display:block; font:900 28px/.95 "Arial Black",system-ui,sans-serif; letter-spacing:-.07em; }
.brand strong span { color:var(--coral); }
.route-name { margin:0 auto 0 10px; color:#cbe1d7; font-size:12px; font-weight:bold; }
.tools { display:flex; gap:6px; }
.tools button { display:grid; place-items:center; border:1px solid #7a9b96; color:var(--paper); background:#31595b; width:44px; height:44px; border-radius:12px; box-shadow:0 2px 0 #0c292f; }
.tools button[aria-pressed="true"] { color:var(--gold); background:#4a6c58; }
.dashboard { display:flex; justify-content:center; align-items:center; gap:clamp(12px,4vw,64px); padding:8px 12px; background:var(--paper); border-bottom:2px solid #b6c5ac; font-variant-numeric:tabular-nums; }
.stat { display:flex; gap:7px; align-items:center; }
.stat span { font-size:9px; font-weight:900; letter-spacing:.05em; }
.stat strong { font-size:19px; line-height:1; white-space:nowrap; }
.stat svg { width:21px; height:21px; color:var(--teal); }
#lives { color:#bc594b; font-size:17px; letter-spacing:2px; }
.time.urgent { color:#bc4b38; }
.stage { position:relative; min-width:0; min-height:0; isolation:isolate; overflow:hidden; background:#cbd9c8; }
canvas { display:block; width:100%; height:100%; outline:none; touch-action:none; }
.powers { position:absolute; left:12px; top:10px; display:flex; gap:5px; flex-wrap:wrap; pointer-events:none; }
.powers span { border:1px solid #527f73; color:#174b4a; background:#e8fff1e8; padding:6px 9px; border-radius:20px; font-size:11px; font-weight:bold; box-shadow:0 2px 0 #163e4220; }
#slow { background:#fff2cbe8; }
#notice { position:absolute; bottom:8px; left:12px; right:12px; width:fit-content; max-width:calc(100% - 24px); margin:0 auto; padding:6px 12px; border-radius:20px; color:var(--paper); background:#163e42e8; font-size:12px; font-weight:bold; text-align:center; pointer-events:none; }
#notice:empty { display:none; }
.screen { position:absolute; inset:0; display:flex; align-items:safe center; justify-content:center; gap:34px; padding:20px; overflow:auto; overscroll-behavior:contain; background:#143c456b; }
.screen.intro { background:linear-gradient(100deg,#19494bba,#275f6538); }
.postcard { position:relative; flex:0 1 350px; color:var(--ink); background:var(--paper); padding:25px; border:2px solid #fffcf2; border-radius:7px 28px 8px 28px; box-shadow:6px 7px 0 #153b3d55; }
.postcard::before { content:""; position:absolute; width:70px; height:9px; left:25px; top:-5px; transform:rotate(-4deg); background:var(--coral); border:1px solid #a75e43; }
.eyebrow { font-size:10px; font-weight:900; letter-spacing:.08em; color:#9b4e37; margin:0 0 10px; }
h1 { margin:0 0 12px; font:900 clamp(30px,4.6vw,52px)/.96 "Arial Black",system-ui,sans-serif; letter-spacing:-.07em; }
#message { font-size:14px; line-height:1.5; margin:0 0 14px; }
label { display:block; font-size:11px; font-weight:900; margin-bottom:5px; }
select { width:100%; min-height:44px; border:2px solid #9bb5a4; border-radius:10px; padding:8px 10px; background:#fffdf5; color:var(--ink); font-size:13px; font-weight:bold; }
.mode-group { display:flex; gap:6px; margin-top:9px; }
.mode-group button { flex:1; min-height:44px; color:#446259; border:1px solid #a6bfa9; border-radius:10px; background:#eef0de; font-size:12px; font-weight:bold; }
.mode-group button[aria-pressed="true"] { color:#fffbed; background:var(--teal); border-color:#285d57; box-shadow:0 2px 0 #173f3e; }
#stage-hint { font-size:12px; color:#506a5f; line-height:1.4; margin:10px 0; }
#record { margin:8px 0 12px; font-size:11px; font-weight:bold; color:#9b5836; }
.primary { width:100%; min-height:48px; border:2px solid #214d48; border-radius:12px; background:var(--gold); color:var(--ink); box-shadow:0 4px 0 #a97432; font-weight:900; padding:10px; }
.primary:active { transform:translateY(2px); box-shadow:0 2px 0 #a97432; }
.other-actions { display:flex; gap:7px; }
.other-actions button { flex:1; min-height:44px; padding:8px; margin-top:12px; background:transparent; color:var(--ink); border:1px solid #a3b8a5; border-radius:9px; font-size:12px; font-weight:bold; }
#instructions { font-size:11px; line-height:1.4; color:#576c60; margin:14px 0 0; }
.cover-card { flex:0 1 340px; transform:rotate(3deg); padding:9px; border-radius:18px; background:#fff9eb; box-shadow:7px 9px 0 #163d4344; }
.cover-card img { width:100%; display:block; aspect-ratio:3/2; object-fit:cover; border-radius:11px; }
.cover-card span { display:block; padding:16px 12px; font:900 28px/1.05 "Trebuchet MS",sans-serif; letter-spacing:-.05em; }
.screen:not(.intro) .cover-card { display:none; }
.controls { display:flex; justify-content:center; align-items:center; gap:28px; padding:9px max(15px,env(safe-area-inset-right)) max(13px,env(safe-area-inset-bottom)) max(15px,env(safe-area-inset-left)); background:var(--paper); border-top:2px solid #a9bca9; user-select:none; -webkit-user-select:none; }
.dpad { display:grid; grid-template-columns:repeat(4,62px); gap:7px; }
.dpad button { display:flex; align-items:center; justify-content:center; gap:5px; height:54px; border:1px solid #346d62; border-radius:13px; background:linear-gradient(#438c7b,#286d62); color:#fff9e6; box-shadow:0 4px 0 #184b49,inset 0 1px 0 #ffffff60; touch-action:none; }
.dpad button.held,.dpad button:active:not(:disabled) { transform:translateY(3px); box-shadow:0 1px 0 #184b49; background:#1c5a51; }
#left { order:0; } #down { order:1; } #up { order:2; } #right { order:3; }
#left svg { transform:rotate(-90deg); } #down svg { transform:rotate(180deg); } #right svg { transform:rotate(90deg); }
kbd { font:700 10px ui-monospace,monospace; opacity:.8; }
.control-tip { max-width:245px; margin:0; font-size:12px; line-height:1.4; }
.control-tip strong { display:block; margin-bottom:3px; }.control-tip span { color:#5a7064; }
.route-progress { display:flex; align-items:center; gap:7px; border-left:1px solid #bdcbb3; padding-left:20px; }
.route-progress>span { font-size:32px; font-weight:900; letter-spacing:-.08em; color:#32756a; }.route-progress small { font-size:9px; color:#5a7064; }
#game:not([data-phase="playing"]) .dashboard { opacity:.65; }
@media(hover:hover) { button:hover:not(:disabled) { filter:brightness(1.08); } }
@media(max-width:720px) { .cover-card { display:none; }.route-name { display:none; }.route-progress { display:none; }.screen { padding:16px; } }
@media(max-width:500px) {
  header { padding:8px 10px; gap:7px; }.brand { gap:6px; }.brand>svg { width:28px; }.brand strong { font-size:25px; }.brand small { font-size:8px; }.tools { gap:5px; }
  .dashboard { gap:10px; justify-content:space-between; padding:8px 10px; }.stat { gap:4px; }.stat span { font-size:8px; }.stat strong { font-size:16px; }.stat svg { width:18px; }.stat.homes>span { display:none; } #lives { font-size:14px; letter-spacing:0; }
  .controls { padding:8px 12px max(12px,env(safe-area-inset-bottom)); gap:20px; }
  .dpad { grid-template-columns:repeat(3,54px); grid-template-rows:48px 48px; gap:6px; }.dpad button { height:48px; }
  #up { grid-column:2; grid-row:1; }#left { grid-column:1; grid-row:2; }#down { grid-column:2; grid-row:2; }#right { grid-column:3; grid-row:2; }
  .control-tip { font-size:11px; max-width:130px; }.dpad kbd { display:none; }
  .postcard { flex-basis:340px; padding:20px; }h1 { font-size:39px; }#message { font-size:13px; }
  .powers { left:8px; top:6px; }.powers span { padding:4px 7px; font-size:10px; }#notice { font-size:11px; }
}
@media(max-height:560px) and (min-width:501px) {
  #game { grid-template-columns:minmax(0,1fr) 170px; grid-template-rows:48px 34px minmax(0,1fr); }
  header { grid-column:1/-1; padding:2px 10px; }.brand small { display:none; }.brand strong { font-size:24px; }.brand>svg { width:26px; }
  .dashboard { grid-column:1; grid-row:2; padding:5px 10px; gap:20px; }.stat strong { font-size:16px; }.stat span { font-size:8px; }
  .stage { grid-column:1; grid-row:3; }.controls { grid-column:2; grid-row:2/4; border-top:0; border-left:2px solid #a9bca9; padding:8px; flex-direction:column; gap:13px; }
  .dpad { grid-template-columns:repeat(3,44px); grid-template-rows:44px 44px; gap:5px; }.dpad button { height:44px; }.dpad kbd { display:none; }
  #up { grid-column:2; grid-row:1; }#left { grid-column:1; grid-row:2; }#down { grid-column:2; grid-row:2; }#right { grid-column:3; grid-row:2; }
  .control-tip { font-size:10px; text-align:center; }.route-progress { display:none; }.cover-card { display:none; }.screen { padding:9px; align-items:start; }
  .postcard { flex:1; max-width:580px; padding:12px 17px; display:grid; grid-template-columns:1fr 1fr; gap:3px 14px; align-items:center; }
  .eyebrow { grid-column:1; font-size:8px; margin:0; }h1 { grid-column:1; font-size:28px; margin:3px 0; }#message { grid-column:1; font-size:11px; margin:3px 0; }
  #selection { grid-column:2; grid-row:1/4; }select { font-size:11px; } .mode-group { margin-top:5px; }.mode-group button { font-size:10px; }
  #stage-hint { font-size:10px; margin:5px 0; }#record { font-size:9px; margin:3px 0; }.primary { grid-column:2; min-height:44px; }.other-actions { grid-column:1; grid-row:4; }.other-actions button { margin:0; }#instructions { grid-column:1; grid-row:4; font-size:9px; margin:0; }
}
@media(max-height:620px) and (max-width:500px) {
  .screen { padding:8px; }
  .postcard { padding:12px; border-radius:6px 18px 6px 18px; }
  h1 { font-size:25px; margin:0 0 6px; line-height:1; }
  .eyebrow { font-size:8px; margin-bottom:5px; }
  .screen.intro :is(#message,#stage-hint,#instructions,#record) { display:none; }
  #selection label { font-size:10px; margin-bottom:3px; }
  select { font-size:12px; padding:7px; }
  .mode-group { margin-top:6px; }
  .primary { min-height:44px; margin-top:9px; padding:8px; font-size:13px; }
}
@media(max-width:360px) {
  .dashboard { gap:6px; padding-inline:8px; }
  .stat { gap:3px; }
  #lives { font-size:13px; }
}
.reward { display:flex; align-items:center; gap:12px; margin:4px 0 14px; color:#825322; font-size:11px; font-weight:900; text-transform:uppercase; letter-spacing:.07em; }
.reward svg { flex:none; width:54px; height:54px; padding:12px; color:#825322; background:linear-gradient(135deg,#fff0a6,#efb44c); border:2px solid #fff8cf; outline:2px solid #d99737; border-radius:50%; box-shadow:0 4px 0 #b97c33; }
.victory .postcard { border-color:#f7d98c; box-shadow:0 0 0 5px #fff0b533,5px 7px 0 #183d3d44; animation:prize-arrival .6s ease-out both; }
#game[data-phase="complete"] .controls { display:none; }
@keyframes prize-arrival { from { opacity:0; transform:translateY(16px) scale(.96); } to { opacity:1; transform:none; } }
@media(max-height:620px) { .reward { gap:9px; margin-bottom:9px; font-size:10px; }.reward svg { width:36px; height:36px; padding:7px; } }
@media(max-height:560px) and (min-width:501px) {
  #game[data-phase="complete"] { grid-template-columns:minmax(0,1fr); }
  .victory .postcard { grid-template-columns:1fr 1fr; }
  .victory .eyebrow { display:none; }.victory .reward { grid-column:1; grid-row:1; margin:0; }
  .victory h1 { grid-column:1; grid-row:2; }.victory #message { grid-column:1; grid-row:3; }
  .victory .primary { grid-column:2; grid-row:1/3; }.victory .other-actions { grid-column:2; grid-row:3; }
}
@media(prefers-reduced-motion:reduce) { .victory .postcard { animation:none; } }
