:root {
  color-scheme: dark;
  --background: #0a1718;
  --panel: rgba(12, 30, 32, 0.88);
  --panel-strong: #112f32;
  --ink: #fff7df;
  --muted: #b7c7bd;
  --line: rgba(255, 255, 255, 0.16);
  --accent: #facc15;
  --accent-ink: #1d1603;
  --blue: #38bdf8;
  --green: #34d399;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    linear-gradient(135deg, rgba(56, 189, 248, 0.09), transparent 32%),
    linear-gradient(315deg, rgba(250, 204, 21, 0.08), transparent 28%),
    var(--background);
}

button {
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  padding: 0.75rem 1rem;
  color: var(--accent-ink);
  background: var(--accent);
  box-shadow: 0 4px 0 #9a6d03;
  cursor: pointer;
  font: inherit;
  font-weight: 850;
}

button:hover,
button:focus-visible {
  transform: translateY(-1px);
}

button:active {
  transform: translateY(2px);
  box-shadow: 0 2px 0 #9a6d03;
}

.app-shell {
  width: min(1180px, calc(100vw - 32px));
  min-height: calc(100vh - 32px);
  margin: 16px auto;
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 16px;
}

.top-bar,
.board-panel,
.control-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  backdrop-filter: blur(8px);
}

.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 20px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 0.76rem;
  font-weight: 850;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(2.2rem, 8vw, 4.7rem);
  line-height: 0.95;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 132px;
  min-height: 44px;
  border-radius: 999px;
  color: #061315;
  background: var(--blue);
  font-weight: 900;
}

.game-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 340px);
  gap: 16px;
  align-items: stretch;
}

.board-panel {
  display: grid;
  place-items: center;
  min-width: 0;
  padding: 16px;
}

#game-board {
  width: min(100%, calc(100vh - 190px));
  min-width: 280px;
  max-width: 720px;
  aspect-ratio: 1 / 1;
  border: 2px solid rgba(255, 255, 255, 0.22);
  border-radius: 8px;
  background: #08251f;
  box-shadow: 0 22px 40px rgba(0, 0, 0, 0.28);
}

.control-panel {
  display: grid;
  grid-template-rows: auto auto 1fr;
  gap: 16px;
  padding: 16px;
}

.score-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.score-grid div {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.05);
}

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

.score-grid strong {
  display: block;
  margin-top: 4px;
  font-size: 1.55rem;
}

.actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.secondary-button {
  color: var(--ink);
  background: var(--panel-strong);
  box-shadow: 0 4px 0 #07191b;
}

.dpad {
  align-self: center;
  justify-self: center;
  width: min(100%, 230px);
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-template-areas:
    ". up ."
    "left . right"
    ". down .";
  gap: 10px;
}

.dpad button {
  width: 68px;
  height: 68px;
  padding: 0;
  justify-self: center;
  color: #061315;
  background: var(--green);
  box-shadow: 0 4px 0 #087344;
  font-size: 1.5rem;
}

[data-direction="up"] { grid-area: up; }
[data-direction="left"] { grid-area: left; }
[data-direction="right"] { grid-area: right; }
[data-direction="down"] { grid-area: down; }

@media (max-width: 860px) {
  .app-shell {
    width: min(100vw - 20px, 720px);
    margin: 10px auto;
  }

  .top-bar,
  .game-layout {
    grid-template-columns: 1fr;
  }

  .top-bar {
    align-items: stretch;
  }

  .status-pill {
    min-width: 0;
  }

  #game-board {
    width: min(100%, 620px);
  }
}

@media (max-width: 520px) {
  .top-bar,
  .board-panel,
  .control-panel {
    padding: 14px;
  }

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

  .score-grid strong {
    font-size: 1.25rem;
  }
}
