/* ============================================================
   PLAYORA — HTML5 게임 포털 스타일시트
   CrazyGames.com 을 벤치마킹한 다크 테마 게임 허브
   ============================================================ */

:root {
  --bg: #0e131a;
  --bg-elevated: #151b24;
  --bg-card: #1b232e;
  --bg-card-hover: #232d3a;
  --sidebar-bg: #11161d;
  --header-bg: #0e131aee;
  --border: #262f3b;
  --text: #f2f4f7;
  --text-muted: #9aa5b3;
  --text-dim: #6b7684;
  --accent: #8b5cf6;
  --accent-2: #6d28d9;
  --accent-grad: linear-gradient(135deg, #8b5cf6, #6366f1);
  --success: #22c55e;
  --danger: #ef4444;
  --radius: 12px;
  --radius-sm: 8px;
  --sidebar-w: 72px;
  --header-h: 64px;
  --max-w: 1600px;
  font-size: 16px;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Pretendard", "Noto Sans KR", "Apple SD Gothic Neo", Roboto, Arial, sans-serif;
  scroll-behavior: smooth;
}

a { color: inherit; text-decoration: none; }
ul { list-style: none; margin: 0; padding: 0; }
button { font-family: inherit; cursor: pointer; }
img { max-width: 100%; display: block; }

/* ---------- Layout shell ---------- */
.app-shell {
  display: flex;
  min-height: 100vh;
}

/* ---------- Header ---------- */
.site-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-h);
  background: var(--header-bg);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 20px;
  z-index: 100;
}

.sidebar-toggle {
  background: transparent;
  border: none;
  color: var(--text-muted);
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
}
.sidebar-toggle:hover { background: var(--bg-card); color: var(--text); }

.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 800;
  font-size: 20px;
  letter-spacing: -0.5px;
  white-space: nowrap;
}
.logo .logo-mark {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: var(--accent-grad);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}
.logo .logo-text-sub { color: var(--accent); }

.search-form {
  flex: 1;
  max-width: 640px;
  margin: 0 auto;
  position: relative;
}
.search-form input {
  width: 100%;
  height: 42px;
  border-radius: 21px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text);
  padding: 0 44px 0 18px;
  font-size: 14px;
  outline: none;
  transition: border-color .15s;
}
.search-form input:focus { border-color: var(--accent); }
.search-form button {
  position: absolute;
  right: 4px;
  top: 4px;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
}
.search-results {
  position: absolute;
  top: 50px;
  left: 0;
  right: 0;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  max-height: 420px;
  overflow-y: auto;
  display: none;
  box-shadow: 0 20px 40px rgba(0,0,0,.5);
}
.search-results.open { display: block; }
.search-results a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
}
.search-results a:last-child { border-bottom: none; }
.search-results a:hover { background: var(--bg-card); }
.search-results .thumb {
  width: 44px; height: 44px; border-radius: 8px; overflow: hidden; flex-shrink: 0;
  display:flex;align-items:center;justify-content:center;font-size:20px;
}
.search-results .thumb img { width: 100%; height: 100%; object-fit: cover; }
.search-results .meta strong { display: block; font-size: 14px; }
.search-results .meta span { font-size: 12px; color: var(--text-dim); }
.search-empty { padding: 16px; color: var(--text-dim); font-size: 13px; }

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: var(--bg-card);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
}
.icon-btn:hover { background: var(--bg-card-hover); color: var(--text); }
.btn-login {
  height: 40px;
  padding: 0 20px;
  border-radius: 20px;
  border: none;
  background: var(--accent-grad);
  color: #fff;
  font-weight: 700;
  font-size: 14px;
}
.btn-login:hover { filter: brightness(1.1); }

/* ---------- Sidebar ---------- */
.site-sidebar {
  position: fixed;
  top: var(--header-h);
  left: 0;
  bottom: 0;
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  z-index: 90;
  padding: 10px 0;
  transition: width .18s ease;
}
.site-sidebar.expanded { width: 220px; }
.site-sidebar::-webkit-scrollbar { width: 6px; }
.site-sidebar::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 0;
  margin: 2px 10px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 11px;
  justify-content: center;
  flex-direction: column;
  gap: 4px;
  text-align: center;
}
.site-sidebar.expanded .sidebar-link {
  flex-direction: row;
  justify-content: flex-start;
  padding: 10px 14px;
  font-size: 13px;
}
.sidebar-link .ic { font-size: 18px; }
.sidebar-link:hover { background: var(--bg-card); color: var(--text); }
.sidebar-link.active { background: var(--bg-card); color: var(--accent); }
.sidebar-sep { height: 1px; background: var(--border); margin: 8px 16px; }

