/* Terka — brahmana.id palette. One ground (paper), one ink, blue fields, orange accent. */
:root {
  --paper: #f8f5ec;
  --paper-2: #efe9da;
  --white: #ffffff;
  --ink: #102c49;
  --ink-2: #4a5f78;
  --blue: #2467b5;
  --blue-2: #1d5aa0;
  --blue-dark: #123c63;
  --orange: #f28a2e;
  --orange-dark: #c96a17;
  --orange-light: #ffa64d;
  --good: #1f8a4c;
  --bad: #c8373a;
  --meh: #d99a00;
  --r-card: 24px;
  --sans: "DM Sans", Arial, sans-serif;
  --ease: cubic-bezier(.2, .8, .2, 1);
  --pop: cubic-bezier(.34, 1.56, .64, 1);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--paper); color: var(--ink); font-family: var(--sans);
  font-size: 17px; line-height: 1.5; -webkit-font-smoothing: antialiased;
  font-variant-numeric: tabular-nums; min-height: 100vh;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; }
a { color: var(--blue); text-underline-offset: 3px; }
[hidden] { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 3px solid var(--orange); outline-offset: 3px; }

/* ---------- bar ---------- */
.bar { display: flex; align-items: center; justify-content: space-between; max-width: 520px; margin: 0 auto; padding: 14px 16px 6px; }
.logo { font-weight: 900; font-size: 28px; letter-spacing: -0.04em; color: var(--blue); text-decoration: none; }
.logo span { color: var(--orange); }
.bar-right { display: flex; align-items: center; gap: 8px; }
.bank { display: inline-flex; align-items: center; gap: 6px; background: var(--white); border-radius: 999px; padding: 6px 14px 6px 8px; font-weight: 800; font-size: 17px; }
.bank.bump { animation: bump .5s var(--pop); }
.coin { width: 20px; height: 20px; fill: var(--orange); }
.coin .coin-in { fill: var(--orange-light); }
.round { width: 40px; height: 40px; border-radius: 50%; border: 0; background: var(--white); font-weight: 800; font-size: 18px; display: inline-grid; place-items: center; transition: transform .12s var(--ease), background .15s; }
.round:hover { background: var(--paper-2); }
.round:active { transform: scale(.92); }

main { max-width: 520px; margin: 0 auto; padding: 6px 16px 56px; }
.screen { display: grid; gap: 14px; }

/* ---------- cards ---------- */
.card { border-radius: var(--r-card); padding: 22px 20px; position: relative; overflow: hidden; }
.card-blue { background: var(--blue); color: var(--white); }
.card-paper, .card-white { background: var(--white); color: var(--ink); }
.skeleton { min-height: 420px; display: grid; place-items: center; font-weight: 700; }
.skeleton p { animation: breathe 1.4s ease-in-out infinite; }
.meta { margin: 0; font-weight: 700; font-size: 15px; }
.small { margin: 12px 0 0; font-size: 14px; opacity: .85; text-align: center; }

