@font-face {
    font-family: Inter;
    src: url("/fonts/inter-latin-variable.woff2") format("woff2");
    font-weight: 100 900;
    font-display: swap;
}

:root {
    color-scheme: dark;
    --gather-bg: #0b0f19;
    --gather-panel: #121a2a;
    --gather-surface: #1a2539;
    --gather-line: #63708a;
    --gather-border: #31415c;
    --gather-text: #f8fafc;
    --gather-muted: #b7c4d6;
    --gather-gold: #e6bd59;
    --gather-gold-bright: #f2d388;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
    margin: 0;
    background: var(--gather-bg);
    color: var(--gather-text);
    font: 16px/1.55 Inter, system-ui, sans-serif;
    -webkit-tap-highlight-color: transparent;
}
h1, h2, h3, p { margin: 0; }
h1, h2, h3 { line-height: 1.14; overflow-wrap: anywhere; }
h1 { font-size: clamp(1.8rem, 4.5vw, 3.3rem); letter-spacing: -.035em; }
h2 { font-size: clamp(1.2rem, 3vw, 1.65rem); letter-spacing: -.02em; }
h3 { font-size: 1.1rem; }
a { color: var(--gather-gold-bright); text-underline-offset: .22em; }
:focus-visible { outline: 3px solid var(--gather-gold-bright); outline-offset: 4px; }

