:root {
    --bg: #15151a;
    --bg-deep: #101014;
    --surface: #202027;
    --surface-raised: #27272f;
    --line: rgba(255, 255, 255, 0.09);
    --line-strong: rgba(255, 255, 255, 0.16);
    --text: #f1f1f5;
    --muted: #a0a0aa;
    --dim: #a0a0aa;
    --cyan: #00d4e5;
    --cyan-dark: #00a8b5;
    --cyan-glow: rgba(0, 212, 229, 0.32);
    --red: #ff3d50;
    --red-glow: rgba(255, 61, 80, 0.3);
    --twitch: #a970ff;
    --youtube: #ff3d3d;
    --radius: 10px;
    --display: 'Orbitron', sans-serif;
    --body: 'Rajdhani', sans-serif;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

[hidden] {
    display: none !important;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

html {
    color-scheme: dark;
    scroll-behavior: smooth;
}

body {
    min-width: 320px;
    min-height: 100vh;
    overflow-x: hidden;
    background: var(--bg);
    color: var(--text);
    font-family: var(--body);
    font-size: 17px;
    line-height: 1.55;
}

body::before {
    content: '';
    position: fixed;
    inset: 0;
    z-index: -2;
    background:
        radial-gradient(ellipse at 50% -10%, rgba(0, 212, 229, 0.1), transparent 46%),
        linear-gradient(180deg, var(--bg-deep), var(--bg) 38%);
}

body::after {
    content: '';
    position: fixed;
    inset: 0;
    z-index: -1;
    opacity: 0.025;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
    pointer-events: none;
}

button,
a {
    -webkit-tap-highlight-color: transparent;
}

a:focus-visible,
button:focus-visible,
[tabindex]:focus-visible {
    outline: 3px solid var(--cyan);
    outline-offset: 3px;
}

.shell {
    width: min(100% - 48px, 1180px);
    margin-inline: auto;
}

.skip-link {
    position: fixed;
    top: 12px;
    left: 12px;
    z-index: 100;
    padding: 10px 16px;
    border-radius: 4px;
    background: var(--cyan);
    color: var(--bg-deep);
    font-family: var(--display);
    font-size: 0.72rem;
    font-weight: 700;
    text-decoration: none;
    transform: translateY(-180%);
}

.skip-link:focus {
    transform: translateY(0);
}

.site-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    padding-block: 24px;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 13px;
    color: var(--text);
    font-family: var(--display);
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-decoration: none;
    text-transform: uppercase;
}

.brand img {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    object-fit: cover;
    box-shadow: 0 0 24px var(--cyan-glow);
}

.site-header nav {
    display: flex;
    align-items: center;
    gap: 22px;
}

.site-header nav a {
    color: var(--muted);
    font-family: var(--display);
    font-size: 0.66rem;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-decoration: none;
    text-transform: uppercase;
    transition: color 150ms ease;
}

.site-header nav a:hover {
    color: var(--cyan);
}

main {
    padding-block: 54px 90px;
}

.hero {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 32px;
    margin-bottom: 26px;
}

.eyebrow,
.panel-kicker {
    color: var(--cyan);
    font-family: var(--display);
    font-size: 0.66rem;
    font-weight: 700;
    letter-spacing: 0.2em;
    text-transform: uppercase;
}

.hero h1 {
    margin-top: 8px;
    background: linear-gradient(135deg, #fff 20%, #b5b5bd 72%, var(--cyan));
    background-clip: text;
    color: transparent;
    font-family: var(--display);
    font-size: clamp(2rem, 6vw, 4rem);
    font-weight: 800;
    letter-spacing: -0.035em;
    line-height: 1.05;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.broadcast-state {
    display: inline-flex;
    align-items: center;
    flex: 0 0 auto;
    gap: 9px;
    padding: 9px 13px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.025);
    color: var(--muted);
    font-family: var(--display);
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--dim);
}

.broadcast-state--live {
    border-color: rgba(255, 61, 80, 0.36);
    color: #ff8c98;
}

.broadcast-state--live .status-dot {
    background: var(--red);
    box-shadow: 0 0 0 5px rgba(255, 61, 80, 0.12), 0 0 16px var(--red-glow);
    animation: pulse 1.8s ease-in-out infinite;
}

.broadcast-state--upcoming {
    border-color: rgba(0, 212, 229, 0.3);
    color: var(--cyan);
}

.broadcast-state--upcoming .status-dot {
    background: var(--cyan);
    box-shadow: 0 0 14px var(--cyan-glow);
}

@keyframes pulse {
    50% { opacity: 0.52; }
}

.player-panel {
    position: relative;
    margin-bottom: 28px;
}

.player-shell {
    position: relative;
    overflow: hidden;
    width: 100%;
    aspect-ratio: 16 / 9;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius);
    background: #09090c;
    box-shadow: 0 28px 80px rgba(0, 0, 0, 0.42), 0 0 60px rgba(0, 212, 229, 0.05);
}

