@font-face { font-family: "Cormorant Garamond"; src: url("fonts/CormorantGaramond-Medium.ttf") format("truetype"); font-weight: 500; font-display: swap; }
@font-face { font-family: "Cormorant Garamond"; src: url("fonts/CormorantGaramond-SemiBold.ttf") format("truetype"); font-weight: 600 800; font-display: swap; }
:root {
  --a: #c63f24; --b: #0e5560; --paper: #f6efe1; --paper2: #ece2cf; --ink: #231a14; --ink2: #5e5246; --line: rgba(35,26,20,.14);
  --onhalf: #fbf3e4; --gold: #a86a00; --shadow: 0 14px 34px rgba(30,15,5,.22);
  --serif: "Cormorant Garamond", Georgia, "Times New Roman", serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  --spring: cubic-bezier(.34,1.56,.64,1); --out: cubic-bezier(.2,.8,.2,1);
  color-scheme: light;
}
:root[data-theme="dark"] {
  --a: #a3321c; --b: #0b4048; --paper: #1e1915; --paper2: #2a231d; --ink: #f4ead9; --ink2: #b9ac98; --line: rgba(244,234,217,.16);
  --gold: #f0b43c; --shadow: 0 14px 34px rgba(0,0,0,.5); color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--paper); color: var(--ink); font-family: var(--sans); -webkit-font-smoothing: antialiased; }
body { overflow-x: hidden; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; touch-action: manipulation; }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
#app { height: 100dvh; min-height: 100vh; }
#fx { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 70; }

/* ---------- press feel: every button squashes and springs back */
.btn, .ib, .chip, .cell { transition: transform .38s var(--spring), background-color .2s, box-shadow .2s; }
.btn:active, .ib:active, .chip:active, .cell:active { transform: scale(.93); transition-duration: .06s; }

/* ---------- split stage: the idea of the whole game */
.stage { height: 100dvh; min-height: 100vh; display: flex; flex-direction: column; position: relative; overflow: hidden; animation: stageIn .45s var(--out); }
@keyframes stageIn { from { opacity: 0; } }
.half { position: relative; flex: 1 1 0; min-height: 0; display: flex; flex-direction: column; justify-content: center; align-items: center; padding: 0 20px; color: var(--onhalf); transition: transform .5s var(--spring), flex-grow .45s var(--out); }
.half.a { background: var(--a); justify-content: flex-end; padding-bottom: 14px; }
.half.b { background: var(--b); justify-content: flex-start; padding-top: 14px; }
.word { font-family: var(--serif); font-weight: 600; text-transform: uppercase; letter-spacing: .08em; line-height: 1; font-size: clamp(38px, 12.5vw, 84px); text-align: center; word-break: break-word; max-width: 100%; }
.word.pop { animation: wordPop .6s var(--spring); }
@keyframes wordPop { from { transform: scale(.82); opacity: 0; } }
.seam { position: relative; z-index: 3; background: var(--paper); padding: 14px 16px 16px; display: flex; flex-direction: column; align-items: center; gap: 10px; box-shadow: 0 -1px 0 rgba(0,0,0,.12), 0 1px 0 rgba(0,0,0,.12); }
.wrap { width: 100%; max-width: 520px; margin: 0 auto; }

/* ---------- top bar */
.top { position: absolute; z-index: 5; top: 0; left: 0; right: 0; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: max(10px, env(safe-area-inset-top)) 12px 0; color: var(--onhalf); pointer-events: none; }
.top > * { pointer-events: auto; }
.ib { display: inline-flex; align-items: center; gap: 6px; height: 40px; padding: 0 12px; border-radius: 12px; font-size: 14px; font-weight: 600; letter-spacing: .02em; background: rgba(255,255,255,.14); color: var(--onhalf); }
.ib svg { width: 18px; height: 18px; flex: none; }
.ib:hover { background: rgba(255,255,255,.24); }
.top .grp { display: flex; gap: 8px; }

/* ---------- home */
.home .half.a { padding-top: 64px; }
.mark { font-family: var(--serif); font-weight: 700; text-transform: uppercase; line-height: .86; letter-spacing: .04em; font-size: clamp(56px, 19vw, 118px); }
.mark.m { animation: slideDown .7s var(--spring) both; }
.mark.g { animation: slideUp .7s var(--spring) .08s both; }
@keyframes slideDown { from { transform: translateY(-40px); opacity: 0; } }
@keyframes slideUp { from { transform: translateY(40px); opacity: 0; } }
.homeseam { gap: 6px; padding-top: 18px; padding-bottom: 18px; }
.eyebrow { font-size: 13px; font-weight: 700; letter-spacing: .16em; text-transform: uppercase; color: var(--ink2); }
.tag { font-family: var(--serif); font-size: 24px; font-style: italic; font-weight: 500; color: var(--ink); margin-bottom: 8px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border-radius: 14px; font-weight: 700; font-size: 16px; letter-spacing: .02em; padding: 0 18px; height: 52px; }
.btn.primary { width: 100%; background: var(--ink); color: var(--paper); font-size: 18px; height: 58px; box-shadow: 0 4px 0 rgba(0,0,0,.28); }
.btn.primary:active { box-shadow: 0 1px 0 rgba(0,0,0,.28); }
.btn.sec { background: var(--paper2); color: var(--ink); box-shadow: inset 0 0 0 1px var(--line); }
.btn.onhalf { background: rgba(255,255,255,.16); color: var(--onhalf); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; width: 100%; }
.homebtm { padding-top: 22px; gap: 14px; justify-content: flex-start; }
.streak { font-size: 14px; font-weight: 600; letter-spacing: .04em; opacity: .9; min-height: 20px; }

/* ---------- play */
.pips { display: flex; gap: 5px; align-items: center; }
.pip { width: 22px; height: 6px; border-radius: 4px; background: rgba(255,255,255,.28); transition: background .3s, transform .4s var(--spring); }
.pip.now { background: rgba(255,255,255,.85); }
.pip.t1 { background: #d9cdb8; } .pip.t2 { background: #f1c36a; } .pip.t3 { background: #ffa845; } .pip.t4 { background: #ff6b3d; } .pip.t5 { background: #fff; box-shadow: 0 0 0 2px #f0b43c; } .pip.t0 { background: rgba(0,0,0,.35); }
.pip.bump { transform: scaleY(2.2); }
.score { font-family: var(--serif); font-weight: 700; font-size: 26px; min-width: 56px; text-align: right; padding-right: 6px; font-variant-numeric: tabular-nums; }
.timer { width: 100%; height: 6px; border-radius: 4px; background: var(--paper2); overflow: hidden; box-shadow: inset 0 0 0 1px var(--line); }
.timer i { display: block; height: 100%; width: 100%; background: var(--ink); transform-origin: left; border-radius: 4px; transition: background .3s; }
.timer.low i { background: var(--a); }
.entry { display: flex; gap: 8px; width: 100%; }
.entry input { flex: 1; min-width: 0; height: 56px; border-radius: 14px; border: 2px solid var(--ink); background: #fffdf8; color: #231a14; font-family: var(--serif); font-weight: 600; font-size: 28px; padding: 0 16px; text-align: center; outline: none; letter-spacing: .02em; transition: box-shadow .2s, transform .3s var(--spring); }
:root[data-theme="dark"] .entry input { background: #2e2620; color: #f4ead9; }
.entry input:focus { box-shadow: 0 0 0 4px color-mix(in srgb, var(--gold) 45%, transparent); }
.entry input::placeholder { color: var(--ink2); opacity: .6; font-weight: 500; font-style: italic; }
.entry .go { width: 56px; height: 56px; padding: 0; background: var(--ink); color: var(--paper); border-radius: 14px; box-shadow: 0 4px 0 rgba(0,0,0,.28); }
.entry .go svg { width: 24px; height: 24px; }
.shake { animation: shake .42s; }
@keyframes shake { 15%, 55%, 90% { transform: translateX(-9px); } 35%, 75% { transform: translateX(9px); } }
.msg { min-height: 20px; font-size: 14px; font-weight: 600; color: var(--a); text-align: center; transition: opacity .2s; }
.msg.ok { color: var(--ink2); }
.guesses { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; min-height: 0; }
.guess { font-size: 13px; padding: 3px 10px; border-radius: 999px; background: var(--paper2); color: var(--ink2); text-decoration: line-through; animation: popIn .35s var(--spring); }
@keyframes popIn { from { transform: scale(.5); opacity: 0; } }

/* the connection: a spine draws from word to word through the seam */
.spine { position: absolute; left: 50%; width: 4px; margin-left: -2px; background: var(--paper); z-index: 2; transform: scaleY(0); transform-origin: center; border-radius: 2px; pointer-events: none; }
.spine.on { animation: spineDraw .5s var(--out) forwards; }
@keyframes spineDraw { to { transform: scaleY(1); } }
.stage.joined .half.a { transform: translateY(10px); } .stage.joined .half.b { transform: translateY(-10px); }
.stage.joined .half { transition-duration: .35s; }

.resp { width: 100%; display: none; flex-direction: column; align-items: center; gap: 8px; text-align: center; }
.stage.rev .resp { display: flex; animation: respIn .55s var(--spring); }
.stage.rev .entry, .stage.rev .msg, .stage.rev .guesses, .stage.rev .timer { display: none; }
@keyframes respIn { from { opacity: 0; transform: translateY(18px) scale(.96); } }
.pill { font-family: var(--serif); font-weight: 700; font-size: 32px; line-height: 1.05; padding: 6px 20px 8px; border-radius: 999px; background: #fffdf8; color: #231a14; box-shadow: 0 0 0 3px var(--ink), var(--shadow); animation: pillPop .6s var(--spring); max-width: 100%; overflow-wrap: anywhere; }
:root[data-theme="dark"] .pill { background: #2e2620; color: #f4ead9; }
@keyframes pillPop { 0% { transform: scale(.4); } 60% { transform: scale(1.14); } 100% { transform: scale(1); } }
.tier { font-family: var(--serif); font-weight: 700; line-height: 1; text-transform: uppercase; color: var(--ink); }
.tier.t1 { font-size: 30px; font-weight: 500; color: var(--ink2); letter-spacing: .02em; }
.tier.t2 { font-size: 34px; font-weight: 600; letter-spacing: .05em; }
.tier.t3 { font-size: 40px; letter-spacing: .08em; }
.tier.t4 { font-size: 46px; letter-spacing: .1em; color: var(--a); }
.tier.t5 { font-size: 54px; letter-spacing: .12em; color: var(--gold); }
.tier.t0 { font-size: 30px; font-weight: 500; letter-spacing: .06em; color: var(--ink2); }
.pts { font-family: var(--serif); font-weight: 700; font-size: 22px; font-variant-numeric: tabular-nums; }
.meter { display: flex; gap: 4px; width: min(280px, 80%); }
.meter i { flex: 1; height: 8px; border-radius: 4px; background: var(--paper2); box-shadow: inset 0 0 0 1px var(--line); transform: scaleY(.7); transition: transform .4s var(--spring), background .3s; }
.meter i.on { background: var(--ink); transform: scaleY(1.2); }
.meter.m4 i.on, .meter.m5 i.on { background: var(--a); } .meter.m5 i.on { background: var(--gold); }
.facts { font-size: 14px; color: var(--ink2); line-height: 1.45; }
.facts b { color: var(--ink); font-weight: 700; }
.facts .rare { color: var(--ink); }
.resp .btn.primary { margin-top: 4px; }
.shakeall { animation: shakeAll .5s; }
@keyframes shakeAll { 10%, 50%, 90% { transform: translate(-5px, 2px); } 30%, 70% { transform: translate(5px, -2px); } }

/* ---------- mini loader in the seam (two dots meet) */
.mini { display: none; width: 100%; height: 56px; align-items: center; justify-content: center; position: relative; }
.stage.judging .mini { display: flex; }
.stage.judging .entry, .stage.judging .msg { display: none; }
.mini i { position: absolute; width: 16px; height: 16px; border-radius: 50%; top: 20px; }
.mini i:first-child { background: var(--a); animation: meetA 1s ease-in-out infinite; }
.mini i:nth-child(2) { background: var(--b); animation: meetB 1s ease-in-out infinite; }
@keyframes meetA { 0%, 100% { transform: translateX(-60px); } 50% { transform: translateX(-5px) scale(1.15); } }
@keyframes meetB { 0%, 100% { transform: translateX(60px); } 50% { transform: translateX(5px) scale(1.15); } }
.mini span { position: absolute; bottom: -6px; font-size: 12px; font-weight: 600; color: var(--ink2); letter-spacing: .08em; }

/* ---------- full loader: the halves pull together like a heartbeat */
#loader { position: fixed; inset: 0; z-index: 90; display: none; }
#loader.show { display: block; animation: ldFade .15s; }
@keyframes ldFade { from { opacity: 0; } }
.lh { position: absolute; left: 0; right: 0; height: 50%; }
.lh.a { top: 0; background: var(--a); animation: lA 1s var(--out) infinite; }
.lh.b { bottom: 0; background: var(--b); animation: lB 1s var(--out) infinite; }
@keyframes lA { 0% { transform: translateY(-30%); } 40% { transform: translateY(0); } 55% { transform: translateY(-4%); } 70% { transform: translateY(0); } 100% { transform: translateY(-30%); } }
@keyframes lB { 0% { transform: translateY(30%); } 40% { transform: translateY(0); } 55% { transform: translateY(4%); } 70% { transform: translateY(0); } 100% { transform: translateY(30%); } }
.lspine { position: absolute; left: 50%; top: 50%; width: 4px; height: 0; margin-left: -2px; background: var(--paper); animation: lS 1s var(--out) infinite; transform: translateY(-50%); }
@keyframes lS { 0%, 100% { height: 0; } 42% { height: 38%; } 70% { height: 38%; } }
.ltxt { position: absolute; left: 0; right: 0; top: calc(50% + 2px); text-align: center; font-family: var(--serif); font-style: italic; font-weight: 600; font-size: 24px; color: var(--onhalf); transform: translateY(12px); text-shadow: 0 1px 8px rgba(0,0,0,.35); }

/* ---------- results */
.res .half.a { padding-top: 64px; gap: 6px; }
.big { font-family: var(--serif); font-weight: 700; line-height: .9; font-size: clamp(84px, 28vw, 150px); font-variant-numeric: tabular-nums; }
.of { font-size: 16px; font-weight: 600; letter-spacing: .12em; opacity: .85; }
.rank { font-family: var(--serif); font-weight: 700; text-transform: uppercase; line-height: 1; color: var(--onhalf); margin-top: 4px; }
.rank.r0 { font-size: 30px; font-weight: 500; opacity: .85; } .rank.r1 { font-size: 36px; letter-spacing: .05em; } .rank.r2 { font-size: 44px; letter-spacing: .08em; } .rank.r3 { font-size: 52px; letter-spacing: .1em; } .rank.r4 { font-size: 60px; letter-spacing: .12em; color: #ffd37a; }
.res .seam { flex-direction: row; gap: 10px; }
.res .seam .btn { flex: 1; padding: 0 10px; height: 54px; }
.res .half.b { justify-content: flex-start; padding: 12px 14px 20px; overflow-y: auto; align-items: stretch; }
.rows { width: 100%; max-width: 520px; margin: 0 auto; display: flex; flex-direction: column; gap: 6px; }
.rrow { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: center; background: rgba(255,255,255,.1); border-radius: 12px; padding: 8px 12px; animation: rowIn .5s var(--spring) both; }
@keyframes rowIn { from { opacity: 0; transform: translateY(14px); } }
.rrow .pr { font-size: 12px; font-weight: 700; letter-spacing: .1em; opacity: .8; text-transform: uppercase; }
.rrow .an { font-family: var(--serif); font-weight: 700; font-size: 22px; line-height: 1.1; }
.rrow .tg { text-align: right; font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.rrow .tg b { display: block; font-family: var(--serif); font-size: 20px; letter-spacing: .02em; }
.next { text-align: center; font-size: 13px; opacity: .85; padding-top: 4px; }
.res .stage-wrap { height: 100%; }

/* ---------- modals */
#modal-root .ov { position: fixed; inset: 0; z-index: 80; background: rgba(20,12,6,.72); display: flex; align-items: flex-end; justify-content: center; animation: ovIn .2s; }
@keyframes ovIn { from { opacity: 0; } }
.sheet { width: 100%; max-width: 560px; max-height: 88dvh; overflow-y: auto; background: var(--paper); color: var(--ink); border-radius: 22px 22px 0 0; padding: 20px 20px max(24px, env(safe-area-inset-bottom)); box-shadow: var(--shadow); animation: sheetIn .45s var(--spring); }
@media (min-width: 700px) { #modal-root .ov { align-items: center; } .sheet { border-radius: 22px; } }
@keyframes sheetIn { from { transform: translateY(60px); opacity: 0; } }
.sheet h2 { font-family: var(--serif); font-size: 34px; font-weight: 700; margin: 0 0 10px; text-transform: uppercase; letter-spacing: .05em; }
.sheet p, .sheet li { font-size: 15px; line-height: 1.5; color: var(--ink); }
.sheet ul { padding-left: 18px; margin: 6px 0 12px; }
.sheet .x { position: absolute; }
.shead { display: flex; justify-content: space-between; align-items: flex-start; }
.close { width: 40px; height: 40px; border-radius: 12px; background: var(--paper2); display: grid; place-items: center; box-shadow: inset 0 0 0 1px var(--line); }
.close svg { width: 18px; height: 18px; }
.lad { display: grid; grid-template-columns: auto 1fr auto; gap: 4px 12px; align-items: baseline; margin: 8px 0 14px; }
.lad b { font-family: var(--serif); font-size: 24px; text-transform: uppercase; }
.lad span { color: var(--ink2); font-size: 13px; }
.lad em { font-style: normal; font-weight: 700; font-variant-numeric: tabular-nums; }
.set { display: flex; justify-content: space-between; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--line); font-weight: 600; }
.tog { width: 52px; height: 30px; border-radius: 16px; background: var(--paper2); box-shadow: inset 0 0 0 1px var(--line); position: relative; transition: background .25s; }
.tog::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: var(--paper); box-shadow: 0 1px 4px rgba(0,0,0,.35); transition: transform .35s var(--spring); }
.tog[aria-checked="true"] { background: var(--ink); } .tog[aria-checked="true"]::after { transform: translateX(22px); }
.seg { display: flex; gap: 6px; } .seg button { padding: 8px 14px; border-radius: 10px; background: var(--paper2); font-weight: 700; font-size: 14px; box-shadow: inset 0 0 0 1px var(--line); } .seg button[aria-pressed="true"] { background: var(--ink); color: var(--paper); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(58px, 1fr)); gap: 8px; margin-top: 10px; }
.cell { height: 58px; border-radius: 12px; background: var(--paper2); box-shadow: inset 0 0 0 1px var(--line); display: flex; flex-direction: column; align-items: center; justify-content: center; font-weight: 700; font-size: 15px; line-height: 1.1; }
.cell small { font-size: 11px; font-weight: 600; color: var(--ink2); }
.cell.done { background: var(--b); color: var(--onhalf); } .cell.done small { color: var(--onhalf); opacity: .85; }
.cell.today { box-shadow: inset 0 0 0 2px var(--a); }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 8px 0 14px; text-align: center; }
.stats div { background: var(--paper2); border-radius: 14px; padding: 12px 4px; } .stats b { display: block; font-family: var(--serif); font-size: 32px; line-height: 1; } .stats span { font-size: 12px; color: var(--ink2); font-weight: 600; letter-spacing: .06em; text-transform: uppercase; }
.bars div { display: grid; grid-template-columns: 110px 1fr 30px; gap: 8px; align-items: center; font-size: 13px; font-weight: 600; margin: 5px 0; } .bars i { display: block; height: 10px; border-radius: 5px; background: var(--ink); min-width: 2px; transition: width .6s var(--out); }
.toast { position: fixed; left: 50%; bottom: 40px; transform: translateX(-50%); z-index: 95; background: var(--ink); color: var(--paper); padding: 10px 18px; border-radius: 12px; font-weight: 700; animation: popIn .35s var(--spring); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
  .lh, .lspine, .mini i { animation: none !important; }
}

/* half-right feedback + hint */
.half.glow { animation: halfGlow 1.8s ease-out; }
@keyframes halfGlow { 0% { filter: brightness(1); } 18% { filter: brightness(1.45) saturate(1.3); box-shadow: inset 0 0 60px rgba(255,255,255,.55); } 100% { filter: brightness(1); box-shadow: inset 0 0 0 rgba(255,255,255,0); } }
.hint { min-height: 0; font-size: 13px; font-style: italic; color: var(--ink2); text-align: center; opacity: 0; max-height: 0; transition: opacity .4s, max-height .3s; }
.hint.on { opacity: 1; max-height: 40px; margin-top: 2px; }
.stage.rev .hint, .stage.judging .hint { display: none; }
