:root {
  --green-950: #243426;
  --green-900: #30472f;
  --green-800: #39543a;
  --green-700: #5d785f;
  --sage: #8ba38d;
  --sage-soft: #edf3ee;
  --mint: #dfe9e0;
  --gold: #c9a44f;
  --ink: #15231d;
  --muted: #65756e;
  --line: #dce5df;
  --paper: #f7faf7;
  --white: #ffffff;
  --danger: #b43b31;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--paper);
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
}

.sidebar {
  min-height: 100vh;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 28px;
  color: var(--white);
  background: linear-gradient(180deg, var(--green-950), var(--green-800));
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand img {
  width: 48px;
  height: 48px;
  object-fit: contain;
}

.brand strong,
.brand span,
.judge-card strong,
.judge-card small {
  display: block;
}

.brand span,
.judge-card span,
.judge-card small,
.eyebrow {
  color: rgba(255, 255, 255, .72);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0;
}

.nav {
  display: grid;
  gap: 8px;
}

.nav-item {
  min-height: 44px;
  border: 1px solid rgba(255, 255, 255, .13);
  border-radius: 8px;
  padding: 0 14px;
  color: var(--white);
  background: rgba(255, 255, 255, .05);
  text-align: left;
  text-decoration: none;
  font-weight: 800;
  font: inherit;
  cursor: pointer;
}

.nav-link {
  display: flex;
  align-items: center;
}

.nav-item.is-active {
  color: var(--green-900);
  background: var(--mint);
}

.judge-card {
  margin-top: auto;
  border: 1px solid rgba(255, 255, 255, .18);
  border-radius: 8px;
  padding: 14px;
  background: rgba(255, 255, 255, .07);
}

.judge-card strong,
.judge-card small {
  margin-top: 6px;
}

.app-shell {
  min-width: 0;
  padding: 28px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}

.topbar .eyebrow,
.panel .eyebrow {
  color: var(--green-700);
  margin: 0 0 4px;
  font-weight: 900;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 32px;
}

h2 {
  font-size: 20px;
}

.status-pill,
.sync-note {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 14px;
  color: var(--green-800);
  background: var(--white);
  font-weight: 800;
  white-space: nowrap;
}

.status-pill span {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #23b26d;
}

.sync-note {
  min-height: 30px;
  color: #755615;
  background: rgba(201, 164, 79, .16);
  border: 0;
  font-size: 12px;
  text-transform: uppercase;
}

.disconnect-action {
  width: 100%;
  min-height: 36px;
  margin-top: 12px;
  border: 1px solid rgba(255, 255, 255, .22);
  border-radius: 8px;
  color: var(--white);
  background: rgba(255, 255, 255, .08);
  font-weight: 850;
  cursor: pointer;
}

.view {
  display: none;
}

.view.is-active {
  display: block;
}

.hero-live {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  padding: 24px;
  margin-bottom: 18px;
  border-radius: 8px;
  color: var(--white);
  background: linear-gradient(135deg, var(--green-950), var(--green-700));
  box-shadow: 0 18px 45px rgba(15, 61, 46, .16);
}

.hero-live h2 {
  font-size: 30px;
  margin-bottom: 8px;
}

.hero-live p:not(.eyebrow) {
  margin: 0;
  max-width: 720px;
  color: rgba(255, 255, 255, .78);
  line-height: 1.5;
}

.live-total {
  min-width: 170px;
  border: 1px solid rgba(255, 255, 255, .18);
  border-radius: 8px;
  padding: 16px;
  display: grid;
  place-content: center;
  text-align: center;
  background: rgba(255, 255, 255, .08);
}

.live-total strong {
  font-size: 42px;
}

.live-total span {
  color: rgba(255, 255, 255, .78);
}

.panel {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 20px;
  box-shadow: 0 18px 45px rgba(15, 61, 46, .08);
}

.judge-login {
  display: grid;
  gap: 12px;
  max-width: 620px;
}

.judge-login label {
  color: var(--green-800);
  font-size: 13px;
  font-weight: 950;
  text-transform: uppercase;
}

.judge-login > div {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
}

.judge-login input {
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 14px;
  font: inherit;
  font-weight: 800;
}

.settings-panel {
  margin-bottom: 18px;
}

.competition-settings {
  display: grid;
  grid-template-columns: repeat(3, minmax(180px, 1fr));
  gap: 12px;
}

.competition-settings label {
  display: grid;
  gap: 6px;
}

.competition-settings span {
  color: var(--green-800);
  font-size: 12px;
  font-weight: 950;
  text-transform: uppercase;
}

.formula-note {
  margin: 14px 0 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px;
  color: var(--green-800);
  background: var(--sage-soft);
  font-size: 15px;
  font-weight: 900;
  line-height: 1.45;
}

.prepared-list-info {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  margin: 0 0 14px;
  border: 1px solid rgba(139, 163, 141, .46);
  border-radius: 999px;
  padding: 0 14px;
  color: var(--green-800);
  background: var(--sage-soft);
  font-size: 13px;
  font-weight: 950;
}

.prepare-list-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  margin: 0 0 14px;
  border: 1px solid rgba(139, 163, 141, .56);
  border-radius: 8px;
  padding: 0 16px;
  color: var(--green-800);
  background: var(--sage-soft);
  text-decoration: none;
  font-weight: 950;
}

