:root {
  color-scheme: dark;
  font-family: Inter, system-ui, sans-serif;
  background: #06111f;
  color: #ecf7ff;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: radial-gradient(circle at top, #12345a 0%, #04101b 65%);
}
.layout {
  width: min(1080px, calc(100vw - 24px));
  display: grid;
  gap: 18px;
  grid-template-columns: minmax(280px, 360px) minmax(320px, 1fr);
}
.panel {
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 24px;
  background: rgba(7, 18, 32, .8);
  box-shadow: 0 18px 50px rgba(0,0,0,.32);
}
.hero { padding: 28px; display: flex; flex-direction: column; }
.eyebrow { margin: 0 0 10px; font-size: 12px; letter-spacing: .18em; text-transform: uppercase; color: #7dd3fc; }
h1 { margin: 0 0 12px; font-size: clamp(2.4rem, 4vw, 4rem); }
.copy { color: #c6d5e7; line-height: 1.65; }
.hud { display: grid; gap: 12px; grid-template-columns: repeat(3, 1fr); margin: 24px 0; }
.hud div { padding: 14px; border-radius: 16px; background: rgba(255,255,255,.04); }
.hud span { display:block; font-size: 12px; color: #9fb4c9; text-transform: uppercase; letter-spacing: .1em; }
.hud strong { display:block; margin-top: 8px; font-size: 1.6rem; }
button {
  border: 0; border-radius: 999px; padding: 14px 18px; font-weight: 700;
  background: linear-gradient(135deg, #38bdf8, #22c55e); color: #03131c; cursor: pointer;
  box-shadow: 0 10px 24px rgba(34,197,94,.22);
}
#status {
  margin: 0;
  color: #e2e8f0;
  min-height: 24px;
  text-align: center;
}
.board-wrap {
  position: relative;
  overflow: hidden;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  align-items: center;
}
.mobile-controls {
  width: min(100%, 480px);
  display: grid;
  grid-template-columns: minmax(150px, 180px) 1fr;
  gap: 14px;
  align-items: center;
}
.touch-controls {
  width: min(100%, 280px);
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-areas:
    '. up .'
    'left down right';
  gap: 10px;
}
.touch-btn {
  min-height: 56px;
  border-radius: 18px;
  background: rgba(255,255,255,.08);
  color: #ecf7ff;
  font-size: 1.4rem;
  font-weight: 700;
  box-shadow: none;
}
.touch-btn.up { grid-area: up; }
.touch-btn.left { grid-area: left; }
.touch-btn.down { grid-area: down; }
.touch-btn.right { grid-area: right; }
canvas {
  width: min(100%, 480px); height: auto; aspect-ratio: 1 / 1;
  border-radius: 20px; border: 1px solid rgba(255,255,255,.12); background: linear-gradient(180deg, #081522, #0c1c2f);
  box-shadow: 0 0 0 1px rgba(56,189,248,.08), 0 24px 40px rgba(0,0,0,.3);
}
.legend { width: 100%; display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; color: #9fb4c9; font-size: 14px; }
@media (max-width: 880px) {
  body { place-items: start center; padding: 12px 0; }
  .layout { grid-template-columns: 1fr; }
  .hero { order: 1; }
  .board-wrap { order: 2; margin-top: -6px; }
  .mobile-controls { grid-template-columns: 1fr; }
  #startButton { width: 100%; min-height: 58px; }
  .touch-controls { width: 100%; max-width: 360px; }
  .touch-btn { min-height: 72px; font-size: 1.65rem; }
}
@media (max-width: 520px) {
  .layout { width: min(100vw - 12px, 520px); gap: 10px; }
  .hero, .board-wrap { padding: 16px; border-radius: 20px; }
  .hud { grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 16px 0 8px; }
  .hud div { padding: 12px; }
  .legend { font-size: 12px; }
}
