:root {
  color-scheme: dark;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #080b13;
  color: #f8fafc;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at 12% 16%, rgba(69, 240, 164, 0.16), transparent 28rem),
    linear-gradient(135deg, #080b13 0%, #111827 45%, #201433 100%);
}

button,
input {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.game-shell {
  display: grid;
  grid-template-columns: minmax(18rem, 43rem) minmax(17rem, 23rem);
  gap: clamp(1rem, 3vw, 2.25rem);
  align-items: center;
  justify-content: center;
  width: min(100%, 76rem);
  min-height: 100vh;
  margin: 0 auto;
  padding: clamp(0.75rem, 2vw, 2rem);
}

.play-surface,
.control-panel {
  min-width: 0;
}

.play-surface {
  justify-self: end;
  width: min(100%, 43rem, calc(100vh - 9.5rem));
}

.score-ribbon {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
  margin-bottom: 0.85rem;
}

.score-ribbon > div {
  min-height: 4.4rem;
  padding: 0.85rem 1rem;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: rgba(8, 11, 19, 0.72);
  box-shadow: 0 1rem 3rem rgba(0, 0, 0, 0.24);
}

.metric-label {
  display: block;
  margin-bottom: 0.2rem;
  color: #a7f3d0;
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.score-ribbon strong {
  font-size: clamp(1.35rem, 3vw, 2.1rem);
  line-height: 1;
}

.board-wrap {
  position: relative;
  overflow: hidden;
  width: 100%;
  aspect-ratio: 1;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  background: #0f172a;
  box-shadow: 0 1.5rem 4rem rgba(0, 0, 0, 0.38);
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

.status-layer {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  gap: 1rem;
  padding: 1rem;
  background: rgba(8, 11, 19, 0.58);
  opacity: 0;
  pointer-events: none;
  text-align: center;
  transition: opacity 160ms ease;
}

.status-layer.is-visible {
  opacity: 1;
  pointer-events: auto;
}

.status-layer p {
  margin: 0;
  color: #f8fafc;
  font-size: clamp(2rem, 8vw, 4.75rem);
  font-weight: 900;
  line-height: 0.95;
}

.primary-action,
.command-button,
.mode-button,
.dpad-button {
  min-height: 2.75rem;
  border-radius: 8px;
  color: #f8fafc;
  font-weight: 850;
}

.primary-action {
  justify-self: center;
  min-width: 8.5rem;
  padding: 0.85rem 1.35rem;
  background: #45f0a4;
  color: #062015;
  box-shadow: 0 0.9rem 2.5rem rgba(69, 240, 164, 0.25);
}

.control-panel {
  display: grid;
  gap: 1rem;
  padding: clamp(1rem, 3vw, 1.35rem);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: rgba(8, 11, 19, 0.74);
  box-shadow: 0 1rem 3rem rgba(0, 0, 0, 0.26);
}

.brand-lockup {
  display: flex;
  gap: 0.8rem;
  align-items: center;
}

.brand-lockup img {
  flex: 0 0 auto;
  border-radius: 8px;
}

h1 {
  margin: 0;
  font-size: clamp(1.3rem, 2.5vw, 1.85rem);
  line-height: 1.05;
}

.brand-lockup p {
  margin: 0.25rem 0 0;
  color: #cbd5e1;
  font-size: 0.95rem;
}

.mode-group {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.45rem;
}

.mode-button,
.command-button {
  padding: 0.7rem 0.75rem;
  background: rgba(255, 255, 255, 0.08);
}

.mode-button.is-selected {
  background: #ffcf5f;
  color: #241a05;
}

.command-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.55rem;
}

.command-button {
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.dpad {
  display: grid;
  grid-template-columns: repeat(3, 4.4rem);
  grid-template-rows: repeat(3, 4.1rem);
  justify-content: center;
  gap: 0.45rem;
  padding: 0.4rem 0;
}

.dpad-button {
  position: relative;
  background: rgba(255, 255, 255, 0.09);
  border: 1px solid rgba(255, 255, 255, 0.11);
}

.dpad-button::before {
  content: "";
  position: absolute;
  inset: 50% auto auto 50%;
  width: 0;
  height: 0;
  transform: translate(-50%, -50%);
  border-style: solid;
}

.dpad-button.up {
  grid-column: 2;
  grid-row: 1;
}

.dpad-button.up::before {
  border-width: 0 0.55rem 0.78rem;
  border-color: transparent transparent #f8fafc;
}

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

.dpad-button.left::before {
  border-width: 0.55rem 0.78rem 0.55rem 0;
  border-color: transparent #f8fafc transparent transparent;
}

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

.dpad-button.right::before {
  border-width: 0.55rem 0 0.55rem 0.78rem;
  border-color: transparent transparent transparent #f8fafc;
}

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

.dpad-button.down::before {
  border-width: 0.78rem 0.55rem 0;
  border-color: #f8fafc transparent transparent;
}

.toggle-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.6rem;
}

.toggle-row label {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  min-height: 2.8rem;
  padding: 0.7rem 0.8rem;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.07);
  color: #e2e8f0;
  font-weight: 750;
}

.toggle-row input {
  accent-color: #45f0a4;
}

button:focus-visible,
input:focus-visible {
  outline: 3px solid rgba(255, 207, 95, 0.85);
  outline-offset: 2px;
}

@media (max-width: 860px) {
  .game-shell {
    grid-template-columns: 1fr;
    align-items: start;
    min-height: auto;
  }

  .play-surface {
    justify-self: stretch;
    width: 100%;
  }

  .dpad {
    grid-template-columns: repeat(3, minmax(3.6rem, 4.4rem));
  }
}

@media (max-width: 520px) {
  .game-shell {
    padding: 0.7rem;
  }

  .score-ribbon {
    gap: 0.45rem;
  }

  .score-ribbon > div {
    min-height: 3.9rem;
    padding: 0.7rem;
  }

  .metric-label {
    font-size: 0.68rem;
  }

  .mode-group,
  .command-grid,
  .toggle-row {
    grid-template-columns: 1fr;
  }
}
