:root {
  --space: #071013;
  --panel: #101b22;
  --panel-light: #172832;
  --text: #f4f7f4;
  --muted: #9cafb3;
  --line: rgba(255, 255, 255, 0.14);
  --core: #f6b44b;
  --core-deep: #d9582a;
  --leaf: #6fd36f;
  --cyan: #4fb9c7;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 78% 18%, rgba(216, 88, 42, 0.18), transparent 24%),
    radial-gradient(circle at 20% 70%, rgba(79, 185, 199, 0.14), transparent 30%),
    linear-gradient(135deg, #05080c, var(--space));
  color: var(--text);
}

button,
a {
  font: inherit;
}

.game-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: clamp(16px, 4vw, 42px);
}

.game-shell {
  width: min(1180px, 100%);
  display: grid;
  grid-template-columns: minmax(260px, 350px) minmax(320px, 560px) minmax(132px, 170px);
  align-items: center;
  gap: clamp(18px, 4vw, 40px);
}

.game-info {
  min-width: 0;
}

.back-link {
  display: inline-flex;
  min-height: 36px;
  align-items: center;
  color: var(--muted);
  text-decoration: none;
}

.back-link:hover {
  color: var(--text);
}

.eyebrow {
  margin: 26px 0 8px;
  color: var(--core);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(3rem, 8vw, 5.8rem);
  line-height: 0.9;
  letter-spacing: 0;
}

.intro {
  margin: 22px 0 0;
  color: var(--muted);
  font-size: 1.04rem;
  line-height: 1.65;
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 28px;
}

.stats div {
  min-height: 74px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
}

.stats span {
  display: block;
  color: var(--muted);
  font-size: 0.76rem;
  text-transform: uppercase;
}

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

.actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.actions button,
.pad-button {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-light);
  color: var(--text);
  cursor: pointer;
}

.actions button:first-child {
  background: var(--core);
  color: #211208;
  border-color: transparent;
  font-weight: 800;
}

.actions button:hover,
.pad-button:hover {
  transform: translateY(-1px);
}

.board-wrap {
  position: relative;
  width: min(100%, 560px);
  aspect-ratio: 1;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #071014;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.36);
}

#gameCanvas {
  display: block;
  width: 100%;
  height: 100%;
}

.message {
  position: absolute;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  max-width: calc(100% - 32px);
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(7, 16, 19, 0.86);
  color: var(--text);
  font-weight: 700;
  text-align: center;
  pointer-events: none;
}

.message.hidden {
  opacity: 0;
}

.control-pad {
  display: grid;
  grid-template-columns: repeat(3, 48px);
  grid-template-rows: repeat(3, 48px);
  gap: 8px;
  justify-content: center;
}

.pad-button {
  width: 48px;
  height: 48px;
  padding: 0;
  color: var(--cyan);
  font-size: 1.1rem;
  font-weight: 900;
}

.up {
  grid-column: 2;
}

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

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

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

@media (max-width: 980px) {
  .game-shell {
    grid-template-columns: 1fr;
    justify-items: center;
  }

  .game-info {
    width: min(560px, 100%);
  }

  .control-pad {
    grid-template-columns: repeat(3, 56px);
    grid-template-rows: repeat(3, 56px);
  }

  .pad-button {
    width: 56px;
    height: 56px;
  }
}

@media (max-width: 520px) {
  .game-page {
    padding: 14px;
  }

  .stats,
  .actions {
    grid-template-columns: 1fr;
  }

  .stats div {
    min-height: 60px;
  }
}
