:root {
  --bg: #0a0f0c;
  --panel: #131b16;
  --panel2: #1b2620;
  --line: #27352d;
  --text: #f4f0e6;
  --muted: #9faea3;
  --gold: #e7b64a;
  --gold-ink: #1a1405;
  --green: #54d07e;
  --green-ink: #06230f;
  --red: #ff6b6b;
  --amber: #ffb454;
  --radius: 16px;
}
* { box-sizing: border-box; }
html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 18px;
  line-height: 1.35;
  -webkit-text-size-adjust: 100%;
}
button, input { font: inherit; }
h1, h2, h3, p { margin: 0; }

.screen {
  min-height: 100dvh;
  padding: calc(20px + env(safe-area-inset-top)) 20px calc(28px + env(safe-area-inset-bottom));
  max-width: 520px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.screen.wide { max-width: 1100px; }
.center { justify-content: center; align-items: center; text-align: center; }
.brand { text-align: center; padding-top: 6px; }
.wordmark { font-weight: 900; font-size: 46px; letter-spacing: 0.06em; color: var(--gold); line-height: 1; }
.sub { color: var(--muted); margin-top: 6px; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.row { display: flex; align-items: center; gap: 10px; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--muted); }
.small { font-size: 15px; }
.error { color: var(--red); }
.gold { color: var(--gold); }
.green { color: var(--green); }

.label { display: flex; flex-direction: column; gap: 6px; color: var(--muted); font-size: 15px; }
.input {
  background: var(--panel);
  border: 2px solid var(--line);
  border-radius: 12px;
  color: var(--text);
  padding: 15px 16px;
  font-size: 22px;
  width: 100%;
  outline: none;
}
.input:focus { border-color: var(--gold); }
.input.sm { font-size: 18px; padding: 10px 12px; }

.btn {
  border: 0;
  border-radius: 14px;
  padding: 14px 20px;
  font-size: 19px;
  font-weight: 700;
  background: var(--panel2);
  color: var(--text);
  min-height: 56px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.5; }
.btn-primary { background: var(--gold); color: var(--gold-ink); }
.btn-green { background: var(--green); color: var(--green-ink); }
.btn-danger { background: transparent; border: 2px solid var(--red); color: var(--red); }
.btn-ghost { background: transparent; border: 2px solid var(--line); color: var(--muted); }
.btn-xl { font-size: 26px; min-height: 72px; border-radius: 18px; }
.btn-sm { min-height: 40px; padding: 6px 12px; font-size: 15px; border-radius: 10px; }
.btn-block { width: 100%; }

.admin-link { align-self: center; color: var(--muted); font-size: 14px; text-decoration: none; opacity: 0.7; padding: 10px 16px; }
.notice { background: var(--panel); border-left: 4px solid var(--amber); padding: 12px 14px; border-radius: 10px; }
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.card.hot { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold) inset; }
.big { font-size: 64px; font-weight: 900; line-height: 1; color: var(--gold); }
.huge { font-size: 32px; font-weight: 800; line-height: 1.15; }
.title { font-size: 22px; font-weight: 800; }
.pill {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  background: var(--panel2);
  color: var(--muted);
  white-space: nowrap;
}
.pill-red { background: #3a1a1a; color: var(--red); }
.pill-gold { background: #3a2f12; color: var(--gold); }
.pill-green { background: #10321c; color: var(--green); }

.takeover {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  padding: 24px;
  text-align: center;
  animation: flash 1s ease-in-out infinite alternate;
}
@keyframes flash {
  from { background-color: var(--bg); }
  to { background-color: #241d08; }
}
.ring { position: relative; width: 220px; height: 220px; }
.ring svg { transform: rotate(-90deg); width: 100%; height: 100%; }
.ring .n {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 76px;
  font-weight: 900;
  color: var(--gold);
  font-variant-numeric: tabular-nums;
}

.score { display: grid; grid-template-columns: 1fr auto 1fr; gap: 6px; align-items: start; }
.score .col { display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; min-width: 0; }
.score .who { font-size: 14px; color: var(--muted); font-weight: 700; min-height: 2.6em; overflow: hidden; max-width: 100%; }
.score .num { font-size: 72px; font-weight: 900; line-height: 1; font-variant-numeric: tabular-nums; }
.score .col.mine .num { color: var(--gold); }
.score .col.mine .who { color: var(--gold); }
.score .vs { font-size: 40px; font-weight: 900; color: var(--muted); padding-top: 2.4em; }
.score .btns { display: flex; gap: 5px; flex-wrap: wrap; justify-content: center; }
.score .btns .btn { min-width: 42px; min-height: 44px; padding: 6px 4px; font-size: 16px; }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.seg { display: flex; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.seg button {
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 10px 16px;
  font-weight: 800;
  font-size: 18px;
  min-width: 50px;
  min-height: 48px;
}
.seg button.on { background: var(--gold); color: var(--gold-ink); }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 14px; }
.line { display: flex; flex-direction: column; gap: 6px; }
.line-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background: var(--panel2);
  border-radius: 10px;
}
.pos { width: 24px; color: var(--muted); font-weight: 800; }
.names { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.slot { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 10px; background: var(--panel2); }
.line-row.me { outline: 2px solid var(--gold); }
.card.list { gap: 8px; }
.bracket { display: flex; flex-direction: column; gap: 10px; }
.bracket .rnd { display: flex; flex-direction: column; gap: 6px; }
.bracket .rnd-label { text-transform: uppercase; letter-spacing: 0.08em; font-size: 12px; }
.mrow { display: flex; align-items: center; gap: 10px; padding: 8px 10px; background: var(--panel2); border-radius: 10px; }
.mrow.live { border: 1px solid var(--gold); }
.mrow.me { outline: 2px solid var(--gold); }
.mrow .names { white-space: normal; }
.me-name { text-decoration: underline; text-decoration-color: var(--gold); text-underline-offset: 3px; }
.tv .bracket { display: grid; grid-template-columns: repeat(auto-fit, minmax(28vw, 1fr)); gap: 1.5vw; }
.tv .mrow { font-size: 2.4vh; padding: 1vh 1vw; }
.tv .rnd-label { font-size: 1.8vh; }
.sc-inline { font-size: 1.25em; font-weight: 900; }
.scoreboard { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 2vw; padding: 1vh 0; }
.scoreboard .side { display: flex; flex-direction: column; align-items: center; gap: 0.8vh; min-width: 0; }
.scoreboard .nm { font-size: 3vh; font-weight: 800; text-align: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.scoreboard .sc { font-size: 13vh; font-weight: 900; color: var(--gold); line-height: 1; font-variant-numeric: tabular-nums; }
.scoreboard .colon { font-size: 8vh; font-weight: 900; color: var(--muted); padding-top: 3vh; }
.scoreboard .bar { width: 80%; height: 1.2vh; background: var(--line); border-radius: 999px; overflow: hidden; }
.scoreboard .bar i { display: block; height: 100%; background: var(--gold); transition: width 0.3s; }
.qr { width: min(70vw, 360px); height: auto; border-radius: 12px; background: #fff; display: block; margin: 0 auto; }
.slot.col, .line-row.col { flex-direction: column; align-items: stretch; gap: 8px; }
.slot.empty { color: var(--muted); border: 1px dashed var(--line); background: transparent; }
.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  background: #3a1a1a;
  color: #fff;
  padding: 12px 18px;
  border-radius: 12px;
  border: 1px solid var(--red);
  max-width: 90vw;
  z-index: 9;
}
.bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  background: var(--amber);
  color: var(--gold-ink);
  text-align: center;
  font-weight: 700;
  padding: 6px;
  z-index: 10;
  font-size: 15px;
}
.settings { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; align-items: end; }
@media (max-width: 480px) { .settings { grid-template-columns: 1fr; } }

.tv { max-width: none; padding: 3vh 3vw; }
.tv .grid { grid-template-columns: repeat(auto-fit, minmax(min(100%, 40vw), 1fr)); gap: 2vw; }
.tv .card { padding: 2.5vh 2vw; gap: 1.6vh; }
.tv .title { font-size: 3.2vh; }
.tv .huge { font-size: 4.6vh; }
.tv .line-row { font-size: 2.8vh; padding: 1.2vh 1.5vw; }
.tv .wordmark { font-size: 7vh; }
.tv .sub { font-size: 2.6vh; }
.tv .called-row { border: 1px solid var(--gold); animation: pulse 0.9s infinite alternate; }
.tv .pill { font-size: 2vh; padding: 0.4vh 1.2vw; }
.tv .pos { width: 3vw; }
.tv .small { font-size: 2.2vh; }
.tv .card.list { gap: 1.2vh; }
@keyframes pulse {
  from { opacity: 1; }
  to { opacity: 0.5; }
}
