:root {
  color-scheme: dark;
  --bg: #030713;
  --panel: rgba(5, 18, 40, .78);
  --panel-2: rgba(8, 31, 65, .72);
  --text: #f3fbff;
  --muted: #9bb7d0;
  --line: rgba(119, 211, 255, .22);
  --accent: #2ee4ff;
  --accent-2: #d9f6ff;
  --danger: #ff5367;
  --ok: #55f2b5;
  --warn: #ffd166;
  --shadow: 0 22px 70px rgba(0, 14, 32, .45);
  --radius: 8px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
  margin: 0;
  background:
    radial-gradient(circle at 50% 12%, rgba(132, 219, 255, .24), transparent 25%),
    radial-gradient(circle at 15% 70%, rgba(0, 152, 255, .32), transparent 28%),
    linear-gradient(145deg, #02030a 0%, #05143a 48%, #02030a 100%);
  color: var(--text);
  overflow-x: hidden;
}

button, input, textarea, select {
  font: inherit;
}

button {
  border: 1px solid var(--line);
  color: var(--text);
  background: rgba(8, 33, 70, .72);
  border-radius: var(--radius);
  min-height: 44px;
  padding: 11px 16px;
  cursor: pointer;
  transition: transform .16s ease, background .16s ease, border-color .16s ease;
}
button:hover { transform: translateY(-1px); border-color: rgba(46, 228, 255, .72); }
button:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.primary { background: linear-gradient(180deg, #44f0ff, #127bd9); color: #001326; border-color: rgba(211, 250, 255, .8); font-weight: 800; }
.danger { background: rgba(255, 83, 103, .18); border-color: rgba(255, 83, 103, .48); }
.ghost { background: rgba(255,255,255,.06); }
.small { min-height: 34px; padding: 7px 10px; font-size: 13px; }

a { color: var(--accent); }
input, textarea, select, .editor {
  width: 100%;
  border: 1px solid var(--line);
  color: var(--text);
  background: rgba(1, 9, 24, .72);
  border-radius: var(--radius);
  padding: 12px 13px;
  outline: none;
}
textarea { min-height: 150px; resize: vertical; }
label { display: grid; gap: 8px; color: var(--muted); font-size: 13px; }

.stage-lights { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 0; }
.stage-lights span {
  position: absolute;
  top: -16vh;
  width: 12vw;
  height: 95vh;
  background: linear-gradient(to bottom, rgba(230, 246, 255, .72), rgba(0, 151, 255, .28) 38%, transparent 76%);
  filter: blur(10px);
  transform-origin: top center;
  opacity: .55;
}
.stage-lights span:nth-child(1) { left: 8%; transform: rotate(36deg); }
.stage-lights span:nth-child(2) { left: 28%; transform: rotate(16deg); }
.stage-lights span:nth-child(3) { left: 47%; transform: rotate(0deg); opacity: .75; }
.stage-lights span:nth-child(4) { right: 27%; transform: rotate(-15deg); }
.stage-lights span:nth-child(5) { right: 7%; transform: rotate(-34deg); }

#app, #adminApp { position: relative; z-index: 1; min-height: 100vh; }
.shell { width: min(1180px, calc(100% - 28px)); margin: 0 auto; padding: 24px 0 40px; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark { width: 46px; height: 46px; border-radius: 50%; border: 2px solid rgba(211,250,255,.8); background: radial-gradient(circle, #64efff 0 34%, #095da8 36% 66%, #001a42 67%); box-shadow: 0 0 30px rgba(48, 218, 255, .42); }
.brand h1 { margin: 0; font-size: clamp(25px, 4vw, 48px); line-height: .95; text-transform: uppercase; letter-spacing: 0; }
.brand p, .muted { color: var(--muted); margin: 0; }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid var(--line); background: rgba(3, 15, 35, .64); border-radius: var(--radius); }
.avatar { width: 34px; height: 34px; border-radius: 50%; object-fit: cover; background: #123b68; display: grid; place-items: center; font-weight: 800; }

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  border-radius: var(--radius);
  backdrop-filter: blur(18px);
}
.pad { padding: clamp(16px, 3vw, 26px); }
.grid { display: grid; gap: 16px; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.between { justify-content: space-between; }
.tabs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 18px; }
.tab.active, .pill.active { background: rgba(46, 228, 255, .18); border-color: rgba(46, 228, 255, .78); }
.pill { border-radius: 999px; }
.screen-center { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.auth-card { width: min(520px, 100%); }
.auth-card h1 { font-size: clamp(34px, 8vw, 68px); margin: 0 0 8px; text-transform: uppercase; }

.game-layout { display: grid; grid-template-columns: 170px minmax(0, 1fr); gap: 16px; align-items: start; }
.chain { display: grid; gap: 9px; }
.chain-step {
  display: grid; place-items: center;
  min-height: 44px;
  border-radius: 50%;
  background: linear-gradient(180deg, rgba(72, 219, 255, .95), rgba(5, 88, 163, .92));
  border: 1px solid rgba(207, 246, 255, .72);
  color: white;
  font-weight: 900;
  text-shadow: 0 2px 8px rgba(0,0,0,.45);
}
.chain-step.hot { background: linear-gradient(180deg, #ff6b6b, #b70d22); }
.chain-step.dim { opacity: .45; }
.timer { font-size: clamp(42px, 12vw, 92px); font-weight: 900; line-height: .9; }
.timerbar { height: 8px; background: rgba(255,255,255,.12); border-radius: 999px; overflow: hidden; }
.timerbar span { display: block; height: 100%; background: linear-gradient(90deg, #2ee4ff, #ff5367); transition: width .2s linear; }
.question-text { font-size: clamp(22px, 4vw, 42px); line-height: 1.12; font-weight: 800; }
.question-text img, .editor img { max-width: min(220px, 80vw); max-height: 160px; object-fit: contain; vertical-align: middle; border-radius: 6px; border: 1px solid var(--line); background: rgba(255,255,255,.08); }
.options { display: grid; gap: 10px; }
.option { display: grid; grid-template-columns: 34px 1fr; align-items: center; gap: 12px; text-align: left; }
.option.selected { border-color: rgba(85, 242, 181, .8); background: rgba(85, 242, 181, .12); }
.keycap { width: 28px; height: 28px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 6px; color: var(--accent-2); font-weight: 900; }
.verdict { border-color: rgba(255,255,255,.28); }
.verdict.good { background: rgba(31, 166, 118, .22); }
.verdict.bad { background: rgba(255, 83, 103, .18); }
.checking { display: grid; place-items: center; gap: 14px; min-height: 210px; text-align: center; }
.spinner { width: 58px; height: 58px; border-radius: 50%; border: 4px solid rgba(255,255,255,.16); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.stat-card strong { display: block; font-size: clamp(28px, 5vw, 46px); }
.donut { width: 180px; height: 180px; border-radius: 50%; display: grid; place-items: center; margin: 0 auto; background: conic-gradient(var(--ok) var(--ok-deg), var(--danger) 0); }
.donut-inner { width: 118px; height: 118px; border-radius: 50%; display: grid; place-items: center; background: #051229; border: 1px solid var(--line); font-size: 30px; font-weight: 900; }
.leader { display: grid; gap: 8px; }
.leader-row { display: grid; grid-template-columns: 34px 1fr auto; gap: 10px; align-items: center; padding: 9px; border: 1px solid var(--line); border-radius: var(--radius); background: rgba(255,255,255,.04); }
.switch { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px; border: 1px solid var(--line); border-radius: var(--radius); }
.switch input { width: auto; transform: scale(1.2); }

.admin-layout { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 16px; align-items: start; }
.admin-menu { display: grid; gap: 8px; position: sticky; top: 16px; }
.editor { min-height: 150px; overflow: auto; line-height: 1.45; }
.question-list { display: grid; gap: 10px; }
.question-item { padding: 14px; border: 1px solid var(--line); border-radius: var(--radius); background: rgba(255,255,255,.04); display: grid; gap: 10px; }
.mini { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
.toast { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); background: rgba(1,9,24,.92); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 16px; z-index: 10; box-shadow: var(--shadow); }

.theme-apple {
  color-scheme: light;
  --bg: #f5f5f7;
  --panel: rgba(255,255,255,.86);
  --panel-2: rgba(255,255,255,.72);
  --text: #111114;
  --muted: #6e6e73;
  --line: rgba(0,0,0,.1);
  --accent: #007aff;
  --accent-2: #004a9f;
  --shadow: 0 22px 70px rgba(0,0,0,.1);
  background: radial-gradient(circle at 20% 0%, #dff2ff, transparent 28%), linear-gradient(180deg, #fbfbfd, #eff1f5);
}
.theme-apple .stage-lights { opacity: .12; }
.theme-apple button { color: var(--text); background: rgba(255,255,255,.8); }
.theme-apple .primary { color: white; background: #007aff; border-color: #007aff; }
.theme-apple input, .theme-apple textarea, .theme-apple select, .theme-apple .editor { background: rgba(255,255,255,.92); color: var(--text); }
.theme-apple .chain-step { border-radius: 8px; background: #f5f8ff; color: #0058b8; text-shadow: none; }
.theme-apple .chain-step.hot { background: #007aff; color: white; }
.theme-apple .donut-inner { background: #fff; }

@media (max-width: 860px) {
  .shell { width: min(100% - 20px, 720px); padding-top: 14px; }
  .topbar { align-items: flex-start; }
  .user-chip { width: 100%; justify-content: space-between; }
  .grid.two, .grid.three, .game-layout, .admin-layout { grid-template-columns: 1fr; }
  .chain { grid-template-columns: repeat(7, minmax(0, 1fr)); }
  .chain-step { min-height: 38px; border-radius: 8px; font-size: 13px; }
  .admin-menu { position: static; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .topbar { display: grid; }
}
