:root {
    --bg-1: #08131f;
    --bg-2: #102542;
    --bg-3: #174c67;
    --panel: rgba(7, 19, 33, 0.86);
    --panel-strong: rgba(10, 27, 45, 0.95);
    --line: rgba(161, 214, 255, 0.18);
    --text: #eff8ff;
    --muted: #b8d2e8;
    --accent: #ffd166;
    --accent-2: #4ad6b8;
    --danger: #ff6b6b;
    --success: #59e3a7;
    --success-soft: rgba(89, 227, 167, 0.18);
    --error: #ff7474;
    --error-soft: rgba(255, 116, 116, 0.16);
    --shadow: 0 24px 50px rgba(0, 0, 0, 0.3);
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    height: 100%;
    min-height: 100%;
    min-height: 100svh;
    font-family: "Trebuchet MS", "Segoe UI", sans-serif;
    color: var(--text);
    background:
        radial-gradient(circle at top left, rgba(255, 209, 102, 0.22), transparent 30%),
        radial-gradient(circle at bottom right, rgba(74, 214, 184, 0.18), transparent 35%),
        linear-gradient(135deg, var(--bg-1), var(--bg-2) 48%, var(--bg-3));
    overflow: hidden;
}

body {
    min-height: 100vh;
    min-height: 100svh;
}

.page-shell {
    max-width: min(1800px, 100vw);
    margin: 0 auto;
    height: 100vh;
    height: 100svh;
    padding: clamp(12px, 1.3vw, 24px);
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    gap: clamp(12px, 1.3vw, 24px);
}

.hero-panel,
.card {
    border: 1px solid var(--line);
    border-radius: 28px;
    background: var(--panel);
    box-shadow: var(--shadow);
    backdrop-filter: blur(12px);
}

.hero-panel {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 0;
    padding: clamp(18px, 1.6vw, 28px) clamp(20px, 1.8vw, 30px);
}

.hero-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
    flex-wrap: wrap;
}

.eyebrow {
    margin: 0 0 12px;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.24em;
    color: var(--accent);
}

.hero-panel h1 {
    margin: 0;
    font-size: clamp(1.9rem, 3vw, 3.2rem);
    line-height: 0.98;
}

.hero-copy {
    max-width: 50rem;
    margin: 10px 0 0;
    color: var(--muted);
    font-size: clamp(0.92rem, 1vw, 1.05rem);
}

.secondary-button {
    border: 0;
    border-radius: 999px;
    padding: 14px 20px;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.18), rgba(161, 214, 255, 0.08));
    color: var(--text);
    font: inherit;
    font-weight: 700;
    cursor: pointer;
}

.secondary-button:hover {
    background: linear-gradient(135deg, rgba(255, 209, 102, 0.28), rgba(161, 214, 255, 0.14));
}

.secondary-button.active,
.secondary-button:disabled {
    background: linear-gradient(135deg, rgba(74, 214, 184, 0.26), rgba(89, 227, 167, 0.16));
    color: var(--accent-2);
    cursor: default;
}

.content-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.8fr) minmax(300px, 0.92fr);
    gap: clamp(12px, 1.3vw, 24px);
    min-height: 0;
    align-items: stretch;
}

.card {
    padding: clamp(16px, 1.35vw, 24px);
}

.question-panel {
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.02), transparent),
        var(--panel-strong);
    overflow: hidden;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.question-topbar,
.question-meta,
.roster-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
}

.question-meta {
    margin-top: clamp(10px, 1.1vh, 18px);
    color: var(--muted);
    font-size: clamp(0.88rem, 0.9vw, 0.95rem);
}

.phase-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    border-radius: 999px;
    background: rgba(255, 209, 102, 0.14);
    color: var(--accent);
    font-size: 0.92rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.timer-block {
    text-align: right;
}