.prepare-list-link:hover {
  border-color: var(--sage);
  background: var(--white);
}

.panel-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 18px;
}

select,
input {
  width: 100%;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--white);
  color: var(--ink);
  padding: 0 12px;
  font: inherit;
  font-weight: 700;
}

input:focus,
select:focus {
  outline: 3px solid rgba(19, 86, 64, .14);
  border-color: var(--green-700);
}

button {
  font: inherit;
}

.primary-action,
.validated-action,
.secondary-action {
  min-height: 46px;
  border: 0;
  border-radius: 8px;
  padding: 0 16px;
  font-weight: 950;
  cursor: pointer;
}

.primary-action {
  color: var(--white);
  border: 1px solid rgba(139, 163, 141, .52);
  background: linear-gradient(180deg, var(--green-800), var(--green-950));
  box-shadow: 0 6px 16px rgba(36, 52, 38, .16);
}

.validated-action {
  color: var(--green-800);
  background: rgba(19, 86, 64, .14);
  cursor: default;
}

.primary-action:disabled,
.validated-action:disabled {
  opacity: .42;
  cursor: not-allowed;
}

.validated-action:disabled {
  opacity: 1;
  cursor: default;
}

.primary-action.compact {
  width: 150px;
}

.secondary-action {
  color: var(--green-800);
  background: var(--sage-soft);
}

.danger-action {
  color: var(--danger);
  background: rgba(180, 59, 49, .1);
}

.add-player {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
}

.record-score-action {
  width: 100%;
  min-height: 54px;
  margin-top: 14px;
  font-size: 17px;
}

.group-list,
.run-board,
.send-summary {
  display: grid;
  gap: 12px;
}

.group-card,
.judge-run-card,
.summary-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fbfdfb;
}

.group-card {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
}

.group-card > div > strong,
.group-card > div > span {
  display: block;
}

.group-card span,
.summary-card span {
  color: var(--muted);
  font-size: 13px;
  margin-top: 3px;
}

.group-card strong,
.player-cell strong,
.summary-card strong {
  display: flex;
  align-items: center;
  gap: 8px;
}

.order-badge {
  width: 30px;
  height: 30px;
  display: inline-grid !important;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 999px;
  color: var(--white) !important;
  background: var(--green-800);
  font-size: 13px !important;
  font-weight: 950;
  margin: 0 !important;
}

.group-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.group-actions select {
  min-height: 42px;
  min-width: 150px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  color: var(--ink);
  background: var(--white);
  font: inherit;
  font-weight: 800;
}

.icon-action {
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--green-800);
  background: var(--white);
  font-size: 20px;
  font-weight: 950;
  cursor: pointer;
}

