:root {
  --navy: #071527;
  --panel: #f8fafc;
  --text: #102033;
  --muted: #64748b;
  --blue: #2563eb;
  --blue-dark: #1d4ed8;
  --green: #16a34a;
  --green-soft: #dcfce7;
  --orange: #ea580c;
  --orange-soft: #ffedd5;
  --red: #dc2626;
  --red-soft: #fee2e2;
  --grey-soft: #e2e8f0;
  --grey: #475569;
}

* {
  box-sizing: border-box;
}

html {
  overscroll-behavior: none;
  background: #020b16;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--navy);
  color: white;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  overscroll-behavior: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

.app-header {
  padding: max(18px, env(safe-area-inset-top)) 16px 12px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
}

.header-actions {
  display: flex;
  gap: 8px;
}

h1, h2, p {
  margin: 0;
}

h1 {
  font-size: 1.7rem;
  letter-spacing: 0;
}

.app-header p {
  color: #cbd5e1;
  margin-top: 4px;
  font-weight: 700;
}

main {
  padding: 0 14px 20px;
}

.screen {
  display: none;
}

.screen.active {
  display: block;
}

#startScreen {
  padding-bottom: calc(96px + env(safe-area-inset-bottom));
}

#startPlayerPanel {
  margin-bottom: calc(84px + env(safe-area-inset-bottom));
}

.sport-select-panel {
  margin-top: 18px;
}

.sport-select-panel h2 {
  font-size: 1.35rem;
}

.sport-choice-grid {
  display: grid;
  gap: 12px;
  margin-top: 16px;
}

.sport-choice {
  min-height: 76px;
  font-size: 1.2rem;
}

.coach-signin-panel {
  margin-top: 18px;
  display: grid;
  gap: 12px;
}

.coach-name-input {
  width: 100%;
  border: 2px solid #cbd5e1;
  border-radius: 8px;
  padding: 14px;
  font: inherit;
  font-weight: 800;
}

.panel, .time-panel, .sub-box, details {
  background: var(--panel);
  color: var(--text);
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: 0 8px 22px rgba(0, 0, 0, .18);
}

.small-panel {
  padding: 12px;
}

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

h2 {
  font-size: 1.1rem;
}

.court-count, .hint {
  color: var(--muted);
  font-weight: 700;
  margin-top: 8px;
}

.hint {
  color: var(--red);
}

.card-grid {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.card-grid.compact {
  grid-template-columns: 1fr 1fr;
}

.player-card {
  width: 100%;
  min-height: 56px;
  border: 2px solid #cbd5e1;
  border-radius: 8px;
  padding: 12px;
  background: white;
  color: var(--text);
  text-align: left;
  font: inherit;
  font-size: 1.08rem;
  font-weight: 850;
}

.player-card.selected {
  border-color: var(--green);
  background: var(--green-soft);
  color: #14532d;
}

.start-card {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 10px;
}

.start-card.starter {
  border-color: var(--blue);
  background: #eff6ff;
}

.start-name-button,
.starter-toggle {
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  font-weight: 900;
}

.start-name-button {
  min-height: 34px;
  padding: 0;
  text-align: left;
}

.start-name-button small {
  display: block;
  margin-top: 3px;
  color: inherit;
  font-size: .78rem;
  opacity: .82;
}

.starter-toggle {
  min-height: 38px;
  border-radius: 8px;
  padding: 0 10px;
  background: #dbeafe;
  color: #12335f;
  font-size: .88rem;
}

.starter-toggle.selected {
  background: var(--blue);
  color: white;
}

.starter-toggle:disabled {
  opacity: .45;
}

.button {
  width: 100%;
  min-height: 52px;
  border: 0;
  border-radius: 8px;
  padding: 0 14px;
  color: white;
  font: inherit;
  font-weight: 900;
  font-size: 1rem;
}

.button:disabled {
  opacity: .45;
}

.blue {
  background: var(--blue);
}

.blue:active {
  background: var(--blue-dark);
}

.green {
  background: var(--green);
}

.quiet {
  background: #dbeafe;
  color: #12335f;
}

.danger {
  background: var(--red-soft);
  color: var(--red);
}

.sticky-start {
  position: sticky;
  bottom: max(12px, env(safe-area-inset-bottom));
  box-shadow: 0 10px 26px rgba(0, 0, 0, .28);
  z-index: 10;
}

.time-panel {
  display: grid;
  gap: 8px;
}

#timeLabel {
  font-size: 1.65rem;
  font-weight: 950;
}

.time-panel small {
  color: var(--muted);
  font-weight: 750;
}

