:root {
  --bg: #111827;
  --panel: #1f2937;
  --panel-2: #273449;
  --line: #374151;
  --muted: #9ca3af;
  --text: #ffffff;
  --gold: #d4af37;
  --gold-bright: #f7e7a6;
  --red: #ef4444;
  --yellow: #eab308;
  --green: #22c55e;
  --blue: #3b82f6;
  --indigo: #6366f1;
  --purple: #a855f7;
  --pink: #ec4899;
  --teal: #14b8a6;
  --rose: #f43f5e;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: "Noto Sans KR", system-ui, sans-serif;
  font-size: 14px;
}

a { color: inherit; text-decoration: none; }
button, input { font: inherit; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: linear-gradient(180deg, #11151f 0%, #0c0f17 100%);
  border-bottom: 1px solid rgba(212, 175, 55, .35);
  box-shadow: 0 2px 18px rgba(0, 0, 0, .45);
}

.site-header::after {
  content: "";
  display: block;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--gold), var(--gold-bright), var(--gold), transparent);
}

.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  min-height: 64px;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1.05;
}

.logo-kicker {
  margin-bottom: 3px;
  color: #d9dbe3;
  font-size: 11px;
  font-weight: 700;
}

.logo-text {
  background: linear-gradient(180deg, #fff 0%, var(--gold-bright) 58%, var(--gold) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  font-size: 26px;
  font-weight: 900;
  text-shadow: 0 1px 10px rgba(212, 175, 55, .25);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.partner-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  padding: 7px 16px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,.25);
  color: #2a1d00;
  background: linear-gradient(135deg, var(--gold-bright), var(--gold) 55%, #b8902b);
  box-shadow: 0 4px 14px rgba(212,175,55,.35), inset 0 1px 0 rgba(255,255,255,.5);
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

.admin-button {
  min-height: 32px;
  padding: 7px 12px;
  border: 1px solid rgba(212,175,55,.42);
  border-radius: 999px;
  background: rgba(212,175,55,.12);
  color: var(--gold-bright);
  font-size: 12px;
  font-weight: 900;
  cursor: pointer;
  white-space: nowrap;
}

.icon-button {
  width: 40px;
  height: 40px;
  border: 0;
  background: transparent;
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.menu-toggle {
  flex-direction: column;
  gap: 5px;
}

.menu-toggle span {
  display: block;
  width: 26px;
  height: 2px;
  background: currentColor;
}

.search-toggle svg { width: 25px; height: 25px; fill: currentColor; }

.desktop-nav {
  display: none;
  max-width: 1200px;
  margin: 0 auto;
  padding: 8px 16px;
  border-top: 1px solid rgba(212,175,55,.18);
}

.desktop-nav a {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 7px 14px;
  border-radius: 8px;
  color: #e5e7eb;
  font-weight: 800;
}

.desktop-nav a:hover {
  background: rgba(212,175,55,.15);
  color: var(--gold-bright);
}

.page {
  max-width: 1200px;
  margin: 0 auto;
  padding: 8px;
}

.banner-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 8px;
}

.ad-banner {
  min-height: 82px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,.16);
  overflow: hidden;
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 16px 20px;
  isolation: isolate;
}

.ad-banner::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(110deg, rgba(255,255,255,.24), transparent 30%),
    repeating-linear-gradient(135deg, rgba(255,255,255,.08) 0 1px, transparent 1px 10px);
  z-index: -1;
}

.ad-banner strong {
  font-size: 22px;
  font-weight: 900;
  letter-spacing: 0;
}

.ad-banner span {
  margin-top: 3px;
  color: rgba(255,255,255,.82);
  font-weight: 700;
}