/* ---------- Main content ---------- */
.site-main {
  margin-left: var(--sidebar-w);
  margin-top: var(--header-h);
  flex: 1;
  padding: 20px 24px 60px;
  max-width: 100%;
  width: calc(100% - var(--sidebar-w));
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 30px 0 14px;
}
.section-title h2 {
  font-size: 19px;
  margin: 0;
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: 8px;
}
.section-title .subtitle { color: var(--text-dim); font-size: 13px; font-weight: 400; margin-top: 2px; }
.section-title a.see-all { font-size: 13px; color: var(--text-muted); font-weight: 600; }
.section-title a.see-all:hover { color: var(--accent); }

/* ---------- Hero category chips (top of homepage) ---------- */
.hero-chip-row {
  display: flex;
  gap: 14px;
  overflow-x: auto;
  padding-bottom: 6px;
  scrollbar-width: none;
}
.hero-chip-row::-webkit-scrollbar { display: none; }
.hero-chip {
  min-width: 220px;
  height: 100px;
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  font-weight: 800;
  font-size: 15px;
  color: #fff;
  position: relative;
  overflow: hidden;
  flex-shrink: 0;
  text-shadow: 0 1px 4px rgba(0,0,0,.4);
}
.hero-chip .chip-emoji {
  position: absolute;
  top: 12px;
  right: 14px;
  font-size: 30px;
  opacity: .9;
}
.hero-chip:hover { transform: translateY(-3px); transition: transform .15s; }

/* ---------- Game rows (horizontal scroll) ---------- */
.game-row {
  display: flex;
  gap: 14px;
  overflow-x: auto;
  padding-bottom: 10px;
  scroll-snap-type: x proximity;
  scrollbar-width: none;
}
.game-row::-webkit-scrollbar { display: none; }

/* ---------- Grid (category / search pages) ---------- */
.game-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 16px;
}

.game-card {
  flex-shrink: 0;
  width: 168px;
  scroll-snap-align: start;
}
.game-grid .game-card { width: auto; }

.game-card .thumb-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg-card);
  margin-bottom: 8px;
  border: 1px solid var(--border);
  transition: transform .15s, box-shadow .15s;
}
.game-card:hover .thumb-wrap {
  transform: translateY(-4px) scale(1.02);
  box-shadow: 0 14px 30px rgba(0,0,0,.5);
  border-color: var(--accent);
}
.game-card .thumb-wrap img {
  width: 100%; height: 100%; object-fit: cover;
}
.game-card .thumb-emoji {
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  font-size: 52px;
}
.game-card .badge {
  position: absolute;
  top: 8px;
  left: 8px;
  background: rgba(0,0,0,.55);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 20px;
  backdrop-filter: blur(4px);
}
.game-card .badge.new { background: var(--success); }
.game-card .title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.game-card .cats {
  font-size: 11px;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---------- Breadcrumb ---------- */
.breadcrumb {
  font-size: 13px;
  color: var(--text-dim);
  margin-bottom: 16px;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.breadcrumb a:hover { color: var(--accent); }

/* ---------- Game play page ---------- */
.play-layout {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 24px;
  align-items: start;
}
.play-stage {
  background: #000;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  position: relative;
}
.play-stage .stage-frame {
  width: 100%;
  aspect-ratio: 16/10;
  display: block;
  border: none;
  background: #05070a;
}
.play-stage.custom-game .stage-frame {
  aspect-ratio: auto;
  height: 560px;
}
.game-title-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 16px 0 6px;
  flex-wrap: wrap;
  gap: 10px;
}
.game-title-bar h1 {
  font-size: 24px;
  margin: 0;
}
.tag-list { display: flex; gap: 8px; flex-wrap: wrap; }
.tag-pill {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 12px;
  padding: 5px 12px;
  border-radius: 20px;
}
.tag-pill:hover { color: var(--accent); border-color: var(--accent); }

.play-btn-fullscreen {
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text);
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
}
.play-btn-fullscreen:hover { background: var(--bg-card-hover); }

