:root {
  --brand: #4f46e5;
  --brand-dark: #3730a3;
  --accent: #f59e0b;
  --ink: #0f172a;
  --ink-soft: #64748b;
  --bg: #ffffff;
  --rule: #e2e8f0;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-weight: 500;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  min-height: 100dvh;
  overflow: hidden;
}

a { color: inherit; text-decoration: none; }

.game-shell {
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 16px;
  gap: 12px;
}

.game-bar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 16px;
}

.game-back {
  justify-self: start;
  font-size: 15px;
  font-weight: 600;
  color: var(--ink-soft);
  padding: 6px 10px;
  border-radius: 6px;
}

.game-back:hover { color: var(--brand); background: #f1f5f9; }

.game-title {
  justify-self: center;
  font-weight: 800;
  font-size: clamp(16px, 2vw, 22px);
  letter-spacing: -0.01em;
}

.game-stage {
  position: relative;
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  min-height: 0;
}

.game-hud {
  position: absolute;
  top: 6px;
  left: 50%;
  transform: translateX(-50%);
  width: min(95vw, calc(95vh * 4 / 3));
  max-width: 800px;
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  pointer-events: none;
  z-index: 2;
  font-weight: 700;
  font-size: 14px;
  color: var(--ink);
}

.hud-cell { padding: 6px 14px; }
.hud-left { text-align: left; }
.hud-center { text-align: center; color: var(--ink-soft); }
.hud-right { text-align: right; }
.hud-cell span { color: var(--brand); margin-left: 6px; font-weight: 800; }

canvas#game {
  display: block;
  width: min(95vw, calc(95vh * 4 / 3));
  height: auto;
  aspect-ratio: 4 / 3;
  background: #ffffff;
  border-radius: 12px;
  box-shadow: 0 2px 0 var(--rule), 0 24px 48px -24px rgba(15, 23, 42, 0.18);
  touch-action: none;
  cursor: none;
}

.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.78);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border-radius: 12px;
  z-index: 3;
}

.overlay[hidden] { display: none; }

.overlay-card {
  background: #fff;
  border: 1px solid var(--rule);
  padding: 28px 32px;
  border-radius: 14px;
  text-align: center;
  box-shadow: 0 24px 60px -24px rgba(15, 23, 42, 0.25);
  max-width: 420px;
}

.overlay-card h1 {
  margin: 0 0 10px;
  font-size: clamp(22px, 2.6vw, 28px);
  font-weight: 800;
  letter-spacing: -0.01em;
}

.overlay-card p {
  margin: 0 0 18px;
  color: var(--ink-soft);
  font-size: 15px;
  line-height: 1.5;
}

.overlay-card kbd {
  display: inline-block;
  font-family: var(--font);
  font-size: 13px;
  padding: 1px 6px;
  border: 1px solid var(--rule);
  border-radius: 4px;
  background: #f8fafc;
  color: var(--ink);
}

.overlay-btn {
  appearance: none;
  border: none;
  background: var(--brand);
  color: #fff;
  font: 700 16px var(--font);
  padding: 12px 28px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.05s ease;
}

.overlay-btn:hover { background: var(--brand-dark); }
.overlay-btn:active { transform: translateY(1px); }

.game-foot {
  text-align: center;
  font-size: 13px;
  color: var(--ink-soft);
}

@media (max-width: 640px) {
  .game-shell { padding: 8px; }
  canvas#game { width: 96vw; }
  .game-hud { width: 96vw; font-size: 12px; }
  .game-title { font-size: 14px; }
}
