:root {
  --bg-overlay: rgba(2, 12, 7, 0.54);
  --panel: rgba(4, 17, 10, 0.78);
  --panel-strong: rgba(5, 18, 11, 0.88);
  --line: rgba(255, 255, 255, 0.14);
  --text: #f4fff7;
  --muted: #cfe6d8;
  --accent: #78e3a4;
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.36);
  --radius: 28px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  font-family: "Segoe UI", Arial, sans-serif;
  color: var(--text);
  overflow-x: hidden;
}

body.settings-page,
body.tournament-page,
body.login-page {
  overflow-y: auto;
}

body.control-page,
body.scoreboard-page {
  overflow: hidden;
}

body {
  min-height: 100vh;
  min-height: 100svh;
  background:
    linear-gradient(180deg, var(--bg-overlay), rgba(1, 8, 4, 0.74)),
    url("logos/background.jpg") center center / cover no-repeat fixed;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background:
    radial-gradient(circle at top left, rgba(255, 255, 255, 0.08), transparent 26%),
    radial-gradient(circle at bottom right, rgba(120, 227, 164, 0.16), transparent 24%);
  pointer-events: none;
}

button, input, select { font: inherit; }

h1, h2, p {
  margin-top: 0;
}

.v2-shell,
.scoreboard-shell {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  min-height: 100svh;
  padding: clamp(8px, 1.2vw, 16px);
  overflow: hidden;
}

body.settings-page .v2-shell,
body.tournament-page .v2-shell,
body.login-page .v2-shell {
  min-height: auto;
  overflow: visible;
}

.v2-shell {
  display: flex;
  flex-direction: column;
  gap: clamp(6px, 0.8vw, 10px);
}

.login-shell {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: 20px;
}

.top-strip,
.hero-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.top-strip {
  min-height: 40px;
}

.top-strip-left,
.top-strip-right,
.hero-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.top-strip-link,
.session-pill {
  min-height: 32px;
  padding: 0 12px;
  font-size: 0.8rem;
}

.top-strip-button {
  cursor: pointer;
}

.session-pill {
  white-space: nowrap;
}

.hero-bar {
  padding: 4px 2px 8px;
}

.eyebrow {
  margin-bottom: 6px;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-size: 0.72rem;
  font-weight: 700;
}

.guard-note {
  padding: 10px 14px;
  border-radius: 16px;
  background: rgba(255, 204, 84, 0.16);
  border: 1px solid rgba(255, 204, 84, 0.26);
  color: #fff4cf;
  line-height: 1.45;
}

.ghost-link,
.live-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0 14px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.38);
  border: 1px solid var(--line);
  color: var(--text);
  text-decoration: none;
  backdrop-filter: blur(8px);
}

.control-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.7fr) minmax(300px, 0.7fr);
  gap: clamp(16px, 1.8vw, 26px);
  flex: 1 1 auto;
  min-height: 0;
}

.control-layout.solo {
  grid-template-columns: 1fr;
  min-height: 0;
}

.arena-panel,
.settings-card,
.event-card,
.score-card {
  background: linear-gradient(145deg, rgba(4, 17, 10, 0.82), rgba(5, 28, 16, 0.76));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.arena-panel {
  padding: clamp(10px, 1vw, 16px);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 0;
  overflow: hidden;
}

.team-select-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: clamp(12px, 1vw, 18px);
}

.queue-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 240px;
  gap: 12px;
}

.select-input,
.toolbar-btn,
.field input {
  width: 100%;
  min-height: clamp(58px, 7vh, 84px);
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.94);
  color: #203126;
  padding: 0 18px;
}

.select-input.away { background: rgba(255, 217, 221, 0.96); }

.match-stage {
  display: grid;
  grid-template-columns: minmax(140px, 0.7fr) minmax(240px, 1fr) minmax(140px, 0.7fr);
  align-items: center;
  gap: clamp(12px, 2vw, 24px);
  padding: clamp(4px, 1vh, 10px) 0;
  flex: 1;
  min-height: 0;
}

.team-column {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(12px, 1.2vw, 18px);
}

.logo-frame {
  width: clamp(140px, 16vw, 230px);
  height: clamp(140px, 16vw, 230px);
  border-radius: 30px;
  background: rgba(0, 0, 0, 0.34);
  display: grid;
  place-items: center;
}

.stage-logo {
  width: clamp(110px, 13vw, 190px);
  height: clamp(110px, 13vw, 190px);
  object-fit: contain;
  filter: drop-shadow(0 10px 20px rgba(0, 0, 0, 0.28));
}

.goal-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  width: 100%;
}

