/* Riddle10 Friend Challenge: /challenge (create) and /c/<code> (lobby, race, results). Uses the site's tokens (site.css) and the
   PLAY shell (play.css). Mobile first; works in the dark "night" and light "parchment" themes. */

.ch-wrap { max-width: 760px; margin: 0 auto; padding-bottom: 28px; }
.ch-hero { margin-bottom: 18px; }
.ch-hero .eyebrow, .ch-head .eyebrow { justify-content: center; font-size: 12px; }
.ch-hero .eyebrow svg, .ch-head .eyebrow svg { width: 15px; height: 15px; }

.ch-card { position: relative; padding: 18px; border-radius: var(--radius); border: 1px solid var(--line-2); background: linear-gradient(160deg, var(--glass-2), var(--glass)); box-shadow: var(--shadow); }
.ch-card + .ch-card { margin-top: 12px; }
.ch-msg { text-align: center; padding: 26px 18px; }
.ch-msg h2 { font-size: clamp(26px, 6vw, 34px); margin-bottom: 8px; }
.ch-msg p { color: var(--ink-2); max-width: 30em; margin-inline: auto; }
.ch-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin-top: 18px !important; }
.ch-quiet { display: flex; align-items: center; justify-content: center; gap: 12px; box-shadow: none; }
.ch-spin { width: 20px; height: 20px; border-radius: 50%; border: 2.5px solid var(--line-2); border-top-color: var(--gold); animation: ch-spin .8s linear infinite; }
@keyframes ch-spin { to { transform: rotate(360deg); } }
.ch-ended-art { display: inline-grid; place-items: center; width: 64px; height: 64px; margin-bottom: 12px; border-radius: 50%; border: 1px solid rgba(244, 199, 111, .45); color: var(--gold-text); background: radial-gradient(circle at 50% 35%, rgba(244, 199, 111, .2), transparent 70%); }
.ch-ended-art svg { width: 30px; height: 30px; }
.linklike, .ch-linkbtn { background: none; border: 0; padding: 6px 4px; color: var(--muted); font: 500 14px var(--sans); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.linklike:hover, .ch-linkbtn:hover { color: var(--gold-text); }
.ch-sub-actions { text-align: center; margin-top: 12px; }

/* player colours (seat gems). Colour is never the only signal: every seat also says "Player n" and its state. */
.ch-p1 { --pc: #f4c76f; } .ch-p2 { --pc: #4fd1c5; } .ch-p3 { --pc: #ff8f86; } .ch-p4 { --pc: #a98bff; } .ch-p5 { --pc: #7fe0a0; }
.ch-p6 { --pc: #6fb6ff; } .ch-p7 { --pc: #ffa94d; } .ch-p8 { --pc: #ff7fc8; } .ch-p9 { --pc: #c6e86a; } .ch-p10 { --pc: #5ee0ff; }
.ch-p11 { --pc: #e0a043; } .ch-p12 { --pc: #c3a6ff; } .ch-p13 { --pc: #3fbf8f; } .ch-p14 { --pc: #ff6f61; } .ch-p15 { --pc: #8fb3ff; }
.ch-p16 { --pc: #ffd54f; } .ch-p17 { --pc: #4aa3e8; } .ch-p18 { --pc: #f48fb1; } .ch-p19 { --pc: #9ccc65; } .ch-p20 { --pc: #ffb74d; }
.ch-gem { flex: none; display: inline-block; width: 13px; height: 13px; border-radius: 3px; transform: rotate(45deg); background: var(--pc, var(--gold)); box-shadow: 0 0 0 1.5px rgba(0, 0, 0, .28), 0 0 10px color-mix(in srgb, var(--pc, #f4c76f) 55%, transparent); }
:root[data-theme="light"] .ch-gem { box-shadow: 0 0 0 1.5px rgba(60, 40, 10, .45); }

.ch-pips { display: inline-flex; gap: 3px; margin-inline-end: 7px; font-style: normal; }
.ch-pips em { width: 6px; height: 6px; border-radius: 1.5px; transform: rotate(45deg); background: currentColor; }

/* ---------- create ---------- */
.ch-create { display: grid; gap: 6px; }
.ch-step { border: 0; padding: 0; margin: 0 0 16px; min-width: 0; }
.ch-step legend { display: flex; align-items: center; gap: 10px; padding: 0; margin-bottom: 10px; font: 700 23px/1.1 var(--serif); }
.ch-num { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: linear-gradient(180deg, var(--gold), var(--gold-2)); color: var(--gold-ink); font: 700 14px var(--sans); }
.ch-games { display: grid; grid-template-columns: repeat(auto-fill, minmax(156px, 1fr)); gap: 8px; }
@media (min-width: 600px) { .ch-games { grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); } }
.ch-games.is-collapsed .ch-game:not(:has(input:checked)) { display: none; }
.ch-games.is-collapsed .ch-game:has(input:checked) { grid-column: 1 / -1; }
.ch-game { position: relative; display: flex; align-items: center; gap: 10px; min-width: 0; padding: 9px 10px; border-radius: 14px; border: 1px solid var(--line-2); background: var(--glass); cursor: pointer; transition: border-color .15s, background .15s, box-shadow .15s; }
.ch-game:hover { border-color: rgba(244, 199, 111, .5); }
.ch-game input, .ch-band input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.ch-game:has(input:checked) { border-color: var(--gold); background: rgba(244, 199, 111, .12); box-shadow: var(--glow); }
.ch-game:has(input:focus-visible), .ch-band input:focus-visible + span { outline: 2px solid var(--gold); outline-offset: 2px; }
.ch-game-art { flex: none; display: grid; place-items: center; width: 40px; height: 40px; border-radius: 11px; background: radial-gradient(circle at 50% 40%, rgba(244, 199, 111, .18), transparent 70%), var(--bg-2); border: 1px solid var(--line); }
.ch-game-art svg { width: 26px; height: 26px; fill: none; stroke: var(--gold-text); stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round; }
.ch-surprise .ch-game-art svg { stroke-width: 1.8; }
.ch-game-txt { display: grid; min-width: 0; line-height: 1.2; }
.ch-game-txt b { font: 600 14.5px/1.2 var(--sans); overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.ch-game-txt small { color: var(--muted); font-size: 12px; }
.ch-more { margin-top: 10px; }
.ch-bands { display: flex; flex-wrap: wrap; gap: 8px; }
.ch-band { position: relative; }
.ch-band span { display: inline-flex; align-items: center; min-height: 44px; padding: 0 16px; border-radius: 999px; border: 1px solid var(--line-2); background: var(--glass); font: 600 14.5px var(--sans); color: var(--ink-2); cursor: pointer; }
.ch-band span .ch-pips { color: var(--muted); }
.ch-band input:checked + span { border-color: var(--gold); color: var(--gold-text); background: rgba(244, 199, 111, .12); }
.ch-band input:checked + span .ch-pips { color: var(--gold-text); }
.ch-band input:disabled + span { opacity: .4; cursor: not-allowed; text-decoration: line-through; }
.ch-stepper { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; }
.ch-stepper .iconbtn { width: 48px; height: 48px; }
.ch-stepper .iconbtn:disabled { opacity: .35; cursor: default; }
.ch-stepper output { min-width: 2ch; text-align: center; font: 700 44px/1 var(--serif); color: var(--gold-text); font-variant-numeric: tabular-nums; }
.ch-stepper-note { color: var(--ink-2); font-size: 15px; }
.ch-stepper-note small { color: var(--muted); }
.ch-create-foot { text-align: center; margin-top: 4px; }
.ch-go { min-height: 54px; padding: 0 28px; font-size: 17px; width: 100%; max-width: 360px; }
.ch-error { margin-top: 12px !important; color: var(--rose); font-weight: 600; }
.ch-fine { margin-top: 12px !important; color: var(--muted); font-size: 13.5px; max-width: 34em; margin-inline: auto !important; }

/* ---------- room head ---------- */
.ch-head { display: flex; align-items: center; gap: 14px; margin: 10px 0 16px; }
.ch-head .eyebrow { justify-content: flex-start; }
.ch-head-art { flex: none; display: grid; place-items: center; width: 68px; height: 68px; border-radius: 18px; background: radial-gradient(circle at 50% 40%, rgba(244, 199, 111, .2), transparent 70%), var(--bg-2); border: 1px solid var(--line-2); box-shadow: var(--glow); }
.ch-head-art svg { width: 44px; height: 44px; fill: none; stroke: var(--gold-text); stroke-width: 1.3; stroke-linecap: round; stroke-linejoin: round; filter: drop-shadow(0 0 8px rgba(244, 199, 111, .45)); }
.ch-head-txt { min-width: 0; }
.ch-head h1 { font-size: clamp(28px, 7vw, 42px); margin: 2px 0 6px; overflow-wrap: anywhere; }
.ch-head .pl-tags { justify-content: flex-start; }
.ch-banner { margin: 0 0 12px; padding: 9px 14px; border-radius: 12px; border: 1px solid rgba(244, 199, 111, .45); background: rgba(244, 199, 111, .1); color: var(--ink); text-align: center; font-weight: 600; font-size: 14px; }

/* ---------- lobby ---------- */
.ch-share h2 { font-size: 26px; }
.ch-share-sub { color: var(--ink-2); font-size: 14.5px; margin: 4px 0 12px; }
.ch-link { display: flex; flex-wrap: wrap; gap: 8px; }
.ch-link input { flex: 1 1 100%; min-width: 0; height: 46px; padding: 0 14px; border-radius: 12px; border: 1px solid var(--line-2); background: var(--bg); color: var(--ink); font: 500 16px var(--sans); }
.ch-link input:focus { outline: none; border-color: var(--gold); }
.ch-link .btn { flex: 1 1 0; min-height: 44px; }
@media (min-width: 560px) { .ch-link input { flex: 1 1 auto; } .ch-link .btn { flex: none; } }
.ch-expire { display: flex; align-items: center; gap: 7px; margin-top: 12px !important; color: var(--muted); font-size: 13.5px; font-variant-numeric: tabular-nums; }
.ch-expire svg { width: 15px; height: 15px; }
.ch-count { text-align: center; font: 700 26px/1.15 var(--serif); margin-bottom: 12px; }
.ch-seats { list-style: none; margin: 0 0 14px; padding: 0; display: grid; gap: 6px; }
@media (min-width: 560px) { .ch-seats { grid-template-columns: 1fr 1fr; } }
.ch-seat { display: flex; align-items: center; gap: 11px; min-height: 48px; padding: 8px 14px; border-radius: 13px; border: 1px solid var(--line-2); background: var(--glass); }
.ch-seat-name { flex: 1; min-width: 0; font-weight: 600; }
.ch-seat-name b { color: var(--gold-text); font-weight: 600; }
.ch-seat-state { display: inline-flex; align-items: center; gap: 5px; color: var(--muted); font-size: 13px; font-weight: 600; }
.ch-seat-state svg { width: 15px; height: 15px; }
.ch-seat.is-ready { border-color: color-mix(in srgb, var(--pc) 70%, transparent); background: color-mix(in srgb, var(--pc) 10%, var(--glass)); }
.ch-seat.is-ready .ch-seat-state { color: var(--green); }
.ch-seat.is-empty { border-style: dashed; background: transparent; }
.ch-seat.is-empty .ch-gem { background: transparent; box-shadow: inset 0 0 0 1.5px var(--line-2); }
.ch-seat.is-empty .ch-seat-name { color: var(--muted); font-weight: 500; }
.ch-seat.is-away { opacity: .7; }
.ch-seat.is-me { box-shadow: 0 0 0 1px rgba(244, 199, 111, .35); }
.ch-ready { min-height: 54px; font-size: 17px; }
.ch-ready.is-on { background: var(--glass-2); color: var(--ink); border-color: var(--line-2); box-shadow: none; }
:root[data-theme="light"] .ch-ready.is-on { color: var(--ink); }
.ch-start { margin-top: 10px; min-height: 48px; }
.ch-start[hidden] { display: none; }
.ch-start:disabled { opacity: .45; cursor: not-allowed; }
.ch-note { margin-top: 10px !important; text-align: center; color: var(--muted); font-size: 14px; }

/* ---------- race ---------- */
.ch-racebar { scroll-margin-top: 76px; display: grid; grid-template-columns: auto 1fr auto; grid-template-areas: "time runners left"; align-items: center; gap: 10px; margin-bottom: 12px; padding: 10px 14px; border-radius: var(--radius); border: 1px solid var(--line-2); background: var(--glass); }
.ch-clock { grid-area: time; display: grid; line-height: 1.05; }
.ch-clock.ch-left { grid-area: left; text-align: end; }
.ch-clock span { font: 600 11px var(--sans); letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.ch-clock b { font: 700 28px var(--serif); color: var(--gold-text); font-variant-numeric: tabular-nums; }
.ch-clock.is-low b { color: var(--rose); }
.ch-runners { grid-area: runners; list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; min-width: 0; }
.ch-runner { display: inline-flex; align-items: center; gap: 7px; padding: 4px 10px 4px 9px; border-radius: 999px; border: 1px solid var(--line); background: var(--glass); font-size: 12.5px; }
.ch-runner .ch-gem { width: 10px; height: 10px; }
.ch-runner .ch-seat-name { font-weight: 600; white-space: nowrap; }
.ch-runner .ch-seat-state { font-size: 11.5px; }
.ch-runner.is-left, .ch-runner.is-away { opacity: .55; }
.ch-runner.is-left .ch-seat-name { text-decoration: line-through; }
@media (max-width: 520px) {
  .ch-racebar { grid-template-columns: 1fr 1fr; grid-template-areas: "time left" "runners runners"; padding: 10px 12px; }
  .ch-runners { justify-content: flex-start; }
  .ch-runner .ch-seat-state { display: none; }
}
.ch-resultbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; padding: 10px 14px; border-radius: var(--radius); border: 1px solid rgba(244, 199, 111, .45); background: rgba(244, 199, 111, .08); }
.ch-resultbar p { font-weight: 600; }
.ch-resultbar.is-won p { color: var(--gold-text); }
.ch-resultbar-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.ch-game-host { min-height: 280px; }

.ch-countdown { position: fixed; inset: 0; z-index: 85; display: grid; place-items: center; background: rgba(4, 6, 12, .62); backdrop-filter: blur(5px); }
:root[data-theme="light"] .ch-countdown { background: rgba(245, 239, 226, .72); }
.ch-countdown > div { display: grid; justify-items: center; gap: 4px; text-align: center; }
.ch-countdown b { font: 700 clamp(110px, 32vw, 190px)/1 var(--serif); color: var(--gold-text); text-shadow: 0 0 40px rgba(244, 190, 100, .55); min-height: 1em; font-variant-numeric: tabular-nums; }
.ch-countdown b.pop { animation: ch-pop .4s cubic-bezier(.2, 1.4, .4, 1); }
@keyframes ch-pop { from { transform: scale(.55); opacity: .3; } }
.ch-countdown span { font: 700 14px var(--sans); letter-spacing: .3em; text-transform: uppercase; color: var(--ink); }

/* ---------- results ---------- */
.ch-result-card { max-height: calc(100dvh - 32px); overflow-y: auto; }
.ch-result.is-won .ch-result-card { border-color: rgba(244, 199, 111, .7); }
.ch-time { font: 700 64px/1 var(--serif); color: var(--gold-text); margin: 2px 0 4px !important; text-shadow: 0 0 30px rgba(244, 190, 100, .4); font-variant-numeric: tabular-nums; }
.ch-result-sub { color: var(--ink-2); margin-bottom: 12px !important; }
.ch-pic { margin: 4px auto 14px; width: 150px; aspect-ratio: 1080 / 1350; border-radius: 12px; overflow: hidden; border: 1px solid rgba(244, 199, 111, .45); box-shadow: var(--shadow); background: var(--bg-2); }
.ch-pic img { width: 100%; height: 100%; object-fit: cover; }
.ch-pic.is-loading { background: linear-gradient(100deg, var(--bg-2) 30%, var(--bg-3) 50%, var(--bg-2) 70%) 0 0 / 300% 100%; animation: ch-shine 1.2s linear infinite; }
@keyframes ch-shine { to { background-position: -300% 0; } }
.ch-result .pl-win-actions + .pl-win-actions { margin-top: 8px; }
.ch-lost-line { display: flex; align-items: center; justify-content: center; gap: 9px; font: 600 17px var(--sans); margin-bottom: 2px !important; }
.ch-answer { margin: 6px 0 14px; padding: 12px 14px; border-radius: 14px; text-align: start; border: 1px solid rgba(244, 199, 111, .35); background: rgba(244, 199, 111, .07); }
.ch-answer h3 { font: 700 12px var(--sans); letter-spacing: .16em; text-transform: uppercase; color: var(--gold-text); margin-bottom: 4px; }
.ch-answer p { font-size: 14.5px; color: var(--ink-2); }
.ch-answer .ch-answer-main { font: 600 16px/1.45 var(--sans); color: var(--ink); }
.ch-result-extra { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 16px; margin-top: 10px !important; }