.timer-label {
    display: block;
    color: var(--muted);
    font-size: 0.8rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.timer-value {
    display: block;
    margin-top: 2px;
    font-size: clamp(2.1rem, 4.4vw, 4.1rem);
    font-weight: 700;
    line-height: 0.9;
}

.question-title {
    margin: clamp(18px, 2vh, 28px) 0 clamp(14px, 1.6vh, 20px);
    font-size: clamp(1.7rem, 2.5vw, 3rem);
    line-height: 1.02;
}

.question-panel.question-transition .question-title {
    animation: titleSwap 820ms cubic-bezier(0.22, 1, 0.36, 1);
}

.question-panel.reveal-transition .question-title {
    animation: titleSwap 540ms cubic-bezier(0.22, 1, 0.36, 1);
}

.question-panel.question-transition .question-meta {
    animation: metaFade 620ms ease;
}

.question-panel.reveal-transition .question-meta {
    animation: metaFade 420ms ease;
}

.option-list,
.participant-list,
.name-list,
.leaderboard-list {
    margin: 0;
    padding: 0;
    list-style: none;
}

.option-list {
    display: grid;
    gap: clamp(8px, 1vh, 14px);
    align-content: start;
    overflow: hidden;
    flex: 1 1 auto;
}

.option-item {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: clamp(10px, 1vw, 16px);
    padding: clamp(12px, 1.4vh, 18px) clamp(14px, 1.1vw, 20px);
    border: 1px solid var(--line);
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.05);
    position: relative;
    overflow: hidden;
    transition:
        transform 220ms ease,
        border-color 220ms ease,
        background 220ms ease,
        opacity 220ms ease,
        box-shadow 220ms ease;
}

.option-item::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(120deg, transparent 0%, rgba(255, 255, 255, 0.12) 45%, transparent 100%);
    opacity: 0;
    transform: translateX(-55%);
    pointer-events: none;
}

.option-item.option-enter {
    animation: optionRise 760ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

.option-item.playable {
    cursor: pointer;
}

.option-item.playable:hover,
.option-item.playable:focus-visible {
    border-color: rgba(255, 209, 102, 0.55);
    transform: translateY(-1px);
    box-shadow: 0 14px 24px rgba(0, 0, 0, 0.16);
    outline: none;
}

.option-item.selected {
    border-color: rgba(255, 209, 102, 0.82);
    background: rgba(255, 209, 102, 0.14);
    box-shadow: 0 16px 28px rgba(255, 209, 102, 0.14);
}

.option-item.correct {
    border-color: rgba(89, 227, 167, 0.78);
    background: var(--success-soft);
    box-shadow: 0 18px 34px rgba(89, 227, 167, 0.18);
}

.option-item.correct::after {
    opacity: 1;
    animation: revealSweep 700ms ease;
}

.option-item.incorrect {
    border-color: rgba(255, 116, 116, 0.78);
    background: var(--error-soft);
    box-shadow: 0 14px 28px rgba(255, 116, 116, 0.14);
}

.option-item.dimmed {
    opacity: 0.72;
}

.option-index {
    width: clamp(36px, 2.2vw, 42px);
    height: clamp(36px, 2.2vw, 42px);
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: rgba(255, 255, 255, 0.08);
    font-weight: 700;
    transition: background 220ms ease, color 220ms ease, transform 220ms ease;
}

.option-item.correct .option-index {
    background: rgba(89, 227, 167, 0.24);
    color: var(--success);
    transform: scale(1.04);
}

.option-item.incorrect .option-index {
    background: rgba(255, 116, 116, 0.2);
    color: #ffd1d1;
}

.option-label {
    font-size: clamp(0.98rem, 1.05vw, 1.1rem);
}

.option-state {
    color: var(--muted);
    font-size: clamp(0.82rem, 0.88vw, 0.92rem);
    font-weight: 700;
}

.option-state.correct-text {
    color: var(--success);
}

.option-state.incorrect-text {
    color: #ffbcbc;
}

.option-item.selected .option-state {
    color: var(--accent);
}

.result-panel,
.leaderboard-panel {
    margin-top: clamp(16px, 1.8vh, 26px);
    padding-top: clamp(16px, 1.8vh, 24px);
    border-top: 1px solid var(--line);
}

.result-panel:not([hidden]) {
    animation: panelLift 420ms cubic-bezier(0.22, 1, 0.36, 1);
}

.result-panel h3,
.leaderboard-panel h3,
.join-panel h3,
.roster-panel h3 {
    margin: 0 0 14px;
    font-size: clamp(1.05rem, 1.1vw, 1.25rem);
}

.result-panel h4 {
    margin: 18px 0 10px;
    color: var(--muted);
    font-size: 0.95rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.correct-answer {
    margin: 0;
    font-size: clamp(1rem, 1.05vw, 1.15rem);
    color: var(--success);
}

.name-list,
.leaderboard-list,
.participant-list {
    display: grid;
    gap: clamp(8px, 0.95vh, 12px);
    align-content: start;
    overflow: hidden;
}

.name-item,
.leaderboard-item,
.participant-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: clamp(10px, 1vh, 14px) clamp(12px, 1vw, 16px);
    border-radius: 16px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.04);
}