.score-btn {
  min-height: clamp(64px, 8vh, 92px);
  border: none;
  border-radius: 24px;
  font-size: clamp(2rem, 3.2vw, 3rem);
  color: white;
  cursor: pointer;
  box-shadow: var(--shadow);
}

.score-btn.minus { background: linear-gradient(180deg, #ef546c, #d9364e); }
.score-btn.plus { background: linear-gradient(180deg, #42cb62, #26a846); }

.center-column {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.score-cluster {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: clamp(12px, 1.8vw, 24px);
}

.score-box {
  min-width: clamp(124px, 13vw, 200px);
  padding: clamp(10px, 1.2vw, 16px) 0;
  border-radius: 28px;
  background: linear-gradient(180deg, rgba(6, 10, 12, 0.98), rgba(14, 22, 28, 0.92));
  border: 1px solid rgba(255, 255, 255, 0.14);
  text-align: center;
  font-size: clamp(4rem, 8vw, 7.2rem);
  font-weight: 700;
}

.score-divider { font-size: clamp(3rem, 5vw, 5rem); font-weight: 700; }

.clock-box {
  min-width: clamp(200px, 18vw, 320px);
  padding: clamp(10px, 1.2vw, 16px) clamp(16px, 1.4vw, 24px);
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(8, 13, 14, 0.98), rgba(16, 34, 32, 0.9));
  border: 1px solid rgba(120, 227, 164, 0.28);
  text-align: center;
  font-size: clamp(2.2rem, 4vw, 4rem);
}

.status-line { color: var(--muted); font-size: clamp(1rem, 1.4vw, 1.3rem); }

.toolbar-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 8px;
}

.toolbar-btn {
  border: none;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.9);
}

.toolbar-btn.primary {
  background: linear-gradient(180deg, #7de7ac, #43c978);
  color: #0a2413;
  font-weight: 700;
}

.toolbar-btn:disabled { opacity: 0.45; cursor: not-allowed; }

.settings-card, .event-card { padding: 20px; }
.card-head h2 { margin: 0; }
.setup-copy { color: var(--muted); line-height: 1.55; }
.setup-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  margin-top: 18px;
}

.field,
.toggle-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 16px;
}

.toggle-row {
  flex-direction: row;
  justify-content: space-between;
  align-items: center;
}

.event-title { font-size: 1.3rem; font-weight: 700; }
.event-detail { margin-top: 8px; color: var(--muted); line-height: 1.5; }

.banner {
  display: none;
  margin-bottom: 18px;
  padding: 18px 24px;
  border-radius: 24px;
  background: linear-gradient(135deg, rgba(255, 180, 84, 0.96), rgba(234, 93, 85, 0.96));
  box-shadow: var(--shadow);
}

.banner.is-visible { display: block; }
.banner-title { font-size: clamp(1.4rem, 2.4vw, 2.4rem); font-weight: 700; }
.banner-detail { margin-top: 6px; font-size: clamp(1rem, 1.4vw, 1.2rem); }

.scoreboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr));
  gap: 18px;
}

.score-card {
  padding: 22px;
  min-height: 360px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.score-card-top,
.score-card-bottom {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
}

.phase-pill,
.field-pill {
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.phase-pill.live { background: rgba(47, 208, 115, 0.2); }
.phase-pill.finished { background: rgba(255, 92, 115, 0.22); }
.phase-pill.next { background: rgba(255, 180, 84, 0.24); }

.score-match {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 18px;
}

.score-team { text-align: center; }

.score-team img {
  width: clamp(88px, 9vw, 130px);
  height: clamp(88px, 9vw, 130px);
  object-fit: contain;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 24px;
  padding: 10px;
}

.score-team-name {
  margin-top: 12px;
  font-size: clamp(1.2rem, 1.5vw, 1.5rem);
  line-height: 1.2;
}

.score-core { text-align: center; }
.scoreline { font-size: clamp(3rem, 6vw, 5.4rem); font-weight: 700; line-height: 1; }
.match-time { margin-top: 8px; color: var(--muted); font-size: clamp(1rem, 1.3vw, 1.2rem); }
.match-half { margin-top: 6px; color: var(--text); font-size: 0.95rem; opacity: 0.9; }

.score-empty {
  background: var(--panel-strong);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  min-height: 260px;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 20px;
}

.floor-banner {
  flex: 0 0 auto;
  display: grid;
  gap: 4px;
}

.ticker-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) minmax(0, 132px);
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding: 0 8px;
  border-radius: 14px;
  background: linear-gradient(90deg, rgba(7, 10, 12, 0.94), rgba(19, 32, 26, 0.94));
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: var(--shadow);
}

.ticker-row-accent {
  background: linear-gradient(90deg, rgba(90, 16, 18, 0.96), rgba(140, 32, 24, 0.96));
}