.progress {
  height: 10px;
  border-radius: 999px;
  background: #dbe4ef;
  overflow: hidden;
}

.progress span {
  display: block;
  height: 100%;
  width: 0%;
  background: var(--blue);
}

.progress span.timer-due {
  background: var(--orange);
}

.sub-box h2 {
  margin-bottom: 12px;
  font-size: 1.28rem;
  letter-spacing: 0;
}

.coming-off-box {
  background: var(--orange-soft);
}

.coming-off-box h2 {
  color: #9a3412;
}

.going-on-box {
  background: #dbeafe;
}

.going-on-box h2 {
  color: #1e40af;
}

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

.sub-player {
  border-radius: 8px;
  padding: 14px;
  background: white;
  color: var(--text);
  font-size: 1.22rem;
  font-weight: 950;
}

.sub-player {
  width: 100%;
  text-align: left;
}

.sub-note {
  margin-top: 10px;
  color: #1e40af;
  font-weight: 850;
}

.notice {
  border-radius: 8px;
  padding: 14px;
  margin-bottom: 12px;
  background: var(--green-soft);
  color: #14532d;
  font-weight: 900;
}

.notice-info {
  background: #dbeafe;
  color: #1e3a8a;
}

.quick-panel {
  min-height: 56vh;
}

.quick-prompt {
  margin-top: 10px;
  color: var(--muted);
  font-size: 1.08rem;
  font-weight: 850;
}

#quickList,
#quickResultList {
  margin-bottom: 14px;
}

#quickResult {
  margin-top: 16px;
}

#quickResult h3 {
  margin: 0;
  color: var(--text);
}

.quick-section-label {
  margin: 0;
  color: #9a3412;
  font-size: 1.05rem;
}

.injury-player {
  background: var(--red-soft);
  color: var(--red);
}

.settings-box {
  display: grid;
  gap: 10px;
  margin-bottom: 12px;
}

.settings-current {
  color: var(--muted);
  font-weight: 850;
}

.option-row {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}

.option-button {
  min-height: 48px;
  border: 2px solid #cbd5e1;
  border-radius: 8px;
  background: white;
  color: var(--text);
  font: inherit;
  font-size: 1.1rem;
  font-weight: 950;
}

.option-button.selected {
  border-color: var(--green);
  background: var(--green-soft);
  color: #14532d;
}

.help-issues {
  display: grid;
  gap: 8px;
  margin: 10px 0 12px;
}

.help-issue {
  min-height: 40px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: white;
  color: var(--text);
  text-align: left;
  padding: 8px 10px;
  font: inherit;
  font-weight: 700;
}

.help-issue.selected {
  border-color: var(--blue);
  background: #eff6ff;
}

.help-context {
  display: grid;
  gap: 6px;
  padding: 10px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  margin-bottom: 10px;
}

.help-selectors h3,
.help-selectors h4,
#recommendationCard h3,
#recommendationCard h4 {
  margin: 8px 0;
  color: var(--text);
}

.help-action-row {
  grid-template-columns: 1fr;
}

.secondary-info {
  display: grid;
  gap: 8px;
}

details {
  margin-bottom: 0;
  padding: 12px;
}

summary {
  cursor: pointer;
  font-weight: 900;
}

.badge-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.badge {
  border-radius: 8px;
  padding: 9px 10px;
  font-weight: 850;
}

.badge.on {
  background: var(--green-soft);
  color: #14532d;
}

.badge.off {
  background: var(--grey-soft);
  color: var(--grey);
}

.badge.out {
  background: var(--red-soft);
  color: var(--red);
}

.badge.rest {
  background: var(--orange-soft);
  color: #9a3412;
}

.minutes-list {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.minute-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 0;
  border-bottom: 1px solid #e2e8f0;
  color: var(--muted);
  font-weight: 750;
}

.mini-button {
  border: 0;
  border-radius: 8px;
  min-height: 38px;
  padding: 0 12px;
  background: #dbeafe;
  color: #12335f;
  font: inherit;
  font-weight: 850;
}

.sticky-actions {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 10px 14px max(12px, env(safe-area-inset-bottom));
  background: rgba(7, 21, 39, .97);
  box-shadow: 0 -10px 30px rgba(0, 0, 0, .35);
}

.big {
  min-height: 64px;
  font-size: 1.18rem;
}

.action-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 8px;
}

.action-row .button {
  min-height: 46px;
  font-size: .82rem;
  padding: 0 8px;
}

.bottom-space {
  height: 220px;
}

.help-action-row {
  grid-template-columns: 1fr;
}

