:root {
  --bg1: #1b1f3b;
  --bg2: #0d0f1f;
  --fg: #eef1ff;
  --muted: #9aa3c7;
  --accent: #ffb347;
  --accent2: #ff5d73;
  --card: rgba(24, 28, 56, 0.92);
}
* { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%;
  background: radial-gradient(circle at 50% 20%, var(--bg1), var(--bg2) 75%);
  background-color: var(--bg2);
  color: var(--fg);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  overflow: hidden;
  -webkit-user-select: none; user-select: none;
  -webkit-tap-highlight-color: transparent;
}
#app {
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  display: flex; flex-direction: column; height: 100%; max-width: 720px; margin: 0 auto; }
header {
  display: flex; align-items: center; justify-content: flex-end; gap: 12px;
  padding: 12px 16px; flex-wrap: wrap; position: relative;
}
/* Title sits underneath; on narrow screens the stats and buttons may cover it. */
.title { position: absolute; left: 16px; top: 50%; transform: translateY(calc(-50% - 4px)); }
header > :not(.title) { position: relative; z-index: 1; }
h1 { margin: 0; font-size: 26px; font-weight: 800; letter-spacing: 0.5px; line-height: 1.1; }
#version { font-size: 9px; color: var(--muted); letter-spacing: 0.5px; line-height: 1; }
h1 span { color: var(--accent); }
.stats { display: flex; gap: 10px; }
.stat {
  background: rgba(255,255,255,0.07); border-radius: 10px;
  padding: 4px 12px; min-width: 70px; text-align: center;
}
.stat.hidden { display: none; }
.stat.clickable { cursor: pointer; }
.stat.clickable:active { transform: translateY(1px); }
.stat .label { font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); }
.stat .value { font-size: 22px; font-weight: 800; font-variant-numeric: tabular-nums; }
.value.bump { animation: bump 0.35s ease-out; }
@keyframes bump { 0% { transform: scale(1); } 40% { transform: scale(1.3); color: var(--accent); } 100% { transform: scale(1); } }
.btn {
  font: inherit; font-weight: 700; font-size: 15px; color: #1a1a2e;
  background: linear-gradient(180deg, #ffd27a, var(--accent));
  border: 0; border-radius: 10px; padding: 9px 16px; cursor: pointer;
  box-shadow: 0 3px 0 #c97d1e, 0 6px 14px rgba(0,0,0,0.3);
}
.btn:active { transform: translateY(2px); box-shadow: 0 1px 0 #c97d1e; }
.btn.on, .btn.again { background: linear-gradient(180deg, #8ff0a8, #3fbf6a); box-shadow: 0 3px 0 #23803f, 0 6px 14px rgba(0,0,0,0.3); }
.btn.ghost {
  background: transparent; color: var(--fg); box-shadow: none;
  border: 1px solid rgba(255,255,255,0.25); margin-top: 12px;
}
.btn.hidden { display: none; }
.btn.big { font-size: 20px; padding: 12px 28px; margin-top: 8px; }
.modes { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; margin-top: 8px; }
#clearBestOverlay .modes { grid-template-columns: 1fr 1fr; gap: 12px; }
.modes-title { grid-column: 1 / -1; margin-top: 8px; color: var(--muted); font-size: 13px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; }
.btn.mode { position: relative; overflow: hidden; margin-top: 0; padding: 12px 4px; font-size: 17px; white-space: nowrap; }
.btn.mode.wide, .btn.again { grid-column: 1 / -1; }
.btn.again { margin-top: 0; }
.btn.mode:not(.sel) {
  background: transparent; color: var(--fg);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.25);
}
#intro.hidden, #overInfo.hidden { display: none; }
#clearBestOverlay .card { background: rgb(24, 28, 56); }
.card-foot { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
#stage { position: relative; flex: 1; min-height: 0; }
#board { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; display: block; }
.overlay {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  background: rgba(8, 10, 24, 0.55); padding: 16px;
}
.overlay.hidden { display: none; }
.card {
  background: var(--card); border-radius: 18px; padding: 24px 28px; max-width: 380px;
  text-align: center; box-shadow: 0 20px 50px rgba(0,0,0,0.5);
  border: 1px solid rgba(255,255,255,0.08);
}
.card h2 { margin: 0 0 8px; font-size: 30px; }
.card p { color: var(--muted); line-height: 1.45; margin: 8px 0; }
.card .final { font-size: 48px; font-weight: 900; color: var(--accent); margin: 4px 0 8px; }
.card .final s { color: var(--muted); margin-right: 12px; }
.card .final s:empty { display: none; }
@media (max-width: 480px) {
  header { padding: 10px 16px; gap: 6px; flex-wrap: nowrap; }
  h1 { font-size: 20px; }
  .stats { gap: 6px; }
  .stat { min-width: 50px; padding: 3px 6px; }
  .stat .value { font-size: 18px; }
  .btn { padding: 8px 10px; font-size: 13px; white-space: nowrap; }
}
