:root {
  color-scheme: dark;
  --bg: #07101a;
  --muted: #91a2b7;
  --text: #f3f8ff;
  --accent: #74f6c1;
  --accent-soft: rgba(116, 246, 193, 0.13);
  --gold: #ffd166;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  min-height: 100%;
  margin: 0;
}

body {
  overflow: hidden;
  color: var(--text);
  background:
    radial-gradient(circle at 10% 0%, rgba(47, 117, 128, 0.22), transparent 32rem),
    radial-gradient(circle at 100% 100%, rgba(75, 55, 124, 0.2), transparent 28rem),
    var(--bg);
}

button {
  font: inherit;
}

.game-shell {
  width: 100%;
  height: 100%;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  position: relative;
  min-height: 0;
  overflow: hidden;
  background:
    radial-gradient(circle at 12% 18%, rgba(26, 94, 106, 0.2), transparent 34rem),
    radial-gradient(circle at 88% 90%, rgba(75, 55, 124, 0.2), transparent 30rem),
    var(--bg);
}

.canvas-wrap {
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

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

.game-hud,
.control-row {
  background: rgba(5, 14, 23, 0.65);
}

.game-hud {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 10px 18px;
}

.game-meta {
  display: flex;
  flex-direction: column;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
}

.game-meta p,
.status-line {
  margin: 0;
}

.status-line {
  display: flex;
  align-items: center;
  gap: 8px;
}

.status-dot {
  width: 7px;
  height: 7px;
  background: var(--gold);
  border-radius: 50%;
  box-shadow: 0 0 11px rgba(255, 209, 102, 0.7);
}

.status-dot.is-live {
  background: var(--accent);
  box-shadow: 0 0 11px rgba(116, 246, 193, 0.8);
}

.status-dot.is-paused {
  background: #9ea9ff;
  box-shadow: 0 0 11px rgba(158, 169, 255, 0.75);
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.stat {
  min-width: 46px;
  text-align: right;
}

.stat span,
.overlay-kicker {
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.stat strong {
  display: block;
  margin-top: 2px;
  color: var(--text);
  font-size: 18px;
  line-height: 1;
}

.icon-button,
.direction-button,
.primary-button {
  border: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.icon-button {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  color: var(--accent);
  font-size: 20px;
  background: var(--accent-soft);
  border: 1px solid rgba(116, 246, 193, 0.25);
  border-radius: 12px;
  pointer-events: auto;
  transition: transform 160ms ease, background 160ms ease;
}

.icon-button:hover,
.icon-button:focus-visible {
  background: rgba(116, 246, 193, 0.2);
  outline: none;
  transform: translateY(-1px);
}

.overlay {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(5, 14, 23, 0.56);
  backdrop-filter: blur(7px);
  transition: opacity 180ms ease, visibility 180ms ease;
}

.overlay.is-hidden {
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
}

.overlay-panel {
  width: min(100%, 345px);
  padding: 27px 24px 22px;
  text-align: center;
  background: rgba(14, 28, 44, 0.93);
  border: 1px solid rgba(116, 246, 193, 0.2);
  border-radius: 18px;
  box-shadow: 0 18px 45px rgba(0, 0, 0, 0.35);
}

.overlay-kicker {
  margin: 0;
  color: var(--accent);
  font-size: 9px;
}

.overlay h1 {
  margin: 7px 0 9px;
  font-size: clamp(26px, 7vw, 34px);
  letter-spacing: -0.055em;
}

.overlay-panel > p:not(.overlay-kicker):not(.overlay-hint) {
  margin: 0 0 20px;
  color: #b0bdcc;
  font-size: 14px;
  line-height: 1.55;
}

.primary-button {
  width: 100%;
  padding: 12px 18px;
  color: #06141a;
  font-weight: 800;
  background: var(--accent);
  border-radius: 11px;
  box-shadow: 0 7px 20px rgba(57, 220, 161, 0.22);
  transition: transform 160ms ease, background 160ms ease, box-shadow 160ms ease;
}

.primary-button:hover,
.primary-button:focus-visible {
  background: #9bffda;
  outline: none;
  box-shadow: 0 9px 26px rgba(57, 220, 161, 0.32);
  transform: translateY(-1px);
}

.overlay-hint {
  margin: 17px 0 0;
  color: var(--muted);
  font-size: 11px;
}

kbd {
  display: inline-block;
  min-width: 20px;
  padding: 2px 4px;
  color: #d9e6f4;
  font-size: 10px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 4px;
}

.control-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 8px 18px;
}

.keyboard-hint {
  max-width: 320px;
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.45;
}

.keyboard-hint strong {
  color: #d7e3ef;
  font-weight: 700;
}

.keyboard-hint span {
  margin: 0 5px;
  color: var(--accent);
}

.touch-controls {
  display: grid;
  grid-template-columns: repeat(4, 40px);
  gap: 4px;
}

.direction-button {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  color: #c7d7e7;
  font-size: 18px;
  line-height: 1;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.11);
  border-radius: 9px;
  transition: color 140ms ease, background 140ms ease, transform 140ms ease;
}

.direction-button:hover,
.direction-button:focus-visible,
.direction-button:active {
  color: var(--accent);
  background: var(--accent-soft);
  outline: none;
  transform: scale(0.94);
}

@media (max-width: 500px) {
  .game-hud {
    padding: 8px 12px;
  }

  .control-row {
    padding: 8px 12px;
    justify-content: center;
  }

  .keyboard-hint {
    display: none;
  }

  .touch-controls {
    grid-template-columns: repeat(4, 44px);
    gap: 8px;
  }

  .direction-button {
    width: 44px;
    height: 44px;
  }
}

@media (max-width: 370px) {
  .game-hud {
    gap: 8px;
  }

  .game-meta,
  .stat span {
    font-size: 10px;
  }

  .stat {
    min-width: 35px;
  }

  .top-actions {
    gap: 7px;
  }
}

@media (max-height: 420px) {
  .game-hud,
  .control-row {
    padding: 4px 12px;
  }

  .overlay {
    padding: 8px;
  }

  .overlay-panel {
    padding: 12px 18px;
  }

  .overlay h1 {
    margin: 0 0 8px;
    font-size: 26px;
  }

  .overlay-kicker,
  .overlay-hint,
  .overlay-panel > p:not(.overlay-kicker):not(.overlay-hint) {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}