.hidden {
  display: none;
}

@media (min-width: 620px) {
  body {
    max-width: 620px;
    margin: 0 auto;
  }

  .sticky-actions {
    left: 50%;
    max-width: 620px;
    transform: translateX(-50%);
  }

  .help-action-row {
    grid-template-columns: 1fr 1fr 1fr;
  }
}

/* Sideline dark mode: compact enough for tall iPhone screens. */
:root {
  --navy: #020b16;
  --panel: #101c2b;
  --panel-2: #142236;
  --text: #eef6ff;
  --muted: #9fb0c5;
  --blue: #3b82f6;
  --blue-dark: #2563eb;
  --green: #22c55e;
  --green-soft: #123524;
  --orange: #fb923c;
  --orange-soft: #321d0d;
  --red: #f87171;
  --red-soft: #3b1518;
  --grey-soft: #243346;
  --grey: #c2cfdd;
}

body {
  background: var(--navy);
  color: var(--text);
}

.app-header {
  padding: max(8px, env(safe-area-inset-top)) 12px 6px;
}

h1 {
  font-size: 1.22rem;
  line-height: 1.05;
}

.app-header p {
  margin-top: 2px;
  font-size: .82rem;
}

main {
  padding: 0 10px 12px;
}

.panel,
.time-panel,
.sub-box,
details {
  background: var(--panel);
  color: var(--text);
  border: 1px solid #213249;
  border-radius: 8px;
  padding: 10px;
  margin-bottom: 8px;
  box-shadow: none;
}

.time-panel {
  gap: 6px;
}

#timeLabel {
  font-size: 1.45rem;
  line-height: 1.05;
}

.time-panel small,
.court-count,
.hint,
.quick-prompt,
.settings-current {
  color: var(--muted);
}

.progress {
  height: 8px;
  background: #233248;
}

h2 {
  font-size: 1.02rem;
}

.small-panel {
  padding: 9px 10px;
}

#startedFirst {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
}

.badge,
.sub-player,
.minute-row strong,
.minute-row span {
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.badge {
  display: block;
  padding: 7px 4px;
  border-radius: 7px;
  font-size: clamp(.72rem, 3.15vw, .9rem);
  line-height: 1.05;
  text-align: center;
}

.badge.on {
  background: #123524;
  color: #b9f7cf;
}

.badge.off {
  background: #253348;
  color: #d5e0ee;
}

.badge.out {
  background: #3b1518;
  color: #fecaca;
}

.badge.rest {
  background: #321d0d;
  color: #fed7aa;
}

.sub-box h2 {
  margin-bottom: 8px;
  font-size: 1rem;
  line-height: 1.05;
}

.coming-off-box {
  background: #24180d;
  border-color: #5b3413;
}

.coming-off-box h2 {
  color: #fdba74;
}

.going-on-box {
  background: #0e2038;
  border-color: #1e3a5f;
}

.going-on-box h2 {
  color: #93c5fd;
}

.sub-list {
  gap: 6px;
}

.sub-player {
  min-height: 0;
  padding: 10px 12px;
  border-radius: 7px;
  background: #162437;
  color: #edf6ff;
  border: 1px solid #2b3d55;
  font-size: clamp(1rem, 4.8vw, 1.22rem);
  line-height: 1.08;
  touch-action: manipulation;
  user-select: none;
  pointer-events: none;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
}

.sub-player-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sub-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  pointer-events: auto;
}

.hold-action,
.swap-action {
  min-height: 32px;
  border: 0;
  border-radius: 7px;
  padding: 0 10px;
  background: #25364c;
  color: #d9e7f7;
  font: inherit;
  font-size: .76rem;
  font-weight: 900;
  text-transform: uppercase;
  touch-action: none;
}

.hold-action::after,
.swap-action::after {
  content: "";
  display: block;
  height: 3px;
  width: 0;
  margin-top: 2px;
  border-radius: 999px;
  background: currentColor;
}

.hold-action.pressing::after,
.swap-action.pressing::after {
  width: 100%;
  transition: width .65s linear;
}

.hold-action.pressing,
.swap-action.pressing {
  outline: 3px solid #facc15;
}

.swap-action {
  background: #1d4ed8;
  color: #eff6ff;
}

.sub-player.held {
  outline: 3px solid var(--green);
  background: #123524;
  color: #bbf7d0;
}

.sub-player.held .hold-action {
  background: #15803d;
  color: white;
}

.swap-player {
  background: #112a4a;
  color: #dbeafe;
}

.swap-on-label {
  color: #93c5fd;
}

