:root {
  --bg: #0d0d0d;
  --bg-surface: #1a1a1a;
  --bg-card: #222;
  --text: #f0f0f0;
  --text-muted: #888;
  --accent: #E85D04;
  --accent-dim: rgba(232,93,4,0.15);
  --border: #2a2a2a;
  --radius: 4px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}

/* ── NAV ──────────────────────────────── */
.nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 100;
  padding: 0 2rem;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(13,13,13,0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.nav-brand {
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text);
  text-decoration: none;
}

.nav-brand span { color: var(--accent); }

.nav-links {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.nav-links a {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.85rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  transition: color 0.2s;
}

.nav-links a:hover, .nav-links a.active { color: var(--text); }

.nav-btn {
  color: var(--accent) !important;
  border: 1px solid var(--accent);
  padding: 5px 14px;
  border-radius: 2px;
  transition: background 0.2s !important;
}

.nav-btn:hover { background: var(--accent-dim) !important; }

/* ── GALLERY ──────────────────────────── */
.gallery-wrap {
  padding-top: 52px;
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 3px;
}

.gallery-item {
  position: relative;
  overflow: hidden;
  cursor: pointer;
  aspect-ratio: 16/9;
  background: var(--bg-surface);
}

.gallery-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.4s ease, filter 0.4s ease;
  filter: brightness(0.92);
}

.gallery-item:hover img {
  transform: scale(1.04);
  filter: brightness(1);
}

.gallery-item-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(0,0,0,0.7) 0%, transparent 50%);
  opacity: 0;
  transition: opacity 0.3s;
  display: flex;
  align-items: flex-end;
  padding: 1rem;
}

.gallery-item:hover .gallery-item-overlay { opacity: 1; }

.gallery-item-title {
  color: white;
  font-size: 0.9rem;
  font-weight: 600;
  text-shadow: 0 1px 4px rgba(0,0,0,0.5);
}

.gallery-item-score {
  color: rgba(255,255,255,0.7);
  font-size: 0.75rem;
  margin-top: 2px;
}

/* ── LIGHTBOX ─────────────────────────── */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 300;
  background: rgba(0,0,0,0.97);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.lightbox-img-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 52px 80px 0;
  overflow: hidden;
}

.lightbox-img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 2px;
  box-shadow: 0 8px 60px rgba(0,0,0,0.6);
}

.lightbox-footer {
  width: 100%;
  padding: 1.2rem 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-shrink: 0;
  border-top: 1px solid var(--border);
}

.lightbox-info h2 {
  font-size: 1.1rem;
  font-weight: 600;
}

.lightbox-info p {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-top: 3px;
}

.lightbox-close {
  position: absolute;
  top: 14px;
  right: 20px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.6rem;
  cursor: pointer;
  line-height: 1;
  transition: color 0.2s;
}

.lightbox-close:hover { color: white; }

.lightbox-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(255,255,255,0.06);
  border: none;
  color: white;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  font-size: 1.4rem;
  cursor: pointer;
  transition: background 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.lightbox-nav:hover { background: rgba(255,255,255,0.14); }
.lightbox-nav.prev { left: 16px; }
.lightbox-nav.next { right: 16px; }

/* Donut */
.donut-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
}

.donut-svg { width: 48px; height: 48px; flex-shrink: 0; }

.donut-meta {
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.6;
}

.donut-meta strong { color: var(--accent); font-size: 1rem; }

/* ── PAGINATION ───────────────────────── */
.pager {
  display: flex;
  justify-content: center;
  gap: 6px;
  padding: 2rem;
}

.pager-btn {
  width: 36px;
  height: 36px;
  border-radius: 2px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s;
}

.pager-btn:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--text);
}

.pager-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

.pager-btn:disabled { opacity: 0.3; cursor: not-allowed; }

/* ── VOTE PAGE ────────────────────────── */
.vote-header {
  padding-top: 72px;
  padding-bottom: 1.5rem;
  padding-left: 2rem;
  padding-right: 2rem;
  border-bottom: 1px solid var(--border);
}

.vote-header h1 {
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.vote-header p { color: var(--text-muted); font-size: 0.9rem; margin-top: 4px; }

.vote-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 3px;
  padding: 3px;
}

.vote-item {
  position: relative;
  cursor: pointer;
  overflow: hidden;
  background: var(--bg-surface);
}

.vote-item img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.3s, filter 0.3s;
  filter: brightness(0.85);
}

.vote-item:hover img { transform: scale(1.03); filter: brightness(1); }

.vote-item.selected img { filter: brightness(0.6); }

.vote-item.selected::after {
  content: '';
  position: absolute;
  inset: 0;
  border: 3px solid var(--accent);
  pointer-events: none;
}

.vote-rank-label {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.2s;
}

.vote-item.selected .vote-rank-label { opacity: 1; }

.vote-rank-num {
  width: 44px;
  height: 44px;
  background: var(--accent);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  font-weight: 900;
  color: white;
  box-shadow: 0 2px 12px rgba(0,0,0,0.5);
}

