/* Young's Games — 밤의 오락실 간판. 바탕은 보랏빛 밤, 빛은 분홍과 하늘색 네온 두 가지 */
:root {
  --night: #140f2b;
  --night-2: #1d1740;
  --panel: #221b4a;
  --line: #3b3275;
  --pink: #ff5bd6;
  --cyan: #4cf3ff;
  --gold: #ffd84d;
  --text: #f1edff;
  --dim: #a79fd6;
  --display: 'Black Han Sans', 'Apple SD Gothic Neo', sans-serif;
  --body: 'IBM Plex Sans KR', 'Apple SD Gothic Neo', 'Malgun Gothic', sans-serif;
  --rail: 200px;
  --radius-tile: 14px;
  --glow-pink: 0 0 4px #fff3, 0 0 12px var(--pink), 0 0 28px #ff5bd680;
  --glow-cyan: 0 0 4px #fff4, 0 0 12px var(--cyan), 0 0 26px #4cf3ff70;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { background: var(--night); }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font: 400 16px/1.6 var(--body);
  background:
    radial-gradient(1200px 600px at 85% -10%, #3a1f6b66, transparent 60%),
    radial-gradient(900px 500px at -10% 110%, #0f3b5c55, transparent 60%),
    var(--night);
  background-attachment: fixed;
}
/* 바닥에 깔린 격자 — 오락실 바닥 타일 */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(#ffffff07 1px, transparent 1px),
    linear-gradient(90deg, #ffffff07 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: linear-gradient(to bottom, transparent, #000 40%);
  z-index: -1;
}
img { display: block; max-width: 100%; }
a { color: inherit; }
button, input { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--cyan); outline-offset: 3px; border-radius: 6px; }

.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: 12px; top: -48px; padding: 8px 14px; background: var(--cyan); color: var(--night); border-radius: 8px; z-index: 10; }
.skip:focus { top: 12px; }

/* ── 머리: 간판, 검색, 로그인 ── */
.top {
  position: sticky;
  top: 0;
  z-index: 5;
  display: grid;
  grid-template-columns: minmax(var(--rail), max-content) minmax(0, 1fr) auto;
  align-items: center;
  gap: 24px;
  padding: 14px 28px;
  background: #140f2bd9;
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.sign { text-decoration: none; display: inline-flex; flex-direction: column; line-height: 1; width: max-content; }
.sign-ko {
  font: 400 30px/1 var(--display);
  letter-spacing: 0.03em;
  color: #ffe9fa;
  text-shadow: var(--glow-pink);
  animation: power-on 1.4s steps(1, end) 0.2s both;
}
/* 간판에 불이 들어오는 순간. 처음 한 번만 깜빡이고 켜진다 */
@keyframes power-on {
  0% { opacity: 0.12; text-shadow: none; }
  12% { opacity: 1; }
  18% { opacity: 0.2; text-shadow: none; }
  30% { opacity: 1; }
  36% { opacity: 0.35; text-shadow: none; }
  48%, 100% { opacity: 1; }
}

.search {
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 520px;
  width: 100%;
  padding: 0 16px;
  height: 44px;
  border-radius: 999px;
  background: var(--night-2);
  border: 1px solid var(--line);
  color: var(--dim);
}
.search:focus-within { border-color: var(--cyan); box-shadow: 0 0 0 3px #4cf3ff26; color: var(--cyan); }
.search input { flex: 1; min-width: 0; border: 0; background: none; outline: none; height: 100%; color: var(--text); }
.search input::placeholder { color: #8a82bd; }

.account { display: flex; align-items: center; gap: 12px; justify-content: flex-end; min-height: 44px; }
.me { display: inline-flex; align-items: center; gap: 8px; }
.me img { border-radius: 50%; box-shadow: 0 0 0 2px var(--line); }
.me-name { max-width: 10em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.gsi-slot { min-height: 40px; display: flex; align-items: center; }
.gsi-slot.nudge { animation: nudge 0.5s ease 2; border-radius: 999px; }
@keyframes nudge { 50% { box-shadow: 0 0 0 4px var(--cyan); } }

/* ── 왼쪽 기기 목록 (기기별로 나눈 줄) ── */
.layout { display: grid; grid-template-columns: var(--rail) minmax(0, 1fr); gap: 24px; padding: 0 28px 64px; }
.rail { position: sticky; top: 73px; align-self: start; padding-top: 24px; }
.rail-title { margin: 0 0 8px 12px; font-size: 13px; color: var(--dim); }
.rail ul { list-style: none; margin: 0 0 24px; padding: 0; display: grid; gap: 4px; }
.rail button {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border: 0;
  border-radius: 10px;
  background: none;
  cursor: pointer;
  font-weight: 500;
  color: var(--dim);
  text-align: left;
}
.rail svg { width: 22px; height: 22px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linejoin: round; stroke-linecap: round; }
.rail button:hover { color: var(--text); background: #ffffff0a; }
.rail button[aria-pressed='true'] { color: var(--text); background: var(--panel); box-shadow: inset 3px 0 0 var(--cyan); }
.rail button[aria-pressed='true'] svg { color: var(--cyan); filter: drop-shadow(0 0 6px #4cf3ffaa); }
.rail [data-view][aria-pressed='true'] svg { color: var(--gold); fill: var(--gold); filter: drop-shadow(0 0 6px #ffd84daa); }

main { padding-top: 24px; min-width: 0; outline: none; }

/* ── 장르 (장르별로 나눈 칩) ── */
.genres { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 28px; }
.chip {
  padding: 7px 15px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--night-2);
  color: var(--dim);
  cursor: pointer;
  font-size: 15px;
}
.chip:hover { color: var(--text); border-color: #5b4fa8; }
.chip[aria-pressed='true'] { color: #2a0e25; background: var(--pink); border-color: var(--pink); box-shadow: 0 0 14px #ff5bd680; font-weight: 700; }

/* ── 묶음 제목 ── */
.block { margin-bottom: 44px; }
.h { margin: 0 0 16px; font: 400 24px/1.25 var(--display); letter-spacing: 0.01em; }
.h.small { font-size: 18px; margin-top: 28px; }
.h-sub { color: var(--dim); }
.count { font: 500 15px var(--body); color: var(--dim); margin-left: 4px; }

/* ── 타일 격자 ── */
.grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(176px, 1fr));
  gap: 22px 18px;
}
.tile a { display: block; text-decoration: none; border-radius: var(--radius-tile); }
.thumb {
  position: relative;
  display: block;
  aspect-ratio: 1;
  border-radius: var(--radius-tile);
  overflow: hidden;
  background: var(--panel);
  border: 1px solid var(--line);
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb-blank { display: grid; place-items: center; width: 100%; height: 100%; font: 400 64px var(--display); color: var(--accent); text-shadow: 0 0 18px var(--accent); }
.tile a:hover .thumb, .tile a:focus-visible .thumb {
  border-color: var(--cyan);
  box-shadow: 0 0 0 1px var(--cyan), 0 0 22px #4cf3ff55;
  transform: translateY(-3px);
}
.fav-dot { position: absolute; top: 8px; right: 8px; width: 28px; height: 28px; display: grid; place-items: center; border-radius: 50%; background: #140f2bcc; color: var(--gold); font-size: 15px; text-shadow: 0 0 6px var(--gold); }
.name { display: block; margin-top: 10px; font-weight: 700; font-size: 16px; line-height: 1.35; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.visits { position: absolute; right: 8px; bottom: 8px; padding: 2px 9px; border-radius: 999px; background: #140f2bcc; font-size: 12px; color: var(--text); }

/* 방문 순위 — 순위 숫자는 타일 왼쪽 아래에 네온 관으로 걸린다 */
.ranked { position: relative; padding-left: 34px; }
.rank {
  position: absolute;
  left: -4px;
  bottom: 22px;
  z-index: 1;
  font: 400 76px/0.8 var(--display);
  color: var(--night);
  -webkit-text-stroke: 2px var(--gold);
  text-shadow: 0 0 14px #ffd84d88;
  pointer-events: none;
}
.ranked:nth-child(n + 4) .rank { -webkit-text-stroke-color: var(--cyan); text-shadow: 0 0 12px #4cf3ff70; }

/* ── 빈 화면, 안내 ── */
.empty, .login-prompt {
  padding: 28px;
  border: 1px dashed var(--line);
  border-radius: var(--radius-tile);
  color: var(--dim);
  max-width: 560px;
}
.empty p, .login-prompt p { margin: 0 0 14px; }
.empty-title { color: var(--text); font-weight: 700; font-size: 18px; }
.loading { color: var(--dim); }

/* ── 단추 ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  height: 48px;
  padding: 0 22px;
  border-radius: 12px;
  border: 1px solid transparent;
  text-decoration: none;
  font-weight: 700;
  cursor: pointer;
}
.btn.small { height: 38px; padding: 0 14px; font-size: 14px; font-weight: 500; }
.btn.ghost { background: transparent; border-color: var(--line); color: var(--text); }
.btn.ghost:hover { border-color: var(--cyan); }
.btn:disabled { opacity: 0.55; cursor: default; }

/* ── 게임 상세 ── */
.back { display: inline-block; margin-bottom: 18px; color: var(--dim); text-decoration: none; }
.back:hover { color: var(--text); }
.detail-top { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(300px, 1fr); gap: 28px; align-items: start; }
.hero {
  aspect-ratio: 16 / 9;
  border-radius: 18px;
  overflow: hidden;
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: 0 0 40px #00000066;
}
.hero img { width: 100%; height: 100%; object-fit: cover; }
.panel { display: flex; flex-direction: column; }
.title { margin: 0; font: 400 44px/1.1 var(--display); text-shadow: 0 0 22px color-mix(in srgb, var(--accent) 55%, transparent); }
.title-en { margin: 6px 0 0; color: var(--dim); font-size: 15px; }
.by { margin: 14px 0 0; color: var(--dim); }
.by strong { color: var(--text); }
.summary { margin: 12px 0 0; }
.actions { display: grid; grid-template-columns: 1fr auto; gap: 10px; margin-top: 24px; }
.btn.play {
  height: 64px;
  font-size: 22px;
  font-family: var(--display);
  font-weight: 400;
  letter-spacing: 0.02em;
  color: #052327;
  background: var(--cyan);
  box-shadow: 0 0 0 1px #b9fbff inset, 0 0 26px #4cf3ff88;
}
.btn.play:hover { background: #8af8ff; box-shadow: 0 0 0 1px #fff inset, 0 0 36px #4cf3ffbb; }
.btn.fav { height: 64px; background: var(--night-2); border-color: var(--line); color: var(--text); }
.btn.fav span { font-size: 20px; color: var(--dim); }
.btn.fav[aria-pressed='true'] { border-color: var(--gold); }
.btn.fav[aria-pressed='true'] span { color: var(--gold); text-shadow: 0 0 8px var(--gold); }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); margin: 22px 0 0; border: 1px solid var(--line); border-radius: 12px; }
.stats div { padding: 12px 14px; }
.stats div + div { border-left: 1px solid var(--line); }
.stats dt { font-size: 13px; color: var(--dim); }
.stats dd { margin: 2px 0 0; font: 400 24px/1.2 var(--display); }

.detail-body { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(300px, 1fr); gap: 28px; margin-top: 40px; }
.desc { margin: 0; max-width: 40em; line-height: 1.75; }
.facts { margin: 0; display: grid; gap: 14px; }
.facts dt { font-size: 13px; color: var(--dim); margin-bottom: 6px; }
.facts dd { margin: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.tag { padding: 4px 12px; border-radius: 999px; border: 1px solid var(--line); text-decoration: none; font-size: 14px; }
.tag:hover { border-color: var(--pink); color: #ffd2f4; }
.controls { margin: 0; padding-left: 18px; color: var(--dim); }
.controls li + li { margin-top: 4px; }

/* ── 알림 ── */
.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translate(-50%, 20px);
  padding: 12px 20px;
  border-radius: 12px;
  background: var(--panel);
  border: 1px solid var(--cyan);
  box-shadow: 0 0 20px #4cf3ff44;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 20;
}
.toast.on { opacity: 1; transform: translate(-50%, 0); }

/* ── 작은 화면: 기기 목록이 위쪽 가로 줄로 ── */
@media (max-width: 860px) {
  .top { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: 'sign account' 'search search'; gap: 12px 16px; padding: 12px 16px; }
  .sign { grid-area: sign; }
  .account { grid-area: account; }
  .search { grid-area: search; max-width: none; }
  .sign-ko { font-size: 24px; }
  .me-name { display: none; }
  .layout { grid-template-columns: minmax(0, 1fr); gap: 0; padding: 0 16px 48px; }
  .rail { position: static; padding-top: 14px; display: flex; gap: 6px; overflow-x: auto; min-width: 0; }
  .rail-title { display: none; }
  .rail ul { display: flex; margin: 0; gap: 6px; }
  .rail button { padding: 8px 12px; white-space: nowrap; }
  .rail button[aria-pressed='true'] { box-shadow: inset 0 -2px 0 var(--cyan); }
  main { padding-top: 16px; }
  .genres { flex-wrap: nowrap; overflow-x: auto; margin: 0 -16px 22px; padding: 0 16px 4px; }
  .chip { flex: none; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 18px 12px; }
  .rank { font-size: 60px; bottom: 22px; }
  .ranked { padding-left: 26px; }
  .detail-top, .detail-body { grid-template-columns: minmax(0, 1fr); }
  .title { font-size: 34px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
