:root {
  color-scheme: light;
  --cream: #fffbed;
  --paper: rgba(255, 255, 255, 0.88);
  --ink: #07132f;
  --muted: #6c7080;
  --red: #f51720;
  --deep-red: #c41018;
  --blue: #0861c6;
  --green: #02aa55;
  --yellow: #ffc313;
  --line: rgba(7, 19, 47, 0.12);
  --shadow: 0 22px 60px rgba(7, 19, 47, 0.12);
  font-family: ui-rounded, "SF Pro Rounded", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--cream);
  color: var(--ink);
}

* { box-sizing: border-box; }
html { scrollbar-gutter: stable; }
body { margin: 0; min-height: 100vh; min-height: 100dvh; overflow-x: hidden; }
button, input, select { font: inherit; }
input[type="number"], select { width: 100%; min-height: 48px; border: 2px solid var(--line); border-radius: 12px; padding: 9px; color: var(--ink); background: white; }
.rules-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.rules-summary { padding: 14px; border-radius: 16px; background: rgba(8,97,198,.07); font-size: .9rem; }
.rules-summary summary { color: var(--blue); font-weight: 800; cursor: pointer; }
.chip small, .public-game small { display:block; margin-top:6px; color:var(--muted); font-weight:500; }
.out-badge { color:var(--deep-red); font-size:.8rem; }
.score-table { overflow-x:auto; }
.score-table table { width:100%; border-collapse:collapse; font-size:.88rem; }
.score-table th, .score-table td { padding:12px 8px; text-align:left; border-bottom:1px solid var(--line); }
button { cursor: pointer; }
.orb { position: fixed; z-index: -1; border-radius: 50%; pointer-events: none; }
.orb-top { width: min(70vw, 720px); height: min(70vw, 720px); right: -22vw; top: -24vw; background: rgba(255, 195, 19, .22); }
.orb-bottom { width: min(56vw, 560px); height: min(56vw, 560px); left: -24vw; bottom: -24vw; background: rgba(8, 97, 198, .08); }

#app { width: min(100%, 760px); margin: 0 auto; padding: max(22px, env(safe-area-inset-top)) 20px max(34px, env(safe-area-inset-bottom)); }
.shell { min-height: calc(100dvh - 56px); display: flex; flex-direction: column; gap: 22px; }
.brand { display: flex; align-items: center; justify-content: center; gap: 12px; }
.brand img { width: 52px; height: 52px; border-radius: 14px; box-shadow: 0 9px 22px rgba(7,19,47,.16); }
.brand strong { font-size: 1.28rem; letter-spacing: .04em; }
.hero { text-align: center; padding: 18px 0 2px; }
.hero img { width: 150px; height: 150px; border-radius: 34px; box-shadow: var(--shadow); }
.eyebrow { display: inline-flex; padding: 8px 15px; border-radius: 999px; color: var(--red); background: rgba(255,195,19,.25); font-size: .76rem; font-weight: 900; letter-spacing: .18em; }
h1 { margin: 18px 0 4px; font-size: clamp(2.3rem, 10vw, 4.4rem); line-height: .96; letter-spacing: -.05em; }
h2 { margin: 0; font-size: clamp(1.55rem, 6vw, 2.25rem); letter-spacing: -.025em; }
h3 { margin: 0; }
p { line-height: 1.45; }
.subhead { margin: 10px auto 0; color: var(--muted); font-weight: 650; max-width: 530px; }

.card { background: var(--paper); border: 1px solid rgba(255,255,255,.8); border-radius: 28px; box-shadow: var(--shadow); padding: clamp(18px, 5vw, 30px); backdrop-filter: blur(18px); }
.stack { display: grid; gap: 16px; }
.row { display: flex; align-items: center; gap: 12px; }
.spread { justify-content: space-between; }
.grow { flex: 1; }
.muted { color: var(--muted); }
.center { text-align: center; }
.hidden { display: none !important; }

.field { display: grid; gap: 7px; }
.field label { font-size: .78rem; font-weight: 900; letter-spacing: .1em; color: var(--muted); }
input[type="text"] { width: 100%; min-height: 54px; border: 2px solid var(--line); border-radius: 17px; padding: 0 16px; background: white; color: var(--ink); outline: none; }
input[type="text"]:focus { border-color: var(--blue); box-shadow: 0 0 0 4px rgba(8,97,198,.1); }