.ticker-label {
  min-width: 48px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #ffffff;
  font-size: 0.72rem;
}

.ticker-window {
  position: relative;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
}

.ticker-marquee {
  display: flex;
  width: max-content;
  min-width: 100%;
}

.ticker-track {
  display: inline-flex;
  align-items: center;
  gap: 24px;
  white-space: nowrap;
  min-width: max-content;
  padding-right: 24px;
  animation: ticker-scroll 26s linear infinite;
}

.ticker-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.86rem;
  color: #f5fff8;
}

.ticker-item strong {
  color: #7de7ac;
}

.ticker-meta {
  min-width: 0;
  max-width: 132px;
  color: rgba(255, 255, 255, 0.8);
  font-size: 0.74rem;
  text-align: right;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.event-feed {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow: hidden;
  white-space: nowrap;
}

.event-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 100%;
  padding: 5px 9px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #fff7f2;
  font-size: 0.82rem;
}

.event-chip-minute {
  color: #ffd27a;
  font-weight: 700;
}

.event-chip-text {
  overflow: hidden;
  text-overflow: ellipsis;
}

.ticker-row-bottom {
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 8px;
}

.ticker-scoreboard-link {
  min-height: 30px;
  padding: 0 10px;
  font-size: 0.74rem;
  background: rgba(255, 255, 255, 0.14);
}

