:root {
  color-scheme: light;
  --bg: #f6f6f4;
  --panel: #ffffff;
  --ink: #121212;
  --muted: #66645f;
  --line: #deded9;
  --soft: #efefeb;
  --brand: #e4482c;
  --brand-dark: #b92f1d;
  --green: #18824b;
  --red: #b93428;
  --amber: #9b6800;
  --shadow: 0 16px 42px rgba(18, 18, 18, 0.08);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
}

button,
input,
textarea {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button {
  color: inherit;
}

a {
  color: inherit;
  text-decoration: none;
}

.site-header,
main {
  width: min(1240px, calc(100% - 28px));
  margin: 0 auto;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 0;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 950;
}

.brand-mark {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border-radius: 8px;
  background: var(--ink);
  color: white;
  font-size: 0.8rem;
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 0.95rem;
}

.nav-actions a,
.ghost-button {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: inherit;
  cursor: pointer;
  padding: 10px 12px;
}

.nav-actions a:hover,
.ghost-button:hover {
  border-color: var(--ink);
  color: var(--ink);
}

.scoreboard-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(360px, 0.62fr);
  gap: 18px;
  align-items: stretch;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--brand);
  font-size: 0.74rem;
  font-weight: 950;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  overflow-wrap: anywhere;
}

h1 {
  margin: 0;
  font-size: clamp(2.6rem, 7vw, 5rem);
  line-height: 0.94;
  letter-spacing: 0;
}

h2 {
  margin: 0;
  font-size: clamp(1.65rem, 3vw, 2.6rem);
  line-height: 1;
  letter-spacing: 0;
}

h3 {
  margin: 0 0 8px;
  font-size: 1rem;
}

.scoreboard-hero p:not(.eyebrow),
.section-heading p:not(.eyebrow),
.admin-note,
#videoModalMeta,
#videoModalComment {
  margin: 10px 0 0;
  max-width: 650px;
  color: var(--muted);
  line-height: 1.5;
}

.stat-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.stat-strip > div {
  display: grid;
  align-content: center;
  min-height: 116px;
  border-radius: 8px;
  background: var(--ink);
  color: white;
  padding: 16px;
}

.stat-value,
.stat-label {
  display: block;
}

.stat-value {
  font-size: clamp(1.7rem, 4vw, 2.4rem);
  font-weight: 950;
  line-height: 1;
}

.stat-label {
  margin-top: 8px;
  color: rgba(255, 255, 255, 0.68);
  font-size: 0.76rem;
  font-weight: 900;
  text-transform: uppercase;
}

.section {
  padding: 22px 0 0;
}

.app-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(330px, 420px);
  gap: 18px;
  align-items: start;
}

.leaderboard-section,
.submit-section {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 18px;
}

.leaderboard-section {
  min-height: 560px;
}

.submit-section {
  position: sticky;
  top: 14px;
}

.section-heading {
  margin-bottom: 18px;
}

.section-heading.compact {
  margin-bottom: 14px;
}

.submit-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 13px;
}

label {
  display: grid;
  gap: 7px;
  color: #282826;
  font-size: 0.9rem;
  font-weight: 850;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  outline: 0;
  padding: 12px;
}

textarea {
  resize: vertical;
}

input:focus,
textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 4px rgba(228, 72, 44, 0.14);
}

.field-note {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 650;
  line-height: 1.35;
}

.full-width {
  grid-column: 1 / -1;
}

.check-row,
.toggle-row {
  display: flex;
  align-items: center;
  gap: 10px;
  line-height: 1.35;
}

.check-row input,
.toggle-row input {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
}

.primary-button,
.small-button,
.icon-button {
  min-height: 42px;
  border-radius: 8px;
  font-weight: 900;
  cursor: pointer;
}

.primary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  background: var(--brand);
  color: white;
  padding: 12px 18px;
}

.primary-button:hover {
  background: var(--brand-dark);
}