.gather-shell {
    max-width: 78rem;
    margin: 0 auto;
    padding: max(1rem, env(safe-area-inset-top)) max(1rem, env(safe-area-inset-right)) max(2rem, env(safe-area-inset-bottom)) max(1rem, env(safe-area-inset-left));
}
.gather-phone .gather-shell { max-width: 52rem; }
.gather-header {
    min-height: 3rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding-bottom: .75rem;
    border-bottom: 1px solid var(--gather-border);
    color: var(--gather-muted);
}
.gather-brand {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    gap: .6rem;
    color: var(--gather-text);
    font-weight: 750;
    letter-spacing: -.035em;
    text-decoration: none;
}
.gather-main { margin-top: 1rem; }
.gather-status {
    margin: 0 0 1rem;
    color: var(--gather-gold-bright);
    font-weight: 600;
    overflow-wrap: anywhere;
}
.gather-status:empty { display: none; }
.gather-muted { color: var(--gather-muted); }
.gather-panel {
    border: 1px solid var(--gather-border);
    border-radius: 1rem;
    background: var(--gather-panel);
}
.gather-panel-body {
    display: grid;
    gap: .9rem;
    padding: clamp(1rem, 3vw, 1.6rem);
}
.gather-form { display: grid; gap: .55rem; }
.gather-form label { font-size: .91rem; font-weight: 650; }
.gather-form input, .gather-form select, .gather-display-card select {
    min-width: 0;
    min-height: 48px;
    max-width: 100%;
    padding: .65rem .8rem;
    border: 1px solid var(--gather-line);
    border-radius: .55rem;
    background: var(--gather-bg);
    color: var(--gather-text);
    font: inherit;
}
.gather-form button[type=submit] { justify-self: start; }
.gather-button {
    min-height: 48px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: .65rem 1rem;
    border: 1px solid var(--gather-line);
    border-radius: .65rem;
    background: var(--gather-surface);
    color: var(--gather-text);
    text-align: center;
    text-decoration: none;
    font: inherit;
    font-weight: 650;
    cursor: pointer;
}
.gather-button:hover { border-color: var(--gather-gold); }
.gather-button:disabled { opacity: .55; cursor: default; }
.gather-primary { background: var(--gather-gold); color: var(--gather-bg); border-color: var(--gather-gold); }
.gather-primary:hover:not(:disabled) { background: var(--gather-gold-bright); }
.gather-quiet { background: transparent; color: var(--gather-muted); }
.gather-actions { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem; }
.gather-room, .gather-control-list { display: grid; gap: .8rem; }
.gather-control-list:empty { display: none; }
.gather-section-heading, .gather-display-heading {
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    align-items: baseline;
    gap: .55rem 1rem;
}
.gather-phone-question {
    font-size: 1.15rem;
    font-weight: 600;
    overflow-wrap: anywhere;
}
.gather-display-card {
    display: grid;
    gap: .6rem;
    padding: .9rem;
    border: 1px solid var(--gather-border);
    border-radius: .75rem;
}
.gather-display-card .gather-actions { align-items: end; }
.gather-display-card label {
    display: grid;
    gap: .3rem;
    min-width: 0;
    max-width: 100%;
}
.gather-phone video { display: block; width: min(100%, 17rem); border-radius: .65rem; background: #070a10; }
.gather-phone details summary { cursor: pointer; font-weight: 650; }
.gather-phone details p { margin-top: .7rem; }
.gather-game-area {
    position: fixed;
    inset: 0;
    width: min(62rem, calc(100% - 1rem));
    height: calc(100% - 1rem);
    max-height: calc(100% - 1rem);
    margin: auto;
    padding: .75rem;
    border: 1px solid var(--gather-line);
    border-radius: .8rem;
    background: var(--gather-panel);
    color: var(--gather-text);
}
.gather-game-area[open] { display: grid; grid-template-rows: auto minmax(0, 1fr); gap: .75rem; }
.gather-game-area:not([open]) { display: none; }
.gather-game-area::backdrop { background: rgba(0, 0, 0, .78); }
.gather-game-area iframe {
    width: 100%;
    height: 100%;
    min-height: 0;
    border: 1px solid var(--gather-border);
    border-radius: .65rem;
    background: var(--gather-bg);
}
.gather-phone pre {
    margin: .6rem 0;
    padding: .8rem;
    border-radius: .5rem;
    background: var(--gather-bg);
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.gather-cast {
    --cast-text: clamp(1rem, 2.8vmin, 3.75rem);
    --cast-gap: calc(var(--cast-text) * .8);
    font-size: var(--cast-text);
    line-height: 1.35;
}
.gather-cast .gather-shell {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    max-width: none;
    padding: max(1rem, 5vh, env(safe-area-inset-top)) max(1rem, 5vw, env(safe-area-inset-right))
             max(1rem, 5vh, env(safe-area-inset-bottom)) max(1rem, 5vw, env(safe-area-inset-left));
}
.gather-cast .gather-header {
    min-height: 0;
    flex-wrap: wrap;
    gap: calc(var(--cast-gap) * .5) var(--cast-gap);
    padding-bottom: calc(var(--cast-gap) * .7);
}
.gather-cast .gather-brand { min-height: 2rem; }
.gather-cast .gather-brand img { width: calc(var(--cast-text) * 1.35); height: auto; }
.gather-cast .gather-status { max-width: 65ch; margin: 0; }
.gather-cast .gather-main { margin-top: var(--cast-gap); }
.gather-cast .gather-main, .gather-cast #gather-app, .gather-connected {
    display: flex;
    flex: 1;
    flex-direction: column;
}
.gather-cast a:focus, .gather-cast button:focus {
    outline: 4px solid var(--gather-gold-bright);
    outline-offset: 5px;
}
.gather-cast .gather-button { min-height: max(48px, calc(var(--cast-text) * 2.4)); }
.gather-pair-panel {
    display: grid;
    align-items: center;
    gap: calc(var(--cast-gap) * 1.7);
    width: min(100%, calc(var(--cast-text) * 53));
    margin: auto;
    padding: calc(var(--cast-text) * 1.55);
}
.gather-pair-copy { display: grid; justify-items: start; gap: calc(var(--cast-gap) * .9); }
.gather-pair-copy h1 { font-size: calc(var(--cast-text) * 2.5); }
.gather-pair-copy p { max-width: 33ch; color: var(--gather-muted); }
.gather-pair-copy a { padding: .4em 0; font-weight: 650; }
.gather-pair-details { display: grid; justify-items: center; gap: .22em; text-align: center; }
.gather-qr {
    --cast-qr-size: clamp(8rem, 32vmin, 44rem);
    margin-bottom: .35em;
    /* The pairing URL needs version 2 or later, with at least 25 modules per side. */
    padding: calc(var(--cast-qr-size) * .16);
    border-radius: .65rem;
    background: #fff;
}
.gather-qr img, .gather-qr canvas { display: block; width: var(--cast-qr-size); height: auto; }
.gather-short-code-label, .gather-pair-details p { color: var(--gather-muted); font-size: .9em; }
.gather-code {
    font-family: ui-monospace, Consolas, monospace;
    font-size: min(8vw, calc(var(--cast-text) * 2.15));
    font-weight: 800;
    line-height: 1.15;
    letter-spacing: .07em;
}
.gather-pair-panel > button { justify-self: start; }
.gather-connected { gap: var(--cast-gap); }
.gather-display-heading { align-items: center; }
.gather-display-heading h1 { font-size: calc(var(--cast-text) * 1.6); }
.gather-display-heading p { margin-top: .16em; font-size: .9em; }
.gather-display-content {
    display: grid;
    flex: 1;
    grid-template-columns: minmax(0, 1fr);
    align-content: center;
    align-items: center;
    gap: var(--cast-gap);
}
.gather-question { padding: calc(var(--cast-text) * 1.25); }
.gather-question h2 { margin-bottom: .55em; color: var(--gather-gold-bright); font-size: calc(var(--cast-text) * 1.18); }
.gather-question p {
    max-width: 42ch;
    font-size: calc(var(--cast-text) * 1.9);
    line-height: 1.2;
    font-weight: 650;
    overflow-wrap: anywhere;
}
#gather-cast-vote-time { margin-top: .6em; font-size: calc(var(--cast-text) * 1.22); }
.gather-scores { margin: .65em 0 0; padding-inline-start: 1.65em; font-size: calc(var(--cast-text) * 1.2); overflow-wrap: anywhere; }
.gather-video-grid { display: grid; gap: calc(var(--cast-gap) * .75); grid-template-columns: minmax(0, 1fr); }
.gather-video-grid:empty { display: none; }
.gather-video-grid figure {
    position: relative;
    margin: 0;
    min-width: 0;
    padding: calc(var(--cast-gap) * .55);
    overflow: hidden;
    border: 1px solid var(--gather-border);
    border-radius: .85rem;
    background: var(--gather-panel);
}
.gather-video-grid video {
    display: block;
    width: 100%;
    aspect-ratio: 16 / 9;
    object-fit: contain;
    border-radius: .45rem;
    background: #070a10;
}
.gather-video-grid video:not([hidden]) + figcaption { margin-top: .3em; }
.gather-video-grid [data-video-state="stalled"] video,
.gather-video-grid [data-video-state="network_error"] video,
.gather-video-grid [data-video-state="playback_error"] video { position: absolute; inset: 0; height: 100%; visibility: hidden; }
.gather-video-grid figcaption {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: baseline;
    gap: .2em .8em;
    overflow-wrap: anywhere;
}
.gather-video-grid figcaption span, #gather-video-status { color: var(--gather-muted); font-size: .95em; }
.gather-video-grid [data-video-state="live"] figcaption span { color: var(--gather-gold-bright); }

@media (min-width: 42rem) {
    .gather-shell { padding-inline: max(1.6rem, env(safe-area-inset-left), env(safe-area-inset-right)); }
}
@media (min-width: 48rem) and (min-aspect-ratio: 4/3) {
    .gather-pair-panel { grid-template-columns: minmax(0, 1fr) auto; }
    .gather-pair-panel > button { grid-column: 1 / -1; }
    .gather-display-content[data-video-active="true"][data-layout="question"] {
        grid-template-columns: minmax(0, 8fr) minmax(0, 9fr);
    }
    .gather-display-content[data-video-active="true"][data-layout="game"] {
        grid-template-columns: minmax(0, 3fr) minmax(0, 2fr);
    }
    .gather-video-grid[data-count="2"], .gather-video-grid[data-count="3"], .gather-video-grid[data-count="4"] {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    .gather-video-grid video { max-height: 47vh; }
    .gather-video-grid[data-count="3"] video, .gather-video-grid[data-count="4"] video { max-height: 21vh; }
}
@media (min-width: 48rem) and (min-aspect-ratio: 4/3) and (max-height: 40rem) {
    .gather-display-content[data-video-active="true"][data-layout="question"] {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}
@media (max-width: 25rem) {
    .gather-actions > .gather-button { flex: 1 1 10rem; }
}