/* ---------- buttons ---------- */
.btn {
  display: block; width: 100%; border: 0; border-radius: 999px; padding: 16px 20px;
  font-weight: 900; font-size: 19px; letter-spacing: -0.01em;
  transition: transform .1s var(--ease), border-bottom-width .1s var(--ease), margin-top .1s var(--ease), filter .15s;
}
.btn-orange { background: var(--orange); color: var(--ink); border-bottom: 5px solid var(--orange-dark); }
.btn-white { background: var(--white); color: var(--blue); border-bottom: 5px solid #c9d8ec; }
.btn:hover { filter: brightness(1.04); }
.btn:active { transform: translateY(3px); border-bottom-width: 2px; margin-top: 3px; }
.btn:disabled { opacity: .55; cursor: default; transform: none; }

/* ---------- intro ---------- */
.hero { padding: 26px 22px 22px; min-height: 520px; display: flex; flex-direction: column; }
.hero h1 { position: relative; font-size: clamp(42px, 12vw, 58px); line-height: .95; font-weight: 900; letter-spacing: -0.045em; margin: 14px 0 16px; max-width: 13ch; }
.o { color: var(--orange); }
.lead { position: relative; margin: 0 0 18px; font-size: 17px; max-width: 34ch; }
.radar { position: absolute; right: -86px; top: -70px; width: 240px; height: 240px; pointer-events: none; }
@media (min-width: 560px) { .radar { right: -40px; top: 30px; width: 260px; height: 260px; } }
.radar circle { fill: none; stroke: rgba(255,255,255,.28); stroke-width: 1.2; }
.radar .radar-core { fill: var(--orange); stroke: none; opacity: .9; }
.radar line { stroke: rgba(255,255,255,.4); stroke-width: 1.2; }
.radar .radar-dot { fill: var(--white); animation: blink 2.4s steps(2) infinite; }
.today { list-style: none; padding: 0; margin: auto 0 18px; display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.today li { background: var(--blue-2); border-radius: 12px; padding: 10px 4px 8px; text-align: center; font-size: 12px; font-weight: 700; line-height: 1.2; }
.today li svg { width: 22px; height: 22px; display: block; margin: 0 auto 6px; fill: none; stroke: var(--white); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.how { padding: 18px 4px 0; }
.how h2 { font-size: 28px; font-weight: 900; letter-spacing: -0.03em; margin: 0 0 10px; }
.how-row { display: grid; grid-template-columns: 96px 1fr; gap: 14px; align-items: center; padding: 12px 0; }
.how-row h3 { margin: 0 0 2px; font-size: 18px; font-weight: 800; }
.how-row p { margin: 0; font-size: 16px; }
.how-pic { height: 80px; border-radius: 16px; background: var(--white); display: flex; align-items: center; justify-content: center; gap: 3px; }
.num-demo { font-weight: 900; font-size: 22px; color: var(--blue); }
.num-demo small { font-size: 13px; color: var(--ink-2); }
.chip-demo { background: var(--paper-2); border-radius: 999px; padding: 3px 6px; font-size: 11px; font-weight: 800; }
.chip-demo.on { background: var(--ink); color: var(--white); }
.mini-target { width: 66px; height: 66px; }
.t5 { fill: #dbe6f4; } .t3 { fill: #9fc0e6; } .t1 { fill: var(--blue); } .tdot { fill: var(--orange); }

/* ---------- play card ---------- */
.play { padding: 18px 18px 18px; }
.play-top { display: flex; justify-content: space-between; font-size: 14px; font-weight: 700; opacity: .9; }
.play-top.ink { color: var(--ink-2); opacity: 1; }
.timer { height: 8px; border-radius: 99px; background: var(--blue-dark); margin-top: 10px; overflow: hidden; }
.timer-fill { height: 100%; width: 100%; background: var(--white); border-radius: 99px; transform-origin: left; transition: background .3s; }
.timer-fill.hot { background: var(--orange); }
.timer-text { font-size: 13px; margin: 6px 0 0; opacity: .9; min-height: 20px; }
.qtext { font-size: clamp(23px, 6.4vw, 30px); line-height: 1.18; font-weight: 800; letter-spacing: -0.02em; margin: 12px 0 18px; }

.field { display: flex; align-items: center; gap: 10px; background: var(--white); color: var(--ink); border-radius: 18px; padding: 4px 16px; border-bottom: 4px solid #c9d8ec; }
.field:focus-within { border-bottom-color: var(--orange); }
#guessInput { flex: 1; min-width: 0; border: 0; outline: 0; font-size: 30px; font-weight: 900; letter-spacing: -0.02em; padding: 10px 0; background: transparent; }
#guessInput::placeholder { color: #a9b6c6; font-weight: 700; }
.field-unit { color: var(--ink-2); font-weight: 700; font-size: 15px; text-align: right; max-width: 42%; line-height: 1.2; }
.field.shake { animation: shake .35s; }
.units { display: flex; gap: 6px; margin-top: 10px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.units::-webkit-scrollbar { display: none; }
.units button { flex: none; border: 0; border-radius: 999px; padding: 7px 13px; font-size: 14px; font-weight: 800; background: var(--blue-2); color: var(--white); transition: transform .1s, background .15s; }
.units button:active { transform: scale(.94); }
.units button.on { background: var(--white); color: var(--blue); }
.preview { font-size: 15px; font-weight: 700; margin: 8px 2px 0; min-height: 23px; color: #dbe6f4; }
.preview.warn { color: var(--orange-light); }

.stake { background: var(--blue-dark); border-radius: 18px; padding: 14px 14px 12px; margin: 14px 0 16px; }
.stake-head { display: flex; align-items: center; justify-content: space-between; font-weight: 800; }
.stepper { display: flex; align-items: center; gap: 10px; }
.round-ink { background: var(--blue-2); color: var(--white); width: 36px; height: 36px; }
.round-ink:hover { background: var(--blue); }
.stake-val { font-size: 26px; font-weight: 900; min-width: 64px; text-align: center; letter-spacing: -0.02em; }
input[type=range] { -webkit-appearance: none; appearance: none; width: 100%; height: 30px; background: transparent; margin: 8px 0 4px; }
/* hard-stop fill of the slider track: two flat colours, not a gradient. taste-skill-ignore */
input[type=range]::-webkit-slider-runnable-track { height: 10px; border-radius: 99px; background: linear-gradient(to right, var(--orange) var(--fill, 25%), rgba(255,255,255,.18) var(--fill, 25%)); } /* taste-skill-ignore */
input[type=range]::-moz-range-track { height: 10px; border-radius: 99px; background: rgba(255,255,255,.18); }
input[type=range]::-moz-range-progress { height: 10px; border-radius: 99px; background: var(--orange); }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 28px; height: 28px; border-radius: 50%; background: var(--white); border: 5px solid var(--orange); margin-top: -9px; }
input[type=range]::-moz-range-thumb { width: 18px; height: 18px; border-radius: 50%; background: var(--white); border: 5px solid var(--orange); }
.quick { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.quick button { border: 0; border-radius: 999px; padding: 8px 0; font-weight: 800; font-size: 14px; background: var(--blue-2); color: var(--white); transition: transform .1s, background .15s; }
.quick button:active { transform: scale(.94); }
.quick button.on { background: var(--white); color: var(--blue-dark); }
.odds { margin: 10px 2px 0; font-size: 14px; color: #dbe6f4; }
.odds b { color: var(--white); }

/* ---------- reveal ---------- */
.result { padding: 18px 18px 18px; }
.rv-q { font-weight: 700; font-size: 17px; margin: 8px 0 4px; }
.target-wrap { display: grid; place-items: center; margin: 4px 0; }
.target { width: min(78vw, 300px); height: auto; overflow: visible; }
.target .ring { transition: opacity .3s; }
.target text { font-family: var(--sans); font-size: 8.5px; font-weight: 700; fill: var(--ink-2); }
.target .ring-label { fill: var(--blue-dark); }
.target .side { font-size: 10px; font-weight: 800; fill: var(--ink-2); }
.target .shot { transform-box: fill-box; transform-origin: center; animation: land .6s var(--pop) both .15s; }
.target .shot-trail { stroke: var(--orange); stroke-width: 2; stroke-dasharray: 3 4; fill: none; opacity: .8; }
.rv-off { text-align: center; font-weight: 900; font-size: 22px; line-height: 1.15; letter-spacing: -0.02em; margin: 4px 0 12px; }
.rv-nums { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.rv-nums div { background: var(--paper); border-radius: 16px; padding: 10px 14px; }
.rv-nums span { display: block; font-size: 13px; font-weight: 700; color: var(--ink-2); }
.rv-nums b { display: block; font-size: 20px; line-height: 1.2; font-weight: 900; letter-spacing: -0.01em; word-break: break-word; }
.rv-nums div:first-child b { color: var(--blue); }
.rv-delta { text-align: center; font-size: 52px; font-weight: 900; letter-spacing: -0.04em; margin: 12px 0 0; line-height: 1; }
.rv-delta.up { color: var(--good); } .rv-delta.down { color: var(--bad); } .rv-delta.flat { color: var(--ink-2); }
.rv-calc { text-align: center; font-size: 14px; color: var(--ink-2); margin: 6px 0 0; }
.rv-crowd { text-align: center; font-weight: 800; font-size: 15px; margin: 10px auto 0; background: var(--paper); border-radius: 999px; padding: 6px 14px; width: fit-content; }
.rv-crowd:empty { display: none; }
.rv-source { background: var(--paper); border-radius: 16px; padding: 12px 14px; margin: 14px 0 16px; font-size: 15px; }
.rv-source p { margin: 0; }
.rv-source p + p { margin-top: 6px; }
.src { color: var(--ink-2); font-size: 14px; }
.reveal-in > * { animation: rise .45s var(--ease) both; }
.reveal-in > *:nth-child(2) { animation-delay: .04s; } .reveal-in > *:nth-child(3) { animation-delay: .08s; }
.reveal-in > *:nth-child(4) { animation-delay: .5s; } .reveal-in > *:nth-child(5) { animation-delay: .58s; }
.reveal-in > *:nth-child(6) { animation-delay: .66s; } .reveal-in > *:nth-child(7) { animation-delay: .72s; }
.reveal-in > *:nth-child(8) { animation-delay: .78s; } .reveal-in > *:nth-child(9) { animation-delay: .84s; } .reveal-in > *:nth-child(10) { animation-delay: .9s; }

/* ---------- end ---------- */
.score { text-align: center; padding: 24px 20px 20px; }
.end-title { font-size: clamp(30px, 8vw, 38px); line-height: 1.02; font-weight: 900; letter-spacing: -0.035em; margin: 6px 0 8px; }
.score-num { margin: 0; font-size: 72px; font-weight: 900; letter-spacing: -0.05em; line-height: 1; }
.score-num small { font-size: 22px; letter-spacing: 0; margin-left: 6px; opacity: .9; }
.score-pct { margin: 6px 0 14px; font-weight: 800; color: var(--orange-light); font-size: 18px; }
.tiles { display: flex; justify-content: center; gap: 8px; margin-bottom: 12px; }
.tile { width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center; font-weight: 900; font-size: 13px; color: var(--white); animation: flip .45s var(--pop) both; }
.tile.up { background: var(--good); } .tile.meh { background: var(--meh); color: var(--ink); } .tile.down { background: var(--bad); }
.tile.timeout { background: var(--blue-dark); } .tile.skip { background: var(--blue-2); color: #9fc0e6; }
.rank { margin: 0 0 16px; font-weight: 700; color: #dbe6f4; min-height: 24px; }
.toast { margin: 10px 0 0; font-weight: 800; }
.sec { font-size: 22px; font-weight: 900; letter-spacing: -0.02em; margin: 0 0 12px; }
.histo { display: grid; grid-template-columns: repeat(8, 1fr); gap: 6px; align-items: stretch; height: 150px; }
.histo .col { display: grid; grid-template-rows: auto 1fr auto; justify-items: center; gap: 4px; min-height: 0; }
.histo .well { width: 100%; display: flex; align-items: flex-end; min-height: 0; }
.histo .bar-v { width: 100%; background: #c9d8ec; border-radius: 8px 8px 3px 3px; min-height: 4px; transform-origin: bottom; animation: grow .6s var(--ease) both; }
.histo .col.me .bar-v { background: var(--orange); }
.histo .n { font-size: 12px; font-weight: 700; color: var(--ink-2); }
.histo .lbl { font-size: 11px; font-weight: 700; color: var(--ink-2); white-space: nowrap; }
.histo .col.me .lbl { color: var(--ink); }
.histo-note { margin: 10px 0 0; font-size: 14px; color: var(--ink-2); }
.recap { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.recap li { display: grid; grid-template-columns: 12px 1fr auto; gap: 12px; align-items: start; background: var(--paper); border-radius: 16px; padding: 12px 14px; }
.recap .dot { width: 12px; height: 12px; border-radius: 4px; margin-top: 6px; }
.recap .dot.up { background: var(--good); } .recap .dot.meh { background: var(--meh); } .recap .dot.down { background: var(--bad); } .recap .dot.timeout { background: var(--blue-dark); }
.recap p { margin: 0; font-size: 15px; font-weight: 600; line-height: 1.35; }
.recap .ans { display: block; font-weight: 800; color: var(--blue); margin-top: 2px; }
.recap b { font-size: 17px; white-space: nowrap; }
.recap b.up { color: var(--good); } .recap b.down { color: var(--bad); }
.next { text-align: center; margin: 8px 0 0; font-weight: 700; color: var(--ink-2); }
.next b { color: var(--ink); font-size: 18px; }

/* ---------- dialog ---------- */
dialog { border: 0; border-radius: 24px; padding: 24px 22px; width: min(480px, calc(100% - 28px)); max-height: calc(100% - 40px); color: var(--ink); background: var(--paper); }
dialog::backdrop { background: rgba(16, 44, 73, .6); }
dialog[open] { animation: rise .3s var(--ease); }
dialog h2 { margin: 0 0 8px; font-size: 30px; font-weight: 900; letter-spacing: -0.03em; }
dialog p { margin: 0 0 12px; }
.pay { width: 100%; border-collapse: collapse; margin: 4px 0 14px; font-size: 15px; background: var(--white); border-radius: 14px; overflow: hidden; }
.pay th, .pay td { text-align: left; padding: 8px 12px; }
.pay th { background: var(--blue); color: var(--white); font-weight: 800; }
.pay tr:nth-child(1) td:last-child { color: var(--good); font-weight: 800; }
.pay tr:nth-child(6) td:last-child { color: var(--bad); font-weight: 800; }
.pay tbody tr + tr td { border-top: 1px solid var(--paper-2); }

/* ---------- motion ---------- */
.enter { animation: rise .4s var(--ease) both; }
@keyframes rise { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: none; } }
@keyframes land { 0% { transform: scale(3); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }
@keyframes flip { from { transform: rotateX(90deg); } to { transform: none; } }
@keyframes grow { from { transform: scaleY(0); } to { transform: none; } }
@keyframes bump { 50% { transform: scale(1.15); } }
@keyframes shake { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }
@keyframes blink { 50% { opacity: .2; } }
@keyframes breathe { 50% { opacity: .45; } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-delay: 0ms !important; transition-duration: .01ms !important; }
}

@media (min-width: 700px) {
  body { font-size: 18px; }
  .bar { padding-top: 22px; }
  main { padding-top: 12px; }
}
