:root {
    color: #17223b;
    background: #f3f5fc;
    font-family: "Segoe UI", system-ui, sans-serif;
    line-height: 1.5;
    --blue: #0066cc;
    --purple: #9966cc;
    --border: #c8c8c8;
    --page-gutter: clamp(1rem, 2vw, 3rem);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
h1, h2, button { font-weight: 600; }
h2 { margin: 0 0 .65rem; }
p { margin: .45rem 0; }

.masthead {
    display: flex;
    align-items: center;
    gap: .65rem;
    border-bottom: .35rem solid transparent;
    border-image: linear-gradient(90deg, var(--blue), var(--purple)) 1;
    color: white;
    background: #17223b;
    padding: 1rem var(--page-gutter);
}

.masthead h1 { font-size: clamp(2rem, 5vw, 2.75rem); line-height: 1; margin: .15em 0; }
.masthead-intro p { margin: 0; }
.masthead-logo { flex: none; height: auto; }
.eyebrow { font-size: .85rem; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; }
main { display: grid; grid-template-columns: minmax(0, 1fr); align-items: start; gap: 1rem; padding: 1rem var(--page-gutter); }
.build-version { padding: 0 var(--page-gutter) 1rem; color: #445273; font-size: .85rem; overflow-wrap: anywhere; }

section {
    background: white;
    border: 1px solid var(--border);
    border-radius: .65rem;
    padding: clamp(1rem, 2vw, 1.5rem);
}

form { display: grid; gap: .65rem; grid-template-columns: minmax(0, 1fr) auto; align-items: end; margin-top: 1rem; }
label { grid-column: 1 / -1; font-weight: 600; }
input, select, button { font: inherit; border-radius: .4rem; min-height: 2.75rem; }
input, select { border: 1px solid #6e778b; color: inherit; padding: .5rem .7rem; width: 100%; }
button { background: var(--blue); border: 1px solid transparent; color: white; cursor: pointer; padding: .5rem .9rem; }
button.secondary { background: #eaf2fe; border-color: #9ebbe2; color: #183863; }
button:disabled, button.secondary:disabled { background: #eceef2; color: #4c5363; border-color: #c9cdd5; cursor: default; }
:is(button, input, select):focus-visible { outline: 3px solid #7043b0; outline-offset: 3px; }

#invite-form { margin-bottom: .75rem; }
#invite-qr { display: grid; justify-items: center; gap: .35rem; max-width: 100%; margin: .5rem 0 .75rem; }
#invite-qr-image { display: block; max-width: 100%; height: auto; image-rendering: pixelated; }
#invite-teams { display: block; margin-bottom: .75rem; }
#question-packs { min-inline-size: 0; margin: 1rem 0 0; border: 1px solid var(--border); border-radius: .4rem; }
#question-packs legend { font-weight: 600; }
#pack-options { display: flex; flex-wrap: wrap; gap: .35rem 1rem; }
#pack-options label { display: flex; align-items: center; gap: .4rem; min-height: 2rem; font-weight: 400; }
#pack-options input { width: 1rem; height: 1rem; min-height: auto; margin: 0; }
#scheduled-start { background: #eaf2fe; border-radius: .5rem; padding: .5rem .75rem; }
#lobby-timer { font-size: 1.35rem; font-weight: 600; font-variant-numeric: tabular-nums; }
#cancel-start { grid-column: 1 / -1; justify-self: start; }

.round-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: .75rem;
    background: var(--phase-accent, #264988);
    color: white;
    border-radius: .5rem;
    margin-bottom: 1rem;
    padding: .8rem 1rem;
}

#round[data-phase="Writing"] { --phase-accent: #62348a; }
#round[data-phase="Voting"] { --phase-accent: #8b3c05; }
#round[data-phase="Reveal"] { --phase-accent: #166043; }
#round[data-phase="Intermission"] { --phase-accent: #445273; }
.round-header .eyebrow { margin: 0 0 .2rem; }
#phase { font-size: clamp(1.25rem, 5vw, 1.85rem); line-height: 1.15; margin: 0; }
#timer {
    font-size: 1.35rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    border: 1px solid currentColor;
    border-radius: .4rem;
    margin: 0;
    padding: .2rem .5rem;
}

#prompt { overflow-wrap: anywhere; font-size: clamp(1.25rem, 5vw, 1.75rem); line-height: 1.25; margin: .4rem 0 1rem; }
#explanation { overflow-wrap: anywhere; }
ol, ul { padding-inline-start: 1.4rem; overflow-wrap: anywhere; }
li { margin-block: .4rem; }
li button { width: 100%; text-align: left; overflow-wrap: anywhere; }
#answers button { text-transform: uppercase; }
li small { display: block; color: #445273; }
.truth { font-weight: 600; color: #165532; }
#error { color: #821f33; background: #ffeff2; border-radius: .4rem; padding: .75rem; }

@media (max-width: 30rem) {
    form { grid-template-columns: minmax(0, 1fr); }
}

@media (min-width: 40rem) {
    #answers, #choices {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        align-items: start;
        gap: .5rem 1.5rem;
        line-height: 1.25;
    }

    #answers li, #choices li { margin-block: 0; }
}

@media (min-width: 64rem) {
    main { grid-template-columns: minmax(0, 1fr) clamp(19rem, 30%, 30rem); }
    main > * { grid-column: 1 / -1; }
    #join, #lobby, #round { grid-column: 1; }
    main:has(> :is(#join, #lobby, #round):not([hidden])) > #standings,
    main:has(> #join:not([hidden])):not(:has(> #standings:not([hidden]))) > #rules {
        grid-column: 2;
    }

    #standings { container-type: inline-size; }
    #players { line-height: 1.25; }
    #players li { margin-block: .3rem; }
    #rules > :is(p, ol) { max-inline-size: 80ch; }
    .round-header > div { display: flex; align-items: baseline; flex-wrap: wrap; gap: 0 1rem; }
}

@container (min-width: 44rem) {
    #players {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(19rem, 1fr));
        align-items: start;
        gap: .5rem 2rem;
    }

    #players li { margin-block: 0; }
}

@media (min-width: 85rem) {
    #answers, #choices {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        margin-block: 0 .5rem;
    }
}

@media (min-width: 100rem) {
    .round-results:has(> #choices:not([hidden])) {
        display: grid;
        grid-template-columns: minmax(0, 4fr) minmax(0, 3fr);
        align-items: start;
        column-gap: 1.5rem;
    }

    .round-results:has(> #choices:not([hidden])) :is(#answers, #choices) {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}