.name-item.correct-name {
    border-color: rgba(89, 227, 167, 0.52);
    background: rgba(89, 227, 167, 0.12);
    animation: optionRise 380ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

.leaderboard-item.winner {
    border-color: rgba(255, 209, 102, 0.72);
    background: rgba(255, 209, 102, 0.14);
    box-shadow: 0 16px 30px rgba(255, 209, 102, 0.16);
}

.leaderboard-rank {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: rgba(255, 209, 102, 0.16);
    color: var(--accent);
    font-weight: 700;
}

.participant-main,
.leaderboard-main {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.winner-badge {
    display: inline-flex;
    align-items: center;
    padding: 6px 10px;
    border-radius: 999px;
    background: rgba(255, 209, 102, 0.18);
    color: var(--accent);
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.participant-status,
.participant-score,
.leaderboard-score {
    color: var(--muted);
    font-size: clamp(0.84rem, 0.88vw, 0.93rem);
}

.participant-status.waiting {
    color: var(--accent);
}

.participant-status.answered,
.leaderboard-score strong {
    color: var(--accent-2);
}

.participant-status.inactive {
    color: var(--danger);
}

.side-column {
    display: grid;
    gap: clamp(12px, 1.3vw, 24px);
    grid-template-rows: auto minmax(0, 1fr);
    min-height: 0;
}

.join-panel {
    text-align: center;
}

.roster-panel {
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.qr-code {
    display: grid;
    place-items: center;
    height: clamp(136px, 10.5vw, 184px);
    width: clamp(136px, 10.5vw, 184px);
    margin: 10px auto;
    padding: 14px;
    border-radius: 22px;
    background: rgba(255, 255, 255, 0.96);
}

.qr-code img,
.qr-code canvas {
    max-width: 100%;
    height: auto;
}

.join-link {
    display: block;
    color: var(--text);
    word-break: break-all;
}

.join-copy {
    margin: 10px 0 0;
    color: var(--muted);
    font-size: clamp(0.86rem, 0.92vw, 0.96rem);
}

.empty-text {
    margin: 0;
    color: var(--muted);
}

@media (max-height: 1100px) {
    .hero-panel {
        gap: 18px;
    }

    .secondary-button {
        padding: 12px 18px;
    }

    .question-topbar,
    .question-meta,
    .roster-header {
        gap: 12px;
    }

    .phase-badge {
        padding: 8px 12px;
        font-size: 0.84rem;
    }

    .timer-label {
        font-size: 0.74rem;
    }

    .result-panel h4 {
        margin: 14px 0 8px;
        font-size: 0.86rem;
    }
}

@media (max-width: 820px) {
    .page-shell {
        padding: 10px;
        gap: 10px;
    }

    .hero-panel,
    .card {
        border-radius: 22px;
    }

    .hero-panel {
        padding: 14px 16px;
        gap: 14px;
    }

    .eyebrow {
        margin-bottom: 6px;
        font-size: 0.68rem;
        letter-spacing: 0.16em;
    }

    .hero-panel h1 {
        font-size: clamp(1.45rem, 4.2vw, 2rem);
    }

    .hero-copy {
        margin-top: 6px;
        font-size: 0.84rem;
    }

    .secondary-button {
        padding: 10px 14px;
        font-size: 0.86rem;
    }

    .hero-actions {
        justify-content: flex-start;
    }

    .content-grid {
        grid-template-columns: 1fr;
        grid-template-rows: minmax(0, 1.36fr) minmax(0, 0.64fr);
        gap: 10px;
    }

    .side-column {
        grid-template-columns: minmax(0, 0.84fr) minmax(0, 1.16fr);
        grid-template-rows: none;
        gap: 10px;
    }

    .card {
        padding: 14px;
    }

    .question-topbar,
    .question-meta,
    .roster-header {
        gap: 10px;
    }

    .phase-badge {
        padding: 7px 10px;
        font-size: 0.76rem;
    }

    .timer-label {
        font-size: 0.7rem;
    }

    .timer-value {
        font-size: clamp(1.85rem, 7vw, 2.8rem);
    }

    .question-title {
        margin: 12px 0 10px;
        font-size: clamp(1.3rem, 4vw, 1.95rem);
    }

    .option-list,
    .participant-list,
    .leaderboard-list {
        gap: 8px;
    }

    .option-item,
    .participant-item,
    .leaderboard-item {
        padding: 10px 12px;
        border-radius: 14px;
    }

    .option-index,
    .leaderboard-rank {
        width: 30px;
        height: 30px;
    }

    .option-label {
        font-size: 0.9rem;
    }

    .option-state,
    .participant-status,
    .participant-score,
    .leaderboard-score,
    .join-copy {
        font-size: 0.78rem;
    }

    .join-panel h3,
    .roster-panel h3,
    .leaderboard-panel h3 {
        margin-bottom: 10px;
        font-size: 1rem;
    }

    .qr-code {
        width: 124px;
        height: 124px;
        padding: 10px;
        margin: 8px auto;
        border-radius: 18px;
    }
}

@media (orientation: portrait) {
    .page-shell {
        max-width: min(1080px, 100vw);
    }

    .hero-panel {
        gap: 16px;
        align-items: flex-start;
    }

    .content-grid {
        grid-template-columns: 1fr;
        grid-template-rows: minmax(0, 1.28fr) minmax(0, 0.82fr);
    }

    .side-column {
        grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
        grid-template-rows: none;
    }

    .join-panel {
        display: flex;
        flex-direction: column;
        justify-content: center;
    }

    .qr-code {
        height: clamp(150px, 19vw, 210px);
        width: clamp(150px, 19vw, 210px);
    }
}

@media (max-width: 540px) {
    .page-shell {
        padding: 8px;
        gap: 8px;
    }

    .hero-panel,
    .card {
        border-radius: 18px;
    }

    .hero-panel {
        padding: 12px 13px;
        gap: 10px;
    }

    .hero-panel h1 {
        font-size: clamp(1.1rem, 5vw, 1.45rem);
    }

    .hero-copy {
        font-size: 0.74rem;
        line-height: 1.2;
    }

    .secondary-button {
        padding: 8px 11px;
        font-size: 0.78rem;
    }

    .hero-actions {
        gap: 8px;
    }

    .content-grid {
        grid-template-rows: minmax(0, 1.42fr) minmax(0, 0.58fr);
        gap: 8px;
    }

    .side-column {
        grid-template-columns: 1fr;
        gap: 8px;
    }

    .card {
        padding: 11px;
    }

    .question-topbar,
    .question-meta,
    .roster-header {
        gap: 8px;
    }

    .question-meta {
        font-size: 0.74rem;
    }

    .phase-badge {
        padding: 6px 9px;
        font-size: 0.68rem;
    }

    .timer-value {
        font-size: 1.6rem;
    }

    .question-title {
        margin: 10px 0 8px;
        font-size: clamp(1.02rem, 5.1vw, 1.32rem);
        line-height: 1.05;
    }

    .option-list,
    .participant-list,
    .leaderboard-list {
        gap: 6px;
    }

    .option-item,
    .participant-item,
    .leaderboard-item {
        gap: 8px;
        padding: 8px 9px;
        border-radius: 12px;
    }

    .option-index,
    .leaderboard-rank {
        width: 26px;
        height: 26px;
        font-size: 0.76rem;
    }

    .option-label {
        font-size: 0.78rem;
    }

    .option-state {
        font-size: 0.68rem;
    }

    .participant-status,
    .participant-score,
    .leaderboard-score {
        font-size: 0.7rem;
    }

    .participant-main,
    .leaderboard-main {
        gap: 8px;
    }

    .participant-item strong,
    .leaderboard-item strong {
        font-size: 0.82rem;
    }

    .winner-badge {
        padding: 4px 7px;
        font-size: 0.62rem;
    }

    .join-panel h3,
    .roster-panel h3,
    .leaderboard-panel h3 {
        margin-bottom: 8px;
        font-size: 0.86rem;
    }

    .join-copy {
        display: none;
    }

    .qr-code {
        width: 116px;
        height: 116px;
        padding: 8px;
        margin: 6px auto;
        border-radius: 14px;
    }

    .roster-panel {
        display: none;
    }
}

@media (max-height: 560px) and (orientation: landscape) {
    .page-shell {
        padding: 8px;
        gap: 8px;
    }

    .hero-panel,
    .card {
        border-radius: 18px;
    }

    .hero-panel {
        padding: 10px 12px;
        gap: 12px;
    }

    .eyebrow {
        margin-bottom: 4px;
        font-size: 0.64rem;
    }

    .hero-panel h1 {
        font-size: clamp(1.12rem, 2vw, 1.5rem);
    }

    .hero-copy {
        display: none;
    }

    .secondary-button {
        padding: 8px 12px;
        font-size: 0.78rem;
    }

    .hero-actions {
        gap: 8px;
    }

    .content-grid {
        grid-template-columns: minmax(0, 1.72fr) minmax(220px, 0.92fr);
        gap: 8px;
    }

    .side-column {
        gap: 8px;
        grid-template-rows: 1fr;
    }

    .card {
        padding: 10px;
    }

    .question-topbar,
    .question-meta,
    .roster-header {
        gap: 8px;
    }

    .question-meta {
        margin-top: 6px;
        font-size: 0.72rem;
    }

    .phase-badge {
        padding: 6px 9px;
        font-size: 0.66rem;
    }

    .timer-label {
        font-size: 0.64rem;
    }

    .timer-value {
        font-size: clamp(1.45rem, 3vw, 2rem);
    }

    .question-title {
        margin: 8px 0 7px;
        font-size: clamp(1rem, 2.2vw, 1.45rem);
    }

    .option-list,
    .participant-list,
    .leaderboard-list {
        gap: 5px;
    }

    .option-item,
    .participant-item,
    .leaderboard-item {
        gap: 8px;
        padding: 7px 8px;
        border-radius: 11px;
    }

    .option-index,
    .leaderboard-rank {
        width: 24px;
        height: 24px;
        font-size: 0.7rem;
    }

    .option-label {
        font-size: 0.74rem;
    }

    .option-state,
    .participant-status,
    .participant-score,
    .leaderboard-score {
        font-size: 0.66rem;
    }

    .participant-main,
    .leaderboard-main {
        gap: 7px;
    }

    .participant-item strong,
    .leaderboard-item strong {
        font-size: 0.76rem;
    }

    .winner-badge {
        padding: 3px 6px;
        font-size: 0.58rem;
    }

    .join-panel h3,
    .roster-panel h3,
    .leaderboard-panel h3 {
        margin-bottom: 7px;
        font-size: 0.82rem;
    }

    .join-copy {
        display: none;
    }

    .qr-code {
        width: 96px;
        height: 96px;
        padding: 6px;
        margin: 4px auto;
        border-radius: 12px;
    }

    .roster-panel {
        display: none;
    }
}

@keyframes titleSwap {
    0% {
        opacity: 0;
        transform: translateY(18px) scale(0.985);
        filter: blur(10px);
    }

    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
        filter: blur(0);
    }
}

@keyframes metaFade {
    0% {
        opacity: 0;
        transform: translateY(10px);
    }

    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes optionRise {
    0% {
        opacity: 0;
        transform: translateY(18px) scale(0.97);
    }

    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes panelLift {
    0% {
        opacity: 0;
        transform: translateY(16px);
    }

    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes revealSweep {
    0% {
        opacity: 0;
        transform: translateX(-55%);
    }

    25% {
        opacity: 1;
    }

    100% {
        opacity: 0;
        transform: translateX(55%);
    }
}

@media (max-width: 980px) {
    .hero-panel {
        flex-direction: column;
        align-items: stretch;
    }

    .secondary-button {
        align-self: flex-start;
    }

    .hero-actions {
        justify-content: flex-start;
    }
}

@media (max-width: 640px) {
    .question-topbar,
    .question-meta,
    .roster-header {
        flex-wrap: wrap;
        align-items: flex-start;
    }

    .timer-block {
        text-align: left;
    }
}