.primary-button:disabled {
  cursor: wait;
  opacity: 0.72;
}

.upload-spinner {
  width: 18px;
  height: 18px;
  margin-right: 8px;
  border: 2px solid rgba(255, 255, 255, 0.45);
  border-top-color: white;
  border-radius: 999px;
  animation: spin 800ms linear infinite;
}

.upload-status {
  margin: -2px 0 0;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 0.88rem;
  font-weight: 850;
  line-height: 1.35;
}

.upload-status.info {
  background: rgba(18, 18, 18, 0.07);
  color: var(--muted);
}

.upload-status.error {
  background: rgba(185, 52, 40, 0.12);
  color: var(--red);
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.segmented {
  display: flex;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
}

.segmented button {
  min-height: 42px;
  border: 0;
  border-right: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  padding: 10px 14px;
  font-weight: 900;
}

.segmented button:last-child {
  border-right: 0;
}

.segmented button.active {
  background: var(--ink);
  color: white;
}

.search-field {
  display: flex;
  min-width: min(260px, 100%);
  flex: 1;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 0 12px;
}

.search-field span {
  color: var(--muted);
  font-size: 0.74rem;
  text-transform: uppercase;
}

.search-field input {
  border: 0;
  background: transparent;
  box-shadow: none;
  padding-inline: 0;
}

.leaderboard-list,
.admin-list,
.rules-grid,
.privacy-grid {
  display: grid;
  gap: 10px;
}

.party-share {
  display: grid;
  gap: 14px;
  align-items: center;
  margin-bottom: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fafafa;
}

.party-share[hidden] {
  display: none;
}

.party-share .eyebrow {
  margin-bottom: 4px;
}

.party-share input {
  margin: 10px 0;
  background: var(--panel);
}

.leaderboard-row {
  display: grid;
  width: 100%;
  grid-template-columns: 48px minmax(0, 1fr) auto auto auto;
  gap: 12px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 13px;
  text-align: left;
  cursor: pointer;
}

.leaderboard-row:hover,
.leaderboard-row:focus-visible {
  border-color: var(--brand);
  box-shadow: 0 0 0 4px rgba(228, 72, 44, 0.12);
  outline: 0;
}

.rank {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 8px;
  background: var(--soft);
  font-weight: 950;
}

.player-main {
  min-width: 0;
}

.player-main strong {
  display: block;
  font-size: 1.03rem;
}

.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 5px;
  color: var(--muted);
  font-size: 0.84rem;
}

.time-pill {
  border-radius: 8px;
  background: var(--ink);
  color: white;
  padding: 9px 12px;
  font-weight: 950;
}

.status-pill {
  border-radius: 999px;
  padding: 7px 10px;
  font-size: 0.72rem;
  font-weight: 950;
  text-transform: uppercase;
  white-space: nowrap;
}

.status-pill.verified {
  background: rgba(24, 130, 75, 0.12);
  color: var(--green);
}

.status-pill.pending {
  background: rgba(155, 104, 0, 0.12);
  color: var(--amber);
}

.status-pill.hidden {
  background: rgba(185, 52, 40, 0.12);
  color: var(--red);
}

.watch-cue {
  color: var(--brand);
  font-size: 0.82rem;
  font-weight: 950;
  white-space: nowrap;
}

.video-actions,
.admin-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.admin-login {
  display: grid;
  gap: 12px;
  max-width: 420px;
}

.admin-login[hidden],
.admin-workspace[hidden] {
  display: none;
}

.admin-login-status {
  display: none;
  margin: 0;
  border-radius: 8px;
  background: rgba(155, 104, 0, 0.1);
  color: var(--amber);
  padding: 10px 12px;
  font-weight: 800;
  line-height: 1.4;
}

.admin-login-status.show {
  display: block;
}

.admin-login-status.locked {
  background: rgba(185, 52, 40, 0.12);
  color: var(--red);
}

