:root {
  --bg: #eef1fb;
  --surface: #ffffff;
  --surface-2: #f1f2fb;
  --text: #1b1d3a;
  --muted: #646a8a;
  --line: #e0e3f2;
  --accent: #6c4dff;
  --accent-strong: #4f33d6;
  --accent-2: #ff4f9a;
  --accent-text: #ffffff;
  --glow-1: #d9d0ff;
  --glow-2: #ffd6ea;
  --shadow: 0 8px 24px rgba(38, 30, 110, .10);
  --shadow-hover: 0 16px 36px rgba(38, 30, 110, .18);
  --font: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Malgun Gothic", "맑은 고딕", "Noto Sans KR", system-ui, sans-serif; /* 기기 기본 글꼴 (내려받지 않음) */
  color-scheme: light;
}
/* 다크: 깊은 남보라 배경 (CrazyGames 계열), 라이트: 밝은 라벤더 배경 (Poki 계열) */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e0f1d;
    --surface: #191a30;
    --surface-2: #24264a;
    --text: #f1f1ff;
    --muted: #a4a7c9;
    --line: #2d2f55;
    --accent: #8b74ff;
    --accent-strong: #5f45e0;
    --accent-2: #ff6aa9;
    --glow-1: #2a1f66;
    --glow-2: #3a163f;
    --shadow: 0 10px 28px rgba(0, 0, 0, .45);
    --shadow-hover: 0 18px 40px rgba(0, 0, 0, .6);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0e0f1d;
  --surface: #191a30;
  --surface-2: #24264a;
  --text: #f1f1ff;
  --muted: #a4a7c9;
  --line: #2d2f55;
  --accent: #8b74ff;
  --accent-strong: #5f45e0;
  --accent-2: #ff6aa9;
  --glow-1: #2a1f66;
  --glow-2: #3a163f;
  --shadow: 0 10px 28px rgba(0, 0, 0, .45);
  --shadow-hover: 0 18px 40px rgba(0, 0, 0, .6);
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  padding: 0 env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); /* viewport-fit=cover: 가로 화면 노치 자리 */
  color: var(--text);
  font: 500 15px/1.55 var(--font);
  background:
    radial-gradient(900px 520px at 0% -8%, var(--glow-1), transparent 62%),
    radial-gradient(800px 480px at 105% 4%, var(--glow-2), transparent 58%),
    var(--bg);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, .brand, .btn, .tab, .chip, .stats b { font-family: var(--font); }
h1, h2, h3 { font-weight: 900; letter-spacing: -.015em; }
body.locked { overflow: hidden; }
button { font: inherit; color: inherit; cursor: pointer; }
/* iPhone: 빠르게 두 번 탭하면 화면이 확대되는 것 막기 (두 손가락 확대는 그대로 됨) */
button, a, select, input, label, .card, .modal, .stage, .stage * { touch-action: manipulation; }
/* 게임 화면에서는 길게 누르거나 빠르게 탭할 때 글자 선택·회색 강조가 생기지 않게 */
.stage, .stage * { -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent; -webkit-touch-callout: none; }

/* ---------- header ---------- */
.top {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand {
  font-weight: 800; font-size: 18px; display: flex; align-items: baseline; gap: 8px;
  white-space: nowrap; color: inherit; text-decoration: none; min-width: 0;
}
.brand .logo { align-self: center; }
.tagline { font-family: "Jua", var(--font-fun), system-ui, sans-serif; font-size: 14px; font-weight: 400; color: color-mix(in srgb, var(--accent) 70%, var(--text)); letter-spacing: .2px; overflow: hidden; text-overflow: ellipsis; }
.lang {
  flex: none; height: 38px; padding: 0 10px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface); color: var(--text); font: inherit; font-size: 13px;
}
.logo { font-size: 22px; }
#search {
  flex: 1; min-width: 0; max-width: 360px; margin-left: auto;
  padding: 9px 14px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface); color: var(--text);
  font: inherit; outline: none;
}
#search:focus { border-color: var(--accent); }
.icon-btn {
  width: 38px; height: 38px; flex: none;
  border-radius: 50%; border: 1px solid var(--line); background: var(--surface);
}
.btn {
  padding: 7px 14px; border-radius: 999px; border: 0;
  background: var(--accent); color: var(--accent-text); font-weight: 600;
}

main { max-width: 1100px; margin: 0 auto; padding: 0 16px 48px; }

/* ---------- hero ---------- */
.hero { padding: 36px 0 20px; }
.hero h1 { margin: 0 0 6px; font-size: clamp(24px, 4vw, 34px); letter-spacing: -.02em; }
.hero p { margin: 0; color: var(--muted); }
.stats { display: flex; gap: 10px; margin-top: 18px; flex-wrap: wrap; }
.stats div {
  padding: 10px 16px; border-radius: 14px; background: var(--surface);
  border: 1px solid var(--line); color: var(--muted); font-size: 13px;
}
.stats b { display: block; color: var(--text); font-size: 20px; }

/* ---------- tabs ---------- */
.tabs { display: flex; gap: 8px; margin: 12px 0 18px; overflow-x: auto; padding-bottom: 4px; }
.tab {
  padding: 7px 16px; border-radius: 999px; white-space: nowrap;
  border: 1px solid var(--line); background: var(--surface); color: var(--muted);
}
.tab.on { background: var(--text); color: var(--bg); border-color: var(--text); }

/* ---------- grid ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 16px; }
.card {
  position: relative; overflow: hidden; cursor: pointer;
  border-radius: 18px; background: var(--surface); border: 1px solid var(--line);
  box-shadow: var(--shadow);
  transition: transform .15s ease, box-shadow .15s ease;
}
.card:hover, .card:focus-visible { transform: translateY(-3px); outline: none; box-shadow: 0 10px 30px rgba(20, 26, 40, .16); }
.thumb {
  height: 130px; display: grid; place-items: center; font-size: 60px;
  background: radial-gradient(circle at 30% 20%, color-mix(in srgb, var(--c) 55%, white), var(--c));
}
.card:hover .thumb { animation: bob .6s ease; }
@keyframes bob { 50% { transform: scale(1.04); } }
.fav {
  position: absolute; top: 10px; right: 10px;
  width: 34px; height: 34px; border-radius: 50%; border: 0;
  background: rgba(0, 0, 0, .25); color: rgba(255, 255, 255, .8); font-size: 16px;
}
.fav.on { color: #ffd34d; background: rgba(0, 0, 0, .4); }
.info { padding: 14px 16px 16px; }
.info h3 { margin: 0 0 4px; font-size: 17px; }
.info p { margin: 0 0 12px; color: var(--muted); font-size: 13.5px; min-height: 40px; }
.meta { display: flex; justify-content: space-between; align-items: center; font-size: 12.5px; color: var(--muted); }
.chip { padding: 2px 10px; border-radius: 999px; background: var(--surface-2); }
.empty { text-align: center; color: var(--muted); padding: 40px 0; }

/* ---------- modal ---------- */
.modal {
  position: fixed; inset: 0; z-index: 50;
  display: grid; place-items: center;
  /* viewport-fit=cover: 아이폰 노치·홈 표시줄 자리만큼 비운다 */
  padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  background: rgba(8, 10, 16, .6); backdrop-filter: blur(4px);
}
.modal[hidden] { display: none; }
.panel {
  width: min(560px, 100%); max-height: 100%; overflow: auto;
  background: var(--surface); border-radius: 20px; padding: 14px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .4);
}
.bar { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.bar h2 { margin: 0; font-size: 18px; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.scores { display: flex; gap: 10px; font-size: 13px; color: var(--muted); white-space: nowrap; align-items: center; }
.bar-btns { display: flex; gap: 8px; align-items: center; }
/* 게임 창 위쪽: 제목 | 점수·최고 (가운데) | 전체 화면·닫기 */
.game-panel .bar { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); }
.game-panel .bar-btns { justify-self: end; }
/* 게임 이름·아이콘은 보이지 않게 (대화 상자 이름으로만, aria-labelledby). 그 자리(위 왼쪽)에 '다시' */
.game-panel #mTitle { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.game-panel .bar > #mRestart { grid-column: 1; grid-row: 1; justify-self: start; }
.game-panel #mRestart { display: inline-flex; align-items: center; gap: 5px; }
.scores b { color: var(--text); font-variant-numeric: tabular-nums; }
.stage { position: relative; display: grid; justify-items: center; gap: 10px; }
.help { margin: 10px 0 0; text-align: center; color: var(--muted); font-size: 13px; }

.overlay {
  position: absolute; inset: 0; z-index: 5;
  display: grid; place-content: center; gap: 12px; text-align: center;
  background: rgba(10, 12, 20, .78); color: #fff; border-radius: 14px;
  animation: fade .2s ease;
}
.overlay h3 { margin: 0; font-size: 24px; }
.overlay p { margin: 0; opacity: .85; }
.overlay .new { color: #ffd34d; font-weight: 700; }
@keyframes fade { from { opacity: 0; } }

/* ---------- game window size ---------- */
/* 게임 창은 화면에 맞춰 최대한 크게. 게임 판은 .fit: 가로 폭과 남은 세로 높이(--chrome 만큼 제외) 중 작은 쪽에 맞춘다 */
.panel.game-panel { width: min(1080px, 100%); --chrome: 240px; }
.stage .fit { width: min(100%, calc((100dvh - var(--chrome, 240px) + var(--chrome-cut, 0px) + var(--chrome-free, 0px) - var(--fit-over, 0px) - var(--slot-hud, 0px) - var(--slot-ctl, 0px) - var(--slot-thumb, 0px)) * var(--ar, 1))); max-width: 100%; } /* --chrome-cut: 휴대폰처럼 위아래 막대를 줄인 화면에서 돌려받는 높이 */
/* --chrome-free: 게임 창 아래 '랭킹 TOP 10' 을 뺀 만큼 판에 돌려준다 (데스크톱 44px, 휴대폰 세로 33px). 넘치면 --fit-over 가 다시 줄인다 */
.panel.game-panel { --chrome-free: 44px; }
.stage:has(.hud) { --chrome: 280px; }
.game-panel:fullscreen { width: 100%; max-height: none; border-radius: 0; display: flex; flex-direction: column; justify-content: center; --chrome: 200px; }
.game-panel:fullscreen .stage:has(.hud) { --chrome: 240px; }

/* ---------- shared game bits ---------- */
.cv {
  display: block; width: 100%; height: auto;
  border-radius: 14px; background: #0f1320; touch-action: none;
}
.hud { display: flex; gap: 14px; align-items: center; justify-content: center; font-size: 14px; color: var(--muted); flex-wrap: wrap; }
.hud b { color: var(--text); font-variant-numeric: tabular-nums; }
.toggle { padding: 5px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface-2); }
.toggle.on { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }

/* ---------- account / auth ---------- */
.account { display: flex; align-items: center; gap: 8px; flex: none; }
.account .who {
  display: flex; align-items: center; gap: 8px; max-width: 160px;
  padding: 4px 12px 4px 4px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface);
}
.account .avatar {
  width: 30px; height: 30px; border-radius: 50%; flex: none; object-fit: cover;
  display: grid; place-items: center; background: var(--accent); color: var(--accent-text); font-weight: 700; font-size: 13px;
}
.account .name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 13px; font-weight: 600; }
.menu {
  position: absolute; top: 58px; right: 16px; z-index: 20; min-width: 180px;
  padding: 6px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow);
}
.menu p { margin: 6px 10px 8px; font-size: 12px; color: var(--muted); word-break: break-all; }
.menu button { display: block; width: 100%; text-align: left; padding: 8px 10px; border: 0; border-radius: 8px; background: none; }
.menu button:hover { background: var(--surface-2); }

