:root {
  --bg: #f7f6f2;
  --surface: #ffffff;
  --surface-2: #f1efea;
  --text: #16130f;
  --muted: #6b655e;
  --faint: #9a938b;
  --line: #e4e0d8;
  --line-strong: #cfc9bf;
  --fire: #e8461a;
  --fire-ink: #c23a12;
  --fire-soft: #fdebe4;
  --danger: #c62828;
  --radius: 12px;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 17px/1.5 "Space Grotesk", system-ui, -apple-system, Segoe UI, sans-serif;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
.wrap { max-width: 760px; margin: 0 auto; padding: 24px 16px 48px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); font-size: 14px; }

.brand { font-weight: 700; font-size: 26px; letter-spacing: -1px; color: var(--text); text-decoration: none; }
.brand span { color: var(--fire); }
.top { margin-bottom: 9vh; }

.hero h1 { font-size: clamp(36px, 7vw, 64px); line-height: 1.02; letter-spacing: -2px; margin: 0 0 18px; font-weight: 700; }
.hero h1 em { font-style: normal; color: var(--fire); }
.sub { color: var(--muted); font-size: 19px; margin: 0 0 28px; max-width: 34ch; }

.roast-form { display: flex; gap: 8px; background: var(--surface); border: 1.5px solid var(--line-strong); border-radius: calc(var(--radius) + 4px); padding: 6px; }
.roast-form:focus-within { border-color: var(--text); }
.roast-form input { flex: 1; min-width: 0; background: transparent; border: 0; color: var(--text); font: inherit; font-size: 19px; padding: 12px 14px; outline: none; }
.roast-form input::placeholder { color: var(--faint); }
.hint { color: var(--muted); font-size: 14px; margin: 12px 4px 0; }
.error { color: var(--danger); margin: 14px 4px 0; }
.turnstile { margin-top: 12px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: var(--fire); color: #fff;
  border: 1.5px solid var(--fire); border-radius: var(--radius); padding: 12px 20px; font: inherit; font-weight: 700; font-size: 17px;
  cursor: pointer; text-decoration: none; white-space: nowrap; transition: background-color .15s ease, border-color .15s ease;
}
.btn:hover { background: var(--fire-ink); border-color: var(--fire-ink); }
.btn:focus-visible, .link:focus-visible, .rotd-card:focus-visible { outline: 2px solid var(--text); outline-offset: 2px; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.ghost { background: var(--surface); color: var(--text); border-color: var(--line-strong); font-weight: 500; }
.btn.ghost:hover { background: var(--surface-2); border-color: var(--text); }
.btn.hot { color: var(--fire-ink); }
.btn.hot:hover { background: var(--fire-soft); border-color: var(--fire); }
.btn.small { padding: 8px 14px; font-size: 15px; }
.link { background: none; border: 0; color: var(--muted); font: inherit; cursor: pointer; padding: 0; margin-top: 28px; }
.link:hover { color: var(--text); }

.loading { text-align: center; padding: 60px 0; }
.flame { font-size: 56px; animation: flicker 1s ease-in-out infinite alternate; }
@keyframes flicker { from { transform: scale(1) rotate(-4deg); } to { transform: scale(1.15) rotate(4deg); } }
#loading-text { color: var(--muted); }

.result { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 32px; animation: rise .3s ease-out; }
@keyframes rise { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
.eyebrow { color: var(--fire-ink); font-weight: 500; text-transform: uppercase; letter-spacing: 2px; font-size: 13px; margin: 0 0 6px; }
.nickname { font-size: clamp(28px, 5vw, 40px); letter-spacing: -1px; margin: 0 0 18px; line-height: 1.1; }
.nickname.small { font-size: 22px; font-weight: 700; margin-bottom: 6px; }
.line { border-radius: 0 8px 8px 0; font-size: clamp(21px, 3.6vw, 28px); line-height: 1.3; font-weight: 500; margin: 0; padding: 18px 0 18px 18px; border-left: 4px solid var(--fire); min-height: 3em; }
.line.harder { border-left-color: var(--danger); background: var(--fire-soft); }
.line.swap { animation: swap .3s ease-out; }
@keyframes swap { from { opacity: 0; transform: translateX(8px); } to { opacity: 1; transform: none; } }
.counter { color: var(--muted); font-size: 13px; margin: 6px 0 16px; }
.actions, .share { display: flex; flex-wrap: wrap; gap: 10px; }
.verdict-row { display: flex; gap: 20px; align-items: flex-end; justify-content: space-between; border-top: 1px solid var(--line); margin-top: 24px; padding-top: 20px; }
.verdict { margin: 0; color: var(--text); }
.score { display: flex; flex-direction: column; align-items: flex-end; flex-shrink: 0; }
.score-num { font-size: 52px; font-weight: 700; color: var(--fire); line-height: 1; }
.score-label { font-size: 11px; text-transform: uppercase; letter-spacing: 2px; color: var(--muted); }
.share { margin-top: 22px; }
.nominate { margin-top: 22px; color: var(--muted); font-size: 15px; }
.nominate summary { cursor: pointer; }
.nominate label { display: flex; gap: 8px; align-items: flex-start; margin: 12px 0; }

.rotd { margin-top: 56px; }
.rotd h3 { font-size: 14px; text-transform: uppercase; letter-spacing: 2px; color: var(--muted); margin: 0 0 12px; }
.rotd-card { display: block; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; color: var(--text); text-decoration: none; }
.rotd-card:hover { border-color: var(--text); }
.rotd-card p:last-child { margin: 0; font-size: 18px; }

.foot { margin-top: 64px; padding-top: 20px; border-top: 1px solid var(--line); color: var(--faint); font-size: 13px; }

/* share page */
.share-page, body.share .wrap { padding-top: 32px; }
body.share .brand { display: inline-block; margin-bottom: 32px; }
.roast-list { padding-left: 22px; font-size: 20px; }
.roast-list li { margin-bottom: 12px; }
.roast-list li.harder { color: var(--danger); }
.share-card { width: 100%; height: auto; border-radius: var(--radius); border: 1px solid var(--line); margin: 20px 0; }
.fineprint { color: var(--faint); font-size: 13px; margin-top: 20px; }

@media (max-width: 560px) {
  .roast-form { flex-direction: column; }
  .roast-form .btn { width: 100%; }
  .result { padding: 20px; }
  .verdict-row { flex-direction: column; align-items: flex-start; }
  .score { align-items: flex-start; }
  .actions .btn { flex: 1 1 0; padding-inline: 10px; }
  .share .btn { flex: 1 1 calc(50% - 10px); }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* language switch */
.top { display: flex; align-items: center; justify-content: space-between; }
.lang-switch { display: inline-flex; border: 1px solid var(--line-strong); border-radius: 999px; padding: 2px; background: var(--surface); }
.lang-switch button { font: inherit; font-size: 13px; font-weight: 500; letter-spacing: 1px; border: 0; background: transparent; color: var(--muted); padding: 5px 12px; border-radius: 999px; cursor: pointer; }
.lang-switch button[aria-pressed="true"] { background: var(--text); color: var(--surface); }
.lang-switch button:focus-visible { outline: 2px solid var(--fire); outline-offset: 2px; }
/* Vietnamese headlines run ~30% longer and need room for stacked diacritics. */
html[lang="vi"] .hero h1 { font-size: clamp(32px, 6vw, 54px); line-height: 1.1; }