.player-shell::before {
    content: '';
    position: absolute;
    inset: 0;
    z-index: 0;
    background:
        radial-gradient(circle at 50% 40%, rgba(0, 212, 229, 0.09), transparent 38%),
        linear-gradient(135deg, #131319, #09090c);
}

.youtube-player,
.youtube-player iframe {
    position: absolute;
    inset: 0;
    z-index: 2;
    width: 100%;
    height: 100%;
    border: 0;
}

.player-shell[data-state='fallback'] .youtube-player {
    display: none;
}

.player-fallback {
    position: absolute;
    inset: 0;
    z-index: 1;
    display: grid;
    place-content: center;
    justify-items: center;
    padding: 32px;
    text-align: center;
}

.player-shell[data-state='ready'] .player-fallback {
    display: none;
}

.fallback-mark {
    display: grid;
    width: 68px;
    height: 68px;
    margin-bottom: 18px;
    place-items: center;
    border: 1px solid rgba(0, 212, 229, 0.24);
    border-radius: 18px;
    color: var(--cyan);
    background: rgba(0, 212, 229, 0.06);
    box-shadow: 0 0 32px rgba(0, 212, 229, 0.08);
}

.fallback-mark svg {
    width: 34px;
    height: 34px;
}

.fallback-title {
    font-family: var(--display);
    font-size: clamp(1rem, 3vw, 1.35rem);
    font-weight: 700;
}

.fallback-copy {
    max-width: 500px;
    margin: 8px 0 20px;
    color: var(--muted);
}

.live-layout {
    display: grid;
    grid-template-columns: minmax(0, 1.1fr) minmax(360px, 0.9fr);
    gap: 28px;
    align-items: stretch;
}

.panel {
    position: relative;
    overflow: hidden;
    min-width: 0;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: linear-gradient(145deg, rgba(35, 35, 43, 0.98), rgba(27, 27, 33, 0.98));
}

.panel::before {
    content: '';
    position: absolute;
    top: 0;
    right: 15%;
    left: 15%;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(232, 232, 236, 0.38), transparent);
}

.stream-card {
    display: flex;
    flex-direction: column;
    padding: 30px;
}

.panel-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--line);
}

.panel-heading h2 {
    margin-top: 5px;
    font-family: var(--display);
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: 0.02em;
}

.stream-info {
    flex: 1;
    padding-block: 24px;
}

.stream-info h3 {
    margin-bottom: 7px;
    font-family: var(--display);
    font-size: clamp(1.05rem, 3vw, 1.45rem);
    line-height: 1.4;
}

.stream-summary {
    color: var(--muted);
}

.stream-facts {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
    margin-top: 24px;
}

.stream-facts > div {
    min-width: 0;
    padding: 13px 14px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.018);
}

.stream-facts dt {
    margin-bottom: 4px;
    color: var(--dim);
    font-family: var(--display);
    font-size: 0.56rem;
    font-weight: 700;
    letter-spacing: 0.13em;
    text-transform: uppercase;
}

.stream-facts dd {
    overflow: hidden;
    color: var(--text);
    font-weight: 600;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.platform-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    padding-top: 22px;
    border-top: 1px solid var(--line);
}

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 9px;
    min-height: 44px;
    padding: 11px 18px;
    border: 1px solid transparent;
    border-radius: 4px;
    font-family: var(--display);
    font-size: 0.64rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-decoration: none;
    text-transform: uppercase;
    transition: transform 150ms ease, box-shadow 150ms ease, border-color 150ms ease;
}

.button:hover {
    transform: translateY(-2px);
}

.button--primary {
    background: linear-gradient(135deg, var(--cyan), var(--cyan-dark));
    color: var(--bg-deep);
    box-shadow: 0 5px 24px rgba(0, 212, 229, 0.24);
}

