:root {
  color-scheme: dark;
  --ink: #f8fbff;
  --muted: #aeb9c8;
  --panel: rgba(10, 16, 28, 0.92);
  --panel-strong: #08101f;
  --line: rgba(255, 255, 255, 0.16);
  --green: #00a86b;
  --red: #e13b4a;
  --yellow: #ffd447;
  --blue: #1454d8;
  --cyan: #19d3ff;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.45);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Arial, Helvetica, sans-serif;
  color: var(--ink);
  background:
    linear-gradient(90deg, rgba(0, 168, 107, 0.16), transparent 24%, transparent 76%, rgba(225, 59, 74, 0.14)),
    linear-gradient(180deg, #06101f 0%, #071528 42%, #03060c 100%);
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

a {
  color: inherit;
  text-decoration: none;
}

.app-shell {
  width: min(1260px, calc(100% - 28px));
  margin: 0 auto;
  padding: 26px 0 34px;
}

.home-shell {
  display: grid;
  min-height: 100vh;
  place-items: center;
}

.home-hero {
  width: min(980px, 100%);
  display: grid;
  gap: 20px;
}

.home-hero h1,
.display-header h1,
.operator-header h1 {
  margin: 0;
  font-size: clamp(2rem, 5vw, 5rem);
  line-height: 0.98;
  letter-spacing: 0;
  text-transform: uppercase;
}

.home-copy {
  max-width: 720px;
  margin: 0;
  color: var(--muted);
  font-size: 1.06rem;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--yellow);
  font-size: 0.8rem;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

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

.court-card {
  display: grid;
  gap: 28px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.court-card h2 {
  margin: 10px 0 0;
  font-size: 2rem;
}

.pingpong-card {
  border-color: rgba(25, 211, 255, 0.36);
}

.court-badge,
.broadcast-meta span,
.match-status,
.serve-pill {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  width: max-content;
  padding: 0 12px;
  border-radius: 999px;
  color: #06101f;
  font-size: 0.78rem;
  font-weight: 900;
  background: var(--yellow);
  white-space: nowrap;
}

.link-stack {
  display: grid;
  gap: 10px;
}

.link-stack a,
.small-link {
  min-height: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  padding: 0 16px;
  color: #ffffff;
  font-weight: 900;
  background: var(--blue);
}

.display-shell {
  width: min(100% - 28px, 1540px);
  min-height: 100vh;
  display: grid;
  align-items: center;
}

.display-page {
  display: grid;
  gap: 18px;
}

.display-header,
.operator-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  padding: 18px 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(90deg, rgba(0, 168, 107, 0.2), rgba(20, 84, 216, 0.22)), var(--panel-strong);
  box-shadow: var(--shadow);
}

.display-brand {
  display: flex;
  align-items: center;
  gap: 18px;
  min-width: 0;
}

.display-logo {
  width: clamp(70px, 8vw, 116px);
  height: clamp(70px, 8vw, 116px);
  flex: 0 0 auto;
  border-radius: 50%;
  background: #ffffff;
  object-fit: contain;
  padding: 4px;
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.34);
}

.display-header h1 {
  font-size: clamp(2.2rem, 5.6vw, 6rem);
}

.broadcast-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.match-status {
  min-height: 54px;
  padding: 0 20px;
  color: #ffffff;
  font-size: 1.1rem;
  background: var(--red);
}

.arena-board {
  display: grid;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 8px;
  background: #03060c;
  box-shadow: var(--shadow);
}

.player-strip {
  display: grid;
  grid-template-columns: 86px minmax(0, 1fr) 118px 112px minmax(190px, 0.34fr);
  align-items: stretch;
  min-height: clamp(180px, 24vh, 300px);
  border-left: 12px solid transparent;
  background: linear-gradient(90deg, #10192a 0%, #10192a 52%, #07101e 100%);
}

.player-strip-b {
  background: linear-gradient(90deg, #141926 0%, #141926 52%, #07101e 100%);
}

.player-strip.serving {
  border-left-color: var(--yellow);
  box-shadow: inset 0 0 0 2px rgba(255, 212, 71, 0.38);
}

.seed-box,
.serve-chip,
.game-chip,
.mega-score {
  display: grid;
  place-items: center;
  font-weight: 900;
}

.seed-box {
  color: #06101f;
  font-size: clamp(1.3rem, 2.4vw, 2.3rem);
  background: var(--yellow);
}

.player-name-block {
  display: grid;
  align-content: center;
  gap: 12px;
  min-width: 0;
  padding: 22px 26px;
}

.country-tag {
  width: max-content;
  min-height: 30px;
  display: inline-flex;
  align-items: center;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 4px;
  padding: 0 10px;
  color: var(--cyan);
  font-size: 0.78rem;
  font-weight: 900;
}

.player-strip h2 {
  margin: 0;
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: clamp(2.2rem, 6.5vw, 7.6rem);
  line-height: 0.94;
  text-transform: uppercase;
}

.serve-chip {
  border-left: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.035);
}

.game-chip {
  border-right: 1px solid var(--line);
  color: var(--yellow);
  font-size: clamp(2.6rem, 5vw, 5.6rem);
  background: rgba(255, 255, 255, 0.04);
}

.game-serve-icon {
  display: none;
  width: clamp(62px, 5.8vw, 92px);
  height: clamp(62px, 5.8vw, 92px);
  object-fit: contain;
  transform: rotate(-18deg);
}

.game-serve-icon.active {
  display: block;
}

.serve-text-icon {
  display: none;
  width: clamp(56px, 5vw, 82px);
  height: clamp(56px, 5vw, 82px);
  place-items: center;
  border: 4px solid var(--yellow);
  border-radius: 50%;
  color: var(--yellow);
  font-size: clamp(1rem, 2vw, 1.55rem);
  font-weight: 900;
}

.sport-pingpong .game-serve-icon.active {
  display: none;
}

.sport-pingpong .serve-text-icon.active {
  display: grid;
}

.mega-score {
  color: #06101f;
  font-size: clamp(7rem, 14vw, 15rem);
  line-height: 1;
  background: #f8fbff;
}

.net-line {
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  color: #06101f;
  font-size: 1rem;
  font-weight: 900;
  text-transform: uppercase;
  background: var(--yellow);
}

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

.display-footer div,
.history-panel,
.setup-panel,
.operator-team {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.display-footer div {
  display: grid;
  gap: 6px;
  padding: 16px;
}

.display-footer span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
}

.operator-shell {
  width: min(860px, calc(100% - 18px));
  padding-top: 10px;
}

.operator-page {
  display: grid;
  gap: 14px;
}

.operator-header {
  align-items: center;
  padding: 14px;
}

.operator-header h1 {
  font-size: clamp(1.8rem, 8vw, 3.2rem);
}

.setup-panel {
  display: grid;
  grid-template-columns: 0.85fr 1fr 1fr auto;
  gap: 12px;
  align-items: end;
  padding: 14px;
}

.match-selector {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: end;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.admin-shell,
.standings-shell {
  width: min(1520px, calc(100% - 28px));
}

.admin-page,
.standings-page {
  display: grid;
  gap: 16px;
}

.admin-form {
  grid-template-columns: 0.8fr 1fr 1.2fr 1.2fr 1fr auto;
}

.admin-list-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.admin-match-list {
  display: grid;
  gap: 10px;
}

.bracket-editor {
  display: grid;
  grid-template-columns: 1.6fr 1fr 1fr 1fr;
  gap: 14px;
}

.bracket-editor section {
  display: grid;
  gap: 10px;
  align-content: start;
}

.bracket-editor h3 {
  margin: 0;
  color: var(--yellow);
  font-size: 0.95rem;
  text-transform: uppercase;
}

.bracket-editor-wide {
  min-width: 0;
}

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

.seed-editor-card {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 8px;
  align-items: start;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.04);
}

.seed-editor-card strong {
  min-height: 34px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  color: #06101f;
  background: var(--yellow);
}

.admin-match-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.04);
}