.description-box {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-top: 18px;
  line-height: 1.7;
  color: var(--text-muted);
  font-size: 14px;
}
.description-box h2 { font-size: 15px; color: var(--text); margin: 0 0 8px; }
.description-box + .description-box { margin-top: 12px; }

.sidebar-widget {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
}
.sidebar-widget h3 { font-size: 14px; margin: 0 0 12px; color: var(--text-dim); text-transform: uppercase; letter-spacing: .5px; }
.info-row { display: flex; justify-content: space-between; font-size: 13px; padding: 6px 0; border-bottom: 1px solid var(--border); color: var(--text-muted); }
.info-row:last-child { border-bottom: none; }
.info-row strong { color: var(--text); font-weight: 600; }

/* ---------- Category hero banner ---------- */
.category-hero {
  border-radius: var(--radius);
  padding: 30px 26px;
  margin-bottom: 24px;
  color: #fff;
}
.category-hero h1 { font-size: 26px; margin: 0 0 6px; }
.category-hero p { margin: 0; opacity: .9; font-size: 14px; max-width: 640px; }

/* ---------- Footer ---------- */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 30px 24px 40px;
  color: var(--text-dim);
  font-size: 13px;
  margin-top: 40px;
}
.footer-cols {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 20px;
  max-width: var(--max-w);
  margin-bottom: 24px;
}
.footer-cols h4 { color: var(--text); font-size: 13px; margin: 0 0 10px; }
.footer-cols a { display: block; padding: 4px 0; color: var(--text-dim); }
.footer-cols a:hover { color: var(--accent); }
.footer-bottom { border-top: 1px solid var(--border); padding-top: 16px; }

/* ---------- Section colors for category hero (utility classes) ---------- */
.grad-action { background: linear-gradient(135deg,#ff512f,#dd2476); }
.grad-arcade { background: linear-gradient(135deg,#f7971e,#c2185b); }
.grad-puzzle { background: linear-gradient(135deg,#00c6ff,#0072ff); }
.grad-board { background: linear-gradient(135deg,#42e695,#3bb2b8); }
.grad-racing { background: linear-gradient(135deg,#ff6a00,#ee0979); }
.grad-adventure { background: linear-gradient(135deg,#7f00ff,#e100ff); }
.grad-multiplayer { background: linear-gradient(135deg,#11998e,#38ef7d); }
.grad-shooting { background: linear-gradient(135deg,#485563,#29323c); }
.grad-sports { background: linear-gradient(135deg,#11998e,#38ef7d); }
.grad-strategy { background: linear-gradient(135deg,#614385,#516395); }

/* ---------- Ad slots ---------- */
.ad-slot {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-elevated);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  color: var(--text-dim);
  font-size: 12px;
  letter-spacing: .5px;
  margin: 22px auto;
  overflow: hidden;
  position: relative;
}
.ad-slot::before {
  content: attr(data-label);
}
.ad-slot.ad-leaderboard { width: 100%; max-width: 728px; height: 90px; }
.ad-slot.ad-rectangle { width: 300px; height: 250px; max-width: 100%; }
.ad-slot.ad-inline { width: 100%; height: 100px; }
.ad-slot.ad-sidebar { width: 100%; height: 250px; margin: 0 0 16px; }
@media (max-width: 860px) {
  .ad-slot.ad-leaderboard { height: 100px; }
}

/* ---------- Mobile ---------- */
@media (max-width: 860px) {
  .site-sidebar { transform: translateX(-100%); transition: transform .2s; width: 220px; }
  .site-sidebar.expanded { transform: translateX(0); }
  .site-main { margin-left: 0; width: 100%; padding: 16px; }
  .logo .logo-text { display: none; }
  .play-layout { grid-template-columns: 1fr; }
  .play-stage.custom-game .stage-frame { height: 420px; }
  .header-actions .icon-btn { display: none; }
}

/* ---------- Utility ---------- */
.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0,0,0,0); white-space: nowrap;
}
.overlay-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,.5);
  z-index: 80; display: none;
}
.overlay-backdrop.show { display: block; }