.button--youtube {
    background: linear-gradient(135deg, #ff4747, #d71522);
    color: #fff;
    box-shadow: 0 5px 22px rgba(255, 36, 48, 0.2);
}

.button--twitch {
    border-color: rgba(169, 112, 255, 0.28);
    background: rgba(169, 112, 255, 0.08);
    color: #cfb2ff;
}

.latest-video {
    display: grid;
    grid-template-columns: 150px minmax(0, 1fr);
    gap: 18px;
    align-items: center;
    margin-top: 22px;
    padding-top: 22px;
    border-top: 1px solid var(--line);
}

.latest-video img {
    width: 150px;
    aspect-ratio: 16 / 9;
    border-radius: 5px;
    object-fit: cover;
    background: var(--bg-deep);
}

.latest-video h3 {
    margin: 5px 0 4px;
    font-family: var(--display);
    font-size: 0.88rem;
    line-height: 1.4;
}

.latest-video a {
    color: var(--cyan);
    font-size: 0.9rem;
    font-weight: 600;
}

.chat-card {
    display: grid;
    grid-template-rows: auto auto minmax(320px, 1fr) auto;
    min-height: 590px;
}

.chat-heading {
    margin-inline: 24px;
    padding-block: 24px 18px;
}

.connection-state {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    color: var(--dim);
    font-family: var(--display);
    font-size: 0.54rem;
    font-weight: 700;
    letter-spacing: 0.09em;
    text-transform: uppercase;
}

.connection-state > span:first-child {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--dim);
}

.connection-state[data-state='connected'] {
    color: #81dec8;
}

.connection-state[data-state='connected'] > span:first-child {
    background: #4ec9a8;
    box-shadow: 0 0 10px rgba(78, 201, 168, 0.4);
}

.connection-state[data-state='reconnecting'],
.connection-state[data-state='unavailable'] {
    color: #f0bf70;
}

.provider-health {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    border-bottom: 1px solid var(--line);
}

.provider-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 8px;
    border: 1px solid var(--line);
    border-radius: 999px;
    color: var(--dim);
    font-family: var(--display);
    font-size: 0.5rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.provider-pill i {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
}

.provider-pill[data-status='healthy'][data-provider='twitch'] {
    border-color: rgba(169, 112, 255, 0.26);
    color: #c6a6f7;
}

.provider-pill[data-status='healthy'][data-provider='youtube'] {
    border-color: rgba(255, 61, 61, 0.26);
    color: #ff8b8b;
}

.provider-pill[data-status='degraded'] {
    color: #f0bf70;
}

.provider-pill[data-status='unavailable'] {
    color: #ff8b8b;
}

.viewer-count {
    margin-left: auto;
    color: var(--dim);
    font-size: 0.76rem;
}

.chat-log {
    position: relative;
    overflow-y: auto;
    min-height: 320px;
    max-height: 510px;
    padding: 12px 10px 12px 16px;
    scrollbar-color: #44444d transparent;
    scrollbar-width: thin;
}

.chat-empty {
    display: grid;
    min-height: 280px;
    padding: 34px;
    place-items: center;
    color: var(--dim);
    text-align: center;
}

.chat-message {
    display: grid;
    grid-template-columns: 24px minmax(0, 1fr);
    gap: 9px;
    padding: 8px;
    border-radius: 5px;
    animation: message-in 180ms ease-out;
}

.chat-message:hover {
    background: rgba(255, 255, 255, 0.025);
}

@keyframes message-in {
    from { opacity: 0; transform: translateY(4px); }
}

.chat-platform {
    display: grid;
    width: 22px;
    height: 22px;
    margin-top: 1px;
    place-items: center;
    border-radius: 5px;
    font-family: var(--display);
    font-size: 0.5rem;
    font-style: normal;
    font-weight: 800;
}

.chat-message[data-platform='twitch'] .chat-platform {
    background: rgba(169, 112, 255, 0.14);
    color: #c6a6f7;
}

.chat-message[data-platform='youtube'] .chat-platform {
    background: rgba(255, 61, 61, 0.14);
    color: #ff8585;
}

.chat-message[data-platform='mpd'] .chat-platform {
    background: rgba(0, 212, 229, 0.12);
    color: var(--cyan);
}

.chat-line {
    overflow-wrap: anywhere;
    color: #d6d6dc;
    line-height: 1.42;
}