.admin-match-card div {
  display: grid;
  gap: 5px;
}

.admin-match-card span,
.empty-state,
.bracket-match span,
.bracket-match small {
  color: var(--muted);
}

.status-pill {
  min-height: 28px;
  width: max-content;
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0 10px;
  color: #06101f !important;
  font-size: 0.76rem;
  font-weight: 900;
  background: var(--yellow);
  text-transform: uppercase;
}

.bracket-board {
  display: grid;
  gap: 18px;
}

.bracket-scale-frame {
  width: 100%;
  overflow: hidden;
}

.bracket-scale-frame > .simple-bracket {
  width: 1280px;
  max-width: none;
  transform-origin: top left;
}

.bracket-image-frame {
  overflow: hidden;
  border-radius: 8px;
  background: #210305;
  box-shadow: var(--shadow);
}

.bracket-image-frame img {
  display: block;
  width: 100%;
  height: auto;
}

.simple-bracket {
  border-radius: 8px;
  padding: 22px;
  background:
    linear-gradient(135deg, rgba(86, 9, 11, 0.96), rgba(149, 18, 22, 0.96)),
    #7c1114;
  box-shadow: var(--shadow);
}

.simple-bracket-title {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: end;
  margin-bottom: 18px;
}

.simple-bracket-title p {
  margin: 0 0 4px;
  color: var(--yellow);
  font-size: 0.9rem;
  font-weight: 1000;
  text-transform: uppercase;
}

