:root {
  --bg: #f6f2e3;
  --card: #fbf8ec;
  --ink: #0f2d52;
  --ink-soft: #4a6285;
  --line: #c9cfd6;
  --accent: #0f2d52;
  --on-accent: #f6f2e3;
  --gold: #b8892b;
  --err: #a23a2a;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0a1626;
    --card: #11233b;
    --ink: #eae4d0;
    --ink-soft: #9fb2cc;
    --line: #27405f;
    --accent: #eae4d0;
    --on-accent: #0a1626;
    --gold: #e0b45a;
    --err: #e58a78;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.45 -apple-system, "Segoe UI", Roboto, sans-serif;
  overflow-x: hidden;
}
h1, h2, h3, .top-title { font-family: Georgia, "Times New Roman", serif; letter-spacing: .01em; }
h1 { font-size: 1.7rem; margin: .2em 0 .4em; }
h2 { font-size: 1.3rem; margin: 1.4em 0 .5em; display: flex; align-items: center; gap: .6em; }
h2::after { content: ""; flex: 1; border-top: 1px solid var(--line); }
h3 { font-size: 1.05rem; margin: 0 0 .4em; }
.muted { color: var(--ink-soft); }
.err { color: var(--err); }
[hidden] { display: none !important; }

.top {
  display: flex; align-items: center; gap: 10px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  border-bottom: 3px double var(--line);
  position: sticky; top: 0; background: var(--bg); z-index: 5;
}
.top-logo { width: 36px; height: 36px; border-radius: 50%; }
.top-title { font-weight: 700; font-size: 1.15rem; flex: 1; }
main { padding: 8px 16px calc(90px + env(safe-area-inset-bottom)); max-width: 640px; margin: 0 auto; }

.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; display: flex;
  background: var(--bg); border-top: 3px double var(--line);
  padding-bottom: env(safe-area-inset-bottom); z-index: 5;
}
.tabs a {
  flex: 1; text-align: center; padding: 8px 2px 10px; text-decoration: none;
  color: var(--ink-soft); font-size: .78rem; font-weight: 600;
}
.tabs a span { display: block; font-size: 1.3rem; line-height: 1.1; font-family: Georgia, serif; }
.tabs a.on { color: var(--ink); box-shadow: inset 0 3px 0 var(--ink); }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: 10px;
  padding: 14px; margin: 0 0 12px;
}
.hero { text-align: center; }
.hero img { width: min(260px, 70%); border-radius: 50%; }
.champ {
  text-align: center; border: 2px solid var(--ink); border-radius: 10px;
  padding: 12px; margin: 12px 0; background: var(--card);
}
.champ .big { font-family: Georgia, serif; font-size: 1.8rem; font-weight: 700; }
.champ .lbl { text-transform: uppercase; letter-spacing: .18em; font-size: .72rem; color: var(--gold); font-weight: 700; }

