/* 눈치게임 — 봉잡기·구구단과 같은 픽셀 틀(Galmuri, OFL) + 크림색 바탕. 친구들은 SVG 얼굴 */
@font-face { font-family: 'Galmuri11'; src: url('/assets/fonts/Galmuri11.woff2') format('woff2'); font-display: swap; }
@font-face { font-family: 'Galmuri11'; font-weight: 700; src: url('/assets/fonts/Galmuri11-Bold.woff2') format('woff2'); font-display: swap; }

:root {
  --bg: #F6F3EC; --card: #FFFDF7; --ink: #1F2420; --muted: #7A7F78; --line: #E4DFD3;
  --accent: #3E9B3A; --accent-dark: #2B6E28; --danger: #D9483B; --gold: #E8A317;
  --px: 3px;   /* 픽셀 테두리 두께 */
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); }
body { font-family: 'Galmuri11', -apple-system, 'Apple SD Gothic Neo', sans-serif; -webkit-font-smoothing: none; user-select: none; -webkit-user-select: none; }
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; padding: 0; }
h1, h2 { margin: 0; font-weight: 700; }
b { font-weight: 700; }

/* 픽셀 상자: 모서리를 깎은 테두리 */
.card, .btn, .panel, .levels .lv, .pill {
  border: var(--px) solid var(--ink);
  box-shadow: 0 var(--px) 0 var(--ink);
}

.screen { display: none; min-height: 100%; }
.screen.active { display: block; }

/* ---------- 홈 ---------- */
#home { max-width: 480px; margin: 0 auto; padding: calc(env(safe-area-inset-top) + 18px) 16px calc(env(safe-area-inset-bottom) + 28px); }
.hero { text-align: center; padding: 8px 0 16px; }
#heroCanvas { display: block; width: 240px; height: 150px; margin: 0 auto; image-rendering: pixelated; }
.hero h1 { font-size: 30px; margin-top: 12px; }
.tagline { color: var(--muted); margin: 6px 0 0; font-size: 14px; }

.btn { background: var(--card); padding: 12px 14px; font-weight: 700; font-size: 16px; }
.btn:active { transform: translateY(var(--px)); box-shadow: none; }
.btn.primary { background: var(--accent); color: #fff; }
.btn.big { width: 100%; padding: 16px; font-size: 20px; margin: 4px 0 18px; }
.btn.ghost { padding: 8px 12px; font-size: 14px; }

.card { background: var(--card); padding: 14px; margin-bottom: 16px; }
.label { font-size: 12px; color: var(--muted); }
.nick { font-size: 18px; font-weight: 700; margin-top: 2px; }
.profile-top { display: flex; justify-content: space-between; align-items: center; }
.icon-btn { font-size: 22px; padding: 6px; }
.profile-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 12px; padding-top: 12px; border-top: 2px dashed var(--line); }
.num { font-size: 18px; font-weight: 700; margin-top: 2px; }
.section-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 10px; gap: 8px; }
.section-head h2 { font-size: 17px; }
.hint { font-size: 12px; color: var(--muted); text-align: right; }

