:root {
  --ground: #EEF2F3;
  --card: #FFFFFF;
  --ink: #1B2328;
  --muted: #4C5960;
  --line: #C5CED3;
  --soft: #DCE3E6;
  --accent: #F2B630;
  --brown: #7A4A2A;
  --t-bad: #E86A5C;
  --t-low: #F29E5C;
  --t-medium: #F3D35B;
  --t-high: #A6D98A;
  --t-veryhigh: #4FB98A;
  --display: "Bricolage Grotesque", system-ui, sans-serif;
  --body: "DM Sans", system-ui, sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { background: var(--ground); }
body {
  margin: 0;
  min-height: 100dvh;
  background: var(--ground);
  color: var(--ink);
  font-family: var(--body);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--ink); }
a:hover { color: #5A3A22; }
img { display: block; }

.page {
  max-width: 440px;
  min-height: 100dvh;
  margin: 0 auto;
  padding: 18px 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.page.dark { background: var(--ink); color: #FFFFFF; max-width: none; }
.page.dark > * { width: 100%; max-width: 400px; margin-left: auto; margin-right: auto; }

/* Header + logo */
.top { display: flex; align-items: center; justify-content: space-between; min-height: 44px; }
.top .link { font-size: 15px; font-weight: 700; padding: 12px 4px; text-decoration: none; }
.logo { display: flex; align-items: center; gap: 6px; text-decoration: none; font-family: var(--display); font-weight: 800; font-size: 25px; letter-spacing: -0.8px; color: var(--ink); }
.logo svg { transform: rotate(-8deg); }
.logo .a { display: inline-block; margin: 0 2px; padding: 0 6px; border-radius: 8px; background: var(--accent); transform: rotate(-8deg); line-height: 1.15; }
.wordmark { font-family: var(--display); font-weight: 800; font-size: 22px; letter-spacing: -0.5px; text-decoration: none; }

/* Type */
h1, h2 { font-family: var(--display); font-weight: 800; margin: 0; }
h1 { font-size: 40px; line-height: 1.02; letter-spacing: -1.2px; }
h1.xl { font-size: 48px; line-height: 0.98; letter-spacing: -1.6px; }
.lede { margin: 0; font-size: 17px; line-height: 1.45; color: var(--muted); }
.page.dark .lede { color: #C9D3D8; }
.small { font-size: 13px; color: var(--muted); margin: 0; }
.center { text-align: center; }
.hl { display: inline-block; margin-top: 4px; padding: 0 10px 4px; border-radius: 12px; background: var(--accent); transform: rotate(-2deg); }

/* Buttons */
.btn {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 56px; padding: 0 18px; border: 0; border-radius: 16px;
  background: var(--ink); color: #FFFFFF; font: inherit; font-size: 18px; font-weight: 700;
  text-decoration: none; cursor: pointer;
  transition: transform .12s ease, opacity .2s ease;
}
.btn:hover { color: #FFFFFF; transform: translateY(-2px); }
.btn:active { transform: scale(.97); }
.btn.ghost { background: transparent; color: var(--ink); border: 2px solid var(--ink); min-height: 52px; font-size: 17px; }
.btn.accent { background: var(--accent); color: var(--ink); }
.btn[disabled], .btn.off { opacity: .45; pointer-events: none; }
.textbtn { all: unset; cursor: pointer; font-size: 15px; font-weight: 700; padding: 12px 0; white-space: nowrap; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; }
.row.tight > * { flex: none; }
.push { margin-top: auto; }

/* Inputs */
label.field { display: flex; flex-direction: column; gap: 6px; font-size: 14px; font-weight: 700; }
.input {
  height: 52px; width: 100%; border-radius: 12px; border: 1.5px solid var(--line); background: #FFFFFF;
  padding: 0 14px; font: inherit; font-size: 16px; color: var(--ink);
  transition: border-color .15s, box-shadow .15s;
}
.input::placeholder { color: #7A868D; }
.input:focus { outline: none; border-color: var(--ink); box-shadow: 0 0 0 4px rgba(242, 182, 48, .45); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.ts-slot:empty { display: none; }
.ts-slot { display: flex; justify-content: center; }
.error { margin: 0; font-size: 14px; font-weight: 700; color: #B23A2E; }

/* Cards & chips */
.card { border-radius: 20px; background: var(--card); padding: 16px; }
.chip { display: inline-block; border-radius: 999px; padding: 5px 10px; font-size: 13px; font-weight: 700; background: var(--ink); color: #FFFFFF; }
.score-pill { font-family: var(--display); font-weight: 800; border-radius: 10px; padding: 4px 8px; }
.portrait { border-radius: 14px; flex-shrink: 0; background: var(--soft); }

/* Animations */
@keyframes pop { 0% { transform: scale(.4) rotate(-12deg); opacity: 0 } 70% { transform: scale(1.08) rotate(4deg); opacity: 1 } 100% { transform: none } }
@keyframes rise { from { transform: translateY(12px); opacity: 0 } to { transform: none; opacity: 1 } }
@keyframes bob { 0%, 100% { transform: translateY(0) rotate(10deg) } 50% { transform: translateY(-4px) rotate(6deg) } }
@keyframes spin { to { transform: rotate(360deg) } }
@keyframes scan { 0%, 100% { top: 8% } 50% { top: 86% } }
@keyframes burst { 0% { transform: translate(0, 0) scale(.4); opacity: 0 } 30% { opacity: 1 } 100% { transform: translate(var(--dx), var(--dy)) scale(1) rotate(160deg); opacity: 0 } }
.pop { animation: pop .5s cubic-bezier(.2, .9, .3, 1.2) both; }
.rise { animation: rise .45s ease both; }
.bob { animation: bob 2.6s ease-in-out infinite; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* Landing */
.landing { position: relative; overflow: hidden; }
.landing > :not(.floaty) { position: relative; }
.floaty { position: absolute; right: 18px; pointer-events: none; opacity: .95; }
.floaty img { border-radius: 12px; }
.floaty.a { top: 104px; animation: float-a 5.2s ease-in-out infinite; }
.floaty.b { top: 232px; right: 30px; animation: float-b 6.4s ease-in-out infinite; }
.floaty.c { top: 600px; right: 26px; animation: float-c 4.6s ease-in-out infinite; }
@keyframes float-a { 0%, 100% { transform: translate(0, 0) rotate(-6deg) } 50% { transform: translate(-6px, -10px) rotate(4deg) } }
@keyframes float-b { 0%, 100% { transform: translate(0, 0) rotate(8deg) } 50% { transform: translate(5px, -8px) rotate(-3deg) } }
@keyframes float-c { 0%, 100% { transform: translate(0, 0) rotate(-3deg) } 50% { transform: translate(-4px, 9px) rotate(6deg) } }
@keyframes wiggle { 0%, 86%, 100% { transform: rotate(-2deg) } 89% { transform: rotate(3deg) } 92% { transform: rotate(-4deg) } 95% { transform: rotate(2deg) } }
.wiggle { animation: wiggle 4s ease-in-out infinite; }
.carousel { position: relative; height: 112px; margin-top: 22px; }
.carousel .slide { position: absolute; inset: 0; text-decoration: none; color: var(--ink); opacity: 0; transform: translateY(10px); pointer-events: none; transition: opacity .5s ease, transform .5s ease; }
.carousel .slide.on { opacity: 1; transform: none; pointer-events: auto; }
.carousel .mascot { position: absolute; right: 14px; top: -46px; z-index: 1; border-radius: 16px; }
.carousel .card { display: flex; align-items: center; gap: 14px; padding: 14px 16px; transform: rotate(-1.5deg); }
.carousel .badge { flex: none; border-radius: 14px; padding: 10px 12px; display: flex; flex-direction: column; align-items: center; }
.carousel .badge b { font-family: var(--display); font-size: 24px; line-height: 1; }
.carousel .badge span { font-size: 11px; font-weight: 700; white-space: nowrap; }
.carousel .nm { font-size: 16px; }
.carousel .rq { line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.dots { display: flex; justify-content: center; gap: 6px; }
.dots i { width: 8px; height: 8px; border-radius: 4px; background: var(--line); transition: width .3s ease, background .3s ease; }
.dots i.on { width: 22px; background: var(--ink); }
.steps { margin: 4px 0 0; padding: 0; list-style: none; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.steps li { display: flex; flex-direction: column; gap: 6px; font-size: 14px; font-weight: 700; line-height: 1.3; }
.steps li span { width: 32px; height: 32px; border-radius: 50%; background: var(--ink); color: #FFFFFF; display: flex; align-items: center; justify-content: center; }

/* Centered state screens */
.state { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; text-align: center; }
.state .icon { width: 112px; height: 112px; border-radius: 32px; background: var(--accent); display: flex; align-items: center; justify-content: center; }
.confetti { position: relative; width: 140px; height: 140px; display: flex; align-items: center; justify-content: center; }
.confetti i { position: absolute; left: 50%; top: 50%; width: 10px; height: 10px; border-radius: 3px; animation: burst 1.1s ease-out .25s both; }

/* Drop */
.drop-zone {
  all: unset; cursor: pointer; box-sizing: border-box; height: 220px; border-radius: 20px; border: 2px dashed #9AA7AE; background: #FFFFFF;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; text-align: center;
  transition: transform .15s ease, border-color .15s ease;
}
.drop-zone:hover { transform: scale(1.01); border-color: var(--ink); }
.drop-zone .cam { width: 60px; height: 60px; border-radius: 50%; background: var(--ink); color: #FFFFFF; display: flex; align-items: center; justify-content: center; }
.picked { position: relative; height: 220px; border-radius: 20px; overflow: hidden; background: var(--soft); }
.picked img { width: 100%; height: 100%; object-fit: cover; filter: blur(18px) saturate(.6); transform: scale(1.15); }
.picked .tag { position: absolute; left: 12px; top: 12px; display: flex; align-items: center; gap: 6px; border-radius: 999px; background: var(--t-veryhigh); padding: 6px 12px; font-size: 13px; font-weight: 700; }
.picked .retake { position: absolute; right: 12px; bottom: 12px; height: 40px; border: 0; border-radius: 999px; background: var(--ink); color: #FFFFFF; padding: 0 16px; font: inherit; font-size: 14px; font-weight: 700; cursor: pointer; }
.name-row { display: flex; gap: 8px; }
.name-row .input { flex: 1; min-width: 0; }
.name-row .btn { min-height: 52px; font-size: 14px; border-radius: 12px; padding: 0 14px; flex: none; }

/* Judging */
.page.dark > .judge-box, .judge-box { position: relative; width: 240px; height: 240px; margin: 0 auto; border-radius: 28px; border: 4px solid var(--accent); overflow: hidden; background: #33404A; }
.judge-box img.preview { width: 100%; height: 100%; object-fit: cover; filter: blur(22px) saturate(.5); transform: scale(1.2); }
.judge-box img.art { position: absolute; inset: 0; width: 100%; height: 100%; animation: rise .5s ease both; }
.judge-box .scanline { position: absolute; left: 0; right: 0; height: 4px; background: var(--accent); box-shadow: 0 0 18px var(--accent); animation: scan 2.2s ease-in-out infinite; }
.checklist { border-radius: 18px; background: #26333A; padding: 18px 20px; display: flex; flex-direction: column; gap: 14px; }
.checklist div { display: flex; align-items: center; gap: 12px; font-size: 16px; color: #9AA7AE; }
.checklist div.active { color: #FFFFFF; font-weight: 700; }
.checklist div.done { color: #FFFFFF; }
.checklist i { width: 26px; height: 26px; border-radius: 50%; border: 2px solid #55626A; flex: none; display: flex; align-items: center; justify-content: center; }
.checklist .active i { border: 3px solid var(--accent); border-right-color: transparent; animation: spin .8s linear infinite; }
.checklist .done i { border: 0; background: #7CC6A4; color: var(--ink); }

/* Result */
.result-head { display: flex; gap: 14px; align-items: center; }
.eyebrow { font-size: 13px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .8px; }
.score-card { border-radius: 18px; padding: 14px 18px; display: flex; flex-direction: column; gap: 12px; }
.score-card .big { font-family: var(--display); font-weight: 800; font-size: 56px; line-height: 1; letter-spacing: -1.5px; }
.tiers { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 4px; }
.tiers div { display: flex; flex-direction: column; gap: 4px; font-size: 10px; font-weight: 700; }
.tiers div i { height: 8px; border-radius: 4px; border: 1.5px solid var(--ink); }
.tiers div.on i { background: var(--ink) !important; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.stat { border-radius: 14px; background: var(--ground); padding: 10px 12px; }
.stat small { display: block; font-size: 12px; color: var(--muted); }
.stat b { font-size: 17px; }
.roast { border-radius: 20px; background: var(--ink); color: #FFFFFF; padding: 16px 18px; }
.roast span { font-size: 13px; font-weight: 700; color: var(--accent); text-transform: uppercase; letter-spacing: .8px; }
.roast p { margin: 6px 0 0; font-size: 16px; line-height: 1.45; }

/* Score math */
.math { display: flex; flex-direction: column; gap: 14px; }
.math-toggle { all: unset; cursor: pointer; display: flex; align-items: center; justify-content: space-between; gap: 12px; font-family: var(--display); font-weight: 800; font-size: 22px; letter-spacing: -.5px; }
.math-toggle i { font-style: normal; width: 32px; height: 32px; flex: none; border-radius: 50%; background: var(--ground); display: flex; align-items: center; justify-content: center; font-family: var(--body); font-size: 18px; }
.math-step { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16px; }
.math-step span { width: 26px; height: 26px; flex: none; border-radius: 50%; background: var(--ink); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 13px; }
.math-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px 10px; align-items: center; font-size: 14px; }
.math-row small { font-weight: 500; color: var(--muted); font-size: 14px; }
.math-bar { grid-column: 1 / -1; display: flex; align-items: center; gap: 8px; }
.math-bar > div { flex: 1; height: 10px; border-radius: 5px; background: var(--ground); overflow: hidden; }
.math-bar i { display: block; height: 100%; border-radius: 5px; background: var(--ink); transform-origin: left; animation: grow .7s cubic-bezier(.2, .8, .2, 1) both; }
.math-bar small { width: 34px; text-align: right; font-size: 12px; font-weight: 700; }
.math-mood { display: flex; justify-content: space-between; font-size: 14px; color: var(--muted); }
.math-total { display: flex; align-items: baseline; justify-content: space-between; border-top: 2px dashed var(--soft); padding-top: 12px; font-weight: 700; }
.math-total b { font-family: var(--display); font-size: 30px; }
.math-total small { font-size: 15px; color: var(--muted); }
.curve { position: relative; padding-top: 6px; }
.curve svg { display: block; overflow: visible; font-family: var(--body); }
.curve .pin-drop { animation: rise .5s ease .6s both; }
.curve-pin { position: absolute; top: -16px; width: 30px; height: 30px; margin-left: -15px; border-radius: 8px; animation: rise .5s ease .6s both; }
.math-line { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; font-size: 15px; }
.math-line small { font-weight: 500; color: var(--muted); font-size: 14px; }
.math-lines { display: flex; flex-direction: column; gap: 8px; font-size: 14px; }
.math-lines div { display: flex; justify-content: space-between; gap: 12px; }
.math-lines span { color: var(--muted); }
.math-lines div:nth-child(4) { border-top: 2px dashed var(--soft); padding-top: 8px; }
.math-beats { margin: 0; border-radius: 16px; background: #FFF6D6; padding: 12px 14px; font-size: 15px; line-height: 1.45; }
.math-final { display: flex; align-items: center; justify-content: space-between; border-radius: 16px; background: var(--ink); color: #fff; padding: 12px 16px; font-weight: 700; }
.math-final b { font-family: var(--display); font-size: 26px; }
@keyframes grow { from { transform: scaleX(0) } to { transform: scaleX(1) } }

/* Leaderboard & lists */
.tabs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; border-radius: 14px; background: var(--soft); padding: 4px; }
.tabs button { all: unset; cursor: pointer; text-align: center; height: 40px; border-radius: 10px; font-size: 15px; font-weight: 700; color: var(--muted); }
.tabs button[aria-selected="true"] { background: #FFFFFF; color: var(--ink); }
.podium { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; align-items: end; }
.podium > a { text-decoration: none; }
.podium > * { display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; border-radius: 18px; padding: 10px 8px 12px; }
.podium .name { font-size: 13px; font-weight: 700; line-height: 1.2; overflow-wrap: anywhere; }
.podium .place { font-size: 12px; font-weight: 700; color: var(--muted); }
.list { border-radius: 18px; background: #FFFFFF; overflow: hidden; }
.list > div, .list > a { text-decoration: none; display: flex; align-items: center; gap: 12px; padding: 0 14px; min-height: 58px; border-bottom: 1px solid #E4E9EB; }
.list > :last-child { border-bottom: 0; }
.tap { transition: transform .12s ease; }
.tap:hover { transform: translateY(-2px); color: var(--ink); }
.tap:active { transform: scale(.98); }
.list .rank { width: 28px; font-size: 15px; font-weight: 700; color: var(--muted); }
.list .who { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.list .who b { font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list .who small { font-size: 12px; color: var(--muted); }
.empty { padding: 24px; text-align: center; color: var(--muted); font-size: 15px; }
.stats3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.stats3 div { border-radius: 16px; background: #FFFFFF; padding: 12px; }
.stats3 small { display: block; font-size: 12px; font-weight: 700; color: var(--muted); }
.stats3 b { font-family: var(--display); font-size: 22px; }
.bars { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; align-items: end; height: 84px; }
.bars div { display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 11px; color: var(--muted); }
.bars i { width: 100%; border-radius: 6px; background: #9AA7AE; }
.bars i.good { background: var(--ink); }
.prose { font-size: 15px; line-height: 1.6; }
.prose h2 { font-size: 22px; margin-top: 18px; }
