@font-face { font-family: 'Fraunces'; src: url('fonts/fraunces.woff2') format('woff2'); font-weight: 300 900; font-style: normal; font-display: swap; }
@font-face { font-family: 'Inter'; src: url('fonts/inter.woff2') format('woff2'); font-weight: 300 900; font-style: normal; font-display: swap; }

:root {
  --ink: #1E1A3C; --ink2: #4A4566; --muted: #8B86A3; --line: #E8E1D3;
  --bg: #F7F1E6; --card: #FFFDF8; --indigo: #241B5C; --indigo2: #3A2D8C; --gold: #F4B63F; --gold2: #E79A1B;
  --good: #1F9D6B; --bad: #D9473B;
  --pa: #0E8C7F; --pb: #E2574C; --cur: var(--pa);
  --tabh: calc(3.6rem + env(safe-area-inset-bottom));
  --r: 1rem;
  --shadow: 0 1px 0 rgba(255,255,255,.7) inset, 0 .5rem 1.4rem -0.6rem rgba(36,27,92,.28), 0 .1rem .25rem rgba(36,27,92,.08);
}
html { font-size: clamp(14px, min(4.27vw, 2.45vh), 26px); -webkit-text-size-adjust: 100%; }
@media (orientation: landscape) and (min-width: 900px) { html { font-size: clamp(14px, min(2.15vw, 2.55vh), 24px); } }
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--indigo); }
body { font-family: 'Inter', system-ui, sans-serif; color: var(--ink); overscroll-behavior: none; -webkit-user-select: none; user-select: none; }
button { font: inherit; color: inherit; border: 0; background: none; padding: 0; cursor: pointer; }
input, select, textarea { font: inherit; color: inherit; -webkit-user-select: text; user-select: text; }
.num, .serif { font-family: 'Fraunces', Georgia, serif; font-variant-numeric: lining-nums tabular-nums; }

#app { position: fixed; inset: 0; display: flex; flex-direction: column; background:
  radial-gradient(120% 60% at 100% 0%, rgba(244,182,63,.16), transparent 60%),
  radial-gradient(90% 50% at 0% 100%, rgba(58,45,140,.10), transparent 60%), var(--bg); }
#view { flex: 1; min-height: 0; position: relative; }
.scroll { position: absolute; inset: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: calc(env(safe-area-inset-top) + 1rem) 1rem 1.5rem; }
.wrap { max-width: 40rem; margin: 0 auto; }

/* Tabs */
#tabs { flex: none; height: var(--tabh); padding-bottom: env(safe-area-inset-bottom); display: flex; background: rgba(255,253,248,.92);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border-top: 1px solid var(--line); }
#tabs button { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .15rem; color: var(--muted); font-size: .72rem; font-weight: 600; letter-spacing: .01em; }
#tabs svg { width: 1.45rem; height: 1.45rem; fill: currentColor; }
#tabs button.on { color: var(--indigo2); }
#tabs button.on svg { filter: drop-shadow(0 2px 4px rgba(58,45,140,.25)); }
#tabs .dot { position: absolute; }