.ticker-row-bottom .ticker-meta {
  display: none;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@keyframes ticker-scroll {
  from { transform: translateX(0); }
  to { transform: translateX(-50%); }
}

.settings-layout {
  display: grid;
  grid-template-columns: minmax(320px, 520px) minmax(280px, 420px);
  gap: clamp(18px, 2vw, 28px);
  align-items: start;
}

.tournament-layout {
  display: grid;
  grid-template-columns: minmax(380px, 0.9fr) minmax(0, 1.1fr);
  gap: clamp(18px, 2vw, 28px);
  align-items: start;
}

.tournament-sections {
  display: grid;
  grid-template-columns: 1fr;
  gap: clamp(18px, 2vw, 28px);
}

.settings-page-card {
  min-height: 0;
}

.settings-feedback {
  margin-top: 14px;
  color: var(--muted);
}

.tournament-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.tournament-card {
  min-height: 0;
}

.roadmap-list {
  display: grid;
  gap: 10px;
  margin-top: 18px;
}

.roadmap-item {
  padding: 12px 14px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.group-assignment,
.standings-container,
.group-matches-container {
  display: grid;
  gap: 14px;
  margin-top: 18px;
}

.export-actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  margin-top: 18px;
}

.group-assignment {
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
}

.group-draw-card,
.standing-card,
.match-group-card {
  padding: 16px;
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.group-draw-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
}

.group-slot-list,
.match-editor-list {
  display: grid;
  gap: 12px;
}

.bye-note {
  margin-top: 12px;
  color: var(--muted);
  font-size: 0.9rem;
}

.group-slot {
  display: grid;
  gap: 8px;
}

.field-inline {
  margin-top: 0;
}

.standings-table-wrap {
  overflow-x: auto;
}

.standings-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

.standings-table th,
.standings-table td {
  padding: 10px 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  text-align: left;
}

.standings-table th {
  color: var(--muted);
  font-weight: 600;
}

.match-editor {
  display: grid;
  gap: 12px;
  padding: 14px;
  border-radius: 18px;
  background: rgba(0, 0, 0, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.match-editor-main {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 72px auto 72px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
}

.match-team-name {
  font-weight: 600;
  line-height: 1.3;
}

.field-input-compact {
  width: 100%;
  min-height: 44px;
  padding: 0 12px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.96);
  color: #203126;
}

.match-score-divider {
  text-align: center;
  font-size: 1.2rem;
  font-weight: 700;
}

.match-editor-meta {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  align-items: end;
}

.match-status-pill {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 12px;
  border-radius: 14px;
  background: rgba(120, 227, 164, 0.14);
  border: 1px solid rgba(120, 227, 164, 0.22);
  color: var(--text);
}

.bracket-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 14px;
  margin-top: 18px;
}

.bracket-match {
  padding: 16px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.bracket-team-row {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr);
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.bracket-team-row:last-of-type {
  margin-bottom: 8px;
}

.bracket-seed {
  color: var(--muted);
  font-size: 0.88rem;
}

.bracket-team {
  font-weight: 600;
}

.login-card {
  width: min(100%, 520px);
  padding: 28px;
}

.login-hint {
  margin-top: 16px;
  color: var(--muted);
  font-size: 0.92rem;
}

.login-actions {
  margin-top: 22px;
}

@media (max-width: 1100px) {
  .control-layout { grid-template-columns: 1fr; }
  .settings-layout { grid-template-columns: 1fr; }
  .tournament-layout { grid-template-columns: 1fr; }
}

@media (max-width: 820px) {
  body {
    background:
      linear-gradient(180deg, var(--bg-overlay), rgba(1, 8, 4, 0.74)),
      url("logos/background-rotate.jpg") center center / cover no-repeat fixed;
  }

  body.control-page {
    overflow-y: auto;
  }

  body.control-page .v2-shell {
    min-height: auto;
    overflow: visible;
    padding-bottom: 20px;
  }

  .match-stage {
    grid-template-columns: minmax(88px, 1fr) minmax(120px, auto) minmax(88px, 1fr);
    align-items: center;
  }
  .queue-row { grid-template-columns: 1fr; }
  .toolbar-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .toolbar-grid > :first-child,
  .toolbar-grid > :last-child { grid-column: span 2; }
  .score-match { grid-template-columns: 1fr; }
  .arena-panel {
    justify-content: flex-start;
    overflow: visible;
  }
  .team-column {
    gap: 8px;
  }
  .logo-frame {
    width: clamp(74px, 22vw, 104px);
    height: clamp(74px, 22vw, 104px);
    border-radius: 20px;
  }
  .stage-logo {
    width: clamp(56px, 16vw, 80px);
    height: clamp(56px, 16vw, 80px);
  }
  .goal-buttons {
    width: 100%;
    max-width: 110px;
    gap: 6px;
  }
  .score-cluster {
    gap: 8px;
  }
  .score-box {
    min-width: 52px;
    padding: 8px 0;
    border-radius: 18px;
    font-size: clamp(2.2rem, 12vw, 3.4rem);
  }
  .score-divider {
    font-size: clamp(1.6rem, 8vw, 2.4rem);
  }
  .clock-box {
    min-width: 0;
    width: 100%;
    max-width: 220px;
    padding: 8px 14px;
    font-size: clamp(1.3rem, 7vw, 2rem);
  }
  .status-line {
    text-align: center;
    font-size: 0.82rem;
    line-height: 1.3;
  }
  .select-input,
  .toolbar-btn,
  .field input {
    min-height: 48px;
  }
  .score-btn {
    min-height: 46px;
    border-radius: 16px;
    font-size: 1.5rem;
  }
  .top-strip,
  .hero-bar,
  .top-strip-left,
  .top-strip-right,
  .hero-actions {
    flex-wrap: wrap;
  }
  .tournament-grid {
    grid-template-columns: 1fr;
  }
  .match-editor-main,
  .match-editor-meta,
  .bracket-team-row {
    grid-template-columns: 1fr;
  }
  .ticker-row {
    min-height: 40px;
    padding: 0 8px;
    gap: 8px;
  }
  .ticker-row-bottom {
    grid-template-columns: auto minmax(0, 1fr) auto;
  }
  .ticker-label {
    min-width: 48px;
    font-size: 0.72rem;
  }
  .ticker-meta {
    display: none;
  }
  .ticker-item {
    font-size: 0.84rem;
  }
  .event-chip {
    font-size: 0.8rem;
    padding: 6px 8px;
  }
  .ticker-scoreboard-link {
    justify-self: end;
    min-height: 32px;
    padding: 0 10px;
    font-size: 0.76rem;
  }
}

@media (max-width: 480px) {
  .v2-shell {
    gap: 8px;
  }

  .arena-panel {
    padding: 10px;
  }

  .match-stage {
    grid-template-columns: minmax(74px, 1fr) minmax(96px, auto) minmax(74px, 1fr);
    gap: 8px;
    padding: 8px 0;
  }

  .team-select-row {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .logo-frame {
    width: 68px;
    height: 68px;
  }

  .stage-logo {
    width: 50px;
    height: 50px;
  }

  .goal-buttons {
    max-width: 92px;
  }

  .toolbar-grid {
    grid-template-columns: 1fr;
  }

  .toolbar-grid > :first-child,
  .toolbar-grid > :last-child {
    grid-column: span 1;
  }

  .score-btn {
    min-height: 42px;
    font-size: 1.3rem;
  }

  .score-box {
    min-width: 46px;
    font-size: clamp(1.8rem, 11vw, 2.6rem);
  }

  .clock-box {
    max-width: 180px;
    font-size: clamp(1.1rem, 6.5vw, 1.6rem);
  }

  .top-strip-link,
  .session-pill {
    font-size: 0.74rem;
    padding: 0 10px;
  }

  .ticker-row {
    min-height: 36px;
  }
}
