:root {
  --gold: #dcce36;
  --card: #12002d;
  --font: "Montserrat", sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #05010a;
  color: #fff;
  font-family: var(--font);
}

.bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  background: url("/back.jpg") center / cover no-repeat;
}

.viewport {
  position: relative;
  z-index: 1;
  width: 100vw;
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.stage {
  position: relative;
  width: 1920px;
  height: 1080px;
  flex-shrink: 0;
  transform-origin: center center;
}

.header {
  position: absolute;
  left: 0;
  right: 0;
  top: 36px;
  z-index: 3;
  display: flex;
  justify-content: center;
  pointer-events: none;
}

.partners {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 22px;
  border: 0;
  padding: 0;
  margin: 0;
  background: transparent;
  cursor: pointer;
  pointer-events: auto;
  font: inherit;
  color: inherit;
}

.logo-cg {
  height: 96px;
  width: auto;
  display: block;
}

.partners-x {
  font-size: 36px;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.9);
  line-height: 1;
}

.hk-brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.logo-hk {
  height: 108px;
  width: auto;
  display: block;
  mix-blend-mode: screen;
}

.hk-text {
  display: flex;
  flex-direction: column;
  justify-content: center;
  line-height: 0.92;
  font-weight: 800;
  font-size: 38px;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: #ffe14a;
}

.bracket {
  position: absolute;
  inset: 0;
}

.wires {
  position: absolute;
  inset: 0;
  width: 1920px;
  height: 1080px;
  pointer-events: none;
  z-index: 1;
}

.wires path {
  fill: none;
  stroke-width: 1;
  vector-effect: non-scaling-stroke;
}

.matches {
  position: absolute;
  inset: 0;
  z-index: 2;
}

/* Frame 34 card: 371.281 × 98.326 */
.match {
  position: absolute;
  width: 371.281px;
  height: 98.326px;
  display: grid;
  grid-template-rows: 43.326px 43.326px 11.674px;
  grid-template-columns: minmax(0, 1fr) 45.596px;
}

.slot {
  display: contents;
}

.slot-name {
  grid-column: 1;
  display: flex;
  align-items: center;
  padding: 0 18px;
  background: rgba(18, 0, 45, 0.67);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: #fff;
}

.slot:nth-child(1) .slot-name {
  grid-row: 1;
}

.slot:nth-child(2) .slot-name {
  grid-row: 2;
  box-shadow: inset 0 1px 0 var(--gold);
}

.slot-name.is-empty {
  color: rgba(255, 255, 255, 0.35);
}

.slot.is-loser .slot-name {
  color: rgba(255, 255, 255, 0.45);
}

.slot-score {
  grid-column: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #12002d;
  box-shadow: inset 1px 0 0 var(--gold);
  font-size: 18px;
  font-weight: 700;
  color: var(--gold);
}

.slot:nth-child(1) .slot-score {
  grid-row: 1;
}

.slot:nth-child(2) .slot-score {
  grid-row: 2;
  box-shadow: inset 1px 0 0 var(--gold), inset 0 1px 0 var(--gold);
}

.slot.is-loser .slot-score {
  color: rgba(220, 206, 54, 0.45);
}

.match::after {
  content: "";
  grid-column: 1 / 2;
  grid-row: 3;
  background: #12002d;
  clip-path: polygon(0 0, 78.4% 0, 74.35% 100%, 0 100%);
}

.admin-bar {
  position: fixed;
  top: 12px;
  right: 12px;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.4rem 0.55rem;
  border-radius: 10px;
  background: rgba(8, 2, 18, 0.88);
  border: 1px solid rgba(220, 206, 54, 0.35);
  backdrop-filter: blur(8px);
}

.admin-badge {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--gold);
  padding: 0 0.35rem;
}

.tb-btn {
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
  font: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0.35rem 0.65rem;
  border-radius: 7px;
  cursor: pointer;
}

.tb-btn:hover {
  border-color: rgba(220, 206, 54, 0.55);
}

.tb-danger {
  border-color: rgba(255, 100, 120, 0.4);
  color: #ffb0ba;
}

.admin-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(4px);
}

.admin-overlay[hidden],
.admin-bar[hidden],
.side-panel[hidden] {
  display: none !important;
}

.admin-panel {
  width: min(380px, calc(100vw - 2rem));
  background: #12081c;
  border: 1px solid rgba(220, 206, 54, 0.35);
  border-radius: 14px;
  padding: 1.1rem 1.2rem 1.25rem;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
}

.admin-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}

.admin-head h2,
.side-head h3 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
}

.admin-close {
  border: 0;
  background: transparent;
  color: rgba(255, 255, 255, 0.7);
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
}

.auth-hint {
  margin: 0 0 0.85rem;
  color: rgba(255, 255, 255, 0.65);
  font-size: 0.88rem;
}

.otp {
  display: flex;
  gap: 0.4rem;
  justify-content: center;
  margin-bottom: 0.75rem;
}

.otp-box {
  width: 2.4rem;
  height: 2.8rem;
  text-align: center;
  font-size: 1.25rem;
  font-weight: 700;
  font-family: inherit;
  color: #fff;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(220, 206, 54, 0.4);
  border-radius: 8px;
  outline: none;
}

.otp-box:focus {
  border-color: var(--gold);
}

.auth-error {
  color: #ff8a9a;
  font-size: 0.85rem;
  margin: 0 0 0.6rem;
  text-align: center;
}

.auth-actions {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.btn {
  border: 1px solid rgba(220, 206, 54, 0.55);
  background: rgba(220, 206, 54, 0.15);
  color: #fff;
  font: inherit;
  font-weight: 700;
  padding: 0.55rem 0.8rem;
  border-radius: 8px;
  cursor: pointer;
}

.btn-ghost {
  background: transparent;
  border-color: rgba(255, 255, 255, 0.2);
  font-weight: 600;
}

.side-panel {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 45;
  width: min(360px, 100vw);
  height: 100vh;
  background: rgba(10, 4, 20, 0.96);
  border-left: 1px solid rgba(220, 206, 54, 0.3);
  display: flex;
  flex-direction: column;
  backdrop-filter: blur(10px);
}

.side-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1rem 0.75rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.side-body {
  overflow: auto;
  padding: 0.9rem 1rem 1.5rem;
}

.field {
  display: grid;
  grid-template-columns: 2.2rem 1fr;
  gap: 0.45rem;
  align-items: center;
  margin-bottom: 0.45rem;
}

.field label {
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.5);
}

.field input,
.score-row input {
  width: 100%;
  font: inherit;
  color: #fff;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 7px;
  padding: 0.4rem 0.55rem;
}

.match-edit {
  margin-bottom: 1rem;
  padding-bottom: 0.85rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.match-edit h3 {
  margin: 0 0 0.5rem;
  font-size: 0.85rem;
  color: var(--gold);
}

.score-row {
  display: grid;
  grid-template-columns: 1fr 4rem;
  gap: 0.4rem;
  align-items: center;
  margin-bottom: 0.35rem;
  font-size: 0.85rem;
}

.match-edit-actions {
  display: flex;
  gap: 0.4rem;
  margin-top: 0.45rem;
}

.match-edit-actions button {
  font: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
  padding: 0.3rem 0.6rem;
  cursor: pointer;
}
