:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --paper: rgba(39, 25, 19, 0.5);
  --paper-strong: rgba(28, 18, 14, 0.74);
  --line: rgba(255, 246, 230, 0.28);
  --text: #fff8ec;
  --muted: #e5d2bd;
  --button: #f4e0bd;
  --button-text: #4b1e12;
  --accent: #79b68d;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  min-height: 100%;
  overflow: auto;
  overscroll-behavior-y: none;
}

body {
  background: #8e3d26;
}

button,
input,
textarea {
  font: inherit;
}

.app-shell {
  position: relative;
  width: min(100vw, 480px);
  min-height: 100svh;
  margin: 0 auto;
  overflow: hidden;
  background:
    linear-gradient(180deg, rgba(44, 22, 14, 0.38), rgba(24, 14, 10, 0.52)),
    url("clay-court-background.png") center / cover;
  box-shadow: 0 0 48px rgba(24, 11, 7, 0.55);
}

.app-shell::before {
  content: "";
  position: absolute;
  inset: 50% 0 auto;
  height: 1px;
  background: rgba(255, 248, 229, 0.58);
  box-shadow: 0 0 18px rgba(255, 232, 190, 0.55);
  z-index: 2;
  transition: opacity 250ms ease-in;
  opacity: 0;
}

.auth-screen {
  position: relative;
  z-index: 1;
  min-height: 100svh;
  display: grid;
  grid-template-rows: auto 1fr;
  align-content: start;
  gap: 18px;
  padding: max(22px, env(safe-area-inset-top)) 20px max(22px, env(safe-area-inset-bottom));
  overflow: auto;
  opacity: 1;
  transition: opacity 250ms ease-in, transform 250ms ease-in;
}

.app-shell.is-logging-in .auth-screen {
  opacity: 0;
  pointer-events: none;
  transform: translateY(-18px);
}

.auth-screen .auth-form {
  align-self: start;
  margin-top: 20px;
}

.login-buttons {
  display: grid;
  gap: 10px;
  margin-top: 4px;
}

.register-area {
  align-self: end;
  display: grid;
  gap: 12px;
  margin-top: 12px;
  padding-bottom: max(16px, env(safe-area-inset-bottom));
}

.register-area > .secondary-button {
  width: 100%;
  background: var(--button);
  color: var(--button-text);
}

.inline-register {
  padding: 14px;
  border: 1px solid rgba(255, 244, 222, 0.2);
  border-radius: 8px;
  background: rgba(22, 14, 10, 0.54);
}

.email-note {
  margin: 0;
  color: #fff2d6;
  font-size: 12px;
  font-weight: 850;
  line-height: 1.35;
}

.organizer-screen,
.player-screen {
  position: absolute;
  inset: 0;
  z-index: 0;
  display: grid;
  align-content: start;
  gap: 18px;
  padding: max(18px, env(safe-area-inset-top)) 18px max(18px, env(safe-area-inset-bottom));
  overflow: auto;
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: opacity 220ms ease, transform 220ms ease;
}

.app-shell.is-organizer-home .organizer-screen,
.app-shell.is-player-home .player-screen {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
  transition-delay: 250ms;
}

body.is-chat-active .app-shell.is-organizer-home .organizer-screen,
body.is-chat-active .app-shell.is-player-home .player-screen {
  overflow-y: hidden;
}

.organizer-actions,
.player-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  opacity: 0;
  transform: translateY(-8px);
  transition: opacity 220ms ease, transform 220ms ease;
}

.organizer-actions .primary-button,
.organizer-actions .secondary-button,
.player-actions .secondary-button {
  width: 100%;
  background: var(--button);
  color: var(--button-text);
}

.player-actions {
  grid-template-columns: 1fr;
}

.player-level-display {
  margin: 0;
  padding: 12px 14px;
  border: 1px solid rgba(255, 248, 229, 0.2);
  border-radius: 8px;
  background: rgba(22, 14, 10, 0.58);
  color: var(--text);
  font-size: 14px;
  font-weight: 950;
}

