:root {
  --background: #071426; --foreground: #fff; --card: #102944; --card-foreground: #fff;
  --popover: #0c2037; --popover-foreground: #fff; --primary: #f6b81a;
  --primary-foreground: #071426; --secondary: #16324f; --secondary-foreground: #fff;
  --muted: #17314c; --muted-foreground: #aabbd0; --accent: #4bd2d0;
  --accent-foreground: #071426; --destructive: #db493b; --border: #ffffff22;
  --input: #ffffff2b; --ring: #4bd2d0; --radius: .75rem;
}

@theme inline {
  --color-background: var(--background); --color-foreground: var(--foreground);
  --color-card: var(--card); --color-card-foreground: var(--card-foreground);
  --color-popover: var(--popover); --color-popover-foreground: var(--popover-foreground);
  --color-primary: var(--primary); --color-primary-foreground: var(--primary-foreground);
  --color-secondary: var(--secondary); --color-secondary-foreground: var(--secondary-foreground);
  --color-muted: var(--muted); --color-muted-foreground: var(--muted-foreground);
  --color-accent: var(--accent); --color-accent-foreground: var(--accent-foreground);
  --color-destructive: var(--destructive); --color-border: var(--border);
  --color-input: var(--input); --color-ring: var(--ring);
  --radius-sm: calc(var(--radius) - 4px); --radius-md: calc(var(--radius) - 2px);
  --radius-lg: var(--radius); --radius-xl: calc(var(--radius) + 5px);
  --font-sans: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: #071426; color: #fff; font-family: var(--font-sans); }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .42; }
input, select { width: 100%; padding: 0 13px; border: 1px solid #ffffff22; border-radius: 10px; outline: none; }
input:focus, select:focus { border-color: #4bd2d0; box-shadow: 0 0 0 3px #4bd2d01f; }
.utility-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.utility-row form { margin: 0; }
.logout-link { color: #aabbd0; background: none; border: 0; font-weight: 750; }
.logout-link:hover { color: #fff; }

.login-screen { min-height: 100vh; display: grid; place-items: center; padding: 22px; background: radial-gradient(circle at 78% 14%, #4bd2d02a, transparent 31%), linear-gradient(145deg, #071426, #0d213b 68%, #103253); }
.login-card { width: min(480px, 100%); padding: clamp(30px, 6vw, 54px); background: #091c31ed; border: 1px solid #ffffff20; border-radius: 28px; box-shadow: 0 24px 75px #00000057; }
.login-mark { margin-bottom: 25px; }
.login-card h1 { margin: 13px 0 14px; font-size: clamp(2.7rem, 9vw, 4.5rem); line-height: .94; letter-spacing: -.055em; text-transform: uppercase; }
.login-card h1 span { color: #4bd2d0; }
.login-intro { margin: 0 0 22px; color: #ccdae7; line-height: 1.55; }
.login-form { display: grid; gap: 16px; margin-top: 18px; }
.login-form label { color: #aabbd0; font-size: .85rem; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; }
.login-form input { height: 50px; margin-top: 7px; color: #fff; background: #102944; font-size: 1rem; }
.login-form .primary-button { width: 100%; margin-top: 4px; font-size: 1rem; }
.login-form .primary-button span { margin-left: auto; }
.privacy-note { margin: 20px 0 0; color: #71879c; font-size: .78rem; line-height: 1.5; text-align: center; }

.loading-screen { min-height: 100vh; display: grid; place-content: center; gap: 16px; text-align: center; color: #aabbd0; }
.loader { width: 46px; height: 46px; margin: auto; border: 4px solid #ffffff1c; border-top-color: #4bd2d0; border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.setup-screen, .result-screen { min-height: 100vh; padding: 28px; background: radial-gradient(circle at 80% 12%, #4bd2d02a, transparent 30%), linear-gradient(145deg, #071426, #0d213b 68%, #103253); }
.setup-shell { width: min(1240px, 100%); min-height: calc(100vh - 56px); margin: auto; display: grid; grid-template-columns: minmax(0, 1fr) 360px; border: 1px solid #ffffff20; border-radius: 28px; overflow: hidden; background: #091c31dd; box-shadow: 0 24px 75px #00000057; }
.setup-card { padding: clamp(30px, 5vw, 66px); }
.eyebrow { margin: 0; color: #f6b81a; font-size: .82rem; font-weight: 900; letter-spacing: .17em; }
.round-badge { display: inline-flex; gap: 9px; margin-top: 18px; padding: 8px 12px; color: #cfe5f2; background: #ffffff0d; border: 1px solid #ffffff18; border-radius: 999px; font-size: .88rem; font-weight: 750; }
.round-badge span { color: #4bd2d0; }
.setup-card h1 { margin: 18px 0 15px; font-size: clamp(3rem, 5.9vw, 6.2rem); line-height: .93; letter-spacing: -.055em; text-transform: uppercase; }
.setup-card h1 span { color: #4bd2d0; }
.intro { max-width: 700px; margin: 0 0 24px; color: #ccdae7; font-size: 1.06rem; line-height: 1.55; }
.format-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 13px 16px; }
.participant-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 13px 16px; }
.format-grid { margin-bottom: 10px; }
.participant-grid { margin: 22px 0 16px; }
.format-grid label, .participant-grid label, .timer-select { color: #aabbd0; font-size: .85rem; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; }
.format-grid input, .participant-grid input { height: 46px; margin-top: 7px; background: #102944; color: #fff; font-size: 1rem; }
.format-grid input:disabled { color: #8fa2b5; background: #0d2137; }
.format-summary { padding: 10px 12px; color: #9fe6e3; background: #4bd2d012; border: 1px solid #4bd2d035; border-radius: 10px; font-size: .86rem; }
.format-summary.invalid { color: #ffc0b8; background: #ff6b5914; border-color: #ff6b5940; }
.timer-select { display: grid; grid-template-columns: 1fr; gap: 7px; width: min(300px, 100%); }
.timer-select select { height: 46px; background: #102944; color: #fff; font-size: 1rem; }
.primary-button, .secondary-button, .ghost-button { min-height: 48px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; border-radius: 12px; font-weight: 850; transition: transform .15s, filter .15s; }
.primary-button { padding: 13px 20px; color: #061321; background: #f6b81a; border: 0; box-shadow: 0 9px 24px #f6b81a2d; }
.secondary-button, .ghost-button { padding: 12px 16px; color: #d7e6f4; background: #ffffff0f; border: 1px solid #ffffff20; }
.primary-button:not(:disabled):hover, .secondary-button:not(:disabled):hover, .ghost-button:hover { transform: translateY(-1px); filter: brightness(1.08); }
.start-button { min-width: 220px; margin-top: 22px; }
.start-button span { margin-left: 24px; }
.start-note { margin: 13px 0 0; color: #8298ad; font-size: .84rem; line-height: 1.45; }
.error-banner { margin-top: 16px; padding: 12px 14px; color: #ffd2cd; background: #ff6b5918; border: 1px solid #ff6b5950; border-radius: 10px; font-size: .9rem; }

.tournament-panel { padding: 32px 24px; background: #05101e77; border-left: 1px solid #ffffff1c; }
.tournament-heading { display: flex; align-items: start; justify-content: space-between; margin-bottom: 20px; }
.tournament-heading span, .score-heading span { color: #f6b81a; font-size: .74rem; font-weight: 900; letter-spacing: .14em; text-transform: uppercase; }
.tournament-heading h2, .score-heading h2 { margin: 4px 0 0; font-size: 1.35rem; }
.tournament-heading > strong { width: 54px; height: 54px; display: grid; place-items: center; color: #071426; background: #4bd2d0; border-radius: 14px 14px 26px 14px; font-size: 1rem; }
.leaderboard { display: grid; gap: 8px; }
.leaderboard > div { display: grid; grid-template-columns: 26px minmax(0, 1fr) auto 35px; gap: 7px; align-items: center; padding: 11px 10px; background: #ffffff0a; border: 1px solid #ffffff12; border-radius: 11px; }
.leaderboard > div.leader { background: #f6b81a17; border-color: #f6b81a48; }
.leaderboard span { color: #7f93a8; text-align: center; font-size: .8rem; font-weight: 900; }
.leaderboard strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.leaderboard small { color: #8196aa; }
.leaderboard b { color: #f6b81a; text-align: right; font-size: 1.25rem; }
.empty-standings { padding: 25px 16px; color: #8298ad; text-align: center; border: 1px dashed #ffffff20; border-radius: 12px; }
.record-actions { display: flex; justify-content: space-between; gap: 8px; margin-top: 16px; }
.record-actions button { display: inline-flex; align-items: center; gap: 6px; padding: 7px; color: #4bd2d0; background: none; border: 0; font-size: .83rem; font-weight: 800; }
.record-actions .reset-link { color: #ffa99e; }
.round-records { margin-top: 24px; padding-top: 20px; border-top: 1px solid #ffffff16; }
.round-records h3 { margin: 0 0 11px; font-size: .9rem; }
.round-records > p { color: #8298ad; font-size: .86rem; }
.round-record { display: flex; justify-content: space-between; padding: 8px 0; color: #aabbd0; border-bottom: 1px solid #ffffff0d; font-size: .84rem; }
.round-record strong { color: #dbe7f2; }

.game-screen { min-height: 100vh; background: linear-gradient(145deg, #071426, #0b1d33 65%, #102c48); }
.topbar { min-height: 76px; padding: 0 28px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid #ffffff1c; background: #05101ebc; }
.brand-block { display: flex; align-items: center; gap: 12px; }
.brand-mark { width: 43px; height: 43px; display: grid; place-items: center; color: #071426; background: #4bd2d0; border-radius: 11px 11px 21px 11px; font-weight: 950; }
.brand-block strong, .brand-block span { display: block; }
.brand-block span { margin-top: 2px; color: #aabbd0; font-size: .78rem; }
.game-layout { min-height: calc(100vh - 76px); display: grid; grid-template-columns: minmax(0, 1fr) 330px; }
.quiz-panel { min-width: 0; padding: clamp(24px, 3.8vw, 54px); display: flex; flex-direction: column; }
.round-meta { display: grid; grid-template-columns: auto minmax(100px, 1fr) auto; align-items: center; gap: 14px; color: #90a4b7; font-size: .79rem; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; }
.progress-track { height: 6px; overflow: hidden; background: #ffffff12; border-radius: 20px; }
.progress-track div { height: 100%; background: linear-gradient(90deg, #4bd2d0, #f6b81a); border-radius: inherit; transition: width .2s; }
.question-wrap { display: grid; grid-template-columns: 80px minmax(0, 1fr); align-items: center; gap: 22px; margin: clamp(28px, 5vh, 54px) 0 30px; }
.question-wrap.question-only { grid-template-columns: 1fr; min-height: 48vh; }
.question-wrap h1 { margin: 0; font-size: clamp(2rem, 3.8vw, 4.4rem); line-height: 1.08; letter-spacing: -.04em; }
.question-wrap.question-only h1 { max-width: 1100px; font-size: clamp(3rem, 5.7vw, 6.5rem); }
.timer { width: 78px; height: 78px; display: grid; place-items: center; color: #dffffe; border: 7px solid #4bd2d0; border-radius: 50%; font-size: 1.4rem; font-weight: 950; }
.timer.warning { color: #ffb6ac; border-color: #ff6b59; }
.answers-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 13px; }
.answer-card { min-height: 96px; display: grid; grid-template-columns: 52px 1fr; gap: 14px; align-items: center; padding: 17px; color: #fff; background: #ffffff0d; border: 1px solid #ffffff20; border-radius: 17px; font-size: clamp(1rem, 1.45vw, 1.3rem); font-weight: 750; }
.answer-key { width: 50px; height: 50px; display: grid; place-items: center; background: #3d78e7; border-radius: 13px; font-size: 1.35rem; font-weight: 950; }
.answer-card:nth-child(2) .answer-key { background: #a83cba; } .answer-card:nth-child(3) .answer-key { background: #d68a08; } .answer-card:nth-child(4) .answer-key { background: #198b68; }
.answers-grid.revealed .answer-card:not(.correct) { opacity: .28; }
.answer-card.correct { background: #4bd2d024; border-color: #4bd2d0; box-shadow: 0 0 0 3px #4bd2d015; }
.reveal-banner { display: grid; gap: 8px; margin-top: 15px; padding: 15px 18px; color: #dffffe; background: #4bd2d018; border: 1px solid #4bd2d064; border-radius: 12px; }
.reveal-banner > div { display: flex; gap: 13px; align-items: baseline; }
.reveal-banner span { color: #4bd2d0; font-size: .74rem; font-weight: 950; letter-spacing: .11em; text-transform: uppercase; }
.reveal-banner p { margin: 0; color: #c5e4e3; font-size: .98rem; line-height: 1.5; }
.host-controls { margin-top: auto; padding-top: 26px; display: grid; grid-template-columns: auto auto minmax(210px, 1fr); gap: 10px; }
.keyboard-help { margin-top: 10px; color: #71879c; text-align: center; font-size: .78rem; }

.score-panel { padding: 30px 22px; background: #05101e83; border-left: 1px solid #ffffff1c; }
.score-heading { margin-bottom: 18px; }
.score-list { display: grid; gap: 9px; }
.score-row { padding: 12px; background: #ffffff0a; border: 1px solid #ffffff13; border-radius: 12px; }
.score-row.awarded { background: #f6b81a16; border-color: #f6b81a55; }
.score-row > div { display: flex; gap: 8px; align-items: center; }
.player-number { width: 24px; height: 24px; display: grid; place-items: center; color: #071426; background: #4bd2d0; border-radius: 7px; font-size: .76rem; font-weight: 950; }
.score-row > b { float: right; margin-top: -24px; color: #f6b81a; font-size: 1.25rem; }
.score-row button, .no-point { width: 100%; margin-top: 10px; padding: 8px; color: #071426; background: #f6b81a; border: 0; border-radius: 8px; font-size: .82rem; font-weight: 850; }
.score-row button:disabled { color: #71879c; background: #ffffff0b; }
.score-row.awarded button { color: #073d3d; background: #4bd2d0; }
.no-point { color: #cbd8e5; background: #ffffff0d; border: 1px solid #ffffff18; }
.score-note { color: #71879c; font-size: .8rem; line-height: 1.5; }

.result-screen { display: grid; place-items: center; }
.result-card { width: min(760px, 100%); padding: clamp(30px, 6vw, 62px); text-align: center; background: #091c31e8; border: 1px solid #ffffff20; border-radius: 28px; box-shadow: 0 24px 75px #00000057; }
.trophy { width: 76px; height: 76px; display: grid; place-items: center; margin: 0 auto 18px; color: #071426; background: #f6b81a; border-radius: 20px 20px 38px 20px; }
.result-card h1 { margin: 12px 0 7px; font-size: clamp(2rem, 5vw, 4rem); line-height: 1; }
.result-card > p:not(.eyebrow) { color: #aabbd0; }
.result-card .leaderboard { margin-top: 24px; text-align: left; }
.result-actions { display: flex; justify-content: center; gap: 10px; margin-top: 24px; }

@media (max-width: 980px) {
  .setup-shell, .game-layout { grid-template-columns: 1fr; }
  .tournament-panel, .score-panel { border-left: 0; border-top: 1px solid #ffffff1c; }
}
@media (max-width: 650px) {
  .setup-screen, .result-screen { padding: 12px; }
  .setup-shell { min-height: calc(100vh - 24px); border-radius: 20px; }
  .setup-card { padding: 28px 20px; }
  .format-grid, .participant-grid, .answers-grid { grid-template-columns: 1fr; }
  .topbar { padding: 12px 15px; } .ghost-button { font-size: 0; width: 46px; }
  .quiz-panel { padding: 20px 14px; }
  .question-wrap { grid-template-columns: 58px 1fr; gap: 13px; }
  .question-wrap.question-only { min-height: 42vh; }
  .timer { width: 56px; height: 56px; border-width: 5px; }
  .answer-card { min-height: 72px; grid-template-columns: 42px 1fr; padding: 11px; }
  .answer-key { width: 40px; height: 40px; border-radius: 10px; }
  .host-controls { grid-template-columns: 1fr 1fr; }
  .host-controls .primary-button { grid-column: 1 / -1; grid-row: 1; }
  .keyboard-help { display: none; }
  .result-actions { flex-direction: column; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