.btn, .chip, select, input {
  font: inherit; color: var(--ink); background: var(--card);
  border: 1.5px solid var(--ink); border-radius: 8px; padding: 10px 12px; min-height: 44px;
}
.btn { cursor: pointer; font-weight: 600; }
.btn.primary { background: var(--accent); color: var(--on-accent); }
.btn.sm { min-height: 36px; padding: 6px 10px; font-size: .9rem; }
.btn.ghost { border-color: var(--line); font-weight: 500; }
.btn:active { transform: translateY(1px); }
.chip { min-height: 36px; padding: 4px 12px; border-radius: 999px; font-size: .9rem; cursor: pointer; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.row > * { flex: 0 1 auto; }
.grow { flex: 1 1 120px !important; min-width: 0; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
input, select { width: 100%; }

.board { list-style: none; margin: 0; padding: 0; }
.board li {
  display: flex; align-items: center; gap: 10px; padding: 9px 0;
  border-bottom: 1px dotted var(--line);
}
.board li:last-child { border-bottom: 0; }
.rank { width: 1.6em; font-family: Georgia, serif; font-weight: 700; color: var(--gold); }
.board .name { flex: 1; font-weight: 600; min-width: 0; }
.board .sub { display: block; font-weight: 400; font-size: .78rem; color: var(--ink-soft); }
.pts { font-family: Georgia, serif; font-weight: 700; font-size: 1.2rem; }

.log { list-style: none; margin: 0; padding: 0; font-size: .92rem; }
.log li { display: flex; gap: 8px; align-items: center; padding: 6px 0; border-bottom: 1px dotted var(--line); }
.log .t { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.log .x { background: none; border: 0; color: var(--ink-soft); font-size: 1.1rem; cursor: pointer; padding: 6px 10px; }

.bar { height: 22px; background: var(--line); border-radius: 5px; overflow: hidden; flex: 1; }
.bar i { display: block; height: 100%; background: var(--ink); }
.vrow { display: flex; gap: 8px; align-items: center; margin: 4px 0; font-size: .92rem; }
.vrow b { width: 5.5em; font-weight: 600; }
.vrow em { width: 1.5em; text-align: right; font-style: normal; }
.pill { display: inline-block; font-size: .72rem; font-weight: 700; padding: 1px 8px; border-radius: 999px; border: 1px solid var(--ink); margin-left: 4px; }

.match { padding: 8px 0; border-bottom: 1px dotted var(--line); }
.match:last-child { border-bottom: 0; }
.match .grid3 .btn { padding: 6px 4px; font-size: .85rem; min-height: 40px; overflow-wrap: anywhere; }
.btn.sel { background: var(--accent); color: var(--on-accent); }
.medals { display: flex; gap: 6px; flex-wrap: wrap; }

.gate { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.gate-card { width: 100%; max-width: 380px; text-align: center; }
.gate-card input { margin: 8px 0; text-align: center; }
.gate-logo { width: 150px; border-radius: 50%; }
.prog { list-style: none; padding: 0; margin: 0; }
.prog li { display: flex; gap: 12px; padding: 6px 0; border-bottom: 1px dotted var(--line); }
.prog li:last-child { border-bottom: 0; }
.prog b { width: 5.2em; flex: none; font-family: Georgia, serif; }
.toast {
  position: fixed; left: 16px; right: 16px; bottom: calc(80px + env(safe-area-inset-bottom));
  background: var(--accent); color: var(--on-accent); padding: 10px 14px; border-radius: 8px;
  text-align: center; z-index: 9; max-width: 400px; margin: 0 auto;
}

.day { padding: 0; overflow: hidden; }
.day img { display: block; width: 100%; height: 150px; object-fit: cover; }
.day-body { padding: 12px 14px 14px; }
.bul { margin: 0; padding-left: 1.2em; }
.bul li { margin: 4px 0; }
a { color: var(--ink); }

.opt-btn { display: block; width: 100%; text-align: left; margin: 6px 0; }
.opt { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; padding: 8px 10px; margin: 5px 0; border: 1px solid var(--line); border-radius: 8px; }
.opt small { color: var(--ink-soft); text-align: right; }
.opt.right { border: 2px solid var(--ink); font-weight: 700; }
.cta { display: flex; align-items: center; justify-content: space-between; gap: 12px; text-decoration: none; border: 2px solid var(--ink); }
.cta h3 { margin: 0 0 2px; }
.cta .go { font-family: Georgia, serif; font-weight: 700; white-space: nowrap; }

.bingo { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; margin: 10px 0; }
.bcell { aspect-ratio: 1; padding: 3px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  border: 1.5px solid var(--line); background: var(--card); color: var(--ink); border-radius: 6px; font: inherit; font-size: .62rem; line-height: 1.1; cursor: pointer; overflow: hidden; overflow-wrap: anywhere; }
.bcell small { font-size: .55rem; font-weight: 700; }
.bcell.on { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.pgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.ph { margin: 0; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.ph.win { border: 2px solid var(--gold); }
.ph img { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: cover; background: var(--line); cursor: zoom-in; }
.ph figcaption { padding: 6px; font-size: .85rem; }
.ph .row { margin-top: 4px; }
.upl { text-align: center; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; }

.win { position: fixed; inset: 0; z-index: 20; background: rgba(10, 22, 38, .88); display: flex; align-items: center; justify-content: center; padding: 16px; }
.win canvas { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.win-card { position: relative; background: var(--bg); color: var(--ink); border: 3px double var(--gold); border-radius: 14px; padding: 24px 20px; text-align: center; width: 100%; max-width: 360px; animation: pop .7s cubic-bezier(.2, 1.4, .4, 1) both; }
.win-card .lbl { text-transform: uppercase; letter-spacing: .18em; font-size: .75rem; color: var(--gold); font-weight: 700; }
.win-name { font-family: Georgia, serif; font-size: 2.2rem; font-weight: 700; margin: 4px 0; overflow-wrap: anywhere; }
.win-card .btn { margin-top: 16px; }
.trophy { font-size: 4rem; line-height: 1; animation: bounce 1.2s ease-in-out infinite; }
@keyframes pop { from { transform: scale(.3); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes bounce { 0%, 100% { transform: translateY(0) rotate(-6deg); } 50% { transform: translateY(-10px) rotate(6deg); } }
@media (prefers-reduced-motion: reduce) { .trophy, .win-card { animation: none; } }
.champ.crowned { border-color: var(--gold); border-width: 3px; }
.crown-card { text-align: center; }
.crown-card .btn { width: 100%; }
.link { background: none; border: 0; color: var(--ink-soft); text-decoration: underline; font: inherit; font-size: .85rem; cursor: pointer; padding: 6px; }