.auth { width: min(400px, 100%); display: grid; gap: 12px; padding: 18px; }
.auth .bar { margin-bottom: 0; }
.google {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  padding: 11px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); font-weight: 600;
}
.google:hover { background: var(--surface-2); }
.divider { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 12px; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.field { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
.field input {
  padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--bg); color: var(--text); font: inherit; outline: none;
}
.field input:focus { border-color: var(--accent); }
.btn.wide { padding: 11px; border-radius: 12px; }
.btn:disabled { opacity: .6; cursor: default; }
.auth-msg { margin: 0; min-height: 1em; font-size: 13px; color: #ef4444; }
.auth-msg.ok { color: #16a34a; }
.auth-links { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.link { border: 0; background: none; padding: 0; color: var(--accent); font-size: 13px; }
.muted { color: var(--muted); }
.small { margin: 0; font-size: 12px; }

/* ---------- ranking ---------- */
.rank { margin-top: 12px; border-top: 1px solid var(--line); padding-top: 10px; }
.rank summary { cursor: pointer; font-weight: 600; font-size: 14px; }
.rank ol { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 4px; }
.rank li { display: grid; grid-template-columns: 28px 1fr auto; gap: 8px; padding: 6px 10px; border-radius: 8px; font-size: 14px; }
.rank li:nth-child(odd) { background: var(--surface-2); }
.rank li.me { outline: 2px solid var(--accent); outline-offset: -2px; }
.rank li.muted { display: block; background: none; font-size: 13px; }
.rank li span:first-child { color: var(--muted); font-variant-numeric: tabular-nums; }
.rank li span:nth-child(2) { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }


/* ---------- my page ---------- */
.me { max-width: 860px; padding-top: 20px; display: grid; gap: 16px; }
.back { color: var(--accent); text-decoration: none; font-size: 14px; }
#meBody { display: grid; gap: 16px; }
.me-card {
  padding: 18px; border-radius: 18px; background: var(--surface);
  border: 1px solid var(--line); box-shadow: var(--shadow);
}
.me-card h1 { margin: 0; font-size: 22px; }
.me-card h2 { margin: 0 0 12px; font-size: 16px; }
.me-card p { margin: 4px 0 0; }
.me-card.center { text-align: center; display: grid; gap: 12px; justify-items: center; padding: 40px 18px; }
.me-head { display: flex; align-items: center; gap: 16px; }
.avatar.lg { width: 64px; height: 64px; font-size: 26px; }
.me-card .avatar {
  border-radius: 50%; flex: none; object-fit: cover; display: grid; place-items: center;
  background: var(--accent); color: var(--accent-text); font-weight: 700;
}
.me-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.me-list li { display: flex; align-items: center; gap: 12px; padding: 8px; border-radius: 12px; background: var(--surface-2); }
.me-emoji {
  width: 44px; height: 44px; flex: none; display: grid; place-items: center; font-size: 24px; border-radius: 12px;
  background: radial-gradient(circle at 30% 20%, color-mix(in srgb, var(--c) 55%, white), var(--c));
}
.me-main { flex: 1; min-width: 0; display: grid; }
.me-main small { color: var(--muted); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.btn.small { padding: 6px 14px; font-size: 13px; }
.radios { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.radio {
  display: flex; align-items: center; gap: 8px; cursor: pointer;
  padding: 8px 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface-2);
}
.radio:has(input:checked) { border-color: var(--accent); }

/* ---------- documents (privacy, terms, contact) ---------- */
.doc { line-height: 1.7; }
.doc h1 { margin: 0 0 4px; font-size: 24px; }
.doc h2 { margin: 26px 0 8px; font-size: 17px; }
.doc ul { padding-left: 20px; margin: 6px 0; }
.doc li { margin: 4px 0; }
.doc a, .foot a, .consent a, .check a, #googleNotice a { color: var(--accent); }
.doc a.btn { color: var(--accent-text); text-decoration: none; }
.contact { display: grid; gap: 12px; margin-top: 16px; max-width: 560px; }
.field select, .field textarea {
  padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--bg); color: var(--text); font: inherit; outline: none; resize: vertical;
}
.field select:focus, .field textarea:focus { border-color: var(--accent); }

/* ---------- footer ---------- */
.foot { max-width: 1100px; margin: 0 auto; padding: 24px 16px 40px; border-top: 1px solid var(--line); text-align: center; }
.foot nav { display: flex; gap: 18px; justify-content: center; flex-wrap: wrap; font-size: 14px; }
.foot a { text-decoration: none; }
.foot p { margin-top: 10px; }

/* ---------- consent banner ---------- */
.consent {
  position: fixed; left: 16px; right: 16px; bottom: calc(16px + env(safe-area-inset-bottom)); z-index: 40; max-width: 720px; margin: 0 auto;
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 14px 16px; border-radius: 16px; background: var(--surface); border: 1px solid var(--line);
  box-shadow: 0 10px 40px rgba(0, 0, 0, .25); font-size: 14px;
}
.consent[hidden] { display: none; }
.consent p { margin: 0; flex: 1 1 260px; }
.consent-btns { display: flex; gap: 8px; }
.btn.ghost { background: var(--surface-2); color: var(--text); border: 1px solid var(--line); }
.consent-setting { padding: 12px 14px; border-radius: 12px; background: var(--surface-2); display: grid; gap: 10px; }
.consent-setting p { margin: 0; }

/* ---------- my page: forms ---------- */
.inline-form { display: flex; gap: 8px; flex-wrap: wrap; }
.inline-form input {
  flex: 1 1 200px; min-width: 0; padding: 9px 12px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--bg); color: var(--text); font: inherit; outline: none;
}
.inline-form input:focus { border-color: var(--accent); }
.form-msg { margin: 8px 0 0; min-height: 1em; font-size: 13px; color: #ef4444; }
.form-msg.ok { color: #16a34a; }
.me-card.danger { border-color: color-mix(in srgb, #ef4444 40%, var(--line)); }
.btn.danger-btn { background: #ef4444; color: #fff; }
.check { display: flex; gap: 8px; align-items: flex-start; font-size: 13px; color: var(--muted); }
.check input { margin-top: 3px; }
.flash { margin: 16px 0 0; padding: 12px 16px; border-radius: 12px; background: color-mix(in srgb, #16a34a 14%, var(--surface)); border: 1px solid color-mix(in srgb, #16a34a 40%, var(--line)); }

/* ---------- home: 본문 + 오른쪽 프레임 ---------- */
main.home {
  max-width: 1240px; display: grid; gap: 0 28px; align-items: start;
  grid-template-columns: minmax(0, 1fr) 300px;
  grid-template-areas: "hero side" "list side";
}
main.home[hidden] { display: none; }
.home > .hero { grid-area: hero; }
.home-list { grid-area: list; min-width: 0; }
.home-side { grid-area: side; position: sticky; top: 84px; display: grid; gap: 14px; padding-top: 36px; }
.home-side:empty { display: none; }
.side-card { padding: 16px; border-radius: 18px; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); }
.side-card h2 { margin: 0 0 4px; font-size: 16px; }
.side-card > p { margin: 0 0 10px; line-height: 1.45; }
.side-card.challenge { background: linear-gradient(160deg, color-mix(in srgb, var(--accent) 14%, var(--surface)), var(--surface) 70%); }
.side-list { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 6px; }
.side-list li { display: flex; align-items: center; gap: 10px; min-width: 0; }
.side-link { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; padding: 4px; margin: -4px; border-radius: 12px; color: var(--text); text-decoration: none; }
.side-link:hover { background: var(--surface-2); }
.side-emoji {
  width: 38px; height: 38px; flex: none; display: grid; place-items: center; font-size: 21px; border-radius: 11px;
  background: radial-gradient(circle at 30% 20%, color-mix(in srgb, var(--c) 55%, white), var(--c));
}
.side-list .me-main b { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-play { color: var(--muted); font-size: 12px; padding-right: 4px; }
.side-link:hover .side-play { color: var(--accent); }

@media (max-width: 960px) {
  main.home { grid-template-columns: 1fr; grid-template-areas: "hero" "side" "list"; }
  .home-side { position: static; padding-top: 0; margin-bottom: 8px; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
}

/* ---------- cards ---------- */
.card h3 a { color: inherit; text-decoration: none; }
.new-icon {
  position: absolute; top: 10px; left: 10px; width: 34px; height: 34px;
  display: grid; place-items: center; border-radius: 50%; font-size: 16px;
  background: rgba(0, 0, 0, .25); backdrop-filter: blur(4px);
}

/* ---------- game page ---------- */
#gamePage { display: grid; gap: 18px; }
#gamePage[hidden] { display: none; }
.game-hero {
  display: grid; grid-template-columns: 200px 1fr; gap: 22px; align-items: center;
  padding: 20px; border-radius: 20px; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow);
}
.game-hero-thumb {
  aspect-ratio: 1; display: grid; place-items: center; font-size: 96px; border-radius: 18px;
  background: radial-gradient(circle at 30% 20%, color-mix(in srgb, var(--c) 55%, white), var(--c));
}
.game-hero-info h1 { margin: 8px 0 6px; font-size: 28px; }
.game-hero-info p { margin: 4px 0; }
.hero-btns { display: flex; gap: 8px; flex-wrap: wrap; margin: 14px 0 10px; }
.btn.big { padding: 11px 22px; font-size: 16px; }

/* ---------- ranking panel ---------- */
.rank-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.tab.small { padding: 5px 12px; font-size: 13px; }
.rank-panel .rank-list { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 4px; }
.rank-panel .rank-list li { display: grid; grid-template-columns: 28px 1fr auto; gap: 8px; padding: 6px 10px; border-radius: 8px; font-size: 14px; }
.rank-panel .rank-list li:nth-child(odd) { background: var(--surface-2); }
.rank-panel .rank-list li.me { outline: 2px solid var(--accent); outline-offset: -2px; }
.rank-panel .rank-list li.muted { display: block; background: none; font-size: 13px; }
.rank-panel .rank-list li span:first-child { color: var(--muted); font-variant-numeric: tabular-nums; }
.rank-panel .rank-list li span:nth-child(2) { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-note { margin: 8px 0 0; }

/* ---------- game over / toast ---------- */
.over-btns { display: flex; gap: 8px; justify-content: center; }
.overlay .btn.ghost { background: rgba(255, 255, 255, .15); color: #fff; border-color: rgba(255, 255, 255, .3); }
.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 80;
  padding: 10px 18px; border-radius: 999px; background: var(--text); color: var(--bg); font-size: 14px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .3); animation: fade .2s ease;
  /* left: 50% 이면 폭이 화면 절반으로 묶여 긴 문구가 여러 줄로 좁아진다 → 글자 폭만큼, 화면 폭 - 여백까지 */
  width: max-content; max-width: min(440px, calc(100vw - 32px)); text-align: center; line-height: 1.45;
}

/* ---------- game toolbar: level, pause, sound ---------- */
.mtools { display: flex; align-items: center; gap: 8px; margin: -4px 0 10px; flex-wrap: wrap; }
.mtools-gap { flex: 1; }
.tool-btn {
  padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface-2);
  font-size: 13px; font-weight: 700; white-space: nowrap;
}
.tool-btn:hover { border-color: var(--accent); }
#mLevel { height: 32px; font-weight: 700; }

/* ---------- achievements, likes ---------- */
.ach-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 8px; }
.ach-grid li { display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: 14px; background: var(--surface-2); opacity: .55; }
.ach-grid li.on { opacity: 1; background: color-mix(in srgb, var(--accent) 12%, var(--surface)); }
.ach-icon { font-size: 26px; width: 36px; text-align: center; flex: none; }
.ach-icon img { width: 30px; height: 30px; object-fit: contain; vertical-align: middle; } /* 업적 아이콘이 그림 주소면 그림으로 */
.ach-grid small { color: var(--muted); font-size: 12px; }
.like-btn[aria-pressed="true"] { color: #e11d48; border-color: color-mix(in srgb, #e11d48 40%, var(--line)); }

/* ---------- news ---------- */
.notice { padding: 18px 0; border-top: 1px solid var(--line); scroll-margin-top: 90px; }
.notice.focus { animation: pop .6s ease; }
.notice h2 { margin: 6px 0 8px; font-size: 19px; }
.notice p { margin: 0; line-height: 1.7; }
.notice-meta { display: flex; align-items: center; gap: 8px; }
.notice-kind {
  display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 800;
  color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, var(--surface));
}
.notice-mini { list-style: none; margin: 8px 0 6px; padding: 0; display: grid; gap: 4px; }
.notice-mini a { display: grid; gap: 2px; padding: 6px 8px; margin: 0 -8px; border-radius: 10px; color: var(--text); text-decoration: none; }
.notice-mini a:hover { background: var(--surface-2); }
.notice-mini b { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.notice-mini .notice-kind { justify-self: start; }
.notice-mini small { color: var(--muted); font-size: 12px; }
.side-more { font-size: 13px; font-weight: 700; color: var(--accent); text-decoration: none; }

/* ---------- 404 ---------- */
.not-found { text-align: center; padding: 20px 0 28px; }
.nf-emoji { font-size: 84px; animation: bob 1.6s ease-in-out infinite; }
.not-found h1 { margin: 8px 0 6px; }

/* ---------- admin ---------- */
main.admin { max-width: 1100px; }
#adminBody { display: grid; gap: 16px; }
.admin-form { display: grid; gap: 12px; }
.admin-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.admin-row select, .admin-row .field select { padding: 8px 10px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); color: var(--text); font: inherit; }
.admin-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.admin-table th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 800; padding: 6px 8px; border-bottom: 1px solid var(--line); }
.admin-table td { padding: 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.admin-table td.actions { white-space: nowrap; text-align: right; }
.admin-table tr.banned td { opacity: .6; }
.admin-table td.rev-cell { max-width: 320px; white-space: pre-wrap; overflow-wrap: anywhere; }
.admin-msgs { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.admin-msgs li { padding: 12px 14px; border-radius: 14px; background: var(--surface-2); }
.admin-msgs li.done { opacity: .55; }
.admin-msgs p { margin: 8px 0; white-space: normal; }
@media (max-width: 720px) {
  .admin-table { display: block; overflow-x: auto; }
}

/* ---------- game list: view toggle + icon view ---------- */
.list-bar { display: flex; align-items: center; gap: 10px; margin: 12px 0 18px; }
.list-bar .tabs { margin: 0; flex: 1; min-width: 0; }
.view-toggle { display: flex; gap: 4px; padding: 3px; border-radius: 999px; background: var(--surface); box-shadow: var(--shadow); flex: none; }
.view-btn { width: 34px; height: 30px; border: 0; border-radius: 999px; background: none; color: var(--muted); font-size: 16px; font-weight: 900; }
.view-btn.on { background: var(--accent); color: var(--accent-text); }
.grid.icons { grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 14px 10px; }
.tile { cursor: pointer; display: grid; justify-items: center; gap: 6px; outline: none; }
.tile-icon {
  position: relative; width: 100%; aspect-ratio: 1; border-radius: 24%; display: grid; place-items: center;
  font-size: clamp(34px, 9vw, 46px); box-shadow: var(--shadow);
  background: radial-gradient(circle at 30% 20%, color-mix(in srgb, var(--c) 55%, white), var(--c));
  transition: transform .15s cubic-bezier(.2, .9, .3, 1.2), box-shadow .15s ease;
}
@media (hover: hover) { .tile:hover .tile-icon { transform: translateY(-3px) scale(1.05); box-shadow: var(--shadow-hover); } }
.tile:focus-visible .tile-icon { transform: translateY(-3px) scale(1.05); box-shadow: var(--shadow-hover); }
.tile:active:not(:has(.tile-fav:active)) .tile-icon { transform: scale(.96); }
.tile-new, .tile-fav {
  position: absolute; top: -4px; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center;
  font-size: 12px; background: var(--surface); box-shadow: 0 2px 6px rgba(0, 0, 0, .18);
}
.tile-new { left: -4px; }
.tile-fav { right: -4px; color: #f5b301; }
.tile-name {
  font-size: 13px; font-weight: 800; color: var(--text); text-decoration: none; text-align: center; line-height: 1.25;
  max-width: 100%; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}

/* ---------- ratings & comments ---------- */
.rev-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.rev-head h2 { margin-bottom: 8px; }
.stars { color: #f59e0b; letter-spacing: 1px; }
.rev-avg b { font-size: 18px; }
.rev-login { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 12px 14px; border-radius: 14px; background: var(--surface-2); }
.rev-login p { margin: 0; }
.rev-form { display: grid; gap: 8px; padding: 14px; border-radius: 16px; background: var(--surface-2); }
.rev-label { font-weight: 800; font-size: 14px; }
.star-pick { display: flex; gap: 4px; }
.star-pick button { border: 0; background: none; padding: 0 2px; font-size: 32px; line-height: 1; color: color-mix(in srgb, var(--muted) 45%, transparent); transition: transform .1s; }
.star-pick button.on { color: #f59e0b; }
.star-pick button:hover { transform: scale(1.15); }
.rev-form textarea {
  width: 100%; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface);
  color: var(--text); font: inherit; resize: vertical; outline: none;
}
.rev-form textarea:focus { border-color: var(--accent); }
.rev-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.rev-actions .form-msg { flex: 1; margin: 0; }
.rev-list { list-style: none; margin: 14px 0 0; padding: 0; display: grid; gap: 4px; }
.rev-list li { padding: 12px 4px; border-top: 1px solid var(--line); }
.rev-list li.mine { background: color-mix(in srgb, var(--accent) 6%, transparent); border-radius: 12px; padding: 12px; }
.rev-list li.muted { border: 0; }
.rev-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.rev-list p { margin: 6px 0 0; line-height: 1.6; overflow-wrap: anywhere; }

/* ---------- 결과 카드 (게임 종료) ---------- */
.stage:has(.over-ov) { min-height: min(470px, calc(100dvh - 150px)); }
.overlay.over-ov { place-content: safe center; grid-template-columns: min(380px, 100%); overflow: auto; padding: 12px; background: rgba(10, 12, 20, .82); backdrop-filter: blur(3px); }
.over-card {
  width: min(380px, 100%); display: grid; gap: 10px; justify-items: center; padding: 0 0 18px; overflow: hidden;
  border-radius: 22px; background: var(--surface); color: var(--text); box-shadow: 0 18px 50px rgba(0, 0, 0, .45);
  animation: card-in .35s cubic-bezier(.2, 1.4, .4, 1);
}
@keyframes card-in { from { transform: translateY(18px) scale(.94); opacity: 0; } }
.over-art {
  position: relative; width: 100%; height: 132px; overflow: hidden;
  background: radial-gradient(circle at 50% 120%, color-mix(in srgb, var(--c) 55%, #fff), var(--c) 55%, color-mix(in srgb, var(--c) 70%, #000));
}
.oa-deco span { position: absolute; font-size: 28px; opacity: .22; transform: rotate(var(--r)); }
.oa-deco span:nth-child(1) { left: 6%; top: 12%; --r: -18deg; }
.oa-deco span:nth-child(2) { left: 20%; top: 58%; --r: 12deg; font-size: 22px; }
.oa-deco span:nth-child(3) { left: 74%; top: 10%; --r: 20deg; font-size: 22px; }
.oa-deco span:nth-child(4) { left: 86%; top: 55%; --r: -10deg; }
.oa-deco span:nth-child(5) { left: 34%; top: 6%; --r: 8deg; font-size: 18px; }
.oa-deco span:nth-child(6) { left: 62%; top: 66%; --r: -24deg; font-size: 18px; }
.oa-main {
  position: absolute; left: 50%; top: 50%; translate: -50% -50%; font-size: 72px; line-height: 1; /* translate·rotate·scale 를 따로 둬서 출렁임이 아래의 줄이기(scale)를 덮지 않게 */
  filter: drop-shadow(0 6px 10px rgba(0, 0, 0, .35)); animation: oa-bob 2.4s ease-in-out infinite;
}
/* 목록 아이콘 키우기(iconScale)는 타일을 채우려는 것이라 결과 창 띠에서는 쓰지 않고, 그림 아이콘도 이모지 크기에 가깝게 (띠가 낮아 출렁일 때 위가 잘림, 미니 골프 1.5) */
.oa-main .g-icon { display: block; scale: none; width: 1.1em; height: 1.1em; }
@keyframes oa-bob { 50% { translate: -50% -58%; rotate: -4deg; } }
@keyframes oa-pop { from { transform: scale(0) rotate(-40deg); } }
.over-ov.record .over-art { background: radial-gradient(circle at 50% 120%, #fff7c2, #facc15 45%, var(--c)); }
.oa-confetti i {
  position: absolute; top: -10px; left: var(--x); width: 7px; height: 12px; border-radius: 2px;
  background: hsl(var(--h) 90% 60%); animation: confetti 1.6s var(--d) ease-in infinite;
}
@keyframes confetti { to { transform: translateY(160px) rotate(540deg); opacity: .2; } }
.over-card h3 { margin: 4px 16px 0; font-size: 22px; }
.over-score { display: grid; justify-items: center; line-height: 1; }
.over-score small { font-size: 13px; font-weight: 700; color: var(--muted); letter-spacing: .08em; }
.over-score b { font-size: clamp(44px, 12vw, 64px); font-weight: 900; font-variant-numeric: tabular-nums; color: var(--c-ink, var(--c)); /* 게임 색, 카드에서 안 보이면 portal.js readableOn 이 진하게·밝게 */ margin-top: 4px; }
.over-ov.record .over-score b { background: linear-gradient(90deg, #f59e0b, #ef4444, #a855f7); -webkit-background-clip: text; background-clip: text; color: transparent; }
.over-stats { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; font-size: 15px; color: var(--muted); }
.over-stats { gap: 0; }
/* 기록 칸: 버튼으로 보이지 않게 테두리·배경 없이, 칸 사이에 가는 세로줄만 (진짜 버튼은 아래 .over-btns 뿐) */
.over-stats > span { padding: 0 14px; display: grid; align-content: center; justify-items: center; font-size: 13px; }
.over-stats > span + span { border-left: 1px solid var(--line); }
.over-stats > .chip { border: 0; background: none; color: var(--accent); font-weight: 800; } /* '오늘의 도전' 표시도 버튼처럼 보이지 않게 */
.over-stats b { color: var(--text); font-variant-numeric: tabular-nums; font-size: 18px; order: 2; }
.over-stats .up { color: #16a34a; font-weight: 800; }
.over-card .over-sub { margin: 0 16px; font-size: 15px; color: var(--text); opacity: .8; }
.over-card .new { margin: 0; font-size: 18px; color: #d97706; font-weight: 900; }
.over-card .over-btns { margin-top: 4px; flex-wrap: wrap; padding: 0 12px; }
/* 버튼 글자는 줄바꿈하지 않는다 (좁으면 버튼째 다음 줄로). 휴대폰에서는 조금 작게 */
.over-card .over-btns .btn { white-space: nowrap; }
@media (max-width: 520px) { .over-card .over-btns { gap: 6px; padding: 0 8px; } .over-card .over-btns .btn.big { padding: 10px 11px; font-size: 15px; } }
.over-card .btn.ghost { background: var(--surface-2); color: var(--text); border-color: var(--line); }
@media (prefers-reduced-motion: reduce) { .oa-main, .oa-confetti i, .over-card { animation: none; } }

/* ---------- 게임 소개 (게임 페이지) ---------- */
.guide { border-top: 4px solid var(--c); }
.guide-intro { font-size: 16px; line-height: 1.7; margin: 0 0 10px; }
.guide-meta { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.guide-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 14px; }
.guide-cols > div { padding: 14px 16px; border-radius: 14px; background: var(--surface-2); }
.guide-cols h3 { margin: 0 0 8px; font-size: 16px; }
.guide-cols ol, .guide-cols ul { margin: 0; padding-left: 20px; display: grid; gap: 6px; line-height: 1.6; font-size: 15px; }

/* ---------- 게임 창 상단: 게임 이름·점수·최고 기록 ---------- */
.game-panel .bar h2 { display: flex; align-items: center; gap: 10px; font-size: 24px; font-weight: 900; letter-spacing: -.01em; min-width: 0; }
.m-emoji {
  flex: none; width: 44px; height: 44px; display: grid; place-items: center; font-size: 26px; border-radius: 14px;
  background: linear-gradient(145deg, color-mix(in srgb, var(--c) 35%, #fff), var(--c));
  box-shadow: 0 3px 0 color-mix(in srgb, var(--c) 70%, #000), inset 0 1px 0 rgba(255, 255, 255, .5);
}
.m-name { overflow: hidden; text-overflow: ellipsis; }
.m-tag { flex: none; font-size: 13px; font-weight: 800; padding: 4px 10px; border-radius: 999px; background: color-mix(in srgb, var(--c) 18%, var(--surface)); color: var(--text); }
.game-panel .scores { gap: 8px; }
.sc-pill {
  display: grid; justify-items: center; min-width: 78px; padding: 4px 14px 5px; border-radius: 14px; line-height: 1.05;
  background: var(--surface-2); border: 1px solid var(--line);
}
.sc-pill small { font-size: 11px; font-weight: 800; color: var(--muted); letter-spacing: .04em; }
.sc-pill b { font-size: 24px; font-weight: 900; font-variant-numeric: tabular-nums; }
.sc-pill.now { background: color-mix(in srgb, var(--c) 14%, var(--surface)); border-color: color-mix(in srgb, var(--c) 40%, transparent); }
.sc-pill.now b { color: color-mix(in srgb, var(--c) 75%, var(--text)); }
.sc-pill.best { background: color-mix(in srgb, #facc15 14%, var(--surface)); border-color: color-mix(in srgb, #f59e0b 35%, transparent); }
.sc-pill.best b { color: #b45309; }
:root[data-theme="dark"] .sc-pill.best b { color: #fbbf24; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .sc-pill.best b { color: #fbbf24; } }
.sc-pill.beat { animation: beat-glow 1.2s ease-in-out infinite alternate; }
@keyframes beat-glow { to { box-shadow: 0 0 0 3px rgba(250, 204, 21, .55), 0 0 18px rgba(250, 204, 21, .5); } }
#mScore.bump { display: inline-block; animation: score-bump .25s ease; }
@keyframes score-bump { 40% { transform: scale(1.25); } }
@media (max-width: 640px) {
  .game-panel .bar h2 { font-size: 20px; gap: 8px; }
  .m-emoji { width: 36px; height: 36px; font-size: 21px; border-radius: 11px; }
  .sc-pill { min-width: 64px; padding: 3px 10px 4px; }
  .sc-pill b { font-size: 20px; }
}
@media (prefers-reduced-motion: reduce) { .sc-pill.beat, #mScore.bump { animation: none; } }

/* 게임 목록 아이콘이 그림일 때: 이모지와 같은 크기로 */
.g-icon { scale: var(--k, 1); width: 1.25em; height: 1.25em; object-fit: contain; vertical-align: middle; filter: drop-shadow(0 .06em .08em rgba(0, 0, 0, .25)); }
.side-emoji .g-icon, .me-emoji .g-icon { width: 1.1em; height: 1.1em; }

/* ---------- 전체 게임 링크 (꼬리말·소개 페이지) ---------- */
.foot nav.all-games { display: block; max-width: 1100px; margin: 0 auto 18px; text-align: left; }
.all-games > h2 { font-size: 15px; margin: 0 0 10px; color: var(--muted); }
.all-games-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 14px 22px; }
.all-games-list h2, .all-games-list h3 { font-size: 13px; margin: 0 0 6px; color: var(--text); }
.all-games-list ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 3px; font-size: 13px; }
.all-games-list a { color: var(--muted); text-decoration: none; }
.all-games-list a:hover { color: var(--accent); text-decoration: underline; }
.doc .all-games-list { margin-top: 18px; }
.doc .all-games-list h2 { font-size: 16px; }
.doc .all-games-list ul { font-size: 15px; }

/* ---------- 휴대폰 가로 화면: 왼쪽 세로 막대 + 오른쪽 게임 (세로 높이를 게임에 최대한) ---------- */
.rotate-hint { display: flex; align-items: center; justify-content: center; gap: 6px; margin: 0 0 8px; padding: 6px 10px; border-radius: 12px; background: var(--surface-2); font-size: 13px; font-weight: 700; }
.rotate-hint .icon-btn { width: 26px; height: 26px; font-size: 12px; }
@media (orientation: landscape), (pointer: fine) { .rotate-hint { display: none; } }
@media (orientation: landscape) and (max-height: 540px) and (pointer: coarse) {
  #modal { padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); }
  .panel.game-panel {
    width: 100%; height: 100%; max-height: none; border-radius: 0; padding: 6px 8px;
    display: grid; grid-template-columns: 132px minmax(0, 1fr); grid-template-rows: auto 1fr auto auto 1fr auto; gap: 6px 8px; align-items: start;
    --chrome: 16px;
  }
  /* 왼쪽 막대: 점수(위) → 다시·(간격)·난이도·도움말·일시정지·소리(가운데) → 전체 화면·나가기(맨 아래) */
  .game-panel .bar { display: contents; }
  .game-panel .scores { grid-column: 1; grid-row: 1; }
  .game-panel .bar > #mRestart { grid-column: 1; grid-row: 3; justify-self: stretch; margin-bottom: 14px; }
  .game-panel .bar-btns { grid-column: 1; grid-row: 6; align-self: end; justify-self: stretch; }
  .game-panel .bar h2 { font-size: 14px; gap: 6px; white-space: normal; }
  .game-panel .m-emoji { width: 28px; height: 28px; font-size: 17px; border-radius: 9px; }
  .game-panel .m-tag { display: none; }
  .game-panel .scores { flex-direction: column; gap: 4px; }
  .game-panel .sc-pill { min-width: 0; padding: 2px 8px; }
  .game-panel .sc-pill b { font-size: 17px; }
  .game-panel #mRestart { padding: 8px; font-size: 14px; }
  .game-panel .bar-btns { gap: 4px; }
  .game-panel #mFull { width: 36px; height: 34px; border-radius: 10px; }
  .game-panel #mClose { flex: 1; height: 34px; padding: 0 6px; justify-content: center; font-size: 13px; border-radius: 10px; }
  .game-panel .mtools { grid-column: 1; grid-row: 4; flex-direction: column; align-items: stretch; gap: 4px; margin: 0; }
  .game-panel .mtools-gap { display: none; }
  .game-panel .mtools .tool-btn, .game-panel #mLevel { font-size: 12px; padding: 4px 6px; }
  /* 난이도는 한 줄, 도움말·일시정지·소리는 아이콘만 한 줄에 (이름은 aria-label) */
  .game-panel .mtools { flex-direction: row; flex-wrap: wrap; }
  .game-panel .mtools > #mLevel { flex: 1 1 100%; }
  .game-panel .mtools .tool-btn { flex: 1 1 0; min-width: 0; height: 32px; padding: 0; font-size: 15px; justify-content: center; }
  .game-panel .mtools .tool-btn .tl { display: none; }
  /* 점수·최고는 정보: 버튼처럼 보이지 않게 테두리·그림자 없이 '이름 … 값' 줄로, 아래 버튼들과 점선으로 나눈다 */
  .game-panel .scores { gap: 2px; padding-bottom: 10px; margin-bottom: 4px; border-bottom: 2px dashed var(--line); }
  .game-panel .sc-pill { display: flex; justify-content: space-between; align-items: baseline; padding: 0 4px; border: 0 !important; background: transparent; box-shadow: none; }
  .game-panel .sc-pill small { font-size: 12px; }
  .game-panel .sc-pill b { font-size: 18px; }
  .game-panel .mtools { margin-top: 6px; }
  .game-panel .stage { grid-column: 2; grid-row: 1 / -1; align-self: center; }
  .stage:has(.hud) { --chrome: 50px; }
  .game-panel .help, .game-panel .rotate-hint { display: none; }
  .panel.game-panel { --chrome-free: 0px; } /* 가로 화면은 랭킹·설명을 원래 안 보였다 */
  .game-panel .sc-pill { width: 100%; }
  /* 결과 카드: 낮은 화면에 맞게 작게, 위가 잘리지 않게 */
  .stage:has(.over-ov) { min-height: calc(100dvh - 14px); }
  .overlay.over-ov { align-content: safe center; padding: 8px; }
  .over-card { gap: 6px; padding-bottom: 12px; }
  .over-art { height: 72px; }
  .oa-main { font-size: 44px; }
  .over-card h3 { font-size: 18px; margin-top: 2px; }
  .over-score b { font-size: 38px; }
  .over-card .new { font-size: 15px; }
}

/* ---------- visual polish (Poki · CrazyGames 참고) ---------- */
.top { background: color-mix(in srgb, var(--surface) 78%, transparent); border-bottom-color: transparent; box-shadow: 0 1px 0 var(--line), 0 6px 20px rgba(38, 30, 110, .05); }
.brand > span[data-i18n="site.name"] {
  font-weight: 900; font-size: 20px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2)); -webkit-background-clip: text; background-clip: text; color: transparent;
}
#search { background: var(--surface-2); border-color: transparent; font-weight: 600; }
#search:focus { background: var(--surface); border-color: var(--accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 18%, transparent); }

/* 버튼: 아래쪽 그림자로 눌리는 느낌 */
.btn { font-weight: 800; box-shadow: 0 3px 0 var(--accent-strong); transition: transform .08s ease, box-shadow .08s ease, filter .15s; }
.btn:hover { filter: brightness(1.07); }
.btn:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--accent-strong); }
.btn.ghost { box-shadow: 0 3px 0 var(--line); }
.btn.ghost:active { box-shadow: 0 1px 0 var(--line); }
.btn.danger-btn { box-shadow: 0 3px 0 #b91c1c; }
.overlay .btn.ghost { box-shadow: none; }

/* 히어로: 색 그라디언트 배너 */
.hero {
  position: relative; overflow: hidden; margin-top: 24px; padding: 30px 30px 26px; border-radius: 26px; color: #fff;
  background: linear-gradient(120deg, var(--accent) 0%, #a24dff 55%, var(--accent-2) 110%);
  box-shadow: 0 14px 34px color-mix(in srgb, var(--accent) 35%, transparent);
}
.hero::after {
  content: "🐍 🔢 💣 🃏 🧱"; position: absolute; right: -10px; bottom: -14px; font-size: 64px; letter-spacing: 6px;
  opacity: .22; transform: rotate(-8deg); pointer-events: none; white-space: nowrap;
}
.hero h1 { font-size: clamp(26px, 4vw, 38px); position: relative; }
.hero p { color: rgba(255, 255, 255, .9); max-width: 620px; position: relative; font-weight: 600; }
.stats { position: relative; }
.stats div { background: rgba(255, 255, 255, .16); border: 1px solid rgba(255, 255, 255, .25); color: rgba(255, 255, 255, .85); backdrop-filter: blur(6px); font-weight: 700; }
.stats b { color: #fff; font-weight: 900; }
.home-side { padding-top: 24px; }

/* 탭: 선택된 탭은 강조색 */
.tab { font-weight: 800; background: var(--surface); border-color: transparent; box-shadow: var(--shadow); }
.tab:hover { color: var(--text); }
.tab.on { background: var(--accent); color: var(--accent-text); border-color: var(--accent); box-shadow: 0 3px 0 var(--accent-strong); }

/* 게임 카드: 둥근 타일, 마우스를 올리면 살짝 커짐 */
.card { border: 0; border-radius: 22px; transition: transform .18s cubic-bezier(.2, .9, .3, 1.2), box-shadow .18s ease; }
.card:hover, .card:focus-visible { transform: translateY(-5px) scale(1.02); box-shadow: var(--shadow-hover); }
.thumb { height: 140px; font-size: 68px; }
.thumb { text-shadow: 0 10px 18px rgba(0, 0, 0, .18); }
.info h3 { font-size: 18px; }
.info p { font-weight: 600; }
.chip { font-weight: 800; color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, var(--surface)); }
.meta { font-weight: 700; }

/* 카드형 상자들 */
.me-card, .side-card, .game-hero, .challenge-item { border-radius: 22px; border-color: transparent; }
.side-card.challenge { background: linear-gradient(160deg, color-mix(in srgb, var(--accent) 16%, var(--surface)), var(--surface) 75%); }
.panel { border-radius: 24px; }
.foot { border-top-color: transparent; }

@media (max-width: 720px) {
  .tagline { display: none; }
  .game-hero { grid-template-columns: 1fr; text-align: center; }
  .game-hero-thumb { width: 140px; margin: 0 auto; font-size: 72px; }
  .hero-btns { justify-content: center; }
}

@media (max-width: 520px) {
  .top { gap: 8px; flex-wrap: wrap; }
  .brand { flex: 1; overflow: hidden; font-size: 16px; gap: 6px; }
  .brand > span:not(.logo) { overflow: hidden; text-overflow: ellipsis; }
  .lang { height: 34px; padding: 0 4px; font-size: 12px; }
  .icon-btn { width: 34px; height: 34px; }
  .account .btn { padding: 7px 12px; font-size: 13px; }
  .brand > span[data-i18n="site.name"] { font-size: 17px; }
  .brand .logo { font-size: 20px; }
  .hero { padding: 24px 20px 22px; border-radius: 22px; }
  .hero::after { font-size: 40px; letter-spacing: 2px; right: -6px; bottom: -8px; opacity: .14; }
  /* 휴대폰: 게임 목록을 바로 보이게 (소개 → 게임 목록 → 오늘의 도전·이어서 하기·공지) */
  main.home { grid-template-areas: "hero" "list" "side"; }
  .home-side { grid-template-columns: 1fr; margin: 18px 0 0; }
  .hero { margin-top: 14px; padding: 18px 18px 16px; }
  .hero h1 { font-size: 22px; }
  .hero p { font-size: 13.5px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
  .stats { display: none; }
  .grid.icons { grid-template-columns: repeat(4, 1fr); gap: 14px 10px; }
  .list-bar { margin: 12px 0 14px; }
  #search { order: 10; flex-basis: 100%; max-width: none; margin-left: 0; }
  .account .name { display: none; }
  .account .who { padding-right: 4px; }
  .bar { display: grid; grid-template-columns: 1fr auto; row-gap: 8px; column-gap: 8px; }
  .game-panel .bar { grid-template-columns: minmax(0, 1fr) auto; }
  .bar h2 { grid-row: 1; grid-column: 1; }
  .bar-btns { grid-row: 1; grid-column: 2; }
  .game-panel .scores { grid-row: 2; grid-column: 1 / 3; justify-self: center; }
  /* 휴대폰에서는 게임 창을 화면 전체로 */
  #modal { padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); }
  .panel.game-panel { width: 100%; height: 100%; max-height: none; border-radius: 0; padding: 10px; --chrome: 210px; }
  .stage:has(.hud) { --chrome: 245px; }
}

/* ======================================================================
   스티커 아케이드 테마: 굵은 테두리 + 그림자 없이 아래로 밀린 단색 그림자 + 캔디 색
   (위의 기존 스타일을 덮어쓴다. 게임 화면(.stage 안)은 건드리지 않는다)
   ====================================================================== */
:root {
  --bg: #fff7e8;
  --surface: #ffffff;
  --surface-2: #fff1d9;
  --text: #2b2350;
  --muted: #6c6390;
  --line: #eadcbd;
  --ink: #2b2350;          /* 스티커 테두리·그림자 색 */
  --accent: #8b6cff;
  --accent-strong: #2b2350;
  --accent-2: #ff6fa5;
  --accent-text: #ffffff;
  --dots: #f1dfb9;
  --candy-pink: #ff8fb8; --candy-yellow: #ffd54a; --candy-mint: #5fe0b7; --candy-sky: #6ec6ff; --candy-orange: #ffa552;
  --b: 3px;                /* 테두리 두께 */
  --lift: 5px;             /* 그림자 높이 */
  --shadow: 0 var(--lift) 0 var(--ink);
  --shadow-hover: 0 calc(var(--lift) + 3px) 0 var(--ink);
  --font-fun: "Fredoka", "Jua", -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Malgun Gothic", "맑은 고딕", "Noto Sans KR", system-ui, sans-serif;
  --font: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Malgun Gothic", "맑은 고딕", "Noto Sans KR", system-ui, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #17142e; --surface: #252049; --surface-2: #302a5c; --text: #fbf6ff; --muted: #b9b0de; --line: #3b3470;
    --ink: #07050f; --accent: #9d82ff; --accent-strong: #07050f; --accent-2: #ff7fb0; --dots: #221d42;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #17142e; --surface: #252049; --surface-2: #302a5c; --text: #fbf6ff; --muted: #b9b0de; --line: #3b3470;
  --ink: #07050f; --accent: #9d82ff; --accent-strong: #07050f; --accent-2: #ff7fb0; --dots: #221d42;
  color-scheme: dark;
}
body { background: var(--bg) radial-gradient(var(--dots) 1.6px, transparent 1.7px) 0 0 / 22px 22px; background-attachment: fixed; }
h1, h2, h3, .btn, .tab, .chip, .stats b, .side-card h2, .me-card h2, .tile-name, .info h3, .section-title, .rank-head, .over-card h3 { font-family: var(--font-fun); font-weight: 600; letter-spacing: 0; }
h1 { font-weight: 700; }

/* 공통 스티커: 테두리 + 아래로 밀린 단색 그림자 */
.card, .side-card, .me-card, .game-hero, .panel, .tile-icon, .stats div, .toast, .consent, .over-card, .view-toggle {
  border: var(--b) solid var(--ink) !important; box-shadow: var(--shadow) !important;
}

/* ---------- 머리글: 떠 있는 흰 스티커 막대 ---------- */
.top {
  max-width: 1100px; margin: 12px auto 0; border: var(--b) solid var(--ink); border-radius: 22px;
  background: var(--surface); box-shadow: var(--shadow); backdrop-filter: none; top: 10px;
}
@media (min-width: 1132px) { .top { width: calc(100% - 32px); } }
.brand-name { font-family: "Fredoka", system-ui, sans-serif; font-weight: 700; font-size: 25px; letter-spacing: .5px; white-space: nowrap; }
.brand-name i { font-style: normal; display: inline-block; transform: rotate(-5deg); text-shadow: 1.5px 1.5px 0 var(--ink); }
.brand-name i:nth-child(2n) { transform: rotate(6deg) translateY(2px); }
.brand-name i:nth-child(6n+1) { color: var(--candy-pink); } .brand-name i:nth-child(6n+2) { color: var(--candy-orange); }
.brand-name i:nth-child(6n+3) { color: var(--candy-yellow); } .brand-name i:nth-child(6n+4) { color: var(--candy-mint); }
.brand-name i:nth-child(6n+5) { color: var(--candy-sky); } .brand-name i:nth-child(6n) { color: var(--accent); }
.brand .logo { font-size: 26px; transform: rotate(-8deg); }
#search, .lang, .icon-btn { border: 2.5px solid var(--ink); background: var(--surface); box-shadow: 0 3px 0 var(--ink); font-weight: 600; }
#search:focus { border-color: var(--ink); box-shadow: 0 3px 0 var(--ink), 0 0 0 4px color-mix(in srgb, var(--accent) 30%, transparent); }

/* ---------- 버튼: 눌리는 장난감 버튼 ---------- */
.btn {
  border: var(--b) solid var(--ink); border-radius: 999px; font-weight: 600; font-size: 15px; padding: 7px 18px;
  box-shadow: 0 4px 0 var(--ink); transition: transform .08s ease, box-shadow .08s ease, filter .15s;
}
.btn:hover { filter: brightness(1.06); transform: translateY(-1px); box-shadow: 0 5px 0 var(--ink); }
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
.btn.ghost { background: var(--surface); color: var(--text); border: var(--b) solid var(--ink); box-shadow: 0 4px 0 var(--ink); }
.btn.ghost:active { box-shadow: 0 1px 0 var(--ink); }
.btn.danger-btn { box-shadow: 0 4px 0 var(--ink); }
.btn.small { padding: 4px 13px; font-size: 13px; border-width: 2.5px; box-shadow: 0 3px 0 var(--ink); }
.btn.big { font-size: 18px; padding: 10px 24px; }
.icon-btn:active, .tab:active, .tool-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--ink); }

/* ---------- 히어로: 단색 무대 + 둥둥 떠다니는 아이콘 ---------- */
.hero {
  background: var(--accent); border: var(--b) solid var(--ink); border-radius: 28px; box-shadow: 0 7px 0 var(--ink);
  padding: 28px 30px 26px;
}
.hero::after { content: none; }
.hero h1 { color: #fff; font-size: clamp(28px, 4.4vw, 40px); text-shadow: 3px 3px 0 var(--ink); }
.hero p { color: #fff; font-weight: 600; max-width: 560px; }
.stats div { background: var(--surface) !important; color: var(--muted) !important; border-radius: 16px; backdrop-filter: none !important; border-width: 2.5px !important; box-shadow: 0 3px 0 var(--ink) !important; }
.stats b { color: var(--text) !important; font-weight: 700; }
.play-random { position: relative; margin-top: 16px; background: var(--candy-yellow); color: #2b2350; font-size: 18px; padding: 9px 22px; }
.hero > :not(.hero-art) { position: relative; z-index: 2; }
.hero-art { position: absolute; inset: 0; z-index: 1; pointer-events: none; }
.hero[data-art] > h1, .hero[data-art] > p { max-width: 60%; } /* 오른쪽은 그림 자리 */
.hero-art img, .hero-art .mascot { position: absolute; animation: hero-bob 3.4s ease-in-out infinite; }
.hero-art > img { transform: rotate(var(--r, 0deg)); filter: drop-shadow(0 4px 0 rgba(43, 35, 80, .35)); }
@keyframes hero-bob { 50% { translate: 0 -8px; } }
.hero-art .mascot { aspect-ratio: 1; }
.hero-art .mascot > img { position: absolute; animation: none; }
.hero-art .mascot > img:first-child { inset: 0; width: 100%; height: 100%; }
.hero-art .mascot .face { left: 50%; top: 44%; width: 56%; transform: translate(-50%, -50%); }
.hero-art .mascot .hand { width: 34%; transform: rotate(var(--hr, 0deg)); }
/* 날마다 바뀌는 배너: 도형 캐릭터 날은 민트, 풍경 날은 하늘·언덕 그림 */
.hero[data-art="shapes"] { background: var(--candy-mint); }
.hero[data-art="shapes"] p { color: #2b2350; }
.hero[data-art="scenery"] { background: url(/img/kenney/scenery/colored_castle.png) right -20px bottom -110px / 70% auto no-repeat, linear-gradient(#d6edf6 73%, #b6cfa6 73%); }
.hero[data-art="scenery"] p { color: #2b2350; }
.hero[data-art="scenery"] .stats div, .hero[data-art="shapes"] .stats div { background: #fff !important; }

/* ---------- 카테고리 탭 ---------- */
.tabs { padding: 2px 2px 8px; gap: 10px; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { border: 2.5px solid var(--ink); background: var(--surface); color: var(--text); box-shadow: 0 3px 0 var(--ink); font-size: 15px; }
.tab:hover { transform: translateY(-1px); }
.tab.on { background: var(--candy-mint); color: #2b2350; border-color: var(--ink); box-shadow: 0 3px 0 var(--ink); }
.view-toggle { padding: 3px; }
.view-btn.on { background: var(--candy-yellow); color: #2b2350; }

/* ---------- 게임 카드 ---------- */
.grid { gap: 20px; }
.card { border-radius: 22px; transition: transform .16s cubic-bezier(.2, .9, .3, 1.3), box-shadow .16s; }
.card:hover, .card:focus-visible { transform: translateY(-4px) rotate(-1.2deg); box-shadow: var(--shadow-hover) !important; }
.card:nth-child(2n):hover { transform: translateY(-4px) rotate(1.2deg); }
.thumb { position: relative; background: var(--c); border-bottom: var(--b) solid var(--ink); text-shadow: 3px 3px 0 rgba(43, 35, 80, .35); }
.thumb::after { content: ""; position: absolute; inset: 9px; border: 2px dashed rgba(255, 255, 255, .6); border-radius: 14px; pointer-events: none; }
.new-icon { background: var(--candy-yellow); border: 2.5px solid var(--ink); backdrop-filter: none; transform: rotate(-10deg); box-shadow: 0 2px 0 var(--ink); z-index: 1; }
.fav { border: 2.5px solid var(--ink); background: var(--surface); color: var(--muted); box-shadow: 0 2px 0 var(--ink); z-index: 1; }
.fav.on { background: var(--candy-yellow); color: #2b2350; }
.chip { border: 2px solid var(--ink); background: var(--surface-2); color: var(--text); font-weight: 600; }

/* 아이콘 보기 */
.tile-icon { background: var(--c); border-radius: 26% !important; }
.tile-new, .tile-fav { border: 2px solid var(--ink); box-shadow: 0 2px 0 var(--ink); }
.tile-new { background: var(--surface); }
.tile-name { font-weight: 600; }

/* ---------- 오른쪽 상자들 ---------- */
.side-card { border-radius: 22px; }
.side-card.challenge { background: var(--candy-yellow) !important; border-style: dashed !important; color: #2b2350; }
.side-card.challenge .muted, .side-card.challenge small { color: #5b4a1a; }
.side-emoji { border: 2px solid var(--ink); border-radius: 12px; }
.side-list li + li { border-top: 2px dotted color-mix(in srgb, var(--ink) 25%, transparent); padding-top: 6px; }

/* ---------- 게임 페이지·내 페이지·문서 ---------- */
.me-card, .game-hero { border-radius: 24px; }
.game-hero-thumb { border: var(--b) solid var(--ink); box-shadow: 0 4px 0 var(--ink); background: var(--c); }
.guide { border-top: var(--b) solid var(--ink) !important; }
.guide-cols > div { border: 2px solid var(--ink); }
.rank-panel .rank-list li.me { outline: 2.5px solid var(--ink); background: var(--candy-yellow) !important; color: #2b2350; }
.back { font-family: var(--font-fun); font-weight: 600; }

/* ---------- 게임 창 ---------- */
.modal { background: rgba(43, 35, 80, .55); }
.panel { border-radius: 26px; box-shadow: 0 8px 0 var(--ink) !important; }
.m-emoji { border: 2.5px solid var(--ink); box-shadow: 0 3px 0 var(--ink); }
.sc-pill { border: 2.5px solid var(--ink) !important; box-shadow: 0 3px 0 var(--ink); }
.tool-btn, .toggle { border: 2.5px solid var(--ink) !important; box-shadow: 0 3px 0 var(--ink); font-weight: 600; }
.toggle.on { background: var(--candy-mint); color: #2b2350; }
.rotate-hint { border: 2px dashed var(--ink); background: var(--candy-yellow); color: #2b2350; }
.over-card { border-radius: 24px; }
.over-art { border-bottom: var(--b) solid var(--ink); }
.overlay .btn.ghost { box-shadow: 0 4px 0 var(--ink); }

/* ---------- 꼬리말·알림 ---------- */
.foot nav.all-games { border: var(--b) dashed color-mix(in srgb, var(--ink) 35%, transparent); border-radius: 20px; padding: 14px 16px; background: color-mix(in srgb, var(--surface) 70%, transparent); }
.foot nav a { font-weight: 600; }
.toast { border-radius: 22px; background: var(--surface); color: var(--text); } /* 999px 면 여러 줄 문구가 동그라미 안에서 잘린다 */
.consent { border-radius: 20px; }

/* 휴대폰: 테두리·그림자를 조금 가늘게 */
@media (max-width: 520px) {
  :root { --b: 2.5px; --lift: 4px; }
  .top { margin: 8px 8px 0; border-radius: 18px; padding: 8px 10px; top: 6px; }
  .brand-name { font-size: 16px; letter-spacing: 0; }
  .brand .logo { font-size: 20px; }
  .hero { padding: 18px 18px 18px; border-radius: 22px; }
  .hero h1 { font-size: 24px; }
  /* 휴대폰: 배너 그림은 작게, 글자와 겹치지 않게 일부만 */
  .hero[data-art] > h1, .hero[data-art] > p { max-width: none; }
  /* 그림은 오른쪽 아래(버튼 옆)에 두 개만 작게 */
  .hero-art > :nth-child(n+3) { display: none; }
  .hero-art > :nth-child(1) { top: auto !important; bottom: 12px !important; right: 12px !important; width: 50px !important; }
  .hero-art > :nth-child(2) { top: auto !important; bottom: 16px !important; right: 70px !important; width: 44px !important; }
  .hero[data-art="scenery"] { background: url(/img/kenney/scenery/colored_castle.png) right -80px bottom -120px / 92% auto no-repeat, linear-gradient(#d6edf6 82%, #b6cfa6 82%); }
  .play-random { font-size: 15px; padding: 7px 16px; margin-top: 10px; }
  .panel.game-panel { border: 0 !important; box-shadow: none !important; }
  .card:hover, .card:nth-child(2n):hover { transform: none; }
}
@media (prefers-reduced-motion: reduce) { .hero-art img, .hero-art .mascot { animation: none; } }
/* 테두리·버튼이 굵어진 만큼 게임 판 높이 여유를 조금 더 둔다 (휴대폰은 위의 휴대폰 규칙 그대로) */
@media (min-width: 521px) and (min-height: 541px) {
  .panel.game-panel { --chrome: 254px; }
  .stage:has(.hud) { --chrome: 294px; }
  /* 게임별 높이 설정도 같은 만큼 (위 규칙이 이것들을 덮지 않게 다시 적는다) */
}

/* ---------- 앱으로 설치 ---------- */
.install-bar {
  display: flex; align-items: center; gap: 10px; margin: 14px 0 4px; padding: 10px 12px;
  border: var(--b) dashed var(--ink); border-radius: 18px; background: var(--surface); font-weight: 700; font-size: 14px;
}
.install-bar span { flex: 1; }
.install-bar .icon-btn { width: 30px; height: 30px; font-size: 13px; box-shadow: none; }
.install-bar[hidden], .foot-install[hidden] { display: none; }
.foot-install { margin: 12px 0 0; }
.install-guide {
  width: min(420px, calc(100% - 32px)); border: var(--b) solid var(--ink); border-radius: 24px; box-shadow: 0 7px 0 var(--ink);
  background: var(--surface); color: var(--text); padding: 20px 22px;
}
.install-guide::backdrop { background: rgba(43, 35, 80, .55); }
.install-guide h2 { margin: 0 0 10px; font-size: 22px; }
.install-guide ol { margin: 0 0 10px; padding-left: 22px; display: grid; gap: 8px; line-height: 1.55; }
.install-guide form { margin: 14px 0 0; text-align: right; }

/* ---------- 휴대폰 머리글: 사이트명은 잘리지 않게, 언어는 국기만 ---------- */
@media (max-width: 520px) {
  .top { flex-wrap: wrap; row-gap: 8px; }
  .brand { flex: 1 0 auto; overflow: visible; min-width: max-content; }
  .brand > span.brand-name { overflow: visible; text-overflow: clip; }
  .account .btn { padding: 5px 10px; font-size: 13px; }
}
@media (max-width: 360px) { .brand .logo { display: none; } }

/* ---------- 게임 창: 플레이 중 글자 선택·복사/붙여넣기 메뉴가 뜨지 않게 (입력칸은 제외) ---------- */
.modal, .modal * { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent; }
.modal input, .modal textarea { -webkit-user-select: text; user-select: text; -webkit-touch-callout: default; }

/* ---------- 판 모양 (docs/modular.md '판 모양'): 게임 등록의 layout → .stage[data-layout] ---------- */
/* tall: 3:5. 같은 모양이면 판 높이가 같다 (게임 이름별 --chrome 예외를 두지 않는다. 넘치면 --fit-over 가 줄임) */
.stage[data-layout="tall"] { --chrome: 270px; }
@media (min-width: 521px) and (min-height: 541px) { .stage[data-layout="tall"] { --chrome: 284px; } }
/* square 1:1 (보드·퍼즐, 최대 620px) · wide 16:9 (최대 960px) · table (카드: 판 폭은 games/lib/cards.css). 높이는 게임 창 기본값(--chrome) + 아래 표준 자리 */
.stage[data-layout="square"] .fit { --ar: 1; max-width: min(100%, 620px); }
.stage[data-layout="wide"] .fit { max-width: min(100%, 960px); }
/* 판 둘레 표준 자리 (GameKit k.hud / k.controls / k.thumb): 순서는 HUD → 판 → 조작 줄 → 손가락 자리. 자리 높이만큼 판 높이 식에서 뺀다 */
.g-hud { order: -1; display: flex; gap: 16px; align-items: center; justify-content: center; flex-wrap: wrap; min-height: 36px; font-size: 15px; color: var(--muted); }
.g-hud b { color: var(--text); font-variant-numeric: tabular-nums; }
.g-controls { order: 1; display: flex; gap: 8px; align-items: center; justify-content: center; flex-wrap: wrap; min-height: 52px; }
.g-thumb {
  order: 2; width: 100%; height: var(--thumb-h); display: grid; place-items: center; text-align: center; padding: 8px;
  border: 2px dashed var(--line); border-radius: 14px; color: var(--muted); font-weight: 700; font-size: 14px; touch-action: none;
}
.stage[data-layout] { --thumb-h: min(36dvh, 280px); }
.stage[data-layout]:has(> .g-hud) { --slot-hud: 46px; }
.stage[data-layout]:has(> .g-controls) { --slot-ctl: 62px; }
.stage[data-layout]:has(> .g-thumb) { --slot-thumb: calc(var(--thumb-h) + 10px); }
/* 휴대폰 가로 화면: 위아래 막대가 왼쪽으로 가므로 판이 높이를 거의 다 쓴다 (위 모양별 값이 가로 화면 규칙을 덮지 않게 여기서 다시) */
@media (orientation: landscape) and (max-height: 540px) and (pointer: coarse) {
  .stage[data-layout] { --chrome: 16px; }
  /* HUD·조작 줄은 판 오른쪽에 세로로 (높이를 판에 다 준다) */
  .stage[data-layout]:is(:has(> .g-hud), :has(> .g-controls)) { grid-template-columns: minmax(0, 1fr) auto; column-gap: 10px; --slot-hud: 0px; --slot-ctl: 0px; }
  .stage[data-layout]:is(:has(> .g-hud), :has(> .g-controls)) > :not(.g-hud, .g-controls, .overlay) { grid-column: 1; grid-row: 1 / span 2; justify-self: end; }
  .stage[data-layout] > .g-hud { grid-column: 2; grid-row: 1; flex-direction: column; align-items: flex-start; align-self: end; gap: 6px; }
  .stage[data-layout] > .g-controls { grid-column: 2; grid-row: 2; flex-direction: column; align-self: start; }
}

/* ---------- 게임 불러오는 중 (공통 로딩 화면) ---------- */
.stage:has(.load-ov):not(:has(.load-board)) { min-height: min(60dvh, 420px); } /* 판 모양이 없는 게임(table·free)만: 판 모양이 있으면 .load-board 가 판 크기 자리를 잡는다 */
.stage .load-board { aspect-ratio: var(--ar); position: relative; }
.overlay.load-ov { background: color-mix(in srgb, var(--c, #6a5af9) 82%, #0a0c14); }
.load-ov[hidden] { display: none; }
.load-ov .load-icon { font-size: 56px; line-height: 1; justify-self: center; }
.load-ov .load-icon .g-icon { width: 72px; height: 72px; }
.load-ov p { font-weight: 800; }
.load-ov .load-bar { width: min(220px, 60vw); height: 10px; border-radius: 99px; background: rgba(255, 255, 255, .25); overflow: hidden; justify-self: center; }
.load-ov .load-bar i { display: block; height: 100%; width: 0; background: #fff; border-radius: inherit; transition: width .2s; }
/* 시간을 재는 게임(pause: 'clock')의 일시정지: 판을 완전히 가린다 */
.pause-ov.cover { background: #12142a; }
#pageGuide { display: contents; }

/* 게임 창 나가기 버튼: 크고 눈에 띄게 (바깥을 눌러도 창이 닫히지 않으므로 이 버튼이 닫는 방법) */
.exit-btn {
  display: inline-flex; align-items: center; gap: 6px; flex: none; height: 42px; padding: 0 16px 0 12px;
  border-radius: 999px; border: 2.5px solid var(--ink); background: #ef4444; color: #fff;
  font: inherit; font-size: 15px; font-weight: 900; box-shadow: 0 3px 0 var(--ink); cursor: pointer;
  transition: transform .08s ease, box-shadow .08s ease, filter .15s;
}
.exit-btn > span[aria-hidden] { font-size: 19px; line-height: 1; }
.exit-btn:hover { filter: brightness(1.08); }
.exit-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--ink); }
.exit-btn:focus-visible { outline: 3px solid #facc15; outline-offset: 2px; }
@media (max-width: 520px) { .exit-btn { height: 40px; padding: 0 12px 0 10px; font-size: 14px; } }

/* ---------- 휴대폰 세로: 게임 창 위 막대·버튼을 한 줄씩으로 줄이고 남는 높이는 게임 화면에 ---------- */
@media (max-width: 520px) {
  .panel.game-panel { padding: 8px 10px; --chrome-cut: 110px; display: flex; flex-direction: column; }
  /* 게임 화면(+설명·랭킹)은 위 막대 아래 남은 높이의 가운데에 */
  .game-panel #stage { margin-top: auto; }
  .panel.game-panel { --chrome-free: 33px; }
  .game-panel #mHelp:last-child { margin-bottom: auto; }
  .game-panel .bar { grid-template-columns: minmax(0, 1fr) auto auto; column-gap: 6px; row-gap: 0; margin-bottom: 6px; align-items: center; }
  .game-panel .bar h2 { grid-row: 1; grid-column: 1; font-size: 16px; gap: 6px; }
  .game-panel .m-emoji { width: 28px; height: 28px; font-size: 16px; border-radius: 9px; box-shadow: none; }
  .game-panel .m-tag { display: none; }
  .game-panel .scores { grid-row: 1; grid-column: 2; justify-self: end; flex-direction: row; gap: 4px; }
  .game-panel .sc-pill { display: flex; align-items: baseline; gap: 4px; min-width: 0; padding: 3px 8px; border-radius: 10px; box-shadow: 0 2px 0 var(--ink); }
  .game-panel .sc-pill small { font-size: 10px; }
  .game-panel .sc-pill b { font-size: 16px; }
  .game-panel .bar-btns { grid-row: 1; grid-column: 3; gap: 6px; }
  .game-panel #mFull { width: 32px; height: 32px; font-size: 14px; }
  .game-panel .exit-btn { width: 36px; height: 36px; padding: 0; justify-content: center; }
  .game-panel .exit-btn > span[aria-hidden] { font-size: 18px; }
  .game-panel .exit-label, .game-panel .restart-label { display: none; }
  .game-panel #mRestart > span[aria-hidden] { font-size: 16px; }
  .game-panel .mtools { margin: 0 0 6px; gap: 6px; flex-wrap: nowrap; }
  .game-panel #mRestart { height: 30px; min-width: 34px; padding: 0 8px; justify-content: center; font-size: 13px; }
  .game-panel #mLevel { height: 30px; font-size: 12px; min-width: 0; }
  .game-panel .mtools .tool-btn { height: 30px; min-width: 34px; padding: 0 8px; font-size: 14px; }
  .game-panel .tool-btn .tl { display: none; }
  .game-panel .rotate-hint { margin: 0 0 6px; padding: 3px 8px; font-size: 11.5px; border-radius: 10px; }
  .game-panel .rotate-hint .icon-btn { width: 20px; height: 20px; font-size: 10px; box-shadow: none; }
  /* 설명은 두 줄까지 (예전: 한 줄로 줄이고 눌러 펼치기 → 아이폰에서 눌러도 안 펼쳐지는 일이 있었음). 두 줄을 넘는 설명은 게임 쪽에서 줄인다 */
  .game-panel #mHelp { flex-shrink: 0; margin: 6px 0 0; font-size: 12px; line-height: 1.45; text-align: left; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
}

/* ---------- 휴대폰: 꼬리말 '전체 게임' 목록 숨김, 게임 소개는 접어 두기 (portal.js PHONE_MQ 와 같은 조건) ---------- */
details.guide > summary { list-style: none; }
details.guide > summary::-webkit-details-marker { display: none; }
details.guide > summary h2 { margin: 0 0 12px; }
@media (min-width: 521px) and (not ((pointer: coarse) and (max-height: 540px))) {
  details.guide > summary { pointer-events: none; } /* 데스크톱은 늘 펼친 채로 */
}
@media (max-width: 520px), (pointer: coarse) and (max-height: 540px) {
  .foot nav.all-games { display: none; }
  details.guide > summary { display: flex; align-items: center; justify-content: space-between; gap: 8px; cursor: pointer; }
  details.guide > summary h2 { margin: 0; }
  details.guide > summary::after {
    content: '▾'; flex: none; display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%;
    border: 2px solid var(--ink); background: var(--surface-2); font-size: 15px; transition: transform .15s;
  }
  details.guide[open] > summary { margin-bottom: 12px; }
  details.guide[open] > summary::after { transform: rotate(180deg); }
}

/* ---------- 게임 목록 NEW · HOT 표시 ---------- */
.badge, .tile-badge {
  position: absolute; z-index: 2; display: inline-block; padding: 3px 9px; border-radius: 999px;
  font-family: var(--font-fun); font-size: 12px; font-weight: 700; letter-spacing: .04em; line-height: 1.2; color: #fff;
  border: 2px solid var(--ink); box-shadow: 0 2px 0 var(--ink);
}
.badge { top: 10px; left: 10px; }
.tile-badge { top: -7px; left: -6px; padding: 1px 6px; font-size: 10px; transform: rotate(-8deg); }
.badge.new, .tile-badge.new { background: #22c55e; }
.badge.hot, .tile-badge.hot { background: #f43f5e; }

/* ---------- 쿠키 동의: 화면 아래 얇은 막대 (게임 목록을 가리지 않게) ---------- */
.consent {
  left: 0; right: 0; bottom: 0; max-width: none; margin: 0; border-radius: 0 !important;
  padding: 8px max(16px, calc((100% - 1100px) / 2)); gap: 10px; flex-wrap: nowrap;
  border-width: 2.5px 0 0 !important; box-shadow: 0 -4px 16px rgba(0, 0, 0, .12) !important; font-size: 13px;
}
.consent p { flex: 1 1 auto; line-height: 1.4; }
.consent-btns { flex: none; gap: 6px; }
.consent-btns .btn { padding: 6px 14px; font-size: 13px; }
@media (max-width: 520px) {
  .consent { padding: 6px 10px; font-size: 12px; }
  .consent-btns .btn { padding: 5px 10px; font-size: 12px; }
}

/* ---------- 휴대폰 첫 화면: 소개 막대를 한 줄로 줄여 게임 목록이 바로 보이게 ---------- */
@media (max-width: 520px) {
  .hero { padding: 14px 16px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
  .hero h1 { font-size: 19px; margin: 0; flex: 1 1 100%; }
  .hero p, .hero .stats { display: none; }
  .hero .play-random { margin: 0; padding: 7px 14px; font-size: 14px; }
}

/* ---------- 홈: 지금 인기 (가장 많이 플레이한 게임 바로 시작) ---------- */
.hot-strip { margin: 18px 0 4px; }
.hot-strip[hidden] { display: none; }
.hot-title { margin: 0 0 10px; font-size: 18px; }
.hot-row { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 10px; }
.hot-item {
  display: grid; justify-items: center; gap: 6px; padding: 10px 6px 8px; border-radius: 16px; text-decoration: none; color: var(--text);
  background: var(--surface); border: 2.5px solid var(--ink); box-shadow: 0 3px 0 var(--ink); position: relative;
  transition: transform .08s ease, box-shadow .08s ease;
}
.hot-item:hover { transform: translateY(-2px); box-shadow: 0 5px 0 var(--ink); }
.hot-item:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--ink); }
.hot-icon {
  width: 52px; height: 52px; display: grid; place-items: center; font-size: 28px; border-radius: 14px;
  background: radial-gradient(circle at 30% 20%, color-mix(in srgb, var(--c) 55%, white), var(--c)); border: 2px solid var(--ink);
}
.hot-icon .g-icon { width: 78%; height: 78%; object-fit: contain; }
.hot-name { font-family: var(--font-fun); font-size: 13px; text-align: center; line-height: 1.2; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 720px) {
  .hot-strip { margin: 12px 0 2px; }
  .hot-title { font-size: 16px; margin-bottom: 8px; }
  .hot-row { display: flex; overflow-x: auto; gap: 8px; padding: 2px 2px 8px; scroll-snap-type: x mandatory; scrollbar-width: none; }
  .hot-row::-webkit-scrollbar { display: none; }
  .hot-item { flex: 0 0 84px; scroll-snap-align: start; padding: 8px 4px 6px; }
  .hot-icon { width: 46px; height: 46px; font-size: 24px; }
  .hot-name { font-size: 12px; }
}

/* ---------- 오늘의 도전: 연속 참여, 결과 카드 로그인 안내 ---------- */
.side-card .streak {
  display: inline-block; margin: 2px 0 6px; padding: 3px 10px; border-radius: 999px; font-size: 13px; font-weight: 800;
  background: #f43f5e; color: #fff; border: 2px solid var(--ink);
}
.over-nudge { margin: 4px 0 0; font-size: 13px; color: var(--muted); display: flex; align-items: center; justify-content: center; gap: 8px; flex-wrap: wrap; }

/* ---------- 결과 카드: 닉네임만 넣고 랭킹 올리기 (임시 계정) ---------- */
.over-rank { display: grid; gap: 6px; justify-items: center; margin: 4px 0 2px; padding: 10px 12px; border-radius: 14px; background: var(--surface-2); border: 2px dashed var(--ink); font-size: 13px; }
.over-rank b { font-size: 14px; }
.over-rank-row { display: flex; gap: 6px; width: 100%; max-width: 280px; }
.over-rank-row input { flex: 1; min-width: 0; height: 34px; padding: 0 10px; border-radius: 10px; border: 2px solid var(--ink); background: var(--surface); color: var(--text); font: inherit; font-size: 14px; }
.over-rank-msg { color: #dc2626; }
.over-rank-msg:empty { display: none; }
.link-btn { background: none; border: 0; padding: 0; color: var(--accent); font: inherit; font-size: 12.5px; text-decoration: underline; cursor: pointer; }
.link-card { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; border: 2.5px dashed var(--ink) !important; }
.link-card p { margin: 0; flex: 1 1 280px; line-height: 1.55; }
/* 랭킹 올리기 칸이 있으면 위 그림을 줄여 카드가 게임 화면 안에 들어오게 */
.over-card:has(.over-rank) .over-art { height: 76px; }
.over-card:has(.over-rank) .oa-main { scale: .65; }
.overlay.over-ov > .over-card { min-height: max-content; } /* 게임 화면보다 길면 줄어들어 위가 잘리지 않고, 결과 화면이 스크롤된다 */
.over-card:has(.over-rank) { gap: 4px; padding-bottom: 12px; }
.over-card .over-rank { padding: 8px 12px; gap: 4px; }
.overlay.over-ov:has(.over-rank) { padding: 6px 12px; }
.over-card:has(.over-rank) .over-score b { font-size: 48px; }

/* ---------- HOT 게임: 그림 위로 빛나는 띠가 지나간다 ---------- */
.shine { position: absolute; inset: 0; border-radius: inherit; overflow: hidden; pointer-events: none; z-index: 1; }
.shine::before {
  content: ""; position: absolute; top: -20%; bottom: -20%; left: -60%; width: 45%;
  background: linear-gradient(100deg, transparent, rgba(255, 255, 255, .15) 30%, rgba(255, 255, 255, .7) 50%, rgba(255, 255, 255, .15) 70%, transparent);
  transform: skewX(-18deg); animation: shine-sweep 3.2s ease-in-out var(--d, 0s) infinite;
}
@keyframes shine-sweep { 0% { left: -60%; } 45%, 100% { left: 130%; } }
@media (prefers-reduced-motion: reduce) { .shine::before { animation: none; display: none; } }

/* 첫 화면 밀림 방지: 게임 목록이 그려지기 전에도 자리를 잡아 두어, 꼬리말이 먼저 보였다가 아래로 밀리지 않게 한다 */
#grid:empty { min-height: 150vh; }

/* ---------- 홈 배너 배경 그림 (떠 있는 섬과 게임 소품). 왼쪽은 비어 있어 글자 자리, 그림은 오른쪽 ---------- */
/* 그림은 배너 높이에 맞추고(오른쪽 정렬), 넓은 화면에서 왼쪽에 남는 자리는 그림 왼쪽 끝 색(세로 그라데이션)으로 채운다 */
.hero[data-art="islands"] {
  background: url(/img/hero/islands-1200.webp) right center / auto 100% no-repeat, linear-gradient(#9a8efd, #949dfc 50%, #9cdbfc);
}
.hero[data-art="islands"] > h1, .hero[data-art="islands"] > p { max-width: 48%; }
.hero[data-art="islands"] p { text-shadow: 0 1px 2px rgba(43, 35, 80, .55); }
@media (max-width: 520px) {
  .hero[data-art="islands"] { background-image: url(/img/hero/islands-800.webp), linear-gradient(#9a8efd, #949dfc 50%, #9cdbfc); }
  .hero[data-art="islands"] > h1 { max-width: 64%; font-size: 17px; white-space: nowrap; }
}

/* ---------- 아무 게임이나 하기: 주사위가 6초마다 구르고 버튼이 꿈틀, 올리면 떠오름, 누르면 게임 룰렛 ---------- */
.play-random { display: inline-flex; align-items: center; gap: 8px; animation: pr-wiggle 6s ease-in-out infinite; transition: transform .15s cubic-bezier(.2, .9, .3, 1.3), box-shadow .15s; }
.play-random .pr-die { display: inline-block; font-size: 1.15em; line-height: 1; animation: pr-die-roll 6s ease-in-out infinite; }
@keyframes pr-die-roll {
  0%, 82% { transform: none; }
  88% { transform: translateY(-6px) rotate(200deg); }
  94% { transform: translateY(0) rotate(360deg); }
  97% { transform: translateY(-2px) rotate(360deg); }
  100% { transform: rotate(360deg); }
}
@keyframes pr-wiggle { 0%, 86%, 100% { rotate: 0deg; } 89% { rotate: -3deg; } 92% { rotate: 3deg; } 95% { rotate: -1.5deg; } }
@media (hover: hover) {
  .play-random:hover { transform: translateY(-3px) scale(1.04); box-shadow: 0 7px 0 var(--ink); }
  .play-random:hover .pr-die { animation: pr-die-spin .5s linear infinite; }
}
.play-random:active { transform: translateY(2px) scale(.98); box-shadow: 0 1px 0 var(--ink); }
@keyframes pr-die-spin { to { transform: rotate(360deg); } }
.pr-reel { position: relative; display: inline-block; height: 1.3em; line-height: 1.3em; overflow: hidden; vertical-align: middle; }
.pr-strip { display: block; will-change: transform; }
.pr-strip > span { display: flex; align-items: center; gap: 6px; height: 1.3em; white-space: nowrap; }
.pr-strip img { width: 1.1em; height: 1.1em; object-fit: contain; }
.play-random.spinning { animation: none; }
.play-random.spinning .pr-die { animation: pr-die-spin .25s linear infinite; }
.play-random.landed { animation: pr-pop .35s cubic-bezier(.2, 1.6, .4, 1); }
@keyframes pr-pop { 50% { transform: scale(1.12); } }
@media (prefers-reduced-motion: reduce) { .play-random, .play-random .pr-die { animation: none !important; } }

/* ---------- 게임 목록 움직임: 올리면 통통 뜨며 게임마다 다른 각도로 흔들, 스크롤하면 톡 등장, 즐겨찾기 별 톡, 탭 바꾸면 자리 이동(portal.js) ---------- */
.tile .tile-icon { transition: transform .22s cubic-bezier(.2, 1.6, .4, 1), box-shadow .22s; }
.tile-icon > .g-icon, .tile-emoji { display: inline-block; }
@media (hover: hover) {
  .tile:hover .tile-icon { transform: translateY(-6px) scale(1.08) rotate(var(--tilt, -4deg)); box-shadow: 0 9px 0 var(--ink) !important; }
  .tile:hover .tile-icon > :is(.g-icon, .tile-emoji) { animation: icon-jiggle .5s ease-in-out; }
}
.tile:focus-visible .tile-icon { transform: translateY(-6px) scale(1.08) rotate(var(--tilt, -4deg)); box-shadow: 0 9px 0 var(--ink) !important; }
.tile:active:not(:has(.tile-fav:active)) .tile-icon { transform: translateY(2px) scale(.95); box-shadow: 0 1px 0 var(--ink) !important; }
@keyframes icon-jiggle { 25% { rotate: -10deg; } 50% { rotate: 8deg; } 75% { rotate: -4deg; } }

.reveal { opacity: 0; transform: translateY(24px) scale(.92); }
.reveal.in { animation: tile-in .5s cubic-bezier(.2, 1.4, .4, 1) forwards; animation-delay: calc(var(--d, 0) * 1ms); }
@keyframes tile-in { to { opacity: 1; transform: none; } }

button.tile-fav { top: -7px; right: -7px; width: 26px; height: 26px; padding: 0; border: 2px solid var(--ink); background: var(--surface); color: #c7c2d6; font-size: 13px; line-height: 1; cursor: pointer; z-index: 2; }
button.tile-fav.on { background: var(--candy-yellow); color: #2b2350; }
/* 손가락으로 별 언저리를 눌러도 게임이 아니라 즐겨찾기가 눌리게 누르는 영역을 넓힌다 (보이는 크기는 그대로) */
button.tile-fav::after { content: ""; position: absolute; inset: -12px -10px -14px -14px; border-radius: 50%; }
@media (pointer: coarse) { button.tile-fav { width: 30px; height: 30px; font-size: 15px; } }
.fav.pop, .tile-fav.pop { animation: star-pop .45s cubic-bezier(.2, 1.8, .4, 1); }
@keyframes star-pop { 40% { transform: scale(1.5) rotate(-15deg); } }
.spark { position: absolute; left: 50%; top: 50%; width: 7px; height: 7px; border-radius: 50%; background: #ffd54a; border: 1.5px solid var(--ink); pointer-events: none; animation: spark .55s ease-out forwards; }
@keyframes spark { from { transform: translate(-50%, -50%) scale(1); opacity: 1; } to { transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(.3); opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
  .reveal { opacity: 1; transform: none; }
  .tile .tile-icon > *, .fav.pop, .tile-fav.pop { animation: none !important; }
}

/* ---------- 맨 아래: 언어·화면 테마 ---------- */
.foot-prefs { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin: 16px 0 0; }
.foot-pref { display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 6px 0 12px; border: 2px solid var(--ink); border-radius: 999px; background: var(--surface); box-shadow: 0 2px 0 var(--ink); color: var(--text); font: 600 13px var(--font-fun); cursor: pointer; }
.foot-pref .lang { height: 30px; padding: 0 4px; border: 0 !important; box-shadow: none !important; background: none; font: inherit; cursor: pointer; }
.foot-pref .lang:focus-visible { outline: 2px solid var(--accent); border-radius: 8px; }
.theme-btn { padding: 0 14px 0 12px; }
.theme-btn:active { transform: translateY(2px); box-shadow: 0 0 0 var(--ink); }

/* ---------- 휴대폰 게임 목록: 분류는 드롭다운, 아이콘의 즐겨찾기 별은 표시만 ---------- */
.cat-select { display: none; }
@media (max-width: 520px) {
  .list-bar .tabs { display: none; }
  .cat-select {
    display: block; flex: 1; min-width: 0; height: 40px; padding: 0 36px 0 16px; border: 2.5px solid var(--ink); border-radius: 999px;
    background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%238a84a3' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat right 14px center;
    box-shadow: 0 3px 0 var(--ink); color: var(--text); font: 600 15px var(--font-fun); appearance: none; -webkit-appearance: none;
  }
}
/* 터치 기기: 별을 누르려다 게임이 열리거나 게임을 누르려다 별이 눌리지 않게, 목록의 별은 즐겨찾기한 게임에만 표시하고 누를 수 없게 한다.
   즐겨찾기 추가·해제는 게임 페이지의 즐겨찾기 버튼으로 */
@media (pointer: coarse) {
  button.tile-fav { width: 24px; height: 24px; font-size: 12px; top: -6px; right: -6px; pointer-events: none; }
  button.tile-fav:not(.on) { display: none; }
  button.tile-fav::after { content: none; }
}

/* ---------- 게임 페이지: 게임 그림을 눌러도 플레이 (플레이 버튼과 같은 동작) ---------- */
button.game-hero-thumb { position: relative; padding: 0; color: inherit; font-family: inherit; cursor: pointer; transition: transform .15s cubic-bezier(.2, .9, .3, 1.3), box-shadow .15s; }
@media (hover: hover) {
  button.game-hero-thumb:hover { transform: translateY(-3px) rotate(-1.5deg); box-shadow: 0 7px 0 var(--ink); }
}
button.game-hero-thumb:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--ink); }

/* ---------- 게임 페이지: '게임 목록'으로 돌아가기 버튼 ---------- */
a.back {
  display: inline-flex; align-items: center; gap: 7px; justify-self: start; align-self: start; width: max-content;
  height: 38px; padding: 0 16px 0 7px; border: 2.5px solid var(--ink); border-radius: 999px; background: var(--surface);
  color: var(--text); box-shadow: 0 3px 0 var(--ink); font: 600 15px var(--font-fun); text-decoration: none;
  transition: transform .15s cubic-bezier(.2, .9, .3, 1.3), box-shadow .15s;
}
.back-ar { display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: var(--candy-mint); border: 2px solid var(--ink); color: #2b2350; font-size: 13px; }
@media (hover: hover) { a.back:hover { transform: translateY(-2px); box-shadow: 0 5px 0 var(--ink); } }
a.back:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--ink); }

/* ---------- 게임 검색: 머리글 대신 오른쪽 상자(휴대폰은 소개 아래) '이어서 하기' 다음 ---------- */
.side-group { display: contents; }
.search-card #search { display: block; width: 100%; max-width: none; margin: 8px 0 0; flex: none; order: 0; }
.top .account { margin-left: auto; } /* 검색창이 빠져서 로그인 버튼을 오른쪽 끝으로 */
@media (max-width: 520px) { .home-side.searching .side-group { display: none; } } /* 휴대폰: 검색 중에는 검색창이 결과 바로 아래에 */

/* ---------- 다른 언어로 보기 안내 (자동으로 옮기지 않고 묻기만) ---------- */
.lang-offer {
  max-width: 1100px; margin: 10px auto 0; width: calc(100% - 32px); display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 8px 8px 8px 16px; border: 2.5px dashed var(--ink); border-radius: 16px; background: var(--candy-yellow); color: #2b2350;
  font: 600 14px var(--font-fun);
}
.lang-offer span { flex: 1; min-width: 160px; }
.lang-offer .btn { flex: none; }
.lang-offer .icon-btn { width: 30px; height: 30px; flex: none; font-size: 13px; box-shadow: none; }
@media (max-width: 520px) { .lang-offer { margin: 8px 8px 0; width: auto; font-size: 13px; } }

/* ---------- 결과 카드 리본: 이모지 + 짧은 글자 (신기록·오늘의 도전·아까워요·잘했어요·다시 도전) ---------- */
.over-art .oa-main { top: 42%; }
.oa-ribbon {
  position: absolute; left: 50%; bottom: 10px; transform: translateX(-50%) rotate(-2deg); white-space: nowrap;
  display: inline-flex; align-items: center; padding: 5px 22px; border-radius: 0;
  /* 리본 띠 모양(양 끝이 V 로 파임): 테두리·아래 그림자 없이 (버튼처럼 보이지 않게) */
  clip-path: polygon(0 0, 100% 0, calc(100% - 10px) 50%, 100% 100%, 0 100%, 10px 50%);
  font: 700 15px var(--font-fun); color: #2b2350;
  animation: oa-rib .45s .25s both cubic-bezier(.2, 1.6, .4, 1);
}
@keyframes oa-rib { from { opacity: 0; transform: translateX(-50%) scale(.4) rotate(-12deg); } }
.oa-ribbon.gold { background: #fde047; } .oa-ribbon.sky { background: #7dd3fc; } .oa-ribbon.fire { background: #fdba74; }
.oa-ribbon.mint { background: #86efac; } .oa-ribbon.pink { background: #f9a8d4; }
/* 그림 띠가 낮을 때(랭킹 올리기 칸이 있는 카드 76px, 휴대폰 가로 화면 72px): 게임 그림은 왼쪽, 리본은 오른쪽에 나란히 */
.over-card:has(.over-rank) .over-art .oa-main { top: 50%; left: calc(50% - 70px); scale: .65; }
.over-card:has(.over-rank) .oa-ribbon { left: calc(50% - 36px); bottom: auto; top: 50%; transform: translateY(-50%) rotate(-2deg); animation-name: oa-rib-side; }
@keyframes oa-rib-side { from { opacity: 0; transform: translateY(-50%) scale(.4) rotate(-12deg); } }
@media (orientation: landscape) and (max-height: 540px) and (pointer: coarse) {
  .over-art .oa-main { top: 50%; left: calc(50% - 64px); }
  .oa-ribbon { left: calc(50% - 30px); bottom: auto; top: 50%; transform: translateY(-50%) rotate(-2deg); font-size: 13px; padding: 4px 18px; animation-name: oa-rib-side; }
}

/* ---------- 결과 창 '판 보기': 결과 창을 숨기고 끝난 판을 보여 줌, 아래 띠로 돌아옴 ---------- */
.overlay.over-ov.peeking { background: transparent; backdrop-filter: none; overflow: hidden; }
.overlay.over-ov.peeking > .over-card { display: none; }
.peek-bar {
  position: absolute; left: 50%; bottom: 12px; transform: translateX(-50%); display: flex; gap: 8px; padding: 6px; white-space: nowrap;
  border-radius: 999px; background: color-mix(in srgb, var(--surface) 92%, transparent); border: 2.5px solid var(--ink); box-shadow: 0 4px 0 var(--ink);
  animation: peek-in .25s cubic-bezier(.2, 1.4, .4, 1);
}
@keyframes peek-in { from { transform: translateX(-50%) translateY(16px) scale(.9); opacity: 0; } }
.peek-bar[hidden] { display: none; }
.peek-bar .btn { padding: 8px 16px; font-size: 15px; }
.peek-bar .btn.ghost { background: var(--surface-2); color: var(--text); border-color: var(--line); }
@media (max-width: 520px) { .peek-bar .btn { padding: 7px 12px; font-size: 14px; } }
/* 판 보기 중에는 결과 창 때문에 늘린 게임 칸 높이를 원래대로 (늘어난 칸에 맞춰 판이 커져 옆이 잘리지 않게) */
.stage:has(.over-ov.peeking) { min-height: 0; padding-bottom: 64px; } /* 아래 띠가 판을 가리지 않게 띠 자리만큼 비운다 */

/* 게임이 끝나고 결과 창이 뜨기 전(overDelay): 투명한 층으로 판 입력만 막는다 */
.overlay.over-wait { background: transparent; animation: none; }

/* ---------- 게임 안 도움말 (게임 속성 rules) ---------- */
.rules-btn > span[aria-hidden] { font: 800 15px var(--font-fun); }
.rules-ov {
  position: fixed; inset: 0; z-index: 60; display: grid; place-items: center;
  padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  background: rgba(43, 35, 80, .55); backdrop-filter: blur(2px); animation: fade .15s ease;
}
.rules-card {
  position: relative; width: min(520px, 100%); max-height: 100%; overflow: auto; text-align: left;
  background: var(--surface); color: var(--text); border: 2.5px solid var(--ink); border-radius: 18px;
  box-shadow: 0 5px 0 var(--ink); padding: 16px 18px 18px; border-top: 8px solid var(--c, var(--ink));
}
.rules-card h3 { margin: 0 44px 10px 0; font: 700 19px var(--font-fun); }
.rules-card h4 { margin: 8px 0 4px; font: 700 15px var(--font-fun); }
.rules-card ol, .rules-card ul { margin: 4px 0 8px; padding-left: 22px; line-height: 1.55; font-size: 15px; }
.rules-card li + li { margin-top: 3px; }
.rules-card details { margin-top: 4px; }
.rules-card summary { cursor: pointer; font: 700 15px var(--font-fun); padding: 4px 0; }
.rules-card .rules-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 4px; }
.rules-card .rules-x { position: absolute; top: 10px; right: 10px; width: 34px; height: 34px; }
.rules-card .rules-ok { display: block; margin: 12px auto 0; min-width: 120px; }
@media (max-width: 520px) { .rules-card { padding: 14px 14px 16px; } .rules-card ol, .rules-card ul { font-size: 14px; } }

/* ---------- 휴대폰 가로 화면 안내 (주소창 없이 크게: 아이폰 홈 화면 추가 / 안드로이드 전체 화면) ---------- */
.land-hint {
  position: fixed; z-index: 55; top: max(8px, env(safe-area-inset-top)); left: 50%; translate: -50% 0;
  display: flex; align-items: center; gap: 8px; width: max-content; max-width: calc(100% - 24px); margin: 0;
  padding: 6px 6px 6px 12px; border: 2px dashed var(--ink); border-radius: 12px; background: var(--candy-yellow); color: #2b2350;
  font-size: 13px; font-weight: 700; box-shadow: 0 3px 0 var(--ink); animation: fade .2s ease;
}
.land-hint .btn { padding: 4px 10px; font-size: 13px; white-space: nowrap; }
.land-hint .icon-btn { width: 26px; height: 26px; font-size: 12px; flex: none; box-shadow: none; }
