/* Fonts are self-hosted (OFL, see /fonts) so the strict CSP stays and no player data reaches a font CDN. */
@font-face { font-family: "Figtree"; src: url("/fonts/figtree.woff2") format("woff2"); font-weight: 300 900; font-display: swap; }
@font-face { font-family: "Bricolage"; src: url("/fonts/bricolage.woff2") format("woff2"); font-weight: 200 800; font-display: swap; }

:root {
  --bg: #f7f4ee;
  --surface: #fdfbf7;
  --raised: #efe9df;
  --raised-hover: #e7dfd2;
  --text: #1f1b16;
  --text-2: #5e554a;
  --muted: #6e655a;
  --line: rgb(31 27 22 / 9%);
  --line-strong: rgb(31 27 22 / 24%);
  --primary: #c2410c;
  --primary-hover: #9a3412;
  --on-primary: #ffffff;
  --primary-soft: rgb(194 65 12 / 10%);
  --ya: #166534;      --ya-bg: #e2efe2;
  --tidak: #a1281d;   --tidak-bg: #f7e1dc;
  --tt: #57504a;      --tt-bg: #ebe5dc;
  --mungkin: #85570b; --mungkin-bg: #f5e8cc;
  /* the playing card is a physical object: same in both themes */
  --card-back: #c2410c;
  --card-ink: #fdf3e4;
  --card-face: #fdfbf7;
  --shadow: 0 1px 2px rgb(31 27 22 / 5%);
  --shadow-object: 0 1px 2px rgb(31 27 22 / 12%), 0 16px 32px -12px rgb(31 27 22 / 35%);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --display: "Bricolage", "Figtree", system-ui, sans-serif;
  font-family: "Figtree", ui-rounded, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161513; --surface: #1c1a18; --raised: #262421; --raised-hover: #2f2c28;
    --text: #efe9de; --text-2: #aaa398; --muted: #9a9388;
    --line: rgb(239 233 222 / 8%); --line-strong: rgb(239 233 222 / 22%);
    --primary: #fb923c; --primary-hover: #fdba74; --on-primary: #1f1408; --primary-soft: rgb(251 146 60 / 12%);
    --ya: #8fd3a0; --ya-bg: #1d2b20; --tidak: #f2a397; --tidak-bg: #35201c;
    --tt: #cfc8bd; --tt-bg: #2c2926; --mungkin: #e8c26a; --mungkin-bg: #33291a;
    --card-face: #f3ece0;
    --shadow: none;
    --shadow-object: 0 1px 2px rgb(0 0 0 / 40%), 0 16px 32px -12px rgb(0 0 0 / 60%);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font-size: 16px; line-height: 1.5; min-height: 100dvh; font-variant-numeric: tabular-nums; }