.sub-note {
  margin-top: 6px;
  color: #bfdbfe;
  font-size: .86rem;
}

.notice {
  padding: 9px 10px;
  margin-bottom: 8px;
  background: #102d22;
  color: #bbf7d0;
}

.player-card,
.option-button,
.help-issue {
  background: var(--panel-2);
  color: var(--text);
  border-color: #2d4058;
}

.player-card.selected,
.option-button.selected {
  background: #123524;
  color: #bbf7d0;
  border-color: var(--green);
}

.start-card.starter,
.help-issue.selected {
  background: #112a4a;
  border-color: var(--blue);
}

.quiet,
.mini-button,
.starter-toggle {
  background: #1a2b43;
  color: #d7e8ff;
}

.danger {
  background: #3b1518;
  color: #fecaca;
}

.green {
  background: #15803d;
}

.blue {
  background: #2563eb;
}

.secondary-info {
  gap: 6px;
}

details {
  padding: 8px 10px;
}

summary {
  font-size: .93rem;
}

.minute-row {
  padding: 6px 0;
  border-color: #26374d;
  color: var(--muted);
}

.sticky-actions {
  padding: 8px 10px max(10px, env(safe-area-inset-bottom));
  background: rgba(2, 11, 22, .98);
  border-top: 1px solid #213249;
}

.big {
  min-height: 54px;
  font-size: 1.04rem;
}

.action-row {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  margin-top: 6px;
}

.action-row .button {
  min-height: 42px;
  font-size: .82rem;
  padding: 0 6px;
}

.bottom-space {
  height: 164px;
}

.confirm-panel {
  min-height: 58vh;
}