.simple-bracket-title h2 {
  margin: 0;
  color: #ffffff;
  font-size: clamp(2rem, 4vw, 4.4rem);
  line-height: 0.95;
  text-transform: uppercase;
}

.simple-bracket-title span {
  border-radius: 999px;
  padding: 9px 13px;
  color: #06101f;
  font-weight: 1000;
  background: var(--yellow);
}

.simple-bracket-grid {
  display: grid;
  grid-template-columns: 1.15fr 1fr 0.9fr 0.9fr 0.9fr 1fr 1.15fr;
  gap: 14px;
  align-items: stretch;
}

.pingpong-grid {
  grid-template-columns: 1.1fr 1fr 0.9fr 0.9fr 0.9fr 1fr 1.1fr;
}

.futsal-grid {
  grid-template-columns: 1.25fr 1fr 0.95fr 1fr 1.25fr;
}

.simple-round {
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 12px;
}

.simple-round h3 {
  min-height: 34px;
  margin: 0;
  color: #ffffff;
  font-size: 0.8rem;
  text-align: center;
  text-transform: uppercase;
}

.simple-round-list {
  display: grid;
  align-content: space-around;
  gap: 14px;
}

.simple-round.middle .simple-round-list {
  padding-block: 44px;
}

.simple-round.center .simple-round-list {
  padding-block: 132px;
}

.simple-seed-card {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr);
  min-height: 76px;
}

.simple-seed-card b {
  display: grid;
  place-items: center;
  border-radius: 6px 0 0 6px;
  color: #06101f;
  font-size: 1rem;
  background: var(--yellow);
}

.simple-seed-card div,
.simple-slot-card,
.final-round strong {
  overflow: hidden;
  border-radius: 6px;
  color: #08111f;
  background: #f8fafc;
}

.simple-seed-card div {
  display: grid;
  border-radius: 0 6px 6px 0;
}

.simple-seed-card span {
  display: grid;
  place-items: center;
  padding: 6px 8px;
  font-size: clamp(0.72rem, 0.9vw, 1rem);
  font-weight: 1000;
  text-align: center;
}

.simple-seed-card span + span {
  border-top: 1px dashed rgba(0, 0, 0, 0.25);
}