a { color: var(--primary); text-underline-offset: 3px; }
h1, h2, h3 { margin: 0 0 8px; font-weight: 600; }
h1 { font-family: var(--display); font-size: 28px; line-height: 1.15; font-weight: 600; letter-spacing: -0.01em; }
h2 { font-size: 18px; line-height: 1.3; }
h3 { font-size: 16px; line-height: 1.4; }
p { margin: 0 0 12px; }
ol, ul { padding-left: 20px; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

.sr-only, .skip:not(:focus) { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip:focus { position: fixed; top: 8px; left: 8px; z-index: 10; background: var(--surface); padding: 8px 12px; border-radius: 8px; }

/* top bar */
.topbar { position: sticky; top: 0; z-index: 5; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 16px; padding: 4px 16px; background: var(--bg); border-bottom: 1px solid var(--line); }
.brand { display: inline-flex; align-items: center; gap: 12px; font-weight: 600; font-size: 17px; color: var(--text); text-decoration: none; min-height: 48px; }
.brand-mark { display: grid; place-items: center; width: 20px; height: 28px; border-radius: 4px; transform: rotate(-8deg);
  background: var(--card-back); color: var(--card-ink); box-shadow: inset 0 0 0 2px var(--card-back), inset 0 0 0 3px var(--card-ink);
  font-family: var(--display); font-weight: 600; font-size: 14px; line-height: 1; }
#nav { display: flex; flex-wrap: wrap; gap: 4px; margin-left: auto; }
#nav a, #nav button { display: inline-flex; align-items: center; min-height: 44px; padding: 0 12px; border-radius: 10px; color: var(--text-2); text-decoration: none;
  font: inherit; font-size: 15px; font-weight: 500; background: none; border: 0; cursor: pointer; transition: background-color 150ms var(--ease), color 150ms var(--ease); }
#nav a:hover, #nav button:hover { color: var(--text); background: var(--raised); }
#nav a[aria-current="page"] { color: var(--text); background: var(--raised); }

main { max-width: 720px; margin: 0 auto; padding: 24px 16px 64px; outline: none; }
main.wide { max-width: 1040px; }
main:focus-visible { outline: none; } /* focused programmatically on route change for screen readers */

.card { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 16px; box-shadow: var(--shadow); margin-bottom: 16px; }
.stack > * + * { margin-top: 12px; }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.spread { justify-content: space-between; }
.muted { color: var(--text-2); }
.small { font-size: 14px; line-height: 20px; }

/* forms */
label { display: block; font-weight: 600; font-size: 15px; margin-bottom: 4px; }
.field { margin-bottom: 16px; }
.hint { font-size: 14px; line-height: 20px; color: var(--muted); margin-top: 4px; font-weight: 400; }
input[type=text], input[type=password], input[type=url], input[type=search], input[type=date], select, textarea {
  width: 100%; font: inherit; font-size: 16px; color: var(--text); background: var(--surface); border: 1px solid var(--line-strong);
  border-radius: 10px; padding: 10px 12px; min-height: 44px; transition: border-color 150ms var(--ease), box-shadow 150ms var(--ease);
}
textarea { resize: vertical; min-height: 96px; }
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); outline: none; }
.check { display: flex; align-items: center; gap: 12px; font-weight: 500; min-height: 44px; }
.check input { width: 20px; height: 20px; accent-color: var(--primary); }
fieldset { border: 1px solid var(--line); border-radius: 16px; padding: 12px 16px 4px; margin: 0 0 16px; }
legend { font-weight: 600; padding: 0 4px; }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 20px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--raised); color: var(--text); font: inherit; font-size: 15px; font-weight: 600; cursor: pointer; text-decoration: none;
  transition: background-color 150ms var(--ease), border-color 150ms var(--ease), color 150ms var(--ease), transform 120ms var(--ease); }
