:root {
  color-scheme: dark;
  --bg: #0e1116;
  --panel: #161b22;
  --line: #2a313c;
  --text: #e6edf3;
  --muted: #8b949e;
  --accent: #3b82f6;
  --live: #22c55e;
  --danger: #f87171;
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); }
html:has(.auth-page) { background: #fff; }

/* Sign-in page: light split screen (form left, image right), shadcn-style controls. */
.auth-page {
  color-scheme: light;
  --a-bg: #ffffff;
  --a-soft: #f6f6f8;
  --a-line: #e4e4e9;
  --a-text: #0f0f14;
  --a-muted: #6b6b76;
  --a-pink: #c026d3;
  --a-orange: #ff6a00;
  --a-purple: #8b0094;
  --a-ring: rgb(192 38 211 / .22);
  --a-danger: #dc2626;
  background: var(--a-bg);
  color: var(--a-text);
}
.auth { display: flex; min-height: 100%; }
.auth-form {
  position: relative; display: flex; align-items: center; justify-content: center; width: 100%; padding: 40px 24px;
  background:
    radial-gradient(40rem 28rem at 0% 0%, rgb(192 38 211 / .07), transparent 60%),
    radial-gradient(34rem 24rem at 100% 100%, rgb(255 106 0 / .05), transparent 60%),
    var(--a-bg);
}
.auth-inner { width: 100%; max-width: 24rem; display: flex; flex-direction: column; gap: 28px; }
.auth-logo { display: flex; }
.auth-logo img { display: block; width: 168px; height: auto; }
.auth-head h1 { margin: 0; font-size: 30px; font-weight: 700; letter-spacing: -.03em; line-height: 1.15; }
.auth-head p { margin: 8px 0 0; color: var(--a-muted); font-size: 15px; line-height: 1.5; }
.auth-fields { display: flex; flex-direction: column; gap: 18px; margin: 0; }
.auth .field { display: flex; flex-direction: column; gap: 8px; }
.auth label { margin: 0; color: var(--a-text); font-size: 14px; font-weight: 500; line-height: 1; }
.auth .input-wrap { position: relative; }
.auth .input-wrap svg { position: absolute; left: 14px; top: 50%; width: 18px; height: 18px; transform: translateY(-50%); fill: none; stroke: var(--a-muted); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; pointer-events: none; transition: stroke .15s; }
.auth input {
  height: 46px; padding: 0 14px 0 42px; border-radius: 10px; border: 1px solid var(--a-line); background: var(--a-soft);
  color: var(--a-text); font-size: 15px; transition: border-color .15s, box-shadow .15s, background-color .15s;
}
.auth input::placeholder { color: #a1a1aa; }
.auth input:hover { border-color: #d4d4db; }
.auth input:focus { outline: none; background: var(--a-bg); border-color: var(--a-pink); box-shadow: 0 0 0 4px var(--a-ring); }
.auth .input-wrap:focus-within svg { stroke: var(--a-pink); }
.auth input:disabled { opacity: .6; cursor: not-allowed; }
.auth button.primary {
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 8px; width: 100%; height: 46px; margin: 4px 0 0; padding: 0 16px;
  border: 0; border-radius: 10px; background: var(--a-text); color: #fff; font-size: 15px; font-weight: 600; overflow: hidden;
  box-shadow: 0 8px 20px -8px rgb(15 15 20 / .45); transition: transform .15s, box-shadow .2s;
}
.auth button.primary::before {
  content: ''; position: absolute; inset: 0; background: linear-gradient(100deg, var(--a-purple), var(--a-pink) 55%, var(--a-orange));
  opacity: 0; transition: opacity .25s;
}
.auth button.primary { z-index: 0; }
.auth button.primary::before { z-index: -1; }
.auth button.primary:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 12px 24px -10px rgb(192 38 211 / .55); }
.auth button.primary:hover:not(:disabled)::before { opacity: 1; }
.auth button.primary:active:not(:disabled) { transform: none; }
.auth button.primary:focus-visible { outline: none; box-shadow: 0 0 0 4px var(--a-ring); }
.auth .spinner { display: none; width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; animation: spin 1s linear infinite; }
.auth button:disabled .spinner { display: block; }
.auth .error { margin: 0; min-height: 0; padding: 10px 12px; border-radius: 10px; background: #fef2f2; border: 1px solid #fecaca; color: var(--a-danger); font-size: 14px; font-weight: 500; }
.auth .error:empty { display: none; }
.auth-foot { margin: 0; color: var(--a-muted); font-size: 13px; line-height: 1.6; }
.auth-foot a { color: var(--a-text); font-weight: 500; text-decoration: underline; text-decoration-color: var(--a-line); text-underline-offset: 3px; transition: color .15s, text-decoration-color .15s; }
.auth-foot a:hover { color: var(--a-pink); text-decoration-color: currentColor; }

.auth-image { position: relative; display: none; width: 50%; margin: 12px 12px 12px 0; border-radius: 24px; overflow: hidden; background: #000; }
.auth-image img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: 40% center; }
.auth-image::after { content: ''; position: absolute; inset: 0; background: linear-gradient(to top, rgb(0 0 0 / .75), rgb(0 0 0 / 0) 45%); }
.auth-caption { position: absolute; left: 36px; right: 36px; bottom: 36px; z-index: 1; display: flex; flex-direction: column; gap: 6px; color: #fff; }
.auth-caption strong { font-size: 26px; font-weight: 700; letter-spacing: -.02em; }
.auth-caption span { color: rgb(255 255 255 / .75); font-size: 15px; }
@media (min-width: 768px) {
  .auth-form { width: 50%; }
  .auth-image { display: block; }
}

/* Terms & Privacy page. Reuses the light sign-in palette. */
html:has(.legal-page) { scroll-behavior: smooth; scroll-padding-top: 88px; }
.legal-page { height: auto; min-height: 100%; }
.legal-bar {
  position: sticky; top: 0; z-index: 10; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px clamp(16px, 4vw, 40px); background: rgb(255 255 255 / .82); backdrop-filter: saturate(1.4) blur(12px);
  -webkit-backdrop-filter: saturate(1.4) blur(12px); border-bottom: 1px solid var(--a-line);
}
.legal-brand img { display: block; width: 120px; height: auto; }
.legal-actions { display: flex; gap: 8px; }
.legal-btn {
  display: inline-flex; align-items: center; gap: 8px; height: 38px; padding: 0 14px; border-radius: 10px;
  background: var(--a-text); color: #fff; font-size: 14px; font-weight: 500; text-decoration: none; transition: background-color .15s, border-color .15s;
}
.legal-btn:hover { background: var(--a-purple); }
.legal-btn.ghost { background: transparent; color: var(--a-text); border: 1px solid var(--a-line); }
.legal-btn.ghost:hover { border-color: var(--a-pink); color: var(--a-pink); }
.legal-btn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
@media (max-width: 480px) { .legal-btn span { display: none; } .legal-btn { width: 38px; padding: 0; justify-content: center; } }

.legal-hero {
  padding: clamp(40px, 8vw, 80px) clamp(16px, 4vw, 40px) clamp(32px, 5vw, 48px); text-align: center;
  background:
    radial-gradient(36rem 20rem at 20% 0%, rgb(192 38 211 / .09), transparent 65%),
    radial-gradient(30rem 18rem at 85% 30%, rgb(255 106 0 / .07), transparent 65%);
}
.legal-eyebrow {
  display: inline-block; margin: 0 0 14px; padding: 4px 12px; border-radius: 999px; font-size: 12px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase;
  color: var(--a-purple); background: rgb(192 38 211 / .08); border: 1px solid rgb(192 38 211 / .18);
}
.legal-hero h1 { margin: 0; font-size: clamp(30px, 5vw, 48px); font-weight: 700; letter-spacing: -.035em; line-height: 1.1; }
.legal-meta { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 20px; margin: 16px 0 0; color: var(--a-muted); font-size: 14px; }
.legal-meta b { color: var(--a-text); font-weight: 600; }

.legal-layout { display: grid; gap: 40px; max-width: 1080px; margin: 0 auto; padding: 0 clamp(16px, 4vw, 40px) 64px; }
@media (min-width: 960px) { .legal-layout { grid-template-columns: 220px minmax(0, 1fr); } }
.legal-toc { display: none; }
@media (min-width: 960px) {
  .legal-toc { display: block; position: sticky; top: 96px; align-self: start; }
}
.legal-toc p { margin: 0 0 10px; color: var(--a-muted); font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; }
.legal-toc ol { list-style: none; margin: 0; padding: 0; border-left: 1px solid var(--a-line); }
.legal-toc a { display: block; margin-left: -1px; padding: 7px 0 7px 14px; border-left: 2px solid transparent; color: var(--a-muted); font-size: 14px; text-decoration: none; transition: color .15s, border-color .15s; }
.legal-toc a:hover { color: var(--a-text); border-left-color: var(--a-pink); }

.legal-doc { max-width: 720px; min-width: 0; color: #2b2b33; font-size: 16px; line-height: 1.75; }
.legal-doc p { margin: 0 0 14px; }
.legal-doc strong { color: var(--a-text); }
.legal-lead { font-size: 17px; color: var(--a-text); }
.legal-callout {
  margin: 0 0 28px; padding: 16px 18px; border-radius: 14px; font-size: 14.5px; font-weight: 500; line-height: 1.65; color: var(--a-text);
  background: linear-gradient(135deg, rgb(192 38 211 / .06), rgb(255 106 0 / .05)); border: 1px solid rgb(192 38 211 / .16);
}
.legal-part { margin-top: 56px; padding-top: 40px; border-top: 1px solid var(--a-line); }
.legal-part > header { margin-bottom: 28px; }
.legal-part-no {
  font-size: 13px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  background: linear-gradient(90deg, var(--a-purple), var(--a-pink), var(--a-orange)); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.legal-part h2 { margin: 4px 0 4px; font-size: clamp(24px, 3.4vw, 32px); font-weight: 700; letter-spacing: -.025em; line-height: 1.2; color: var(--a-text); }
.legal-part > header p { margin: 0; color: var(--a-muted); font-size: 14px; }
.legal-doc h3 { margin: 36px 0 10px; font-size: 19px; font-weight: 650; letter-spacing: -.015em; line-height: 1.35; color: var(--a-text); }
.legal-doc h4 { margin: 22px 0 6px; font-size: 15.5px; font-weight: 600; color: var(--a-text); }
.legal-doc ul { margin: 0 0 16px; padding: 0; list-style: none; }
.legal-doc li { position: relative; margin: 0 0 8px; padding-left: 22px; }
.legal-doc li::before { content: ''; position: absolute; left: 4px; top: .72em; width: 7px; height: 7px; border-radius: 50%; background: linear-gradient(135deg, var(--a-pink), var(--a-orange)); }
.legal-doc a { color: var(--a-purple); text-underline-offset: 3px; }
.legal-doc a:hover { color: var(--a-pink); }
.legal-contact {
  display: flex; flex-direction: column; gap: 4px; padding: 16px 18px; border-radius: 14px; background: var(--a-soft); border: 1px solid var(--a-line);
  font-style: normal; font-size: 15px;
}
.legal-part:last-child .legal-callout { margin: 28px 0 0; }
.legal-footer {
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; padding: 24px clamp(16px, 4vw, 40px);
  border-top: 1px solid var(--a-line); color: var(--a-muted); font-size: 13px;
}
.legal-footer a { color: var(--a-text); text-decoration: none; font-weight: 500; }
.legal-footer a:hover { color: var(--a-pink); }

/* Staggered fade-up entrance, like the framer-motion variants of the original component. */
.stagger { opacity: 0; animation: rise .5s ease-out forwards; }
.auth-logo.stagger { animation-delay: .1s; }
.auth-head.stagger { animation-delay: .2s; }
.field.stagger:nth-child(1) { animation-delay: .3s; }
.field.stagger:nth-child(2) { animation-delay: .4s; }
.auth-fields > .stagger:nth-child(3) { animation-delay: .5s; }
.auth-foot.stagger { animation-delay: .6s; }
@keyframes rise { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: none; } }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .stagger { opacity: 1; animation: none; }
}

label { display: block; font-size: 13px; color: var(--muted); margin: 14px 0 6px; }
input { width: 100%; padding: 10px 12px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg); color: var(--text); font-size: 15px; }
input:focus { outline: 2px solid var(--accent); border-color: transparent; }
button { cursor: pointer; border: 1px solid var(--line); background: var(--panel); color: var(--text); padding: 8px 12px; border-radius: 8px; font-size: 14px; }
button.primary { width: 100%; margin-top: 22px; padding: 11px; background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
button:disabled { opacity: .6; cursor: wait; }
.error { color: var(--danger); min-height: 1.2em; font-size: 14px; margin: 12px 0 0; }

.play { display: flex; flex-direction: column; height: 100%; }
.bar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 8px 16px; border-bottom: 1px solid var(--line); background: var(--panel); }
.bar .brand { font-weight: 600; }
.bar .spacer { flex: 1; }
#status { color: var(--muted); font-size: 13px; }
#status[data-live="true"] { color: var(--live); }
#admin { display: flex; gap: 6px; }
#player { position: relative; flex: 1; min-height: 0; }