.simple-seed-card .bye {
  color: #d92d20;
}

.simple-slot-card {
  min-height: 58px;
  display: grid;
  place-items: center;
  padding: 7px 10px;
  font-size: clamp(0.72rem, 0.9vw, 1rem);
  font-weight: 1000;
  text-align: center;
}

.final-round {
  align-content: center;
}

.final-cup {
  color: var(--yellow);
  font-size: 2.7rem;
  text-align: center;
}

.final-round .simple-slot-card {
  color: #4a2b00;
  background: var(--yellow);
}

.final-round strong {
  display: grid;
  place-items: center;
  min-height: 42px;
  padding: 6px 10px;
  color: #d92d20;
  text-align: center;
}

.third-place-box {
  display: grid;
  gap: 7px;
  margin-top: 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.24);
  padding-top: 14px;
}

.third-place-box h4 {
  margin: 0;
  color: #ffffff;
  font-size: 0.78rem;
  text-align: center;
  text-transform: uppercase;
}

.third-place-box strong {
  color: #06101f;
  background: #ffffff;
}

.simple-bracket-footer {
  display: flex;
  justify-content: center;
  gap: 22px;
  margin-top: 20px;
  color: #ffffff;
  font-weight: 900;
  text-transform: uppercase;
}

.simple-bracket-footer strong {
  color: var(--yellow);
}

