:root {
  color-scheme: light;
  --ink: #18212f;
  --muted: #657084;
  --line: #d8dee8;
  --surface: #ffffff;
  --soft: #f4f7fa;
  --blue: #246bfe;
  --blue-dark: #164dba;
  --green: #0f7b53;
  --amber: #9a5a00;
  --red: #ba2d2d;
  --purple: #6a3fb5;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--soft);
}

a {
  color: inherit;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: 64px;
  padding: 0 24px;
  background: rgba(255, 255, 255, 0.96);
  border-bottom: 1px solid var(--line);
}

.brand {
  font-weight: 800;
  text-decoration: none;
}

.brand-group {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.role-status {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.role-pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 10px;
  border-radius: 999px;
  background: #eef1f5;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.role-pill.competitor {
  background: #e8f1ff;
  color: var(--blue-dark);
}

.role-pill.judge {
  background: #efe8fb;
  color: var(--purple);
}

.role-pill.admin {
  background: #fbe6e6;
  color: var(--red);
}

nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  justify-content: flex-end;
}

.nav-toggle-input {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: 0;
  padding: 0;
  border: 0;
  opacity: 0;
  pointer-events: none;
}

.nav-toggle-btn {
  display: none;
}

nav a {
  padding: 8px 10px;
  color: var(--muted);
  text-decoration: none;
  border-radius: 6px;
}

nav a:hover {
  background: var(--soft);
  color: var(--ink);
}

.nav-form {
  display: inline-flex;
  margin: 0;
}

.nav-logout {
  min-height: 34px;
  padding: 0 10px;
  border-color: #f2c8c8;
  background: #fff;
  color: var(--red);
  font-size: 14px;
}

.nav-logout:hover {
  border-color: var(--red);
  background: #fbe6e6;
  color: var(--red);
}

.nav-section {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px;
}

.nav-divider {
  width: 1px;
  height: 20px;
  margin: 0 4px;
  background: var(--line);
}

.nav-label {
  padding: 8px 4px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.shell {
  width: min(1220px, calc(100vw - 32px));
  margin: 32px auto;
}

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 22px;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 6px;
  font-size: 34px;
  line-height: 1.1;
}

h2 {
  font-size: 20px;
}

p {
  color: var(--muted);
  line-height: 1.5;
}

.head-actions,
.form-actions,
.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.button,
button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid var(--blue);
  border-radius: 6px;
  background: var(--blue);
  color: #fff;
  font: inherit;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}

.button:hover,
button:hover {
  background: var(--blue-dark);
}

.button.secondary,
button.secondary {
  background: #fff;
  color: var(--ink);
  border-color: var(--line);
}

.button.danger,
button.danger {
  background: var(--red);
  border-color: var(--red);
}

.button.small,
button.small {
  min-height: 32px;
  padding: 0 10px;
  font-size: 14px;
}

.icon-button {
  min-width: 54px;
  min-height: 30px;
  padding: 0 8px;
  background: #fff;
  color: var(--ink);
  border-color: var(--line);
  font-size: 13px;
}

button:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.panel,
.challenge-card,
.home-card,
.team-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 1px 2px rgba(24, 33, 47, 0.04);
}

.panel {
  margin-bottom: 20px;
  padding: 18px;
}

.compact-panel {
  padding-bottom: 8px;
}

.auth-panel {
  max-width: 520px;
}

.notice {
  margin-bottom: 18px;
  padding: 12px 14px;
  background: #e8f1ff;
  border: 1px solid #b9d1ff;
  border-radius: 6px;
  font-weight: 700;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 860px;
}

th,
td {
  padding: 12px;
  border-top: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 13px;
  text-transform: uppercase;
}

td p {
  margin: 4px 0 0;
  font-size: 14px;
}

.points {
  font-variant-numeric: tabular-nums;
  font-weight: 800;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  background: #edf2f7;
  color: #304055;
  font-size: 12px;
  font-weight: 800;
}

.badge.good {
  background: #e4f6ee;
  color: var(--green);
}

.badge.warn {
  background: #fff1d6;
  color: var(--amber);
}

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

.inline {
  display: inline-flex;
  margin: 0;
}

.inline-edit {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) auto;
  gap: 8px;
  margin: 0;
}