.btn:hover { background: var(--raised-hover); }
.btn:active:not(:disabled) { transform: scale(0.98); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.btn.primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn.big { min-height: 52px; font-size: 17px; width: 100%; }
.btn.link { border: 0; background: none; color: var(--text-2); text-decoration: underline; text-underline-offset: 3px; padding: 0 8px; font-weight: 500; }
.btn.link:hover { color: var(--text); }
.btn.danger { color: var(--tidak); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.alert { border-radius: 12px; padding: 12px 16px; margin-bottom: 16px; border: 1px solid; }
.alert > p:last-child { margin-bottom: 0; }
.alert .btn { margin-top: 8px; }
.alert.error { background: var(--tidak-bg); color: var(--tidak); border-color: color-mix(in srgb, currentColor 30%, transparent); }
.alert.ok { background: var(--ya-bg); color: var(--ya); border-color: color-mix(in srgb, currentColor 30%, transparent); }
.alert.info { background: var(--raised); color: var(--text); border-color: var(--line); }
.secret { font-family: ui-monospace, Menlo, monospace; font-size: 17px; padding: 12px; background: var(--surface); color: var(--text); border-radius: 8px; user-select: all; word-break: break-all; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 4px 8px; border-radius: 6px; background: var(--raised); color: var(--text-2); font-size: 14px; line-height: 20px; }
.chip strong { font-weight: 600; color: var(--text); }

/* ---------- the secret card (the one rich object) ---------- */
.secret-card { --w: 168px; position: relative; flex: none; width: var(--w); aspect-ratio: 5 / 7; transform: rotate(-3deg); perspective: 900px; }
.secret-card .inner { position: absolute; inset: 0; transform-style: preserve-3d; }
.secret-card .face { position: absolute; inset: 0; border-radius: calc(var(--w) * .08); box-shadow: var(--shadow-object); backface-visibility: hidden; overflow: hidden;
  display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
.secret-card .face::before { content: ""; position: absolute; inset: calc(var(--w) * .07); border-radius: calc(var(--w) * .045); pointer-events: none; }
.secret-card .back { background-color: var(--card-back); color: var(--card-ink);
  background-image: repeating-linear-gradient(45deg, rgb(255 255 255 / 8%) 0 1.5px, transparent 1.5px 9px), repeating-linear-gradient(-45deg, rgb(0 0 0 / 8%) 0 1.5px, transparent 1.5px 9px); }
.secret-card .back::before { border: 1.5px solid rgb(253 243 228 / 75%); }
.secret-card .glyph { position: relative; font-family: var(--display); font-weight: 600; font-size: calc(var(--w) * .5); line-height: 1; }
.secret-card .back .glyph { background: var(--card-back); border-radius: 50%; width: calc(var(--w) * .56); aspect-ratio: 1; display: grid; place-items: center; box-shadow: 0 0 0 1.5px rgb(253 243 228 / 75%); }
.secret-card .idx { position: absolute; font-family: var(--display); font-weight: 600; font-size: calc(var(--w) * .1); line-height: 1; }
.secret-card .idx.tl { top: calc(var(--w) * .1); left: calc(var(--w) * .1); }
.secret-card .idx.br { bottom: calc(var(--w) * .1); right: calc(var(--w) * .1); transform: rotate(180deg); }
.secret-card .label { position: absolute; left: 0; right: 0; bottom: calc(var(--w) * .13); padding: 0 calc(var(--w) * .14); font-size: 12px; line-height: 16px; font-weight: 500; }
.secret-card .back .label { color: var(--card-ink); }
.secret-card .front { background: var(--card-face); color: #1f1b16; padding: calc(var(--w) * .16); }
.secret-card .front::before { border: 1.5px solid rgb(194 65 12 / 35%); }
.secret-card .front .idx { color: #c2410c; }
.secret-card .front .kicker { font-size: 12px; line-height: 16px; color: #6e655a; margin-bottom: 8px; }
.secret-card .front .name { font-family: var(--display); font-weight: 600; font-size: calc(var(--w) * .13); line-height: 1.1; letter-spacing: -0.01em; overflow-wrap: anywhere; }
.secret-card .front .label { color: #6e655a; }
.secret-card.reveal .back { transform: rotateY(180deg); }
.secret-card.reveal .inner { animation: flip 700ms 250ms var(--ease) both; }
@keyframes flip { from { transform: rotateY(-180deg); } to { transform: rotateY(0); } }
.secret-card.mini { --w: 40px; transform: rotate(-6deg); }
.secret-card.mini .face::before { inset: 3px; border-radius: 2px; border-width: 1px; }
.secret-card.mini .back .glyph { background: none; box-shadow: none; font-size: 20px; }

/* ---------- 20 question holes (signature) ---------- */
.pips { display: grid; grid-template-columns: repeat(20, minmax(0, 12px)); gap: 4px; margin: 0; padding: 0; }
.pips > i { display: block; aspect-ratio: 1; border-radius: 50%; box-shadow: inset 0 0 0 1.5px var(--line-strong); transition: background-color 300ms var(--ease), box-shadow 300ms var(--ease); }
.pips > i.used { background: var(--text); box-shadow: none; }
.pips-caption { font-size: 14px; line-height: 20px; color: var(--text-2); margin-top: 8px; }

/* ---------- home ---------- */
.hero { display: grid; gap: 32px; align-items: center; padding: 8px 0 32px; }
.hero h1 { font-size: 36px; line-height: 1.08; letter-spacing: -0.02em; margin-bottom: 12px; }
.hero .lead { font-size: 18px; line-height: 28px; color: var(--text-2); max-width: 30rem; margin-bottom: 24px; }
.hero .actions { display: grid; gap: 12px; }
.hero .actions .row .btn { flex: 1; }
.hero .resume { margin-top: 16px; }
.hero-card { display: flex; justify-content: center; padding: 8px 0; }
.hero-card .secret-card { --w: 176px; }

/* ---------- game ---------- */
.game { display: flex; flex-direction: column; min-height: calc(100dvh - 140px); }
.game-head { display: grid; grid-template-columns: auto 1fr; gap: 12px 16px; align-items: center; }
.game-head .meta { display: grid; gap: 8px; min-width: 0; }
.game-head .pips { grid-column: 1 / -1; grid-template-columns: repeat(20, minmax(0, 1fr)); max-width: 320px; }
.counter { font-variant-numeric: tabular-nums; font-weight: 600; font-size: 15px; color: var(--text-2); }
.counter b { font-family: var(--display); font-size: 22px; color: var(--text); font-weight: 600; }
.log { list-style: none; padding: 0; margin: 8px 0 16px; flex: 1; }
.log li { display: grid; grid-template-columns: 28px 1fr auto; gap: 8px 12px; align-items: baseline; padding: 12px 0; border-bottom: 1px solid var(--line); }
.log li.fresh { animation: rise 300ms var(--ease) both; }
.log .q { display: contents; }
.log .num { color: var(--muted); font-size: 14px; font-variant-numeric: tabular-nums; }
.answer { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: 6px; font-weight: 600; font-size: 14px; line-height: 24px; white-space: nowrap; }
.answer .ico { font-weight: 700; }
.a-ya { background: var(--ya-bg); color: var(--ya); }
.a-tidak { background: var(--tidak-bg); color: var(--tidak); }
.a-tidak_tahu { background: var(--tt-bg); color: var(--tt); }
.a-mungkin { background: var(--mungkin-bg); color: var(--mungkin); }
@media (max-width: 479px) {
  .log li { grid-template-columns: 28px 1fr; }
  .log li .answer { grid-column: 2; justify-self: start; }
}
.composer { position: sticky; bottom: 0; background: var(--bg); padding: 12px 0 calc(8px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); }
.composer textarea { min-height: 52px; }
.composer .field { margin-bottom: 8px; }
.thinking { display: flex; align-items: center; gap: 8px; color: var(--text-2); padding: 8px 0; }
.dots::after { content: "…"; animation: blink 1.2s steps(4) infinite; }
@keyframes blink { 0% { opacity: .2; } 50% { opacity: 1; } 100% { opacity: .2; } }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- result ---------- */
.result-hero { text-align: center; padding: 32px 16px 40px; }
.result-hero h1 { font-size: 32px; margin-bottom: 4px; }
.result-hero .secret-card { --w: 196px; margin: 32px auto 24px; transform: rotate(-2deg); }
.result-hero p:last-child { margin-bottom: 0; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(136px, 1fr)); gap: 8px; }
.stat { background: var(--raised); border-radius: 12px; padding: 12px 16px; }
.stat b { display: block; font-family: var(--display); font-size: 28px; line-height: 1.15; font-weight: 600; font-variant-numeric: tabular-nums; }
.stat span { display: block; margin-top: 4px; }

/* tables: horizontal scroll inside the wrapper only, never the page */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); }
table { border-collapse: collapse; width: 100%; font-size: 15px; }
th, td { text-align: left; padding: 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 13px; color: var(--muted); font-weight: 500; white-space: nowrap; background: var(--bg); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.rank { font-family: var(--display); font-weight: 600; font-size: 17px; color: var(--text-2); }
tr.me td { background: var(--primary-soft); }
tr.me td:first-child { box-shadow: inset 3px 0 0 var(--primary); color: var(--primary); }
tr.me .you { margin-left: 8px; font-size: 13px; color: var(--primary); font-weight: 600; }
tr:last-child td { border-bottom: 0; }

.list { list-style: none; padding: 0; margin: 0; }
.list > li { padding: 12px 0; border-bottom: 1px solid var(--line); }
.list > li:last-child { border-bottom: 0; }
.list > li > .row:last-child:not(:first-child) { margin-top: 8px; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 6px; font-size: 13px; line-height: 20px; font-weight: 500; background: var(--raised); color: var(--text-2); }
.badge.on, .badge.WON { background: var(--ya-bg); color: var(--ya); }
.badge.off, .badge.SURRENDERED, .badge.EXPIRED { background: var(--tt-bg); color: var(--tt); }
.badge.LOST, .badge.VOID { background: var(--tidak-bg); color: var(--tidak); }
.badge.ACTIVE { background: var(--mungkin-bg); color: var(--mungkin); }
.tabs { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }

@media (max-width: 479px) {
  #nav { gap: 0; margin-left: -8px; }
  #nav a, #nav button { padding: 0 8px; font-size: 14px; }
}
@media (min-width: 640px) {
  .grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
  main { padding-top: 40px; }
  .card { padding: 20px; }
  h1 { font-size: 32px; }
  .hero { grid-template-columns: 1fr auto; gap: 48px; padding: 24px 0 48px; }
  .hero h1 { font-size: 48px; }
  .hero .actions { max-width: 360px; }
  .hero-card { padding: 0 24px 0 0; }
  .hero-card .secret-card { --w: 208px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