.admin-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.small-button {
  border: 1px solid var(--line);
  background: white;
  padding: 9px 11px;
}

.small-button:hover {
  border-color: var(--ink);
}

.small-button.danger {
  color: var(--red);
}

.privacy-page {
  padding-bottom: 56px;
}

.rules-grid,
.privacy-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.rules-grid article,
.privacy-grid article,
.admin-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 16px;
}

.rules-grid p,
.privacy-grid p {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.admin-dialog,
.video-dialog {
  width: min(940px, calc(100% - 28px));
  max-height: min(780px, calc(100% - 28px));
  border: 0;
  border-radius: 8px;
  padding: 0;
  background: transparent;
}

.video-dialog {
  width: min(820px, calc(100% - 28px));
}

.admin-dialog::backdrop,
.video-dialog::backdrop {
  background: rgba(18, 18, 18, 0.62);
}

.admin-panel,
.video-panel {
  display: grid;
  gap: 14px;
  max-height: inherit;
  overflow: auto;
  border-radius: 8px;
  background: var(--panel);
  padding: 18px;
}

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

.icon-button {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border: 1px solid var(--line);
  background: white;
}

.video-panel video {
  display: block;
  width: 100%;
  height: auto;
  max-height: min(62vh, 560px);
  border-radius: 8px;
  background: #111;
}

.admin-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
}

.empty-state {
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: #fafafa;
  color: var(--muted);
  padding: 24px;
  text-align: center;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 20;
  max-width: min(360px, calc(100% - 36px));
  transform: translateY(18px);
  border-radius: 8px;
  background: var(--ink);
  color: white;
  opacity: 0;
  padding: 12px 14px;
  pointer-events: none;
  transition:
    opacity 160ms ease,
    transform 160ms ease;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

.site-version {
  position: fixed;
  right: 8px;
  bottom: 6px;
  z-index: 5;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.78);
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 800;
  padding: 3px 7px;
  pointer-events: none;
}

@media (max-width: 980px) {
  .scoreboard-hero,
  .app-grid {
    grid-template-columns: 1fr;
  }

  .submit-section {
    position: static;
  }

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

@media (max-width: 680px) {
  .site-header,
  main {
    width: min(100% - 20px, 1240px);
  }

  .topbar {
    align-items: flex-start;
  }

  .nav-actions {
    flex-wrap: wrap;
    justify-content: flex-end;
  }

  .nav-actions a {
    display: none;
  }

  .scoreboard-hero {
    padding: 16px;
  }

  h1 {
    font-size: 2.7rem;
  }

  .stat-strip,
  .submit-form,
  .leaderboard-row,
  .admin-item,
  .rules-grid,
  .privacy-grid,
  .party-share {
    grid-template-columns: 1fr;
  }

  .stat-strip > div {
    min-height: 86px;
  }

  .toolbar {
    align-items: stretch;
  }

  .segmented,
  .search-field,
  .toggle-row {
    width: 100%;
  }

  .segmented button {
    flex: 1;
    padding-inline: 8px;
  }

  .video-dialog {
    width: 100vw;
    max-width: 100vw;
    height: 100dvh;
    max-height: 100dvh;
    margin: 0;
    border-radius: 0;
  }

  .video-panel {
    min-height: 100dvh;
    max-height: 100dvh;
    gap: 10px;
    overflow-y: auto;
    border-radius: 0;
    padding: 12px;
  }

  .video-panel .dialog-heading {
    position: sticky;
    top: 0;
    z-index: 1;
    align-items: center;
    border-bottom: 1px solid var(--line);
    background: var(--panel);
    padding-bottom: 10px;
  }

  .video-panel h2 {
    font-size: 1.35rem;
    line-height: 1.08;
  }

  #videoModalMeta,
  #videoModalComment {
    margin-top: 6px;
    font-size: 0.92rem;
    line-height: 1.35;
  }

  .video-panel video {
    max-height: 58dvh;
    object-fit: contain;
  }

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

}
