#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-connection { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 11px; }
#ctv-tournament-connection p { margin: 0; color: #385d77; }
#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 {
  --time-offset: clamp(46px, calc(16.5vw - 12px), 68px);
  position: absolute;
  top: max(49px, calc(env(safe-area-inset-top) + 40px));
  left: max(12px, env(safe-area-inset-left));
  right: max(14px, env(safe-area-inset-right));
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 4px 8px;
}
.ctv-match-time {
  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; margin-left: var(--time-offset); 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-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-supplies {
  justify-self: end;
  color: #eff9fc;
  text-shadow: 0 1px 3px #061b29, 0 1px 6px #061b29;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
#ctv-tournament-standings {
  grid-column: 1 / -1;
  justify-self: end;
  width: min(174px, 100%);
  box-sizing: border-box;
  padding: 2px 4px 4px;
  border: 1px solid #ecf8ff38;
  border-radius: 12px;
  background: linear-gradient(160deg, #16374c18, #0c20292e);
  -webkit-backdrop-filter: blur(5px) brightness(92%);
  backdrop-filter: blur(5px) brightness(92%);
  box-shadow: 0 3px 12px #08172224, inset 0 1px #ffffff16;
  text-shadow: 0 1px 2px #071922, 0 0 5px #071922a6;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  #ctv-tournament-standings { background: #16374cc7; }
}
#ctv-tournament-standings.expanded { width: min(212px, 100%); }
#ctv-standings-toggle {
  display: grid;
  grid-template-columns: 19px 1fr 12px;
  align-items: center;
  gap: 6px;
  width: 100%;
  min-height: 29px;
  padding: 0 6px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: inherit;
  font: inherit;
  font-weight: 700;
  text-align: left;
  pointer-events: auto;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
#ctv-standings-toggle:active { background: #e4f6ff14; }
#ctv-standings-toggle:focus-visible { outline: 2px solid #a2ebff; outline-offset: -2px; }
.ctv-scoreboard-trophy, .ctv-scoreboard-place {
  font-size: 15px;
  line-height: 1;
  text-align: center;
}
.ctv-scoreboard-chevron {
  width: 7px;
  height: 7px;
  border: solid currentColor;
  border-width: 0 2px 2px 0;
  transform: translateY(-2px) rotate(45deg);
}
#ctv-standings-toggle[aria-expanded="true"] .ctv-scoreboard-chevron { transform: translateY(2px) rotate(225deg); }
#ctv-standings-players { margin: 0; padding: 0; list-style: none; }
#ctv-standings-players li {
  display: grid;
  grid-template-columns: 19px minmax(0, 1fr) auto;
  align-items: center;
  gap: 6px;
  min-height: 23px;
  padding: 0 6px;
  border-radius: 6px;
}
#ctv-standings-players li:first-child { background: #c4a96124; }
#ctv-standings-players li.mine { color: #fff; font-weight: 700; background: #9edcfa2b; }
#ctv-standings-players li.mine:first-child { background: #edc46c32; }
#ctv-tournament-standings:not(.expanded) :is(li:nth-child(n + 4), .ctv-scoreboard-fish) { display: none; }
#ctv-tournament-standings.expanded li { grid-template-columns: 19px minmax(0, 1fr) auto auto; }
.ctv-scoreboard-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ctv-scoreboard-fish { color: #c8dfec; font-size: 10px; white-space: nowrap; }
.ctv-scoreboard-weight { min-width: 40px; text-align: right; white-space: nowrap; }

#GameDiv.is-fishing:has(#ctv-tournament-hud:not([hidden])) #ctv-scene-chat {
  top: max(8px, env(safe-area-inset-top));
  left: max(8px, env(safe-area-inset-left));
  right: max(56px, calc(env(safe-area-inset-right) + 48px));
}
#ctv-tournament-fight {
  grid-column: 1 / -1;
  justify-self: end;
  display: grid;
  gap: 4px;
  width: 148px;
  padding: 5px 8px;
  border: 1px solid #e9f7fc52;
  border-radius: 7px;
  background: #173648dc;
  color: #f2faff;
  font-size: 11px;
}
#ctv-tournament-fight progress { width: 100%; height: 7px; accent-color: #77dcbd; }
#ctv-tournament-fight.under-strain { color: #ffe0a3; border-color: #ffc463; }

@media (orientation: landscape) and (min-width: 600px) {
  .ctv-match-hud-top {
    grid-template-columns: minmax(0, 1fr) min(212px, 48%);
    grid-template-rows: 34px auto auto;
    align-items: start;
  }
  #ctv-tournament-standings { grid-column: 2; grid-row: 1 / 3; }
  #ctv-tournament-supplies { grid-column: 2; grid-row: 3; }
  #ctv-tournament-fight {
    grid-column: 1;
    grid-row: 2;
    justify-self: start;
    margin-left: var(--time-offset);
  }
  #GameDiv.is-fishing:has(#ctv-tournament-hud:not([hidden])) #ctv-scene-chat {
    left: max(55%, calc(100% - 226px));
  }
}
