:root {
  --red: #D11216;
  --red-dark: #8E0B0E;
  --black: #120F19;
  --white: #FFFFFF;
  --bg: #F4F3F5;
  --surface: #FFFFFF;
  --text: #120F19;
  --muted: #6B6872;
  --border: #DDDBE0;
  --warn-bg: #FFF1F1;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0C0A10;
    --surface: #1B1822;
    --text: #F4F3F5;
    --muted: #A19EA8;
    --border: #312D3A;
    --warn-bg: #2A1214;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

body { padding-bottom: calc(72px + env(safe-area-inset-bottom)); }

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  padding-top: calc(10px + env(safe-area-inset-top));
  background: var(--red);
  color: var(--white);
  position: sticky;
  top: 0;
  z-index: 5;
}
.topbar-logo { height: 40px; }
.topbar h1 {
  margin: 0;
  font: 400 26px/1 Anton, Impact, sans-serif;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

main { max-width: 720px; margin: 0 auto; padding: 8px 16px 24px; }

h2 {
  font: 400 22px/1.2 Anton, Impact, sans-serif;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  margin: 20px 0 8px;
}

.tab { display: none; }
.tab.active { display: block; }

.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }

.hint { color: var(--muted); font-size: 14px; margin: 4px 0 12px; }
.empty { color: var(--muted); text-align: center; padding: 24px 0; }

label { display: block; font-size: 14px; color: var(--muted); margin-bottom: 12px; }
label.inline { display: inline-flex; align-items: center; gap: 6px; margin: 0; }

input[type=text], input[type=date], input[type=number], select {
  display: block;
  width: 100%;
  margin-top: 4px;
  padding: 10px 12px;
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  min-height: 44px;
}
label.inline input { width: 80px; margin: 0; }
input[type=range] { width: 100%; accent-color: var(--red); }
input[type=file] { font-size: 14px; max-width: 100%; color: var(--text); }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 420px) { .grid2 { grid-template-columns: 1fr; } }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  padding: 0 16px;
  font: 600 15px/1 system-ui, sans-serif;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  text-decoration: none;
}
.btn.primary { background: var(--red); border-color: var(--red); color: var(--white); }
.btn.danger { color: var(--red); border-color: var(--red); }
.btn.small { min-height: 34px; padding: 0 12px; font-size: 13px; }
.btn:disabled { opacity: 0.5; cursor: default; }

.row-buttons { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; align-items: center; }
.spacer { flex: 1; }

.player-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.player-list li {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
}
.player-num {
  flex: none;
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  background: var(--red);
  color: var(--white);
  font: 400 24px/1 Anton, Impact, sans-serif;
  border-radius: 6px;
}
.player-name { flex: 1; min-width: 0; }
.player-name strong { display: block; text-transform: uppercase; }
.player-name span { color: var(--muted); font-size: 13px; }
.badge { font-size: 12px; padding: 2px 8px; border-radius: 999px; background: var(--bg); color: var(--muted); white-space: nowrap; }
.badge.ok { background: var(--black); color: var(--white); }

.lineup { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.lineup li {
  display: grid;
  grid-template-columns: 36px 1fr 84px auto;
  gap: 6px;
  align-items: center;
}
.lineup select { margin: 0; }
.order {
  height: 44px;
  display: grid;
  place-items: center;
  background: var(--black);
  color: var(--white);
  font: 400 22px/1 Anton, Impact, sans-serif;
  border-radius: 6px;
}
.move { display: flex; gap: 2px; }
.move button {
  width: 34px;
  height: 44px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 6px;
  cursor: pointer;
}

.warnings { list-style: none; padding: 0; margin: 12px 0; }
.warnings li, p.warnings { background: var(--warn-bg); color: var(--red); padding: 8px 12px; border-radius: 8px; margin-bottom: 6px; font-size: 14px; }

.music-info { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 12px; font-size: 14px; }

.stage { display: flex; justify-content: center; margin: 12px 0; }
.stage canvas, .result video {
  width: auto;
  height: min(70vh, 640px);
  max-width: 100%;
  aspect-ratio: 9 / 16;
  background: var(--black);
  border-radius: 12px;
}
.result { display: flex; flex-direction: column; align-items: center; }

.progress { display: flex; align-items: center; gap: 10px; margin: 12px 0; }
.progress-bar { flex: 1; height: 10px; background: var(--border); border-radius: 999px; overflow: hidden; }
#progress-fill { height: 100%; width: 0; background: var(--red); transition: width 0.2s; }

.tabs {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  background: var(--black);
  padding-bottom: env(safe-area-inset-bottom);
  z-index: 5;
}
.tabs button {
  flex: 1;
  min-height: 60px;
  background: none;
  border: none;
  border-top: 3px solid transparent;
  color: #A19EA8;
  font: 400 18px/1 Anton, Impact, sans-serif;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  cursor: pointer;
}
.tabs button.active { color: var(--white); border-top-color: var(--red); }

dialog {
  width: min(560px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  padding: 16px;
  border: none;
  border-radius: 14px;
  background: var(--surface);
  color: var(--text);
}
dialog::backdrop { background: rgba(0, 0, 0, 0.6); }
dialog h2 { margin-top: 0; }
fieldset { border: 1px solid var(--border); border-radius: 10px; margin: 0 0 12px; padding: 10px 12px; }
legend { font-size: 14px; color: var(--muted); padding: 0 4px; }
#clip-video, #photo-img { display: block; width: 100%; max-height: 40vh; object-fit: contain; background: #000; border-radius: 8px; margin: 8px 0; }

/* Login page */
.login { max-width: 360px; margin: 10vh auto 0; padding: 0 16px; text-align: center; }
.login form { display: grid; gap: 12px; text-align: left; margin-top: 16px; }
.login .btn { justify-self: stretch; }
