:root {
  color-scheme: dark;
  --bg-top: #091124;
  --bg-bottom: #050811;
  --panel-bg: #0d1629;
  --panel-border: #253859;
  --accent: #4cc9f0;
  --gold: #ffd166;
  --coral: #ff7b54;
  --mint: #80ed99;
  --text: #f8fafc;
  --muted: #94a3b8;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  overflow: hidden;
  background: radial-gradient(circle at 50% 15%, #162447 0%, var(--bg-top) 55%, var(--bg-bottom) 100%);
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  user-select: none;
  -webkit-user-select: none;
}

body {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  align-items: stretch;
  justify-items: center;
}

#stage {
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  display: grid;
  place-items: center;
  padding: 6px 6px 2px;
}

#game {
  display: block;
  aspect-ratio: 420 / 640;
  width: auto;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  border: 2px solid var(--panel-border);
  border-radius: 10px;
  background: #0b132b;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.48);
  touch-action: manipulation;
  cursor: pointer;
}

#game:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

#controls {
  width: min(100%, 560px);
  padding: 6px 10px 8px;
  background: rgba(13, 22, 41, 0.96);
  border-top: 1px solid var(--panel-border);
  display: grid;
  gap: 5px;
}

.status-row,
.button-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.metric {
  min-width: 68px;
  padding: 3px 7px;
  border: 1px solid #1e2f4d;
  border-radius: 6px;
  background: #111c33;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 6px;
  flex: 1 1 78px;
}

.metric-label {
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.metric strong {
  color: var(--gold);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  font-weight: 800;
}

.button-row {
  justify-content: center;
}

button {
  min-height: 30px;
  padding: 5px 11px;
  border: 1px solid #355078;
  border-radius: 6px;
  background: #172642;
  color: var(--text);
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: background-color 120ms ease, transform 80ms ease, border-color 120ms ease;
}

button:hover:not(:disabled) {
  background: #21365c;
  border-color: var(--accent);
}

button:active:not(:disabled) {
  transform: translateY(1px);
}

button:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

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

#play {
  background: #1b6b58;
  border-color: var(--mint);
  color: #ffffff;
}

#play:hover:not(:disabled) {
  background: #238971;
}

.hint {
  margin: 0;
  color: var(--muted);
  font-size: 10.5px;
  line-height: 1.3;
  text-align: center;
  text-wrap: balance;
}

.hint kbd {
  padding: 1px 4px;
  border: 1px solid #334e73;
  border-radius: 3px;
  background: #0d1629;
  color: #e2e8f0;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 10px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 380px) {
  #controls {
    padding-inline: 6px;
  }
  .status-row {
    gap: 4px;
  }
  .metric {
    min-width: 58px;
    padding: 2px 5px;
    flex: 1 1 60px;
  }
  .metric strong {
    font-size: 11.5px;
  }
  .button-row {
    gap: 4px;
  }
  button {
    padding-inline: 8px;
    font-size: 11px;
  }
  .hint {
    font-size: 9.5px;
  }
}

@media (max-height: 680px) {
  #stage {
    padding: 3px 4px 1px;
  }

  #controls {
    padding: 4px 8px 5px;
    gap: 3px;
  }

  button {
    min-height: 26px;
    padding: 3px 9px;
    font-size: 11px;
  }

  .hint {
    font-size: 10px;
  }
}
