:root {
    color-scheme: dark;
    --background: #101211;
    --panel: #171a18;
    --border: #323732;
    --text: #f5f3ed;
    --muted: #aeb5ac;
    --accent: #ffab72;
    --live: #94e2aa;
    font-family: "Segoe UI", system-ui, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

body {
    min-width: 280px;
    min-height: 100vh;
    margin: 0;
    background: radial-gradient(ellipse at 18% 3%, #282019, transparent 38rem), var(--background);
    color: var(--text);
    line-height: 1.5;
}

button, input { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: wait; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }

.shell {
    width: min(100% - 3rem, 74rem);
    margin-inline: auto;
}

.masthead {
    min-height: 5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
    border-bottom: 1px solid var(--border);
}

.brand, .brand-icon {
    display: flex;
    align-items: center;
}

.brand { gap: .65rem; font-weight: 750; }

.brand-icon {
    width: 2.35rem;
    height: 2.35rem;
    justify-content: center;
    color: var(--accent);
    border: 1px solid #63462f;
    border-radius: .55rem;
    background: #2e211a;
}

.header-tag, .eyebrow {
    color: var(--accent);
    font: 650 .72rem/1.4 ui-monospace, Consolas, monospace;
    text-transform: uppercase;
    letter-spacing: .12em;
}

.login {
    display: grid;
    grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr);
    align-items: stretch;
    min-height: 27rem;
    margin-block: clamp(2rem, 9vh, 6rem) 2rem;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: .95rem;
    background: var(--panel);
}

.login-art {
    position: relative;
    isolation: isolate;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: clamp(1.4rem, 5vw, 4.2rem);
    overflow: hidden;
    background:
        radial-gradient(ellipse at 80% 86%, #563829 0%, transparent 65%),
        linear-gradient(120deg, #171b18, #241c17);
}

.login-art::before, .stage::before {
    content: "";
    position: absolute;
    inset: 0;
    background-image: linear-gradient(#d7e0d409 1px, transparent 1px), linear-gradient(90deg, #d7e0d409 1px, transparent 1px);
    background-size: 2.5rem 2.5rem;
    pointer-events: none;
    z-index: -1;
}

.eyebrow { margin: 0 0 .6rem; }

.login h1, .watch h1 {
    margin: 0;
    font-weight: 750;
    line-height: 1.08;
    letter-spacing: -.055em;
}

.login h1 { font-size: clamp(2rem, 5.5vw, 5.3rem); }
.login h1 span { color: var(--accent); }

.art-reticle {
    position: absolute;
    z-index: -1;
    right: -3rem;
    bottom: -6rem;
    width: 22rem;
    aspect-ratio: 1;
    border: 1px solid #f4a77137;
    border-radius: 50%;
    box-shadow: inset 0 0 0 2rem #f4a77109, 0 0 0 2.5rem #f4a7710d, 0 0 0 5rem #f4a77109;
}

.art-reticle::before, .art-reticle::after {
    content: "";
    position: absolute;
    background: #f4a77133;
}

.art-reticle::before { top: 50%; left: -4.5rem; right: -4.5rem; height: 1px; }
.art-reticle::after { left: 50%; top: -4.5rem; bottom: -4.5rem; width: 1px; }

.login-card {
    align-content: center;
    border-left: 1px solid var(--border);
    padding: clamp(1.4rem, 4vw, 3.5rem);
}

.login-card h2, .stage h2 { margin: 0; font-size: clamp(1.25rem, 3vw, 1.7rem); line-height: 1.2; }
.login-card p, .stage p { margin: .55rem 0 0; color: var(--muted); }
.login-card form { display: grid; gap: .65rem; margin-top: 1.6rem; }
.login-card label { font-weight: 650; font-size: .92rem; }

.login-card input:not([type="hidden"]), .chat-form input {
    min-height: 3rem;
    min-width: 0;
    width: 100%;
    border: 1px solid #4f554f;
    border-radius: .4rem;
    background: #101311;
    color: var(--text);
    padding: .6rem .8rem;
}

.primary, .logout {
    min-height: 2.75rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .5rem;
    padding: .6rem .9rem;
    border: 1px solid transparent;
    border-radius: .4rem;
    font-weight: 700;
}

.primary { color: #22160f; background: var(--accent); }
.primary:hover { background: #ffc398; }
.login-card .primary { justify-content: space-between; margin-top: .5rem; text-align: left; }

.logout {
    color: var(--text);
    border-color: var(--border);
    background: var(--panel);
    font-size: .9rem;
}

.logout:hover { background: #272c28; }
.login-card .form-error, .form-error { color: #ffbfae; }

.watch { margin-block: clamp(1.7rem, 5vw, 3.6rem) 2rem; }

.watch-heading {
    display: flex;
    align-items: end;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: .8rem 1rem;
    margin-bottom: 1.05rem;
}

.watch h1 { font-size: clamp(1.8rem, 5vw, 3.1rem); }

.watch-badges { display: flex; flex-wrap: wrap; gap: .5rem; }

.status, .viewer-count {
    display: inline-flex;
    align-items: center;
    gap: .45rem;
    min-height: 2rem;
    padding: .3rem .7rem;
    border: 1px solid #444c45;
    border-radius: 5rem;
    color: #cbd2cb;
    background: #1c201d;
    font-size: .78rem;
    font-weight: 700;
}

.status::before { content: ""; width: .47rem; height: .47rem; border-radius: 50%; background: currentColor; }
.status[data-state="live"] { color: var(--live); border-color: #47684e; background: #192b1e; }
.status[data-state="retrying"] { color: var(--accent); border-color: #765339; background: #2d2219; }
.viewer-count strong { min-width: 1ch; color: var(--text); font-variant-numeric: tabular-nums; }

.watch-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(16rem, 20rem);
    gap: 1rem;
    align-items: start;
}

.stage {
    position: relative;
    isolation: isolate;
    display: grid;
    place-items: center;
    width: 100%;
    min-height: 15rem;
    aspect-ratio: 16 / 9;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: .75rem;
    background: radial-gradient(ellipse at 50% 48%, #242c25, #141814 65%);
}

.stage video { position: absolute; inset: 0; width: 100%; height: 100%; background: #000; }
.stage-content { position: relative; z-index: 1; padding: 1rem; text-align: center; }

.reticle {
    display: block;
    width: 2rem;
    aspect-ratio: 1;
    margin: 0 auto .85rem;
    border: 1px solid #cb935f;
    border-radius: 50%;
    background:
        linear-gradient(var(--accent), var(--accent)) center / 1px .85rem no-repeat,
        linear-gradient(var(--accent), var(--accent)) center / .85rem 1px no-repeat;
    box-shadow: 0 0 0 .35rem #ffab7218;
}

.play { margin-top: .85rem; }
.watch-note { margin-top: .8rem; color: var(--muted); font-size: .9rem; }

.chat {
    min-width: 0;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: .75rem;
    background: #18181b;
}

.chat-header, .chat-form { padding: .8rem 1rem; }
.chat-header { border-bottom: 1px solid var(--border); }
.chat-header h2 { margin: 0; font-size: 1.04rem; }

.chat-scroll {
    height: clamp(11rem, 22vw, 18rem);
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: .6rem .7rem;
}

.chat-scroll:focus-visible { outline-offset: -2px; }
.chat-empty { margin: 0; color: var(--muted); font-size: .9rem; }
.chat-messages { display: grid; gap: .35rem; margin: 0; padding: 0; list-style: none; }
.chat-messages li { color: #efeff1; font-size: .9rem; line-height: 1.45; overflow-wrap: anywhere; }
.chat-messages time { margin-inline-end: .1rem; color: #b9b9c0; font-variant-numeric: tabular-nums; }
.chat-messages strong[data-color="0"] { color: #32ef87; }
.chat-messages strong[data-color="1"] { color: #63a8ff; }
.chat-messages strong[data-color="2"] { color: #d7a2ff; }
.chat-messages strong[data-color="3"] { color: #ffab72; }
.chat-messages strong[data-color="4"] { color: #f59fca; }
.chat-messages strong[data-color="5"] { color: #f5df71; }
.chat-messages strong[data-color="6"] { color: #71e0e5; }
.chat-messages strong[data-color="7"] { color: #ff9797; }

.chat-form {
    display: grid;
    gap: .35rem;
    border-top: 1px solid var(--border);
}

.chat-form input { min-height: 2.75rem; font-size: 1rem; }
.chat-compose { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .4rem; }
.chat-feedback { margin: .15rem 0 0; font-size: .85rem; }
.chat-feedback:empty { display: none; }

@media (max-width: 58rem) {
    .watch-layout { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 43rem) {
    .shell { width: calc(100% - 2rem); }
    .masthead { min-height: 4.25rem; }
    .login { grid-template-columns: minmax(0, 1fr); min-height: 0; }
    .login-art { min-height: 12rem; }
    .login h1 { font-size: clamp(1.8rem, 8.7vw, 3.3rem); }
    .login-card { border-top: 1px solid var(--border); border-left: 0; }
    .art-reticle { width: 14rem; bottom: -6rem; }
}
