:root {
  --bg: #f0f4f8;
  --card: #ffffff;
  --border: #d5dee8;
  --text: #152238;
  --muted: #5b6b7c;
  --accent: #1d4ed8;
  --accent-hot: #e11d48;
  --rank: #b45309;
  --nav-bg: #ffffff;
  --max: 1040px;
  --sidebar-w: 280px;
  --topbar-h: 3.5rem;
}

* { box-sizing: border-box; }

html {
  overflow-x: clip;
}

body {
  margin: 0;
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: clip;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.site-header {
  background: var(--nav-bg);
  border-bottom: 3px solid var(--accent-hot);
  box-shadow: 0 1px 0 rgba(15, 23, 42, 0.04);
}

.site-header-inner {
  max-width: none;
  width: 100%;
  margin: 0;
  padding: 0.85rem clamp(1rem, 3vw, 2rem);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1.5rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  text-decoration: none;
  color: inherit;
}

.brand:hover {
  text-decoration: none;
}

.brand-mark {
  width: 2.4rem;
  height: 2.4rem;
  border-radius: 50%;
  background:
    radial-gradient(circle at 30% 30%, #93c5fd, #1d4ed8 55%, #0f766e);
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.35);
  flex-shrink: 0;
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

.brand-text strong {
  font-size: 1.25rem;
  font-weight: 800;
  color: #0f2744;
}

.brand-text small {
  font-size: 0.75rem;
  color: var(--muted);
  font-weight: 600;
}

.nav-menu {
  margin-left: auto;
  position: relative;
}

.nav-toggle {
  display: none;
  list-style: none;
  cursor: pointer;
  user-select: none;
  font-weight: 800;
  font-size: 0.85rem;
  color: #1e3a5f;
  padding: 0.4rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  align-items: center;
  gap: 0.4rem;
}

.nav-toggle::-webkit-details-marker {
  display: none;
}

.nav-toggle-bars {
  width: 1rem;
  height: 0.75rem;
  display: inline-block;
  background:
    linear-gradient(#1e3a5f 0 0) 0 0 / 100% 2px no-repeat,
    linear-gradient(#1e3a5f 0 0) 0 50% / 100% 2px no-repeat,
    linear-gradient(#1e3a5f 0 0) 0 100% / 100% 2px no-repeat;
}

.site-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.15rem 0.1rem;
  align-items: center;
  justify-content: flex-end;
}

.site-nav a {
  color: #1e3a5f;
  font-weight: 700;
  font-size: 0.9rem;
  text-decoration: none;
  padding: 0.45rem 0.75rem;
  border-radius: 6px;
  white-space: nowrap;
}

.site-nav a:hover {
  background: #eff6ff;
  color: var(--accent);
  text-decoration: none;
}

/* Desktop: tampilkan menu horizontal tanpa tombol */
@media (min-width: 769px) {
  .nav-menu {
    display: contents;
  }

  .nav-toggle {
    display: none !important;
  }
}

.site-main {
  max-width: var(--max);
  margin: 0 auto;
  padding: 1rem 1.25rem 3rem;
}

.docs-main {
  max-width: 920px;
  margin: 0;
  padding: 1.25rem 1.5rem 2.5rem;
}

/* —— Stripe-like docs shell —— */
.page-docs {
  min-height: 100vh;
  background: #fff;
}

.docs-topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0 0.85rem;
  background: rgba(255, 255, 255, 0.96);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(8px);
}

.docs-menu-btn {
  display: none;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  font-weight: 800;
  font-size: 0.82rem;
  color: #1e3a5f;
  cursor: pointer;
}

.docs-topbar .brand {
  min-width: 0;
}

.docs-top-admin {
  margin-left: auto;
  font-size: 0.85rem;
  font-weight: 700;
  color: #1e3a5f;
  text-decoration: none;
  padding: 0.35rem 0.6rem;
  border-radius: 6px;
}

.docs-top-admin:hover {
  background: #eff6ff;
  text-decoration: none;
}

.docs-shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  min-height: calc(100vh - var(--topbar-h));
}

.docs-sidebar {
  position: sticky;
  top: var(--topbar-h);
  align-self: start;
  height: calc(100vh - var(--topbar-h));
  overflow: auto;
  border-right: 1px solid var(--border);
  background: #f8fafc;
}

.docs-sidebar-inner {
  padding: 1rem 0.85rem 2rem;
}

.docs-sidebar-title {
  margin: 0 0 0.65rem;
  padding: 0 0.55rem;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #94a3b8;
}

.docs-side-group {
  margin-top: 1rem;
}

.docs-side-group-label {
  display: block;
  margin: 0 0 0.35rem;
  padding: 0.35rem 0.55rem;
  font-size: 0.78rem;
  font-weight: 800;
  color: #0f2744;
  text-decoration: none;
  border-radius: 6px;
}

a.docs-side-group-label:hover {
  background: #eef2ff;
  text-decoration: none;
}

.docs-side-group-label.is-active {
  color: var(--accent);
  background: #eff6ff;
}

.docs-side-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.docs-side-list li {
  margin: 0;
}

.docs-side-link {
  display: block;
  padding: 0.4rem 0.55rem 0.4rem 0.85rem;
  border-radius: 6px;
  color: #475569;
  font-size: 0.86rem;
  font-weight: 600;
  line-height: 1.35;
  text-decoration: none;
  border-left: 2px solid transparent;
}

.docs-side-link:hover {
  background: #eef2ff;
  color: #1e3a5f;
  text-decoration: none;
}

.docs-side-link.is-active {
  background: #eff6ff;
  color: var(--accent);
  border-left-color: var(--accent);
  font-weight: 800;
}

.docs-side-muted {
  display: block;
  padding: 0.35rem 0.85rem;
  font-size: 0.8rem;
  color: #94a3b8;
}

.docs-content {
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: #fff;
}

.docs-footer.site-footer {
  background: #0f2744;
  margin-top: auto;
}

.docs-backdrop {
  display: none;
}

.docs-nav-toggle:checked ~ .docs-backdrop {
  display: block;
}

@media (max-width: 960px) {
  .docs-menu-btn {
    display: inline-flex;
  }

  .docs-shell {
    grid-template-columns: 1fr;
  }

  .docs-sidebar {
    position: fixed;
    top: var(--topbar-h);
    left: 0;
    bottom: 0;
    width: min(var(--sidebar-w), 88vw);
    z-index: 45;
    transform: translateX(-105%);
    transition: transform 0.2s ease;
    box-shadow: none;
  }

  .docs-nav-toggle:checked ~ .docs-shell .docs-sidebar {
    transform: translateX(0);
    box-shadow: 8px 0 28px rgba(15, 23, 42, 0.18);
  }

  .docs-backdrop {
    position: fixed;
    inset: var(--topbar-h) 0 0 0;
    z-index: 42;
    background: rgba(15, 23, 42, 0.35);
  }

  .docs-main {
    padding: 1rem 1rem 2rem;
  }

  .docs-topbar .brand-text small {
    display: none;
  }
}

.site-main-home {
  max-width: none;
  padding: 0 0 3rem;
}

body.page-home {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
}

body.page-home .site-header {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 5;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

body.page-home .site-main-home {
  flex: 0 0 auto;
  padding-bottom: 3rem;
}

body.page-home .site-footer {
  margin-top: 0;
}

.site-main h1 {
  margin: 0;
  font-size: 1.55rem;
}

.page-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 0.35rem;
}

.live-status {
  margin: 0;
  font-size: 0.78rem;
  color: var(--muted);
}

.live-status.error {
  color: #dc2626;
}

.subtitle {
  margin: 0 0 1.25rem;
  color: var(--muted);
}

.site-footer {
  background: #0f2744;
  color: #cbd5e1;
  margin-top: auto;
}

.site-footer-inner {
  max-width: var(--max);
  margin: 0 auto;
  padding: 1.25rem 1.25rem 1.75rem;
  font-size: 0.85rem;
}

.site-footer p {
  margin: 0 0 0.35rem;
}

.site-footer strong {
  color: #fff;
}

/* Beranda ala Bebras: banner penuh + tentang + kartu kegiatan */
.home-hero {
  width: 100%;
  height: 100vh;
  height: 100dvh;
  min-height: 28rem;
  background: #0b1f36;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.home-hero picture {
  display: block;
  width: 100%;
  height: 100%;
}

.home-hero-img {
  display: block;
  width: 100%;
  height: 100%;
  max-width: none;
  margin: 0;
  object-fit: cover;
  object-position: center center;
}

/* HP / layar sempit: 1 baris (brand | Menu) + hero pas layar */
@media (max-width: 768px) {
  .site-header-inner {
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: center;
    gap: 0.5rem;
    padding: 0.45rem 0.7rem;
    max-width: 100%;
  }

  .brand {
    min-width: 0;
    flex: 1 1 auto;
  }

  .brand-mark {
    width: 1.75rem;
    height: 1.75rem;
  }

  .brand-text strong {
    font-size: 0.95rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .brand-text small {
    display: none;
  }

  .nav-menu {
    flex: 0 0 auto;
    margin-left: 0;
  }

  .nav-toggle {
    display: inline-flex;
  }

  .nav-menu .site-nav {
    display: none;
    position: absolute;
    right: 0;
    top: calc(100% + 0.35rem);
    z-index: 20;
    min-width: 12.5rem;
    max-width: min(18rem, calc(100vw - 1.4rem));
    flex-direction: column;
    align-items: stretch;
    gap: 0.15rem;
    padding: 0.45rem;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: 0 10px 28px rgba(15, 23, 42, 0.16);
  }

  .nav-menu[open] .site-nav {
    display: flex;
  }

  .site-nav a {
    font-size: 0.88rem;
    padding: 0.55rem 0.7rem;
    white-space: normal;
  }

  .home-hero {
    width: 100%;
    max-width: 100vw;
    min-height: 100svh;
    height: 100svh;
    height: 100dvh;
    max-height: 100dvh;
  }

  .home-hero-img {
    object-fit: cover;
    object-position: center center;
  }

  .home-about,
  .home-kegiatan {
    padding-top: 1.25rem;
    max-width: 100%;
  }

  .home-about h1,
  .home-kegiatan h2 {
    font-size: 1.25rem;
  }

  .home-card {
    min-height: 0;
  }
}

.home-hero-fallback {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem 1.25rem;
  color: #fff;
  text-align: center;
}

.home-hero-brand {
  font-size: 2rem;
  font-weight: 800;
  margin: 0 0 0.5rem;
}

.home-about,
.home-kegiatan {
  max-width: var(--max);
  margin: 0 auto;
  padding: 1.75rem 1.25rem 0;
}

.home-about h1,
.home-kegiatan h2 {
  margin: 0 0 0.75rem;
  font-size: 1.55rem;
  color: #0f2744;
  border-left: 5px solid var(--accent-hot);
  padding-left: 0.65rem;
}

.home-about p {
  margin: 0 0 0.75rem;
  line-height: 1.65;
  color: #334155;
  max-width: 52rem;
}

.home-about-meta {
  font-size: 0.92rem;
  color: var(--muted) !important;
}

.home-kegiatan-lead {
  margin: 0 0 1.1rem;
  color: var(--muted);
}

.home-cards {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
}

@media (max-width: 800px) {
  .home-cards {
    grid-template-columns: 1fr;
  }
}

.home-card {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  min-height: 10.5rem;
  padding: 1.15rem 1.2rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-top: 4px solid var(--accent);
  border-radius: 4px;
  color: inherit;
  text-decoration: none;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.06);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.home-card:hover {
  text-decoration: none;
  border-color: var(--accent-hot);
  border-top-color: var(--accent-hot);
  box-shadow: 0 6px 18px rgba(15, 23, 42, 0.1);
}

.home-card-label {
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent-hot);
}

.home-card-title {
  font-size: 1.15rem;
  font-weight: 800;
  color: #0f2744;
}

.home-card-meta {
  font-size: 0.9rem;
  color: var(--muted);
  line-height: 1.45;
  margin-top: auto;
}

.card-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.75rem;
}

.card-list li a {
  display: block;
  padding: 1rem 1.1rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text);
  text-decoration: none;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.card-list li a:hover {
  border-color: var(--accent);
  box-shadow: 0 4px 14px rgba(234, 88, 12, 0.12);
}

.card-title {
  display: block;
  font-weight: 700;
  font-size: 1.05rem;
}

.card-meta {
  display: block;
  margin-top: 0.25rem;
  color: var(--muted);
  font-size: 0.85rem;
}

.back-link {
  display: inline-block;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}

.empty {
  padding: 1.25rem;
  border: 1px dashed var(--border);
  border-radius: 12px;
  color: var(--muted);
  background: #fff;
}

.rank-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.rank-table th,
.rank-table td {
  padding: 0.75rem 0.9rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.rank-table th {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 600;
  background: #eff6ff;
}

.rank-table tr:last-child td {
  border-bottom: none;
}

.rank-num {
  color: var(--rank);
  font-weight: 800;
  width: 3rem;
}

.rank-time {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  white-space: nowrap;
}

.school {
  color: var(--muted);
  font-size: 0.92rem;
}

.badge-salah {
  display: inline-block;
  margin-left: 0.35rem;
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  background: #fee2e2;
  color: #b91c1c;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  vertical-align: middle;
}

.badge-benar {
  display: inline-block;
  margin-left: 0.35rem;
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  background: #dcfce7;
  color: #166534;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  vertical-align: middle;
}

.rank-actions {
  width: 1%;
  white-space: nowrap;
  text-align: right;
}

.btn-lihat-penilaian {
  appearance: none;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--ink, #1c1917);
  font: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0.35rem 0.65rem;
  border-radius: 6px;
  cursor: pointer;
}

.btn-lihat-penilaian:hover {
  background: #fff7ed;
  border-color: #fdba74;
}

.penilaian-dialog {
  border: none;
  padding: 0;
  border-radius: 12px;
  max-width: min(92vw, 420px);
  width: 100%;
  box-shadow: 0 20px 50px rgba(28, 25, 23, 0.25);
}

.penilaian-dialog::backdrop {
  background: rgba(28, 25, 23, 0.45);
}

.penilaian-card {
  margin: 0;
  padding: 0;
}

.penilaian-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 1rem 1.1rem 0.75rem;
  border-bottom: 1px solid var(--border);
}

.penilaian-head h2 {
  margin: 0;
  font-size: 1.05rem;
}

.penilaian-close {
  appearance: none;
  border: none;
  background: transparent;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  color: var(--muted);
  padding: 0.15rem 0.35rem;
}

.penilaian-body {
  padding: 1rem 1.1rem;
}

.penilaian-nama {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 800;
}

.penilaian-sekolah {
  margin: 0.25rem 0 1rem;
  color: var(--muted);
  font-size: 0.92rem;
}

.penilaian-dl {
  margin: 0 0 1rem;
  display: grid;
  gap: 0.55rem;
}

.penilaian-dl > div {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: baseline;
}

.penilaian-dl dt {
  margin: 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.penilaian-dl dd {
  margin: 0;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.penilaian-final {
  color: var(--rank, #c2410c);
}

.penilaian-sub {
  margin: 0 0 0.5rem;
  font-size: 0.85rem;
  color: var(--muted);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.penilaian-rubrik {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.4rem;
}

.penilaian-rubrik li {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.45rem 0.55rem;
  border-radius: 6px;
  background: #fafaf9;
  font-size: 0.9rem;
}

.penilaian-rubrik .rubrik-ok strong {
  color: #166534;
}

.penilaian-rubrik .rubrik-fail strong {
  color: #b91c1c;
}

.penilaian-note {
  margin: 0;
  font-size: 0.9rem;
  color: var(--muted);
}

.penilaian-foot {
  padding: 0.75rem 1.1rem 1rem;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
}

.penilaian-ok {
  appearance: none;
  border: none;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-weight: 700;
  padding: 0.5rem 1rem;
  border-radius: 8px;
  cursor: pointer;
}

.row-invalid {
  opacity: 0.72;
}

.row-invalid .rank-time {
  text-decoration: line-through;
}

.hint-block {
  margin-top: 1.5rem;
  padding: 0.9rem 1rem;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--muted);
  font-size: 0.9rem;
}

.game-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
  align-items: flex-end;
  padding: 1rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
}

.game-picker label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
  flex: 1;
  min-width: 220px;
}

.game-picker select,
.admin-form input,
.admin-form select,
.admin-filter select {
  font: inherit;
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
}

.btn-primary {
  appearance: none;
  border: none;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-weight: 700;
  padding: 0.55rem 1rem;
  border-radius: 8px;
  cursor: pointer;
}

.btn-primary:hover {
  background: #1e40af;
}

.btn-ghost {
  display: inline-block;
  padding: 0.55rem 1rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  color: var(--text);
  text-decoration: none;
  font-weight: 600;
}

.badge-juara {
  display: inline-block;
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 800;
  white-space: nowrap;
}

.juara-1 {
  background: #fef3c7;
  color: #92400e;
}

.juara-2 {
  background: #e2e8f0;
  color: #334155;
}

.juara-3 {
  background: #ffedd5;
  color: #9a3412;
}

.admin-panel {
  margin-bottom: 1.75rem;
  padding: 1rem 1.1rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
}

.admin-panel h2 {
  margin: 0 0 0.85rem;
  font-size: 1.1rem;
}

.admin-form {
  display: grid;
  gap: 0.75rem;
}

.admin-form label,
.admin-filter label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
}

.admin-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

@media (max-width: 560px) {
  .admin-row {
    grid-template-columns: 1fr;
  }
}

.admin-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  align-items: center;
}

.admin-filter {
  margin-bottom: 0.85rem;
}

.admin-flash {
  padding: 0.65rem 0.85rem;
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
  color: #065f46;
  border-radius: 8px;
}

.admin-error {
  padding: 0.65rem 0.85rem;
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #991b1b;
  border-radius: 8px;
}

.admin-table-actions {
  white-space: nowrap;
  display: flex;
  gap: 0.65rem;
  align-items: center;
}

.inline-form {
  display: inline;
  margin: 0;
}

.link-danger {
  appearance: none;
  border: none;
  background: none;
  color: #b91c1c;
  font: inherit;
  font-size: inherit;
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
}