.badminton-fixed-bracket {
  position: relative;
  overflow: hidden;
  aspect-ratio: 16 / 9;
  border-radius: 8px;
  background:
    radial-gradient(circle at 50% 46%, rgba(175, 35, 34, 0.55), transparent 38%),
    linear-gradient(135deg, #4c0305 0%, #760b0d 50%, #a31a1d 100%);
  box-shadow: var(--shadow);
}

.poster-canvas {
  position: absolute;
  top: 0;
  left: 50%;
  width: 1536px;
  height: 900px;
  transform: translateX(-50%) scale(1);
  transform-origin: top center;
}

.poster-lines {
  position: absolute;
  inset: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
  fill: none;
  stroke: rgba(255, 255, 255, 0.82);
  stroke-width: 2;
  stroke-linecap: square;
  stroke-linejoin: miter;
}

.poster-title {
  position: absolute;
  top: 38px;
  left: 50%;
  z-index: 3;
  display: flex;
  align-items: flex-start;
  gap: 18px;
  transform: translateX(-50%);
}

.poster-title h2 {
  margin: 0;
  color: #ffffff;
  font-size: clamp(3.2rem, 6.2vw, 7rem);
  font-style: italic;
  font-weight: 1000;
  line-height: 0.82;
  text-align: right;
  text-transform: uppercase;
  letter-spacing: 0;
  text-shadow: 0 6px 16px rgba(0, 0, 0, 0.28);
}

.poster-title span {
  display: inline-block;
  transform: rotate(-1deg);
  padding: 9px 12px;
  color: #ffffff;
  font-size: clamp(1.25rem, 2vw, 2.2rem);
  font-style: italic;
  font-weight: 1000;
  line-height: 1.12;
  background: var(--yellow);
  text-transform: uppercase;
}

.poster-checker {
  position: absolute;
  top: 58px;
  z-index: 2;
  width: 118px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 9px;
  transform: skewX(-8deg);
}

.poster-checker-left {
  left: 165px;
}

.poster-checker-right {
  right: 165px;
}

.poster-checker span {
  aspect-ratio: 1;
  background: #ffffff;
}

.poster-checker span:nth-child(1),
.poster-checker span:nth-child(5) {
  visibility: hidden;
}

.poster-label {
  position: absolute;
  z-index: 3;
  color: #ffffff;
  font-size: clamp(0.82rem, 1.1vw, 1.05rem);
  font-weight: 1000;
  line-height: 1.12;
  text-align: center;
  text-transform: uppercase;
}

.lq-left { left: 120px; top: 250px; }
.qf-left { left: 352px; top: 305px; }
.sf-left { left: 556px; top: 425px; }
.sf-right { right: 556px; top: 425px; }
.qf-right { right: 352px; top: 305px; }
.lq-right { right: 120px; top: 250px; }

.poster-seed,
.poster-slot,
.poster-final {
  position: absolute;
  z-index: 3;
}

.poster-seed {
  display: grid;
  grid-template-columns: 42px 162px;
  align-items: stretch;
}

.poster-seed.right {
  grid-template-columns: 162px 42px;
}

.poster-seed strong {
  display: grid;
  place-items: center;
  border-radius: 4px;
  color: #111827;
  font-size: 1.1rem;
  font-weight: 1000;
  background: var(--yellow);
}

.poster-seed.right strong {
  order: 2;
}

.poster-seed div {
  display: grid;
  border-radius: 5px;
  overflow: hidden;
  background: #f8fafc;
}

.poster-seed span,
.poster-slot,
.poster-final span {
  min-height: 47px;
  display: grid;
  place-items: center;
  padding: 4px 10px;
  color: #101828;
  font-size: clamp(0.86rem, 1.22vw, 1.28rem);
  font-weight: 1000;
  text-align: center;
}

.poster-seed span + span {
  border-top: 1px dashed rgba(20, 31, 48, 0.38);
}

.poster-seed .bye {
  color: #d92d20;
}

.poster-slot {
  width: 142px;
  min-height: 53px;
  border-radius: 5px;
  background: #f8fafc;
  color: #d92d20;
}

.poster-final {
  left: 50%;
  top: 420px;
  width: 132px;
  display: grid;
  justify-items: center;
  gap: 8px;
  transform: translateX(-50%);
}

.poster-trophy {
  font-size: 3rem;
  line-height: 1;
}

.poster-final strong {
  color: #ffffff;
  font-size: 1rem;
  font-weight: 1000;
}

.poster-final span {
  width: 130px;
  min-height: 44px;
  border-radius: 5px;
  background: var(--yellow);
}

.seed-1 { left: 70px; top: 310px; }
.seed-2 { left: 70px; top: 430px; }
.seed-3 { left: 70px; top: 590px; }
.seed-4 { left: 70px; top: 710px; }
.seed-5 { right: 70px; top: 310px; }
.seed-6 { right: 70px; top: 430px; }
.seed-7 { right: 70px; top: 590px; }
.seed-8 { right: 70px; top: 710px; }

.qf-1 { left: 330px; top: 338px; }
.qf-2 { left: 330px; top: 508px; }
.qf-3 { left: 330px; top: 640px; }
.qf-4 { left: 330px; top: 772px; }
.qf-5 { right: 330px; top: 338px; }
.qf-6 { right: 330px; top: 508px; }
.qf-7 { right: 330px; top: 640px; }
.qf-8 { right: 330px; top: 772px; }

.sf-1 { left: 528px; top: 438px; }
.sf-2 { left: 528px; top: 710px; }
.sf-3 { right: 528px; top: 438px; }
.sf-4 { right: 528px; top: 710px; }

.poster-note {
  position: absolute;
  left: 70px;
  bottom: 58px;
  z-index: 3;
  border: 1px solid rgba(255, 255, 255, 0.82);
  border-radius: 8px;
  padding: 12px 14px;
  color: #ffffff;
  font-size: 0.9rem;
  font-weight: 900;
  text-transform: uppercase;
}

.poster-note strong {
  color: var(--yellow);
}

.poster-footer {
  position: absolute;
  left: 50%;
  bottom: 34px;
  z-index: 3;
  display: grid;
  gap: 9px;
  color: #ffffff;
  font-weight: 1000;
  text-align: center;
  text-transform: uppercase;
  transform: translateX(-50%);
}

.poster-footer strong {
  font-size: 1rem;
}

.poster-footer span {
  font-size: clamp(1rem, 1.45vw, 1.45rem);
}

.poster-footer span:first-of-type {
  color: var(--yellow);
}

.standings-tools {
  display: flex;
  align-items: end;
  gap: 12px;
}

.standings-tools label {
  min-width: 190px;
}

.round-column {
  display: grid;
  align-content: start;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.round-column h2 {
  margin: 0;
  color: var(--yellow);
  font-size: 1rem;
  text-transform: uppercase;
}

.bracket-match {
  display: grid;
  gap: 7px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.05);
}

.bracket-match.finished {
  border-color: rgba(255, 212, 71, 0.5);
}

.bracket-match strong {
  border-radius: 6px;
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.06);
}

