/* Reset & base */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: Arial, sans-serif;
  background: #f4f7f5;
  color: #333;
  line-height: 1.5;
}

.login-container {
  background: white;
  padding: 2rem;
  border-radius: 12px;
  box-shadow: 0 2px 5px rgba(0,0,0,0.1);
  max-width: 320px;
  width: 100%;
  text-align: center;
  margin: 15vh auto 0;
}

.login-container form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.login-container input {
  padding: 0.75rem;
  border: 1px solid #ccc;
  border-radius: 8px;
}

.login-container button {
  padding: 1rem;
  border: none;
  border-radius: 8px;
  background-color: #1a5f4a;
  color: white;
  font-size: 1rem;
  cursor: pointer;
}

.login-container button:hover {
  background-color: #154c3c;
}

.login-back {
  margin-top: 1rem;
}

.login-back a {
  color: #1a5f4a;
}

.error {
  color: #9e000d;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}

.dashboard-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  gap: 1rem;
}

.logout-button {
  padding: 0.5rem 1rem;
  background-color: #1a5f4a;
  color: white;
  text-decoration: none;
  border-radius: 6px;
  white-space: nowrap;
}

.logout-button:hover {
  background-color: #154c3c;
}

.header-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.secondary-button {
  padding: 0.5rem 1rem;
  background: white;
  color: #1a5f4a;
  text-decoration: none;
  border: 1px solid #1a5f4a;
  border-radius: 6px;
  white-space: nowrap;
}

.secondary-button:hover {
  background: #e7f3ee;
}

.score-form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.score-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

.score-controls {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex: none;
}

.score-bumps {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.score-row input {
  width: 6.5rem;
  padding: 0.55rem 0.7rem;
  border: 1px solid #ccc;
  border-radius: 8px;
  font-size: 1rem;
}

.score-bump {
  width: auto;
  min-width: 2.8rem;
  padding: 0.55rem 0.65rem;
  border-radius: 999px;
  font-size: 0.95rem;
  font-weight: 700;
}

.admin-page .score-bump.is-selected {
  background: #6e4e16;
  color: #fff8ea;
  box-shadow: inset 0 0 0 2px #3d2b0c;
}

.admin-controls h2 {
  margin-bottom: 0.75rem;
  font-size: 1.25rem;
}

.saved-note {
  color: #1a5f4a;
  margin-bottom: 0.75rem;
}

.container {
  max-width: 900px;
  margin: auto;
  padding: 1rem;
}

.container.login-container {
  max-width: 320px;
  margin-top: 15vh;
}

h1 {
  text-align: center;
  margin-bottom: 1rem;
}

.status-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1rem;
}

@media (max-width: 600px) {
  .status-grid {
    grid-template-columns: 1fr;
  }

  .dashboard-header {
    flex-direction: column;
  }

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

  .score-row {
    flex-direction: column;
    align-items: stretch;
  }

  .score-controls {
    width: 100%;
  }

  .score-row input {
    width: auto;
    flex: 1;
    min-width: 0;
  }
}

@media (max-width: 700px) and (orientation: portrait) {
  .score-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "team score"
      "minus plus";
    align-items: center;
    column-gap: 0.75rem;
    row-gap: 0.65rem;
  }

  .score-controls {
    display: contents;
  }

  .score-team {
    grid-area: team;
  }

  .score-row input[type="number"] {
    grid-area: score;
    width: 5rem;
    flex: none;
  }

  .score-bumps-minus {
    grid-area: minus;
    justify-content: flex-start;
  }

  .score-bumps-plus {
    grid-area: plus;
    justify-content: flex-end;
  }

  .score-bump {
    min-width: 2.35rem;
    padding: 0.45rem 0.4rem;
  }
}