.icon-action:disabled {
  opacity: .35;
  cursor: not-allowed;
}

.filters {
  display: flex;
  gap: 10px;
  min-width: min(520px, 60%);
}

.judge-run-card {
  display: grid;
  grid-template-columns: minmax(190px, .8fr) repeat(3, minmax(160px, 1fr)) minmax(170px, .7fr);
  gap: 12px;
  align-items: stretch;
}

.player-cell > span {
  display: block;
}

.player-cell span {
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
}

.run-cell {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: var(--white);
}

.run-cell header {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
  font-weight: 900;
}

.run-inputs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.run-cell button {
  width: 100%;
  margin-top: 8px;
}

.run-cell.is-valid {
  border-color: rgba(19, 86, 64, .32);
  background: rgba(19, 86, 64, .06);
}

.run-cell.has-error {
  border-color: rgba(180, 59, 49, .55);
  background: rgba(180, 59, 49, .05);
}

.run-feedback {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.run-cell.has-error .run-feedback {
  color: var(--danger);
}

.reset-live-panel {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.reset-live-panel span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.run-pill,
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 46px;
  height: 26px;
  border-radius: 999px;
  padding: 0 10px;
  font-size: 12px;
  font-weight: 950;
}

.run-pill.pending {
  color: #755615;
  background: rgba(201, 164, 79, .15);
}

.run-pill.ready,
.badge.ready {
  color: var(--green-800);
  background: rgba(19, 86, 64, .12);
}

.badge.waiting {
  color: var(--muted);
  background: #e8eee9;
}

.score-cell {
  display: grid;
  gap: 8px;
  align-content: center;
}

.score-cell b {
  color: var(--green-800);
  font-size: 30px;
}

.score-cell button {
  width: 100%;
}

.summary-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 120px 160px;
  gap: 12px;
  align-items: center;
}

.summary-card b {
  color: var(--green-800);
  font-size: 24px;
  text-align: right;
}

.hint {
  color: var(--muted);
  margin: 14px 0 0;
  line-height: 1.45;
}

@media (max-width: 1120px) {
  .judge-run-card {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 900px) {
  body {
    grid-template-columns: 1fr;
  }

  .sidebar {
    min-height: auto;
    padding: 14px;
    position: sticky;
    top: 0;
    z-index: 10;
  }

  .brand {
    display: none;
  }

  .judge-card {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 6px 10px;
    margin-top: 10px;
    padding: 10px 12px;
  }

  .judge-card span,
  .judge-card small {
    display: none;
  }

  .judge-card strong {
    margin-top: 0;
    font-size: 13px;
    line-height: 1.2;
  }

  .judge-card .disconnect-action {
    width: auto;
    min-height: 32px;
    margin-top: 0;
    padding: 0 12px;
    font-size: 12px;
    white-space: nowrap;
  }

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

  .nav-item {
    text-align: center;
    padding: 0 8px;
    font-size: 13px;
  }

  .app-shell {
    padding: 18px;
  }

  .topbar,
  .hero-live,
  .panel-head,
  .add-player,
  .filters,
  .group-card,
  .summary-card {
    flex-direction: column;
    grid-template-columns: 1fr;
  }

  .topbar,
  .hero-live,
  .panel-head,
  .group-card {
    align-items: stretch;
  }

  .filters {
    min-width: 0;
  }

  .primary-action.compact {
    width: 100%;
  }

  .judge-login > div {
    grid-template-columns: 1fr;
  }

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

  .group-actions select {
    grid-column: 1 / -1;
    width: 100%;
  }

  .group-actions {
    display: grid;
    grid-template-columns: 42px 42px minmax(0, 1fr);
    justify-content: stretch;
    width: 100%;
  }

  .group-actions .icon-action {
    width: 42px;
    min-width: 42px;
  }

  .group-actions .secondary-action {
    justify-self: end;
    min-height: 42px;
    width: auto;
    min-width: 96px;
  }

  .reset-live-panel {
    align-items: stretch;
    flex-direction: column;
  }
}
