@font-face { font-family: "Cinzel"; font-weight: 700; font-display: swap; src: url("/static/fonts/cinzel-latin-700-normal.woff2") format("woff2"); }
@font-face { font-family: "Cinzel"; font-weight: 900; font-display: swap; src: url("/static/fonts/cinzel-latin-900-normal.woff2") format("woff2"); }

:root {
  --ink: #1b1916;
  --ink-2: #2a2621;
  --paper: #f4efe3;
  --card: #fffcf5;
  --line: #ddd3be;
  --line-2: #ebe3d1;
  --cream: #f0e7d2;
  --gold: #b8913f;
  --gold-hi: #d8b465;
  --gold-soft: #f1e5c4;
  --red: #8e1f1f;
  --red-soft: #f6e4df;
  --text: #221f1a;
  --muted: #7b7466;
  --amber: #b47a17;
  --radius: 12px;
  --display: "Cinzel", "Times New Roman", serif;
  --shadow: 0 1px 0 rgba(27, 25, 22, .04), 0 6px 16px -10px rgba(27, 25, 22, .35);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --hatch: repeating-linear-gradient(135deg, rgba(240, 231, 210, .035) 0 1px, transparent 1px 7px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; }
body {
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--paper);
  color: var(--text);
  font-size: 16px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--red); font-weight: 700; }
button { font: inherit; color: inherit; cursor: pointer; }
input, textarea, select { font: inherit; }
[hidden] { display: none !important; }
.display { font-family: var(--display); }

