:root {
  --bg: #f2eee5;
  --panel: rgba(255, 252, 246, 0.88);
  --panel-strong: #fff9f0;
  --ink: #1b2230;
  --muted: #596270;
  --line: rgba(27, 34, 48, 0.12);
  --accent: #c05a2a;
  --accent-dark: #8b3d1b;
  --forest: #1d5b49;
  --warn: #a03333;
  --shadow: 0 20px 60px rgba(72, 47, 28, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: "Space Grotesk", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(192, 90, 42, 0.18), transparent 34%),
    radial-gradient(circle at top right, rgba(29, 91, 73, 0.18), transparent 32%),
    linear-gradient(180deg, #f6f1e6 0%, #efe8dd 100%);
}

a {
  color: var(--accent-dark);
  text-decoration: none;
}

pre,
code,
textarea,
input,
select {
  font-family: "SFMono-Regular", "Consolas", monospace;
}

.page-shell {
  width: min(1240px, calc(100% - 32px));
  margin: 0 auto;
  padding: 20px 0 48px;
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 14px 18px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: rgba(255, 248, 238, 0.8);
  backdrop-filter: blur(10px);
  box-shadow: var(--shadow);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 14px;
  color: var(--ink);
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--accent), #efb381);
  color: white;
  font-weight: 700;
  letter-spacing: 0.06em;
}

.brand strong,
.hero h1,
.section-head h2,
.panel-card h3 {
  font-family: "Literata", serif;
}

.brand small {
  display: block;
  color: var(--muted);
}

.main-nav,
.nav-actions,
.hero-meta,
.card-meta,
.action-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.content {
  display: grid;
  gap: 28px;
  margin-top: 28px;
}

.hero,
.panel-card,
.table-panel {
  border: 1px solid var(--line);
  border-radius: 28px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.hero {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 24px;
  padding: 32px;
}

.hero-copy h1 {
  margin: 0 0 10px;
  font-size: clamp(2.4rem, 5vw, 4.6rem);
  line-height: 0.95;
}

.eyebrow {
  margin: 0 0 10px;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--accent-dark);
  font-size: 0.82rem;
}

.lede {
  font-size: 1.14rem;
  color: var(--forest);
}

.hero-panel,
.metric-grid,
.card-grid,
.sample-grid,
.admin-layout,
.problem-layout {
  display: grid;
  gap: 18px;
}

.hero-panel,
.metric-grid {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.metric-card {
  display: grid;
  gap: 8px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--panel-strong);
}

.metric-card strong {
  font-size: 2rem;
}

.metric-card.accent {
  background: linear-gradient(135deg, rgba(29, 91, 73, 0.12), rgba(192, 90, 42, 0.12));
}

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 20px;
}

.section-head.compact {
  align-items: center;
}

.section-head h2 {
  margin: 0;
  font-size: 2rem;
}

.card-grid {
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

.panel-card {
  padding: 24px;
}

.scoreboard-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: rgba(255, 249, 240, 0.82);
  box-shadow: var(--shadow);
}

.scoreboard-tab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 12px 18px;
  border: 1px solid transparent;
  border-radius: 16px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.16s ease, color 0.16s ease, border-color 0.16s ease, transform 0.16s ease;
}

.scoreboard-tab:hover {
  background: rgba(255, 255, 255, 0.58);
  color: var(--ink);
}

.scoreboard-tab.is-active {
  border-color: rgba(192, 90, 42, 0.2);
  background: linear-gradient(135deg, rgba(192, 90, 42, 0.14), rgba(29, 91, 73, 0.08));
  color: var(--ink);
}

.scoreboard-panel[hidden] {
  display: none;
}

.inline-form {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

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

.problem-badge {
  display: inline-flex;
  width: 44px;
  height: 44px;
  align-items: center;
  justify-content: center;
  border-radius: 14px;
  background: rgba(29, 91, 73, 0.12);
  color: var(--forest);
  font-weight: 700;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid rgba(27, 34, 48, 0.08);
  background: rgba(255, 255, 255, 0.65);
  color: var(--muted);
  font-size: 0.92rem;
}

.pill.warn {
  color: var(--warn);
}

.link-pill {
  color: var(--accent-dark);
}

.button,
.text-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  border-radius: 14px;
  cursor: pointer;
  transition: transform 0.16s ease, opacity 0.16s ease;
}

