:root {
  color-scheme: dark;
  --bg: #0f0d19;
  --panel: #1a172c;
  --field: #120f1f;
  --line: #2c2843;
  --ink: #f1ede4;
  --muted: #a29eb9;
  --accent: #38bdf8;
  --accent-ink: #04121c;
  --accent-deep: #1e7fae;
  --frame: rgba(56, 189, 248, .38);
  --glow: rgba(56, 189, 248, .12);
  --ok: #7fd9a2;
  --warn: #ffcf70;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { height: 100%; background: var(--bg); }

body {
  height: 100%; margin: 0; padding: 12px 16px 16px; color: var(--ink);
  background: radial-gradient(1000px 360px at 50% -160px, var(--glow), transparent 70%) no-repeat, var(--bg);
  font: 15px/1.45 "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
}

p { margin: 0; }
code { font-family: Consolas, "Cascadia Mono", monospace; font-size: 13px; color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.page { height: 100%; display: flex; flex-direction: column; gap: 12px; }
.top {
  position: relative; flex: none; align-self: center; max-width: 100%;
  display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px 12px;
  padding: 7px 8px 7px 12px; border-radius: 18px; background: var(--panel); border: 1px solid var(--line);
  box-shadow: 0 12px 32px rgba(0, 0, 0, .28);
}
.logo { display: block; flex: none; border-radius: 8px; }
.logo img { display: block; width: 140px; height: auto; transition: transform .15s; }
.logo:hover img { transform: scale(1.04); }
.brand-box { flex: none; display: flex; flex-direction: column; align-items: center; gap: 2px; }
.edition { margin: 0; display: flex; align-items: center; gap: 5px; line-height: 1; white-space: nowrap; }
.edition b {
  font-size: 10px; font-weight: 900; letter-spacing: .08em; text-transform: uppercase; color: var(--accent);
}
.edition .alpha {
  padding: 1px 5px 2px; border-radius: 5px; background: #ff3b3b; color: #fff; font-size: 9.5px; font-weight: 900;
  letter-spacing: .12em; text-transform: uppercase;
}
.alpha-note { margin: 0; color: #ff5a5a; font-weight: 700; text-align: center; }
.alpha-note a { color: #ff8a8a; }
.foot {
  flex: none; display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 2px 16px;
  padding: 0 8px; font-size: 13px;
}
.tagline {
  flex: 0 1 auto; min-width: 0; color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.tagline:empty { display: none; }
.tagline.ok { color: var(--ok); }
.tagline.warn { color: var(--warn); }
.controls { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.controls input { width: 110px; }
#play { min-width: 7.5em; }
#pause { min-width: 8em; }
#next { min-width: 6em; }
#restart { min-width: 6.2em; }
#reset { min-width: 5.6em; }
button.armed { border-color: var(--warn); color: var(--warn); }
.author { color: var(--muted); white-space: nowrap; }
.author a { color: var(--accent); font-weight: 700; text-decoration: none; }
@media (max-width: 560px) {
  .author { white-space: normal; text-align: center; }
}
.author a:hover { text-decoration: underline; }
.rules {
  width: min(760px, 94vw); max-height: 88vh; padding: 0; color: var(--ink); background: var(--panel);
  border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 24px 60px rgba(0, 0, 0, .6);
}
.rules[open] { display: flex; flex-direction: column; }
.rules::backdrop { background: rgba(8, 6, 14, .72); }
.rules-head {
  display: flex; align-items: center; gap: 12px; padding: 16px 20px 12px; border-bottom: 1px solid var(--line);
}
.rules-head h2 {
  margin: 0; font-size: 20px; letter-spacing: .02em; text-transform: none; color: var(--accent); font-weight: 900;
}
.rules-x {
  margin-left: auto; width: 34px; height: 34px; padding: 0; font-size: 22px; line-height: 1; font-weight: 400;
  color: var(--muted); background: none;
}
.rules-x:hover { color: var(--ink); }
.rules-body { flex: 1; min-height: 0; overflow-y: auto; padding: 14px 20px 6px; }
.rules-body .lead { font-size: 16px; }
.rules-body .alpha { color: #ff5a5a; font-weight: 700; }
.rules-body h3 { margin: 18px 0 8px; font-size: 16px; font-weight: 800; color: var(--ink); }
.rules-body ul, .rules-body ol { margin: 0; padding-left: 22px; display: grid; gap: 6px; }
.rules-body li::marker { color: var(--accent); }
.rules-body a { color: var(--accent); }
.rules-body .note-line { margin-top: 8px; color: var(--muted); font-size: 14px; }
.rules-commands { margin: 0; display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 6px 14px; }
.rules-commands dt { white-space: nowrap; }
.rules-commands dd { margin: 0; color: var(--muted); }
.rules-foot { display: flex; justify-content: flex-end; padding: 12px 20px 16px; border-top: 1px solid var(--line); }
.rules-foot button { min-width: 8em; }
.news { width: min(600px, 94vw); }
.news-list { margin: 0; padding-left: 22px; display: grid; gap: 12px; font-size: 16px; line-height: 1.45; }
.news-list b { color: var(--ink); }
.news-list .alpha-word { color: #ff5a5a; }
@media (max-width: 560px) {
  .rules-commands { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .rules-commands dd { margin-bottom: 6px; }
}

.popover {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 5; width: min(600px, 100%);
  box-shadow: 0 18px 44px rgba(0, 0, 0, .55);
}

.panel {
  background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 16px 18px; min-width: 0;
}
h2, legend {
  margin: 0 0 10px; padding: 0; font-size: 13px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase;
  color: var(--muted);
}
.hint { color: var(--muted); font-size: 13px; }
.panel > .hint { margin-top: 8px; }

.layout {
  flex: 1; min-height: 0; display: grid; gap: 16px;
  grid-template: minmax(0, 1fr) / minmax(0, 1fr);
}
.layout.with-settings { grid-template-columns: minmax(0, 1fr) 400px; }
.stage { min-width: 0; min-height: 0; display: grid; place-items: start center; container-type: size; }
.screen {
  position: relative; width: 100%; height: 100%; border-radius: 18px; overflow: hidden;
  border: 1px solid var(--frame); box-shadow: 0 24px 70px var(--glow), 0 18px 40px rgba(0, 0, 0, .35);
  background: repeating-conic-gradient(#201d33 0% 25%, #191728 0% 50%) 0 0 / 28px 28px;
}
@supports (width: 1cqw) {
  .screen { width: min(100cqw, 100cqh * 16 / 9); height: auto; aspect-ratio: 16 / 9; }
}
.screen iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; color-scheme: light; }
.note {
  position: absolute; left: 50%; top: 4px; transform: translateX(-50%); padding: 2px 12px; border-radius: 999px;
  background: rgba(15, 13, 25, .9); border: 1px solid var(--line); color: var(--muted); font-size: 13px;
  white-space: nowrap; pointer-events: none;
}
.settings { min-height: 0; overflow-y: auto; }
@media (max-width: 900px) {
  html, body, .page { height: auto; }
  .layout, .layout.with-settings { grid-template: auto / minmax(0, 1fr); }
  .stage { container-type: normal; }
  .screen { width: 100%; height: auto; aspect-ratio: 16 / 9; }
  .settings { overflow-y: visible; }
}

button {
  font: inherit; font-weight: 700; color: var(--ink); background: #252139; border: 1px solid var(--line);
  border-radius: 11px; padding: 8px 12px; cursor: pointer;
}
button:hover { border-color: var(--muted); }
button:disabled { opacity: .5; cursor: default; }
button.primary {
  background: var(--accent); border-color: var(--accent); color: var(--accent-ink);
  box-shadow: 0 3px 0 var(--accent-deep);
}
button.primary:active:not(:disabled) { transform: translateY(2px); box-shadow: 0 1px 0 var(--accent-deep); }
button.quiet { background: none; color: var(--muted); font-weight: 400; }
button[aria-expanded="true"] { border-color: var(--accent); color: var(--accent); }

input, select {
  font: inherit; color: var(--ink); background: var(--field); border: 1px solid var(--line); border-radius: 10px;
  padding: 7px 10px; min-width: 0;
}
input[type=number] { width: 86px; }
input[type=color] { width: 54px; height: 34px; padding: 3px; }
input[type=range] {
  flex: 1 1 140px; max-width: 220px; padding: 0; border: 0; background: none; accent-color: var(--accent);
}
input[type=checkbox] { width: 17px; height: 17px; accent-color: var(--accent); flex: none; margin: 2px 0 0; }

.row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.row > input[type=text] { flex: 1 1 140px; }

#link { font-family: Consolas, "Cascadia Mono", monospace; font-size: 13px; }
.status { margin-top: 10px; font-size: 14px; color: var(--muted); }
.status:empty { display: none; }
.status.warn { color: var(--warn); }

fieldset { border: 0; margin: 0 0 18px; padding: 0; display: grid; gap: 12px; min-width: 0; }
.split {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px 24px; align-items: start;
}
.group { display: grid; gap: 12px; min-width: 0; }
.field { display: grid; gap: 4px; min-width: 0; }
.field > label, .field > .label { font-weight: 600; }
.check { display: flex; gap: 9px; align-items: flex-start; }
.check span { display: block; }

.switch {
  display: inline-flex; justify-self: start; border: 1px solid var(--line); border-radius: 11px; overflow: hidden;
}
.switch button { border: 0; border-radius: 0; background: var(--field); color: var(--muted); white-space: nowrap; }
.switch button.on { background: var(--accent); color: var(--accent-ink); }

.footer { display: flex; justify-content: flex-end; }