/* ---------- Game screen ---------- */
.game { position: absolute; inset: 0; display: grid; grid-template-rows: auto 1fr auto; }
.ghead { background: linear-gradient(160deg, #2F247A, var(--indigo) 70%); color: #fff; padding: calc(env(safe-area-inset-top) + .5rem) .6rem .55rem;
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: stretch; gap: .45rem; border-radius: 0 0 1.2rem 1.2rem; box-shadow: 0 .4rem 1rem -0.4rem rgba(36,27,92,.5); position: relative; z-index: 2; }
.pill { border-radius: .9rem; padding: .3rem .65rem .35rem; background: rgba(255,255,255,.07); border: 1.5px solid rgba(255,255,255,.1); display: grid; grid-template-columns: auto 1fr; grid-template-areas: 'nm nm' 'st tot'; align-items: center; column-gap: .4rem; min-width: 0; transition: background .3s, border-color .3s, transform .3s; }
.pill.r { grid-template-columns: 1fr auto; grid-template-areas: 'nm nm' 'tot st'; text-align: right; }
.pill .tot { text-align: right; } .pill.r .tot { text-align: left; }
.pill .st { align-self: end; padding-bottom: .2rem; }
.pill .nm { grid-area: nm; font-weight: 800; font-size: .95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; line-height: 1.15; }
.pill .st { grid-area: st; font-weight: 600; font-size: .66rem; opacity: .75; letter-spacing: .02em; white-space: nowrap; }
.pill .tot { grid-area: tot; font-family: 'Fraunces', serif; font-weight: 700; font-size: 2rem; line-height: 1; font-variant-numeric: tabular-nums lining-nums; }
.pill.on { background: var(--pc); border-color: rgba(255,255,255,.55); transform: translateY(1px); box-shadow: 0 0 0 3px rgba(255,255,255,.12), 0 .5rem 1rem -0.4rem var(--pc); }
.pill:not(.on) { opacity: .78; }
.mid { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .15rem; min-width: 3.2rem; }
.mid .rd { font-family: 'Fraunces', serif; font-size: 1.25rem; font-weight: 700; line-height: 1; }
.mid .rdl { font-size: .58rem; text-transform: uppercase; letter-spacing: .12em; opacity: .65; }
.mid button { font-size: .7rem; opacity: .75; padding: .1rem .4rem; border-radius: .4rem; background: rgba(255,255,255,.1); }
.tag { display: inline-flex; align-items: center; gap: .3rem; font-size: .7rem; font-weight: 600; color: var(--indigo2); background: rgba(58,45,140,.08); border-radius: 99rem; padding: .15rem .55rem; }

.board { min-height: 0; padding: .45rem .5rem .2rem; display: grid; grid-template-columns: 1fr 1fr; gap: .4rem; }
.sec { background: var(--card); border-radius: var(--r); box-shadow: var(--shadow); display: flex; flex-direction: column; overflow: hidden; min-height: 0; }
.sh { display: grid; grid-template-columns: 1fr 2.6rem 2.6rem; align-items: center; padding: .3rem .35rem .2rem .55rem; font-size: .62rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); border-bottom: 1px solid var(--line); }
.sh i { font-style: normal; text-align: center; letter-spacing: 0; text-transform: none; font-size: .7rem; font-weight: 800; color: var(--pcol); white-space: nowrap; overflow: hidden; }
.row { flex: 1; min-height: 0; display: grid; grid-template-columns: 1fr 2.6rem 2.6rem; align-items: center; padding: 0 .35rem 0 .55rem; border-bottom: 1px solid #F1EBDF; }
.row:last-child { border-bottom: 0; }
.row .lb { font-size: .86rem; font-weight: 600; color: var(--ink2); display: flex; align-items: center; gap: .35rem; white-space: nowrap; overflow: hidden; }
.row .lb .mini { width: 1.05rem; height: 1.05rem; border-radius: .25rem; background: var(--indigo); flex: none; display: grid; grid-template: repeat(3,1fr)/repeat(3,1fr); padding: .12rem; }
.mini b { width: .2rem; height: .2rem; border-radius: 50%; background: #fff; place-self: center; }
.cell { height: calc(100% - 4px); max-height: 2.3rem; margin: 2px 2px; border-radius: .55rem; display: flex; align-items: center; justify-content: center; font-family: 'Fraunces', serif; font-weight: 700; font-size: 1.15rem; font-variant-numeric: tabular-nums lining-nums; color: var(--ink); position: relative; }
.cell.act { background: color-mix(in srgb, var(--cur) 6%, transparent); }
.cell.opt { color: var(--cur); border: 1.5px dashed color-mix(in srgb, var(--cur) 55%, transparent); background: color-mix(in srgb, var(--cur) 9%, #fff); cursor: pointer; }
.board.just .cell.opt { animation: pop .25s ease-out; }
.cell.opt.zero { color: #B9B4C8; border-color: #DDD8E6; background: #FBFAFD; }
.cell.opt.sel { background: var(--cur); color: #fff; border: 1.5px solid var(--cur); transform: scale(1.06); box-shadow: 0 .3rem .7rem -0.2rem var(--cur); }
.cell.opt.best:not(.zero)::after { content: ''; position: absolute; top: .18rem; right: .2rem; width: .38rem; height: .38rem; border-radius: 50%; background: var(--gold); box-shadow: 0 0 0 2px #fff; }
.cell.done.z { color: #C4BFD2; }
.cell.fresh { animation: stamp .45s cubic-bezier(.2,1.6,.4,1); }
.row.sub { background: #FBF7EF; }
.row.sub .lb { font-size: .66rem; letter-spacing: 0 !important; color: var(--muted); font-weight: 700; letter-spacing: .03em; }
.row.sub .cell { font-size: .9rem; }
.prog { font-family: 'Inter'; font-size: .62rem !important; font-weight: 700; color: var(--muted); flex-direction: column; line-height: 1.05; }
.prog em { font-style: normal; font-size: .85rem; font-family: 'Fraunces', serif; color: var(--ink2); }
.prog.got em { color: var(--good); }
.prog .bar { width: 80%; height: 3px; border-radius: 3px; background: #E9E3D6; margin-top: 2px; overflow: hidden; }
.prog .bar i { display: block; height: 100%; background: var(--gold2); }
.prog.got .bar i { background: var(--good); }

.tray { padding: .35rem .7rem calc(.6rem); display: flex; flex-direction: column; gap: .45rem; }
.status { display: flex; align-items: center; justify-content: space-between; font-size: .8rem; font-weight: 600; color: var(--ink2); min-height: 1.2rem; padding: 0 .2rem; }
.status .who { display: flex; align-items: center; gap: .4rem; }
.status .who b { color: var(--cur); font-weight: 800; }
.rolls { display: flex; gap: .3rem; align-items: center; }
.rolls i { width: .62rem; height: .62rem; border-radius: 50%; background: var(--cur); box-shadow: 0 0 0 2px color-mix(in srgb, var(--cur) 25%, transparent); transition: all .3s; }
.rolls i.used { background: #DCD6E6; box-shadow: none; }
.dice { display: grid; grid-template-columns: repeat(5, 1fr); gap: .55rem; padding: .35rem .2rem .2rem; perspective: 600px; }
.die { aspect-ratio: 1; max-height: 4.4rem; justify-self: center; width: 100%; max-width: 4.4rem; border-radius: 22%; background: linear-gradient(145deg, #FFFFFF, #F3ECDD); box-shadow: 0 .15rem 0 #D9CFBC, 0 .5rem .9rem -0.3rem rgba(36,27,92,.45), inset 0 -0.15rem .3rem rgba(0,0,0,.04);
  display: grid; grid-template: repeat(3, 1fr) / repeat(3, 1fr); padding: 17%; position: relative; transition: transform .25s cubic-bezier(.2,1.4,.4,1), box-shadow .25s; }
.die b { width: 78%; aspect-ratio: 1; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #4B3DA8, var(--indigo) 70%); place-self: center; }
.die.blank { background: linear-gradient(145deg, #F3EEFF, #E4DCF7); box-shadow: 0 .15rem 0 #CFC4EA, 0 .4rem .8rem -0.3rem rgba(36,27,92,.3); }
.die.blank::after { content: '?'; position: absolute; inset: 0; display: grid; place-items: center; font-family: 'Fraunces', serif; font-size: 1.6rem; font-weight: 700; color: rgba(58,45,140,.35); }
.die.held { transform: translateY(-.3rem); box-shadow: 0 0 0 .2rem var(--cur), 0 .7rem 1rem -0.3rem rgba(36,27,92,.45); background: linear-gradient(145deg, #FFFFFF, color-mix(in srgb, var(--cur) 12%, #FFF)); }
.die.held::after { content: 'HOLD'; position: absolute; left: 50%; bottom: -1.05rem; transform: translateX(-50%); font-size: .55rem; font-weight: 800; letter-spacing: .12em; color: var(--cur); }
.die.rolling { animation: tumble var(--dur, .7s) cubic-bezier(.3,.7,.3,1) both; }
.die.yz { animation: glow 1.2s ease-in-out 2; }
.go { height: 3.4rem; border-radius: 1.1rem; font-weight: 800; font-size: 1.12rem; letter-spacing: .01em; color: #fff; background: linear-gradient(180deg, color-mix(in srgb, var(--cur) 82%, #fff), var(--cur)); box-shadow: 0 .25rem 0 color-mix(in srgb, var(--cur) 70%, #000), 0 .7rem 1.2rem -0.5rem var(--cur);
  display: flex; align-items: center; justify-content: center; gap: .5rem; transition: transform .1s, box-shadow .1s; }
.go:active { transform: translateY(.2rem); box-shadow: 0 .05rem 0 color-mix(in srgb, var(--cur) 70%, #000); }
.go[disabled] { background: #E6E0EF; color: #8E88A6; box-shadow: none; }
.go.score { background: linear-gradient(180deg, #FFCB62, var(--gold2)); color: var(--indigo); box-shadow: 0 .25rem 0 #B9750D, 0 .7rem 1.2rem -0.5rem var(--gold2); }
.go small { font-weight: 600; opacity: .8; font-size: .85rem; }

/* Landscape tablet: board left, tray right */
@media (orientation: landscape) and (min-width: 900px) {
  .game { grid-template-columns: 1.55fr 1fr; grid-template-rows: auto 1fr; }
  .ghead { grid-column: 1 / -1; }
  .board { grid-row: 2; padding: .7rem .5rem .7rem 1rem; }
  .tray { grid-row: 2; justify-content: center; padding: 1rem 1.2rem 1rem .6rem; gap: 1.2rem; }
  .dice { grid-template-columns: repeat(3, 1fr); row-gap: 1.6rem; }
  .die { max-width: 5.2rem; max-height: 5.2rem; }
}

/* Turn banner */
.banner { position: absolute; left: 50%; top: 42%; transform: translate(-50%, -50%) scale(.8); opacity: 0; pointer-events: none; z-index: 5;
  background: var(--cur); color: #fff; padding: .8rem 1.6rem; border-radius: 1.2rem; font-family: 'Fraunces', serif; font-weight: 700; font-size: 1.6rem; white-space: nowrap; box-shadow: 0 1rem 2rem -0.6rem rgba(0,0,0,.4); }
.banner small { display: block; font-family: 'Inter'; font-size: .75rem; font-weight: 600; opacity: .85; text-align: center; }
.banner.show { animation: banner 1.5s ease both; }
.banner.yz { background: linear-gradient(135deg, var(--gold), #FF7A59); color: var(--indigo); font-size: 2.6rem; }

/* ---------- Generic UI ---------- */
h1.title { font-family: 'Fraunces', serif; font-weight: 800; font-size: 2rem; letter-spacing: -.02em; margin: .2rem 0 .1rem; color: var(--indigo); }
h1.title em { font-style: italic; color: var(--gold2); font-weight: 600; }
.lede { color: var(--ink2); margin: 0 0 1rem; font-size: .92rem; }
h2 { font-size: .72rem; text-transform: uppercase; letter-spacing: .14em; color: var(--muted); margin: 1.4rem 0 .55rem; font-weight: 800; }
.card { background: var(--card); border-radius: 1.2rem; box-shadow: var(--shadow); padding: 1rem; margin-bottom: .8rem; }
.card.dark { background: linear-gradient(160deg, #33278A, var(--indigo)); color: #fff; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; padding: .7rem 1.1rem; border-radius: .9rem; font-weight: 700; font-size: .95rem; background: var(--indigo2); color: #fff; box-shadow: 0 .2rem 0 #241B5C; }
.btn:active { transform: translateY(.15rem); box-shadow: none; }
.btn.ghost { background: #F0EBE0; color: var(--ink); box-shadow: none; }
.btn.gold { background: linear-gradient(180deg, #FFCB62, var(--gold2)); color: var(--indigo); box-shadow: 0 .2rem 0 #B9750D; }
.btn.small { padding: .4rem .75rem; font-size: .82rem; border-radius: .7rem; }
.btn.danger { background: #FBE7E4; color: var(--bad); box-shadow: none; }
.btn.block { width: 100%; }
.btn.big { padding: 1.05rem 1.2rem; font-size: 1.2rem; border-radius: 1.1rem; }
.chips { display: flex; flex-wrap: wrap; gap: .45rem; }
.chip { padding: .5rem .85rem; border-radius: 99rem; background: #F0EBE0; font-weight: 600; font-size: .9rem; color: var(--ink2); border: 1.5px solid transparent; display: inline-flex; align-items: center; gap: .4rem; }
.chip .sw { width: .65rem; height: .65rem; border-radius: 50%; background: var(--c); }
.chip.on { background: #fff; border-color: var(--indigo2); color: var(--indigo); box-shadow: 0 .2rem .5rem -0.2rem rgba(58,45,140,.4); }
.chip.add { background: transparent; border: 1.5px dashed #CFC7B6; color: var(--muted); }
.seg { display: flex; background: #EFE9DD; border-radius: .9rem; padding: .22rem; gap: .2rem; }
.seg button { flex: 1; padding: .5rem .2rem; border-radius: .7rem; font-weight: 700; font-size: .82rem; color: var(--ink2); white-space: nowrap; }
.seg button.on { background: #fff; color: var(--indigo); box-shadow: 0 .15rem .4rem -0.1rem rgba(36,27,92,.2); }
.field { width: 100%; padding: .75rem .9rem; border-radius: .8rem; border: 1.5px solid var(--line); background: #fff; font-size: 1rem; outline: none; }
.field:focus { border-color: var(--indigo2); }
.muted { color: var(--muted); }
.small { font-size: .8rem; }
.row2 { display: flex; gap: .5rem; align-items: center; }
.row2 > .grow { flex: 1; min-width: 0; }
.empty { text-align: center; color: var(--muted); padding: 1.2rem .5rem; font-size: .9rem; }

/* Versus card (setup) */
.vs { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: .6rem; }
.vs .side { text-align: center; padding: .9rem .4rem; border-radius: 1rem; background: color-mix(in srgb, var(--c) 10%, #fff); border: 2px solid color-mix(in srgb, var(--c) 35%, transparent); }
.vs .side .n { font-family: 'Fraunces', serif; font-weight: 800; font-size: 1.45rem; color: color-mix(in srgb, var(--c) 80%, #000); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.vs .side .s { font-size: .72rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; margin-top: .15rem; }
.vs .x { display: flex; flex-direction: column; align-items: center; gap: .3rem; font-family: 'Fraunces', serif; font-style: italic; color: var(--muted); font-weight: 600; }
.swap { width: 2.4rem; height: 2.4rem; border-radius: 50%; background: #F0EBE0; display: grid; place-items: center; font-size: 1.1rem; color: var(--indigo2); }

/* Stats */
.hero { padding: 1.1rem 1rem 1rem; }
.hero .tops { display: grid; grid-template-columns: 1fr auto 1fr; align-items: end; }
.hero .who { font-weight: 700; font-size: .95rem; opacity: .9; }
.hero .w { font-family: 'Fraunces', serif; font-weight: 800; font-size: 3.6rem; line-height: .95; font-variant-numeric: tabular-nums lining-nums; }
.hero .r { text-align: right; }
.hero .dash { font-family: 'Fraunces', serif; font-size: 1.6rem; opacity: .5; padding-bottom: .5rem; }
.hero .bar { display: flex; height: .55rem; border-radius: 99rem; overflow: hidden; margin: .8rem 0 .6rem; background: rgba(255,255,255,.12); }
.hero .bar i { display: block; height: 100%; }
.hero .foot { display: flex; justify-content: space-between; font-size: .8rem; opacity: .85; gap: .5rem; }
.streak { margin-top: .7rem; padding: .5rem .7rem; border-radius: .8rem; background: rgba(255,255,255,.1); font-size: .85rem; font-weight: 600; }
.cmp { width: 100%; border-collapse: collapse; }
.cmp td { padding: .6rem .2rem; border-bottom: 1px solid #F1EBDF; font-size: .95rem; }
.cmp tr:last-child td { border-bottom: 0; }
.cmp td.v { font-family: 'Fraunces', serif; font-weight: 700; font-size: 1.3rem; width: 28%; font-variant-numeric: tabular-nums lining-nums; }
.cmp td.v.l { text-align: left; } .cmp td.v.r { text-align: right; }
.cmp td.k { text-align: center; color: var(--muted); font-size: .76rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; }
.cmp td.v.lead { color: var(--good); }
.cmp th { font-size: .8rem; padding-bottom: .4rem; }
.glist .g { display: grid; grid-template-columns: auto 1fr auto; gap: .7rem; align-items: center; padding: .65rem 0; border-bottom: 1px solid #F1EBDF; }
.glist .g:last-child { border-bottom: 0; }
.glist .d { font-size: .72rem; color: var(--muted); font-weight: 600; text-align: center; line-height: 1.2; width: 2.8rem; }
.glist .d b { display: block; font-family: 'Fraunces', serif; font-size: 1.15rem; color: var(--ink); }
.glist .sc { font-size: .95rem; }
.glist .sc .wn { font-weight: 800; }
.glist .sc .meta { font-size: .72rem; color: var(--muted); margin-top: .15rem; }
.glist .res { font-family: 'Fraunces', serif; font-weight: 700; font-size: 1.15rem; text-align: right; }
.pgrid { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; margin-top: .7rem; }
.pgrid div { background: #FBF7EF; border-radius: .8rem; padding: .55rem .5rem; text-align: center; }
.pgrid b { display: block; font-family: 'Fraunces', serif; font-size: 1.35rem; }
.pgrid span { font-size: .66rem; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .06em; }
.phead { display: flex; align-items: center; gap: .6rem; }
.avatar { width: 2.4rem; height: 2.4rem; border-radius: 50%; background: var(--c); color: #fff; display: grid; place-items: center; font-family: 'Fraunces', serif; font-weight: 800; font-size: 1.15rem; flex: none; box-shadow: 0 .2rem .5rem -0.15rem var(--c); }
.banner-note { display: flex; gap: .7rem; align-items: center; background: #FFF3D6; border: 1px solid #F6D58C; border-radius: 1rem; padding: .75rem .85rem; margin-bottom: .8rem; font-size: .86rem; }

/* Wagers */
.match .mt { display: flex; justify-content: space-between; align-items: center; gap: .5rem; }
.match .stake { font-family: 'Fraunces', serif; font-style: italic; font-size: 1.15rem; color: var(--indigo); margin: .35rem 0 .6rem; }
.pips { display: flex; gap: .35rem; }
.pips i { width: 1.1rem; height: 1.1rem; border-radius: 50%; border: 2px solid var(--c); }
.pips i.w { background: var(--c); }
.mscore { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: .5rem; margin-bottom: .7rem; }
.mscore .p { display: flex; flex-direction: column; gap: .3rem; }
.mscore .p.r { align-items: flex-end; }
.mscore .p .n { font-weight: 700; }
.mscore .big { font-family: 'Fraunces', serif; font-size: 2.2rem; font-weight: 800; }
.debt { display: grid; grid-template-columns: 1fr auto; gap: .6rem; align-items: center; padding: .75rem 0; border-bottom: 1px solid #F1EBDF; }
.debt:last-child { border-bottom: 0; }
.debt .who { font-weight: 700; }
.debt .what { font-family: 'Fraunces', serif; font-style: italic; font-size: 1.1rem; color: var(--indigo); margin: .1rem 0; }
.debt.paid .what { text-decoration: line-through; color: var(--muted); }
.owes { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; }
.owes div { background: rgba(255,255,255,.1); border-radius: .9rem; padding: .7rem; }
.owes b { display: block; font-family: 'Fraunces', serif; font-size: 2rem; line-height: 1; }
.owes span { font-size: .78rem; opacity: .85; }

/* Trips */
.board-t { width: 100%; border-collapse: collapse; font-size: .92rem; }
.board-t th { font-size: .66rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); text-align: right; padding: .3rem .2rem; font-weight: 800; }
.board-t th:first-child, .board-t td:first-child { text-align: left; }
.board-t td { padding: .55rem .2rem; text-align: right; border-top: 1px solid #F1EBDF; font-variant-numeric: tabular-nums; }
.board-t td.nm { font-weight: 700; }
.rank { display: inline-grid; place-items: center; width: 1.5rem; height: 1.5rem; border-radius: 50%; background: #F0EBE0; font-size: .75rem; font-weight: 800; margin-right: .4rem; }
.rank.g1 { background: var(--gold); color: var(--indigo); }

/* Overlay / modal */
#overlay { position: fixed; inset: 0; z-index: 50; background: rgba(20,14,50,.55); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); display: flex; align-items: center; justify-content: center; padding: 1rem; animation: fade .2s; }
#overlay[hidden] { display: none; }
.modal { background: var(--card); border-radius: 1.5rem; width: 100%; max-width: 26rem; max-height: 100%; overflow-y: auto; padding: 1.3rem 1.2rem 1.1rem; box-shadow: 0 1.5rem 3rem -1rem rgba(0,0,0,.5); animation: rise .35s cubic-bezier(.2,1.3,.4,1); position: relative; }
.modal h3 { font-family: 'Fraunces', serif; font-size: 1.5rem; margin: 0 0 .4rem; color: var(--indigo); }
.modal .acts { display: flex; flex-direction: column; gap: .5rem; margin-top: 1rem; }
.win .crown { font-size: 2.6rem; text-align: center; line-height: 1; }
.win .wname { text-align: center; font-family: 'Fraunces', serif; font-weight: 800; font-size: 2.3rem; color: var(--c); line-height: 1.1; margin-top: .3rem; }
.win .sub { text-align: center; color: var(--ink2); font-weight: 600; margin-top: .2rem; }
.finals { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; margin: 1rem 0 .4rem; }
.finals div { border-radius: 1rem; padding: .7rem; text-align: center; background: color-mix(in srgb, var(--c) 10%, #fff); border: 2px solid color-mix(in srgb, var(--c) 30%, transparent); }
.finals div.won { border-color: var(--c); box-shadow: 0 .4rem 1rem -0.4rem var(--c); }
.finals b { display: block; font-family: 'Fraunces', serif; font-size: 2.4rem; line-height: 1.05; color: color-mix(in srgb, var(--c) 85%, #000); }
.finals span { font-size: .82rem; font-weight: 700; color: var(--ink2); }
.finals small { display: block; font-size: .7rem; color: var(--muted); margin-top: .15rem; }
.callout { border-radius: 1rem; padding: .8rem .9rem; background: #FFF3D6; border: 1px solid #F6D58C; margin-top: .7rem; font-size: .92rem; }
.callout b.st { font-family: 'Fraunces', serif; font-style: italic; font-size: 1.1rem; color: var(--indigo); }
.confetti { position: absolute; inset: 0; pointer-events: none; overflow: hidden; border-radius: 1.5rem; }
.confetti i { position: absolute; top: -10%; width: .5rem; height: .8rem; border-radius: 2px; animation: fall 2.4s ease-in forwards; }

#toast { position: fixed; left: 50%; bottom: calc(var(--tabh) + 1rem); transform: translateX(-50%) translateY(1rem); opacity: 0; transition: all .3s; background: var(--indigo); color: #fff; padding: .7rem 1.1rem; border-radius: .9rem; font-weight: 600; font-size: .9rem; z-index: 60; pointer-events: none; max-width: 90vw; text-align: center; box-shadow: 0 .6rem 1.4rem -0.4rem rgba(0,0,0,.4); }
#toast.on { opacity: 1; transform: translateX(-50%) translateY(0); }

@keyframes tumble {
  0% { transform: translateY(0) rotate(0) scale(1); }
  20% { transform: translateY(-1.6rem) rotate(calc(var(--spin, 1) * 160deg)) scale(1.08); }
  45% { transform: translateY(.25rem) rotate(calc(var(--spin, 1) * 300deg)) scale(.96); }
  65% { transform: translateY(-.5rem) rotate(calc(var(--spin, 1) * 345deg)) scale(1.02); }
  82% { transform: translateY(.06rem) rotate(calc(var(--spin, 1) * 362deg)); }
  100% { transform: translateY(0) rotate(calc(var(--spin, 1) * 360deg)) scale(1); }
}
@keyframes pop { from { transform: scale(.7); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes stamp { 0% { transform: scale(1.6); } 100% { transform: scale(1); } }
@keyframes glow { 50% { box-shadow: 0 0 0 .3rem var(--gold), 0 0 1.4rem .3rem rgba(244,182,63,.8); } }
@keyframes banner { 0% { opacity: 0; transform: translate(-50%, -50%) scale(.7); } 18% { opacity: 1; transform: translate(-50%, -50%) scale(1.04); } 28% { transform: translate(-50%, -50%) scale(1); } 78% { opacity: 1; } 100% { opacity: 0; transform: translate(-50%, -60%) scale(.96); } }
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { transform: translateY(2rem) scale(.96); opacity: 0; } }
@keyframes fall { to { transform: translateY(120vh) rotate(720deg); } }
@media (prefers-reduced-motion: reduce) { .die.rolling { animation-duration: .2s; } }
@media (min-width: 700px) {
  .sh, .row { grid-template-columns: 1fr 3.3rem 3.3rem; }
  .cell { max-height: 2.6rem; font-size: 1.3rem; }
}

/* Sync */
#tabs button { position: relative; }
.syncdot { position: absolute; top: .55rem; left: calc(50% + .7rem); width: .6rem; height: .6rem; border-radius: 50%; border: 2px solid #fff; background: var(--good); display: none; }
.syncdot.synced { display: block; background: var(--good); }
.syncdot.syncing, .syncdot.idle { display: block; background: var(--gold2); animation: pulse 1s ease-in-out infinite; }
.syncdot.offline { display: block; background: #9A95B0; }
.syncdot.error { display: block; background: var(--bad); }
.cloud { display: inline-flex; align-items: center; gap: .3rem; vertical-align: middle; margin-left: .4rem; font-family: 'Inter', sans-serif; font-size: .62rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; padding: .2rem .5rem; border-radius: 99rem; background: #EFE9DD; color: var(--muted); }
.cloud i, .sd { width: .5rem; height: .5rem; border-radius: 50%; background: var(--muted); display: inline-block; }
.cloud.synced i, .sd.synced { background: var(--good); } .cloud.syncing i, .sd.syncing, .cloud.idle i, .sd.idle { background: var(--gold2); animation: pulse 1s ease-in-out infinite; } .cloud.error i, .sd.error { background: var(--bad); }
.syncline { font-size: .98rem; display: flex; align-items: center; flex-wrap: wrap; gap: .4rem; } .syncline .sd { margin-right: .1rem; }
.codebox { font-family: 'Fraunces', serif; font-weight: 800; font-size: 1.55rem; line-height: 1.25; text-align: center; padding: 1rem .6rem; border-radius: 1rem; background: #F5F2FF; border: 2px dashed #CFC5F5; color: var(--indigo); word-break: break-word; -webkit-user-select: all; user-select: all; letter-spacing: .01em; }
@keyframes pulse { 50% { opacity: .35; } }
