:root {
  --ink: #2f3431;
  --deep: #526b5d;
  --paper: #f7f5f1;
  --surface: #ffffff;
  --line: #e5e1dc;
  --muted: #777b77;
  --lime: #f2d77b;
  --lime-soft: #fff6d6;
  --orange: #e99a86;
  --blue: #8fb8d8;
  --shadow: 0 8px 24px rgba(60, 54, 48, .07);
  --radius: 18px;
  font-family: "Manrope", system-ui, sans-serif;
  color: var(--ink);
  background: var(--paper);
  font-synthesis: none;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--paper); }
body { margin: 0; min-height: 100%; background: var(--paper); }
button, input { font: inherit; }
button { color: inherit; }
button, [role="button"] { -webkit-tap-highlight-color: transparent; }
button:focus-visible, input:focus-visible { outline: 3px solid rgba(97, 168, 255, .6); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

.app-shell { min-height: 100svh; max-width: 680px; margin: 0 auto; background: var(--paper); padding-bottom: calc(88px + env(safe-area-inset-bottom)); }
.topbar { height: 72px; display: flex; align-items: center; justify-content: space-between; padding: 12px 20px; }
.brand { display: flex; align-items: center; gap: 11px; padding: 0; border: 0; background: transparent; text-align: left; cursor: pointer; }
.brand-mark { display: grid; place-items: center; width: 38px; height: 38px; background: #dfeadf; color: #446052; border-radius: 12px; font-weight: 800; }
.brand strong, .brand small { display: block; line-height: 1.05; }
.brand strong { font-size: 15px; letter-spacing: -.02em; }
.brand small { margin-top: 4px; color: var(--muted); font-size: 9px; font-weight: 600; letter-spacing: .03em; }
.icon-button { width: 40px; height: 40px; border: 1px solid var(--line); border-radius: 12px; background: #fff; cursor: pointer; }
.icon-button[aria-pressed="false"] { color: #a8aaa5; text-decoration: line-through; }

main { padding: 16px 18px 20px; }
.view { display: none; animation: rise .35s ease both; }
.view.active { display: block; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }
.eyebrow { display: flex; align-items: center; gap: 8px; color: #657069; font-size: 11px; font-weight: 700; letter-spacing: .02em; }
.eyebrow span { display: block; width: 7px; height: 7px; border-radius: 50%; background: var(--orange); }
h1 { margin: 14px 0 10px; max-width: 560px; font-size: clamp(34px, 9vw, 52px); line-height: 1.06; letter-spacing: -.045em; }
h1 em { color: var(--muted); font-style: normal; font-weight: 600; }
.lede { max-width: 520px; margin: 0 0 26px; color: #6f746f; font-size: 15px; line-height: 1.55; }

.panel { margin: 0 0 12px; padding: 19px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: 0 3px 14px rgba(60,54,48,.035); }
.section-heading, .section-heading > div { display: flex; align-items: center; }
.section-heading { justify-content: space-between; gap: 12px; margin-bottom: 17px; }
.section-heading > div { gap: 10px; }
.section-heading h2 { margin: 0; font-size: 16px; letter-spacing: -.025em; }
.step-number { color: #a5a6a2; font-size: 10px; font-weight: 700; }
.count-pill { padding: 5px 9px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); font-size: 10px; font-weight: 700; }
.add-player { display: grid; grid-template-columns: 1fr 49px; gap: 8px; }
.add-player input { width: 100%; height: 49px; padding: 0 15px; border: 1px solid var(--line); border-radius: 13px; background: #fff; color: var(--ink); font-size: 16px; }
.add-player input::placeholder { color: #a3a69f; }
.square-button { border: 0; border-radius: 13px; background: var(--deep); color: #fff; font-size: 23px; cursor: pointer; transition: transform .15s ease; }
.square-button:active { transform: scale(.94); }
.player-list { display: flex; flex-wrap: wrap; gap: 8px; min-height: 51px; margin-top: 14px; padding-top: 13px; border-top: 1px solid var(--line); }
.player-list.empty { align-items: center; justify-content: center; }
.empty-copy { margin: 0; color: #a2a59f; font-size: 12px; }
.player-chip { display: inline-flex; align-items: center; gap: 8px; min-height: 38px; padding: 5px 7px 5px 12px; border-radius: 999px; background: #e8e8de; font-size: 13px; font-weight: 700; animation: pop .2s ease both; }
@keyframes pop { from { transform: scale(.85); opacity: 0; } }
.player-chip button { display: grid; place-items: center; width: 27px; height: 27px; padding: 0; border: 0; border-radius: 50%; background: rgba(255,255,255,.6); color: #777c77; cursor: pointer; }

.compact-panel { padding-bottom: 18px; }
.choice-group { margin: 0; padding: 0; border: 0; }
.choice-group + .choice-group { margin-top: 19px; }
.choice-group legend { margin-bottom: 9px; color: var(--muted); font-size: 10px; font-weight: 700; }
.segmented { display: grid; grid-template-columns: repeat(3, 1fr); padding: 4px; border-radius: 13px; background: #e5e5dc; }
.segmented button { min-height: 40px; padding: 6px 4px; border: 0; border-radius: 10px; background: transparent; color: #737a74; font-size: 11px; font-weight: 700; cursor: pointer; }
.segmented button.selected { background: var(--surface); color: var(--ink); box-shadow: 0 2px 8px rgba(20,30,25,.08); }
.game-modes { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.game-modes button { display: grid; grid-template-columns: 34px 1fr; align-items: center; gap: 9px; min-height: 66px; padding: 9px 10px; border: 1px solid var(--line); border-radius: 13px; background: #fff; color: var(--ink); text-align: left; cursor: pointer; }
.game-modes button > span:first-child { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; background: #f4f2ee; font-size: 18px; }
.game-modes button strong, .game-modes button small { display: block; }
.game-modes button strong { font-size: 11px; line-height: 1.2; }
.game-modes button small { margin-top: 3px; color: var(--muted); font-size: 8px; line-height: 1.25; }
.game-modes button.selected { border-color: #789183; background: #edf3ee; box-shadow: 0 0 0 1px #789183 inset; }
.game-modes button.selected > span:first-child { background: #dfeadf; }
.round-options { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.round-options button { min-height: 64px; border: 1px solid var(--line); border-radius: 13px; background: transparent; cursor: pointer; }
.round-options strong, .round-options span { display: block; }
.round-options strong { font-size: 18px; }
.round-options span { margin-top: 2px; color: var(--muted); font-size: 9px; text-transform: uppercase; letter-spacing: .08em; }
.round-options button.selected { border-color: var(--deep); background: var(--deep); color: #fff; }
.round-options button.selected span { color: var(--lime); }
.primary-button { display: flex; align-items: center; justify-content: space-between; width: 100%; min-height: 58px; padding: 0 19px; border: 0; border-radius: 14px; background: var(--deep); color: #fff; box-shadow: none; font-weight: 800; cursor: pointer; transition: transform .15s, background .15s; }
.primary-button:active:not(:disabled) { transform: scale(.985); box-shadow: none; }
.primary-button:disabled { background: #deddd9; color: #9b9e98; box-shadow: none; cursor: not-allowed; }
.primary-button > span:last-child { font-size: 22px; }
.button-hint { margin: 13px 0 0; color: var(--muted); text-align: center; font-size: 11px; }

.bottom-nav { position: fixed; left: 50%; bottom: 0; z-index: 20; display: grid; grid-template-columns: 1fr 1fr; width: min(680px, 100%); height: calc(72px + env(safe-area-inset-bottom)); padding: 8px 18px calc(8px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: rgba(255,255,255,.94); backdrop-filter: blur(18px); transform: translateX(-50%); }
.bottom-nav button { position: relative; display: flex; align-items: center; justify-content: center; gap: 8px; border: 0; background: transparent; color: #90958f; cursor: pointer; }
.bottom-nav button span { font-size: 19px; }
.bottom-nav button strong { font-size: 11px; }
.bottom-nav button.active { color: var(--deep); }
.bottom-nav button.active::after { content: ""; position: absolute; bottom: 0; width: 18px; height: 3px; border-radius: 9px; background: var(--orange); }

/* game */
.game-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 17px; }
.back-button { padding: 8px 0; border: 0; background: transparent; color: var(--muted); font-size: 12px; font-weight: 700; cursor: pointer; }
.round-label { font: 500 10px/1 "DM Mono", monospace; text-transform: uppercase; letter-spacing: .1em; }
.progress-track { height: 4px; margin-bottom: 28px; border-radius: 10px; background: #dbdcd4; overflow: hidden; }
.progress-track > span { display: block; height: 100%; background: var(--orange); transition: width .4s ease; }
.question-card { position: relative; min-height: 230px; padding: 24px 21px; border-radius: 20px; background: var(--deep); color: #fff; overflow: hidden; }
.question-card::after { content: none; }
.question-kicker { position: relative; z-index: 1; display: flex; align-items: center; justify-content: space-between; color: #abb5ae; font: 500 10px/1 "DM Mono", monospace; text-transform: uppercase; letter-spacing: .1em; }
.flag { font-size: 25px; filter: saturate(.9); }
.question-card h2 { position: relative; z-index: 1; max-width: 540px; margin: 35px 0 10px; font-size: clamp(27px, 7.5vw, 42px); line-height: 1.08; letter-spacing: -.045em; }
.question-card h2 em { color: #ffe7a2; font-style: normal; }
.question-card p { position: relative; z-index: 1; margin: 0; color: #9fa9a3; font-size: 12px; }
.turn-panel { margin-top: 10px; padding: 20px; border-radius: 18px; background: var(--surface); border: 1px solid var(--line); }
.turn-who { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.turn-who p { margin: 0; color: var(--muted); font-size: 11px; }
.turn-who strong { font-size: 18px; }
.guess-count { color: var(--muted); font: 500 10px/1 "DM Mono", monospace; }
.guess-form { display: grid; grid-template-columns: 1fr 53px; gap: 8px; }
.guess-form input { min-width: 0; height: 56px; padding: 0 15px; border: 1px solid var(--line); border-radius: 14px; background: #fff; font: 500 18px/1 "DM Mono", monospace; }
.guess-form button { border: 0; border-radius: 14px; background: var(--lime); font-size: 22px; font-weight: 800; cursor: pointer; }
.input-help { margin: 9px 0 0; color: #969b96; font-size: 10px; }
.guess-dots { display: flex; gap: 6px; margin-top: 15px; }
.guess-dots span { height: 5px; flex: 1; border-radius: 9px; background: #dcded6; }
.guess-dots span.done { background: var(--deep); }
.ready-panel { margin-top: 17px; padding: 20px; border-radius: 20px; background: var(--lime-soft); text-align: center; }
.ready-panel strong { display: block; margin-bottom: 5px; font-size: 20px; }
.ready-panel p { margin: 0 0 17px; color: #566049; font-size: 12px; }
.ready-panel .primary-button { background: var(--deep); color: #fff; box-shadow: none; }

.reveal-number { margin: 25px 0 8px; color: #ffe7a2; font: 700 clamp(34px, 9vw, 54px)/1 Manrope, sans-serif; font-variant-numeric: tabular-nums; letter-spacing: -.045em; }
.reveal-number small { display: block; margin-top: 9px; color: #dce5df; font-size: 13px; font-weight: 700; letter-spacing: 0; }
.answer-label { color: #aeb8b2; font-size: 11px; }
.ranking { margin-top: 20px; }
.ranking-head { display: flex; justify-content: space-between; align-items: end; margin-bottom: 11px; }
.ranking-head h3 { margin: 0; font-size: 17px; }
.ranking-head span { color: var(--muted); font-size: 10px; }
.rank-row { display: grid; grid-template-columns: 31px 1fr auto; align-items: center; gap: 10px; min-height: 67px; margin-bottom: 8px; padding: 9px 13px; border: 1px solid var(--line); border-radius: 15px; background: var(--surface); animation: slideIn .35s ease both; animation-delay: calc(var(--i) * 70ms); }
@keyframes slideIn { from { opacity: 0; transform: translateX(12px); } }
.rank-row:first-of-type { border-color: #bfdf39; background: var(--lime-soft); }
.rank-position { font: 500 13px/1 "DM Mono", monospace; }
.rank-person strong, .rank-person span { display: block; }
.rank-person strong { font-size: 13px; }
.rank-person span { margin-top: 3px; color: var(--muted); font: 400 10px/1 "DM Mono", monospace; }
.rank-score { text-align: right; }
.rank-score strong, .rank-score span { display: block; }
.rank-score strong { font: 500 13px/1 "DM Mono", monospace; }
.rank-score span { margin-top: 4px; color: var(--muted); font-size: 9px; }
.continue-button { margin-top: 16px; }

.final-hero { padding: 31px 22px; border-radius: 20px; background: var(--deep); color: #fff; text-align: center; }
.trophy { display: grid; place-items: center; width: 68px; height: 68px; margin: 0 auto 19px; border-radius: 18px; background: #ffe7a2; color: var(--deep); font-size: 31px; }
.final-hero .eyebrow { justify-content: center; color: #9da8a1; }
.final-hero h1 { margin: 17px 0 10px; font-size: 40px; }
.final-hero h1 em { color: #ffe7a2; }
.final-hero p { margin: 0; color: #aab3ae; font-size: 12px; }
.scoreboard { margin: 14px 0; padding: 8px; border: 1px solid var(--line); border-radius: 20px; background: var(--surface); }
.scoreboard .rank-row { margin: 0; border: 0; border-radius: 13px; background: transparent; }
.scoreboard .rank-row:first-child { background: var(--lime-soft); }
.final-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.secondary-button { min-height: 56px; border: 1px solid var(--line); border-radius: 15px; background: var(--surface); font-size: 12px; font-weight: 800; cursor: pointer; }

/* explorer */
.explore-hero h1 { font-size: clamp(34px, 9vw, 50px); }
.search-wrap { position: sticky; top: 8px; z-index: 8; display: grid; grid-template-columns: 26px 1fr 30px; align-items: center; min-height: 56px; padding: 0 13px; border: 1px solid var(--line); border-radius: 14px; background: rgba(255,255,255,.97); box-shadow: 0 5px 18px rgba(60,54,48,.06); backdrop-filter: blur(14px); }
.search-wrap > span { color: var(--muted); font-size: 22px; }
.search-wrap input { min-width: 0; height: 56px; border: 0; outline: 0; background: transparent; font-size: 15px; }
.search-wrap button { border: 0; background: transparent; color: var(--muted); font-size: 21px; cursor: pointer; }
.filter-row { display: flex; gap: 7px; margin: 17px 0 12px; overflow-x: auto; scrollbar-width: none; }
.filter-row button { flex: 0 0 auto; min-height: 37px; padding: 0 15px; border: 1px solid var(--line); border-radius: 999px; background: transparent; color: var(--muted); font-size: 11px; font-weight: 700; cursor: pointer; }
.filter-row button.selected { border-color: var(--deep); background: var(--deep); color: #fff; }
.alphabet { display: flex; gap: 6px; margin: 0 -18px; padding: 0 18px 12px; overflow-x: auto; scrollbar-width: none; }
.alphabet button { flex: 0 0 auto; width: 33px; height: 33px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--muted); font-size: 10px; font-weight: 700; cursor: pointer; }
.alphabet button:first-child { width: auto; padding: 0 12px; }
.alphabet button.selected { border-color: var(--orange); background: #fff0ec; color: #b84632; }
.results-meta { display: flex; justify-content: space-between; align-items: center; margin: 13px 0 10px; }
.results-meta p { margin: 0; color: var(--muted); font-size: 11px; }
.results-meta p strong { color: var(--ink); }
.results-meta button { border: 0; background: transparent; font-size: 11px; font-weight: 800; cursor: pointer; }
.place-card { display: grid; grid-template-columns: 36px minmax(0, 1fr) minmax(98px, auto); align-items: center; gap: 10px; min-height: 68px; margin-bottom: 7px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
.place-rank { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; background: #f1efeb; color: #858984; font-size: 10px; font-weight: 700; }
.place-info { min-width: 0; }
.place-info strong, .place-info span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.place-info strong { font-size: 13px; }
.place-info span { margin-top: 4px; color: var(--muted); font-size: 10px; }
.place-value { text-align: right; }
.place-value strong, .place-value span { display: block; }
.place-value strong { font-size: 13px; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.place-value span { margin-top: 5px; color: var(--muted); font-size: 9px; }
.no-results { padding: 45px 20px; border: 1px dashed #c8cac3; border-radius: 18px; color: var(--muted); text-align: center; font-size: 13px; }
.data-note { margin: 17px 4px 0; color: #999d98; font-size: 9px; line-height: 1.5; }
.toast { position: fixed; left: 50%; bottom: calc(86px + env(safe-area-inset-bottom)); z-index: 40; max-width: calc(100% - 32px); padding: 11px 16px; border-radius: 999px; background: var(--deep); color: #fff; box-shadow: var(--shadow); font-size: 11px; font-weight: 700; opacity: 0; pointer-events: none; transform: translate(-50%, 10px); transition: .25s ease; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (min-width: 620px) {
  body { padding: 20px 0; background: #ebe7e1; }
  .app-shell { min-height: calc(100svh - 40px); border-radius: 28px; box-shadow: 0 30px 90px rgba(19,28,24,.16); overflow: hidden; }
  main { padding-inline: 38px; }
  .topbar { padding-inline: 38px; }
  .bottom-nav { bottom: 20px; width: 680px; border-radius: 0 0 28px 28px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
