:root {
  color-scheme: dark;
  --bg: #060911;
  --panel: rgba(15, 23, 42, 0.72);
  --panel-border: rgba(148, 163, 184, 0.16);
  --text: #e2e8f0;
  --muted: #94a3b8;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  display: grid;
  place-items: center;
  background:
    radial-gradient(1200px 800px at 18% -12%, rgba(56, 189, 248, 0.12), transparent 60%),
    radial-gradient(900px 700px at 112% 18%, rgba(168, 85, 247, 0.14), transparent 58%),
    var(--bg);
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  user-select: none;
}

.app {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 20px 16px 28px;
}

.topbar {
  text-align: center;
}

.topbar h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.42em;
  text-indent: 0.42em;
  background: linear-gradient(90deg, #67e8f9, #a78bfa 55%, #fb7185);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.topbar p {
  margin: 4px 0 0;
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
}

.game {
  display: flex;
  align-items: flex-start;
  gap: 16px;
}

.panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 140px;
}

.box {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  padding: 12px;
  box-shadow: 0 10px 30px rgba(2, 6, 23, 0.35);
}

.box h2 {
  margin: 0 0 10px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
}

canvas {
  display: block;
}

.stage {
  position: relative;
  line-height: 0;
}

#board {
  border-radius: 16px;
  border: 1px solid rgba(148, 163, 184, 0.18);
  background: #0a0f1e;
  box-shadow:
    0 0 0 1px rgba(2, 6, 23, 0.6),
    0 24px 60px rgba(2, 6, 23, 0.6),
    0 0 60px rgba(56, 189, 248, 0.06);
}

.overlay {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  text-align: center;
  line-height: 1.4;
  background: rgba(3, 7, 18, 0.84);
  backdrop-filter: blur(4px);
  border-radius: 16px;
}

.overlay.visible {
  display: flex;
}

.overlay h2 {
  margin: 0;
  font-size: 24px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #fda4af;
}

.overlay p {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
}

.overlay strong {
  color: #f8fafc;
  font-size: 18px;
}

.overlay .hint {
  margin-top: 12px;
}

kbd {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 5px;
  background: rgba(148, 163, 184, 0.16);
  border: 1px solid rgba(148, 163, 184, 0.3);
  font-family: inherit;
  font-size: 11px;
  color: #e2e8f0;
}

.stats div {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 5px 0;
  border-bottom: 1px solid rgba(148, 163, 184, 0.08);
}

.stats div:last-child {
  border-bottom: 0;
}

.stats span {
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.stats strong {
  font-size: 16px;
  font-variant-numeric: tabular-nums;
}

.keys ul {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 11px;
  color: var(--muted);
}

.keys li {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.keys b {
  font-weight: 600;
  letter-spacing: 0.03em;
  color: #cbd5e1;
}

@media (max-width: 720px) {
  .game {
    flex-wrap: wrap;
    justify-content: center;
  }

  .stage {
    order: -1;
    flex-basis: 100%;
    display: flex;
    justify-content: center;
  }

  .panel {
    flex-direction: row;
    width: auto;
  }

  .panel .box {
    width: 140px;
  }

  #board {
    width: min(300px, 68vw) !important;
    height: auto !important;
  }
}

@media (max-height: 780px) and (min-width: 721px) {
  #board {
    width: min(300px, 40vh) !important;
    height: auto !important;
  }
}
