:root {
  --bg: #f6f5fb;
  --surface: #ffffff;
  --surface-2: #f0eef8;
  --text: #1d1b26;
  --text-2: #5f5b70;
  --text-3: #8f8aa3;
  --line: #e4e1ee;
  --primary: #7c5cff;
  --primary-press: #6747f0;
  --primary-soft: #eee9ff;
  --on-primary: #ffffff;
  --good: #14a46c;
  --good-soft: #e3f6ee;
  --bad: #e5484d;
  --bad-soft: #fdeaea;
  --shadow: 0 1px 2px rgba(30, 20, 60, .06), 0 6px 20px rgba(30, 20, 60, .06);
  --radius: 18px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121118;
    --surface: #1c1a24;
    --surface-2: #26232f;
    --text: #f2f0f8;
    --text-2: #b9b4ca;
    --text-3: #847f96;
    --line: #2f2c3a;
    --primary: #9a82ff;
    --primary-press: #876cff;
    --primary-soft: #2b2541;
    --on-primary: #14111f;
    --good: #3ccf91;
    --good-soft: #17322a;
    --bad: #ff6b70;
    --bad-soft: #3a1f22;
    --shadow: none;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #121118;
  --surface: #1c1a24;
  --surface-2: #26232f;
  --text: #f2f0f8;
  --text-2: #b9b4ca;
  --text-3: #847f96;
  --line: #2f2c3a;
  --primary: #9a82ff;
  --primary-press: #876cff;
  --primary-soft: #2b2541;
  --on-primary: #14111f;
  --good: #3ccf91;
  --good-soft: #17322a;
  --bad: #ff6b70;
  --bad-soft: #3a1f22;
  --shadow: none;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Pretendard Variable", Pretendard, -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100dvh;
  padding-bottom: env(safe-area-inset-bottom);
}

button, input { font: inherit; color: inherit; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; }
a { color: inherit; text-decoration: none; }

.container {
  max-width: 720px;
  margin: 0 auto;
  padding: 8px 16px 48px;
}

/* 상단바 */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 720px;
  width: 100%;
  margin: 0 auto;
}
.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 800;
  font-size: 19px;
  letter-spacing: -0.02em;
}

.logo img { border-radius: 8px; }

.top-tabs { display: flex; gap: 4px; padding: 4px; border-radius: 999px; background: var(--surface-2); }
.top-tabs a {
  height: 32px;
  padding: 0 16px;
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 700;
  color: var(--text-3);
}
.top-tabs a[aria-current="page"] { background: var(--surface); color: var(--text); box-shadow: 0 1px 4px rgba(30, 20, 60, .12); }
.games-home .hero { padding-bottom: 12px; }
.games-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
@media (min-width: 640px) { .games-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }

/* 홈 */
.hero { padding: 20px 2px 16px; }
.hero h1 {
  margin: 0 0 4px;
  font-size: 26px;
  line-height: 1.3;
  letter-spacing: -0.03em;
}
.hero p { margin: 0; color: var(--text-2); }

.search {
  width: 100%;
  height: 48px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  outline: none;
  font-size: 16px;
}
.search:focus { border-color: var(--primary); }