/* ---------- hero ---------- */
.hero {
  position: relative;
  background: var(--ink) var(--hatch);
  color: var(--cream);
  padding: calc(18px + var(--safe-t)) 20px 18px;
  border-bottom: 4px double var(--gold);
  overflow: hidden;
}
.hero-row { display: flex; align-items: center; gap: 14px; }
.hero-text { flex: 1; min-width: 0; }
.crest { display: block; mix-blend-mode: lighten; pointer-events: none; user-select: none; }
.hero .crest { width: 92px; height: auto; flex: none; margin: -2px 0 -4px -6px; }
.kicker { font-family: var(--display); color: var(--gold-hi); font-weight: 700; letter-spacing: .12em; text-transform: uppercase; font-size: 12px; }
.hero h1 { font-family: var(--display); margin: 6px 0 4px; font-size: clamp(28px, 8.4vw, 40px); line-height: 1.02; font-weight: 900; letter-spacing: .01em; color: var(--cream); }
.hero .sub { margin: 4px 0 0; color: rgba(240, 231, 210, .72); font-size: 14px; }
.hero .me-btn { position: absolute; top: calc(12px + var(--safe-t)); right: 14px; z-index: 2; }
.hero .kicker { padding-right: 78px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.me-btn { display: flex; align-items: center; gap: 8px; background: rgba(240,231,210,.06); border: 1px solid rgba(216,180,101,.35); border-radius: 999px; padding: 3px 3px 3px 10px; }
.net-dot { width: 8px; height: 8px; border-radius: 50%; background: #8a8478; }
.net-dot.on { background: #7fbf6a; }
.net-dot.off { background: #d4573f; }

/* ---------- layout ---------- */
.view { max-width: 560px; margin: 0 auto; padding: 18px 16px calc(96px + var(--safe-b)); }
.loading { text-align: center; color: var(--muted); padding: 60px 0; font-family: var(--display); }
.section-title { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin: 28px 2px 10px; }
.section-title h2 { margin: 0; font-family: var(--display); font-size: 15px; letter-spacing: .12em; text-transform: uppercase; color: var(--red); font-weight: 900; }
.section-title .aside { font-size: 12px; color: var(--muted); text-align: right; }
.muted { color: var(--muted); }
.center { text-align: center; }
.foot { color: var(--muted); font-size: 14px; margin: 22px 0 6px; font-family: var(--display); font-weight: 700; letter-spacing: .06em; }
.footer-line { display: flex; justify-content: space-between; color: var(--muted); font-size: 13px; margin-top: 10px; padding: 0 2px; }
.rule { height: 0; border: none; border-top: 1px solid var(--line); margin: 22px 0; position: relative; overflow: visible; }

.panel { background: var(--card); border: 1.5px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }

/* ---------- stats strip ---------- */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 16px; }
.stat { background: var(--card); border: 1.5px solid var(--line); border-radius: 10px; padding: 9px 12px; }
.stat b { display: block; font-family: var(--display); font-weight: 900; font-size: 22px; line-height: 1.15; }
.stat span { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; font-weight: 700; }
.stat.gold { background: var(--gold-soft); border-color: #dcc690; }

/* ---------- bingo grid ---------- */
.grid { display: grid; gap: 10px; grid-auto-rows: 1fr; }
.cell {
  position: relative;
  min-height: 134px;
  background: var(--card);
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  padding: 8px 8px 10px;
  display: flex; flex-direction: column; align-items: center;
  text-align: center;
  font-weight: 750;
  font-size: clamp(12px, 3.5vw, 15px);
  line-height: 1.22;
  box-shadow: inset 0 0 0 3px var(--card), inset 0 0 0 4px var(--line-2), var(--shadow);
  transition: transform .12s ease, background .2s, border-color .2s;
  user-select: none;
  overflow-wrap: break-word;
}
.grid.dense .cell { font-size: clamp(11px, 2.9vw, 13px); min-height: 112px; padding: 6px 5px 8px; }
.cell:active { transform: scale(.97); }
.cell .top { align-self: stretch; display: flex; justify-content: space-between; align-items: center; height: 18px; padding: 0 2px; }
.cell .num { font-family: var(--display); font-size: 13px; font-weight: 900; color: var(--red); }
.cell .orn { width: 9px; height: 18px; opacity: .45; }
.cell .txt { flex: 1; display: flex; align-items: center; justify-content: center; padding: 6px 0; }
.cell .mark {
  flex: none; width: 26px; height: 26px; border-radius: 50%;
  border: 2px dashed #c3b89f;
  display: grid; place-items: center; font-size: 13px;
}
.cell.pending { background: #fff6e2; border-color: #e6cc95; box-shadow: inset 0 0 0 3px #fff6e2, inset 0 0 0 4px #f1e1bb, var(--shadow); }
.cell.pending .mark { border: 2px solid var(--amber); color: var(--amber); animation: pulse 1.6s infinite; }
.cell.confirmed { background: #f6eedc; border-color: #cdbb93; box-shadow: inset 0 0 0 3px #f6eedc, inset 0 0 0 4px #e5d7b6, var(--shadow); }
.cell.confirmed .txt { color: #5b4f3b; }
.cell.confirmed .mark { border: none; width: 34px; height: 34px; margin-top: -4px; }
.cell .mark svg { width: 100%; height: 100%; display: block; filter: drop-shadow(0 2px 2px rgba(60, 10, 10, .35)); }
.cell.won { border-color: var(--gold); box-shadow: inset 0 0 0 3px #f6eedc, inset 0 0 0 4px var(--gold-hi), 0 0 0 2px var(--gold), 0 8px 22px -10px rgba(184,145,63,.9); }
.cell.empty { color: var(--muted); font-weight: 500; border-style: dashed; }
@keyframes pulse { 50% { opacity: .45; } }
.frozen-banner { background: var(--ink); color: var(--gold-soft); border-radius: 10px; padding: 10px 14px; margin-bottom: 14px; font-weight: 700; text-align: center; }

/* ---------- witness requests ---------- */
.requests { display: grid; gap: 10px; margin-bottom: 16px; }
.request { background: var(--card); border: 2px solid var(--gold); border-radius: var(--radius); padding: 14px; box-shadow: 0 10px 28px -14px rgba(184,145,63,.95); }
.request .who { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 14px; color: var(--muted); }
.request .what { font-size: 18px; font-weight: 800; margin: 8px 0 4px; }
.request .note { color: var(--muted); font-style: italic; margin: 0 0 6px; }
.request .thumb { width: 100%; max-height: 220px; object-fit: cover; border-radius: 10px; margin: 6px 0; }
.request .actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 10px; }

/* ---------- prizes ---------- */
.prizes { display: grid; gap: 8px; }
.prize { display: flex; align-items: center; gap: 12px; background: var(--card); border: 1.5px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.prize .mid { flex: 1; min-width: 0; }
.prize .lbl { font-family: var(--display); font-weight: 900; font-size: 14px; letter-spacing: .02em; }
.prize .mid .txt { display: block; margin-top: 2px; font-size: 14px; color: #4a4336; }
.prize .ok { font-size: 18px; }
.prize.won { background: var(--gold-soft); border-color: #dcc690; }
.prize.super { background: var(--ink) var(--hatch); border-color: var(--ink); color: var(--cream); border-bottom: 3px solid var(--gold); }
.prize.super .lbl { color: var(--gold-hi); }
.prize.super .mid .txt { color: var(--cream); }
.mini-grid { display: grid; gap: 2px; width: 30px; flex: none; }
.mini-grid i { aspect-ratio: 1; background: #e3d9c3; border-radius: 2px; }
.mini-grid i.on { background: var(--gold); }

/* ---------- avatars, buttons, chips ---------- */
.avatar { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; color: #fff; font-weight: 800; font-size: 13px; text-transform: uppercase; flex: none; background: var(--red); letter-spacing: .02em; box-shadow: inset 0 0 0 2px rgba(255,255,255,.18); }
.avatar.sm { width: 30px; height: 30px; font-size: 12px; }
.avatar.lg { width: 46px; height: 46px; font-size: 16px; }
.btn { border: none; border-radius: 10px; padding: 12px 16px; font-weight: 800; background: #e9e1cf; color: var(--text); display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 46px; }
.btn.big { width: 100%; font-size: 17px; min-height: 54px; }
.btn.gold { background: linear-gradient(180deg, var(--gold-hi), var(--gold)); color: #1f1708; }
.btn.teal, .btn.ink { background: var(--ink); color: var(--cream); }
.btn.navy { background: var(--ink-2); color: var(--cream); }
.btn.red { background: var(--red); color: #fff; }
.btn.ghost { background: transparent; border: 1.5px solid var(--line); }
.btn.small { min-height: 34px; padding: 6px 12px; font-size: 14px; border-radius: 9px; }
.btn:disabled { opacity: .45; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }

.chips { display: grid; grid-template-columns: repeat(auto-fill, minmax(98px, 1fr)); gap: 8px; }
.chip { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 10px 6px; border: 2px solid var(--line); border-radius: 10px; background: var(--card); font-weight: 700; font-size: 14px; }
.chip.sel { border-color: var(--ink); background: var(--gold-soft); }
.chip:disabled { opacity: .4; }
.chip small { color: var(--muted); font-weight: 600; font-size: 11px; }

/* ---------- forms ---------- */
label { display: block; font-weight: 700; font-size: 14px; margin-bottom: 12px; }
input[type=text], input[type=email], input[type=password], input[type=number], input:not([type]), textarea, select {
  display: block; width: 100%; margin-top: 6px; padding: 12px 14px; border: 1.5px solid var(--line); border-radius: 10px; background: #fffdf8; color: var(--text); font-size: 16px;
}
input:focus, textarea:focus { outline: 2px solid var(--gold); outline-offset: 1px; border-color: transparent; }
textarea { min-height: 96px; resize: vertical; }
.alert { background: var(--red-soft); color: #6d1a14; border-radius: 10px; padding: 10px 12px; margin-bottom: 14px; font-weight: 600; }
.toggle { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); font-weight: 700; margin: 0; }
.toggle input { width: 22px; height: 22px; accent-color: var(--red); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* ---------- auth pages ---------- */
body.auth { background: var(--ink) var(--hatch); min-height: 100vh; }
body.auth .auth-hero { text-align: center; color: var(--cream); padding: calc(28px + var(--safe-t)) 20px 8px; }
body.auth .auth-hero .crest { width: min(230px, 62vw); height: auto; margin: 0 auto 6px; }
body.auth .auth-hero h1 { font-family: var(--display); font-weight: 900; font-size: 32px; margin: 8px 0 2px; letter-spacing: .02em; }
body.auth .auth-hero .kicker { margin-top: 2px; }
body.auth .auth-hero .sub { color: rgba(240,231,210,.65); font-size: 14px; margin: 6px 0 0; }
body.auth .auth-box { max-width: 420px; margin: 0 auto; padding: 18px 16px 40px; }
body.auth .panel { border-color: #3b352c; background: var(--paper); }
body.auth .muted { color: rgba(240,231,210,.62); }
body.auth a { color: var(--gold-hi); }
body.auth .foot { color: var(--gold); }

/* ---------- feed ---------- */
.feed { display: grid; gap: 10px; }
.ev { display: flex; gap: 12px; background: var(--card); border: 1.5px solid var(--line); border-radius: 12px; padding: 12px; }
.ev .body { flex: 1; min-width: 0; }
.ev .line1 { font-size: 15px; }
.ev .line1 b { font-weight: 800; }
.ev .item { font-weight: 700; color: #3a3328; }
.ev .meta { font-size: 12px; color: var(--muted); margin-top: 4px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.ev .pic { width: 64px; height: 64px; border-radius: 9px; object-fit: cover; flex: none; }
.ev.bingo { background: var(--gold-soft); border-color: #d9c287; }
.ev.full_card { background: var(--ink) var(--hatch); border-color: var(--ink); color: var(--cream); }
.ev.full_card .meta, .ev.announce .meta { color: rgba(240,231,210,.6); }
.ev.rejected, .ev.claim_vetoed { background: var(--red-soft); border-color: #ecc9c0; }
.ev.announce { background: var(--ink-2); color: var(--cream); border-color: var(--ink-2); }
.ev.announce .line1 b, .ev.full_card .line1 b { color: var(--gold-hi); }
.ev .icon { font-size: 22px; width: 34px; text-align: center; flex: none; }
.pill { display: inline-block; font-size: 11px; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; padding: 2px 8px; border-radius: 999px; background: #ece4d2; color: #6b6352; }
.pill.ok { background: var(--gold-soft); color: #7a5d1f; }
.pill.wait { background: #fff0cf; color: #8a5d0c; }
.pill.bad { background: #f7dcd5; color: var(--red); }
.veto { border: 1.5px solid #e2b9ae; background: #fff; color: var(--red); font-weight: 800; font-size: 12px; border-radius: 999px; padding: 2px 10px; }
.veto.on { background: var(--red); color: #fff; border-color: var(--red); }

/* ---------- leaderboard ---------- */
.board { display: grid; gap: 10px; }
.rank { display: grid; grid-template-columns: 34px auto 1fr; gap: 12px; align-items: center; background: var(--card); border: 1.5px solid var(--line); border-radius: 12px; padding: 12px; }
.rank.me { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold); }
.rank .pos { font-family: var(--display); font-size: 22px; font-weight: 900; text-align: center; color: var(--muted); }
.rank .name { font-weight: 800; font-size: 16px; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.rank .nums { display: flex; gap: 10px; font-size: 13px; color: #4a4336; margin-top: 3px; flex-wrap: wrap; }
.rank .won-list { grid-column: 2 / -1; display: grid; gap: 4px; }
.rank .won-list div { font-size: 13px; background: var(--gold-soft); border-radius: 7px; padding: 4px 8px; }
.badge-first { font-family: var(--display); font-size: 10px; background: var(--ink); color: var(--gold-hi); padding: 3px 8px; border-radius: 999px; font-weight: 900; letter-spacing: .06em; }

/* ---------- album ---------- */
.album { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.album figure { margin: 0; position: relative; aspect-ratio: 1; border-radius: 9px; overflow: hidden; background: #e6dec9; }
.album img { width: 100%; height: 100%; object-fit: cover; display: block; }
.album figcaption { position: absolute; inset: auto 0 0 0; padding: 14px 6px 5px; font-size: 11px; font-weight: 700; color: #fff; background: linear-gradient(transparent, rgba(0,0,0,.7)); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.empty-state { text-align: center; color: var(--muted); padding: 40px 10px; }
.empty-state .big { font-size: 44px; }

/* ---------- admin ---------- */
details.adm { background: var(--card); border: 1.5px solid var(--line); border-radius: var(--radius); margin-bottom: 10px; overflow: hidden; }
details.adm summary { list-style: none; padding: 15px 16px; font-weight: 800; display: flex; align-items: center; gap: 8px; }
details.adm summary .muted { font-weight: 600; font-size: 14px; }
details.adm summary::-webkit-details-marker { display: none; }
details.adm summary::after { content: "＋"; color: var(--red); margin-left: auto; }
details.adm[open] summary::after { content: "－"; }
details.adm .inner { padding: 0 16px 16px; }
.list { display: grid; gap: 8px; }
.li { display: flex; gap: 10px; align-items: center; padding: 10px 0; border-top: 1px solid var(--line); }
.li:first-child { border-top: none; }
.li .grow { flex: 1; min-width: 0; }
.li .small:not(.btn) { font-size: 12px; color: var(--muted); }
.code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-weight: 800; letter-spacing: .04em; }
.warn { color: var(--red); font-size: 13px; }

/* ---------- tabs ---------- */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex; justify-content: space-around;
  background: rgba(27, 25, 22, .97);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  padding: 6px 6px calc(6px + var(--safe-b));
  border-top: 4px double var(--gold);
}
.tabs button { position: relative; flex: 1; background: none; border: none; color: rgba(240,231,210,.55); display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 6px 0; font-size: 11px; font-weight: 700; letter-spacing: .03em; }
.tabs .ico { font-size: 20px; line-height: 1.1; }
.tabs button.active { color: var(--gold-hi); }
.badge { position: absolute; top: 2px; left: 55%; min-width: 18px; height: 18px; border-radius: 9px; background: var(--red); color: #fff; font-style: normal; font-size: 11px; font-weight: 800; display: grid; place-items: center; padding: 0 5px; box-shadow: 0 0 0 2px var(--ink); }
.badge.dot { min-width: 10px; width: 10px; height: 10px; padding: 0; }

/* ---------- sheet ---------- */
.sheet-wrap { position: fixed; inset: 0; z-index: 40; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(15, 13, 10, .55); animation: fade .2s; }
.sheet {
  position: absolute; left: 0; right: 0; bottom: 0; max-height: 90vh; overflow: auto;
  background: var(--paper); border-radius: 20px 20px 0 0; padding: 10px 18px calc(22px + var(--safe-b));
  max-width: 560px; margin: 0 auto; animation: up .25s cubic-bezier(.2,.9,.3,1.1);
  border-top: 4px double var(--gold);
}
.sheet::before { content: ""; display: block; width: 44px; height: 5px; border-radius: 3px; background: #cdc2aa; margin: 0 auto 14px; }
.sheet h3 { margin: 0 0 4px; font-size: 22px; line-height: 1.2; }
.sheet .lead { color: var(--muted); margin: 0 0 16px; }
.sheet .k { font-family: var(--display); font-size: 13px; letter-spacing: .12em; text-transform: uppercase; color: var(--red); font-weight: 900; margin: 18px 0 8px; }
.sheet .photo-prev { width: 100%; max-height: 260px; object-fit: cover; border-radius: 10px; margin-top: 8px; }
.file-btn { position: relative; overflow: hidden; }
.file-btn input { position: absolute; inset: 0; opacity: 0; }
@keyframes up { from { transform: translateY(100%); } }
@keyframes fade { from { opacity: 0; } }

/* ---------- toasts ---------- */
.toasts { position: fixed; left: 0; right: 0; top: calc(12px + var(--safe-t)); z-index: 60; display: grid; gap: 8px; justify-items: center; pointer-events: none; padding: 0 12px; }
.toast { background: var(--ink); color: var(--cream); padding: 11px 16px; border-radius: 12px; font-weight: 700; font-size: 14px; box-shadow: 0 10px 30px -10px rgba(0,0,0,.6); max-width: 520px; animation: drop .3s cubic-bezier(.2,.9,.3,1.2); border-left: 4px solid var(--gold); pointer-events: auto; }
.toast.err { border-left-color: #d4573f; }
.toast.ok { border-left-color: #7fbf6a; }
@keyframes drop { from { transform: translateY(-30px); opacity: 0; } }
.offline-bar { position: sticky; top: 0; z-index: 15; background: var(--red); color: #fff; font-weight: 700; font-size: 13px; text-align: center; padding: 8px 12px; }

/* ---------- bingo overlay ---------- */
.bingo-overlay { position: fixed; inset: 0; z-index: 70; display: grid; place-items: center; background: var(--ink); color: var(--cream); text-align: center; padding: 24px; animation: fade .25s; }
.bingo-overlay .crest { width: min(190px, 50vw); height: auto; margin: 0 auto 4px; }
.bingo-overlay .word { font-family: var(--display); font-size: clamp(54px, 16vw, 104px); font-weight: 900; color: var(--gold-hi); letter-spacing: .02em; line-height: 1; text-shadow: 0 4px 36px rgba(216,180,101,.45); animation: boom .7s cubic-bezier(.2,1.6,.4,1); }
.bingo-overlay .word.long { font-size: clamp(38px, 11.5vw, 76px); }
.bingo-overlay .who { font-family: var(--display); font-size: 20px; font-weight: 900; margin-top: 12px; letter-spacing: .03em; }
.bingo-overlay .line { color: rgba(240,231,210,.7); margin-top: 4px; }
.ribbon {
  position: relative; display: inline-block; margin-top: 20px; padding: 12px 34px;
  background: linear-gradient(180deg, var(--gold-hi), var(--gold)); color: #1f1708;
  font-family: var(--display); font-weight: 900; font-size: 17px; letter-spacing: .02em; max-width: 440px;
  clip-path: polygon(0 0, 100% 0, calc(100% - 16px) 50%, 100% 100%, 0 100%, 16px 50%);
}
.bingo-overlay .tap { margin-top: 26px; color: rgba(240,231,210,.4); font-size: 13px; }
@keyframes boom { from { transform: scale(.2) rotate(-10deg); opacity: 0; } }
@keyframes rise { from { transform: translateY(24px) scale(.9); opacity: 0; } }
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 80; width: 100%; height: 100%; }

.lightbox { position: fixed; inset: 0; z-index: 90; background: rgba(0,0,0,.92); display: grid; place-items: center; padding: 16px; }
.lightbox img { max-width: 100%; max-height: 100%; border-radius: 8px; }

@media (min-width: 600px) {
  .hero { padding-left: max(20px, calc(50% - 260px)); padding-right: max(20px, calc(50% - 260px)); }
  .hero .crest { width: 112px; }
}
