:root {
  color-scheme: dark;
  --bg: #10151f;
  --panel: #17202e;
  --panel-2: #202c3e;
  --line: #314056;
  --text: #f6f8fb;
  --muted: #a9b4c3;
  --accent: #55d782;
  --accent-2: #f4c95d;
  --danger: #ff6b6b;
  --shadow: 0 20px 60px rgba(0, 0, 0, 0.34);
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at 20% 10%, rgba(85, 215, 130, 0.14), transparent 30%),
    radial-gradient(circle at 80% 0%, rgba(244, 201, 93, 0.12), transparent 28%),
    var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button {
  font: inherit;
}

.app {
  width: min(100%, 980px);
  min-height: 100vh;
  margin: 0 auto;
  padding: 28px 18px;
  display: grid;
  place-items: center;
}

.game-shell {
  width: min(100%, 720px);
}

.hud {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 14px;
}

.hud > div {
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(23, 32, 46, 0.86);
  box-shadow: var(--shadow);
}

.label {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 13px;
}

.hud strong {
  display: block;
  font-size: 28px;
  line-height: 1;
}

.board-wrap {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0c1119;
  box-shadow: var(--shadow);
  aspect-ratio: 1;
}

canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  padding: 24px;
  text-align: center;
  background: rgba(12, 17, 25, 0.78);
  backdrop-filter: blur(4px);
}

.overlay.hidden {
  display: none;
}

.overlay h1 {
  margin: 0 0 10px;
  font-size: clamp(42px, 10vw, 82px);
  line-height: 0.95;
  letter-spacing: 0;
}

.overlay p {
  max-width: 320px;
  margin: 0 0 22px;
  color: var(--muted);
  line-height: 1.6;
}

.primary-action,
.controls button,
.touch-pad button {
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  background: var(--panel-2);
  cursor: pointer;
}

.primary-action {
  min-width: 132px;
  height: 46px;
  border-color: color-mix(in srgb, var(--accent) 58%, var(--line));
  color: #08130d;
  background: var(--accent);
  font-weight: 800;
}

.controls {
  display: flex;
  gap: 10px;
  margin-top: 14px;
}

.controls button {
  flex: 1;
  height: 44px;
}

.primary-action:hover,
.controls button:hover,
.touch-pad button:hover {
  filter: brightness(1.08);
}

.touch-pad {
  width: 184px;
  margin: 18px auto 0;
  display: grid;
  grid-template-columns: repeat(3, 56px);
  grid-template-rows: repeat(3, 48px);
  gap: 6px;
}

.touch-pad button {
  font-size: 18px;
  font-weight: 800;
}

.touch-pad .up {
  grid-column: 2;
  grid-row: 1;
}

.touch-pad .left {
  grid-column: 1;
  grid-row: 2;
}

.touch-pad .right {
  grid-column: 3;
  grid-row: 2;
}

.touch-pad .down {
  grid-column: 2;
  grid-row: 3;
}

@media (max-width: 520px) {
  .app {
    padding: 12px;
    align-items: start;
  }

  .hud {
    gap: 8px;
  }

  .hud > div {
    padding: 10px;
  }

  .label {
    font-size: 12px;
  }

  .hud strong {
    font-size: 22px;
  }
}