.vote-item-ranks {
  display: flex;
  gap: 3px;
}

.rank-pip {
  width: 24px; height: 24px;
  border-radius: 50%;
  border: 1.5px solid rgba(255,255,255,0.4);
  background: rgba(0,0,0,0.5);
  color: white;
  font-size: 0.7rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}

.rank-pip:hover:not(:disabled) {
  border-color: var(--accent);
  background: var(--accent-dim);
}

.rank-pip.active {
  background: var(--accent);
  border-color: var(--accent);
}

.rank-pip:disabled { opacity: 0.2; cursor: not-allowed; }

/* ── STICKY VOTE BAR ──────────────────── */
.vote-bar {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 50;
  background: rgba(13,13,13,0.97);
  border-top: 1px solid var(--border);
  padding: 0.9rem 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  backdrop-filter: blur(10px);
}

.vote-slots {
  display: flex;
  gap: 8px;
}

.vote-slot {
  width: 42px;
  height: 42px;
  border-radius: 2px;
  border: 1px solid var(--border);
  overflow: hidden;
  position: relative;
  flex-shrink: 0;
}

.vote-slot img {
  width: 100%; height: 100%;
  object-fit: cover;
}

.vote-slot-empty {
  width: 100%; height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  color: var(--text-muted);
  font-weight: 700;
}

.vote-slot-num {
  position: absolute;
  top: 2px; left: 3px;
  font-size: 0.6rem;
  font-weight: 900;
  color: white;
  text-shadow: 0 1px 3px rgba(0,0,0,0.8);
}

/* ── TOP 5 ────────────────────────────── */
.top5-list {
  padding: 80px 2rem 2rem;
  max-width: 960px;
  margin: 0 auto;
}

.top5-item {
  display: grid;
  grid-template-columns: 40px 280px 1fr auto;
  align-items: center;
  gap: 1.5rem;
  padding: 1.2rem 0;
  border-bottom: 1px solid var(--border);
}

.top5-rank {
  font-size: 1.8rem;
  font-weight: 900;
  color: var(--text-muted);
  text-align: center;
}

.top5-rank.gold { color: #FFD700; }
.top5-rank.silver { color: #A8A8A8; }
.top5-rank.bronze { color: #CD7F32; }

.top5-img {
  width: 280px;
  height: 180px;
  object-fit: cover;
  border-radius: 2px;
  display: block;
}

.top5-title {
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: 6px;
}

.top5-stats {
  color: var(--text-muted);
  font-size: 0.85rem;
}

.top5-pts {
  font-size: 2.2rem;
  font-weight: 900;
  color: var(--accent);
  text-align: right;
}

.top5-pts small {
  display: block;
  font-size: 0.75rem;
  font-weight: 400;
  color: var(--text-muted);
}

/* ── AUTH ─────────────────────────────── */
.auth-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  padding-top: 72px;
}

.auth-box {
  width: 100%;
  max-width: 400px;
}

.auth-logo {
  text-align: center;
  margin-bottom: 2rem;
}

.auth-logo h1 {
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.auth-logo span { color: var(--accent); }
.auth-logo p { color: var(--text-muted); font-size: 0.85rem; margin-top: 6px; }

.tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1.5rem;
}

.tab-btn {
  flex: 1;
  padding: 10px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.2s;
  margin-bottom: -1px;
}

.tab-btn.active {
  color: var(--text);
  border-bottom-color: var(--accent);
}

/* ── FORMS ────────────────────────────── */
.form-group { margin-bottom: 1rem; }

.form-group label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.form-group input,
.form-group textarea,
.form-group select {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 0.95rem;
  transition: border-color 0.2s;
}

.form-group input:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--accent);
}

/* ── BUTTONS ──────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 20px;
  border-radius: var(--radius);
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  cursor: pointer;
  transition: all 0.2s;
  border: 1px solid transparent;
  text-decoration: none;
}

.btn-primary {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

.btn-primary:hover:not(:disabled) { background: #c94d00; }

.btn-ghost {
  background: transparent;
  color: var(--text);
  border-color: var(--border);
}

.btn-ghost:hover:not(:disabled) { border-color: var(--text-muted); }

.btn-danger { background: #c0392b; color: white; }

.btn-sm { padding: 5px 12px; font-size: 0.78rem; }
.btn-lg { padding: 12px 28px; font-size: 0.95rem; }
.btn-full { width: 100%; justify-content: center; }

.btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ── ADMIN ────────────────────────────── */
.admin-wrap {
  padding-top: 52px;
  display: grid;
  grid-template-columns: 200px 1fr;
  min-height: calc(100vh - 52px);
}

.admin-sidebar {
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  padding: 1.5rem 0;
  position: sticky;
  top: 52px;
  height: calc(100vh - 52px);
  overflow-y: auto;
}

.admin-sidebar a {
  display: block;
  padding: 10px 1.5rem;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.85rem;
  transition: all 0.2s;
  border-left: 3px solid transparent;
}

