:root {
    --ink: #12323b;
    --muted: #58727a;
    --ocean: #087f8c;
    --ocean-dark: #075967;
    --sky: #dff5f5;
    --sand: #fff5d6;
    --sun: #ffca3a;
    --coral: #f25f5c;
    --leaf: #2a9d65;
    --white: #fff;
    --shadow: 0 18px 50px rgba(7, 59, 76, .13);
    --radius: 22px;
}

* { box-sizing: border-box; }

html {
    min-height: 100%;
    color: var(--ink);
    background: #f9fcf8;
    font-family: Inter, ui-rounded, "Segoe UI", system-ui, -apple-system, sans-serif;
}

body {
    margin: 0;
    min-height: 100vh;
    background:
        radial-gradient(circle at 9% 12%, rgba(255, 202, 58, .22) 0 90px, transparent 91px),
        linear-gradient(180deg, #e8f8f3 0, #f9fcf8 42%, #fff9e9 100%);
}

button, input { font: inherit; }
a { color: var(--ocean-dark); }

.skip-link {
    position: absolute;
    left: -9999px;
    z-index: 20;
    padding: .75rem 1rem;
    background: var(--ink);
    color: var(--white);
}

.skip-link:focus { left: .5rem; top: .5rem; }

.site-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    max-width: 1180px;
    margin: 0 auto;
    padding: 1rem clamp(1rem, 4vw, 2rem);
}

.brand {
    color: var(--ink);
    font-size: 1.1rem;
    font-weight: 850;
    letter-spacing: -.02em;
    text-decoration: none;
}

.host-link {
    padding: .55rem .9rem;
    border-radius: 999px;
    color: var(--ocean-dark);
    font-size: .9rem;
    font-weight: 750;
    text-decoration: none;
}

.host-link:hover { background: rgba(8, 127, 140, .1); }

.page-shell {
    width: min(1100px, calc(100% - 2rem));
    margin: 1.5rem auto 4rem;
}

.hero {
    position: relative;
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    max-width: 790px;
    margin: 2rem auto 1.4rem;
    overflow: hidden;
    padding: clamp(1.75rem, 5vw, 3.8rem);
    border-radius: 32px;
    color: var(--white);
    background:
        linear-gradient(130deg, rgba(8, 127, 140, .96), rgba(7, 89, 103, .98)),
        repeating-linear-gradient(45deg, transparent, transparent 14px, rgba(255,255,255,.05) 15px);
    box-shadow: var(--shadow);
}

.hero::after {
    content: "";
    position: absolute;
    right: -45px;
    bottom: -72px;
    width: 235px;
    height: 135px;
    border-radius: 50%;
    background: #d4a65d;
    box-shadow: -65px -15px 0 #e8c780;
    transform: rotate(-8deg);
    opacity: .35;
}

.hero h1 {
    max-width: 590px;
    margin: .2rem 0 .65rem;
    font-size: clamp(2.15rem, 6vw, 4rem);
    line-height: .98;
    letter-spacing: -.055em;
}

.hero p:not(.eyebrow) {
    max-width: 550px;
    margin: 0;
    color: #e7ffff;
    font-size: 1.08rem;
}

.sun {
    position: relative;
    z-index: 1;
    font-size: clamp(3.5rem, 10vw, 6rem);
    filter: drop-shadow(0 8px 15px rgba(0,0,0,.14));
}

.eyebrow {
    margin: 0 0 .45rem;
    color: var(--ocean);
    font-size: .75rem;
    font-weight: 850;
    letter-spacing: .13em;
    text-transform: uppercase;
}

