:root {
  --bg: #0a0b10;
  --surface: rgb(20 19 26 / 0.72);
  --surface-2: rgb(34 30 38 / 0.85);
  --border: rgb(255 255 255 / 0.1);
  --border-strong: rgb(255 255 255 / 0.22);
  --text: #f4efe6;
  --muted: #b4ab9f;
  --red: #ff3b3b;
  --orange: #ff8a1f;
  --yellow: #ffcc1a;
  --grad: linear-gradient(100deg, #ff3b3b, #ff8a1f 55%, #ffcc1a);
  --display: "Space Grotesk", system-ui, sans-serif;
  --body: "Inter", system-ui, sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--text); font-family: var(--body); -webkit-tap-highlight-color: transparent; }
button { font: inherit; color: inherit; cursor: pointer; }
[hidden] { display: none !important; }

.stage { position: fixed; inset: 0; background: radial-gradient(120% 90% at 50% 45%, #1a1210 0%, #0d0c11 60%, var(--bg) 100%); transition: background 0.8s; }
body[data-style="alpana"] .stage { background: radial-gradient(120% 90% at 50% 45%, #2a0f0d 0%, #140a0c 60%, var(--bg) 100%); }
body[data-style="mandana"] .stage { background: radial-gradient(120% 90% at 50% 45%, #33180e 0%, #170d0b 60%, var(--bg) 100%); }
#board { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; cursor: crosshair; outline: none; }

/* HUD */
.hud { position: fixed; z-index: 10; top: 0; left: 0; right: 0; display: flex; align-items: center; gap: 10px; padding: max(10px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) 8px max(10px, env(safe-area-inset-left)); pointer-events: none; }
.hud > * { pointer-events: auto; }
.back { display: inline-flex; align-items: center; gap: 2px; text-decoration: none; color: var(--muted); padding: 6px 10px 6px 4px; border-radius: 12px; }
.back:hover, .back:focus-visible { color: var(--text); background: rgb(255 255 255 / 0.08); }
.back svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.back img { height: 30px; width: auto; display: block; }
.hud-info { display: flex; align-items: center; gap: 7px; font-size: 0.9rem; color: var(--muted); padding: 8px 12px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); white-space: nowrap; }
.hud-info .lvl { font-family: var(--display); font-weight: 700; color: var(--text); }
.hud-info .time { font-variant-numeric: tabular-nums; }
.hud-info .sep { opacity: 0.5; }
.hud-score { margin-left: auto; display: flex; flex-direction: column; align-items: flex-end; line-height: 1; font-family: var(--display); font-weight: 700; font-size: 1.25rem; font-variant-numeric: tabular-nums; }
.hud-score small { font-family: var(--body); font-weight: 500; font-size: 0.68rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; margin-top: 3px; }
.icon-btn { height: 40px; width: 40px; display: inline-flex; align-items: center; justify-content: center; border-radius: 12px; border: 1px solid var(--border); background: var(--surface); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); }
.icon-btn:hover { background: var(--surface-2); border-color: var(--border-strong); }
.icon-btn svg, .ctl svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn .off { display: none; }
.icon-btn[aria-pressed="true"] .on { display: none; }
.icon-btn[aria-pressed="true"] .off { display: block; }
.icon-btn[aria-pressed="true"] { color: var(--muted); }

/* progress */
.progress { position: fixed; z-index: 9; top: calc(max(10px, env(safe-area-inset-top)) + 54px); left: 50%; translate: -50% 0; display: flex; align-items: center; gap: 10px; font-size: 0.78rem; color: var(--muted); font-variant-numeric: tabular-nums; pointer-events: none; white-space: nowrap; }
.progress .bar { width: 110px; height: 5px; border-radius: 3px; background: rgb(255 255 255 / 0.1); overflow: hidden; }
.progress .bar i { display: block; height: 100%; width: 0; background: var(--grad); border-radius: 3px; transition: width 0.25s; }
.progress .sikku { color: #e9c9a0; }

.toast { position: fixed; z-index: 11; left: 50%; bottom: calc(max(14px, env(safe-area-inset-bottom)) + 70px); translate: -50% 0; margin: 0; max-width: min(92vw, 460px); text-align: center; font-size: 0.88rem; line-height: 1.4; padding: 9px 14px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--border); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); opacity: 0; transition: opacity 0.35s, translate 0.35s; pointer-events: none; }
.toast.show { opacity: 1; translate: -50% -4px; }
.toast.warn { border-color: rgb(255 138 31 / 0.55); }

/* bottom controls */
.controls { position: fixed; z-index: 10; left: 50%; translate: -50% 0; bottom: max(12px, env(safe-area-inset-bottom)); display: flex; gap: 8px; padding: 6px; border-radius: 16px; border: 1px solid var(--border); background: var(--surface); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); }
.ctl { display: inline-flex; align-items: center; gap: 7px; height: 44px; padding: 0 16px; border-radius: 11px; border: 0; background: transparent; font-weight: 600; font-size: 0.9rem; }
.ctl:hover, .ctl:focus-visible { background: rgb(255 255 255 / 0.08); }
.ctl:disabled { opacity: 0.4; cursor: default; }
.ctl.glow { color: var(--yellow); }

/* overlays */
.overlay { position: fixed; z-index: 20; inset: 0; display: grid; place-items: center; padding: 16px; background: rgb(8 8 12 / 0.62); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); overflow-y: auto; animation: fade 0.35s ease; }
@keyframes fade { from { opacity: 0; } }
.card { width: min(100%, 480px); padding: 26px 24px 22px; border-radius: 22px; border: 1px solid var(--border); background: linear-gradient(180deg, rgb(32 26 28 / 0.95), rgb(16 15 20 / 0.96)); box-shadow: 0 30px 80px -30px rgb(0 0 0 / 0.8), 0 0 0 1px rgb(255 138 31 / 0.06) inset; text-align: center; }
.card.small { width: min(100%, 400px); }
.eyebrow { margin: 0 0 6px; font-size: 0.74rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--orange); font-weight: 600; }
.card h1, .card h2 { font-family: var(--display); margin: 0 0 10px; line-height: 1.05; }
.card h1 { font-size: clamp(2.4rem, 9vw, 3.4rem); background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.card h2 { font-size: 1.6rem; }
.lead { margin: 0 0 12px; color: var(--muted); line-height: 1.5; font-size: 0.95rem; }
.how { margin: 0 0 16px; line-height: 1.5; font-size: 0.95rem; }
.keys { margin: 14px 0 0; font-size: 0.74rem; color: var(--muted); opacity: 0.85; line-height: 1.5; }
.best { margin: 6px 0 0; font-size: 0.8rem; color: #e9c9a0; min-height: 1em; }
.actions { display: flex; flex-direction: column; gap: 8px; margin-top: 6px; }
.btn { height: 48px; border-radius: 14px; border: 1px solid var(--border-strong); background: rgb(255 255 255 / 0.05); font-weight: 600; font-size: 1rem; transition: transform 0.15s, background 0.2s; }
.btn:hover { background: rgb(255 255 255 / 0.1); }
.btn:active { transform: scale(0.98); }
.btn.primary { border: 0; background: var(--grad); color: #1a0d05; font-family: var(--display); font-weight: 700; font-size: 1.08rem; box-shadow: 0 10px 30px -12px rgb(255 138 31 / 0.8); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--muted); font-weight: 500; font-size: 0.92rem; }
.btn.ghost:hover { color: var(--text); }
.btn:focus-visible, .ctl:focus-visible, .icon-btn:focus-visible, .mini:focus-visible, .back:focus-visible { outline: 2px solid var(--yellow); outline-offset: 2px; }
.lvl-pick { display: inline-flex; align-items: center; gap: 12px; margin: 0 0 14px; font-family: var(--display); font-weight: 600; }
.lvl-pick span { min-width: 120px; }
.mini { width: 36px; height: 36px; border-radius: 10px; border: 1px solid var(--border-strong); background: rgb(255 255 255 / 0.04); font-size: 1.3rem; line-height: 1; }
.mini:disabled { opacity: 0.3; cursor: default; }
.stars { font-size: 2rem; letter-spacing: 6px; margin: 2px 0 10px; color: rgb(255 255 255 / 0.15); }
.stars b { color: var(--yellow); font-weight: inherit; text-shadow: 0 0 18px rgb(255 204 26 / 0.6); }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin: 0 0 12px; }
.stats div { padding: 8px 4px; border-radius: 12px; background: rgb(255 255 255 / 0.04); }
.stats dt { font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.stats dd { margin: 3px 0 0; font-family: var(--display); font-weight: 700; font-size: 1.15rem; font-variant-numeric: tabular-nums; }

@media (max-width: 560px) {
  .hud { gap: 6px; }
  .back { padding: 4px 4px 4px 0; }
  .back img { height: 24px; }
  .hud-info { font-size: 0.78rem; padding: 7px 9px; gap: 5px; }
  .hud-info #hudStyle, .hud-info .sep:nth-of-type(1) { display: none; }
  .hud-score { font-size: 1.05rem; }
  .icon-btn { width: 36px; height: 36px; }
  .progress { top: calc(max(10px, env(safe-area-inset-top)) + 48px); font-size: 0.72rem; }
  .progress .bar { width: 70px; }
  .ctl { padding: 0 12px; height: 42px; }
  .card { padding: 22px 18px 18px; }
  .keys { display: none; }
}
@media (max-width: 360px) { .ctl span { display: none; } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
/* the end card sits low and lets the finished kolam show through */
#endCard { place-items: end center; background: linear-gradient(180deg, transparent 35%, rgb(8 8 12 / 0.75)); backdrop-filter: none; -webkit-backdrop-filter: none; padding-bottom: max(16px, env(safe-area-inset-bottom)); }
#endCard .card { background: linear-gradient(180deg, rgb(32 26 28 / 0.9), rgb(16 15 20 / 0.94)); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
