:root {
  --green-900: #06230f;
  --green-800: #0b3d1a;
  --green-600: #157a2a;
  --green-500: #1f9a35;
  --gold-500: #f5b800;
  --gold-400: #ffcf33;
  --ink: #f4f6f1;
  --muted: #b5c2b8;
  --red: #e5322d;
  --panel: rgba(255, 255, 255, 0.05);
  --panel-border: rgba(245, 184, 0, 0.25);
  --radius: 14px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body { margin: 0; min-height: 100%; }

body {
  color: var(--ink);
  background:
    radial-gradient(1200px 600px at 50% -200px, rgba(31, 154, 53, 0.35), transparent 70%),
    linear-gradient(180deg, var(--green-900) 0%, #050a06 100%);
  background-attachment: fixed;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

[hidden] { display: none !important; }

/* ---------- Header ---------- */
.site-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  border-bottom: 3px solid var(--gold-500);
  background: linear-gradient(90deg, var(--green-800), var(--green-600));
}
.site-header img { height: 52px; width: auto; }
.site-header .brand { display: flex; flex-direction: column; line-height: 1.1; }
.site-header .brand strong { font-size: 1.15rem; letter-spacing: 0.04em; text-transform: uppercase; }
.site-header .brand span { color: var(--gold-400); font-size: 0.8rem; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; }
.site-header .spacer { flex: 1; }

main { max-width: 1100px; margin: 0 auto; padding: 16px; }

/* ---------- Gate ---------- */
.gate {
  max-width: 420px;
  margin: 6vh auto 0;
  text-align: center;
  padding: 28px 24px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
}
.gate img { width: 220px; max-width: 70%; height: auto; }
.gate h1 { font-size: 1.35rem; margin: 12px 0 4px; }
.gate p { color: var(--muted); margin: 0 0 18px; }

form.inline { display: flex; gap: 8px; }
input[type="text"], input[type="password"], input[type="url"], input[type="datetime-local"], textarea {
  width: 100%;
  font: inherit;
  font-size: 16px; /* prevents iOS zoom */
  color: var(--ink);
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 10px;
  padding: 12px 14px;
}
input:focus, textarea:focus { outline: 2px solid var(--gold-500); outline-offset: 1px; }

button, .button {
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  border: 0;
  border-radius: 10px;
  padding: 12px 18px;
  color: #1a1400;
  background: var(--gold-500);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  white-space: nowrap;
}
button:hover, .button:hover { background: var(--gold-400); }
button:disabled { opacity: 0.6; cursor: default; }
button.secondary { background: rgba(255, 255, 255, 0.12); color: var(--ink); }
button.secondary:hover { background: rgba(255, 255, 255, 0.2); }
button.danger { background: var(--red); color: #fff; }
button.small { padding: 8px 12px; font-size: 0.9rem; }

.error { color: #ff8a85; min-height: 1.3em; margin-top: 10px; }

/* ---------- Watch page ---------- */
.game-head { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; margin-bottom: 12px; }
.game-head h1 { margin: 0; font-size: clamp(1.25rem, 3.5vw, 1.9rem); }
.game-head .subtitle { color: var(--muted); width: 100%; margin-top: -6px; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-weight: 800;
  font-size: 0.8rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
}
.badge.live { background: var(--red); color: #fff; }
.badge.live::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: #fff; animation: pulse 1.4s infinite; }
.badge.reconnecting { background: #8a6a00; color: #fff; }
.badge.ended { background: var(--gold-500); color: #1a1400; }
@keyframes pulse { 50% { opacity: 0.25; } }

.messages { display: grid; gap: 8px; margin-bottom: 12px; }
.message {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 12px 14px;
  border-radius: 12px;
  background: rgba(245, 184, 0, 0.12);
  border-left: 4px solid var(--gold-500);
}
.message .text { flex: 1; white-space: pre-wrap; word-break: break-word; }
.message time { color: var(--muted); font-size: 0.8rem; white-space: nowrap; }
.message.older { background: var(--panel); border-left-color: rgba(245, 184, 0, 0.4); font-size: 0.92rem; }
.messages details summary { cursor: pointer; color: var(--muted); font-size: 0.9rem; padding: 4px 2px; }
.messages details .message { margin-top: 8px; }

.stage {
  position: relative;
  aspect-ratio: 16 / 9;
  width: 100%;
  background: #000;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--panel-border);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
}
.stage video { width: 100%; height: 100%; display: block; background: #000; }

.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 10px;
  padding: 20px;
  background:
    radial-gradient(600px 300px at 50% 30%, rgba(31, 154, 53, 0.35), transparent 70%),
    linear-gradient(180deg, var(--green-800), #040904);
}
.overlay img { height: 34%; max-height: 200px; width: auto; }
@media (max-width: 600px) {
  .overlay { gap: 6px; padding: 12px; }
  .overlay img { height: 30%; }
  .overlay p { font-size: 0.85rem; }
  .overlay .hide-small { display: none; }
}
.overlay h2 { margin: 4px 0 0; font-size: clamp(1.1rem, 3.2vw, 1.7rem); }
.overlay p { margin: 0; color: var(--muted); max-width: 520px; }
.overlay .countdown { font-size: clamp(1.4rem, 5vw, 2.4rem); font-weight: 800; color: var(--gold-400); font-variant-numeric: tabular-nums; }
.overlay.thin { background: rgba(0, 0, 0, 0.6); }

.unmute {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 3;
}

.spinner {
  width: 34px; height: 34px; border-radius: 50%;
  border: 4px solid rgba(255, 255, 255, 0.2); border-top-color: var(--gold-500);
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.footer-note { color: var(--muted); font-size: 0.85rem; text-align: center; margin: 18px 0 8px; }
.footer-note a { color: var(--gold-400); }

/* ---------- Admin ---------- */
.admin-grid { display: grid; gap: 14px; grid-template-columns: 1fr; }
@media (min-width: 860px) { .admin-grid { grid-template-columns: 1fr 1fr; } }
.card {
  background: var(--panel);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius);
  padding: 16px;
}
.card h2 { margin: 0 0 12px; font-size: 1.05rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--gold-400); }
.card label { display: block; font-size: 0.85rem; color: var(--muted); margin: 10px 0 4px; }
.card .row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.card .hint { color: var(--muted); font-size: 0.85rem; margin: 8px 0 0; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; }
.stat { background: rgba(0, 0, 0, 0.3); border-radius: 10px; padding: 10px 12px; }
.stat .k { color: var(--muted); font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.08em; }
.stat .v { font-size: 1.3rem; font-weight: 800; margin-top: 2px; }
.quick { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.quick button { font-size: 0.85rem; padding: 7px 10px; }
.admin-msgs { display: grid; gap: 6px; margin-top: 12px; }
.admin-msgs .message { align-items: center; }
.toast {
  position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%);
  background: #111; border: 1px solid var(--gold-500); padding: 10px 16px; border-radius: 10px; z-index: 10;
}
.preview-link { color: var(--gold-400); font-size: 0.9rem; }