.chips {
  display: flex;
  gap: 8px;
  margin: 12px -16px 18px;
  padding: 0 16px;
  overflow-x: auto;
  scrollbar-width: none;
}
.chips::-webkit-scrollbar { display: none; }
/* 휴대폰: 옆으로 밀어서 넘김, 오른쪽 끝을 흐리게 해서 더 있다는 표시 */
@media (max-width: 639px) {
  .chips { -webkit-mask-image: linear-gradient(90deg, #000 85%, transparent); mask-image: linear-gradient(90deg, #000 85%, transparent); padding-right: 40px; }
}
/* 넓은 화면: 여러 줄로 모두 보이게 */
@media (min-width: 640px) {
  .chips { flex-wrap: wrap; overflow: visible; }
}
.chip {
  flex: none;
  height: 36px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-2);
  font-size: 14px;
  font-weight: 600;
}
.chip[aria-pressed="true"] {
  background: var(--text);
  border-color: var(--text);
  color: var(--bg);
}

.grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}
@media (min-width: 640px) {
  .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

.card {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  border: 1px solid var(--line);
  transition: transform .15s ease;
}
.card:active { transform: scale(.98); }
.cover {
  position: relative;
  aspect-ratio: 4 / 3;
  display: grid;
  place-items: center;
  background: var(--surface-2);
  overflow: hidden;
}
.cover img { width: 100%; height: 100%; object-fit: cover; }
/* 사진 표지: 그림 표지·국기 표지와 같은 틀 (카테고리 바탕색 + 안쪽에 둥근 사진) */
.framed {
  position: absolute;
  inset: 0;
  padding: 38px 14px 12px;
}
.cover .framed img.inset {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 12px;
  box-shadow: 0 4px 14px rgba(30, 20, 60, .18);
  background: rgba(255, 255, 255, .5);
}
.new-tag {
  position: absolute;
  right: 8px;
  top: 8px;
  padding: 2px 7px;
  border-radius: 999px;
  background: #ff4f5e;
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .02em;
}
.rank-no {
  position: absolute;
  left: 10px;
  bottom: 4px;
  font-size: 40px;
  font-weight: 900;
  line-height: 1;
  color: #fff;
  -webkit-text-stroke: 2px rgba(29, 27, 38, .55);
  text-shadow: 0 2px 8px rgba(0, 0, 0, .25);
}

/* 홈 구역 */
.home-sec { margin-bottom: 26px; }
.sec-title { margin: 0 0 10px; font-size: 18px; font-weight: 800; letter-spacing: -0.02em; }
.row {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 44%;
  gap: 12px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  margin: 0 -16px;
  padding: 2px 16px 8px;
  scrollbar-width: none;
}
.row::-webkit-scrollbar { display: none; }
.row > .card { scroll-snap-align: start; }
/* 넓은 화면: 옆으로 밀지 않아도 되게 4칸씩 */
@media (min-width: 640px) {
  .row { grid-auto-flow: row; grid-template-columns: repeat(4, minmax(0, 1fr)); overflow: visible; margin: 0; padding: 0; }
}
.today-card {
  display: grid;
  grid-template-columns: 42% 1fr;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.today-card .cover { aspect-ratio: auto; min-height: 150px; }
.today-body { padding: 14px 14px 16px; display: flex; flex-direction: column; gap: 4px; justify-content: center; }
.today-tag {
  align-self: flex-start;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 12px;
  font-weight: 800;
}
.today-body h2 { margin: 2px 0 0; font-size: 18px; line-height: 1.3; letter-spacing: -0.02em; }
.today-body p { margin: 0; font-size: 13px; color: var(--text-2); }
.today-btn { align-self: flex-start; margin-top: 8px; height: 38px; padding: 0 16px; display: inline-flex; align-items: center; font-size: 14px; }
@media (min-width: 640px) {
  .today-card .cover { min-height: 200px; }
  .today-body { padding: 20px 24px; }
  .today-body h2 { font-size: 22px; }
}

/* 국기 모음 표지 */
.flag-grid {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: minmax(0, 1fr) minmax(0, 1fr); /* 두 줄이 칸 안에 딱 맞게 */
  gap: 8px;
  padding: 38px 14px 12px; /* 위쪽은 카테고리 표시 자리 (국기와 겹치지 않게) */
  background: linear-gradient(160deg, #dfe9ff, #b9ccff);
}
.flag-grid img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 6px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .15);
}
.flag-grid.vs {
  grid-template-columns: 1fr auto 1fr;
  grid-template-rows: auto;
  align-items: center;
  gap: 6px;
  padding: 38px 12px 12px;
  background: linear-gradient(160deg, #fff1d6, #ffc98f);
}
.flag-grid.vs img { height: auto; aspect-ratio: 3 / 2; }
.vs-mark {
  font-weight: 800;
  font-size: 22px;
  color: #b4610a;
}
.cover-text {
  color: #fff;
  font-weight: 800;
  font-size: clamp(22px, 7vw, 32px);
  letter-spacing: 0.04em;
  text-shadow: 0 2px 12px rgba(0, 0, 0, .15);
}
.badge {
  position: absolute;
  left: 8px;
  top: 8px;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(0, 0, 0, .55);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
}
.card-body { padding: 10px 12px 12px; }
.card-title {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.35;
  letter-spacing: -0.02em;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card-meta {
  margin-top: 4px;
  font-size: 12px;
  color: var(--text-3);
}
.card-meta b { color: var(--primary); font-weight: 700; }

.empty {
  padding: 40px 0;
  text-align: center;
  color: var(--text-3);
}

/* 풀기 화면 */
.play-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 0 12px;
}
.icon-btn {
  flex: none;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  display: grid;
  place-items: center;
  font-size: 18px;
}
.progress {
  flex: 1;
  height: 8px;
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
}
.progress > span {
  display: block;
  height: 100%;
  background: var(--primary);
  border-radius: inherit;
  transition: width .3s ease;
}
.counter {
  flex: none;
  font-size: 14px;
  font-weight: 700;
  color: var(--text-2);
  font-variant-numeric: tabular-nums;
}

.qcard {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.qmedia {
  position: relative;
  display: grid;
  place-items: center;
  background: var(--surface-2);
  aspect-ratio: 16 / 10;
  padding: 16px;
  overflow: hidden; /* 사진이 어떤 크기여도 이 칸 밖으로 못 나가게 */
  border-bottom: 1px solid var(--line);
}
.qbig {
  font-size: clamp(40px, 13vw, 64px);
  font-weight: 800;
  letter-spacing: 0.12em;
  color: var(--primary);
}
.qtext {
  margin: 0;
  padding: 18px 18px 6px;
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -0.02em;
  text-align: center;
}
.qmedia.photo {
  display: block;
  aspect-ratio: auto;
  height: min(46vh, 340px);
  padding: 0;
}
/* 칸 안쪽 여백만큼 띄운 상자에 사진을 '맞춰 넣기'. 비는 곳은 투명이라 그림자는 사진 모양을 따라감 */
.qmedia.photo img {
  position: absolute;
  inset: 16px;
  width: calc(100% - 32px);
  height: calc(100% - 32px);
  object-fit: contain;
  filter: drop-shadow(0 2px 8px rgba(0, 0, 0, .16));
}
.qmedia.photo img.drawn { filter: none; }
.qmedia.photo .qhint { position: absolute; inset: 0; display: grid; place-items: center; }
.qguide {
  margin: 0 18px 4px;
  text-align: center;
  font-size: 13px;
  color: var(--text-3);
}
.credit {
  margin: 0;
  padding: 0 14px 12px;
  text-align: center;
  font-size: 11px;
  color: var(--text-3);
}
.qmedia.lead {
  aspect-ratio: auto;
  min-height: 180px;
  padding: 28px 22px;
  background: linear-gradient(160deg, var(--primary-soft), var(--surface-2));
}
.qlead {
  margin: 0;
  font-size: clamp(21px, 6vw, 26px);
  font-weight: 800;
  line-height: 1.45;
  letter-spacing: -0.03em;
  text-align: center;
  word-break: keep-all;
}
.qtext.sub {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-3);
}
.qhint {
  margin: 0;
  padding: 0 18px;
  min-height: 24px;
  text-align: center;
  color: var(--text-3);
  font-size: 14px;
}

.answer-form {
  display: flex;
  gap: 8px;
  padding: 14px;
}
.answer-input {
  flex: 1;
  min-width: 0;
  height: 52px;
  padding: 0 16px;
  border: 2px solid var(--line);
  border-radius: 14px;
  background: var(--bg);
  outline: none;
  font-size: 17px;
  font-weight: 600;
}
.answer-input:focus { border-color: var(--primary); }

.btn {
  height: 52px;
  padding: 0 20px;
  border: 0;
  border-radius: 14px;
  background: var(--primary);
  color: var(--on-primary);
  font-weight: 700;
  font-size: 16px;
  white-space: nowrap;
}
.btn:active { background: var(--primary-press); }
.btn:disabled { opacity: .45; cursor: default; }
.btn.ghost {
  background: var(--surface-2);
  color: var(--text-2);
}
.btn.block { width: 100%; }
a.btn { display: flex; align-items: center; justify-content: center; }

.sub-actions {
  display: flex;
  justify-content: center;
  gap: 4px;
  padding: 0 14px 14px;
}
.link-btn {
  border: 0;
  background: none;
  padding: 6px 12px;
  color: var(--text-3);
  font-size: 14px;
  font-weight: 600;
  border-radius: 8px;
}
.link-btn:disabled { opacity: .4; cursor: default; }

.feedback {
  margin: 0 14px 14px;
  padding: 14px 16px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  animation: pop .25s ease;
}
.feedback.good { background: var(--good-soft); color: var(--good); }
.feedback.bad { background: var(--bad-soft); color: var(--bad); }
.feedback .mark { font-size: 26px; font-weight: 800; line-height: 1; }
.feedback .msg { font-weight: 700; }
.feedback .sub { font-size: 14px; color: var(--text-2); font-weight: 500; }

.next-wrap { padding: 0 14px 14px; }

@keyframes pop {
  from { transform: scale(.96); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}
.shake { animation: shake .3s ease; }
@keyframes shake {
  25% { transform: translateX(-6px); }
  50% { transform: translateX(6px); }
  75% { transform: translateX(-3px); }
}

/* 결과 화면 */
.result-top {
  text-align: center;
  padding: 28px 16px 22px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.result-title {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-3);
}
.score {
  margin: 6px 0 2px;
  font-size: 56px;
  font-weight: 800;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}
.score small { font-size: 24px; color: var(--text-3); font-weight: 700; }
.grade { margin: 0; font-size: 18px; font-weight: 700; }
.best { margin: 6px 0 0; font-size: 14px; color: var(--text-3); }
.clear-time {
  display: grid;
  gap: 2px;
  margin: 14px auto 0;
  padding: 12px 16px;
  max-width: 280px;
  border-radius: 14px;
  background: var(--primary-soft);
}
.clear-time span { font-size: 13px; font-weight: 600; color: var(--text-2); }
.clear-time b { font-size: 30px; font-weight: 800; color: var(--primary); letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.clear-time small { font-size: 13px; color: var(--text-3); }
.clear-time small.new { color: var(--primary); font-weight: 700; }
.best.new { color: var(--primary); font-weight: 700; }

.result-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 14px 0 22px;
}
.result-actions .btn:first-child { grid-column: 1 / -1; }

.section-title {
  margin: 0 0 10px;
  font-size: 16px;
  font-weight: 700;
}
.review { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.review li {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
}
.review .thumb {
  flex: none;
  width: 56px;
  height: 40px;
  border-radius: 8px;
  background: var(--surface-2);
  display: grid;
  place-items: center;
  overflow: hidden;
  font-size: 12px;
  font-weight: 800;
  color: var(--primary);
  white-space: nowrap;
  letter-spacing: -0.02em;
}
.review .thumb img { width: 100%; height: 100%; object-fit: cover; }
.review .info { flex: 1; min-width: 0; }
.review .q { font-size: 13px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.review .a { font-weight: 700; }
.review .mine { font-size: 13px; color: var(--bad); }
.review .ok { flex: none; font-weight: 800; font-size: 18px; }
.review .ok.good { color: var(--good); }
.review .ok.bad { color: var(--bad); }

/* 알림 */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom));
  transform: translate(-50%, 20px);
  padding: 10px 16px;
  border-radius: 12px;
  background: var(--text);
  color: var(--bg);
  font-size: 14px;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
  max-width: calc(100% - 32px);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* 광고 영역 */
.ad-row { grid-column: 1 / -1; }
.ad-slot {
  position: relative;
  margin: 4px 0 18px;
  min-height: 100px;
  border-radius: 14px;
  overflow: hidden;
}
.ad-label {
  position: absolute;
  top: 4px;
  right: 8px;
  z-index: 1;
  font-size: 10px;
  color: var(--text-3);
}
.ad-placeholder {
  display: grid;
  place-items: center;
  border: 1px dashed var(--line);
  background: var(--surface-2);
  color: var(--text-3);
  font-size: 13px;
  font-weight: 600;
}
.ad-row .ad-slot { margin: 0; }

/* 뽑기 게임 칸 (홈) */
.games-strip { margin: 0 0 18px; }
.strip-title { margin: 0 0 8px; font-size: 16px; font-weight: 800; letter-spacing: -0.02em; }
.strip-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}
.game-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
}
.game-card img { flex: none; width: 64px; height: 48px; border-radius: 10px; object-fit: cover; }
.game-card span { display: grid; min-width: 0; }
.game-card b { font-size: 15px; }
.game-card small { font-size: 12px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* 휴대폰: 세 개가 한 줄에 다 보이게 그림 위·이름 아래 */
@media (max-width: 560px) {
  .game-card { flex-direction: column; gap: 6px; padding: 10px 6px; text-align: center; }
  .game-card img { width: 100%; height: auto; aspect-ratio: 4 / 3; }
  .game-card small { display: none; }
  .game-card b { font-size: 14px; }
}

/* 게임 공통 */
.game-body { display: grid; gap: 14px; padding-bottom: 24px; }
.game-result { margin: 0; min-height: 26px; text-align: center; font-size: 18px; font-weight: 700; line-height: 1.5; }
.game-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.game-actions .btn[hidden] { display: none; }
.field textarea {
  width: 100%;
  padding: 12px 14px;
  border: 2px solid var(--line);
  border-radius: 12px;
  background: var(--bg);
  outline: none;
  font: inherit;
  font-size: 16px;
  resize: vertical;
}
.field textarea:focus { border-color: var(--primary); }
.field { display: grid; gap: 6px; }
.field > span { font-size: 14px; font-weight: 700; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* 돌림판 */
.wheel-wrap { position: relative; width: min(100%, 400px); margin: 0 auto; }
.wheel-canvas { display: block; width: 100%; height: auto; aspect-ratio: 1; }
.wheel-pointer {
  position: absolute;
  top: -4px;
  left: 50%;
  z-index: 1;
  width: 0;
  height: 0;
  transform: translateX(-50%);
  border-left: 14px solid transparent;
  border-right: 14px solid transparent;
  border-top: 26px solid var(--text);
}

/* 사다리 */
.ladder-box {
  overflow-x: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 8px;
  text-align: center;
}
.ladder-svg { display: block; margin: 0 auto; max-width: none; }
.lad-line { stroke: var(--text-3); stroke-width: 3; stroke-linecap: round; }
.lad-path { fill: none; stroke-width: 6; stroke-linecap: round; stroke-linejoin: round; }
.lad-name { cursor: pointer; }
.lad-name text, .lad-res text { font: 700 13px Pretendard, sans-serif; fill: #1d1b26; }
.lad-res rect { fill: var(--surface-2); }
.lad-res text { fill: var(--text-2); }
.lad-res.open text { fill: #1d1b26; }

/* 구슬 추첨 */
.marble-stage { position: relative; }
.marble-canvas {
  display: block;
  width: 100%;
  height: min(62vh, 560px);
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--surface-2);
}
.marble-rank {
  position: absolute;
  top: 8px;
  right: 8px;
  max-height: calc(100% - 16px);
  overflow-y: auto;
  margin: 0;
  padding: 6px 8px 6px 26px;
  border-radius: 12px;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  font-size: 12px;
  font-weight: 700;
  min-width: 70px;
}
.marble-rank:empty { display: none; }
.marble-rank li::marker { color: var(--text-3); }
.marble-rank li { border-left: 4px solid var(--c); padding-left: 4px; margin: 2px 0; }
.rule-row { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 14px; font-weight: 600; }
.rule-row input { accent-color: var(--primary); }

/* 경주마 */
.track {
  display: grid;
  gap: 6px;
  padding: 10px;
  border-radius: var(--radius);
  background: linear-gradient(90deg, #c98a4b, #b9773a);
}
.lane { display: grid; grid-template-columns: 24px 1fr 34px; align-items: center; gap: 6px; }
.lane-no { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; color: #2d2440; font-size: 12px; font-weight: 800; }
.lane-run {
  position: relative;
  height: 50px;
  border-bottom: 2px dashed rgba(255, 255, 255, .45);
  background: repeating-linear-gradient(90deg, transparent 0 calc(100% - 8px), #fff calc(100% - 8px) 100%);
}
.horse {
  position: absolute;
  left: 0;
  bottom: 0;
  transform: translateX(calc(var(--x) * (100cqw - 58px)));
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 58px;
}
.lane-run { container-type: inline-size; }
.pony { display: block; overflow: visible; filter: drop-shadow(0 2px 2px rgba(0, 0, 0, .25)); }
.pony g, .pony .tail { transform-box: fill-box; transform-origin: 50% 10%; }
.track.running .pony { animation: gallop .32s ease-in-out infinite; }
.track.running .pony .leg-f, .track.running .pony .leg-b2 { animation: legA .32s ease-in-out infinite; }
.track.running .pony .leg-b, .track.running .pony .leg-f2 { animation: legB .32s ease-in-out infinite; }
.track.running .pony .tail { animation: tail .32s ease-in-out infinite; }
@keyframes gallop { 50% { transform: translateY(-4px) rotate(-3deg); } }
@keyframes legA { 0%, 100% { transform: rotate(28deg); } 50% { transform: rotate(-24deg); } }
@keyframes legB { 0%, 100% { transform: rotate(-24deg); } 50% { transform: rotate(28deg); } }
@keyframes tail { 50% { transform: rotate(-18deg); } }
.horse-name { font-size: 10px; font-weight: 800; color: #fff; text-shadow: 0 1px 2px rgba(0,0,0,.5); white-space: nowrap; }
.lane-place { color: #fff; font-weight: 800; font-size: 13px; text-align: right; }
.pick-row { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.pick-row .chip[aria-pressed="true"] { background: var(--c); border-color: var(--c); color: #1d1b26; }
.marble-rank { max-height: 45%; }

/* 게임: 카운트다운 · 슬로모션 · 실시간 표시 */
.count-overlay {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: grid;
  place-items: center;
  background: rgba(10, 8, 20, .35);
  border-radius: var(--radius);
  pointer-events: none;
}
.count-overlay[hidden] { display: none; }
.count-num {
  font-size: 72px;
  font-weight: 900;
  color: #fff;
  text-shadow: 0 4px 20px rgba(0, 0, 0, .35);
  animation: countpop .75s ease;
}
@keyframes countpop {
  0% { transform: scale(1.8); opacity: 0; }
  30% { transform: scale(1); opacity: 1; }
  100% { transform: scale(.9); opacity: .9; }
}
.slowmo {
  position: absolute;
  left: 50%;
  top: 10px;
  z-index: 2;
  transform: translateX(-50%);
  padding: 4px 12px;
  border-radius: 999px;
  background: #ff4f5e;
  color: #fff;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: .04em;
  animation: blink 1s ease-in-out infinite;
}
.slowmo[hidden] { display: none; }
@keyframes blink { 50% { opacity: .55; } }
.wheel-live { margin: -4px 0 0; min-height: 28px; text-align: center; font-size: 22px; font-weight: 900; color: var(--primary); }
.wheel-pointer { transform-origin: 50% 0; }
.wheel-pointer.tick { animation: tick .12s ease; }
@keyframes tick { 50% { transform: translateX(-50%) rotate(-14deg); } }
.lad-veil rect { fill: var(--surface-2); stroke: var(--line); stroke-width: 2; }
.lad-veil text { font: 900 22px Pretendard, sans-serif; fill: var(--text-3); letter-spacing: .3em; }
.lad-veil { transition: opacity .6s ease; }
.lad-veil.gone { opacity: 0; pointer-events: none; }
.lad-dot { stroke: #fff; stroke-width: 3; }
.track-wrap { position: relative; }
.lane.mine .lane-run { background-color: rgba(255, 255, 255, .14); border-radius: 8px; }
.lane.mine .lane-no { box-shadow: 0 0 0 3px #fff; }
.marble-rank li.done { opacity: .75; }
.marble-rank li.more { border: 0; list-style: none; margin-left: -16px; color: var(--text-3); font-weight: 600; }

/* 홈 아래 */
.site-foot {
  margin-top: 32px;
  text-align: center;
  font-size: 13px;
  color: var(--text-3);
}
.site-foot a { text-decoration: underline; text-underline-offset: 3px; }

.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;
}

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

/* 게임 공통 (추가 게임) */
.field input[type="number"], .field input[type="text"] {
  width: 100%;
  height: 46px;
  padding: 0 12px;
  border: 2px solid var(--line);
  border-radius: 12px;
  background: var(--bg);
  color: var(--text);
  outline: none;
  font: inherit;
  font-size: 16px;
}
.field input:focus { border-color: var(--primary); }
.num-row { display: grid; grid-template-columns: 1fr 1fr 1.3fr; gap: 10px; }
.opt-row { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.opt-row[hidden] { display: none; }
.check { display: flex; align-items: center; justify-content: center; gap: 8px; font-size: 14px; font-weight: 700; }
.check input { width: 18px; height: 18px; accent-color: var(--primary); }
.game-result .sub { font-size: 14px; font-weight: 600; color: var(--text-3); }

/* 제비뽑기 */
.lots-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(70px, 1fr)); gap: 10px; }
.lot {
  position: relative;
  display: grid;
  place-items: center;
  align-content: center;
  aspect-ratio: 3 / 4;
  border: 0;
  border-radius: 12px;
  background: linear-gradient(135deg, #fff6cf, #ffd68f);
  box-shadow: 0 3px 0 #e2b45c, 0 6px 14px rgba(120, 80, 0, .15);
  color: #7a4b00;
  font: inherit;
  cursor: pointer;
}
.lot b { font-size: 22px; font-weight: 900; }
.lot::after { content: ""; position: absolute; left: 12%; right: 12%; top: 50%; border-top: 2px dashed rgba(122, 75, 0, .25); }
.lot.open::after { display: none; }
.lot small { position: absolute; top: 6px; left: 8px; font-size: 11px; font-weight: 700; opacity: .6; }
.lot span { font-size: 26px; line-height: 1; }
.lot.shake { animation: lotshake .7s ease; }
.lot.flip { animation: lotflip .36s ease; }
.lot.win { background: linear-gradient(135deg, #ffe066, #ffb020); box-shadow: 0 3px 0 #d98e00, 0 0 0 3px #fff, 0 8px 20px rgba(255, 160, 0, .45); color: #5a3300; }
.lot.win b { font-size: 15px; }
.lot.lose { background: var(--surface-2); box-shadow: none; color: var(--text-3); }
.lot.lose b { font-size: 18px; }
@keyframes lotshake {
  0%, 100% { transform: rotate(0); }
  15% { transform: rotate(-6deg) scale(1.04); }
  35% { transform: rotate(6deg) scale(1.06); }
  55% { transform: rotate(-5deg) scale(1.08); }
  75% { transform: rotate(4deg) scale(1.1); }
}
@keyframes lotflip { 0% { transform: scaleX(1); } 50% { transform: scaleX(0); } 100% { transform: scaleX(1); } }

/* 폭탄 돌리기 */
.bomb-stage {
  position: relative;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 8px;
  min-height: 280px;
  padding: 20px;
  border-radius: var(--radius);
  background: var(--surface-2);
  overflow: hidden;
  text-align: center;
  transition: background .6s ease;
}
.bomb-stage.hot { background: #ffd9cf; color: #1d1b26; }
.bomb-svg { display: block; width: 180px; height: 180px; }
.bomb .spark { transform-box: fill-box; transform-origin: center; display: none; }
.bomb.lit .spark { display: inline; animation: spark .18s ease-in-out infinite alternate; }
.bomb.pulse .bomb-svg { animation: bombpulse .16s ease; }
@keyframes spark { from { transform: scale(.75) rotate(0); } to { transform: scale(1.2) rotate(25deg); } }
@keyframes bombpulse { 50% { transform: scale(1.07) rotate(-3deg); } }
.bomb-msg { margin: 0; font-size: 17px; font-weight: 800; }
.bomb-stage.boom {
  background: radial-gradient(circle, #fff3b0 0%, #ffb020 38%, #ff4f5e 80%);
  color: #fff;
  animation: boomshake .55s ease;
}
.boom-text { font-size: 88px; font-weight: 900; line-height: 1; color: #fff; text-shadow: 0 4px 0 #c0392b, 0 8px 24px rgba(0, 0, 0, .3); animation: countpop .6s ease; }
@keyframes boomshake {
  0%, 100% { transform: translate(0); }
  20% { transform: translate(-10px, 4px); }
  40% { transform: translate(9px, -6px); }
  60% { transform: translate(-7px, 5px); }
  80% { transform: translate(5px, -3px); }
}

/* 팀 나누기 */
.teams-box { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
.teams-box:empty { display: none; }
.team { padding: 12px 14px; border-radius: 16px; border-top: 6px solid var(--c); background: var(--surface); box-shadow: var(--shadow); border-left: 1px solid var(--line); border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.team h3 { margin: 0 0 8px; font-size: 17px; font-weight: 900; }
.team h3 small { font-size: 13px; font-weight: 600; color: var(--text-3); }
.team ul { display: flex; flex-wrap: wrap; gap: 6px; margin: 0; padding: 0; list-style: none; }
.team li { padding: 4px 10px; border-radius: 999px; background: color-mix(in srgb, var(--c) 30%, transparent); font-size: 15px; font-weight: 700; animation: pop .3s ease; }
@keyframes pop { 0% { transform: scale(.3); opacity: 0; } 70% { transform: scale(1.12); } 100% { transform: scale(1); opacity: 1; } }

/* 주사위·동전 */
.dice-stage {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 18px;
  min-height: 220px;
  padding: 28px 12px;
  border-radius: var(--radius);
  background: radial-gradient(circle at 50% 40%, #3a9a6f, #246b4c);
  box-shadow: inset 0 0 0 6px #1d5a40;
}
.die { width: 84px; height: 84px; }
.die svg { display: block; width: 100%; height: 100%; filter: drop-shadow(0 6px 8px rgba(0, 0, 0, .3)); }
.die.rolling { animation: tumble 1s cubic-bezier(.2, .6, .3, 1); }
@keyframes tumble {
  0% { transform: translateY(0) rotate(0); }
  25% { transform: translateY(-56px) rotate(200deg); }
  50% { transform: translateY(0) rotate(400deg); }
  70% { transform: translateY(-16px) rotate(560deg); }
  100% { transform: translateY(0) rotate(720deg); }
}
.coin-wrap { perspective: 700px; }
.coin-wrap.toss { animation: toss 1.6s cubic-bezier(.3, .7, .4, 1); }
@keyframes toss {
  0% { transform: translateY(0) scale(1); }
  40% { transform: translateY(-80px) scale(1.18); }
  80% { transform: translateY(0) scale(1); }
  88% { transform: translateY(-10px); }
  100% { transform: translateY(0); }
}
.coin { position: relative; width: 140px; height: 140px; transform-style: preserve-3d; transition: transform 1.6s cubic-bezier(.25, .8, .3, 1); }
.coin-face {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  border-radius: 50%;
  font-size: 54px;
  font-weight: 900;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}
.coin-face.front { background: radial-gradient(circle at 35% 30%, #fff3b0, #f2b51d 60%, #c98a0b); color: #7a4b00; box-shadow: inset 0 0 0 8px rgba(255, 255, 255, .35), 0 8px 18px rgba(0, 0, 0, .3); }
.coin-face.back { transform: rotateY(180deg); background: radial-gradient(circle at 35% 30%, #fff, #c9ccd6 60%, #8d93a3); color: #3a3f4f; box-shadow: inset 0 0 0 8px rgba(255, 255, 255, .4), 0 8px 18px rgba(0, 0, 0, .3); }
.dice-history { margin: 0; min-height: 20px; text-align: center; font-size: 14px; color: var(--text-3); word-break: keep-all; }

/* 새로 고침 때: 검색엔진용 글은 화면에 안 보이게 숨기고, 앱이 뜰 때까지 로딩 표시만 */
.seo-static {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
#app:has(> .seo-static)::before {
  content: "";
  display: block;
  width: 36px;
  height: 36px;
  margin: 30vh auto 0;
  border: 4px solid var(--primary-soft);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* 롤 내전 팀 짜기 */
.lol-board { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.lol-board[hidden] { display: none; }
.lol-team { padding: 12px; border-radius: 16px; color: #fff; }
.lol-team.blue { background: linear-gradient(160deg, #3d7bff, #2a4fb8); }
.lol-team.red { background: linear-gradient(160deg, #ff5a5a, #b83232); }
.lol-team h3 { margin: 0 0 8px; font-size: 18px; font-weight: 900; text-align: center; }
.lol-team ol { display: grid; gap: 6px; margin: 0; padding: 0; list-style: none; }
.lol-team li { display: flex; align-items: center; gap: 8px; min-width: 0; padding: 7px 10px; border-radius: 10px; background: rgba(255, 255, 255, .16); }
.lol-team li b { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 15px; }
.lol-team li.spin b { opacity: .55; }
.lol-team li.pop { animation: pop .35s ease both; }
.lol-team .lol-lane { flex: none; width: 46px; font-size: 12px; font-weight: 800; opacity: .85; }
.lol-inputs input { width: 100%; min-width: 0; height: 42px; padding: 0 10px; border: 2px solid var(--line); border-radius: 10px; background: var(--bg); color: var(--text); font: inherit; font-size: 16px; outline: none; }
.lol-inputs input:focus { border-color: var(--primary); }
.lol-inputs { display: grid; gap: 8px; }
.lol-row { display: grid; grid-template-columns: 66px 1fr 1fr; gap: 8px; align-items: center; }
.lol-lock {
  display: grid;
  place-items: center;
  height: 42px;
  padding: 0;
  border: 2px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text-2);
  font: inherit;
  line-height: 1.1;
  cursor: pointer;
}
.lol-lock b { font-size: 14px; font-weight: 900; }
.lol-lock small { font-size: 10px; font-weight: 700; }
.lol-lock[aria-pressed="true"] { border-color: var(--text); background: var(--text); color: var(--bg); }
.lol-hint { margin: 0; font-size: 13px; line-height: 1.5; color: var(--text-3); text-align: center; word-break: keep-all; }
.lol-person { position: relative; min-width: 0; }
.lol-person input { padding-right: 46px; }
.lol-pin {
  position: absolute;
  top: 6px;
  right: 6px;
  bottom: 6px;
  width: 36px;
  padding: 0;
  border: 0;
  border-radius: 7px;
  background: var(--surface-2);
  color: var(--text-3);
  font: inherit;
  font-size: 11px;
  font-weight: 800;
  cursor: pointer;
}
.lol-pin[data-k="lane"] { background: var(--text); color: var(--bg); }
.lol-pin[data-k="blue"] { background: #3d7bff; color: #fff; }
.lol-pin[data-k="red"] { background: #ff5a5a; color: #fff; }
.lol-team li i { flex: none; margin-left: auto; font-style: normal; font-size: 11px; opacity: .8; }

/* 멜로디 문제 */
.qmedia.melody { align-content: center; gap: 14px; }
.melody-btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  height: 60px;
  padding: 0 28px;
  border: 0;
  border-radius: 999px;
  background: var(--primary);
  color: var(--on-primary);
  font: inherit;
  font-size: 18px;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(124, 92, 255, .35);
}
.melody-btn:active { background: var(--primary-press); }
.melody-btn.playing .melody-ico { animation: blink .6s ease-in-out infinite; }
.melody-eq { display: flex; align-items: flex-end; gap: 5px; height: 34px; }
.melody-eq i { width: 8px; height: 8px; border-radius: 4px; background: var(--primary-soft); }
.melody-btn.playing + .melody-eq i { background: var(--primary); animation: eq .5s ease-in-out infinite alternate; }
.melody-btn.playing + .melody-eq i:nth-child(2) { animation-delay: .1s; }
.melody-btn.playing + .melody-eq i:nth-child(3) { animation-delay: .25s; }
.melody-btn.playing + .melody-eq i:nth-child(4) { animation-delay: .05s; }
.melody-btn.playing + .melody-eq i:nth-child(5) { animation-delay: .18s; }
@keyframes eq { from { height: 8px; } to { height: 34px; } }