.bracket-match strong.winner {
  color: #06101f;
  background: var(--yellow);
}

.visual-bracket {
  --connector: rgba(215, 224, 238, 0.82);
  --card-bg: #f8fafc;
  --card-line: #d8e0ec;
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  min-height: 740px;
  padding: 34px 38px 44px;
  background:
    linear-gradient(135deg, rgba(4, 12, 28, 0.96), rgba(24, 38, 68, 0.94)),
    #0b1426;
  box-shadow: var(--shadow);
}

.visual-bracket-title {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: end;
  gap: 14px;
  margin-bottom: 34px;
}

.visual-bracket-title span {
  min-height: 38px;
  display: inline-grid;
  place-items: center;
  border-radius: 6px;
  padding: 0 14px;
  color: #06101f;
  font-size: 0.9rem;
  font-weight: 1000;
  background: var(--yellow);
  text-transform: uppercase;
}

.visual-bracket-title h2 {
  margin: 0;
  color: #ffffff;
  font-size: clamp(1.6rem, 3.3vw, 3.4rem);
  line-height: 0.95;
  text-transform: uppercase;
  letter-spacing: 0;
}

.bracket-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 190px minmax(0, 1fr);
  gap: 58px;
  align-items: stretch;
}

.bracket-side {
  display: grid;
  grid-template-columns: repeat(3, minmax(136px, 1fr));
  gap: 42px;
  align-items: stretch;
}

.visual-stage {
  position: relative;
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 12px;
}

.visual-stage h3,
.final-stage h3 {
  min-height: 32px;
  margin: 0;
  color: #b9c7db;
  font-size: 0.72rem;
  text-align: center;
  text-transform: uppercase;
}

.stage-matches {
  position: relative;
  display: grid;
  align-content: space-around;
  min-height: 530px;
  gap: 26px;
}

.stage-level-2 .stage-matches {
  padding-block: 74px;
}

.stage-level-3 .stage-matches {
  padding-block: 166px;
}

.visual-match,
.bracket-placeholder,
.final-slot {
  position: relative;
  display: grid;
  gap: 0;
}

.visual-match div,
.bracket-placeholder,
.final-slot {
  position: relative;
  z-index: 2;
  min-height: 35px;
  display: grid;
  place-items: center;
  border: 1px solid var(--card-line);
  padding: 7px 12px;
  color: #1d2939;
  font-size: clamp(0.68rem, 0.86vw, 0.92rem);
  font-weight: 900;
  text-align: center;
  background: var(--card-bg);
}

.visual-match div:first-child {
  border-radius: 6px 6px 0 0;
}

.visual-match div:nth-child(2) {
  border-top: 0;
  border-radius: 0 0 6px 6px;
}

.visual-match div.winner {
  color: #06101f;
  background: var(--yellow);
}

.visual-match small {
  margin-top: 5px;
  color: #93a4bd;
  font-size: 0.68rem;
  text-align: center;
}

.visual-match.finished {
  filter: drop-shadow(0 0 10px rgba(255, 212, 71, 0.22));
}

.bracket-placeholder {
  border-radius: 6px;
  color: #6b7280;
  min-height: 74px;
}