.levels { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.levels .lv { background: var(--card); aspect-ratio: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; box-shadow: 0 2px 0 var(--ink); border-width: 2px; }
.levels .lv b { font-size: 17px; }
.levels .lv small { font-size: 11px; color: var(--muted); margin-top: 2px; }
.levels .lv.cleared { background: #E4F3DC; }
.levels .lv.selected { background: var(--accent); color: #fff; }
.levels .lv.selected small { color: #E4F3DC; }
.levels .lv.locked { opacity: .4; box-shadow: none; }
/* 3단계 칸은 검정·빨강 */
.levels .lv.s3 { border-color: #141414; }
.levels .lv.s3.cleared { background: #FFD9D6; }
.levels .lv.s3.selected { background: #141414; color: #FF6B5E; }

.ranking, .plays { list-style: none; margin: 0; padding: 0; }
.ranking li, .plays li { display: grid; align-items: center; gap: 10px; padding: 9px 2px; border-bottom: 2px dashed var(--line); font-size: 14px; }
.ranking li { grid-template-columns: 26px 1fr auto; }
.plays li { grid-template-columns: 76px 1fr auto; }
.ranking li:last-child, .plays li:last-child { border-bottom: 0; }
.ranking .rank { font-weight: 700; color: var(--muted); text-align: center; }
.ranking .who { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ranking li.me .who, .ranking li.me .rank { color: var(--accent-dark); font-weight: 700; }
.ranking .ms, .plays .ms { font-weight: 700; font-variant-numeric: tabular-nums; }
.ranking .mine-rank { display: block; text-align: right; color: var(--muted); font-size: 13px; border: 0; }
.ranking .empty, .plays .empty { display: block; text-align: center; color: var(--muted); padding: 14px 0; border: 0; }
.plays .when { color: var(--muted); font-size: 12px; }
.plays li.fail .what { color: var(--danger); }
.foot { text-align: center; color: var(--muted); font-size: 12px; margin: 8px 0 0; }
.foot a { color: inherit; }

/* ---------- 게임 ---------- */
#game { position: fixed; inset: 0; display: none; flex-direction: column; max-width: 480px; margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 12px) 16px calc(env(safe-area-inset-bottom) + 16px); }
#game.active { display: flex; }
.topbar { display: flex; justify-content: space-between; align-items: center; }
.pill { background: var(--ink); color: var(--bg); padding: 6px 12px; font-size: 13px; font-weight: 700; box-shadow: none; }

/* 판마다 한 칸: 세이프 초록 · 실패 빨강 · 지금 판 노랑 */
.dots { display: flex; justify-content: center; gap: 8px; margin: 12px 0 4px; }
.dots i { width: 14px; height: 14px; border: var(--px) solid var(--ink); background: var(--card); }
.dots i.ok { background: var(--accent); }
.dots i.miss { background: var(--danger); }
.dots i.now { background: var(--gold); }

.status { text-align: center; font-size: 26px; font-weight: 700; min-height: 40px; margin: 8px 0 0; }
.status.go { color: var(--accent-dark); }
.status.bad { color: var(--danger); }
.status.pop { animation: pop .35s; }

.stage { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; }
.pals { display: grid; gap: 10px 8px; width: 100%; }
.pals.c2 { grid-template-columns: repeat(2, 1fr); max-width: 300px; }
.pals.c3 { grid-template-columns: repeat(3, 1fr); max-width: 380px; }
.pals.c4 { grid-template-columns: repeat(4, 1fr); }

.pal { position: relative; text-align: center; padding-top: 30px; }
.pal svg { display: block; width: 100%; max-width: 92px; margin: 0 auto; image-rendering: pixelated; transition: transform .08s; }
.pal .pname { font-size: 12px; font-weight: 700; margin-top: 4px; white-space: nowrap; }
.pal.me .pname { color: var(--accent-dark); }
.pal.me svg { outline: var(--px) dashed var(--accent); outline-offset: 3px; }
.pal .bubble { position: absolute; top: 0; left: 50%; transform: translateX(-50%); padding: 2px 8px; font-size: 18px; font-weight: 700;
  background: var(--card); border: 2px solid var(--ink); white-space: nowrap; visibility: hidden; }
.pal .breath { position: absolute; top: 4px; left: 50%; transform: translateX(-50%); font-size: 13px; font-weight: 700; color: var(--muted); visibility: hidden; }

/* 얼굴 표정: 평소 n · 숨 들이쉼 t · 외침 c · 탈락 x */
.f-t, .f-c, .f-x { display: none; }
.is-t .f-n, .is-c .f-n { display: none; }
.is-t .f-t, .is-c .f-c { display: inline; }
.pal.tell .f-n, .pal.called .f-n, .pal.out .f-n { display: none; }
.pal.tell:not(.called):not(.out) .f-t { display: inline; }
.pal.called:not(.out) .f-c { display: inline; }
.pal.out .f-x { display: inline; }
.pal.called .f-t { display: none; }
.pal.tell:not(.called):not(.out) svg { transform: translateY(-4px) scale(1.06); }
.pal.tell:not(.called):not(.out) .breath { visibility: visible; }
.pal.called .bubble { visibility: visible; animation: pop .25s; }
.pal.safe .bubble { background: #E4F3DC; }
.pal.out .bubble { visibility: visible; color: var(--danger); }
.pal.out svg { filter: grayscale(1); opacity: .55; }
.pal.out .pname { color: var(--muted); text-decoration: line-through; }

.btn.shout { width: 100%; padding: 22px 16px; font-size: 26px; background: var(--accent); color: #fff; margin-top: 10px; touch-action: manipulation; }
.btn.shout.wait { background: var(--card); color: var(--muted); }
.btn.shout.done { background: var(--card); color: var(--ink); }

.hero-pals { display: flex; justify-content: center; gap: 6px; }
.hero-pals svg { display: block; width: 56px; height: 56px; image-rendering: pixelated; }
.hero-pals .is-t svg { transform: translateY(-4px); }
.friends { list-style: none; margin: 0; padding: 0; }
.friends li { display: grid; grid-template-columns: 40px 1fr; gap: 10px; align-items: center; padding: 8px 0; border-bottom: 2px dashed var(--line); font-size: 13px; line-height: 1.45; }
.friends li:last-child { border-bottom: 0; }
.friends svg { width: 40px; height: 40px; }
.friends b { font-size: 14px; }
.friends small { color: var(--muted); }

.overlay { position: fixed; inset: 0; z-index: 5; display: flex; align-items: center; justify-content: center; padding: 16px; background: rgba(246, 243, 236, .75); }
.overlay[hidden] { display: none; }
.panel { width: 100%; max-width: 440px; background: var(--card); padding: 22px 18px 18px; text-align: center; }
.kicker { font-size: 14px; color: var(--muted); font-weight: 700; }
.panel-title { font-size: 24px; margin: 6px 0 14px; }
.rules-list { text-align: left; margin: 0 auto; padding: 0 0 0 22px; max-width: 320px; font-size: 15px; line-height: 1.6; }
.big { font-size: 46px; font-weight: 700; margin: 6px 0; font-variant-numeric: tabular-nums; }
.big.fail { font-size: 28px; color: var(--danger); margin: 10px 0 6px; }
.sub { font-size: 14px; color: var(--muted); line-height: 1.6; }
.sub b { color: var(--ink); }
.actions { display: flex; gap: 8px; margin-top: 18px; }
.actions .btn { flex: 1; }
.actions #homeBtn, .actions #rulesHomeBtn { flex: 0 0 auto; }
.actions [hidden] { display: none; }
@keyframes pop { from { transform: translateX(-50%) scale(1.6); opacity: 0; } }
.status.pop { animation-name: popc; }
@keyframes popc { from { transform: scale(1.5); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .pal .bubble, .status.pop { animation: none; } .pal svg { transition: none; } }