.button {
  padding: 12px 16px;
  background: linear-gradient(135deg, var(--accent), #de8b59);
  color: white;
  font-weight: 600;
}

.button.ghost {
  background: rgba(255, 255, 255, 0.5);
  color: var(--ink);
  border: 1px solid var(--line);
}

.rejudge-widget {
  min-width: min(320px, 100%);
}

.rejudge-progress {
  display: grid;
  gap: 8px;
  min-width: 320px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.6);
}

.rejudge-progress__topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.rejudge-progress__bar {
  width: 100%;
  height: 10px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(27, 34, 48, 0.08);
}

.rejudge-progress__fill {
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(135deg, var(--accent), #de8b59);
  transition: width 0.25s ease;
}

.rejudge-progress__fill.indeterminate {
  position: relative;
  overflow: hidden;
}

.rejudge-progress__fill.indeterminate::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.45), transparent);
  animation: rejudge-shimmer 1.1s linear infinite;
}

.queue-inline-progress {
  min-width: 0;
  margin-top: 6px;
  padding: 8px 10px;
}

@keyframes rejudge-shimmer {
  from {
    transform: translateX(-100%);
  }
  to {
    transform: translateX(160%);
  }
}

.text-button {
  padding: 0;
  background: transparent;
  color: var(--accent-dark);
  font: inherit;
}

.text-button.danger {
  color: var(--warn);
}

.button:hover,
.text-button:hover {
  transform: translateY(-1px);
  opacity: 0.92;
}

.flash-stack {
  display: grid;
  gap: 12px;
}

.flash {
  padding: 14px 16px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.75);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.flash.success {
  border-color: rgba(29, 91, 73, 0.18);
  color: var(--forest);
}

.flash.error {
  border-color: rgba(160, 51, 51, 0.18);
  color: var(--warn);
}

.form-shell.narrow {
  max-width: 640px;
}

.form-grid {
  display: grid;
  gap: 16px;
}

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

.form-grid label {
  display: grid;
  gap: 8px;
}

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

.form-grid .check-row {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

input,
textarea,
select {
  width: 100%;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid rgba(27, 34, 48, 0.14);
  background: rgba(255, 255, 255, 0.9);
  font-size: 0.96rem;
  color: var(--ink);
}

textarea {
  resize: vertical;
}

small,
.muted {
  color: var(--muted);
}

.formatted {
  color: var(--ink);
  line-height: 1.65;
}

pre {
  overflow: auto;
  padding: 16px;
  border-radius: 18px;
  background: #151924;
  color: #f7f1e6;
  font-size: 0.92rem;
  line-height: 1.45;
}

.sample-grid,
.detail-grid {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.problem-layout,
.admin-layout {
  grid-template-columns: minmax(0, 1.4fr) minmax(320px, 1fr);
}

.mini-list {
  display: grid;
  gap: 12px;
}

.crossword-inline {
  display: grid;
  gap: 10px;
  margin: 12px 0;
}

.crossword-grid {
  display: inline-flex;
  flex-direction: column;
  gap: 2px;
  width: fit-content;
  padding: 4px;
  border-radius: 16px;
  background: rgba(27, 34, 48, 0.08);
}

.crossword-row {
  display: flex;
  gap: 2px;
}

.crossword-cell {
  width: 2rem;
  height: 2rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  border: 1px solid rgba(27, 34, 48, 0.1);
  background: rgba(255, 255, 255, 0.94);
  color: var(--ink);
  font-size: 1rem;
  font-weight: 700;
  text-transform: uppercase;
}

.crossword-cell.empty {
  background: rgba(27, 34, 48, 0.12);
  color: transparent;
}

.crossword-cell.error {
  border: 2px solid var(--warn);
  box-shadow: 0 0 0 3px rgba(160, 51, 51, 0.18);
}

.wifi-raid-inline {
  display: grid;
  gap: 10px;
  margin: 12px 0;
}

.wifi-raid-map {
  width: 100%;
  max-width: 560px;
  height: auto;
  display: block;
  border-radius: 18px;
  border: 1px solid rgba(27, 34, 48, 0.1);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(243, 247, 255, 0.92)),
    linear-gradient(90deg, rgba(27, 34, 48, 0.03) 1px, transparent 1px),
    linear-gradient(rgba(27, 34, 48, 0.03) 1px, transparent 1px);
  background-size: auto, 24px 24px, 24px 24px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
}

.wifi-raid-grid-line {
  stroke: rgba(27, 34, 48, 0.1);
  stroke-width: 1;
}

.wifi-raid-grid-label {
  fill: rgba(27, 34, 48, 0.58);
  font-size: 10px;
  font-weight: 600;
  font-family: "Space Grotesk", sans-serif;
}

.wifi-raid-coverage {
  fill: var(--provider-color);
  fill-opacity: 0.14;
  stroke: var(--provider-color);
  stroke-width: 2;
}

.wifi-raid-router {
  fill: var(--provider-color);
  stroke: rgba(255, 255, 255, 0.95);
  stroke-width: 2.2;
}

.wifi-raid-route {
  fill: none;
  stroke: #dc2626;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.wifi-raid-check-link {
  fill: none;
  stroke: #2563eb;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0.82;
}

.wifi-raid-stop {
  fill: #dc2626;
  stroke: rgba(255, 245, 245, 0.98);
  stroke-width: 1.2;
}

.wifi-raid-stop.error {
  fill: #991b1b;
  stroke: #fee2e2;
  stroke-width: 2.4;
}

.wifi-raid-stop-label,
.wifi-raid-provider-label {
  fill: var(--ink);
  font-size: 12px;
  font-weight: 700;
  font-family: "Space Grotesk", sans-serif;
}

.wifi-raid-stop-label {
  fill: white;
}

.wifi-raid-provider-label {
  fill: #1d4ed8;
}

.wifi-raid-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin: 0 0 10px;
  font-size: 0.94rem;
  color: var(--muted);
}