.final-stage {
  position: relative;
  display: grid;
  grid-template-rows: auto auto auto auto;
  gap: 10px;
  align-content: center;
}

.trophy {
  font-size: 2.35rem;
  text-align: center;
}

.final-slot {
  min-height: 42px;
  border-color: #e1a400;
  border-radius: 6px;
  color: #4a2b00;
  background: var(--yellow);
}

.final-stage .visual-match {
  align-self: center;
}

.bracket-side.left .visual-stage:not(:last-child) .visual-match::after,
.bracket-side.left .visual-stage:not(:last-child) .bracket-placeholder::after,
.bracket-side.right .visual-stage:not(:last-child) .visual-match::after,
.bracket-side.right .visual-stage:not(:last-child) .bracket-placeholder::after {
  content: "";
  position: absolute;
  top: 34px;
  z-index: 1;
  width: 42px;
  height: 2px;
  background: var(--connector);
}

.bracket-side.left .visual-stage:not(:last-child) .visual-match::after,
.bracket-side.left .visual-stage:not(:last-child) .bracket-placeholder::after {
  right: -42px;
}

.bracket-side.right .visual-stage:not(:last-child) .visual-match::after,
.bracket-side.right .visual-stage:not(:last-child) .bracket-placeholder::after {
  left: -42px;
}

.bracket-side.left .visual-stage:last-child .visual-match::after,
.bracket-side.left .visual-stage:last-child .bracket-placeholder::after,
.bracket-side.right .visual-stage:first-child .visual-match::after,
.bracket-side.right .visual-stage:first-child .bracket-placeholder::after {
  content: "";
  position: absolute;
  top: 34px;
  z-index: 1;
  width: 58px;
  height: 2px;
  background: var(--connector);
}

.bracket-side.left .visual-stage:last-child .visual-match::after,
.bracket-side.left .visual-stage:last-child .bracket-placeholder::after {
  right: -58px;
}

.bracket-side.right .visual-stage:first-child .visual-match::after,
.bracket-side.right .visual-stage:first-child .bracket-placeholder::after {
  left: -58px;
}

.bracket-side.left .stage-level-2 .stage-matches::before,
.bracket-side.right .stage-level-2 .stage-matches::before,
.bracket-side.left .stage-level-3 .stage-matches::before,
.bracket-side.right .stage-level-3 .stage-matches::before {
  content: "";
  position: absolute;
  z-index: 1;
  width: 2px;
  background: var(--connector);
}

.bracket-side.left .stage-level-2 .stage-matches::before {
  top: 126px;
  right: -42px;
  height: 278px;
}

.bracket-side.right .stage-level-2 .stage-matches::before {
  top: 126px;
  left: -42px;
  height: 278px;
}

.bracket-side.left .stage-level-3 .stage-matches::before {
  top: 50%;
  right: -58px;
  height: 94px;
  transform: translateY(-50%);
}