.confirm-grid {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.confirm-player {
  padding: 16px;
  border-radius: 8px;
  background: #123524;
  color: #bbf7d0;
  font-size: 1.2rem;
  font-weight: 950;
}

.confirm-actions {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 8px;
  padding: 10px 14px max(12px, env(safe-area-inset-bottom));
  background: rgba(2, 11, 22, .98);
  border-top: 1px solid #213249;
}

.rotation-grid {
  display: grid;
  grid-template-rows: repeat(3, minmax(0, 1fr));
  gap: 6px;
  height: calc(100dvh - 246px);
  min-height: 460px;
}

.rotation-grid .panel,
.rotation-grid .sub-box {
  min-height: 0;
  margin-bottom: 0;
  overflow: hidden;
}

.rotation-grid .sub-list {
  max-height: calc((100dvh - 360px) / 3);
  overflow: hidden;
}

.rotation-grid .sub-player {
  padding: 8px 10px;
  font-size: clamp(.9rem, 4vw, 1.08rem);
}

.rotation-grid .hold-action,
.rotation-grid .swap-action {
  min-height: 30px;
  padding: 0 8px;
  font-size: .68rem;
}

.compact-timer {
  display: none;
}

/* Settings page + safer injury selection update */
.app-settings-panel {
  display: grid;
  gap: 14px;
}

.settings-page {
  display: grid;
  gap: 12px;
}

.settings-page h3 {
  margin: 8px 0 0;
  color: #e5eefb;
  font-size: 1rem;
}

.settings-squad-rows {
  display: grid;
  gap: 8px;
}

.settings-player-row,
.settings-add-row,
.settings-two-col {
  display: grid;
  gap: 8px;
}

.settings-player-row {
  grid-template-columns: 1fr auto;
}

.settings-add-row {
  grid-template-columns: 1fr auto;
}

.settings-two-col {
  grid-template-columns: 1fr 1fr;
}

.settings-label {
  display: grid;
  gap: 6px;
  color: #b8c7da;
  font-size: 0.82rem;
  font-weight: 850;
}

.settings-page input,
.settings-page select {
  width: 100%;
  min-height: 42px;
  border: 1px solid rgba(148, 163, 184, 0.45);
  border-radius: 10px;
  background: #071527;
  color: #f8fafc;
  padding: 8px 10px;
  font: inherit;
  font-size: 1rem;
  font-weight: 850;
}

.settings-safe-hint {
  color: #94a3b8;
}

.advanced-help-details {
  border-top: 1px solid rgba(148, 163, 184, 0.22);
  padding-top: 10px;
}

.advanced-help-details summary {
  color: #cbd5e1;
  font-weight: 900;
  cursor: pointer;
}

.player-card.plain-player-card {
  color: #f8fafc;
}

.player-card.soft-fill {
  background: linear-gradient(90deg, rgba(234, 179, 8, 0.18) 0 10%, rgba(15, 23, 42, 0.92) 10% 100%);
  border-color: rgba(234, 179, 8, 0.35);
}

.player-card.soft-fill.selected {
  background: linear-gradient(90deg, rgba(34, 197, 94, 0.92) 0 100%);
  border-color: #22c55e;
  color: #04210f;
}

@media (max-width: 430px) {
  .settings-two-col {
    grid-template-columns: 1fr 1fr;
  }
  .settings-page input,
  .settings-page select {
    min-height: 39px;
    font-size: 0.95rem;
  }
}


/* Start-screen settings/profile controls */
.start-heading-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.settings-summary {
  margin: 0.25rem 0 0.3rem;
  color: #93c5fd;
  font-size: 0.86rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.start-settings-panel {
  margin-bottom: 5.5rem;
}
.settings-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.55rem;
  margin-top: 0.75rem;
}
@media (min-width: 430px) {
  .settings-actions {
    grid-template-columns: 1fr 1fr;
  }
}

/* Tournament mode */
body.tournament-mode {
  background: linear-gradient(180deg, rgba(74, 20, 110, 0.10), #020b16 42%, #020b16 100%);
}
body.tournament-mode .app-header {
  background: linear-gradient(135deg, rgba(88, 28, 135, 0.38), rgba(2, 11, 22, 0.92));
  border-bottom-color: rgba(168, 85, 247, 0.28);
}
body.tournament-mode .panel,
body.tournament-mode .sub-box {
  border-color: rgba(168, 85, 247, 0.22);
}
.button.purple {
  background: #6d28d9;
  color: #fff;
  border-color: rgba(196, 181, 253, 0.35);
}
.tournament-panel {
  margin-top: 10px;
  background: rgba(34, 16, 52, 0.74);
}
.tournament-next-card {
  border: 1px solid rgba(168, 85, 247, 0.35);
  background: rgba(88, 28, 135, 0.18);
  border-radius: 16px;
  padding: 10px;
}
.tournament-next-card p {
  margin: 6px 0 0;
  color: #ddd6fe;
  font-size: 0.92rem;
}
.tournament-chip {
  display: inline-block;
  padding: 3px 8px;
  margin-bottom: 6px;
  border-radius: 999px;
  background: rgba(168, 85, 247, 0.24);
  color: #e9d5ff;
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: .02em;
  text-transform: uppercase;
}
.tournament-schedule {
  display: grid;
  gap: 6px;
  margin-top: 8px;
}
.tournament-game-row {
  display: grid;
  grid-template-columns: 62px 70px 1fr;
  align-items: center;
  gap: 6px;
  padding: 8px;
  border-radius: 12px;
  border: 1px solid rgba(148, 163, 184, 0.22);
  background: rgba(15, 23, 42, 0.78);
  color: #e5e7eb;
  text-align: left;
  font-size: 0.82rem;
}
.tournament-game-row.selected {
  border-color: rgba(196, 181, 253, 0.7);
  background: rgba(109, 40, 217, 0.25);
}
.tournament-mini-schedule {
  display: grid;
  gap: 4px;
  margin: 8px 0;
  color: #cbd5e1;
  font-size: 0.8rem;
}
.settings-check {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 8px 0 10px;
  color: #e5e7eb;
  font-weight: 700;
}
.settings-check input {
  width: 20px;
  height: 20px;
}
.tournament-stats-details {
  margin-top: 8px;
}
.tournament-stats-details summary {
  color: #ddd6fe;
  font-weight: 800;
}


/* Court-side tournament page and compact live-view refinements */
.sticky-actions .button.big,
#nextBtn.button.big {
  min-height: 76px;
  font-size: 1.22rem;
  border-radius: 12px;
}

.coming-off-box .sub-player {
  background: linear-gradient(90deg, rgba(250, 204, 21, 0.10), rgba(22, 36, 55, 0.94) 42%);
  border-color: rgba(250, 204, 21, 0.22);
}

.going-on-box .sub-player {
  background: linear-gradient(90deg, rgba(96, 165, 250, 0.10), rgba(22, 36, 55, 0.94) 42%);
  border-color: rgba(96, 165, 250, 0.24);
}

#tournamentBtn {
  background: rgba(88, 28, 135, 0.42);
  color: #f3e8ff;
  border-color: rgba(196, 181, 253, 0.32);
}

.tournament-game-panel {
  display: grid;
  gap: 12px;
  background: rgba(35, 14, 55, 0.82);
  border-color: rgba(168, 85, 247, 0.32);
}

.tournament-game-panel.hidden {
  display: none;
}

