:root {
  color-scheme: light;
  --paper: #f8f6ef;
  --surface: #fffdf7;
  --ink: #201c37;
  --muted: #59536a;
  --line: #dad5e3;
  --purple: #4a29a9;
  --deep: #331b82;
  --lavender: #efebff;
  --yellow: #fbe789;
  --green: #14573e;
  --green-bg: #e0f3e6;
  --red: #8d2d38;
  --red-bg: #fce7e7;
  --radius: 18px;
  font-family: "Geist", "Noto Sans CJK TC", "PingFang HK", "Microsoft JhengHei", system-ui, sans-serif;
  font-size: 16px;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-width: 280px; background: var(--paper); color: var(--ink); }
a { color: inherit; }
h1, h2, h3, p { margin: 0; }
button, input, select { font: inherit; }
button, select { cursor: pointer; }
button:disabled { cursor: default; }
button, a, input, select { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 3px solid #8458ec; outline-offset: 4px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }

.topbar { border-bottom: 1px solid var(--line); }
.topbar-inner { width: min(100% - 36px, 1040px); margin-inline: auto; min-height: 65px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; font-weight: 800; font-size: 1.08rem; }
.brand-mark { display: grid; place-items: center; width: 32px; height: 32px; color: white; background: var(--purple); border-radius: 10px; font-size: 1.25rem; }
.connection { color: var(--red); font-size: .82rem; }
.shell { width: min(100% - 36px, 1040px); margin-inline: auto; padding: 26px 0 54px; }
.loading { padding: 36px 0; color: var(--muted); }

.hero { display: grid; align-items: center; min-height: 240px; padding: clamp(24px, 5vw, 54px); overflow: hidden; isolation: isolate; position: relative; background: var(--deep); color: white; border-radius: 24px; }
.hero::after { content: ""; position: absolute; right: -110px; top: -97px; z-index: -1; width: 400px; height: 400px; border: 1px solid #9473e4; border-radius: 50%; box-shadow: inset 0 0 0 29px var(--deep), inset 0 0 0 30px #9473e4, inset 0 0 0 61px var(--deep), inset 0 0 0 62px #9473e4, inset 0 0 0 93px var(--deep), inset 0 0 0 94px #9473e4; opacity: .4; }
.hero h1 { font-size: clamp(2.35rem, 7vw, 4.5rem); line-height: 1.12; letter-spacing: .03em; font-weight: 850; }
.hero p { max-width: 30ch; margin-top: 12px; color: #eee6ff; line-height: 1.65; font-size: 1rem; }
.hero-copy { position: relative; z-index: 1; }
.hero-spark { position: absolute; right: 11%; top: 17%; color: var(--yellow); font-size: clamp(4rem, 14vw, 9rem); line-height: 1; transform: rotate(12deg); opacity: .85; pointer-events: none; }
.hero-spark::after { content: "✦"; position: absolute; left: 99%; top: 65%; font-size: .32em; color: #c2a8ff; }

.lobby-grid { display: grid; gap: 16px; margin-top: 16px; align-items: start; }
.panel { padding: clamp(20px, 4vw, 30px); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.panel h2 { font-size: 1.2rem; margin-bottom: 16px; }
.profile { display: grid; gap: 14px; }
.field { display: grid; gap: 7px; min-width: 0; }
.field label { font-weight: 700; font-size: .91rem; }
.field label span { font-weight: 400; color: var(--muted); }
input, select { width: 100%; min-height: 45px; padding: 9px 12px; background: #fff; color: var(--ink); border: 1px solid #a8a0b7; border-radius: 10px; }
input::placeholder { color: #665f75; }
.modes { display: grid; gap: 9px; }
.mode { display: grid; align-items: center; grid-template-columns: 42px minmax(0, 1fr) 20px; text-align: start; gap: 11px; width: 100%; padding: 12px; background: #fff; color: var(--ink); border: 1px solid var(--line); border-radius: 12px; }
.mode:hover { background: #f7f4ff; border-color: #a38bde; }
.mode-featured { background: var(--lavender); border-color: #b6a3e1; }
.mode-icon { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 10px; background: var(--lavender); color: var(--purple); font-size: 1.35rem; font-weight: 800; }
.mode-featured .mode-icon { background: var(--purple); color: white; }
.mode-name, .mode-detail { display: block; }
.mode-name { font-weight: 800; line-height: 1.35; }
.mode-detail { margin-top: 2px; color: var(--muted); font-size: .84rem; line-height: 1.42; }
.mode-arrow { color: var(--purple); font-size: 1.25rem; }
.join-form { display: flex; align-items: end; gap: 10px; margin-top: 15px; }
.join-form .field { flex: 1; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 20px; }
.button { display: inline-flex; justify-content: center; align-items: center; min-height: 45px; padding: 9px 16px; border: 1px solid transparent; border-radius: 10px; color: #fff; background: var(--purple); text-decoration: none; font-weight: 750; }
.button:hover { background: var(--deep); }
.button.secondary { color: var(--purple); background: var(--surface); border-color: #a48bdc; }
.button.secondary:hover { background: var(--lavender); }
.button:disabled { opacity: .62; }
.alert { width: min(100%, 720px); margin: 0 auto 16px; padding: 11px 14px; color: var(--red); background: var(--red-bg); border: 1px solid #eab4bc; border-radius: 10px; }
.status-card { max-width: 610px; margin: 10px auto 0; }
.status-card h1, .result h1 { font-size: clamp(1.6rem, 5vw, 2.4rem); line-height: 1.25; }
.status-card > p, .result > p { margin-top: 10px; color: var(--muted); line-height: 1.6; }
.status-icon { display: grid; place-items: center; width: 52px; height: 52px; margin-bottom: 16px; color: var(--purple); background: var(--lavender); font-size: 1.6rem; border-radius: 14px; }
.room-code { display: inline-block; margin-top: 8px; color: var(--deep); font-size: 1.7rem; font-weight: 850; letter-spacing: .16em; overflow-wrap: anywhere; }
.room-players { margin: 19px 0 0; padding: 0; list-style: none; }
.room-players li { display: flex; justify-content: space-between; gap: 12px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
.room-players span:last-child { flex: none; color: var(--muted); font-size: .83rem; }
.share-link { margin-top: 15px; }
.share-row { display: flex; gap: 8px; }
.share-row input { min-width: 0; flex: 1; font-size: .86rem; }
.share-row button { flex: none; }

.play, .result { max-width: 720px; margin: 0 auto; }
.scores { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(180px, 100%), 1fr)); gap: 8px; margin: 0 0 12px; padding: 0; list-style: none; }
.score { min-width: 0; display: flex; align-items: center; justify-content: space-between; gap: 10px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.score:first-child { background: var(--lavender); border-color: #c9b7ed; }
.score-name { font-weight: 750; overflow-wrap: anywhere; }
.score-status { display: block; color: var(--muted); font-size: .76rem; margin-top: 2px; }
.score-points { flex: none; color: var(--deep); font-weight: 850; font-size: 1.35rem; font-variant-numeric: tabular-nums; }
.question-meta { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 10px; }
.round { color: var(--purple); font-size: .9rem; font-weight: 800; }
.timer { color: var(--deep); background: var(--lavender); border-radius: 8px; min-width: 56px; padding: 5px 8px; text-align: center; font-weight: 850; font-variant-numeric: tabular-nums; }
.timer.urgent { color: var(--red); background: var(--red-bg); }
.timer-track { height: 6px; border-radius: 8px; overflow: hidden; background: #e6e0ee; margin-bottom: 19px; }
.timer-fill { width: 100%; height: 100%; background: #734dd6; transform-origin: left; transition: transform 100ms linear; }
.question h1 { font-size: clamp(1.25rem, 4vw, 1.85rem); line-height: 1.45; margin-bottom: 19px; overflow-wrap: anywhere; }
.answers { display: grid; gap: 9px; }
.answer { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 53px; padding: 9px 12px; border: 1px solid var(--line); border-radius: 12px; background: #fff; color: var(--ink); text-align: start; overflow-wrap: anywhere; }
.answer:hover:not(:disabled), .answer.chosen { border-color: #a38bde; background: var(--lavender); }
.answer.correct { color: var(--green); border-color: #83bc9a; background: var(--green-bg); }
.answer.incorrect { color: var(--red); border-color: #e4a0a7; background: var(--red-bg); }
.answer-key { flex: none; display: grid; place-items: center; width: 32px; height: 32px; border-radius: 7px; background: #f1edf7; color: var(--purple); font-size: .83rem; font-weight: 850; }
.answer-mark { margin-left: auto; font-weight: 850; }
.feedback { margin-top: 14px; color: var(--muted); line-height: 1.6; }
.reveal { margin-top: 15px; padding: 13px 14px; background: var(--lavender); border-radius: 10px; line-height: 1.65; overflow-wrap: anywhere; }
.reveal h2 { margin-bottom: 2px; font-size: 1rem; }
.countdown { margin: 14px 0 0; font-variant-numeric: tabular-nums; color: var(--purple); font-size: clamp(3.6rem, 15vw, 6rem); font-weight: 850; }
.result > .scores { margin-top: 18px; }
.review { margin-top: 26px; }
.review h2 { margin-bottom: 8px; }
.review details { border-bottom: 1px solid var(--line); padding: 10px 0; overflow-wrap: anywhere; }
.review summary { cursor: pointer; line-height: 1.5; }
.review p { color: var(--muted); margin-top: 7px; line-height: 1.55; }

@media (min-width: 720px) {
  .shell { padding-top: 36px; }
  .lobby-grid { grid-template-columns: minmax(250px, 2fr) minmax(0, 3fr); gap: 16px; }
  .profile { gap: 16px; }
}

@media (max-width: 500px) {
  .hero { min-height: 195px; }
  .hero::after { right: -260px; top: -115px; }
  .hero-spark { right: 12%; top: 13%; opacity: .58; }
}

@media (prefers-reduced-motion: reduce) {
  .timer-fill { transition: none; }
}

/* Quiz Battle: a lighter, faster lobby and a focused play surface. */
:root {
  --paper: #f6f4ee;
  --surface: #fffefa;
  --ink: #241d38;
  --muted: #696477;
  --line: #e5e1e9;
  --purple: #6042c4;
  --deep: #211344;
  --lavender: #f0ecff;
  --yellow: #f8e58d;
  --radius: 20px;
}
body { background: var(--paper); }
.topbar { background: var(--paper); border-bottom: 0; }
.topbar-inner { width: min(100% - 40px, 1080px); min-height: 72px; }
.brand { gap: 11px; letter-spacing: -.035em; font-size: 1.14rem; }
.brand-mark { width: 35px; height: 35px; background: var(--deep); border-radius: 11px; }
.shell { width: min(100% - 40px, 1080px); padding: 10px 0 54px; }
.lobby-topline { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin: 4px 0 15px; }
.lobby-label { color: #797281; font-size: .72rem; font-weight: 800; letter-spacing: .12em; }
.lobby-label span { color: #d28b61; margin-left: 5px; }
.settings-toggle { min-height: 38px; padding: 7px 13px; border: 1px solid #e0dce4; border-radius: 999px; background: #fffefa; color: #5f5869; font-size: .82rem; font-weight: 700; }
.settings-toggle span { margin-right: 4px; font-size: 1rem; }
.settings-toggle:hover { border-color: #a99bd3; color: var(--purple); }
.hero { min-height: 314px; padding: clamp(28px, 5.2vw, 58px); background: #241449; border-radius: 24px; }
.hero::after { right: -70px; top: -115px; width: 480px; height: 480px; border-color: #a082ea; box-shadow: inset 0 0 0 42px #241449, inset 0 0 0 43px #a082ea, inset 0 0 0 88px #241449, inset 0 0 0 89px #a082ea, inset 0 0 0 134px #241449, inset 0 0 0 135px #a082ea; opacity: .19; }
.hero-copy { max-width: 560px; }
.hero .hero-eyebrow { margin: 0 0 17px; color: #c8b9ee; font-size: .68rem; font-weight: 800; letter-spacing: .16em; }
.hero-eyebrow span { margin: 0 5px; color: #e9cf7a; }
.hero h1 { font-size: clamp(2.25rem, 4.8vw, 3.9rem); line-height: 1.2; letter-spacing: -.045em; font-weight: 850; }
.hero .hero-description { margin-top: 13px; color: #d8cee9; font-size: .95rem; }
.hero-facts { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 23px; }
.hero-facts span { display: inline-flex; align-items: center; gap: 5px; padding: 6px 10px; color: #eee8f8; background: #ffffff12; border: 1px solid #ffffff1c; border-radius: 999px; font-size: .73rem; font-weight: 700; }
.hero-facts b { color: #f8e58d; font-size: .83rem; }
.hero-art { position: absolute; top: 30px; right: 8%; width: 220px; height: 220px; pointer-events: none; }
.hero-orbit { position: absolute; inset: 21px; border: 1px solid #a68ce166; border-radius: 50%; transform: rotate(-20deg) scaleX(1.15); }
.hero-question { position: absolute; display: grid; place-items: center; inset: 36px; background: #f4d981; color: #2d1b54; border-radius: 43px; font-size: 7rem; font-weight: 900; line-height: 1; transform: rotate(10deg); box-shadow: 10px 13px 0 #7555bf66; }
.hero-star { position: absolute; right: 4px; top: 6px; color: #f6d982; font-size: 2.6rem; }
.hero-dot { position: absolute; left: 1px; bottom: 29px; width: 15px; height: 15px; background: #f1947e; border-radius: 50%; }
.hero-caption { position: absolute; right: 25px; bottom: 19px; color: #b8a9d0; font-size: .66rem; font-weight: 700; letter-spacing: .08em; }
.lobby-grid { grid-template-columns: 1fr; gap: 15px; margin-top: 29px; }
.modes-panel { min-width: 0; }
.section-heading, .settings-heading { display: flex; justify-content: space-between; align-items: end; gap: 14px; margin-bottom: 15px; }
.section-heading h2, .settings-heading h2 { margin: 0; font-size: 1.3rem; line-height: 1.3; letter-spacing: -.025em; }
.section-kicker { margin: 0 0 5px; color: #827a8e; font-size: .64rem; font-weight: 850; letter-spacing: .15em; }
.section-index { color: #9b95a5; font-size: .72rem; font-weight: 700; }
.modes { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 11px; }
.mode { min-height: 78px; padding: 15px; grid-template-columns: 45px minmax(0, 1fr) 20px; gap: 13px; border-radius: 16px; border-color: #e4e0e8; background: #fffefa; box-shadow: 0 4px 14px #25173d08; transition: transform 160ms ease, border-color 160ms ease, box-shadow 160ms ease; }
.mode:hover { transform: translateY(-2px); border-color: #b9a7ea; background: #fffefa; box-shadow: 0 8px 20px #28144a10; }
.mode-featured { background: #e9e3ff; border-color: #d3c6ff; }
.mode-featured:hover { background: #e4dcff; }
.mode-icon { width: 45px; height: 45px; border-radius: 13px; background: #f1ecff; font-size: 1.25rem; }
.mode-featured .mode-icon { background: #6042c4; }
.mode-name { font-size: 1rem; letter-spacing: -.02em; }
.mode-detail { font-size: .78rem; }
.mode-arrow { justify-self: end; font-size: 1.35rem; }
.settings-panel { margin-top: 0; }
.settings-heading { align-items: center; }
.settings-heading > span { color: #b9a8e5; font-size: 1.5rem; }
.profile { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.trial-note { margin: 22px 0 0; color: #8a8392; font-size: .76rem; text-align: center; }
.trial-note span { color: #b59d68; }
.play, .result { max-width: 720px; }
.scores { gap: 10px; margin-bottom: 15px; }
.score { padding: 14px 17px; border-radius: 15px; }
.score:first-child { background: #ece7fb; border-color: #ddd4f3; }
.score-points { font-size: 1.55rem; }
.question { padding: clamp(22px, 5vw, 34px); border-color: #e7e2e9; border-radius: 22px; box-shadow: 0 16px 40px #2d1a460a; }
.question-meta { margin-bottom: 14px; }
.round { color: #746c7e; letter-spacing: .02em; }
.timer { min-width: 65px; padding: 8px 10px; border-radius: 11px; font-size: 1rem; }
.timer-track { height: 7px; margin-bottom: 27px; background: #eeeaf2; }
.timer-fill { border-radius: inherit; background: #7858db; }
.question h1 { margin-bottom: 24px; font-size: clamp(1.4rem, 4vw, 2rem); line-height: 1.4; letter-spacing: -.025em; }
.answers { gap: 10px; }
.answer { min-height: 62px; padding: 10px 14px; gap: 14px; border-radius: 14px; font-weight: 650; transition: background 140ms ease, border-color 140ms ease, transform 140ms ease; }
.answer:hover:not(:disabled) { transform: translateY(-1px); }
.answer-key { width: 36px; height: 36px; border-radius: 10px; }
.reveal { padding: 16px 18px; border-radius: 14px; }
@media (max-width: 719px) {
  .topbar-inner, .shell { width: min(100% - 32px, 1080px); }
  .topbar-inner { min-height: 62px; }
  .shell { padding-top: 5px; }
  .hero { min-height: 255px; padding: 28px 25px; }
  .hero h1 { font-size: clamp(1.85rem, 7vw, 2.7rem); }
  .hero::after { right: -260px; top: -120px; }
  .hero-art { top: 18px; right: -20px; transform: scale(.52); transform-origin: top right; opacity: .52; }
  .hero-copy { max-width: 87%; }
  .hero .hero-description { font-size: .84rem; }
  .hero-facts { margin-top: 18px; }
  .hero-caption { display: none; }
  .lobby-grid { margin-top: 25px; }
  .profile { grid-template-columns: 1fr; }
  .modes { grid-template-columns: 1fr; }
  .mode { min-height: 70px; padding: 12px 14px; }
  .mode-icon { width: 42px; height: 42px; }
  .trial-note { margin-top: 16px; }
}
@media (prefers-reduced-motion: reduce) {
  .mode, .answer { transition: none; }
  .mode:hover, .answer:hover:not(:disabled) { transform: none; }
}
.hero .hero-eyebrow { max-width: none; }
.lobby > .settings-panel { margin: 0 0 15px; }
