:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, sans-serif;
  color: #f1f5f1;
  background: #11181e;
  --muted: #9daeb4;
  --border: #33434c;
  --signal: #f6ce73;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
main { width: min(100% - 2rem, 60rem); margin: 0 auto; padding: 1.5rem 0; }
header { display: flex; align-items: end; justify-content: space-between; gap: 1rem; margin-bottom: .95rem; }
h1, h2, p { margin: 0; }
h1, h2 { line-height: 1.05; letter-spacing: -.045em; }
h1 { font-size: clamp(1.65rem, 4vw, 2.75rem); }
h2 { font-size: clamp(1.75rem, 5vw, 2.65rem); }
.eyebrow { margin-bottom: .45rem; font-weight: 800; color: var(--signal); font-size: .69rem; letter-spacing: .18em; text-transform: uppercase; }

.game { border: 1px solid var(--border); border-radius: 1rem; overflow: hidden; background: #182329; box-shadow: 0 1.5rem 4rem #070b12a0; }
.hud { display: flex; align-items: center; gap: clamp(.75rem, 3vw, 2rem); min-height: 3.5rem; padding: .65rem 1rem; background: #202d35; border-bottom: 1px solid var(--border); font-variant-numeric: tabular-nums; }
.hud span { font-size: .72rem; color: var(--muted); }
.hud strong { display: block; font-size: 1rem; }
.parcel { margin-inline-start: auto; display: flex; align-items: center; gap: .55rem; }
#parcel-color { flex: 0 0 auto; width: .7rem; height: .7rem; background: var(--parcel, var(--signal)); border-radius: .2rem; box-shadow: 0 0 .75rem var(--parcel, var(--signal)); }

.stage { position: relative; min-height: 14rem; height: clamp(21rem, 52vh, 33rem); background: radial-gradient(ellipse at 55% 30%, #35505a, #1a2b34 65%, #101d23); }
canvas { display: block; width: 100%; height: 100%; outline: 0; }
canvas:focus-visible { outline: 2px solid var(--signal); outline-offset: -3px; }
.overlay { position: absolute; inset: 0; display: grid; align-items: center; justify-items: center; padding: 1rem; background: #0b131ab0; }
.panel { width: min(100%, 26rem); padding: clamp(1.15rem, 4vw, 2rem); border: 1px solid #52636a; background: #132228ec; border-radius: .85rem; box-shadow: 0 1rem 3rem #091119ad; }
.panel > p:not(.eyebrow) { color: #bac7cb; margin: .8rem 0 1.15rem; line-height: 1.55; }
.feedback { min-height: 4rem; padding: .85rem 1rem; display: flex; align-items: center; justify-content: space-between; gap: .5rem 1rem; flex-wrap: wrap; line-height: 1.38; }
#message { font-size: .94rem; }
.keys { font-size: .78rem; color: var(--muted); }
.keys span { padding-inline: .18rem; }
kbd { font-family: inherit; font-weight: 750; color: #dce8e6; }

button { cursor: pointer; min-height: 2.6rem; padding: .55rem .8rem; border: 1px solid #4c626a; border-radius: .5rem; background: #263741; color: #eef7f5; font: inherit; font-size: .85rem; font-weight: 750; }
button:hover { background: #334954; }
button:active { background: #46616b; }
button:disabled { opacity: .6; cursor: default; }
button:focus-visible, a:focus-visible { outline: 2px solid var(--signal); outline-offset: 2px; }
.primary { background: var(--signal); border-color: #fce2a1; color: #20231d; }
.primary:hover { background: #ffe19a; }
.touch { display: none; padding: 0 .85rem .8rem; align-items: center; justify-content: space-between; gap: .75rem; }
.dpad { display: grid; grid-template-columns: repeat(3, minmax(2.6rem, 1fr)); gap: .25rem; touch-action: none; }
.dpad button { padding: .15rem; font-size: 1.2rem; }
.dpad [data-move="up"] { grid-column: 2; }
.dpad [data-move="left"] { grid-column: 1; }
.catalog { display: inline-block; margin-top: .9rem; color: var(--signal); font-size: .84rem; }

@media (max-width: 700px), (pointer: coarse) {
  main { padding: .8rem 0; width: min(100% - 1rem, 60rem); }
  header { align-items: center; }
  .stage { height: clamp(16rem, 48svh, 28rem); }
  .hud, .feedback { padding-inline: .7rem; }
  #reset { max-width: 6rem; font-size: .72rem; }
}

@media (max-width: 480px), (pointer: coarse) {
  .keys { display: none; }
  .touch[data-playing="true"] { display: flex; }
}

@media (max-width: 405px) {
  h1 { font-size: clamp(1.2rem, 6vw, 1.7rem); }
  .hud { gap: .55rem; }
  .hud strong { font-size: .84rem; }
  .hud span { font-size: .66rem; }
  .touch #action { font-size: .75rem; }
}

@media (max-height: 440px) and (orientation: landscape) {
  main { padding-block: .45rem; }
  .stage { height: 64svh; }
  .panel { padding: .7rem 1rem; }
}