.tournament-page-top {
  border: 1px solid rgba(168, 85, 247, 0.22);
  border-radius: 14px;
  padding: 12px;
  background: rgba(15, 23, 42, 0.66);
}

.tournament-page-top strong {
  display: block;
  margin-top: 2px;
  color: #f5f3ff;
  font-size: 1.05rem;
}

.tournament-page-top p {
  margin: 6px 0 0;
  color: #ddd6fe;
}

.tournament-dominant-card {
  min-height: 132px;
  border-radius: 18px;
  padding: 16px;
  background: linear-gradient(135deg, rgba(109, 40, 217, 0.95), rgba(49, 46, 129, 0.92));
  border: 1px solid rgba(221, 214, 254, 0.34);
  box-shadow: 0 18px 36px rgba(0, 0, 0, 0.25);
  display: grid;
  align-content: center;
  gap: 8px;
}

.tournament-dominant-card span {
  color: #ddd6fe;
  font-size: .82rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: .06em;
}

.tournament-dominant-card strong {
  color: #fff;
  font-size: clamp(1.45rem, 7vw, 2.05rem);
  line-height: 1.05;
}

.tournament-dominant-card em {
  color: #fef3c7;
  font-style: normal;
  font-size: 1.15rem;
  font-weight: 900;
}

.tournament-clock-card {
  border-radius: 14px;
  padding: 12px;
  background: rgba(15, 23, 42, 0.78);
  border: 1px solid rgba(96, 165, 250, 0.28);
}

.tournament-clock-card span {
  display: block;
  color: #93c5fd;
  font-size: .82rem;
  font-weight: 900;
  text-transform: uppercase;
}

.tournament-clock-card strong {
  display: block;
  margin-top: 4px;
  color: #eff6ff;
  font-size: 1.28rem;
}

.tournament-stats-card {
  border-radius: 14px;
  padding: 12px;
  background: rgba(15, 23, 42, 0.70);
  border: 1px solid rgba(148, 163, 184, 0.20);
}

.tournament-stats-card h3 {
  margin: 0 0 10px;
  color: #e9d5ff;
}

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

.tournament-stat-badge {
  border-radius: 10px;
  background: rgba(30, 41, 59, 0.86);
  border: 1px solid rgba(148, 163, 184, 0.18);
  padding: 8px;
}

.tournament-stat-badge strong,
.tournament-stat-badge span {
  display: block;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.tournament-stat-badge strong {
  color: #f8fafc;
  font-size: .9rem;
}

.tournament-stat-badge span {
  color: #c4b5fd;
  font-weight: 900;
}

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

/* Settings start-flow cleanup: hidden squad organisation + tournament-only setup */
.settings-mode-label select {
  min-height: 48px;
  border-color: rgba(226, 232, 240, 0.85);
}
.settings-collapsible,
.settings-card {
  border: 1px solid rgba(148, 163, 184, 0.22);
  border-radius: 12px;
  padding: 12px;
  background: rgba(15, 23, 42, 0.48);
}
.settings-collapsible summary {
  cursor: pointer;
  font-size: 1rem;
  font-weight: 950;
  color: #e5eefb;
}
.settings-collapsible:not([open]) {
  padding-block: 10px;
}
.tournament-settings-area.hidden {
  display: none;
}
.settings-save-row {
  margin-top: 4px;
}
.settings-save-play {
  min-height: 58px;
  font-size: 1.08rem;
  border-radius: 12px;
}
.settings-card h3 {
  margin-top: 0;
}

.miniball-rules-card ul {
  margin: 8px 0 0;
  padding-left: 20px;
}

.rules-section {
  margin-top: 12px;
}

.rules-section h4 {
  margin: 0;
}


/* Tournament full-page view */
.tournament-screen.active {
  display: block;
}

.tournament-page-shell {
  display: grid;
  gap: 12px;
  min-height: calc(100vh - 96px);
  padding-bottom: calc(92px + env(safe-area-inset-bottom));
}

.tournament-page-header,
.tournament-current-card,
.tournament-dominant-card,
.tournament-clock-card,
.tournament-stats-card {
  border: 1px solid rgba(168, 85, 247, .42);
  background: rgba(36, 14, 58, .86);
  color: #f8f4ff;
  border-radius: 10px;
  padding: 14px;
  box-shadow: 0 8px 22px rgba(0, 0, 0, .18);
}

.tournament-page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.tournament-page-header h2 {
  margin-top: 7px;
  font-size: 1.22rem;
}

.tournament-section-kicker {
  display: block;
  color: #d8b4fe;
  text-transform: uppercase;
  letter-spacing: .04em;
  font-weight: 950;
  font-size: .82rem;
  margin-bottom: 8px;
}

.tournament-current-card strong,
.tournament-dominant-card strong,
.tournament-clock-card strong {
  display: block;
  font-size: 1.32rem;
  line-height: 1.18;
}

.tournament-game-meta,
.tournament-next-meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 10px;
}

