:root {
  --bg: #0f1420;
  --panel: #182033;
  --text: #f2f4f8;
  --muted: #9aa5b8;
  --accent: #ffd23f;
  --accent-2: #00a3e0;
}
* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0; height: 100%;
  background: var(--bg); color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  overflow: hidden; overscroll-behavior: none;
  -webkit-user-select: none; user-select: none;
  -webkit-tap-highlight-color: transparent;
}
body.popup, body.popup #stage { width: 640px; height: 400px; }

#stage { position: relative; width: 100vw; height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--bg); }
canvas#game { display: block; touch-action: none; image-rendering: pixelated; image-rendering: crisp-edges; }

.hidden { display: none !important; }

.overlay {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  background: rgba(8, 11, 18, .78); padding: 16px; z-index: 10;
}
.panel {
  background: var(--panel); border-radius: 16px; padding: 22px 20px;
  width: min(400px, 100%); text-align: center;
  box-shadow: 0 12px 40px rgba(0,0,0,.5);
  max-height: 100%; overflow: auto;
}
h1 { margin: 0 0 6px; font-size: 36px; letter-spacing: 2px; color: #ff4fa3; text-shadow: 3px 3px 0 #2b57d6, 0 0 18px rgba(255,79,163,.6); font-family: 'Courier New', ui-monospace, monospace; text-transform: uppercase; }
h2 { margin: 0 0 10px; font-size: 22px; }
p { margin: 6px 0; color: var(--muted); font-size: 15px; line-height: 1.4; }
p.big { font-size: 40px; font-weight: 700; color: var(--text); margin: 2px 0; font-variant-numeric: tabular-nums; }
.day-line { color: var(--text); font-weight: 600; }
.record { color: var(--accent); font-weight: 700; }
.hint { font-size: 13px; }
.footer { font-size: 12px; margin-top: 12px; }
.footer a { color: var(--muted); }

button {
  display: block; width: 100%; margin: 10px auto 0; padding: 13px 18px;
  border: 0; border-radius: 12px; font-size: 17px; font-weight: 700;
  background: rgba(255,255,255,.08); color: var(--text); cursor: pointer;
  font-family: inherit;
}
button:active { transform: scale(.98); }
button.primary { background: var(--accent); color: #1a1a1a; }

.choose-label { color: var(--accent); font-weight: 700; text-transform: uppercase; letter-spacing: 1px; font-size: 12px; margin: 12px 0 4px; }
.chars { display: flex; gap: 10px; justify-content: center; margin-top: 4px; }
.chars button { width: 108px; margin: 0; padding: 6px 4px 8px; font-size: 13px; display: flex; flex-direction: column; align-items: center; gap: 4px; border: 3px solid rgba(255,255,255,.12); background: rgba(0,0,0,.25); }
.chars button canvas { width: 84px; height: 84px; image-rendering: pixelated; }
.chars button.active { border-color: var(--accent); background: rgba(255,210,63,.14); box-shadow: 0 0 0 2px rgba(255,210,63,.25), 0 0 18px rgba(255,210,63,.35); }
.chars button.active span::after { content: ' ✓'; }
body.popup .chars button { width: 92px; } body.popup .chars button canvas { width: 64px; height: 64px; }

.diffs { display: flex; gap: 6px; justify-content: center; margin: 4px 0 8px; flex-wrap: wrap; }
.diffs button { width: auto; margin: 0; padding: 7px 10px; font-size: 12px; border: 2px solid rgba(255,255,255,.12); }
.diffs button.active { border-color: var(--accent); background: rgba(255,210,63,.14); }

.langs { display: flex; gap: 8px; justify-content: center; margin-top: 14px; }
.langs button { width: auto; margin: 0; padding: 7px 12px; font-size: 13px; }
.langs button.active { background: var(--accent-2); color: #fff; }

#btn-mute {
  position: absolute; top: 8px; right: 8px; width: 36px; height: 36px; margin: 0; padding: 0;
  border-radius: 50%; font-size: 16px; background: rgba(0,0,0,.35); z-index: 5;
}

button.secondary { background: rgba(0,229,255,.16); color: #bff3ff; border: 2px solid rgba(0,229,255,.35); }
.fro-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); gap: 8px; margin: 10px 0 4px; }
.lvl.fro { border-color: rgba(0,229,255,.35); }
.lvl.fro .lvl-flag { font-size: 26px; }
p.how { text-align: left; color: var(--text); font-size: 15px; margin: 10px 0; }
.panel.wide { width: min(600px, 100%); }
#levels-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 6px; margin-top: 8px; max-height: 52vh; overflow: auto; padding: 2px; }
.lvl-section { grid-column: 1 / -1; color: var(--accent); font-weight: 700; text-transform: uppercase; letter-spacing: 1px; font-size: 11px; margin: 6px 0 0; text-align: left; }
.lvl { margin: 0; padding: 6px 4px; font-size: 12px; display: flex; flex-direction: column; align-items: center; gap: 2px; border: 2px solid rgba(255,255,255,.12); background: rgba(0,0,0,.25); }
.lvl .lvl-flag { font-size: 20px; }
.lvl .lvl-name { font-weight: 700; }
.lvl small { font-weight: 400; color: var(--muted); font-size: 11px; }
.lvl.locked { opacity: .75; }
.lvl.locked:not(.poor) small { color: var(--accent); }
.lvl.poor { opacity: .45; }
.lvl.sel { border-color: var(--accent); background: rgba(255,210,63,.14); }
body.popup #levels-grid { max-height: 46vh; }

.share-preview {
  margin-top: 12px; white-space: pre-line; text-align: left;
  background: rgba(0,0,0,.3); padding: 10px 12px; border-radius: 8px;
  font-size: 13px; color: var(--text); font-family: ui-monospace, Menlo, monospace;
}

/* Boss key: a fake spreadsheet */
#boss {
  position: fixed; inset: 0; z-index: 50; background: #fff; color: #222;
  font-family: Calibri, "Segoe UI", Arial, sans-serif; font-size: 13px;
}
.sheet-top { display: flex; justify-content: space-between; padding: 8px 12px; background: #217346; color: #fff; font-weight: 600; }
#sheet { border-collapse: collapse; width: 100%; }
#sheet td, #sheet th { border: 1px solid #d4d4d4; padding: 4px 8px; white-space: nowrap; }
#sheet th { background: #f3f3f3; font-weight: 600; text-align: center; color: #555; }
#sheet td.num { text-align: right; font-variant-numeric: tabular-nums; }
.sheet-hint { position: fixed; bottom: 10px; right: 12px; color: #999; font-size: 11px; }

/* Privacy page */
body.privacy { overflow: auto; }
body.privacy main { max-width: 640px; margin: 0 auto; padding: 32px 16px; }
body.privacy h1, body.privacy h2 { color: var(--text); }
body.privacy p { color: var(--muted); }
body.privacy a { color: var(--accent); }