.wifi-raid-legend span {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.wifi-raid-legend__swatch {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 999px;
}

.wifi-raid-legend__swatch.provider {
  background: #2563eb;
  border: 2px solid rgba(255, 255, 255, 0.95);
  box-shadow: 0 0 0 1px #2563eb;
}

.wifi-raid-legend__swatch.coverage {
  background: rgba(37, 99, 235, 0.18);
  border: 2px solid #2563eb;
}

.wifi-raid-legend__swatch.stop {
  background: #dc2626;
  border: 2px solid rgba(255, 245, 245, 0.98);
}

.wifi-raid-legend__swatch.route,
.wifi-raid-legend__swatch.check-link {
  width: 18px;
  height: 0;
  border-radius: 0;
  border-top-width: 3px;
  border-top-style: solid;
}

.wifi-raid-legend__swatch.route {
  border-top-color: #dc2626;
}

.wifi-raid-legend__swatch.check-link {
  border-top-color: #2563eb;
}

.mini-item {
  display: grid;
  gap: 4px;
  padding: 14px 16px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.62);
  border: 1px solid var(--line);
}

.table-panel {
  overflow: auto;
}

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

.summary-table,
.submission-feedback-table {
  min-width: 0;
}

.submission-feedback-table td:first-child,
.submission-feedback-table th:first-child {
  width: 220px;
  white-space: nowrap;
}

.submission-feedback-table td {
  line-height: 1.55;
}

th,
td {
  padding: 14px 16px;
  border-bottom: 1px solid rgba(27, 34, 48, 0.08);
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

summary {
  cursor: pointer;
  font-weight: 600;
  margin-bottom: 12px;
}

.benchmark-history-entry {
  padding: 14px 16px;
  border: 1px solid rgba(27, 34, 48, 0.08);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.45);
}

.benchmark-history-entry + .benchmark-history-entry {
  margin-top: 12px;
}

.benchmark-history-entry__summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 0;
}

.benchmark-history-entry__title {
  font-weight: 700;
}

.benchmark-history-entry__meta {
  color: var(--muted);
  font-weight: 500;
}

.benchmark-history-entry[open] .benchmark-history-entry__summary {
  margin-bottom: 12px;
}

@media (max-width: 900px) {
  .site-header,
  .section-head,
  .hero,
  .problem-layout,
  .admin-layout {
    grid-template-columns: 1fr;
    display: grid;
  }

  .site-header {
    justify-items: start;
  }

  .main-nav,
  .nav-actions {
    width: 100%;
  }

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

  .crossword-cell {
    width: 1.75rem;
    height: 1.75rem;
    font-size: 0.92rem;
  }

  .page-shell {
    width: min(100% - 20px, 1240px);
  }
}