.tournament-game-meta span,
.tournament-next-meta span,
.tournament-next-meta em {
  border-radius: 999px;
  background: rgba(255, 255, 255, .12);
  padding: 7px 10px;
  font-style: normal;
  font-weight: 900;
}

.tournament-dominant-card {
  min-height: 132px;
  display: grid;
  align-content: center;
  background: linear-gradient(135deg, rgba(88, 28, 135, .96), rgba(30, 64, 175, .72));
  border-color: rgba(216, 180, 254, .72);
}

.tournament-dominant-card strong {
  font-size: 1.58rem;
}

.tournament-clock-card small {
  display: block;
  margin-top: 8px;
  color: #c4b5fd;
  font-weight: 750;
}

.tournament-stats-card h3 {
  margin: 0;
}

.tournament-stats-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 12px;
}

.tournament-stat-badge {
  border-radius: 8px;
  background: rgba(15, 23, 42, .72);
  border: 1px solid rgba(216, 180, 254, .22);
  padding: 10px;
}

.tournament-stat-badge strong,
.tournament-stat-badge span {
  display: block;
}

.tournament-stat-badge span {
  color: #d8b4fe;
  font-weight: 900;
  margin-top: 3px;
}

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


/* Tournament start-flow refinements */
.start-tournament-info {
  border-color: rgba(168, 85, 247, 0.55);
  background: linear-gradient(135deg, rgba(88, 28, 135, 0.35), rgba(15, 23, 42, 0.98));
  padding: 12px;
}
.start-tournament-kicker {
  color: #c4b5fd;
  font-size: 0.75rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.start-tournament-opponent {
  margin-top: 4px;
  font-size: 1.25rem;
  font-weight: 950;
  color: #ffffff;
}
.start-tournament-meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 8px;
}
.start-tournament-meta span {
  background: rgba(147, 51, 234, 0.22);
  border: 1px solid rgba(196, 181, 253, 0.25);
  color: #ede9fe;
  border-radius: 999px;
  padding: 5px 8px;
  font-size: 0.82rem;
  font-weight: 900;
}
.start-name-button {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
}
.start-name-button small {
  color: #bfdbfe;
  font-size: 0.72rem;
  font-weight: 900;
}
.settings-inline-save {
  margin-top: 10px;
  width: 100%;
}

