/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body {
  background: #f0f2f5;
  color: #333;
  font-family: 'Noto Sans KR', 'Apple SD Gothic Neo', sans-serif;
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
}
a { text-decoration: none; color: inherit; }
img { display: block; max-width: 100%; }

/* ===== HEADER ===== */
.site-header {
  background: #fff;
  border-bottom: 2px solid #e53935;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}
.header-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 0;
  gap: 12px;
}

/* 텔레그램 버튼 */
.header-spacer {
  flex-shrink: 0;
  visibility: hidden;
  pointer-events: none;
  width: var(--tg-btn-width, 120px);
}
.tg-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  background: #29b6f6;
  color: #fff;
  padding: 7px 14px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
  transition: background 0.2s;
  white-space: nowrap;
  flex-shrink: 0;
}
.tg-btn:hover { background: #0288d1; color: #fff; }
.tg-icon { font-size: 15px; }

/* 로고 */
.header-logo {
  display: flex;
  align-items: center;
  gap: 8px;
}
.logo-img {
  height: 120px;
  max-width: 500px;
  object-fit: contain;
  display: block;
  vertical-align: bottom;
  margin: 6px 0;
  filter: drop-shadow(0 1px 3px rgba(0,0,0,0.2));
}
.logo-icon {
  width: 40px; height: 40px;
  background: linear-gradient(135deg, #fff3e0, #ffe0b2);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}
.logo-text {
  font-size: 22px;
  font-weight: 900;
  color: #111;
  letter-spacing: -0.5px;
}

/* 시계 */
.header-clock {
  text-align: right;
  font-size: 12px;
  color: #666;
  line-height: 1.5;
  white-space: nowrap;
  flex-shrink: 0;
}

/* ===== MAIN WRAPPER ===== */
.main-wrap {
  max-width: 1400px;
  margin: 12px auto;
  padding: 0 12px 30px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* ===== BANNER GRID ===== */
.banner-grid {
  background: #111;
  border-radius: 6px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0,0,0,0.12);
}
.banner-row {
  display: flex;
}
.banner-row + .banner-row {
  border-top: 3px solid #000;
}
.bn-cell {
  flex: 1;
  overflow: hidden;
  cursor: pointer;
  position: relative;
}
.bn-cell + .bn-cell {
  border-left: 3px solid #000;
}
.bn-cell img {
  width: 100%;
  height: auto;
  object-fit: unset;
  display: block;
  transition: transform 0.25s ease;
}
.bn-cell:hover img { transform: scale(1.04); }
.bn-placeholder {
  width: 100%;
  height: 130px;
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  color: #444;
  font-size: 11px;
  letter-spacing: 1px;
}
.bn-placeholder::before {
  content: '🖼';
  font-size: 28px;
  opacity: 0.3;
}

/* ===== 안전보증 바 ===== */
.safe-site-bar {
  text-align: center;
  background: linear-gradient(135deg, #fff5f5, #fff);
  border: 1px solid #ffcdd2;
  border-radius: 6px;
  padding: 10px;
}
.safe-site-bar a {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #e53935;
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  padding: 8px 24px;
  border-radius: 24px;
  transition: background 0.2s, transform 0.15s;
}
.safe-site-bar a:hover {
  background: #c62828;
  transform: translateY(-1px);
}

/* ===== INFO / SOCIAL BAR ===== */
.info-bar {
  background: #fff;
  border: 1px solid #e8e8e8;
  border-radius: 6px;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.info-bar-left {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 700;
  color: #333;
  white-space: nowrap;
}
.megaphone { font-size: 18px; }
.site-info-link { color: #333; }
.site-info-link strong { color: #e53935; }

.social-icons {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.social-icon-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: #555;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 6px;
  white-space: nowrap;
  overflow: hidden;
  transition: background 0.15s;
  white-space: nowrap;
}
.social-icon-item:hover { background: #f5f5f5; }
.s-emoji {
  width: 30px; height: 30px;
  min-width: 30px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  line-height: 1;
  border-radius: 8px;
  flex-shrink: 0;
  text-align: center;
}

/* ===== CATEGORY GRID ===== */
.category-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
}
.cat-card {
  background: #fff;
  border: 1px solid #e8e8e8;
  border-top: 3px solid #e53935;
  border-radius: 6px;
  overflow: hidden;
  transition: transform 0.2s, box-shadow 0.2s;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}
.cat-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 6px 18px rgba(0,0,0,0.1);
}
.cat-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 10px 8px;
  border-bottom: 1px solid #f0f0f0;
  background: #fafafa;
}
.cat-header-left {
  display: flex;
  align-items: center;
  gap: 7px;
}
.cat-icon-text {
  width: 26px; height: 26px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}
.cat-name {
  font-size: 13px;
  font-weight: 700;
  color: #111;
}
.cat-cursor { font-size: 14px; color: #ccc; }

.cat-links { padding: 4px 0; }
.cat-link-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  cursor: pointer;
  transition: background 0.12s;
}
.cat-link-item:hover { background: #fef5f5; }

.rank-icon {
  width: 22px; height: 22px;
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}
.rank-medal {
  width: 22px; height: 22px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px;
  font-weight: 800;
  flex-shrink: 0;
}
.rank-1 .rank-medal {
  background: radial-gradient(circle, #ffd700, #ffaa00);
  color: #7a4800;
  border: 1.5px solid #e6a800;
  box-shadow: 0 1px 4px rgba(255,170,0,0.4);
}
.rank-2 .rank-medal {
  background: radial-gradient(circle, #e8e8e8, #bbb);
  color: #555;
  border: 1.5px solid #aaa;
  box-shadow: 0 1px 3px rgba(0,0,0,0.12);
}
.rank-3 .rank-medal {
  background: radial-gradient(circle, #f0a868, #c87020);
  color: #6b3000;
  border: 1.5px solid #b06000;
  box-shadow: 0 1px 3px rgba(180,100,0,0.3);
}
.rank-4 .rank-medal,
.rank-5 .rank-medal {
  background: #f0f0f0;
  color: #999;
  border: 1.5px solid #ddd;
  font-size: 10px;
}

.cat-link-title {
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  font-weight: 600;
}
.rank-1 .cat-link-title { color: #d84315; }
.rank-2 .cat-link-title { color: #757575; }
.rank-3 .cat-link-title { color: #bf360c; }
.rank-4 .cat-link-title,
.rank-5 .cat-link-title { color: #666; font-weight: 400; }

.no-links {
  padding: 14px 10px;
  font-size: 12px;
  color: #bbb;
  text-align: center;
}

/* ===== FOOTER ===== */
.site-footer {
  text-align: center;
  padding: 16px;
  font-size: 12px;
  color: #999;
  background: #fff;
  border-top: 1px solid #e8e8e8;
  margin-top: 4px;
}
.site-footer a { color: #ccc; }
.site-footer a:hover { color: #666; }
.admin-link {
  font-size: 11px;
  color: #bbb !important;
  padding: 2px 8px;
  border: 1px solid #ddd;
  border-radius: 4px;
  transition: all 0.15s;
}
.admin-link:hover {
  background: #e53935;
  color: #fff !important;
  border-color: #e53935;
}

/* ===== BACK TO TOP ===== */
.back-top {
  position: fixed;
  bottom: 24px; right: 24px;
  width: 44px; height: 44px;
  background: #e53935;
  color: #fff;
  border: none;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
  cursor: pointer;
  box-shadow: 0 3px 10px rgba(229,57,53,0.4);
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s, transform 0.2s;
}
.back-top.show { opacity: 1; pointer-events: auto; }
.back-top:hover { transform: translateY(-2px); }

/* ===== RESPONSIVE ===== */
@media (max-width: 1100px) {
  .category-grid { grid-template-columns: repeat(4, 1fr); }
}
@media (max-width: 860px) {
  .category-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 640px) {
  .header-inner { padding: 0 10px; min-height: 52px; }
  .tg-btn { display: none; }
  .header-spacer { display: none; }
  .header-inner { justify-content: center; }
  .logo-text { font-size: 18px; }
  .header-clock { font-size: 11px; }
  .main-wrap { padding: 0 8px 20px; margin: 8px auto; }
  .category-grid { grid-template-columns: repeat(2, 1fr); }
  .banner-row { flex-direction: column; }
  .bn-cell + .bn-cell { border-left: none; border-top: 3px solid #000; }
  .bn-cell img { width: 100%; height: auto; object-fit: unset; }
  .bn-placeholder { height: 120px; }
  .info-bar { padding: 8px 10px; flex-direction: column; align-items: flex-start; }
  .social-icons { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; width: 100%; }
  .social-icon-item { justify-content: flex-start; padding: 8px 10px; border-radius: 8px; background: #f7f7f7; font-size: 13px; font-weight: 600; }
  .s-emoji { width: 28px; height: 28px; min-width: 28px; font-size: 20px; }
}
@media (max-width: 380px) {
  .logo-text { font-size: 16px; }
  .category-grid { grid-template-columns: repeat(2, 1fr); }
}