.chat-author {
    margin-right: 6px;
    color: var(--text);
    font-weight: 700;
}

.chat-badge {
    display: inline-flex;
    margin-right: 4px;
    padding: 1px 4px;
    border: 1px solid var(--line);
    border-radius: 3px;
    color: var(--muted);
    font-family: var(--display);
    font-size: 0.43rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    vertical-align: 2px;
    text-transform: uppercase;
}

.chat-text {
    white-space: pre-wrap;
}

.chat-time {
    margin-left: 7px;
    color: var(--muted);
    font-size: 0.72rem;
    white-space: nowrap;
}

.jump-latest {
    position: absolute;
    right: 22px;
    bottom: 54px;
    z-index: 3;
    padding: 8px 12px;
    border: 1px solid rgba(0, 212, 229, 0.3);
    border-radius: 999px;
    background: #22222a;
    color: var(--cyan);
    font-family: var(--display);
    font-size: 0.55rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    cursor: pointer;
    box-shadow: 0 8px 22px rgba(0, 0, 0, 0.35);
}

.chat-note {
    padding: 13px 24px;
    border-top: 1px solid var(--line);
    color: var(--dim);
    font-size: 0.78rem;
}

.reliability-note {
    display: flex;
    align-items: flex-start;
    gap: 13px;
    margin-top: 26px;
    padding: 18px 20px;
    border: 1px solid var(--line);
    border-radius: 7px;
    color: var(--muted);
    background: rgba(255, 255, 255, 0.018);
    font-size: 0.9rem;
}

.reliability-note > div {
    display: grid;
    flex: 0 0 auto;
    width: 22px;
    height: 22px;
    place-items: center;
    border: 1px solid rgba(0, 212, 229, 0.32);
    border-radius: 50%;
    color: var(--cyan);
    font-family: var(--display);
    font-size: 0.65rem;
    font-weight: 700;
}

.reliability-note strong {
    color: var(--text);
}

footer {
    padding: 34px 0;
    border-top: 1px solid var(--line);
    color: #666670;
    font-family: var(--display);
    font-size: 0.58rem;
    letter-spacing: 0.17em;
    text-align: center;
    text-transform: uppercase;
}

.noscript-notice {
    position: fixed;
    right: 12px;
    bottom: 12px;
    left: 12px;
    z-index: 10;
    padding: 12px;
    border: 1px solid var(--red);
    border-radius: 4px;
    background: #21181b;
    text-align: center;
}

.noscript-notice a {
    color: var(--cyan);
}

@media (max-width: 900px) {
    .live-layout {
        grid-template-columns: 1fr;
    }

    .chat-card {
        grid-row: 1;
        min-height: 560px;
    }

    .stream-card {
        grid-row: 2;
    }
}

@media (max-width: 620px) {
    .shell {
        width: min(100% - 28px, 1180px);
    }

    .site-header {
        padding-block: 16px;
    }

    .brand span {
        display: none;
    }

    .site-header nav {
        gap: 14px;
    }

    .site-header nav a {
        font-size: 0.58rem;
    }

    main {
        padding-block: 36px 64px;
    }

    .hero {
        display: block;
        margin-bottom: 18px;
    }

    .broadcast-state {
        margin-top: 18px;
    }

    .player-shell {
        border-radius: 6px;
    }

    .player-fallback {
        padding: 16px;
    }

    .fallback-mark {
        width: 46px;
        height: 46px;
        margin-bottom: 10px;
        border-radius: 12px;
    }

    .fallback-mark svg {
        width: 25px;
        height: 25px;
    }

    .fallback-copy {
        display: none;
    }

    .fallback-title {
        margin-bottom: 12px;
        font-size: 0.84rem;
    }

    .button {
        min-height: 42px;
        padding: 10px 13px;
        font-size: 0.56rem;
    }

    .stream-card {
        padding: 22px;
    }

    .chat-heading {
        margin-inline: 18px;
        padding-block: 20px 15px;
    }

    .provider-health {
        padding-inline: 18px;
    }

    .stream-facts {
        grid-template-columns: 1fr;
    }

    .platform-actions .button {
        flex: 1 1 145px;
    }

    .latest-video {
        grid-template-columns: 110px minmax(0, 1fr);
        gap: 13px;
    }

    .latest-video img {
        width: 110px;
    }

    .chat-card {
        min-height: 520px;
    }

    .chat-log {
        max-height: 470px;
    }
}

@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