.ad-large { grid-column: span 2; min-height: 98px; }
.ad-gold { background: linear-gradient(135deg, #8b5e08, #e4b83f 46%, #331f02); }
.ad-blue { background: linear-gradient(135deg, #063a66, #2d80cf 46%, #071829); }
.ad-red { background: linear-gradient(135deg, #55111a, #e7495f); }
.ad-green { background: linear-gradient(135deg, #064e3b, #14b87a); }
.ad-purple { background: linear-gradient(135deg, #3b1767, #9b5cf7); }
.ad-cyan { background: linear-gradient(135deg, #155e75, #06b6d4); }

.quicklinks {
  margin-bottom: 8px;
  border-radius: 8px;
  border: 1px solid rgba(212,175,55,.35);
  background: linear-gradient(180deg, #202c3c, #141c29);
  padding: 10px;
}

.quick-title {
  margin-bottom: 8px;
  color: #f9fafb;
  font-weight: 900;
  text-align: center;
}

.quick-title b { color: var(--gold-bright); }

.quick-list {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}

.quick-item {
  min-height: 58px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fff;
  color: #111827;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 800;
}

.quick-icon {
  width: 26px;
  height: 26px;
  border-radius: 7px;
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 13px;
  font-weight: 900;
}

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

.category-card {
  overflow: hidden;
  border-radius: 16px;
  border: 4px solid var(--card-color);
  background: #fff;
}

.category-head {
  min-height: 54px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--panel);
}

.category-emoji { font-size: 22px; }
.category-title {
  color: #fff;
  font-size: 18px;
  font-weight: 900;
}

.site-list {
  max-height: 260px;
  min-height: 260px;
  overflow-y: auto;
  padding: 12px 16px;
}

.site-list::-webkit-scrollbar { width: 4px; }
.site-list::-webkit-scrollbar-track { background: #f1f1f1; }
.site-list::-webkit-scrollbar-thumb { background: #c7c7c7; border-radius: 8px; }

.site-item {
  display: flex;
  align-items: center;
  min-height: 38px;
  padding: 6px 0;
  border-radius: 6px;
  color: #1f2937;
}

.site-item:hover { background: #f3f4f6; }

.rank {
  width: 26px;
  height: 26px;
  margin-right: 8px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
}

.rank.num {
  border-radius: 50%;
  background: var(--rose);
  color: #fff;
  font-size: 12px;
  font-weight: 900;
}

.rank.medal { font-size: 20px; }
.site-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
  font-weight: 600;
}

.category-foot {
  background: var(--panel);
  padding: 8px 12px;
  text-align: center;
}

.more-link {
  display: inline-flex;
  justify-content: center;
  min-width: 120px;
  padding: 6px 14px;
  border-radius: 6px;
  background: color-mix(in srgb, var(--card-color) 60%, #111827);
  color: #fff;
  font-size: 11px;
  font-weight: 900;
}

.search-overlay,
.menu-overlay,
.admin-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(0,0,0,.85);
}

.search-overlay.active,
.menu-overlay.active,
.admin-overlay.active { display: block; }

.search-overlay { padding: 60px 20px 20px; }
.search-panel {
  max-width: 600px;
  margin: 0 auto;
  position: relative;
}

.search-panel svg {
  position: absolute;
  left: 15px;
  top: 50%;
  transform: translateY(-50%);
  width: 20px;
  height: 20px;
  fill: var(--green);
}

.search-panel input {
  width: 100%;
  height: 54px;
  border-radius: 12px;
  border: 2px solid var(--green);
  outline: 0;
  background: var(--panel);
  color: #fff;
  padding: 0 16px 0 44px;
  font-size: 15px;
}

.close-button {
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 50%;
  background: var(--panel);
  color: #fff;
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
}

.search-close {
  position: absolute;
  right: 20px;
  top: 20px;
}

.menu-panel {
  width: 85%;
  max-width: 400px;
  min-height: 100%;
  padding: 20px;
  background: var(--panel);
  position: relative;
  overflow-y: auto;
}

.menu-close {
  position: absolute;
  right: 16px;
  top: 16px;
  background: var(--bg);
}

.menu-title {
  margin-top: 8px;
  padding: 6px 4px 14px;
  border-bottom: 1px solid rgba(212,175,55,.25);
  color: var(--gold-bright);
  font-weight: 900;
}

.mobile-nav {
  display: flex;
  flex-direction: column;
  padding: 10px 0;
}

.mobile-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 50px;
  border-bottom: 1px solid var(--line);
  padding: 12px 8px;
  font-size: 16px;
  font-weight: 900;
}

.mobile-nav .arrow {
  margin-left: auto;
  color: var(--muted);
}

.menu-partner {
  width: fit-content;
  margin: 18px auto 0;
}

.admin-overlay {
  z-index: 70;
  overflow-y: auto;
  padding: 18px;
}

.admin-panel {
  width: min(980px, 100%);
  margin: 24px auto;
  border: 1px solid rgba(212,175,55,.35);
  border-radius: 12px;
  background: #111827;
  box-shadow: 0 24px 80px rgba(0,0,0,.45);
  overflow: hidden;
}

.admin-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 18px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #1f2937, #151f2e);
}

.admin-head h2 {
  margin: 0;
  font-size: 22px;
}

.admin-head p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.admin-login,
.admin-workspace {
  padding: 18px;
}

.admin-login {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: end;
}

.admin-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 10px;
  margin-bottom: 12px;
}

.admin-form {
  display: grid;
  grid-template-columns: 1fr 1.4fr auto;
  gap: 10px;
  align-items: end;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
}

.admin-form-actions {
  display: flex;
  gap: 8px;
}

.admin-panel label {
  display: grid;
  gap: 6px;
  color: #d1d5db;
  font-size: 12px;
  font-weight: 900;
}

.admin-panel input,
.admin-panel select {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0b1220;
  color: #fff;
  padding: 0 11px;
  outline: 0;
}

.admin-primary,
.admin-secondary,
.admin-danger {
  min-height: 40px;
  border-radius: 8px;
  padding: 0 14px;
  font-weight: 900;
  cursor: pointer;
}

.admin-primary {
  border: 0;
  background: var(--green);
  color: #052e16;
}

.admin-secondary {
  border: 1px solid var(--line);
  background: #263244;
  color: #fff;
}

.admin-danger {
  border: 1px solid rgba(239,68,68,.45);
  background: rgba(239,68,68,.14);
  color: #fecaca;
}

.admin-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.admin-row {
  display: grid;
  grid-template-columns: 42px 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #0f172a;
}

.admin-rank {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--rose);
  font-weight: 900;
}

.admin-site-name {
  font-weight: 900;
}

.admin-site-url {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.admin-row-actions {
  display: flex;
  gap: 6px;
}

.scroll-next {
  position: fixed;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 10;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 50%;
  background: #854d0e;
  color: #facc15;
  box-shadow: 0 2px 8px rgba(0,0,0,.3);
  cursor: pointer;
}

.footer {
  margin-top: 20px;
  min-height: 78px;
  padding: 20px;
  background: var(--panel);
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 20px;
}

.footer b { color: #fff; }

@media (min-width: 768px) {
  .banner-grid { grid-template-columns: repeat(4, 1fr); }
  .ad-large { grid-column: span 2; }
  .category-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .quick-list { grid-template-columns: repeat(8, 1fr); }
}

@media (min-width: 1024px) {
  .menu-toggle { visibility: hidden; }
  .header-inner {
    position: relative;
    justify-content: flex-end;
  }
  .logo {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
  }
  .desktop-nav {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 4px;
  }
}

@media (max-width: 360px) {
  .partner-button { padding-inline: 10px; }
  .admin-button { padding-inline: 9px; }
  .logo-text { font-size: 23px; }
  .quick-list { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 720px) {
  .admin-login,
  .admin-form,
  .admin-row {
    grid-template-columns: 1fr;
  }
  .admin-toolbar {
    display: grid;
  }
  .admin-row-actions {
    justify-content: stretch;
  }
  .admin-row-actions button,
  .admin-form-actions button {
    flex: 1;
  }
}