.status-card,
.admin-controls {
  background: white;
  border-radius: 12px;
  padding: 1rem;
  box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.status-card {
  text-align: center;
}

.status-card h3 {
  margin: 0 0 0.5rem 0;
  font-size: 1.2rem;
}

button {
  display: block;
  width: 100%;
  padding: 1rem;
  font-size: 1rem;
  border: none;
  border-radius: 8px;
  background-color: #1a5f4a;
  color: white;
  cursor: pointer;
}

button:hover {
  background-color: #154c3c;
}

.scoreboard-page {
  min-height: 100vh;
  overflow-x: clip;
  color: #f7f1e3;
  background-color: #0c1c15;
  background-image:
    radial-gradient(circle at 14% 16%, rgba(255, 255, 255, 0.16) 0 1.5px, transparent 2.5px),
    radial-gradient(circle at 78% 10%, rgba(255, 255, 255, 0.14) 0 1.5px, transparent 2.5px),
    radial-gradient(circle at 62% 82%, rgba(255, 255, 255, 0.12) 0 2px, transparent 3px),
    radial-gradient(circle at 28% 70%, rgba(255, 255, 255, 0.1) 0 1.5px, transparent 2.5px),
    radial-gradient(ellipse at top, #1c4634 0%, #0e241b 48%, #08140f 100%);
}

.snow {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 0;
}

.snow span {
  position: absolute;
  top: -2rem;
  color: rgba(255, 255, 255, 0.82);
  line-height: 1;
  animation: snowfall linear infinite;
  text-shadow: 0 0 6px rgba(255, 255, 255, 0.35);
}

.snow span::before {
  content: "❄";
}

@keyframes snowfall {
  0% {
    transform: translate3d(0, -10vh, 0);
  }
  100% {
    transform: translate3d(var(--drift), 110vh, 0);
  }
}

@media (prefers-reduced-motion: reduce) {
  .snow {
    display: none;
  }

  .standing {
    transition: none;
  }
}

.scoreboard-login {
  position: fixed;
  top: 1.1rem;
  right: 1.1rem;
  z-index: 2;
  padding: 0.7rem 1.15rem;
  background: #f3d48a;
  color: #241b08;
  text-decoration: none;
  border-radius: 999px;
  font-weight: 700;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.28);
}

.scoreboard-login:hover {
  background: #ffe7ad;
}

.scoreboard-login:focus-visible {
  outline: 3px solid #fff8ea;
  outline-offset: 3px;
}

.scoreboard-shell {
  position: relative;
  z-index: 1;
  width: min(1100px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 4.75rem 0 3rem;
}

.scoreboard-header {
  text-align: center;
  margin-bottom: 2rem;
}

.scoreboard-kicker {
  letter-spacing: 0.22em;
  text-transform: uppercase;
  font-size: 0.82rem;
  color: #d7c49a;
}

.scoreboard-page h1 {
  color: #f6e7bf;
  font-size: clamp(2.4rem, 6vw, 4rem);
  line-height: 1.05;
  margin: 0.2rem 0;
}

.scoreboard-sub {
  color: #d5e0d8;
  font-size: 1.15rem;
}

.scoreboard-notice {
  text-align: center;
  color: #ffd0d0;
  margin: -0.5rem 0 1.25rem;
}

html.race .standings--live {
  visibility: hidden;
}

html.race .standings--live.is-racing {
  visibility: visible;
}

.standings {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  width: 100%;
  min-width: 0;
}

html.race .standing {
  transition: transform 0.55s cubic-bezier(0.22, 0.8, 0.3, 1);
}

.standing {
  display: grid;
  grid-template-columns: 4.2rem minmax(0, 1fr);
  gap: 0.85rem;
  align-items: center;
  width: 100%;
  min-width: 0;
}

.standing-rank {
  width: 4rem;
  height: 4rem;
  border-radius: 50%;
  overflow: hidden;
  display: grid;
  place-items: center;
  background: #10281c;
  color: #f7f1e3;
  font-weight: 800;
  font-size: 1.15rem;
}

.standing-rank img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.standing--lead .standing-rank {
  box-shadow: 0 0 0 2px #f3d48a;
}

.standing-body {
  min-width: 0;
}

.standing-name {
  font-weight: 700;
  font-size: clamp(1.15rem, 2.4vw, 1.65rem);
  margin-bottom: 0.4rem;
}

.meter {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
  width: 100%;
  max-width: 100%;
}

.meter-bar {
  position: relative;
  overflow: hidden;
  flex-grow: var(--share);
  flex-shrink: 1;
  flex-basis: 0;
  min-width: 1.15rem;
  height: clamp(2.1rem, 4vw, 3rem);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.16);
}

.snow-cap,
.snow-drape,
.snow-drape i {
  position: absolute;
  pointer-events: none;
}

.snow-cap {
  z-index: 1;
  left: 0;
  right: 0;
  top: 0;
  height: 18px;
  background:
    radial-gradient(circle at 10px -2px, #fff 11px, transparent 12px) 0 0 / 18px 18px repeat-x,
    radial-gradient(circle at 4px -1px, #f4f8fb 9px, transparent 10px) 3px 0 / 15px 18px repeat-x,
    radial-gradient(circle at 7px 0, #d7e2ec 13px, transparent 14px) 9px 2px / 22px 18px repeat-x;
}

.snow-drape {
  left: 0;
  right: 0;
  top: 0;
  height: 33%;
}

.snow-drape i {
  top: 0;
  display: block;
  background: linear-gradient(#fff 0%, #fff 72%, rgba(255, 255, 255, 0));
  border-radius: 0 0 8px 8px;
}

.meter-rest {
  flex-grow: calc(1 - var(--share));
  flex-shrink: 1;
  flex-basis: 0;
  min-width: 0;
}

.meter-bar.has-score {
  background: var(--bar, #1a5f4a);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.18);
}

.standing--lead .meter-bar.has-score {
  box-shadow:
    0 0 0 2px rgba(243, 212, 138, 0.85),
    inset 0 0 0 1px rgba(255, 255, 255, 0.2);
}

.meter-score {
  flex: none;
  font-size: clamp(1.45rem, 3vw, 2.15rem);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.03em;
  line-height: 1;
  color: #fff8ea;
}

.standing--lead .meter-score {
  color: #f3d48a;
}

.admin-shell {
  padding-top: 2.25rem;
}

.admin-page h1,
.login-page h1 {
  text-align: left;
  font-size: clamp(2rem, 5vw, 3.2rem);
}

.login-page h1 {
  text-align: center;
  margin-bottom: 1.1rem;
}

.login-page .scoreboard-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding-top: 2rem;
  padding-bottom: 2rem;
}

.login-page .login-container {
  margin-top: 0;
  background: rgba(7, 20, 15, 0.78);
  border: 1px solid rgba(243, 212, 138, 0.28);
  box-shadow: none;
  color: #f7f1e3;
}

.login-page .login-container input {
  background: #10281c;
  color: #fff8ea;
  border: 1px solid rgba(243, 212, 138, 0.45);
}

.login-page .login-container input::placeholder {
  color: #b7c4bb;
}

.login-page .login-container button {
  background: #f3d48a;
  color: #241b08;
  font-weight: 700;
  border-radius: 999px;
}

.login-page .login-container button:hover {
  background: #ffe7ad;
}

.login-page .login-back a {
  color: #f3d48a;
}

.login-page .error,
.admin-page .error {
  color: #ffd0d0;
}

.admin-page .dashboard-header {
  align-items: flex-end;
  margin-bottom: 1.5rem;
}

.admin-page .status-card,
.admin-page .admin-controls {
  background: rgba(7, 20, 15, 0.78);
  border: 1px solid rgba(243, 212, 138, 0.28);
  box-shadow: none;
  color: #f7f1e3;
}

.admin-page .status-card h3,
.admin-page .admin-controls h2 {
  color: #f6e7bf;
}

.admin-page .saved-note {
  color: #f3d48a;
}

.admin-page .secondary-button,
.admin-page .logout-button {
  border-radius: 999px;
  font-weight: 700;
}

.admin-page .secondary-button {
  background: transparent;
  color: #f6e7bf;
  border: 1px solid rgba(246, 231, 191, 0.55);
}

.admin-page .secondary-button:hover {
  background: rgba(255, 255, 255, 0.08);
}

.admin-page .logout-button {
  background: #f3d48a;
  color: #241b08;
}

.admin-page .logout-button:hover {
  background: #ffe7ad;
}

.admin-page .secondary-button:focus-visible,
.admin-page .logout-button:focus-visible,
.admin-page button:focus-visible,
.login-page button:focus-visible,
.login-page .login-back a:focus-visible {
  outline: 3px solid #fff8ea;
  outline-offset: 3px;
}

.score-team {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
  font-weight: 700;
}

.score-avatar {
  width: 2.6rem;
  height: 2.6rem;
  border-radius: 50%;
  overflow: hidden;
  flex: none;
  background: #10281c;
}

.score-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.admin-page .score-row input {
  background: #10281c;
  color: #fff8ea;
  border: 1px solid rgba(243, 212, 138, 0.45);
  font-weight: 700;
  text-align: right;
  color-scheme: dark;
}

.admin-page .score-row input:focus {
  outline: 3px solid #f3d48a;
  outline-offset: 2px;
}

.admin-page button {
  background: #f3d48a;
  color: #241b08;
  font-weight: 700;
  border-radius: 999px;
}

.admin-page button:hover {
  background: #ffe7ad;
}

.score-box,
.reset-box {
  margin-bottom: 1rem;
}

.reset-copy {
  margin-bottom: 0.75rem;
}

.reset-dialog {
  margin: auto;
  width: min(24rem, calc(100% - 2rem));
  padding: 1.25rem;
  border: 1px solid rgba(243, 212, 138, 0.45);
  border-radius: 12px;
  background: #10281c;
  color: #f7f1e3;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
}

.reset-dialog::backdrop {
  background: rgba(4, 12, 8, 0.72);
}

.reset-dialog h2 {
  color: #f6e7bf;
  margin-bottom: 0.4rem;
  font-size: 1.35rem;
}

.reset-label {
  display: block;
  margin-top: 1rem;
  margin-bottom: 0.4rem;
  color: #d7c49a;
  font-size: 0.9rem;
}

.reset-dialog input[type="text"] {
  width: 100%;
  padding: 0.75rem;
  border-radius: 8px;
  border: 1px solid rgba(243, 212, 138, 0.45);
  background: #0c1c15;
  color: #fff8ea;
  font-size: 1rem;
}

.reset-dialog input[type="text"]:focus {
  outline: 3px solid #f3d48a;
  outline-offset: 2px;
}

.reset-actions {
  display: flex;
  gap: 0.6rem;
  margin-top: 1rem;
}

.reset-actions button {
  flex: 1;
  width: auto;
}

.admin-page button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.admin-page button:disabled:hover {
  background: #f3d48a;
}

@media (max-width: 640px) {
  .scoreboard-shell {
    width: calc(100% - 1.5rem);
    padding-top: 4.5rem;
  }

  .admin-shell,
  .login-page .scoreboard-shell {
    padding-top: 1.5rem;
  }

  .standing {
    grid-template-columns: 3.2rem minmax(0, 1fr);
    gap: 0.65rem;
  }

  .standing-rank {
    width: 3rem;
    height: 3rem;
    font-size: 1rem;
  }

  .admin-page .dashboard-header {
    align-items: stretch;
  }

  .admin-page .dashboard-title {
    text-align: center;
  }

  .admin-page h1 {
    text-align: center;
  }
}
