:root {
  --primary: #17a2b8;
  --bg: #0f1419;
  --card: #1a2332;
  --text: #e6edf3;
  --heading: #ffffff;
  --muted: #8b949e;
  --border: #30363d;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: "Segoe UI", system-ui, sans-serif; background: var(--bg); color: var(--text); line-height: 1.5; }
a { color: var(--primary); text-decoration: none; }
.container { max-width: 1200px; margin: 0 auto; padding: 0 16px; }

.site-header { background: var(--header-bg, var(--card)); border-bottom: 1px solid var(--header-border, var(--border)); padding: var(--header-padding-y, 14px) 0; position: var(--header-position, sticky); top: 0; z-index: 50; font-family: var(--header-font, inherit); }
.site-header.not-sticky { position: relative; top: auto; }
.header-inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: nowrap; }
.header-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex: 0 0 auto; }
.header-menu { display: flex; align-items: center; gap: var(--header-nav-gap, 16px); flex: 1; justify-content: flex-end; min-width: 0; }
.brand img { max-height: var(--header-logo-height, 48px); max-width: 220px; }
.brand-text, .brand span { font-size: var(--header-brand-size, 20px); font-weight: 700; color: var(--header-brand-color, #fff); }
.main-nav { display: flex; gap: var(--header-nav-gap, 16px); flex-wrap: wrap; align-items: center; }
.main-nav a { color: var(--header-nav-color, var(--muted)); font-size: var(--header-nav-size, 14px); font-weight: var(--header-nav-weight, 600); white-space: nowrap; }
.main-nav a:hover { color: var(--header-nav-hover, var(--primary)); }
.main-nav a.active { color: var(--header-nav-active, var(--primary)); }
.main-nav a.nav-profile { color: var(--header-nav-active, var(--primary)); font-weight: 700; }
.main-nav a.nav-admin { color: #f0b429; font-weight: 700; }

.session-hint {
  margin: 10px auto 0; padding: 10px 14px; font-size: 13px; line-height: 1.5;
  background: rgba(240, 180, 41, .12); border: 1px solid rgba(240, 180, 41, .35);
  border-radius: 8px; color: var(--text);
}
.session-hint a { font-weight: 600; }

.nav-toggle {
  display: none; flex-direction: column; justify-content: center; gap: 5px;
  width: 44px; height: 44px; padding: 10px; border: 1px solid var(--header-border, var(--border));
  border-radius: 8px; background: transparent; cursor: pointer; flex-shrink: 0;
}
.nav-toggle-bar {
  display: block; width: 100%; height: 2px; background: var(--header-brand-color, var(--text));
  border-radius: 2px; transition: transform .2s, opacity .2s;
}
body.nav-open .nav-toggle-bar:nth-child(1) { transform: translateY(7px) rotate(45deg); }
body.nav-open .nav-toggle-bar:nth-child(2) { opacity: 0; }
body.nav-open .nav-toggle-bar:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

.nav-backdrop {
  position: fixed; inset: 0; background: rgba(0, 0, 0, .55); z-index: 90;
  opacity: 0; transition: opacity .25s; pointer-events: none;
}
body.nav-open .nav-backdrop { opacity: 1; pointer-events: auto; }
body.nav-open { overflow: hidden; }
.back-link { color: #fff; font-weight: 600; }

.site-main { padding: 20px 0 40px; min-height: calc(100vh - 140px); }
.home-page { padding-top: 8px; }
.hero { text-align: center; padding: 20px 0 8px; }
.hero h1 { font-size: clamp(22px, 4vw, 32px); margin-bottom: 6px; }
.hero p { color: var(--muted); font-size: 15px; }
.section { margin: 24px 0; }
.home-section { margin-bottom: 36px; }
.home-section-title {
  display: block;
  font-size: clamp(24px, 3vw, 32px);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  line-height: 1.2;
  margin: 0 0 18px 0;
  padding: 0 0 12px 0;
  border-bottom: 3px solid var(--primary);
  color: var(--heading, var(--text));
}
.section h1.home-section-title,
.section h2.home-section-title { font-size: clamp(24px, 3vw, 32px); }

.games-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
}
.game-card {
  background: var(--card); border: 1px solid var(--border); border-radius: 10px; overflow: hidden;
  transition: transform .15s, border-color .15s; color: inherit; display: block;
}
.game-card:hover { transform: translateY(-3px); border-color: var(--primary); }
.game-thumb { aspect-ratio: 3/2; background: #0d1117; overflow: hidden; }
.game-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.no-thumb { display: flex; align-items: center; justify-content: center; height: 100%; font-size: 40px; }
.game-info { padding: 12px; }
.game-info h3 { font-size: 15px; margin-bottom: 6px; color: #fff; }
.game-info .cat, .game-info .views { font-size: 12px; color: var(--muted); margin-right: 8px; }

.play-layout { display: grid; grid-template-columns: 1fr 320px; gap: 20px; max-width: 1200px; margin: 20px auto; padding: 0 16px; }
.play-frame-wrap { background: #000; border-radius: 10px; overflow: hidden; border: 2px solid var(--border); margin: 0 auto; width: 100%; }
.play-frame-wrap iframe { display: block; width: 100%; min-height: 70vh; max-height: 90vh; }
.play-sidebar { background: var(--card); border: 1px solid var(--border); border-radius: 10px; padding: 18px; }
.play-sidebar h1 { font-size: 22px; margin-bottom: 8px; }
.play-sidebar h3 { margin: 14px 0 6px; font-size: 15px; color: var(--primary); }
.play-sidebar p { color: var(--muted); font-size: 14px; }
.cat-link { display: inline-block; margin-bottom: 10px; font-size: 13px; }
.views-count { margin-top: 12px; font-size: 13px; }

.site-footer { border-top: 1px solid var(--border); padding: 22px 0; color: var(--muted); font-size: 13px; }
.footer-inner { display: flex; flex-direction: column; align-items: center; gap: 14px; text-align: center; }
.footer-nav { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px 18px; }
.footer-nav a { color: var(--muted); font-size: 13px; font-weight: 500; }
.footer-nav a:hover { color: var(--primary); }
.footer-copy { color: var(--muted); font-size: 12px; }

.nav-dropdown { position: relative; }
.nav-dropdown-toggle {
  background: transparent; border: none; cursor: pointer; padding: 0;
  color: var(--header-nav-color, var(--muted)); font-size: var(--header-nav-size, 14px);
  font-weight: var(--header-nav-weight, 600); font-family: inherit;
  display: inline-flex; align-items: center; gap: 4px;
}
.nav-dropdown-toggle:hover, .nav-dropdown-toggle.active { color: var(--header-nav-hover, var(--primary)); }
.nav-dropdown.open .nav-dropdown-toggle, .nav-dropdown:hover .nav-dropdown-toggle { color: var(--header-nav-active, var(--primary)); }
.nav-caret { font-size: 10px; }
.nav-dropdown-menu {
  display: none; position: absolute; top: calc(100% + 8px); left: 0; min-width: 200px;
  background: var(--header-bg, var(--card)); border: 1px solid var(--header-border, var(--border));
  border-radius: 8px; padding: 6px 0; box-shadow: 0 8px 24px rgba(0,0,0,.35); z-index: 60; list-style: none;
}
.nav-dropdown-menu a {
  display: block; padding: 10px 16px; color: var(--header-nav-color, var(--text));
  font-size: var(--header-nav-size, 14px); white-space: nowrap;
}
.nav-dropdown-menu a:hover, .nav-dropdown-menu a.active {
  background: rgba(23, 162, 184, .12); color: var(--header-nav-active, var(--primary));
}
.nav-dropdown:hover .nav-dropdown-menu, .nav-dropdown.open .nav-dropdown-menu { display: block; }
.content-page { background: var(--card); border: 1px solid var(--border); border-radius: 10px; padding: 24px; }
.empty { color: var(--muted); }

.search-form { display: flex; gap: 6px; flex: 1; max-width: 280px; }
.search-form input { flex: 1; padding: 8px 12px; border: 1px solid var(--border); border-radius: 6px; background: rgba(0,0,0,.2); color: inherit; font-size: 14px; }
.search-form button, .btn-search { padding: 8px 14px; background: var(--primary); color: #fff; border: none; border-radius: 6px; cursor: pointer; font-weight: 600; }
.search-page { max-width: 400px; margin: 16px 0; }
.search-results-info { color: var(--muted); margin: 12px 0; }

.collections-row { display: flex; flex-wrap: wrap; gap: 12px; }
.collection-chip { display: block; padding: 14px 18px; background: var(--card); border: 1px solid var(--border); border-radius: 8px; color: inherit; min-width: 180px; }
.collection-chip:hover { border-color: var(--primary); }
.collection-chip strong { display: block; margin-bottom: 4px; }
.collection-chip span { font-size: 12px; color: var(--muted); }

.pagination { display: flex; gap: 6px; margin-top: 20px; flex-wrap: wrap; }
.pagination a { padding: 8px 14px; background: var(--card); border: 1px solid var(--border); border-radius: 6px; color: inherit; font-size: 14px; }
.pagination a.active, .pagination a:hover { background: var(--primary); color: #fff; border-color: var(--primary); }

.auth-box, .profile-box { max-width: 420px; margin: 30px auto; background: var(--card); border: 1px solid var(--border); border-radius: 10px; padding: 28px; }
.auth-box h1, .profile-box h1 { margin-bottom: 16px; font-size: 22px; }
.auth-box label { display: block; margin: 10px 0 4px; font-size: 14px; font-weight: 600; }
.auth-box input { width: 100%; padding: 10px; border: 1px solid var(--border); border-radius: 6px; background: transparent; color: inherit; }
.auth-box button { width: 100%; margin-top: 16px; padding: 12px; background: var(--primary); color: #fff; border: none; border-radius: 6px; font-weight: 600; cursor: pointer; }
.auth-error { color: #f85149; margin-bottom: 12px; font-size: 14px; }
.auth-info { color: var(--primary); margin-bottom: 12px; font-size: 14px; background: rgba(23,162,184,.12); padding: 10px 12px; border-radius: 6px; }
.auth-link { margin-top: 14px; font-size: 14px; color: var(--muted); }
.auth-warn { color: #d29922; margin-bottom: 12px; font-size: 13px; background: rgba(210,153,34,.12); padding: 10px 12px; border-radius: 6px; }
.auth-legal { margin-top: 14px; display: flex; flex-direction: column; gap: 10px; }
.auth-check { display: flex; align-items: flex-start; gap: 10px; font-size: 13px; line-height: 1.45; font-weight: 400; cursor: pointer; }
.auth-check input { width: auto; margin-top: 3px; flex-shrink: 0; accent-color: var(--primary); }
.auth-check a { color: var(--primary); text-decoration: underline; }
.auth-check a:hover { opacity: .85; }

.cookie-consent {
  position: fixed; inset: 0; z-index: 1300; pointer-events: none;
}
.cookie-consent:not([hidden]) { pointer-events: auto; }
.cookie-consent-bar {
  position: fixed; left: 0; right: 0; bottom: 0;
  background: var(--card); border-top: 1px solid var(--border);
  box-shadow: 0 -8px 28px rgba(0,0,0,.22);
  padding: 18px 0;
}
.cookie-consent-bar-inner {
  display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 16px 24px;
}
.cookie-consent-copy { flex: 1 1 320px; min-width: 0; }
.cookie-consent-copy strong { display: block; font-size: 16px; margin-bottom: 6px; }
.cookie-banner-text { margin: 0 0 8px; font-size: 14px; line-height: 1.55; color: var(--muted); }
.cookie-consent-links { margin: 0; font-size: 13px; }
.cookie-consent-links a { color: var(--primary); font-weight: 600; }
.cookie-consent-actions {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: flex-end;
  flex: 1 1 280px;
}
.cookie-btn {
  border: none; border-radius: 6px; padding: 10px 14px; font-size: 13px; font-weight: 600;
  cursor: pointer; white-space: nowrap;
}
.cookie-btn-primary { background: var(--primary); color: #fff; }
.cookie-btn-secondary { background: transparent; color: inherit; border: 1px solid var(--border); }
.cookie-btn-ghost { background: transparent; color: var(--muted); border: 1px solid var(--border); }
.cookie-btn:hover { filter: brightness(1.05); }

.cookie-consent-modal {
  position: fixed; inset: 0; background: rgba(0,0,0,.55);
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
.cookie-consent-modal[hidden] { display: none !important; }
.cookie-consent-panel {
  position: relative; width: min(520px, 100%); max-height: min(90vh, 720px); overflow: auto;
  background: var(--card); border: 1px solid var(--border); border-radius: 12px;
  padding: 24px; box-shadow: 0 16px 40px rgba(0,0,0,.28);
}
.cookie-consent-panel h2 { margin: 0 0 10px; font-size: 20px; }
.cookie-consent-panel-intro { margin: 0 0 16px; color: var(--muted); font-size: 14px; line-height: 1.5; }
.cookie-consent-close {
  position: absolute; top: 10px; right: 12px; border: none; background: transparent;
  color: var(--muted); font-size: 28px; line-height: 1; cursor: pointer;
}
.cookie-pref-item {
  border: 1px solid var(--border); border-radius: 8px; padding: 12px 14px; margin-bottom: 10px;
}
.cookie-pref-item p { margin: 6px 0 0; font-size: 13px; color: var(--muted); line-height: 1.45; }
.cookie-pref-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.cookie-pref-badge { font-size: 11px; font-weight: 700; text-transform: uppercase; color: var(--primary); }
.cookie-pref-toggle { display: flex; align-items: center; gap: 10px; cursor: pointer; font-weight: 600; }
.cookie-pref-toggle input { width: auto; accent-color: var(--primary); }
.cookie-consent-panel-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; margin-top: 16px; }

.footer-cookie-btn {
  background: none; border: none; padding: 0; color: var(--muted); font-size: 13px; font-weight: 500;
  cursor: pointer; font-family: inherit;
}
.footer-cookie-btn:hover { color: var(--primary); }

body.cookie-consent-visible .site-footer { padding-bottom: 120px; }

@media (max-width: 720px) {
  .cookie-consent-actions { width: 100%; flex-direction: column; align-items: stretch; }
  .cookie-btn { width: 100%; }
  .cookie-consent-panel-actions { flex-direction: column; }
  .cookie-consent-panel-actions .cookie-btn { width: 100%; }
}

.profile-panel { max-width: 900px; }
.profile-header { margin-bottom: 20px; }
.profile-meta { color: var(--muted); font-size: 14px; margin-bottom: 4px; }
.profile-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 24px; }
.profile-stat { background: rgba(0,0,0,.2); border: 1px solid var(--border); border-radius: 8px; padding: 14px; text-align: center; }
.profile-stat strong { display: block; font-size: 24px; color: var(--primary); }
.profile-stat span { font-size: 12px; color: var(--muted); }
.profile-section-title { font-size: 18px; margin: 22px 0 10px; color: var(--heading, var(--text)); border-bottom: 2px solid var(--primary); padding-bottom: 6px; }

.scores-table { width: 100%; border-collapse: collapse; margin-top: 12px; font-size: 14px; }
.scores-table th, .scores-table td { padding: 8px; border-bottom: 1px solid var(--border); text-align: left; }

.score-submit { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--border); }
.score-submit input { width: 100%; padding: 8px; margin-bottom: 8px; border: 1px solid var(--border); border-radius: 4px; background: transparent; color: inherit; }
.score-submit button { padding: 8px 16px; background: var(--primary); color: #fff; border: none; border-radius: 4px; cursor: pointer; }
.score-msg { font-size: 13px; color: var(--primary); margin-top: 6px; }
.leaderboard { margin-top: 16px; }
.leaderboard ol { padding-left: 20px; font-size: 14px; line-height: 1.8; }
.leaderboard li { display: flex; justify-content: space-between; gap: 10px; }
.section-desc { color: var(--muted); margin-bottom: 16px; }

@media (max-width: 600px) {
  .profile-stats { grid-template-columns: 1fr; }
}

@media (max-width: 900px) {
  .header-inner { flex-wrap: wrap; gap: 0; }
  .header-bar { width: 100%; }
  .nav-toggle { display: flex; }

  .header-menu {
    position: fixed; top: 0; right: 0; width: min(320px, 88vw); height: 100vh; height: 100dvh;
    flex-direction: column; align-items: stretch; justify-content: flex-start;
    gap: 0; padding: calc(var(--header-padding-y, 14px) + 56px) 20px 24px;
    background: var(--header-bg, var(--card)); border-left: 1px solid var(--header-border, var(--border));
    box-shadow: -8px 0 32px rgba(0, 0, 0, .35); z-index: 100;
    transform: translateX(100%); transition: transform .25s ease; overflow-y: auto;
  }
  body.nav-open .header-menu { transform: translateX(0); }

  .search-form { max-width: 100%; width: 100%; order: 0; margin-bottom: 16px; flex-shrink: 0; }
  .main-nav { flex-direction: column; align-items: stretch; gap: 0; width: 100%; flex-wrap: nowrap; }
  .main-nav a {
    padding: 14px 4px; font-size: max(16px, var(--header-nav-size, 14px));
    border-bottom: 1px solid var(--header-border, var(--border)); white-space: normal;
  }
  .main-nav a.active, .main-nav a.nav-profile { font-weight: 700; }

  .nav-dropdown { width: 100%; }
  .nav-dropdown-toggle { width: 100%; justify-content: space-between; padding: 14px 4px; font-size: max(16px, var(--header-nav-size, 14px)); border-bottom: 1px solid var(--header-border, var(--border)); }
  .nav-dropdown-menu {
    position: static; display: none; box-shadow: none; border: none; border-radius: 0;
    padding: 0 0 8px 12px; background: transparent; min-width: 0;
  }
  .nav-dropdown.open .nav-dropdown-menu { display: block; }
  .nav-dropdown:hover .nav-dropdown-menu { display: none; }
  .nav-dropdown.open:hover .nav-dropdown-menu { display: block; }
  .nav-dropdown-menu a { padding: 10px 4px; border-bottom: 1px solid var(--header-border, var(--border)); }
}