.reorder {
  white-space: nowrap;
}

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

label,
fieldset {
  display: grid;
  gap: 7px;
  font-weight: 800;
}

input,
select,
textarea {
  width: 100%;
  padding: 10px 11px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-weight: 500;
}

textarea {
  resize: vertical;
}

.wide {
  grid-column: 1 / -1;
}

.checks {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
}

.checks label,
.confirm {
  display: flex;
  align-items: center;
  gap: 10px;
}

.checks input,
.confirm input {
  width: auto;
}

.home-grid,
.team-grid,
.card-grid {
  display: grid;
  gap: 14px;
}

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

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

.home-card,
.team-card {
  display: grid;
  gap: 8px;
  min-height: 118px;
  padding: 18px;
  text-decoration: none;
}

.home-card strong,
.team-card strong {
  font-size: 18px;
}

.home-card span,
.team-card span {
  color: var(--muted);
}

.challenge-card {
  padding: 18px;
}

.card-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.card-head h2 {
  margin: 8px 0 0;
}

.hint,
.safety {
  padding: 10px;
  border-radius: 6px;
  background: var(--soft);
}

.safety {
  border-left: 4px solid var(--amber);
}

.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 14px 0;
  color: var(--muted);
  font-size: 14px;
}

.submit-form,
.approval-form {
  display: grid;
  gap: 10px;
}

.approval-form {
  grid-template-columns: 110px minmax(160px, 1fr) auto;
  align-items: end;
}

.media-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 8px;
  min-width: 180px;
}

.media-item {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-decoration: none;
}

.media-item img,
.media-item video {
  width: 100%;
  max-height: 140px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--soft);
  object-fit: cover;
}

.media-item span,
.media-item a {
  overflow-wrap: anywhere;
}

.empty {
  padding: 18px;
  background: #fff;
  border: 1px dashed var(--line);
  border-radius: 8px;
}

.score-chart-wrap {
  display: grid;
  gap: 14px;
}

.score-chart {
  width: 100%;
  height: auto;
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.chart-grid {
  stroke: var(--line);
  stroke-width: 1;
}

.chart-axis-label {
  fill: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.chart-line {
  fill: none;
  stroke-width: 2.5;
}

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 18px;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
}

.legend-swatch {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.dashboard-hero {
  margin-bottom: 20px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 12px;
}

.dashboard-hero img {
  display: block;
  width: 100%;
  max-height: 360px;
  object-fit: cover;
}

.status-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 20px;
}

.cta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 28px;
}

.button.large {
  min-height: 52px;
  padding: 0 22px;
  border-radius: 8px;
  font-size: 16px;
}

.role-panel {
  border-left: 4px solid var(--line);
}

.role-panel h2 {
  display: flex;
  align-items: center;
  gap: 8px;
}

.competitor-panel {
  border-left-color: var(--blue);
}

.judge-panel {
  border-left-color: var(--purple);
}

.admin-panel {
  border-left-color: var(--red);
}

@media (max-width: 860px) {
  .page-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    row-gap: 10px;
    padding: 10px 16px;
  }

  .brand-group {
    grid-column: 1;
    grid-row: 1;
  }

  .nav-toggle-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    grid-column: 2;
    grid-row: 1;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #fff;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
  }

  nav {
    display: none;
    grid-column: 1 / -1;
    grid-row: 2;
    width: 100%;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    gap: 2px;
    padding-bottom: 10px;
  }

  .nav-toggle-input:checked ~ nav {
    display: flex;
  }

  .nav-section {
    flex-direction: column;
    align-items: stretch;
    width: 100%;
  }

  .nav-divider {
    display: none;
  }

  .nav-label {
    margin-top: 6px;
  }

  nav a {
    min-height: 44px;
    padding: 10px 12px;
  }

  .nav-form {
    width: 100%;
  }

  .nav-logout {
    width: 100%;
  }

  .button,
  button {
    min-height: 44px;
  }

  .shell {
    width: min(100vw - 20px, 1220px);
    margin: 20px auto;
  }

  .form-grid,
  .home-grid,
  .team-grid,
  .card-grid {
    grid-template-columns: 1fr;
  }

  .approval-form {
    grid-template-columns: 1fr;
  }

  .inline-edit {
    grid-template-columns: 1fr;
  }
}