.segmented { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; background: rgba(7,19,47,.06); padding: 5px; border-radius: 16px; }
.score-target-picker { grid-template-columns: repeat(3, 1fr); }
.segmented button { border: 0; border-radius: 12px; padding: 12px; background: transparent; color: var(--muted); font-weight: 850; }
.segmented button.active { background: white; color: var(--blue); box-shadow: 0 4px 14px rgba(7,19,47,.08); }

.primary, .secondary, .danger, .ghost { width: 100%; min-height: 56px; border-radius: 18px; padding: 12px 18px; border: 0; font-weight: 950; letter-spacing: .025em; transition: transform .14s ease, filter .14s ease; }
.primary { color: white; background: var(--red); box-shadow: 0 12px 26px rgba(245,23,32,.24); }
.primary.green { background: var(--green); box-shadow: 0 12px 26px rgba(2,170,85,.2); }
.secondary { color: var(--blue); background: white; border: 2px solid rgba(8,97,198,.24); }
.danger { color: white; background: var(--deep-red); }
.ghost { min-height: 44px; color: var(--blue); background: transparent; width: auto; }
button:hover { filter: brightness(.98); }
button:active { transform: scale(.985); }
button:disabled { opacity: .45; cursor: not-allowed; box-shadow: none; }

.toggle-row { display: flex; align-items: center; gap: 10px; padding: 13px 15px; background: rgba(8,97,198,.06); border-radius: 16px; font-weight: 800; }
.toggle-row input { width: 21px; height: 21px; accent-color: var(--blue); }
.category-toolbar { display: grid; gap: 10px; }
.category-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(145px, 1fr)); gap: 9px; max-height: 295px; overflow: auto; padding: 3px; }
.chip { min-height: 45px; border: 1.5px solid var(--line); border-radius: 15px; padding: 9px 11px; text-align: left; background: white; color: var(--ink); font-size: .88rem; font-weight: 750; }
.chip.selected { border-color: var(--blue); background: rgba(8,97,198,.09); color: var(--blue); }
.full-page-categories { max-height: none; overflow: visible; }
.chip.featured { border-color: var(--blue); border-width: 2px; }
.chip.selected { border-color: #e39a18; }
.chip .new-category { color: var(--blue); font-size: .65rem; font-weight: 700; }

.invite { display: grid; gap: 14px; padding: 20px; border-radius: 22px; background: linear-gradient(135deg, rgba(255,195,19,.26), rgba(255,255,255,.8)); text-align: center; }
.code { display: block; margin: 8px 0 2px; color: var(--blue); font-size: clamp(2.2rem, 12vw, 4.2rem); font-weight: 950; letter-spacing: .13em; }
.players { display: grid; gap: 9px; }
.player { display: flex; align-items: center; justify-content: space-between; padding: 13px 15px; border-radius: 16px; background: rgba(7,19,47,.045); font-weight: 800; }
.player.current { outline: 2px solid var(--yellow); background: rgba(255,195,19,.12); }
.avatar { display: grid; place-items: center; width: 36px; height: 36px; margin-right: 10px; border-radius: 50%; color: white; background: var(--blue); }
.score { font-size: 1.35rem; color: var(--blue); }
.rule-banner { display: flex; justify-content: space-between; gap: 12px; padding: 13px 15px; border-radius: 16px; color: var(--blue); background: rgba(8,97,198,.07); }
.rule-banner span { color: var(--muted); text-align: right; }
.finished { align-content: center; min-height: min(680px, 74dvh); }
.finished h1 { margin-top: 2px; }
.trophy { font-size: 5rem; text-align: center; filter: drop-shadow(0 12px 18px rgba(255,195,19,.28)); }

.waiting { padding: 24px; text-align: center; }
.waiting-dot { width: 14px; height: 14px; margin: 0 auto 15px; border-radius: 50%; background: var(--yellow); box-shadow: -22px 0 var(--red), 22px 0 var(--blue); animation: pulse 1.2s infinite ease-in-out; }
@keyframes pulse { 50% { transform: scale(1.25); opacity: .6; } }

.turn { text-align: center; overflow: hidden; }
.shell:has(.answer-composer) { padding-bottom: 190px; }
.answer-composer { position: fixed; z-index: 10; left: 20px; right: 20px; margin-inline: auto; max-width: 720px; bottom: max(12px, calc(100% - var(--viewport-bottom, 100dvh) + 12px)); padding: 12px; gap: 12px; background: #fff; border-radius: 22px; box-shadow: 0 0 18px rgba(7,19,47,.12); }
.answer-composer input[type="text"] { border: 2px solid var(--blue); font-size: 1.15rem; }
.answer-composer #answerHint { color: var(--red); }
.answer-feedback { font-weight: 800; color: var(--blue); }
.close-game { color: var(--blue); background: white; border: 2px solid var(--blue); }
.timer { position: relative; display: grid; place-items: center; width: 178px; height: 178px; margin: 14px auto; border-radius: 50%; background: conic-gradient(var(--green) var(--progress, 100%), rgba(7,19,47,.08) 0); }
.timer::after { content: ""; position: absolute; inset: 13px; border-radius: 50%; background: var(--cream); }
.timer span { position: relative; z-index: 1; font-size: 4rem; font-weight: 950; color: var(--green); }
.prompt { margin: 4px auto 18px; max-width: 470px; font-size: clamp(1.45rem, 6vw, 2rem); font-weight: 950; text-transform: uppercase; }
.compact-turn .shell:has(.answer-composer) > .brand { display: none; }
.compact-turn .turn { grid-template-columns: 64px 1fr; gap: 10px; padding: 12px; align-items: center; }
.compact-turn .turn .timer { width: 64px; height: 64px; margin: 0; grid-row: span 2; }
.compact-turn .turn .timer::after { inset: 5px; }
.compact-turn .turn .timer span { font-size: 1.8rem; }
.compact-turn .turn .eyebrow { font-size: .62rem; letter-spacing: .04em; padding: 5px; }
.compact-turn .turn .prompt { font-size: 1rem; margin: 0; }
.compact-turn .turn > .notice, .compact-turn .turn > button { grid-column: 1 / -1; }
.review { border: 2px solid rgba(245,23,32,.26); background: rgba(245,23,32,.06); }
.review-answer { font-size: 1.65rem; font-weight: 950; }
.notice { padding: 12px 15px; border-radius: 14px; background: rgba(8,97,198,.08); color: var(--blue); font-weight: 750; text-align: center; }
.game-rules { text-align: left; font-weight: 400; color: var(--ink); line-height: 1.5; }
.game-rules h3 { font-size: 1rem; font-weight: 700; margin: 0 0 12px; color: var(--blue); }
.rule-items { padding-left: 1.25em; margin: 14px 0 20px; }
.rule-items li { margin: 8px 0; padding-left: 4px; }
.rule-categories { display: flex; flex-wrap: wrap; gap: 8px; list-style: none; padding: 0; margin: 10px 0; }
.rule-categories li { background: rgba(255,255,255,.85); border: 1px solid rgba(8,97,198,.12); border-radius: 12px; padding: 6px 10px; font-size: .9rem; }
.more-categories summary { color: var(--blue); cursor: pointer; font-weight: 400; font-size: .9rem; }
.error { background: rgba(245,23,32,.09); color: var(--deep-red); }
.footer-note { margin-top: auto; padding-top: 10px; color: var(--muted); font-size: .8rem; text-align: center; }
.voice-help { font-size: .85rem; margin: 0; }
#voiceStatus { min-height: 48px; overflow-wrap: anywhere; }
.setup-shell { padding-top: 12px; gap: 26px; }
.setup-card { gap: 24px; }
.setup-card .field label, .setup-card .field-heading { font-size: 1rem; font-weight: 750; letter-spacing: 0; color: var(--ink); }
.setup-card .field { gap: 12px; }
.player-name-input { padding: 12px 16px; border: 1px solid rgba(7,19,47,.15); border-radius: 16px; background: rgba(255,255,255,.94); }
.player-name-input label { display: block; font-size: .65rem; font-weight: 650; letter-spacing: .08em; color: var(--muted); margin-bottom: 7px; }
.player-name-input > div { display: flex; gap: 12px; align-items: center; }
.player-color { width: 14px; height: 14px; border-radius: 50%; background: var(--blue); flex: 0 0 14px; }
.player-name-input input[type="text"] { min-height: 30px; padding: 0; border: 0; border-radius: 0; background: transparent; font-size: 1.25rem; font-weight: 500; }
.player-name-input:focus-within { outline: 2px solid var(--blue); outline-offset: 2px; }
.player-name-input input[type="text"]:focus { box-shadow: none; }
.category-page { padding-bottom: calc(165px + env(safe-area-inset-bottom)); }
.category-page .setup-card { background: transparent; border: 0; padding: 0; box-shadow: none; backdrop-filter: none; }
.complete-filter { position: relative; display: flex; align-items: center; gap: 2px; padding: 8px 14px; border-radius: 14px; background: rgba(255,255,255,.72); }
.setup-card .complete-filter label { font-size: .9rem; font-weight: 500; }
.category-info summary { display: grid; place-items: center; width: 44px; height: 44px; color: var(--blue); cursor: pointer; list-style: none; }
.category-info summary::-webkit-details-marker { display: none; }
.category-info-content { position: absolute; z-index: 5; top: 100%; left: 0; right: 0; padding: 20px; border: 1px solid var(--line); border-radius: 18px; background: white; box-shadow: var(--shadow); font-size: .9rem; }
.complete-filter input { appearance: none; flex: 0 0 48px; width: 48px; height: 29px; margin-left: auto; border-radius: 20px; background: #bfc1c5; cursor: pointer; position: relative; }
.complete-filter input::after { content: ''; position: absolute; width: 25px; height: 25px; top: 2px; left: 2px; border-radius: 50%; background: white; transition: transform .15s; }
.complete-filter input:checked { background: var(--blue); }
.complete-filter input:checked::after { transform: translateX(19px); }
.category-search { display: flex; align-items: center; gap: 10px; min-height: 48px; padding: 0 14px; border: 1px solid rgba(7,19,47,.48); border-radius: 14px; background: white; color: var(--muted); }
.category-search:focus-within { border-color: var(--blue); }
.category-search svg { flex-shrink: 0; }
.category-search input[type="text"] { min-height: 46px; padding: 0; border: 0; border-radius: 0; font-size: 1rem; font-weight: 400; background: transparent; }
.category-search input[type="text"]:focus { box-shadow: none; }
.category-search button { border: 0; background: transparent; color: var(--muted); font-size: 1.5rem; min-width: 32px; min-height: 44px; }
.full-page-categories { grid-template-columns: 1fr 1fr; gap: 12px; padding: 3px; }
.full-page-categories .chip { position: relative; display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 5px; min-height: 142px; padding: 28px 10px 12px; border: 3px solid transparent; border-radius: 20px; text-align: center; font-weight: 500; background: rgba(255,255,255,.88); }
.full-page-categories .chip.featured { border-color: var(--blue); }
.full-page-categories .chip.selected { border-color: #e39a18; background: rgba(255,195,19,.55); color: var(--ink); }
.category-emoji { font-size: 32px; line-height: 1.2; }
.category-title { font-size: 1rem; }
.full-page-categories .chip small { margin-top: 0; font-size: .75rem; font-weight: 400; }
.full-page-categories .chip .new-category { font-size: .6rem; font-weight: 700; }
.answer-badge { position: absolute; left: 7px; top: 7px; padding: 3px 7px; border-radius: 20px; background: #e5eefc; color: var(--blue); font-size: .65rem; font-weight: 700; }
.answer-badge.complete { background: #d5f3ea; color: #006b50; }
.selection-check { position: absolute; right: 7px; top: 7px; display: none; width: 19px; height: 19px; border-radius: 50%; background: #e39a18; color: white; font-size: 13px; }
.selected .selection-check { display: block; }
.category-footer { position: fixed; z-index: 10; bottom: 0; left: 50%; transform: translateX(-50%); width: min(100%,760px); display: grid; gap: 4px; padding: 10px 20px max(12px,env(safe-area-inset-bottom)); background: rgba(255,255,255,.88); backdrop-filter: blur(22px); text-align: center; box-shadow: 0 -8px 24px rgba(7,19,47,.04); }
.category-footer #selectedCount { justify-self: center; font-size: .8rem; font-weight: 700; }
.category-footer #answerTotal { color: var(--muted); font-size: .75rem; margin-bottom: 8px; }
.category-footer .notice { margin: 0; font-size: .85rem; }
.text-link { appearance: none; border: 0; padding: 0; background: none; color: var(--blue); text-align: left; font: inherit; font-weight: 800; text-decoration: underline; text-underline-offset: 4px; }
.rule-disclosure { display: grid; gap: 10px; }
#selectedCount { display: inline-block; justify-self: start; padding: 6px 10px; border-radius: 9px; }
#selectedCount.selection-confirmed { color: #086c38; background: #dcfce7; animation: selection-confirmation .9s ease-out; }
@keyframes selection-confirmation { 0%, 35% { background: #bbf7d0; } 100% { background: #dcfce7; } }
@media (prefers-reduced-motion: reduce) { #selectedCount.selection-confirmed { animation: none; } }
.rule-disclosure .text-link { font-size: 1.15rem; display: flex; justify-content: flex-start; align-items: center; }
#toggleRules { min-height: 44px; gap: 12px; line-height: 1.4; text-decoration: none; }
#toggleRules > span:first-child { text-decoration: underline; text-underline-offset: 4px; }
#toggleRules:active { transform: none; }
#toggleRules:focus-visible { outline: 2px solid var(--blue); outline-offset: 4px; border-radius: 4px; }
/* Shared rounded chevron geometry for every custom disclosure. */
.chevron, details:not(.category-info) > summary::after {
  content: ''; display: inline-block; width: 1em; height: 1em; flex: 0 0 1em;
  background: currentColor;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='m9 5 7 7-7 7' fill='none' stroke='black' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat;
}
[aria-expanded="true"] > .chevron, details[open]:not(.category-info) > summary::after { transform: rotate(90deg); }
details:not(.category-info) > summary { position: relative; list-style: none; min-height: 44px; padding: 10px 28px 10px 0; }
details:not(.category-info) > summary::-webkit-details-marker { display: none; }
details:not(.category-info) > summary::after { position: absolute; right: 0; top: 50%; margin-top: -.5em; }
.rule-disclosure small { font-size: .9rem; }
.rule-settings { gap: 24px; }
.rule-settings > .field + .field, .timing-settings { border-top: 1px solid var(--line); padding-top: 20px; }
.timing-settings summary { color: var(--blue); font-weight: 800; cursor: pointer; }
.timing-settings summary small { display: block; margin-top: 7px; font-weight: 500; color: var(--muted); }
.timing-settings > .stack { margin-top: 20px; }
.inline-rule { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; line-height: 1.5; font-weight: 650; }
.inline-rule input[type="number"] { width: 72px; min-width: 60px; text-align: center; flex: 0 0 72px; }
.info-tip { color: var(--muted); font-size: .88rem; }
.info-tip summary { cursor: pointer; color: var(--blue); }
.audience-choice { display: flex; gap: 14px; align-items: center; padding: 22px 18px; border: 2px solid rgba(8,97,198,.4); border-radius: 22px; text-align: left; color: var(--blue); background: white; }
.audience-choice > span:first-child { font-size: 1.8rem; }
.audience-choice > span:nth-child(2) { flex: 1; }
.audience-choice strong { display: block; font-size: 1.1rem; }
.audience-choice small { display: block; margin-top: 7px; color: var(--muted); font-size: .9rem; }
.audience-choice > span:last-child { color: var(--blue); font-size: 1.5rem; }
.audience-choice.audience-primary { color: white; background: var(--red); border-color: var(--red); }
.audience-primary small, .audience-primary > span:last-child { color: white; }
.audience-page .setup-card { padding: 0; border: 0; border-radius: 0; background: none; box-shadow: none; backdrop-filter: none; gap: 24px; }
.audience-description { margin: 0; }
.player-count-picker { display: grid; gap: 12px; }
.player-count-grid { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 10px; }
.player-count-grid button { min-height: 48px; border: 1px solid #989ca8; border-radius: 16px; color: var(--ink); background: white; font-size: 1.5rem; font-weight: 700; }
.player-count-grid button[aria-pressed="true"] { color: var(--blue); border: 2px solid var(--blue); background: #e8effa; }
.more-players { display: flex; align-items: center; justify-content: center; gap: 10px; min-height: 44px; background: none; border: 0; color: var(--blue); font-weight: 700; }
#selectedExtraPlayers { text-align: center; color: var(--blue); }

@media (max-width: 520px) {
  #app { padding-inline: 14px; }
  .card { border-radius: 24px; }
  .hero { padding-top: 3px; }
  .hero img { width: 118px; height: 118px; border-radius: 27px; }
  .category-grid { grid-template-columns: 1fr 1fr; }
  .score-target-picker button { padding-inline: 6px; font-size: .9rem; }
  .row.mobile-stack { align-items: stretch; flex-direction: column; }
}

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