.hero .eyebrow { color: #b9ffff; }

h1, h2, h3 { letter-spacing: -.025em; }
h1 { margin: .2rem 0 1.2rem; font-size: clamp(2rem, 5vw, 3.4rem); }
h2 { margin: .2rem 0 1rem; font-size: clamp(1.5rem, 4vw, 2.25rem); }
h3 { margin: .4rem 0; }
p { line-height: 1.55; }

.card {
    border: 1px solid rgba(7, 89, 103, .1);
    border-radius: var(--radius);
    background: rgba(255,255,255,.94);
    box-shadow: var(--shadow);
}

.join-card {
    width: min(520px, 100%);
    margin: -2.6rem auto 0;
    position: relative;
    z-index: 2;
    padding: clamp(1.35rem, 5vw, 2.25rem);
}

.stack { display: grid; gap: .75rem; }

label, legend {
    font-weight: 750;
}

input {
    width: 100%;
    min-height: 50px;
    padding: .75rem 1rem;
    border: 2px solid #c8d9d9;
    border-radius: 12px;
    color: var(--ink);
    background: var(--white);
}

input:focus {
    border-color: var(--ocean);
    outline: 3px solid rgba(8, 127, 140, .18);
}

.pin-input {
    font-size: 1.45rem;
    font-weight: 850;
    letter-spacing: .18em;
    text-align: center;
}

.button {
    display: inline-flex;
    min-height: 46px;
    align-items: center;
    justify-content: center;
    gap: .5rem;
    padding: .75rem 1.15rem;
    border: 0;
    border-radius: 12px;
    font-weight: 850;
    text-decoration: none;
    cursor: pointer;
}

.button:focus-visible, .answer-button:focus-visible, .mini-button:focus-visible {
    outline: 4px solid rgba(255, 202, 58, .7);
    outline-offset: 3px;
}

.button:disabled { cursor: not-allowed; opacity: .45; }
.button-large { min-height: 56px; font-size: 1.06rem; }
.button-primary { color: var(--white); background: var(--ocean-dark); }
.button-primary:hover { background: #03434f; }
.button-quiet { color: var(--ocean-dark); background: rgba(8,127,140,.1); }
.button-warn { color: #332600; background: var(--sun); }
.button-danger { color: var(--white); background: #a42e35; }
.button-stop { color: #762027; border: 2px solid #c96d72; background: #fff4f4; }
.button-stop:hover { background: #ffe7e7; }

.notice {
    margin: 0 0 1rem;
    padding: .85rem 1rem;
    border-left: 5px solid;
    border-radius: 10px;
    line-height: 1.45;
}

.notice-error { border-color: #a42e35; color: #762027; background: #fff0f0; }
.notice-success { border-color: var(--leaf); color: #125934; background: #e9faef; }
.live-note { display: flex; align-items: center; gap: .5rem; font-weight: 700; }
.live-dot { width: .65rem; height: .65rem; border-radius: 50%; background: var(--leaf); }

.narrow { width: min(520px, 100%); margin: 4rem auto; }
.narrow > .card { padding: clamp(1.3rem, 5vw, 2rem); }
.error-card { text-align: center; }
.error-icon, .big-icon { font-size: 3.4rem; }
code { padding: .12rem .3rem; border-radius: 5px; background: #e9f1ef; }

.game-topline, .host-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
}

.host-heading-actions { display: flex; align-items: center; gap: .6rem; }

.game-topline h1, .host-heading h1 { margin: 0; font-size: clamp(1.7rem, 5vw, 2.6rem); }

.connection {
    display: flex;
    align-items: center;
    gap: .4rem;
    padding: .45rem .7rem;
    border-radius: 999px;
    color: #355b63;
    background: #e4efed;
    font-size: .8rem;
    font-weight: 800;
}

.connection::before { content: ""; width: .5rem; height: .5rem; border-radius: 50%; background: #789095; }
.connection-online::before { background: var(--leaf); }
.connection-offline { color: #762027; background: #ffe9e9; }
.connection-offline::before { background: var(--coral); }

.game-card {
    width: min(850px, 100%);
    min-height: 390px;
    margin: 0 auto;
    overflow: hidden;
    padding: clamp(1.15rem, 4vw, 2.2rem);
}

.loading, .center-state {
    display: flex;
    min-height: 300px;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.center-state.compact { min-height: 180px; }

.spinner {
    width: 36px;
    height: 36px;
    border: 4px solid #d5e6e3;
    border-top-color: var(--ocean);
    border-radius: 50%;
    animation: spin .9s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
    .spinner { animation: none; border-top-color: #d5e6e3; }
}

.player-strip, .question-meta, .section-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.player-strip {
    margin: -1rem -1rem 1.4rem;
    padding: .8rem 1rem;
    border-radius: 14px;
    background: #edf7f5;
    color: #365e65;
}

.score-pill, .count-badge {
    flex: none;
    padding: .35rem .7rem;
    border-radius: 999px;
    color: var(--ocean-dark);
    background: var(--white);
    font-weight: 850;
}

.question-meta {
    margin-bottom: .9rem;
    color: var(--muted);
    font-weight: 800;
}

.timer {
    min-width: 58px;
    padding: .35rem .65rem;
    border-radius: 999px;
    color: var(--ocean-dark);
    background: var(--sky);
    text-align: center;
}

.timer-low { color: #762027; background: #ffe6e6; }
.question-image { display: block; width: 100%; max-height: 330px; object-fit: cover; border-radius: 17px; }
.question-title { margin-top: 1.25rem; text-align: center; }
.question-text { color: var(--muted); font-size: 1.08rem; text-align: center; white-space: pre-line; }

.answer-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: .85rem;
    margin-top: 1.3rem;
}

.answer-button, .answer-option {
    display: flex;
    min-height: 88px;
    align-items: center;
    gap: .8rem;
    padding: 1rem;
    border: 2px solid transparent;
    border-radius: 15px;
    color: var(--white);
    font-size: 1rem;
    font-weight: 800;
    text-align: left;
}

.answer-button { cursor: pointer; box-shadow: 0 5px 0 rgba(0,0,0,.17); }
.answer-button:hover { filter: brightness(.94); transform: translateY(1px); }
.answer-button:disabled { cursor: not-allowed; filter: grayscale(.4); opacity: .6; }
.answer-0 { background: #bd3e49; }
.answer-1 { background: #1479a7; }
.answer-2 { background: #a77509; }
.answer-3 { background: #24784b; }
.option-shape { flex: none; font-size: 1.35rem; }

.reveal-grid .answer-option { color: var(--ink); background: #edf2f1; }
.reveal-grid .is-correct { border-color: var(--leaf); background: #e6f8ed; }
.reveal-grid .is-chosen:not(.is-correct) { border-color: var(--coral); background: #fff0f0; }
.answer-label { margin-left: auto; font-size: .78rem; }

.open-answer { max-width: 580px; margin: 1.5rem auto 0; }
.open-answer input { min-height: 58px; font-size: 1.2rem; }
.upload-answer input[type="file"] { padding: .65rem; font-size: 1rem; }
.field-hint { margin: -.2rem 0 .2rem; color: var(--muted); font-size: .88rem; }
.form-error { min-height: 1.2em; margin: 0; color: #8b242b; font-weight: 700; }

.paste-target {
    display: grid;
    min-height: 130px;
    place-items: center;
    gap: .3rem;
    padding: 1rem;
    border: 2px dashed #9cbfbd;
    border-radius: 14px;
    color: var(--muted);
    background: #f3faf8;
    text-align: center;
}

.paste-target strong { color: var(--ocean-dark); font-size: 1.05rem; }
.paste-target:focus { border-color: var(--ocean); outline: 3px solid rgba(8, 127, 140, .18); }
.paste-target.has-image { border-style: solid; border-color: var(--leaf); background: #edf9f1; }
.upload-preview { display: block; max-width: 100%; max-height: 190px; margin-top: .5rem; border-radius: 9px; object-fit: contain; }
.upload-preview[hidden] { display: none; }
.upload-selection { overflow-wrap: anywhere; font-size: .82rem; }
.upload-divider { display: flex; align-items: center; gap: .7rem; color: var(--muted); font-size: .8rem; text-transform: uppercase; }
.upload-divider::before, .upload-divider::after { content: ""; height: 1px; flex: 1; background: #d5e3e0; }

.received {
    max-width: 560px;
    margin: 1.5rem auto 0;
    padding: 1.4rem;
    border-radius: 16px;
    background: #eaf8ef;
    text-align: center;
}

.received-check {
    display: inline-grid;
    width: 42px;
    height: 42px;
    place-items: center;
    border-radius: 50%;
    color: var(--white);
    background: var(--leaf);
    font-size: 1.45rem;
    font-weight: 900;
}

.received p, .received h3 { margin-bottom: 0; }

.result {
    display: flex;
    max-width: 620px;
    align-items: center;
    gap: 1rem;
    margin: 1.3rem auto;
    padding: 1rem 1.2rem;
    border: 2px solid;
    border-radius: 16px;
}

.result-correct { border-color: var(--leaf); background: #e7f8ed; }
.result-wrong { border-color: var(--coral); background: #fff0f0; }
.result-symbol { font-size: 2rem; font-weight: 900; }
.result p { margin: .2rem 0 0; }
.explanation, .accepted, .correct-answer { padding: 1rem; border-radius: 12px; background: var(--sand); }
.info-slide { max-width: 620px; margin: 1.4rem auto; padding: 1.3rem; border-radius: 17px; background: var(--sand); text-align: center; }
.info-slide span { font-size: 2.7rem; }
.waiting-note { margin: 1.3rem 0 0; color: var(--muted); text-align: center; }

.waiting-dots { display: flex; gap: .35rem; margin-top: 1rem; }
.waiting-dots span { width: .6rem; height: .6rem; border-radius: 50%; background: var(--ocean); opacity: .55; }

.table-wrap { overflow-x: auto; }
.leaderboard { width: 100%; border-collapse: collapse; }
.leaderboard th, .leaderboard td { padding: .8rem .65rem; border-bottom: 1px solid #dce9e6; text-align: left; }
.leaderboard th { color: var(--muted); font-size: .76rem; letter-spacing: .06em; text-transform: uppercase; }
.leaderboard td:nth-child(3), .leaderboard th:nth-child(3),
.leaderboard td:nth-child(4), .leaderboard th:nth-child(4) { text-align: right; }
.leaderboard .is-current-player { background: #fff8dc; }
.rank-badge { display: inline-grid; width: 30px; height: 30px; place-items: center; border-radius: 50%; background: #e7f2ef; font-weight: 850; }
.you-label { color: var(--muted); font-size: .8rem; }

.pin-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
    margin-bottom: 1rem;
    padding: 1rem 1.4rem;
    border-radius: 18px;
    color: var(--white);
    background: var(--ocean-dark);
    box-shadow: var(--shadow);
}

.pin-banner > div:first-child { display: flex; align-items: baseline; gap: .8rem; }
.pin-banner strong { color: var(--sun); font-size: 2rem; letter-spacing: .12em; }
.join-url { overflow-wrap: anywhere; text-align: right; }
.join-url a { color: var(--white); }

.host-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.8fr) minmax(270px, .8fr);
    gap: 1rem;
}

.host-stage, .roster { padding: clamp(1.1rem, 3vw, 1.7rem); }
.host-stage { min-height: 420px; }
.host-stage .question-image { max-height: 270px; }
.host-controls {
    position: sticky;
    z-index: 4;
    top: .75rem;
    display: flex;
    min-height: 62px;
    align-items: center;
    justify-content: flex-end;
    margin: -.35rem -.35rem 1.4rem;
    padding: .5rem;
    border: 1px solid rgba(7, 89, 103, .12);
    border-radius: 14px;
    background: rgba(255, 255, 255, .96);
    box-shadow: 0 8px 24px rgba(7, 59, 76, .1);
    backdrop-filter: blur(8px);
}
.control-group { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: .65rem; }
.host-progress { display: flex; align-items: baseline; gap: .5rem; margin: 1rem 0; color: var(--muted); }
.host-progress strong { color: var(--ocean-dark); font-size: 1.6rem; }
.finished-label { padding: .8rem 1rem; border-radius: 10px; background: #e9f7ee; font-weight: 850; }

.player-list { margin: .8rem 0 0; padding: 0; list-style: none; }
.player-list li { display: flex; justify-content: space-between; gap: .7rem; padding: .75rem 0; border-bottom: 1px solid #e1ece9; }
.player-list strong { flex: none; color: var(--ocean-dark); font-size: .86rem; }
.empty-state { padding: 2rem .5rem; color: var(--muted); text-align: center; }
.empty-state span { font-size: 2.5rem; }

.manual-review { margin-top: 1.2rem; padding-top: 1rem; border-top: 1px solid #d8e6e3; }
.review-row { display: grid; grid-template-columns: 1fr auto; gap: .6rem 1rem; align-items: center; padding: .8rem 0; border-bottom: 1px solid #e1ece9; }
.review-row > div { display: grid; gap: .2rem; }
.review-row > div span { color: var(--muted); }
.review-submission { min-width: 0; }
.review-actions { display: flex; gap: .35rem; }
.mini-button { padding: .45rem .6rem; border: 1px solid; border-radius: 8px; background: var(--white); font-weight: 800; cursor: pointer; }
.correct-button { border-color: var(--leaf); color: #126238; }
.wrong-button { border-color: var(--coral); color: #8a242b; }
.reviewed-tag, .pending-tag { grid-column: 1 / -1; font-size: .75rem; font-weight: 800; }
.reviewed-tag { color: var(--leaf); }
.pending-tag { color: #8b5b00; }

.media-preview-button {
    display: block;
    width: min(210px, 100%);
    margin: .4rem 0;
    overflow: hidden;
    padding: 0;
    border: 2px solid #cadbd8;
    border-radius: 10px;
    background: #edf3f2;
    cursor: zoom-in;
}

.media-preview-button:hover { border-color: var(--ocean); }
.media-preview-button:focus-visible { outline: 4px solid rgba(255, 202, 58, .7); outline-offset: 3px; }
.media-preview-button img { display: block; width: 100%; height: 125px; object-fit: cover; }

.image-review-dialog {
    width: min(96vw, 1400px);
    max-width: none;
    max-height: 95vh;
    margin: auto;
    padding: 1rem;
    border: 0;
    border-radius: 18px;
    background: var(--white);
    box-shadow: 0 25px 90px rgba(0, 30, 37, .45);
}

.image-review-dialog::backdrop { background: rgba(3, 25, 31, .78); }
.image-review-heading { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: .75rem; }
.image-review-heading h2 { margin: 0; font-size: clamp(1.2rem, 3vw, 1.7rem); }
.image-review-dialog > img {
    display: block;
    width: auto;
    max-width: 100%;
    height: auto;
    max-height: calc(95vh - 95px);
    margin: auto;
    object-fit: contain;
}

.danger-zone { margin-top: 1.2rem; padding: 1rem; border: 1px solid #e3c4c4; border-radius: 14px; background: rgba(255,255,255,.7); }
.danger-zone summary { color: #85272e; font-weight: 800; cursor: pointer; }
.inline-form { display: grid; grid-template-columns: 1fr auto; gap: .7rem; align-items: end; margin-top: 1rem; }
.inline-form label { grid-column: 1 / -1; }

.quiz-list { display: grid; gap: .6rem; padding: 0; border: 0; }
.quiz-list legend { margin-bottom: .65rem; }
.quiz-choice { display: flex; gap: .8rem; align-items: flex-start; padding: .9rem; border: 2px solid #d9e6e3; border-radius: 12px; cursor: pointer; }
.quiz-choice:has(input:checked) { border-color: var(--ocean); background: #eaf7f5; }
.quiz-choice input { width: 1.15rem; min-height: auto; margin-top: .2rem; }
.quiz-choice span { display: grid; gap: .2rem; }
.quiz-choice small { color: var(--muted); font-weight: 500; }
.quiz-invalid { cursor: not-allowed; background: #fff1f1; }
.quiz-choice .error-text { color: #8b242b; }
.muted { color: var(--muted); }

.question-deck { grid-column: 1 / -1; padding: clamp(1.1rem, 3vw, 1.7rem); }
.question-list { display: grid; gap: .6rem; margin-top: 1rem; }
.question-preview { border: 1px solid #d7e5e2; border-radius: 12px; overflow: hidden; }
.question-preview.is-current-question { border: 2px solid var(--ocean); }
.question-preview summary { display: flex; align-items: center; gap: .8rem; padding: .8rem 1rem; cursor: pointer; list-style: none; }
.question-preview summary::-webkit-details-marker { display: none; }
.question-preview summary > span:nth-child(2) { display: grid; flex: 1; gap: .15rem; }
.question-preview summary small { color: var(--muted); text-transform: capitalize; }
.question-number { display: inline-grid; width: 32px; height: 32px; flex: none; place-items: center; border-radius: 50%; background: #e7f2ef; font-weight: 850; }
.current-tag { padding: .25rem .55rem; border-radius: 999px; color: var(--white); background: var(--ocean); font-size: .72rem; font-weight: 850; }
.preview-body { padding: 0 1rem 1rem 3.9rem; color: var(--muted); }
.preview-body .question-image { max-width: 520px; max-height: 220px; margin: .8rem 0; }
.preview-options { display: grid; gap: .35rem; padding: 0; list-style: none; }
.preview-options li { padding: .55rem .7rem; border-radius: 8px; background: #f1f5f4; }
.preview-options .preview-correct { color: #125934; background: #e5f7ec; }
.preview-meta { font-size: .82rem; font-weight: 750; }

@media (max-width: 760px) {
    .page-shell { width: min(100% - 1rem, 1100px); margin-top: .5rem; }
    .hero { margin-top: .5rem; padding: 2rem 1.4rem 3.8rem; }
    .sun { position: absolute; right: 1rem; bottom: .2rem; font-size: 3.5rem; }
    .join-card { margin-top: -2.2rem; }
    .host-grid { grid-template-columns: 1fr; }
    .pin-banner { align-items: flex-start; flex-direction: column; }
    .join-url { text-align: left; }
}

@media (max-width: 560px) {
    .site-header { padding: .8rem; }
    .answer-grid { grid-template-columns: 1fr; }
    .answer-button { min-height: 70px; }
    .game-card { padding: 1rem; border-radius: 17px; }
    .player-strip { margin: -.4rem -.4rem 1.2rem; }
    .question-image { max-height: 245px; }
    .leaderboard th, .leaderboard td { padding: .68rem .35rem; }
    .review-row { grid-template-columns: 1fr; }
    .review-actions { flex-wrap: wrap; }
    .inline-form { grid-template-columns: 1fr; }
    .preview-body { padding-left: 1rem; }
}