/* Half-time and tournament transition flow */
.half-time-panel {
  border-color: rgba(96, 165, 250, 0.55);
  background: linear-gradient(135deg, rgba(30, 64, 175, 0.30), rgba(15, 23, 42, 0.98));
  text-align: center;
}
.half-time-kicker {
  color: #93c5fd;
  font-size: 0.75rem;
  font-weight: 950;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.half-time-panel h2 {
  margin: 8px 0 6px;
  font-size: 1.35rem;
  color: #ffffff;
}
.half-time-main {
  margin: 0 0 12px;
  color: #dbeafe;
  font-weight: 800;
}
.half-time-actions {
  display: grid;
  gap: 10px;
}
.half-time-actions .button.big {
  min-height: 64px;
  font-size: 1.02rem;
}
.start-tournament-countdown,
.tournament-page-countdown {
  margin-top: 10px;
  border-radius: 12px;
  border: 1px solid rgba(216, 180, 254, 0.36);
  background: rgba(88, 28, 135, 0.22);
  color: #f5f3ff;
  font-weight: 950;
  padding: 10px;
  text-align: center;
}
.tournament-page-countdown {
  font-size: 1.2rem;
}

/* STARTER COLOUR FIX
   Start screen:
   - Green = selected to start ON
   - Blue = present but not selected to start ON
*/
.start-player-card,
.player-start-card,
.present-player-card,
.player-select-card {
  background: rgba(37, 99, 235, 0.18);
  border-color: rgba(96, 165, 250, 0.75);
}

.start-player-card.starter-on,
.player-start-card.starter-on,
.present-player-card.starter-on,
.player-select-card.starter-on,
.start-player-card.starts-on,
.player-start-card.starts-on,
.present-player-card.starts-on,
.player-select-card.starts-on,
.start-player-card.selected-starter,
.player-start-card.selected-starter,
.present-player-card.selected-starter,
.player-select-card.selected-starter,
.start-player-card.is-starter,
.player-start-card.is-starter,
.present-player-card.is-starter,
.player-select-card.is-starter {
  background: rgba(34, 197, 94, 0.22);
  border-color: rgba(34, 197, 94, 0.95);
}

.start-player-card:not(.starter-on):not(.starts-on):not(.selected-starter):not(.is-starter) .start-on-btn,
.player-start-card:not(.starter-on):not(.starts-on):not(.selected-starter):not(.is-starter) .start-on-btn,
.present-player-card:not(.starter-on):not(.starts-on):not(.selected-starter):not(.is-starter) .start-on-btn,
.player-select-card:not(.starter-on):not(.starts-on):not(.selected-starter):not(.is-starter) .start-on-btn {
  background: rgba(30, 64, 175, 0.9);
  color: #dbeafe;
}

.start-player-card.starter-on .start-on-btn,
.player-start-card.starter-on .start-on-btn,
.present-player-card.starter-on .start-on-btn,
.player-select-card.starter-on .start-on-btn,
.start-player-card.starts-on .start-on-btn,
.player-start-card.starts-on .start-on-btn,
.present-player-card.starts-on .start-on-btn,
.player-select-card.starts-on .start-on-btn,
.start-player-card.selected-starter .start-on-btn,
.player-start-card.selected-starter .start-on-btn,
.present-player-card.selected-starter .start-on-btn,
.player-select-card.selected-starter .start-on-btn,
.start-player-card.is-starter .start-on-btn,
.player-start-card.is-starter .start-on-btn,
.present-player-card.is-starter .start-on-btn,
.player-select-card.is-starter .start-on-btn {
  background: rgba(34, 197, 94, 0.95);
  color: #052e16;
}


/* Tournament reset + halftime starter clarity */
.player-card.start-card.selected {
  border-color: rgba(96, 165, 250, 0.95);
  background: rgba(37, 99, 235, 0.22);
  color: #eff6ff;
}

.player-card.start-card.away,
.player-card.start-card.away.selected {
  border-color: rgba(148, 163, 184, 0.8);
  background: rgba(71, 85, 105, 0.35);
  color: #cbd5e1;
}

.player-card.start-card.starter,
.player-card.start-card.selected.starter {
  border-color: rgba(34, 197, 94, 0.98);
  background: rgba(34, 197, 94, 0.22);
  color: #ecfdf5;
}

.player-card.start-card:not(.starter) .starter-toggle {
  background: rgba(30, 64, 175, 0.92);
  color: #dbeafe;
}

.player-card.start-card.away .starter-toggle,
.player-card.start-card.away .starter-toggle:disabled {
  background: rgba(100, 116, 139, 0.8);
  color: #e2e8f0;
  opacity: 1;
}

.player-card.start-card.starter .starter-toggle,
.player-card.start-card .starter-toggle.selected {
  background: rgba(34, 197, 94, 0.98);
  color: #052e16;
}

.settings-danger-zone {
  margin-top: 14px;
  padding: 14px;
  border: 1px solid rgba(248, 113, 113, 0.55);
  border-radius: 12px;
  background: rgba(127, 29, 29, 0.18);
}

.settings-danger-zone h4 {
  margin: 0 0 6px;
  color: #fecaca;
}

.half-time-next-card {
  margin: 12px 0;
  padding: 12px;
  border: 1px solid rgba(34, 197, 94, 0.55);
  border-radius: 12px;
  background: rgba(20, 83, 45, 0.26);
}

.half-time-player-list {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 7px;
  margin-top: 8px;
}

.half-time-player-badge {
  min-width: 0;
  padding: 9px 6px;
  border-radius: 8px;
  background: rgba(34, 197, 94, 0.28);
  border: 1px solid rgba(34, 197, 94, 0.72);
  color: #dcfce7;
  font-weight: 950;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* iPhone half-time starter name fit */
@media (max-width: 520px) {
  .halftime-card .player-pill,
  .halftime-card .player-chip,
  .halftime-card .starter-pill,
  .halftime-card .starter-chip,
  .halftime-starters .player-pill,
  .halftime-starters .player-chip,
  .halftime-starters .starter-pill,
  .halftime-starters .starter-chip,
  .half-time-starters .player-pill,
  .half-time-starters .player-chip,
  .half-time-starters .starter-pill,
  .half-time-starters .starter-chip {
    font-size: 0.78rem !important;
    padding: 0.45rem 0.42rem !important;
    min-width: 0 !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
  }
}