.admin-sidebar a:hover { color: var(--text); }
.admin-sidebar a.active { color: var(--text); border-left-color: var(--accent); background: var(--accent-dim); }

.admin-main {
  padding: 2rem;
  overflow-y: auto;
}

.admin-main section { display: none; }
.admin-main section.active { display: block; }

.page-title {
  font-size: 1.3rem;
  font-weight: 700;
  margin-bottom: 1.5rem;
  letter-spacing: -0.02em;
}

/* ── STATS ────────────────────────────── */
.stat-row {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 2rem;
}

.stat-cell {
  background: var(--bg-surface);
  padding: 1.2rem;
  text-align: center;
}

.stat-n {
  font-size: 2rem;
  font-weight: 900;
  color: var(--accent);
  line-height: 1;
}

.stat-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 4px;
}

/* ── TABLE ────────────────────────────── */
.tbl { width: 100%; border-collapse: collapse; }
.tbl th, .tbl td { padding: 10px 12px; border-bottom: 1px solid var(--border); font-size: 0.85rem; text-align: left; }
.tbl th { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); }
.tbl tr:last-child td { border-bottom: none; }
.tbl tr:hover td { background: var(--bg-surface); }

/* ── DROP ZONE ────────────────────────── */
.drop-zone {
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 3rem;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s;
  background: var(--bg-surface);
}

.drop-zone:hover, .drop-zone.over { border-color: var(--accent); }
.drop-zone p { color: var(--text-muted); font-size: 0.85rem; margin-top: 8px; }

/* ── BADGE ────────────────────────────── */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 2px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.badge-ok { background: rgba(39,174,96,0.15); color: #27ae60; }
.badge-warn { background: rgba(241,196,15,0.15); color: #f1c40f; }
.badge-err { background: rgba(192,57,43,0.15); color: #e74c3c; }
.badge-info { background: rgba(232,93,4,0.15); color: var(--accent); }

/* ── ALERT ────────────────────────────── */
.alert {
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 0.875rem;
  margin-bottom: 1rem;
  border-left: 3px solid;
}

.alert-ok { background: rgba(39,174,96,0.08); border-color: #27ae60; color: #7dcea0; }
.alert-err { background: rgba(192,57,43,0.08); border-color: #c0392b; color: #e88; }
.alert-info { background: rgba(232,93,4,0.08); border-color: var(--accent); color: var(--text-muted); }

/* ── SPINNER ──────────────────────────── */
.spinner {
  display: inline-block;
  width: 16px; height: 16px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

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

.loading-state {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 4rem;
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* ── RESPONSIVE ───────────────────────── */
@media (max-width: 768px) {
  .gallery-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
  .vote-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
  .top5-item {
    grid-template-columns: 32px 1fr auto;
    grid-template-rows: auto auto;
    gap: 0.5rem 0.75rem;
  }
  .top5-img {
    display: block;
    grid-column: 1 / -1;
    grid-row: 1;
    width: 100%;
    height: 160px;
    border-radius: 2px;
  }
  .top5-rank { grid-column: 1; grid-row: 2; font-size: 1.4rem; }
  .top5-item > *:nth-child(3) { grid-column: 2; grid-row: 2; }
  .top5-pts { grid-column: 3; grid-row: 2; font-size: 1.5rem; }
  .admin-wrap { grid-template-columns: 1fr; }
  .admin-sidebar { position: static; height: auto; display: flex; overflow-x: auto; padding: 0; }
  .admin-sidebar a { flex-shrink: 0; border-left: none; border-bottom: 3px solid transparent; padding: 12px 16px; }
  .admin-sidebar a.active { border-bottom-color: var(--accent); border-left-color: transparent; }
  .nav-links { gap: 1rem; }
  .lightbox-img-wrap { padding: 52px 48px 0; }
  .lightbox-nav { width: 40px; height: 40px; font-size: 1.1rem; }
}

@media (max-width: 480px) {
  .lightbox-img-wrap { padding: 52px 6px 0; }
  .lightbox-nav { width: 36px; height: 36px; font-size: 1rem; }
  .lightbox-nav.prev { left: 2px; }
  .lightbox-nav.next { right: 2px; }
  .lightbox-footer {
    flex-wrap: wrap;
    padding: 0.7rem 1rem;
    gap: 0.5rem;
  }
  .lightbox-info h2 { font-size: 0.95rem; }
  .lightbox-info p { font-size: 0.75rem; }
  .donut-svg { width: 38px; height: 38px; }
}

/* ── POPUP / MODAL ────────────────────── */
.popup-overlay {
  position: fixed;
  inset: 0;
  z-index: 400;
  background: rgba(0,0,0,0.88);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.popup-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  max-width: 500px;
  width: 100%;
  padding: 2rem;
}

.popup-box h2 {
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.popup-box p {
  color: var(--text-muted);
  font-size: 0.9rem;
  line-height: 1.65;
  margin-top: 0.75rem;
}

[x-cloak] { display: none !important; }
