:root {
  color-scheme: dark;
  --bg: #101315;
  --panel: #181d20;
  --panel-2: #20262a;
  --text: #f4f0e8;
  --muted: #aeb7b7;
  --line: #334044;
  --green: #55d66b;
  --apple: #ff4d5a;
  --gold: #ffd166;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  min-width: 320px;
  background:
    linear-gradient(130deg, rgba(85, 214, 107, 0.14), transparent 34%),
    linear-gradient(310deg, rgba(255, 77, 90, 0.1), transparent 38%),
    var(--bg);
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

button {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  color: var(--text);
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  min-height: 44px;
}

button:hover,
button:focus-visible {
  border-color: var(--green);
  outline: none;
}

.app {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 24px;
}

.game-shell {
  width: min(100%, 980px);
  display: grid;
  gap: 18px;
}

.topbar {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 18px;
  align-items: end;
}

h1 {
  margin: 0;
  font-size: clamp(2rem, 6vw, 4.5rem);
  line-height: 0.95;
  letter-spacing: 0;
}

p {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 1rem;
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(88px, 1fr));
  gap: 8px;
}

.stats div {
  background: rgba(24, 29, 32, 0.92);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
}

.stats span {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
}

.stats strong {
  display: block;
  margin-top: 3px;
  font-size: 1.35rem;
}

.board-wrap {
  position: relative;
  width: min(100%, 74vh, 720px);
  aspect-ratio: 1;
  justify-self: center;
  background: #0d1112;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.32);
}

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

.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  gap: 8px;
  padding: 24px;
  text-align: center;
  background: rgba(10, 13, 14, 0.62);
  backdrop-filter: blur(2px);
}

.overlay.hidden {
  display: none;
}

.overlay strong {
  font-size: clamp(1.35rem, 5vw, 2.4rem);
}

.overlay span {
  color: var(--muted);
}

.controls {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

#startBtn {
  background: var(--green);
  border-color: var(--green);
  color: #071108;
}

.touch-controls {
  display: none;
  grid-template-columns: repeat(3, 58px);
  gap: 8px;
  justify-content: center;
}

.touch-controls button {
  aspect-ratio: 1;
  min-height: 0;
  font-size: 1.35rem;
}

.touch-controls .ghost {
  visibility: hidden;
}

@media (max-width: 760px) {
  .app {
    padding: 14px;
    place-items: start center;
  }

  .topbar {
    grid-template-columns: 1fr;
    align-items: start;
  }

  .stats {
    grid-template-columns: repeat(3, 1fr);
  }

  .stats div {
    padding: 8px;
  }

  .board-wrap {
    width: min(100%, 62vh);
  }

  .touch-controls {
    display: grid;
  }
}
