/* Scoreboard Styles */
:root {
  --bg: #0f1115;
  --panel: #1b1f27;
  --panel-alt: #232a35;
  --accent-a: #ff4d5d;
  --accent-b: #4da6ff;
  --accent-focus: #ffd166;
  --text: #f5f7fa;
  --muted: #9aa4b1;
  --radius: 14px;
  --transition: 140ms cubic-bezier(.4, 0, .2, 1);
  font-size: clamp(15px, 1.1vw + .4rem, 20px);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, sans-serif;
  background: radial-gradient(circle at 20% 20%, #18202b, #0f1115 60%);
  color: var(--text);
  display: flex;
  flex-direction: column;
  align-items: center;
  -webkit-font-smoothing: antialiased;
}

body.no-scroll {
  overflow: hidden;
  height: 100%;
}

/* Compact vertical spacing adjustments to minimize scroll on 1080p */
body.compact header {
  padding: .8rem clamp(.7rem, 2.4vw, 1.6rem) .15rem;
}

body.compact header h1 {
  font-size: 1.9rem;
  margin: 0 0 .1rem;
}

body.compact header .subtitle {
  font-size: .78rem;
}

body.compact main {
  gap: 1rem;
  padding: 0 clamp(.7rem, 2.2vw, 1.6rem) 1.2rem;
}

body.compact .scoreboard {
  gap: .9rem;
}

body.compact .team-card {
  padding: .75rem .85rem 1rem;
}

body.compact .score-wrapper {
  margin: .6rem 0 .5rem;
}

body.compact .score {
  font-size: clamp(3rem, 8.2vw, 4.2rem);
}

body.compact .wins-badge {
  margin-top: .1rem;
}

body.compact .current-game-panel {
  margin-top: .2rem;
}

body.compact .current-game-panel .panel-title {
  margin: .2rem 0 .4rem;
  font-size: 1.05rem;
}

body.compact .current-game-grid {
  gap: .8rem;
}

body.compact .game-actions button {
  padding: .45rem .65rem;
  font-size: .7rem;
}

body.compact select,
body.compact input {
  padding: .55rem .65rem;
  font-size: .72rem;
}

body.compact .player-list {
  padding: .4rem .45rem .5rem;
}

body.compact .player-list li {
  margin: .25rem 0;
}

body.compact button {
  padding: .45rem .7rem;
  font-size: .75rem;
}

body.compact .utility-bar {
  gap: .45rem;
}

body.compact .reset-notice {
  margin: .5rem 0 .7rem;
  padding: .65rem .75rem .75rem;
}

body.compact .reset-title {
  font-size: .6rem;
}

body.compact .reset-desc {
  font-size: .6rem;
}

body.compact footer {
  padding: 0 clamp(.7rem, 2.2vw, 1.6rem) 1rem;
}

/* Auto-enable compact mode when viewport height <= 900px */
@media (max-height: 900px) {
  body:not(.no-auto-compact) {
    /* mimic class rules */
    padding-top: 0;
    /* ensures no accidental extra margin */
  }

  body:not(.no-auto-compact) header {
    padding: .8rem clamp(.7rem, 2.4vw, 1.6rem) .15rem;
  }

  body:not(.no-auto-compact) header h1 {
    font-size: 1.9rem;
    margin: 0 0 .1rem;
  }

  body:not(.no-auto-compact) header .subtitle {
    font-size: .78rem;
  }

  body:not(.no-auto-compact) main {
    gap: 1rem;
    padding: 0 clamp(.7rem, 2.2vw, 1.6rem) 1.2rem;
  }

  body:not(.no-auto-compact) .scoreboard {
    gap: .9rem;
  }

  body:not(.no-auto-compact) .team-card {
    padding: .75rem .85rem 1rem;
  }

  body:not(.no-auto-compact) .score-wrapper {
    margin: .6rem 0 .5rem;
  }

  body:not(.no-auto-compact) .score {
    font-size: clamp(3rem, 8.2vw, 4.2rem);
  }

  body:not(.no-auto-compact) .wins-badge {
    margin-top: .1rem;
  }

  body:not(.no-auto-compact) .current-game-panel {
    margin-top: .2rem;
  }

  body:not(.no-auto-compact) .current-game-panel .panel-title {
    margin: .2rem 0 .4rem;
    font-size: 1.05rem;
  }

  body:not(.no-auto-compact) .current-game-grid {
    gap: .8rem;
  }

  body:not(.no-auto-compact) .game-actions button {
    padding: .45rem .65rem;
    font-size: .7rem;
  }

  body:not(.no-auto-compact) select,
  body:not(.no-auto-compact) input {
    padding: .55rem .65rem;
    font-size: .72rem;
  }

  body:not(.no-auto-compact) .player-list {
    padding: .4rem .45rem .5rem;
  }

  body:not(.no-auto-compact) .player-list li {
    margin: .25rem 0;
  }

  body:not(.no-auto-compact) button {
    padding: .45rem .7rem;
    font-size: .75rem;
  }

  body:not(.no-auto-compact) .utility-bar {
    gap: .45rem;
  }

  body:not(.no-auto-compact) .reset-notice {
    margin: .5rem 0 .7rem;
    padding: .65rem .75rem .75rem;
  }

  body:not(.no-auto-compact) .reset-title {
    font-size: .6rem;
  }

  body:not(.no-auto-compact) .reset-desc {
    font-size: .6rem;
  }

  body:not(.no-auto-compact) footer {
    padding: 0 clamp(.7rem, 2.2vw, 1.6rem) 1rem;
  }
}

/* Setup Screen (revamped) */
.setup-screen {
  position: fixed;
  inset: 0;
  background: radial-gradient(circle at 25% 30%, #1a2733, #0f1115 70%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.8rem clamp(.8rem, 2.4vw, 2rem);
  z-index: 1000;
  overflow: hidden;
}

.setup-screen.hidden {
  display: none;
}

.setup-panel {
  width: min(1075px, 100%);
  background: linear-gradient(155deg, #1b232c, #151c24 70%);
  border: 1px solid #2d3945;
  border-radius: 24px;
  padding: 1.6rem clamp(.9rem, 2.3vw, 2.2rem) 1.9rem;
  box-shadow: 0 18px 46px -16px rgba(0, 0, 0, .7), 0 4px 14px -6px rgba(0, 0, 0, .55) inset;
  display: flex;
  flex-direction: column;
  gap: 1.55rem;
  position: relative;
}

.setup-panel:before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: radial-gradient(circle at 80% 20%, rgba(255, 255, 255, .05), transparent 60%);
  pointer-events: none;
}

.setup-panel h1 {
  margin: 0;
  font-size: 2.5rem;
  background: linear-gradient(110deg, var(--accent-a), var(--accent-b));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  letter-spacing: .75px;
  text-shadow: 0 4px 14px rgba(0, 0, 0, .35);
}

.setup-panel h1 span {
  font-size: .55em;
  display: block;
  text-transform: uppercase;
  letter-spacing: 2px;
  margin-top: .6rem;
  color: var(--muted);
  background: none;
  -webkit-background-clip: initial;
  background-clip: initial;
}

.setup-grid {
  display: grid;
  gap: 1.1rem .95rem;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  align-items: start;
}

/* Force exactly two columns for team section when using teams-first variant */
.setup-grid.teams-first {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.setup-grid.teams-first>.setup-field.span-full {
  grid-column: 1 / -1;
}

@media (max-width: 840px) {
  .setup-grid.teams-first {
    grid-template-columns: 1fr;
  }
}

.setup-grid .span-full {
  grid-column: 1 / -1;
}

.setup-field {
  display: flex;
  flex-direction: column;
  gap: .55rem;
  background: #202a33;
  border: 1px solid #2c3742;
  padding: .75rem .75rem .85rem;
  border-radius: 16px;
  position: relative;
  box-shadow: 0 4px 14px -8px rgba(0, 0, 0, .55), 0 0 0 1px #27323c inset;
}

.setup-field:before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(140deg, rgba(255, 255, 255, .05), transparent 60%);
  pointer-events: none;
}

.setup-field label {
  font-size: .65rem;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
}

.setup-field input {
  background: #141c23;
  border: 1px solid #313d47;
  border-radius: 9px;
  padding: .55rem .65rem;
  color: var(--text);
  font-size: .78rem;
}

.setup-field input:focus {
  outline: 2px solid var(--accent-focus);
  outline-offset: 2px;
}

.setup-roster {
  display: flex;
  flex-direction: column;
  gap: .55rem;
  margin-top: .3rem;
}

.roster-add-row {
  display: flex;
  gap: .5rem;
}

.setup-panel .player-add-input {
  flex: 1;
  background: #131a21;
  border: 1px solid #2c3640;
  padding: .45rem .55rem;
  border-radius: 8px;
  font-size: .68rem;
}

.setup-panel .player-add-input:focus {
  outline: 2px solid var(--accent-focus);
  outline-offset: 2px;
}

.setup-panel .player-list {
  background: #161f27;
  border: 1px dashed #2f4659;
  padding: .45rem .5rem .55rem;
  border-radius: 11px;
  min-height: 44px;
}

.setup-panel .player-list li {
  background: #24323f;
  border: 1px solid #324455;
}

.setup-panel .player-list li .move-player {
  background: #1d2730;
  border: 1px solid #35506a;
  color: var(--accent-b);
  font-size: .55rem;
  padding: .25rem .45rem;
  border-radius: 6px;
  margin-left: .4rem;
  cursor: pointer;
  transition: var(--transition);
}

.setup-panel .player-list li .move-player:hover {
  background: #25313c;
}

.setup-panel .player-list li .move-player:focus {
  outline: 2px solid var(--accent-focus);
  outline-offset: 2px;
}

/* unified button sizing (removed .small variant) */

.setup-panel .player-list li.played {
  opacity: 1;
  filter: none;
}

.setup-actions {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: .9rem;
  align-items: center;
  margin-top: -.6rem;
}

.setup-actions button {
  font-size: .82rem;
  padding: .7rem 1.15rem;
  border-radius: 11px;
  font-weight: 600;
  letter-spacing: .4px;
  min-width: 170px;
}

.setup-actions button.danger {
  background: linear-gradient(140deg, #3a2023, #2a1416 60%);
  border: 1px solid #553034;
}

.setup-actions button.danger:hover {
  background: linear-gradient(140deg, #422428, #31181a 60%);
}

.setup-actions button.danger:focus {
  outline: 2px solid var(--accent-focus);
  outline-offset: 2px;
}

.custom-games-list {
  list-style: none;
  margin: .4rem 0 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: .45rem;
  max-height: 140px;
  overflow: auto;
}

.custom-games-list li {
  background: #1c2730;
  border: 1px solid #2c3a46;
  padding: .35rem .55rem .4rem;
  border-radius: 9px;
  font-size: .63rem;
  letter-spacing: .3px;
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  position: relative;
}

.custom-games-list li .cg-title {
  font-weight: 600;
  color: #d5dee6;
}

.custom-games-list li .cg-link {
  color: var(--accent-b);
  text-decoration: none;
  font-size: .62rem;
  font-weight: 600;
}

.custom-games-list li .cg-link:hover {
  text-decoration: underline;
}

.custom-games-list li button.remove-cg {
  background: #2c3944;
  border: 1px solid #3b4a55;
  color: #c7d2da;
  font-size: .6rem;
  padding: .15rem .35rem;
  border-radius: 5px;
  cursor: pointer;
  line-height: 1;
}

/* Restore (enable) button styled same baseline as remove */
.custom-games-list li button.restore-cg {
  background: #323f4a;
  border: 1px solid #44525d;
  color: #d2dee6;
  font-size: .6rem;
  padding: .15rem .42rem;
  /* keep consistent height */
  border-radius: 5px;
  cursor: pointer;
  line-height: 1;
}

.custom-games-list li button.restore-cg:hover {
  background: #3a4954;
}

.custom-games-list li button.restore-cg:focus {
  outline: 2px solid var(--accent-focus);
  outline-offset: 2px;
}

.custom-games-list li button.remove-cg:hover {
  background: #374751;
}

.custom-games-list li.ir l-tag {
  background: #344353;
}

.custom-games-list li .irl-badge {
  background: #394856;
  color: #b8c4ce;
  font-size: .5rem;
  padding: .15rem .4rem;
  border-radius: 4px;
  letter-spacing: .5px;
  text-transform: uppercase;
}

/* Default badge */
.custom-games-list li .def-badge {
  background: linear-gradient(140deg, #2e3a45, #24313c);
  border: 1px solid #3b4a55;
  color: #d0dae2;
  font-size: .48rem;
  padding: .18rem .38rem;
  border-radius: 4px;
  letter-spacing: .6px;
  font-weight: 600;
}

.custom-games-list li .def-badge.disabled {
  opacity: .45;
  filter: grayscale(.4);
}

/* Disabled (inaktiverat) spel – starkare visuell signal */
.custom-games-list li.disabled {
  background: linear-gradient(140deg, #3a1f23, #251316 55%);
  border: 1px solid #553338;
  box-shadow: 0 0 0 1px #402327 inset;
  color: #e5b9be;
}

.custom-games-list li.disabled .cg-title {
  text-decoration: line-through;
  opacity: .75;
}

.custom-games-list li.disabled .disabled-tag {
  font-size: .5rem;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: #ff9aa6;
  background: #522b31;
  padding: .15rem .35rem;
  border-radius: 4px;
  font-weight: 600;
}

.custom-games-list li.disabled button.restore-cg {
  background: #522f35;
  border-color: #6a4047;
  color: #ffced4;
}

.custom-games-list li.disabled button.restore-cg:hover {
  background: #5c343b;
}

.custom-games-list li.disabled button.restore-cg:focus {
  outline: 2px solid #ff9aa6;
  outline-offset: 2px;
}

.custom-games-list li.empty {
  background: none;
  border: 1px dashed #31404c;
  color: var(--muted);
  font-style: italic;
  padding: .6rem .8rem;
  flex: 1 1 100%;
  justify-content: center;
}

.hint {
  display: block;
  margin-top: .45rem;
  font-size: .55rem;
  letter-spacing: .5px;
  color: var(--muted);
}


.tie-timer {
  background: linear-gradient(140deg, #27313b, #1b242c);
  border: 1px solid #31404c;
  padding: .45rem .75rem .5rem;
  border-radius: 12px;
  font-size: .8rem;
  font-weight: 600;
  letter-spacing: .5px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 62px;
  box-shadow: 0 2px 6px -3px rgba(0, 0, 0, .55), 0 0 0 1px #25323c inset;
  color: #d9e3ec;
  position: relative;
}

.tie-timer:before {
  content: '\23F1';
  /* stopwatch symbol */
  font-size: .85em;
  margin-right: .45ch;
  filter: drop-shadow(0 0 2px rgba(0, 0, 0, .4));
  opacity: .85;
}

.tie-timer.warning {
  background: linear-gradient(140deg, #3a3526, #2a2317);
  border-color: #5a4931;
  color: #f8e3c2;
}

.tie-timer.danger {
  background: linear-gradient(140deg, #3a1f24, #2a1517);
  border-color: #5a3035;
  color: #ffd7dd;
}

.game-add-row input {
  flex: 1;
}

.setup-divider {
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--accent-a) 20%, var(--accent-b) 80%, transparent);
  opacity: .5;
}

@media (max-width: 760px) {
  .setup-panel {
    padding: 2rem 1.1rem 2.2rem;
    border-radius: 22px;
  }

  .setup-panel h1 {
    font-size: 2.1rem;
  }

  .setup-grid {
    gap: 1.2rem;
    grid-template-columns: 1fr;
  }

  .setup-field {
    padding: .9rem .85rem 1rem;
  }

  .setup-actions button.primary {
    width: 100%;
    justify-content: center;
  }
}


header {
  width: min(1400px, 100%);
  padding: 1.2rem clamp(.8rem, 3vw, 2rem) .4rem;
}

header h1 {
  margin: 0 0 .2rem;
  font-size: 2.1rem;
  letter-spacing: .5px;
  background: linear-gradient(90deg, var(--accent-a), var(--accent-b));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

header .subtitle {
  color: var(--muted);
  font-size: .9rem;
}

main {
  width: min(1400px, 100%);
  padding: 0 clamp(.8rem, 3vw, 2rem) 2rem;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.scoreboard {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: 1.2rem;
  align-items: stretch;
}

.team-card {
  background: linear-gradient(145deg, var(--panel), var(--panel-alt));
  border-radius: var(--radius);
  padding: 1rem 1.1rem 1.3rem;
  position: relative;
  display: flex;
  flex-direction: column;
  box-shadow: 0 4px 14px -6px rgba(0, 0, 0, .55), 0 2px 4px -2px rgba(0, 0, 0, .5) inset;
  border: 1px solid #2b3642;
  overflow: hidden;
}

.team-card:before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 65% 35%, rgba(255, 255, 255, .05), transparent 60%);
  pointer-events: none;
}

.team-header {
  display: flex;
  gap: .75rem;
  align-items: center;
}

.team-color {
  width: 16px;
  height: 16px;
  border-radius: 4px;
  flex-shrink: 0;
  box-shadow: 0 0 0 2px #0f1115, 0 0 0 3px currentColor;
}

.team-name-input {
  background: transparent;
  border: 1px solid transparent;
  padding: .4rem .55rem;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text);
  border-radius: 8px;
  width: 100%;
  transition: var(--transition);
}

.team-name-input:focus {
  outline: none;
  border-color: var(--accent-focus);
  background: #202a35;
}

/* Match wins badge */
.wins-badge {
  font-size: .65rem;
  background: linear-gradient(120deg, #2b3642, #1d252d);
  border: 1px solid #394752;
  padding: .25rem .55rem;
  border-radius: 999px;
  font-weight: 600;
  letter-spacing: .5px;
  color: #d5dee7;
  display: inline-flex;
  align-items: center;
  gap: .3ch;
  margin-left: auto;
  box-shadow: 0 2px 4px -2px rgba(0, 0, 0, .6), 0 0 0 1px #25303a inset;
  white-space: nowrap;
  /* keep number + trophy on one line */
}

@media (max-width:600px) {
  .wins-badge {
    font-size: .55rem;
    padding: .25rem .55rem;
  }
}

.score-wrapper {
  margin: 1rem 0 .8rem;
  display: flex;
  align-items: center;
  justify-content: center;
  /* center score */
  flex-direction: column;
  gap: .4rem;
}

.score {
  font-size: clamp(3.1rem, 8.4vw, 4.4rem);
  /* slightly smaller */
  font-weight: 700;
  letter-spacing: 2px;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  background: linear-gradient(180deg, #fff, #d7dfe7 40%, #91a0b0);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 6px 14px rgba(0, 0, 0, .35));
}

/* Smaller score inside current round buttons if needed */
.game-actions button span[data-team-a-name],
.game-actions button span[data-team-b-name] {
  font-size: .9em;
}

/* Ensure compact variant also reduces main score slightly more */
body.compact .score {
  font-size: clamp(2.8rem, 7.6vw, 4rem);
}

.buttons {
  display: flex;
  gap: .55rem;
  flex-wrap: wrap;
}

button {
  --btn-bg: #283341;
  cursor: pointer;
  border: 1px solid #394959;
  background: linear-gradient(160deg, var(--btn-bg), #1e262f 70%);
  color: var(--text);
  font: 500 .9rem/1 system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  padding: .55rem .9rem;
  border-radius: 9px;
  display: inline-flex;
  gap: .4rem;
  align-items: center;
  position: relative;
  transition: var(--transition);
}

button:hover {
  filter: brightness(1.15);
}

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

button:focus-visible {
  outline: 2px solid var(--accent-focus);
  outline-offset: 2px;
}

button.primary {
  --btn-bg: #3a4bff;
  border-color: #4d58ff;
}

button.danger {
  --btn-bg: #ff3d4d;
  border-color: #ff5e6b;
}

button.alt {
  --btn-bg: #475568;
}

/* (Deprecated Series styles removed) */

/* Match Panel */
.match-panel {
  background: linear-gradient(145deg, var(--panel), var(--panel-alt));
  border: 1px solid #2b3642;
  border-radius: var(--radius);
  padding: 1rem 1.1rem 1.1rem;
  display: flex;
  flex-direction: column;
  gap: .9rem;
  box-shadow: 0 4px 14px -6px rgba(0, 0, 0, .55), 0 2px 4px -2px rgba(0, 0, 0, .5) inset;
}

.match-settings-row {
  display: flex;
  gap: .6rem;
  flex-wrap: wrap;
  align-items: center;
}

.inline-label {
  font-size: .7rem;
  text-transform: uppercase;
  letter-spacing: .9px;
  color: var(--muted);
}

.target-input {
  width: 90px;
  padding: .5rem .55rem;
  background: #1c2530;
  border: 1px solid #3a4755;
  border-radius: 8px;
  color: var(--text);
  font-size: .85rem;
}

.match-progress {
  font-size: .75rem;
  letter-spacing: .5px;
  color: var(--muted);
  min-height: 1rem;
}

/* Emphasized central match progress */
.match-progress-bar {
  text-align: center;
}

.match-progress {
  font-size: clamp(.95rem, 1.3vw, 1.15rem);
  font-weight: 600;
  letter-spacing: .7px;
  color: #d7e2ec;
  margin-bottom: .15rem;
  /* even tighter */
}

.match-progress strong {
  color: #fff;
}

/* Locked selects state */
select[disabled] {
  opacity: .5;
}

.locked-label {
  font-size: .55rem;
  background: #394552;
  padding: .2rem .45rem;
  border-radius: 5px;
  letter-spacing: .5px;
  text-transform: uppercase;
}

.utility-bar {
  display: flex;
  gap: .45rem;
  flex-wrap: wrap;
  margin-top: -.2rem;
  /* pull closer to progress */
  padding-top: 0;
}

.utility-bar button {
  padding: .5rem .75rem;
  font-size: .78rem;
  line-height: 1;
}

/* Slightly tighten selects and round winner buttons for consistency */
select[data-player-select-a],
select[data-player-select-b] {
  padding: .5rem .55rem;
  font-size: .8rem;
}

.game-actions button {
  padding: .5rem .65rem;
  font-size: .72rem;
}

.utility-bar button {
  white-space: nowrap;
}

/* Reset Notice */
.reset-notice {
  margin: .8rem 0 1rem;
  background: linear-gradient(135deg, #262f39, #1d252d);
  border: 1px solid #364451;
  padding: .9rem 1rem 1rem;
  border-radius: 16px;
  position: relative;
  box-shadow: 0 4px 18px -8px rgba(0, 0, 0, .55), 0 0 0 1px #2a333c inset;
  overflow: hidden;
}

.reset-notice:before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 85% 20%, rgba(255, 255, 255, .07), transparent 70%);
  pointer-events: none;
}

.reset-title {
  display: flex;
  align-items: center;
  gap: .55rem;
  font-size: .72rem;
  letter-spacing: 1.8px;
  text-transform: uppercase;
  color: #f2f6fa;
  margin: 0 0 .4rem;
  position: relative;
}

.reset-title:before {
  content: "⚠";
  font-size: .9rem;
  line-height: 1;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, .5));
}

.reset-desc {
  margin: 0;
  font-size: .68rem;
  line-height: 1.25;
  color: var(--muted);
}

.reset-notice strong {
  font-weight: 600;
}

.reset-notice p {
  font-weight: 400;
}

footer {
  width: min(1400px, 100%);
  padding: 0 clamp(.8rem, 3vw, 2rem) 2rem;
  margin-top: auto;
}

/* Roster & Current Game */
.roster {
  margin-top: .6rem;
  background: #212a33;
  border: 1px solid #2f3c49;
  padding: .6rem .65rem .75rem;
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  gap: .55rem;
}

.roster-header {
  display: flex;
  gap: .5rem;
}

.player-add-input {
  flex: 1;
  background: #1a222a;
  border: 1px solid #303d49;
  color: var(--text);
  border-radius: 8px;
  padding: .45rem .6rem;
  font-size: .8rem;
}

.player-add-input:focus {
  outline: 2px solid var(--accent-focus);
  outline-offset: 2px;
}

.player-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: .45rem;
}

.player-list li {
  background: #283442;
  border: 1px solid #344351;
  padding: .35rem .55rem;
  border-radius: 7px;
  font-size: .7rem;
  display: inline-flex;
  gap: .45rem;
  align-items: center;
  position: relative;
}

.player-list li.played {
  opacity: .55;
  filter: grayscale(.35);
}

.player-list button.remove-player {
  background: #3c4955;
  border: 1px solid #4b5c6a;
  font-size: .65rem;
  padding: .15rem .4rem;
  border-radius: 5px;
  cursor: pointer;
}

.player-list button.remove-player:hover {
  background: #4d5d6b;
}

.current-game-panel {
  background: linear-gradient(145deg, var(--panel), var(--panel-alt));
  border: 1px solid #2b3642;
  border-radius: var(--radius);
  padding: 1rem 1.1rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  box-shadow: 0 4px 14px -6px rgba(0, 0, 0, .55), 0 2px 4px -2px rgba(0, 0, 0, .5) inset;
}

.panel-title {
  margin: 0;
  font-size: 1.05rem;
  letter-spacing: .5px;
  font-weight: 600;
}

.current-game-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.current-selectors {
  display: flex;
  flex-direction: column;
  gap: .75rem;
}

.selector label {
  font-size: .7rem;
  text-transform: uppercase;
  letter-spacing: .9px;
  color: var(--muted);
  display: block;
  margin-bottom: .3rem;
}

select[data-player-select-a],
select[data-player-select-b] {
  width: 100%;
  padding: .55rem .6rem;
  border-radius: 8px;
  background: #1c2530;
  border: 1px solid #35424f;
  color: var(--text);
  font-size: .85rem;
}

select:focus {
  outline: 2px solid var(--accent-focus);
  outline-offset: 2px;
}

.game-display {
  background: #212a33;
  border: 1px solid #2f3c49;
  border-radius: 12px;
  padding: .9rem .9rem 1.05rem;
  display: flex;
  flex-direction: column;
  gap: .75rem;
}

.game-meta {
  display: flex;
  gap: .6rem;
  align-items: center;
  font-size: .85rem;
}

.game-label {
  text-transform: uppercase;
  font-size: .65rem;
  letter-spacing: 1px;
  color: var(--muted);
}

.game-link {
  color: var(--accent-b);
  text-decoration: none;
  font-weight: 600;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.game-link.no-link {
  color: var(--text);
  cursor: default;
  font-weight: 500;
  pointer-events: none;
  text-decoration: none !important;
}

.game-link:hover {
  text-decoration: underline;
}

.game-actions {
  display: flex;
  flex-wrap: wrap;
  gap: .55rem;
}

.cycle-hint {
  color: var(--muted);
  font-size: .65rem;
}

button[disabled] {
  opacity: .55;
  cursor: not-allowed;
}

/* badges for player states */
.player-badge {
  font-size: .55rem;
  padding: .15rem .4rem;
  background: #344455;
  border-radius: 5px;
  letter-spacing: .5px;
  text-transform: uppercase;
  color: #c7d2dc;
}

.player-badge.played {
  background: #45576a;
}

.player-badge.selected {
  background: #3a4bff;
  color: #fff;
}

.player-badge.in-round {
  background: #ff4d5d;
  color: #fff;
}

.player-list li.selected {
  box-shadow: 0 0 0 2px #3a4bff88;
}

.player-list li.in-round {
  box-shadow: 0 0 0 2px #ff4d5d88;
}

/* Click-to-select affordance (entire list item) */
.player-list li.pickable {
  cursor: pointer;
  transition: background var(--transition), box-shadow var(--transition), transform var(--transition);
}

.player-list li.pickable:hover {
  background: #314154;
  box-shadow: 0 0 0 2px #3a4bff55;
}

.player-list li.pickable:active {
  transform: translateY(1px);
}

footer small {
  color: var(--muted);
  font-size: .65rem;
  letter-spacing: .5px;
}

/* Winner Overlay */
.winner-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 14, 18, .85);
  backdrop-filter: blur(8px) saturate(140%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem clamp(1rem, 3vw, 3rem);
  z-index: 2000;
  animation: fadeIn .5s ease;
}

.winner-overlay.hidden {
  display: none;
}

.winner-content {
  position: relative;
  width: min(1080px, 100%);
  background: linear-gradient(145deg, #1d2630, #141b22);
  border: 1px solid #2d3a46;
  border-radius: 30px;
  padding: 2.8rem clamp(1.2rem, 3.5vw, 3rem) 3.2rem;

  /* Tie Breaker Specific Layout */
  #tieBreakerOverlay .winner-content {
    padding: 1.65rem 1.55rem 1.9rem;
    gap: 1.2rem;
  }

  .tie-form {
    display: flex;
    flex-direction: column;
    gap: 1.15rem;
    margin-top: .4rem;
    padding-bottom: .15rem;
    /* ensure descenders (g,p,y) not clipped */
  }

  .tie-row {
    display: flex;
    flex-direction: column;
    gap: .45rem;
  }

  .tie-row label {
    font-size: .7rem;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: var(--muted);
    font-weight: 600;
  }

  .tie-row input[type=number] {
    background: #121a22;
    border: 1px solid #2f3a45;
    border-radius: 10px;
    padding: .7rem .85rem .75rem;
    /* extra bottom padding for descenders */
    font-size: .95rem;
    font-weight: 600;
    color: #f3f6f9;
    box-shadow: 0 2px 4px -2px rgba(0, 0, 0, .6) inset;
  }

  .tie-row input[type=number]:focus {
    outline: 2px solid var(--accent-focus);
    outline-offset: 2px;
  }

  .tie-actions {
    display: flex;
    flex-wrap: wrap;
    gap: .7rem;
    margin-top: .2rem;
  }

  .tie-actions button {
    flex: 1 1 180px;
    justify-content: center;
    font-size: .8rem;
    padding: .75rem 1rem .8rem;
  }

  .tie-status {
    display: block;
    margin-top: .1rem;
    min-height: 1.2em;
    /* reserve space to prevent layout shift */
    font-size: .68rem;
    letter-spacing: .5px;
    color: var(--muted);
  }

  @media (max-width: 560px) {
    #tieBreakerOverlay .winner-content {
      padding: 1.35rem 1.05rem 1.55rem;
    }

    .tie-actions button {
      flex: 1 1 100%;
    }
  }

  box-shadow: 0 20px 54px -18px rgba(0, 0, 0, .75),
  0 0 0 1px #27323c inset;
  overflow: hidden;
}

.winner-content:before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 70% 25%, rgba(255, 255, 255, .08), transparent 60%);
  pointer-events: none;
}

.winner-heading {
  margin: 0 0 1rem;
  font-size: clamp(2rem, 4vw, 3.2rem);
  line-height: 1.05;
  letter-spacing: .5px;
  font-weight: 700;
  background: linear-gradient(90deg, var(--accent-a), var(--accent-b));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: 0 6px 24px rgba(0, 0, 0, .55);
  display: flex;
  flex-wrap: wrap;
  gap: .75rem;
  align-items: flex-end;
}

.winner-prefix {
  font-size: .45em;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: var(--muted);
  background: none;
  -webkit-background-clip: initial;
  background-clip: initial;
}

.winner-score-line {
  font-size: clamp(.95rem, 1.4vw, 1.15rem);
  color: #b9c5d0;
  margin: -.25rem 0 1.4rem;
  letter-spacing: .5px;
}

.players-grid {
  display: grid;
  gap: 1rem 1rem;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  margin-bottom: 2.2rem;
}

.player-card {
  position: relative;
  background: #212d36;
  border: 1px solid #2f3c47;
  border-radius: 18px;
  padding: 1rem .9rem 1.1rem;
  display: flex;
  flex-direction: column;
  gap: .6rem;
  isolation: isolate;
  overflow: hidden;
  animation: popIn .6s cubic-bezier(.16, .8, .3, 1);
}

.player-card:before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(140deg, rgba(255, 255, 255, .06), transparent 60%);
  mix-blend-mode: overlay;
  pointer-events: none;
}

.player-card h3 {
  margin: 0;
  font-size: 1rem;
  letter-spacing: .5px;
  font-weight: 600;
  color: #e2e9ef;
  text-shadow: 0 2px 8px rgba(0, 0, 0, .5);
}

.player-tag {
  font-size: .55rem;
  padding: .25rem .55rem;
  background: #344453;
  border: 1px solid #445767;
  color: #c7d3dc;
  border-radius: 6px;
  letter-spacing: .5px;
  text-transform: uppercase;
  width: max-content;
}

.winner-actions {
  display: flex;
  flex-wrap: wrap;
  gap: .8rem;
  justify-content: flex-end;
}

.winner-actions button {
  font-size: .85rem;
}

.close-overlay {
  position: absolute;
  top: .9rem;
  right: .9rem;
  background: #2a3744;
  border: 1px solid #364553;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  font-size: 1.4rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text);
  cursor: pointer;
}

.close-overlay:hover {
  background: #334151;
}

.confetti-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: scale(.98);
  }

  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes popIn {
  from {
    opacity: 0;
    transform: translateY(14px) scale(.95);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@media (max-width:760px) {
  .winner-content {
    padding: 2.2rem 1.2rem 2.4rem;
    border-radius: 26px;
  }

  .players-grid {
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: .75rem;
  }

  .player-card {
    padding: .85rem .75rem .95rem;
    border-radius: 16px;
  }

  .winner-actions {
    justify-content: center;
  }
}

@media (max-width: 760px) {
  header h1 {
    font-size: 1.7rem;
  }

  .score-wrapper {
    flex-direction: column;
    gap: .6rem;
    align-items: flex-start;
  }

  .current-game-grid {
    grid-template-columns: 1fr;
  }

  .buttons {
    width: 100%;
  }

  .team-card {
    padding: .9rem .9rem 1.1rem;
  }
}