.bracket-side.right .stage-level-3 .stage-matches::before {
  top: 50%;
  left: -58px;
  height: 94px;
  transform: translateY(-50%);
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

input,
select {
  width: 100%;
  min-height: 46px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 6px;
  padding: 0 12px;
  color: var(--ink);
  background: #07101e;
}

input:focus,
select:focus,
button:focus-visible,
a:focus-visible {
  outline: 3px solid rgba(255, 212, 71, 0.45);
  outline-offset: 2px;
}

.primary-action,
.control-strip button,
.history-panel button {
  min-height: 46px;
  border: 0;
  border-radius: 6px;
  padding: 0 14px;
  color: #ffffff;
  font-weight: 900;
  background: var(--blue);
}

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

.operator-team {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 2px solid transparent;
}

.operator-team.serving {
  border-color: var(--yellow);
}

.operator-team > div:first-child {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.operator-team h2 {
  margin: 0;
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: clamp(1.05rem, 5vw, 1.8rem);
}

.team-label {
  display: inline-grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  flex: 0 0 auto;
  color: #06101f;
  font-weight: 900;
  background: var(--yellow);
}

.phone-score {
  min-height: 118px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  color: #06101f;
  font-size: clamp(5rem, 22vw, 9rem);
  line-height: 1;
  background: #f8fbff;
}

.operator-team p {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 0;
}

.operator-team p span {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 10px;
  color: var(--muted);
}

.serve-pill {
  min-height: 44px;
  width: 100%;
  justify-content: center;
}

.score-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.score-button {
  min-height: 68px;
  border: 0;
  border-radius: 8px;
  color: #ffffff;
  font-size: 2.4rem;
  font-weight: 900;
}

.score-button.add {
  background: var(--green);
}

.score-button.subtract {
  background: var(--red);
}

.control-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.control-strip button:nth-child(4) {
  background: var(--red);
}

.history-panel {
  padding: 14px;
}

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

.section-heading h2 {
  margin: 0;
  font-size: 1.2rem;
}

.inline-select {
  width: min(220px, 100%);
}

.history-panel button {
  background: #42526b;
}

ol {
  margin: 0;
  padding-left: 22px;
  color: var(--muted);
}

li + li {
  margin-top: 8px;
}

.connection-error {
  margin-top: 14px;
  border: 1px solid rgba(225, 59, 74, 0.4);
  border-radius: 8px;
  padding: 14px;
  color: #ffffff;
  background: rgba(225, 59, 74, 0.18);
}

@media (max-width: 860px) {
  .court-grid,
  .setup-panel,
  .match-selector,
  .admin-form,
  .admin-match-card,
  .bracket-layout,
  .operator-score,
  .control-strip,
  .display-footer {
    grid-template-columns: 1fr;
  }

  .bracket-side,
  .bracket-side.right {
    grid-template-columns: 1fr;
    direction: ltr;
  }

  .simple-bracket-footer,
  .simple-bracket-title {
    display: grid;
  }

  .standings-tools {
    display: grid;
    align-items: stretch;
  }

  .visual-bracket {
    min-height: auto;
    padding: 30px 14px;
  }

  .bracket-side.left .visual-stage:not(:last-child) .visual-match::after,
  .bracket-side.left .visual-stage:not(:last-child) .bracket-placeholder::after,
  .bracket-side.right .visual-stage:not(:last-child) .visual-match::after,
  .bracket-side.right .visual-stage:not(:last-child) .bracket-placeholder::after,
  .visual-stage::before,
  .stage-matches::before,
  .bracket-side.left .visual-stage:last-child::after,
  .bracket-side.right .visual-stage:first-child::after,
  .final-stage::before,
  .final-stage::after {
    display: none;
  }

  .display-header,
  .operator-header {
    display: grid;
    align-items: start;
  }

  .display-brand {
    align-items: flex-start;
  }

  .player-strip {
    grid-template-columns: 54px minmax(0, 1fr) 72px 64px minmax(104px, 0.34fr);
    min-height: 128px;
    border-left-width: 7px;
  }

  .player-name-block {
    padding: 14px;
  }

  .mega-score {
    font-size: clamp(4.6rem, 18vw, 7rem);
  }
}

@media (max-width: 560px) {
  .display-shell,
  .operator-shell,
  .home-shell {
    width: min(100% - 18px, 1260px);
    padding: 9px 0 18px;
  }

  .display-brand {
    gap: 12px;
  }

  .display-logo {
    width: 58px;
    height: 58px;
  }

  .player-strip {
    grid-template-columns: 42px minmax(0, 1fr) 48px 48px 84px;
    min-height: 112px;
  }

  .seed-box {
    font-size: 1rem;
  }

  .country-tag {
    min-height: 24px;
    padding: 0 8px;
  }

  .game-chip {
    font-size: 1.55rem;
  }

  .game-serve-icon {
    width: 42px;
    height: 42px;
  }

  .operator-score {
    gap: 10px;
  }
}