.profile-form {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid rgba(255, 244, 222, 0.2);
  border-radius: 8px;
  background: rgba(22, 14, 10, 0.54);
}

.player-notifications {
  display: none;
  gap: 8px;
  padding: 12px;
  border: 1px solid rgba(255, 244, 222, 0.24);
  border-radius: 8px;
  background: rgba(22, 14, 10, 0.58);
  color: var(--text);
}

.player-notifications.is-open {
  display: grid;
}

.player-notifications h2 {
  margin: 0;
  font-size: 18px;
}

.player-notifications ul {
  display: grid;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.player-notifications li {
  padding: 10px;
  border-radius: 8px;
  background: rgba(255, 248, 229, 0.1);
  font-size: 13px;
  font-weight: 850;
}

.app-shell.is-organizer-home .organizer-actions,
.app-shell.is-player-home .player-actions {
  opacity: 1;
  transform: translateY(0);
  transition-delay: 280ms;
}

.secondary-button {
  min-height: 46px;
  border: 1px solid rgba(255, 248, 229, 0.32);
  border-radius: 8px;
  background: rgba(31, 19, 14, 0.58);
  color: var(--text);
  font-weight: 900;
}

.tournament-form {
  position: relative;
  display: none;
  gap: 10px;
  max-height: calc(100svh - 92px);
  overflow: auto;
  padding-bottom: 76px;
}

.app-shell.is-creating-tournament .tournament-form {
  display: grid;
}

.app-shell.is-creating-tournament .tournament-list {
  display: none;
}

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

.player-tournament-group {
  display: grid;
  gap: 10px;
}

.player-tournament-group h2 {
  margin: 0;
  color: var(--text);
  font-size: 19px;
  line-height: 1.1;
  font-weight: 950;
  text-shadow: 0 2px 12px rgba(24, 11, 7, 0.5);
}

.tournament-button {
  width: 100%;
  min-height: 50px;
  border: 1px solid rgba(255, 248, 229, 0.24);
  border-radius: 8px;
  background: rgba(31, 19, 14, 0.72);
  color: var(--text);
  font-weight: 900;
  text-align: left;
  padding: 0 14px;
}

.empty-state {
  margin: 0;
  padding: 14px;
  border: 1px solid rgba(255, 248, 229, 0.18);
  border-radius: 8px;
  background: rgba(22, 14, 10, 0.48);
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.notice-state {
  margin: 0;
  padding: 12px;
  border: 1px solid rgba(244, 224, 189, 0.48);
  border-radius: 8px;
  background: rgba(244, 224, 189, 0.16);
  color: var(--text);
  font-size: 13px;
  font-weight: 950;
}

.tournament-summary {
  display: none;
  gap: 10px;
  padding: 14px;
  border: 1px solid rgba(255, 248, 229, 0.2);
  border-radius: 8px;
  background: rgba(22, 14, 10, 0.58);
  color: var(--text);
}

.tournament-summary.is-open {
  display: grid;
}

.tournament-summary h2 {
  margin: 0;
  font-size: 24px;
  line-height: 1;
}

.summary-list {
  display: grid;
  gap: 8px;
  margin: 0;
}

.summary-list div {
  display: grid;
  gap: 3px;
}

.summary-list dt {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.summary-list dd {
  margin: 0;
  color: var(--text);
  font-size: 14px;
  font-weight: 800;
}

.summary-groups {
  display: grid;
  gap: 10px;
}

.team-enroll-form {
  display: grid;
  gap: 10px;
}

.team-enroll-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.team-enroll-form input {
  min-height: 42px;
  border: 1px solid rgba(255, 248, 229, 0.34);
  border-radius: 8px;
  background: rgba(34, 16, 10, 0.55);
  color: var(--text);
  padding: 0 12px;
  font: inherit;
}

.enroll-button,
.withdraw-button {
  width: 100%;
  min-height: 48px;
  border: 0;
  border-radius: 8px;
  background: var(--button);
  color: var(--button-text);
  font-weight: 950;
  letter-spacing: 0.04em;
}

.enroll-button:disabled {
  opacity: 0.62;
}

.withdraw-button {
  position: sticky;
  bottom: 8px;
  z-index: 4;
  background: rgba(126, 35, 25, 0.88);
  color: var(--text);
}

.setup-button {
  width: 100%;
  min-height: 50px;
  border: 1px solid rgba(255, 248, 229, 0.24);
  border-radius: 8px;
  background: rgba(31, 19, 14, 0.68);
  color: var(--text);
  font-weight: 900;
  text-align: left;
  padding: 0 14px;
}

.setup-section {
  display: none;
  gap: 10px;
  padding: 10px;
  border: 1px solid rgba(255, 248, 229, 0.18);
  border-radius: 8px;
  background: rgba(22, 14, 10, 0.52);
}

.setup-section.is-open {
  display: grid;
}

.double-options {
  display: none;
}

.double-options.is-open {
  display: grid;
  grid-template-columns: 1fr 1fr;
}

.start-tournament-button {
  position: sticky;
  bottom: 8px;
  width: 100%;
  min-height: 50px;
  border: 0;
  border-radius: 8px;
  background: var(--button);
  color: var(--button-text);
  font-weight: 950;
  letter-spacing: 0.04em;
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
  transition: opacity 180ms ease, transform 180ms ease;
  box-shadow: 0 14px 28px rgba(13, 28, 17, 0.34);
}

.tournament-form.is-complete .start-tournament-button {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.cancel-tournament-button {
  display: none;
  width: 100%;
  min-height: 48px;
  border: 1px solid rgba(255, 248, 229, 0.22);
  border-radius: 8px;
  background: rgba(126, 35, 25, 0.82);
  color: var(--text);
  font-weight: 950;
  letter-spacing: 0.04em;
}

.tournament-form.is-editing .cancel-tournament-button {
  display: block;
}

.delete-tournament-button {
  display: none;
  width: 100%;
  min-height: 50px;
  border: 1px solid rgba(255, 248, 229, 0.24);
  border-radius: 8px;
  background: rgba(150, 28, 18, 0.92);
  color: #ffffff;
  font-weight: 950;
  text-transform: uppercase;
}

.tournament-form.is-editing.is-finished .delete-tournament-button {
  display: block;
}

.option-grid {
  grid-template-columns: repeat(3, 1fr);
}

.level-grid {
  grid-template-columns: repeat(3, 1fr);
}

.game-system-section {
  gap: 14px;
}

.game-system-group {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  margin: 0;
  padding: 0;
  border: 0;
}

.game-system-group legend {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.game-system-group .choice-pill {
  font-size: 12px;
}

.game-system-group .choice-pill span {
  min-height: 42px;
  padding: 8px 10px;
  text-align: center;
  line-height: 1.18;
}

.register-level {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 0;
  padding: 0;
  border: 0;
}

.county-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.county-grid .choice-pill {
  min-height: 40px;
  font-size: 11px;
}

.county-grid .choice-pill span {
  min-height: 40px;
  padding: 6px;
  text-align: center;
  line-height: 1.14;
}

.register-level legend {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.choice-pill {
  position: relative;
  display: grid;
  min-height: 44px;
  padding: 0;
  color: var(--text);
  font-size: 13px;
  font-weight: 900;
}

.choice-pill input {
  position: absolute;
  inset: 0;
  width: 100%;
  min-height: 100%;
  opacity: 0;
  z-index: 1;
}

.choice-pill span {
  width: 100%;
  min-height: 44px;
  display: grid;
  align-items: center;
  justify-items: center;
  border: 1px solid rgba(255, 248, 229, 0.22);
  border-radius: 8px;
  background: rgba(255, 248, 229, 0.08);
}

.choice-pill input:checked + span {
  border-color: rgba(255, 248, 229, 0.82);
  background: var(--button);
  color: var(--button-text);
}

.role-panel {
  position: relative;
  z-index: 1;
  min-height: 50svh;
  display: grid;
  align-items: end;
  padding: max(18px, env(safe-area-inset-top)) 20px 22px;
  opacity: 1;
  transition: transform 250ms ease-in, opacity 250ms ease-in;
  will-change: transform, opacity;
}

.role-panel-top {
  align-items: end;
  padding-bottom: 26px;
}

.role-panel-bottom {
  align-items: end;
  padding-top: 26px;
  padding-bottom: max(22px, env(safe-area-inset-bottom));
}

.app-shell.is-logging-in::before {
  opacity: 0;
}

.app-shell.is-logging-in .role-panel {
  opacity: 0;
  pointer-events: none;
}

.app-shell.is-logging-in .role-panel-top {
  transform: translateY(-105%);
}

.app-shell.is-logging-in .role-panel-bottom {
  transform: translateY(105%);
}

.role-panel::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(18, 11, 8, 0.06), rgba(18, 11, 8, 0.48));
  pointer-events: none;
}

.role-panel-bottom::after {
  background: linear-gradient(180deg, rgba(18, 11, 8, 0.12), rgba(18, 11, 8, 0.64));
}

.role-content {
  position: relative;
  z-index: 1;
  width: 100%;
}

h1 {
  margin: 0 0 18px;
  color: var(--text);
  font-size: clamp(42px, 12vw, 62px);
  font-weight: 800;
  line-height: 0.9;
  letter-spacing: 0;
  text-transform: lowercase;
  text-shadow: 0 3px 18px rgba(24, 11, 7, 0.72);
}

.auth-form,
.register-card,
.password-recovery-card {
  display: grid;
  gap: 10px;
}

.password-recovery-card {
  padding: 14px;
  border: 1px solid rgba(255, 244, 222, 0.2);
  border-radius: 8px;
  background: rgba(22, 14, 10, 0.54);
}

label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

input,
textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  color: var(--text);
  outline: none;
  padding: 10px 12px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

textarea {
  min-height: 104px;
  resize: vertical;
}

input:focus,
textarea:focus {
  border-color: rgba(255, 248, 229, 0.68);
  box-shadow: 0 0 0 3px rgba(255, 245, 216, 0.16);
}

textarea::placeholder {
  color: rgba(229, 210, 189, 0.72);
}

.role-actions {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 10px 12px;
  margin-top: 4px;
}

.primary-button {
  min-height: 46px;
  border: 0;
  border-radius: 8px;
  background: var(--button);
  color: var(--button-text);
  font-weight: 900;
  letter-spacing: 0.04em;
  box-shadow: 0 12px 26px rgba(28, 13, 8, 0.28);
}

.primary-button:active {
  transform: translateY(1px);
}

.keep-signed {
  display: flex;
  min-height: 46px;
  align-items: center;
  gap: 8px;
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
}

.keep-signed input {
  width: 19px;
  min-height: 19px;
  accent-color: var(--accent);
}

.link-button {
  grid-column: 1 / -1;
  justify-self: start;
  border: 0;
  padding: 0;
  background: transparent;
  color: #fff2d6;
  font-size: 13px;
  font-weight: 800;
  text-decoration: underline;
  text-underline-offset: 4px;
}

.register-dialog,
.confirm-dialog {
  width: min(calc(100vw - 30px), 430px);
  border: 1px solid rgba(255, 244, 222, 0.24);
  border-radius: 8px;
  padding: 0;
  background: var(--paper-strong);
  color: var(--text);
  backdrop-filter: blur(14px);
  box-shadow: 0 24px 80px rgba(18, 10, 7, 0.58);
}

.register-dialog::backdrop,
.confirm-dialog::backdrop {
  background: rgba(17, 10, 7, 0.58);
}

.register-card,
.confirm-card {
  padding: 18px;
}

.confirm-card {
  display: grid;
  gap: 16px;
}

.confirm-card p {
  margin: 0;
  color: var(--text);
  font-size: 24px;
  font-weight: 950;
}

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

.registered-players {
  display: none;
  gap: 10px;
  padding: 14px;
  border: 1px solid rgba(255, 248, 229, 0.2);
  border-radius: 8px;
  background: rgba(22, 14, 10, 0.58);
  color: var(--text);
}

.registered-players.is-open {
  display: grid;
}

.registered-players h2 {
  margin: 0;
  font-size: 20px;
  line-height: 1.1;
}

.registered-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.registered-list li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px;
  border-radius: 8px;
  background: rgba(255, 248, 229, 0.08);
  color: var(--text);
  font-size: 13px;
  font-weight: 800;
}

.registered-player-info {
  display: grid;
  gap: 2px;
}

.remove-player-button {
  align-self: center;
  min-height: 34px;
  border: 1px solid rgba(255, 248, 229, 0.22);
  border-radius: 8px;
  background: rgba(126, 35, 25, 0.84);
  color: var(--text);
  font-size: 12px;
  font-weight: 900;
}

.add-player-toggle,
.draw-groups-button,
.draw-groups,
.complete-list-button,
.manual-player-form {
  display: none;
}

.tournament-form.is-editing .add-player-toggle,
.tournament-form.is-editing .complete-list-button,
.tournament-form.is-editing.is-draw-ready .draw-groups-button {
  display: block;
  width: 100%;
  min-height: 48px;
  border: 0;
  border-radius: 8px;
  background: var(--button);
  color: var(--button-text);
  font-weight: 950;
  letter-spacing: 0.04em;
}

.tournament-form.is-editing .draw-groups.is-open {
  display: block;
  min-width: 0;
}

.tournament-live-scroll {
  display: flex;
  align-items: stretch;
  gap: 0;
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: visible;
  scroll-snap-type: x mandatory;
  scroll-snap-stop: always;
  scrollbar-width: thin;
  overscroll-behavior-x: contain;
  -webkit-overflow-scrolling: touch;
}

.tournament-live-page {
  display: grid;
  flex: 0 0 100%;
  gap: 10px;
  min-width: 100%;
  max-width: 100%;
  align-content: start;
  scroll-snap-align: start;
}

.tournament-live-page.is-chat-page {
  padding-top: var(--chat-offset, 0px);
  min-height: calc(var(--chat-offset, 0px) + 100dvh - 28px);
  align-self: start;
  z-index: 3;
}

.tournament-chat {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 12px;
  height: calc(100dvh - 28px);
  min-height: 0;
  max-height: 100%;
  padding: 14px;
  border: 1px solid rgba(255, 248, 229, 0.2);
  border-radius: 8px;
  background: rgba(22, 14, 10, 0.64);
  color: var(--text);
}

.tournament-chat h2 {
  margin: 0;
  font-size: 20px;
  line-height: 1.1;
}

.chat-messages {
  display: grid;
  align-content: start;
  gap: 8px;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior-y: contain;
  -webkit-overflow-scrolling: touch;
  padding-right: 4px;
}

.chat-message {
  display: grid;
  gap: 5px;
  padding: 10px;
  border: 1px solid rgba(255, 248, 229, 0.12);
  border-radius: 8px;
  background: rgba(255, 248, 229, 0.08);
}

.chat-message.is-mine {
  background: rgba(255, 226, 171, 0.16);
}

.chat-message-top {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  color: #ffffff;
  font-size: 11px;
  font-weight: 900;
}

.chat-message-top span {
  color: var(--muted);
  white-space: nowrap;
}

.chat-message p {
  margin: 0;
  color: #ffffff;
  font-size: 13px;
  font-weight: 750;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.chat-entry {
  display: grid;
  gap: 8px;
}

.chat-entry textarea {
  width: 100%;
  min-height: 76px;
  resize: vertical;
  border: 1px solid rgba(255, 248, 229, 0.34);
  border-radius: 8px;
  background: rgba(35, 18, 12, 0.58);
  color: #ffffff;
  font: inherit;
  font-weight: 800;
  padding: 10px;
}

.chat-entry textarea::placeholder {
  color: rgba(255, 255, 255, 0.72);
}

.draw-group {
  display: grid;
  gap: 8px;
  padding: 14px;
  min-width: 0;
  border: 1px solid rgba(255, 248, 229, 0.2);
  border-radius: 8px;
  background: rgba(22, 14, 10, 0.58);
  color: var(--text);
}

.draw-group h2 {
  margin: 0;
  font-size: 18px;
  line-height: 1.1;
}

.draw-group ol {
  display: grid;
  gap: 6px;
  margin: 0;
  padding-left: 20px;
}

.draw-table {
  width: 100%;
  max-width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  table-layout: fixed;
  overflow: hidden;
  border-radius: 8px;
  border: 1px solid rgba(255, 248, 229, 0.18);
}

.draw-table th,
.draw-table td {
  border: 0;
  border-right: 1px solid rgba(255, 248, 229, 0.18);
  border-bottom: 1px solid rgba(255, 248, 229, 0.18);
  padding: 8px 6px;
  color: #ffffff;
  font-size: 12px;
  font-weight: 850;
  text-align: center;
}

.draw-table th:last-child,
.draw-table td:last-child {
  border-right: 0;
}

.draw-table tbody tr:last-child td {
  border-bottom: 0;
}

.draw-table thead th:first-child {
  border-top-left-radius: 8px;
}

.draw-table thead th:last-child {
  border-top-right-radius: 8px;
}

.draw-table tbody tr:last-child td:first-child {
  border-bottom-left-radius: 8px;
}

.draw-table tbody tr:last-child td:last-child {
  border-bottom-right-radius: 8px;
}

.draw-table th:first-child,
.draw-table td:first-child {
  width: 42%;
  text-align: left;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.draw-table th {
  background: rgba(255, 248, 229, 0.12);
  color: #ffffff;
  text-transform: uppercase;
}

.results-table th:first-child,
.results-table td:first-child {
  width: 52%;
}

.score-input {
  width: 100%;
  min-height: 34px;
  padding: 6px;
  border-radius: 6px;
  text-align: center;
  font-size: 13px;
  font-weight: 900;
}

.score-input:disabled {
  opacity: 0.58;
}

.three-set-results {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  background: rgba(36, 20, 13, 0.74);
  border: 2px solid rgba(255, 248, 229, 0.34);
  border-collapse: separate;
  border-spacing: 0;
  table-layout: fixed;
  overflow: hidden;
  font-family: Arial, sans-serif;
  border-radius: 8px;
}

.three-set-results td {
  border: 0;
  border-right: 1px solid rgba(255, 248, 229, 0.34);
  height: 32px;
  padding: 0 8px;
  background: transparent;
  color: #ffffff;
  font-family: Arial, sans-serif;
  font-size: 18px;
  font-weight: 800;
  line-height: 1;
  vertical-align: middle;
}

.three-set-results td:first-child {
  width: auto;
  text-align: left;
  border-left: 0;
}

.three-set-results td:not(:first-child) {
  width: 32px;
  padding: 0;
  text-align: center;
}

.three-set-results td:last-child {
  border-right: 0;
}

.three-set-results .three-set-match-end td {
  border-bottom: 2px solid rgba(255, 248, 229, 0.34);
}

.three-set-results .three-set-match-start td:not(:first-child) {
  border-bottom: 1px solid rgba(255, 248, 229, 0.34);
}

.three-set-results .three-set-match-end:last-child td {
  border-bottom: 0;
}

.three-set-results .match-player-cell {
  display: table-cell;
  font-weight: 400;
}

.three-set-results .is-match-winner .match-player-cell {
  font-weight: 900;
}

.three-set-results .score-input {
  width: 100%;
  height: 32px;
  min-height: 32px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: #ffffff;
  font-family: Arial, sans-serif;
  font-size: 18px;
  font-weight: 800;
  line-height: 32px;
  text-align: center;
  box-shadow: none;
  outline: none;
}

.three-set-results .score-input:disabled {
  opacity: 1;
  -webkit-text-fill-color: #ffffff;
}

.three-set-results .score-input:focus {
  background: rgba(255, 248, 229, 0.08);
}

.three-set-results .score-input::placeholder {
  color: transparent;
}

.elimination-section {
  display: grid;
  gap: 10px;
  min-width: 0;
  padding: 14px;
  border: 1px solid rgba(255, 248, 229, 0.2);
  border-radius: 8px;
  background: rgba(22, 14, 10, 0.58);
}

.elimination-section h2 {
  margin: 0;
  color: var(--text);
  font-size: 18px;
  line-height: 1.1;
}

.elimination-bracket {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(100%, 100%);
  align-items: stretch;
  gap: 0;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 6px 6px 14px;
  scrollbar-width: thin;
}

.bracket-round {
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 12px;
  box-sizing: border-box;
  min-width: 100%;
  padding-right: 64px;
}

.bracket-round h3 {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.bracket-column {
  display: grid;
  grid-template-rows: repeat(var(--bracket-size), 58px);
  min-height: calc(var(--bracket-size) * 58px);
  align-items: stretch;
}

.bracket-slot {
  position: relative;
  box-sizing: border-box;
  width: 100%;
  min-height: 48px;
  align-self: center;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 126px;
  column-gap: 8px;
  align-items: center;
  padding: 0;
  border: 2px solid rgba(255, 248, 229, 0.38);
  border-radius: 8px;
  background: rgba(36, 20, 13, 0.74);
  color: #ffffff;
  font-size: 12px;
  font-weight: 850;
  line-height: 1.2;
  text-align: left;
  overflow-wrap: normal;
}

.bracket-player-name {
  min-width: 0;
  height: 100%;
  padding: 8px 10px;
  border: 0;
  background: transparent;
  color: #ffffff;
  font: inherit;
  text-align: left;
  overflow: visible;
  overflow-wrap: normal;
  white-space: nowrap;
}

.bracket-player-name:disabled {
  color: #ffffff;
  opacity: 1;
}

.bracket-score-cells {
  box-sizing: border-box;
  height: 100%;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  width: 126px;
  border-left: 2px solid rgba(255, 248, 229, 0.5);
}

.bracket-score-input {
  box-sizing: border-box;
  width: 100%;
  height: 100%;
  border: 0;
  border-right: 2px solid rgba(255, 248, 229, 0.5);
  border-radius: 0;
  background: transparent;
  color: #ffffff;
  padding: 0;
  font: 950 20px/1.1 Arial, sans-serif;
  text-align: center;
  outline: none;
  -webkit-text-fill-color: #ffffff;
}

.bracket-score-input:last-child {
  border-right: 0;
}

.bracket-score-input:disabled {
  opacity: 1;
  -webkit-text-fill-color: #ffffff;
}

.bracket-score-input:focus {
  background: rgba(255, 248, 229, 0.08);
}

.bracket-slot.is-empty-slot .bracket-player-name,
.bracket-slot.is-empty-slot .bracket-score-cells {
  visibility: hidden;
}

.bracket-slot.is-selected-winner {
  border-color: var(--button);
  box-shadow: 0 0 0 1px rgba(244, 221, 177, 0.25);
}

.bracket-round:not(.is-final-round) .bracket-slot::after {
  content: "";
  position: absolute;
  right: -32px;
  top: 50%;
  /* Overlap the bordered box by 2px so the connector is visually continuous. */
  width: 34px;
  border-top: 2px solid rgba(255, 248, 229, 0.5);
  pointer-events: none;
}

.bracket-entry-line {
  display: none;
}

.bracket-round:not(.is-seed-round) .bracket-entry-line {
  display: block;
  position: absolute;
  left: -32px;
  top: 50%;
  /* The small overlap prevents a gap next to the next-round box on mobile. */
  width: 34px;
  border-top: 2px solid rgba(255, 248, 229, 0.5);
  pointer-events: none;
}

.bracket-slot.is-pair-top::before,
.bracket-slot.is-pair-bottom::before {
  content: "";
  position: absolute;
  right: -32px;
  width: 0;
  height: calc(var(--slot-span) * 29px);
  border-right: 2px solid rgba(255, 248, 229, 0.5);
  pointer-events: none;
}

.bracket-slot.is-pair-top::before {
  top: 50%;
}

.bracket-slot.is-pair-bottom::before {
  bottom: 50%;
}

.bracket-round.is-final-round {
  min-width: 100%;
}

@media (max-width: 560px) {
  .elimination-bracket {
    --mobile-score-width: 126px;
    --mobile-name-score-gap: 8px;
    --mobile-bracket-connector: 96px;
    --mobile-bracket-slot-width: calc(
      var(--bracket-name-width, 18ch) + var(--mobile-name-score-gap) + var(--mobile-score-width)
    );
    grid-auto-columns: calc(var(--mobile-bracket-slot-width) + 64px);
    padding-inline: 4px;
  }

  .bracket-round,
  .bracket-round.is-final-round {
    width: calc(var(--mobile-bracket-slot-width) + 64px);
    min-width: calc(var(--mobile-bracket-slot-width) + 64px);
    padding-right: 64px;
  }

  .bracket-slot {
    width: var(--mobile-bracket-slot-width);
    min-width: var(--mobile-bracket-slot-width);
    grid-template-columns: var(--bracket-name-width, 18ch) var(--mobile-score-width);
    column-gap: var(--mobile-name-score-gap);
    min-height: 44px;
    font-size: 11px;
    line-height: 1.1;
  }

  .bracket-player-name {
    padding-inline: 8px;
  }

  /* A round keeps its full horizontal bridge on portrait screens. */
  .bracket-round:not(.is-final-round) .bracket-slot::after {
    right: calc(-1 * var(--mobile-bracket-connector));
    width: calc(var(--mobile-bracket-connector) + 4px);
  }

  .bracket-slot.is-pair-top::before,
  .bracket-slot.is-pair-bottom::before {
    right: calc(-1 * var(--mobile-bracket-connector));
  }

  .bracket-round:not(.is-seed-round) .bracket-entry-line {
    left: -36px;
    width: 38px;
  }
}

.tournament-form.is-editing .manual-player-form:not([hidden]) {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid rgba(255, 248, 229, 0.2);
  border-radius: 8px;
  background: rgba(22, 14, 10, 0.58);
}

.dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.dialog-header p {
  margin: 0;
  color: var(--text);
  font-size: 22px;
  font-weight: 900;
}

.icon-button {
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 248, 229, 0.08);
  color: var(--text);
  font-size: 28px;
  line-height: 1;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: max(16px, env(safe-area-inset-bottom));
  z-index: 10;
  width: min(calc(100vw - 28px), 420px);
  min-height: 44px;
  display: grid;
  align-items: center;
  padding: 10px 14px;
  border: 1px solid rgba(255, 248, 229, 0.22);
  border-radius: 8px;
  background: rgba(28, 18, 14, 0.86);
  color: var(--text);
  font-size: 13px;
  font-weight: 800;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 12px);
  transition: opacity 180ms ease, transform 180ms ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

@media (min-height: 760px) {
  .role-panel {
    padding-inline: 24px;
  }

  .auth-form {
    gap: 12px;
  }
}
