@font-face { font-family: Fredoka; src: url(/static/fonts/fredoka-latin-wght-normal.woff2) format("woff2"); font-weight: 300 700; font-display: swap; }
@font-face { font-family: Nunito; src: url(/static/fonts/nunito-latin-wght-normal.woff2) format("woff2"); font-weight: 200 1000; font-display: swap; }
:root { --bg: #fff; --ink: #1b1640; --muted: #5a5675; --soft: #f3f1fb; --line: #e6e3f4; --lemon: #ffe14d; --danger: #c62f3a; color-scheme: light;
  --display: Fredoka, ui-rounded, system-ui, sans-serif; }
[hidden] { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--ink); font: 16px/1.5 Nunito, system-ui, -apple-system, Segoe UI, sans-serif; }
a { color: inherit; }
:focus-visible { outline: 3px solid #4a3fb0; outline-offset: 2px; }
h1, h2 { font-family: var(--display); font-weight: 700; margin: 0; }

/* header */
.bar { max-width: 1200px; margin: 0 auto; padding: 16px 24px; display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.brand { display: flex; align-items: center; gap: 10px; font: 700 28px/1 var(--display); text-decoration: none; }
#me { margin-left: auto; border: 2px solid var(--ink); border-radius: 999px; padding: 8px 14px; font-size: 14px; font-weight: 700; white-space: nowrap; }
#me:empty { display: none; }
.account-btn { font: inherit; font-size: 14px; font-weight: 700; min-height: 40px; padding: 0 16px; border-radius: 999px; border: 2px solid var(--ink); background: var(--lemon); color: var(--ink); cursor: pointer; }

/* home */
.home { max-width: 1200px; margin: 0 auto; padding: 8px 24px 48px; display: grid; gap: 36px; }
.home section { display: grid; gap: 14px; }
.home h1 { font-size: 34px; }
.home h2 { font-size: 22px; }
.recent ul, .games ul { list-style: none; margin: 0; padding: 0; }
.recent ul { display: flex; flex-wrap: wrap; gap: 12px; }
.recent a { display: flex; align-items: center; gap: 14px; border: 2px solid var(--ink); border-radius: 18px; padding: 8px 20px 8px 8px; text-decoration: none; font: 700 19px var(--display); }
.recent .art { width: 64px; height: 64px; border-radius: 12px; font-size: 22px; }
.games ul { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 24px; }
.game-card { display: grid; gap: 14px; border: 2.5px solid var(--ink); border-radius: 26px; padding: 14px; text-decoration: none; box-shadow: 6px 6px 0 var(--ink); transition: transform .12s, box-shadow .12s; }
.game-card:hover { transform: translate(-2px, -2px); box-shadow: 8px 8px 0 var(--ink); }
.game-card .art { aspect-ratio: 16/10; border-radius: 18px; font-size: 44px; }
.art { display: grid; place-items: center; overflow: hidden; background: var(--lemon); font-family: var(--display); font-weight: 700; flex: none; }
.art img { width: 100%; height: 100%; object-fit: cover; display: block; }
.game-card .meta { display: flex; align-items: center; gap: 12px; padding: 0 6px 4px; }
.game-card .text { flex: 1; display: grid; }
.game-card .name { font: 700 24px/1.2 var(--display); }
.game-card .desc { color: var(--muted); }
.game-card .play { display: inline-flex; align-items: center; min-height: 46px; padding: 0 22px; border-radius: 999px; background: var(--ink); color: #fff; font-weight: 700; }
.empty { color: var(--muted); }

/* game page */
.play { max-width: 1200px; margin: 0 auto; padding: 4px 24px 48px; display: grid; gap: 28px; }
.stage { position: relative; width: 100%; aspect-ratio: 16/9; max-height: calc(100dvh - 170px); background: var(--ink); border: 2.5px solid var(--ink); border-radius: 26px; overflow: hidden; box-shadow: 8px 8px 0 var(--ink); }
.stage:fullscreen { border: 0; border-radius: 0; max-height: none; box-shadow: none; }
.stage iframe { width: 100%; height: 100%; border: 0; display: block; background: var(--ink); }
.loader { position: absolute; inset: 0; display: grid; place-items: center; background: var(--lemon); transition: opacity .25s; z-index: 2; }
.loader.done { opacity: 0; pointer-events: none; }
.track { width: min(280px, 70%); height: 10px; border-radius: 5px; background: rgba(27, 22, 64, .15); overflow: hidden; }
.fill { width: 0; height: 100%; background: var(--ink); transition: width .2s; }
.ad { position: absolute; inset: 0; z-index: 3; display: grid; place-items: center; background: rgba(27, 22, 64, .92); color: #fff; font-size: 20px; }
.gamebar { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; padding: 0 4px; }
.gamebar h1 { margin-right: auto; font-size: 30px; }
.icon-btn { display: grid; place-items: center; width: 46px; height: 46px; border-radius: 50%; border: 0; background: var(--ink); cursor: pointer; }
.about { max-width: 720px; padding: 0 4px; display: grid; gap: 8px; }
.about .lead { margin: 0; font-size: 19px; font-weight: 700; }
.about h2 { font-size: 20px; margin-top: 4px; }
.about p { margin: 0; color: var(--muted); }
.panels { display: flex; flex-wrap: wrap; gap: 20px; }
.panel { flex: 1 1 320px; border: 2px solid var(--line); border-radius: 22px; padding: 18px 20px; display: grid; gap: 10px; align-content: start; }
.panel header { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.panel h2 { font-size: 20px; }
.panel .sub, .panel .note { color: var(--muted); font-size: 14px; margin: 0; }
.board, .achievements { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.board li { display: flex; gap: 8px; padding: 7px 12px; border-radius: 999px; }
.board li.me { background: var(--lemon); font-weight: 700; }
.board .rank { width: 32px; font-family: var(--display); }
.board .who { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board .score { font-variant-numeric: tabular-nums; }
.achievements { gap: 8px; }
.achievements li { display: flex; align-items: center; gap: 12px; }
.achievements .dot { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--ink); flex: none; }
.achievements li.got .dot { background: var(--ink); }
.achievements .text { display: grid; }
.achievements strong { font-weight: 700; }
.achievements .text span { color: var(--muted); font-size: 14px; }
@media (max-width: 640px) {
  .bar { padding: 10px 16px; flex-wrap: nowrap; gap: 8px; }
  .brand { font-size: 24px; }
  #me { min-width: 0; overflow: hidden; text-overflow: ellipsis; padding: 6px 10px; font-size: 13px; }
  .account-btn { min-height: 36px; padding: 0 12px; font-size: 13px; white-space: nowrap; flex: none; }
  .play { padding: 0 0 32px; gap: 20px; }
  .stage { aspect-ratio: auto; height: calc(100dvh - 64px); max-height: none; border-width: 0; border-radius: 0; box-shadow: none; }
  .gamebar, .panels, .about { padding: 0 16px; }
  .home { padding: 8px 16px 40px; }
  .games ul { grid-template-columns: 1fr; }
}

/* overlays */
.toasts { position: fixed; left: 50%; top: 72px; transform: translateX(-50%); display: grid; gap: 8px; z-index: 10; pointer-events: none; }
.toast { display: grid; background: #fff; border: 2px solid var(--ink); border-radius: 16px; padding: 10px 18px; min-width: 220px; box-shadow: 4px 4px 0 var(--ink); transition: opacity .4s, transform .4s; }
.toast strong { font-family: var(--display); }
.toast span { color: var(--muted); font-size: 14px; }
.toast.out { opacity: 0; transform: translateY(-8px); }
.center { display: grid; place-items: center; gap: 12px; min-height: 60vh; text-align: center; padding: 16px; }

.nudge { position: fixed; left: 50%; bottom: max(16px, env(safe-area-inset-bottom)); transform: translateX(-50%); width: min(92vw, 440px);
  display: grid; grid-template-columns: 1fr auto auto; gap: 8px; align-items: center; background: #fff; border: 2px solid var(--ink);
  border-radius: 18px; padding: 10px 12px; z-index: 20; box-shadow: 4px 4px 0 var(--ink); font-size: 15px; }
.modal { position: fixed; inset: 0; background: rgba(27, 22, 64, .45); display: grid; place-items: end center; z-index: 30; }
@media (min-width: 600px) { .modal { place-items: center; } }
.sheet { position: relative; width: min(100vw, 440px); background: #fff; border: 2.5px solid var(--ink); border-bottom: 0; border-radius: 22px 22px 0 0; padding: 22px 18px calc(18px + env(safe-area-inset-bottom)); display: grid; gap: 12px; }
@media (min-width: 600px) { .sheet { border-bottom: 2.5px solid var(--ink); border-radius: 22px; box-shadow: 6px 6px 0 var(--ink); } }
.sheet h2 { font-size: 22px; }
.sheet .lead, .sheet .hint, .sheet .who { margin: 0; color: var(--muted); }
.sheet .close { position: absolute; top: 10px; right: 10px; }
.sheet form, .sheet .passkey, .sheet .manage { display: grid; gap: 8px; }
.sheet input { font: inherit; font-size: 16px; padding: 12px 14px; border-radius: 12px; border: 2px solid var(--ink); background: #fff; color: var(--ink); }
.sheet .webview { background: #fff6c2; border: 2px solid #e6c200; border-radius: 12px; padding: 10px; font-size: 14px; display: grid; gap: 8px; }
.sheet .webview p { margin: 0; }
.sheet .or { text-align: center; color: var(--muted); font-size: 13px; margin-top: 4px; }
.sheet .error { margin: 0; color: var(--danger); min-height: 1em; font-size: 14px; }
button.primary, button.ghost, button.danger { font: inherit; font-weight: 700; padding: 12px 18px; border-radius: 999px; cursor: pointer; }
button.primary { background: var(--ink); color: #fff; border: 2px solid var(--ink); }
button.ghost { background: transparent; color: var(--ink); border: 2px solid var(--ink); }
button.danger { background: var(--danger); color: #fff; border: 2px solid var(--danger); }
.nudge button { padding: 8px 14px; }
.sheet .data { display: flex; justify-content: space-between; gap: 12px; padding-top: 6px; border-top: 2px solid var(--line); }
.sheet .link { background: none; border: 0; padding: 4px 0; font: inherit; font-size: 13px; color: var(--muted); text-decoration: underline; cursor: pointer; }
.sheet .confirm-delete { display: grid; gap: 8px; }
.sheet .warn { margin: 0; color: var(--danger); }
