#ctv-tournament[hidden], #ctv-tournament [hidden],
#ctv-tournament-hud[hidden], #ctv-tournament-hud [hidden] { display: none; }
#ctv-tournament:not([hidden]) ~ #ctv-chat-toggle { visibility: hidden; }

#ctv-tournament {
  position: absolute;
  z-index: 87;
  inset: 0;
  display: grid;
  place-items: center;
  padding: max(12px, env(safe-area-inset-top)) 14px max(12px, env(safe-area-inset-bottom));
  background: #07182799;
  color: #15364f;
  font: 14px/1.42 system-ui, sans-serif;
}

.ctv-match-panel {
  width: min(100%, 380px);
  max-height: min(100%, 660px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: linear-gradient(160deg, #e5f6ff, #f8fcff 70%);
  border: 1px solid #8bc6eb;
  border-radius: 14px;
  box-shadow: 0 12px 36px #0617278c;
}

.ctv-match-header {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 13px;
  background: linear-gradient(140deg, #247cab, #377eaa 65%, #2c6c97);
  color: white;
  border-bottom: 1px solid #b4dcf0;
}
.ctv-match-header h2 { margin: 0; font-size: 19px; }
.ctv-match-header p { margin: 0; color: #dceeff; font-size: 12px; }

#ctv-tournament .ctv-match-panel {
  border-color: #87c9ed;
  border-radius: 6px;
  background: linear-gradient(159deg, #a3d0e8, #e6f4fc 59%, #e0effb);
}
#ctv-tournament .ctv-match-header {
  background: repeating-linear-gradient(139deg, #d2f4fc22 0 2px, transparent 2px 5px, #2378bb16 5px 7px),
    linear-gradient(157deg, #87dcff, #56afe6 54%, #77c8f5);
  color: #163c55;
  border-bottom-color: #8cc8e7;
}
#ctv-tournament .ctv-match-header p { color: #254f6c; }

#ctv-tournament #ctv-tournament-close {
  font-size: 25px;
  line-height: 1;
  width: 36px;
  height: 36px;
  border-color: transparent;
  background: transparent;
  color: white;
}
.ctv-match-body { padding: 14px; overflow: auto; min-height: 0; touch-action: pan-y; }
#ctv-tournament-content { display: grid; gap: 11px; }
#ctv-tournament-content h3 { margin: 0; font-size: 15px; overflow-wrap: anywhere; }
#ctv-tournament-content p, #ctv-tournament-status { margin: 0; }
#ctv-tournament-status { color: #9d301c; }
#ctv-tournament-status:not(:empty) { margin-top: 10px; }
.ctv-match-muted { color: #496780; font-size: 13px; }
.ctv-match-pot {
  width: fit-content;
  border: 1px solid #ebd38f;
  border-radius: 7px;
  padding: 5px 9px;
  color: #684800;
  background: #fff1c3;
  font-weight: 700;
}

#ctv-tournament button {
  border: 1px solid #8fb7cd;
  border-radius: 5px;
  min-height: 37px;
  padding: 5px 10px;
  color: #173c56;
  background: linear-gradient(#ace8ff, #d9f6ff);
  font: inherit;
  font-weight: 650;
  cursor: pointer;
}
#ctv-tournament button:disabled { opacity: .58; cursor: default; }
#ctv-tournament .ctv-match-primary {
  background: linear-gradient(155deg, #ffdc65 0%, #edac20 40%, #ffd76b 88%);
  border-color: #d8a13c;
  color: #46300d;
  box-shadow: inset 0 1px 0 #fff5bd;
}
.ctv-match-actions, .ctv-match-code { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.ctv-match-code span { font-weight: 700; letter-spacing: .07em; }
.ctv-match-code button { font-size: 12px; min-height: 29px; }
.ctv-match-row, .ctv-match-standings li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px solid #cbddea;
}
.ctv-match-row strong, .ctv-match-standings li span { display: block; overflow-wrap: anywhere; }
.ctv-match-row button { flex: none; }
.ctv-match-standings { margin: 0; padding: 0; list-style: none; }
.ctv-match-standings li.mine { font-weight: 700; }
.ctv-match-row small, .ctv-match-standings small { color: #3f6077; }
.ctv-match-standings small { flex: none; text-align: right; }
.ctv-match-player { flex: 1; }
.ctv-match-standings li .ctv-match-position {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  width: 35px;
  height: 24px;
  border-radius: 4px;
  background: #6bacd029;
  color: #2b5974;
  font-size: 12px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.ctv-match-standings li .ctv-match-position.first { background: #f3c76559; color: #694600; }
.ctv-match-position .ctv-match-crown { width: 13px; height: 10px; background: #a46c16; }
.ctv-match-result { padding: 8px 10px; border-radius: 7px; background: #d4eeca; font-weight: 700; }
.ctv-match-form { display: grid; gap: 10px; }
.ctv-match-form-pair { display: grid; gap: 8px; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.ctv-match-field { display: grid; gap: 4px; font-size: 12px; font-weight: 650; }
.ctv-match-field input, .ctv-match-field select {
  box-sizing: border-box;
  width: 100%;
  min-width: 0;
  min-height: 39px;
  padding: 5px 7px;
  border: 1px solid #8fb5cc;
  border-radius: 7px;
  color: #173c56;
  background: #f5fbff;
  font: 400 16px system-ui, sans-serif;
}
.ctv-match-rules { color: #385d77; font-size: 12px; }
.ctv-match-rules summary { cursor: pointer; color: #26628b; font-weight: 700; }
#ctv-tournament-content .ctv-match-rules p { margin-top: 5px; }

#ctv-tournament-hud {
  position: absolute;
  inset: 0;
  z-index: 80;
  pointer-events: none;
  color: #f3fbff;
  font: 13px/1.3 system-ui, sans-serif;
}
.ctv-match-hud-top {
  position: absolute;
  top: max(41px, calc(env(safe-area-inset-top) + 36px));
  left: clamp(58px, 16.5%, 80px);
  right: 14px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 4px 8px;
}
.ctv-match-time, #ctv-tournament-rank {
  box-sizing: border-box;
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: 34px;
  padding: 4px 9px;
  border: 1px solid #e9f7fc52;
  border-radius: 7px;
  background: #173648a3;
  color: #f2faff;
  text-shadow: 0 1px 3px #08202d;
  font: inherit;
  font-variant-numeric: tabular-nums;
}
.ctv-match-time { width: fit-content; max-width: 100%; white-space: nowrap; }
#ctv-tournament-timer { font-size: 14px; letter-spacing: .02em; }
.ctv-match-time.ending { color: #ffdea0; }
.ctv-match-clock {
  position: relative;
  width: 14px;
  height: 14px;
  flex: none;
  box-sizing: border-box;
  border: 1px solid #f2faffb3;
  border-radius: 50%;
}
.ctv-match-clock::after {
  content: '';
  position: absolute;
  left: 5px;
  top: 2px;
  width: 3px;
  height: 4px;
  border-left: 1px solid currentColor;
  border-bottom: 1px solid currentColor;
}
#ctv-tournament-rank { pointer-events: auto; cursor: pointer; white-space: nowrap; }
.ctv-match-crown {
  display: inline-block;
  width: 17px;
  height: 14px;
  flex: none;
  background: #ffe3a8b3;
  clip-path: polygon(2% 22%, 27% 42%, 50% 4%, 73% 42%, 98% 22%, 85% 80%, 15% 80%, 15% 91%, 85% 91%, 85% 100%, 15% 100%);
}
#ctv-tournament-rank.leader .ctv-match-crown { background: #ffdc89; }
#ctv-tournament-score { padding-left: 6px; border-left: 1px solid #e9f7fc4f; color: #d8ebf5; }
#ctv-tournament-supplies {
  grid-column: 1 / -1;
  justify-self: end;
  color: #eff9fc;
  text-shadow: 0 1px 3px #061b29, 0 1px 6px #061b29;
  font-variant-numeric: tabular-nums;
}
