:root {
  --cream: #F6EBD9; --paper: #FFF8EC; --walnut: #8A5A3B; --ink: #2A1B12; --sky: #8FD3F4; --grass: #7BC67E;
  --navy: #0D1240; --purple: #3C2C7A; --star: #FFF6DA; --gold: #FFC94A; --coral: #FF6B5B; --jade: #53C08F;
  --pw: 300px; --ph: 330px; --hudh: 64px;
  --font: system-ui, -apple-system, "Segoe UI", "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", sans-serif;
}
* { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%; background: var(--cream); color: var(--ink); font-family: var(--font);
  overflow: hidden; overscroll-behavior: none; touch-action: none;
  -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent; word-break: keep-all; overflow-wrap: anywhere;
}
button { font-family: inherit; color: inherit; touch-action: manipulation; }
#wrap { position: fixed; inset: 0; }
#game { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; cursor: pointer; }
.hidden { display: none !important; }
.ico { width: 22px; height: 22px; flex: none; }
kbd { font: 700 12px var(--font); padding: 1px 5px; border-radius: 5px; border: 1.5px solid #2a1b1255; color: #2a1b12aa; }

/* ---------- 장면 영역 (캔버스 위 HUD) ---------- */
#sceneUI { position: absolute; left: 0; top: 0; right: 0; bottom: 0; pointer-events: none; }
body.playing.land #sceneUI { right: var(--pw); }
body.playing.port #sceneUI { bottom: var(--ph); }
#sceneUI > * { pointer-events: auto; }
body.playing #hud, body.playing #panel { animation: fadeIn .35s ease-out; }
@keyframes fadeIn { from { opacity: 0; } }
#sceneUI > #notices { pointer-events: none; }

#hud {
  position: absolute; left: 0; right: 0; top: 0; padding: 10px 12px 0; padding-top: max(10px, env(safe-area-inset-top));
  display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: start; pointer-events: none;
}
#hud > * { pointer-events: auto; }
#hudLeft { display: flex; flex-direction: column; gap: 3px; justify-self: start; align-items: flex-start; }
#coinBox {
  display: flex; align-items: center; gap: 7px; padding: 5px 14px 5px 8px; border-radius: 999px;
  background: var(--paper); border: 2.5px solid var(--ink); box-shadow: 0 3px 0 var(--ink);
  font-size: 26px; line-height: 1; min-width: 104px; transition: transform .08s;
}
#coinBox .ico { width: 26px; height: 26px; }
#coinBox b { font-weight: 900; letter-spacing: .5px; font-variant-numeric: tabular-nums; }
#coinBox.ping { transform: scale(1.07); }
#rate { min-height: 16px; font: 800 13px var(--font); padding-left: 12px; color: var(--ink); text-shadow: 0 0 3px #fff8, 0 0 6px #fff8; }
body.dark #rate { color: var(--star); text-shadow: 0 1px 3px #0008; }
#goal {
  justify-self: center; width: min(100%, 360px); padding: 6px 12px 7px; border-radius: 16px;
  background: #fff8ecee; border: 2.5px solid var(--ink); box-shadow: 0 3px 0 var(--ink); font-size: 13px;
}
#goalTop { display: flex; justify-content: space-between; gap: 8px; font-weight: 800; white-space: nowrap; }
#goalName { overflow: hidden; text-overflow: ellipsis; }
#goalMore { color: var(--coral); font-weight: 900; }
#goalMore.ok { color: #2E9A6B; }
#goalBar { height: 8px; margin-top: 5px; border-radius: 6px; background: #2a1b121f; overflow: hidden; }
#goalBar i { display: block; height: 100%; width: 0; border-radius: 6px; background: linear-gradient(90deg, var(--gold), var(--coral)); transition: width .25s; }
#goalEta { margin-top: 3px; font-size: 12px; font-weight: 700; opacity: .7; min-height: 13px; }
#hudRight { display: flex; gap: 7px; }
.icon {
  min-width: 44px; height: 44px; border-radius: 14px; border: 2.5px solid var(--ink); background: var(--paper);
  box-shadow: 0 3px 0 var(--ink); display: inline-flex; align-items: center; justify-content: center; gap: 4px;
  cursor: pointer; padding: 0 8px; font: 800 13px var(--font);
}
.icon:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--ink); }
body.narrow #hud { grid-template-columns: 1fr auto; }
body.narrow #goal { grid-column: 1 / -1; grid-row: 2; width: 100%; padding: 4px 10px 5px; }
body.narrow #goalEta { display: none; }
body.narrow .icon { min-width: 44px; height: 44px; padding: 0 6px; }
body.narrow #coinBox { font-size: 22px; min-width: 90px; }
body.narrow #atlasN { display: none; }
body.compact #hud { gap: 8px; padding-left: 10px; padding-right: 10px; }
body.compact #goal { width: 100%; }
body.compact #atlasN { display: none; }
body.compact .icon { padding: 0 6px; }
body.compact #hudRight { gap: 6px; }

/* 안내 배너 + 토스트: 한 줄기로 쌓아서 서로 겹치지 않게 */
#notices {
  position: absolute; left: 0; right: 0; top: calc(var(--hudh) + 8px); padding: 0 10px;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
}
#banner {
  max-width: min(100%, 560px); padding: 8px 16px; border-radius: 18px; background: var(--ink); color: var(--star);
  font: 800 15px var(--font); line-height: 1.35; text-align: center; box-shadow: 0 4px 14px #0003; animation: bannerIn .35s ease-out;
}
#banner b { color: var(--gold); }
@keyframes bannerIn { from { opacity: 0; transform: translateY(-8px); } }
#toasts { display: flex; flex-direction: column; align-items: center; gap: 6px; max-width: 100%; }
.toast {
  max-width: min(100%, 520px); text-align: center; line-height: 1.35;
  padding: 7px 14px; border-radius: 14px; background: var(--paper); border: 2.5px solid var(--ink);
  box-shadow: 0 3px 0 var(--ink); font: 800 14px var(--font); animation: toastIn .3s ease-out, toastOut .4s ease-in 2.2s forwards;
}
.toast.gold { background: var(--gold); }
@keyframes toastIn { from { opacity: 0; transform: translateY(-10px) scale(.9); } }
@keyframes toastOut { to { opacity: 0; transform: translateY(-6px); } }

#result {
  position: absolute; left: 50%; bottom: 12px; transform: translateX(-50%); width: min(600px, calc(100% - 20px));
  display: flex; align-items: center; gap: 12px; padding: 9px 9px 9px 16px; border-radius: 20px;
  background: #fffdf6f2; border: 2.5px solid var(--ink); box-shadow: 0 4px 0 var(--ink); animation: resIn .28s ease-out;
}
@keyframes resIn { from { opacity: 0; transform: translate(-50%, 14px); } }
.rtext { flex: 1; min-width: 0; }
#resTitle { font: 900 18px var(--font); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#resTitle.win { color: #2E9A6B; }
#resTitle.lose { color: var(--coral); }
#resLine { font: 700 13px var(--font); opacity: .8; margin-top: 2px; }
#resLine em { font-style: normal; color: #D8571F; font-weight: 900; }
#resLine .nw { white-space: nowrap; }
#againBtn {
  position: relative; flex: none; min-height: 52px; padding: 0 22px; border-radius: 16px; border: 2.5px solid var(--ink);
  background: var(--coral); color: #fff; font: 900 18px var(--font); box-shadow: 0 4px 0 var(--ink); cursor: pointer; overflow: hidden;
}
#againBtn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
#againAuto { position: absolute; left: 0; bottom: 0; height: 5px; width: 0; background: #fff9; }

/* ---------- 업그레이드 패널 ---------- */
#panel {
  position: absolute; display: flex; flex-direction: column; gap: 8px; padding: 12px; background: var(--paper);
  border-left: 3px solid var(--ink); overflow-y: auto; overscroll-behavior: contain; touch-action: pan-y;
}
body.land #panel { right: 0; top: 0; bottom: 0; width: var(--pw); padding-top: max(12px, env(safe-area-inset-top)); }
body.port #panel { left: 0; right: 0; bottom: 0; height: var(--ph); border-left: 0; border-top: 3px solid var(--ink); padding-bottom: max(10px, env(safe-area-inset-bottom)); }
#cards { display: flex; flex-direction: column; gap: 8px; }
.card {
  position: relative; display: grid; grid-template-columns: 36px minmax(0, 1fr) auto; grid-template-rows: auto auto;
  column-gap: 9px; row-gap: 2px; align-items: center; min-height: 58px; padding: 7px 10px; text-align: left;
  border-radius: 16px; border: 2.5px solid var(--ink); background: #fff; box-shadow: 0 4px 0 var(--ink); cursor: pointer;
  transition: background .15s, opacity .15s;
}
.card .ic { grid-row: 1 / 3; width: 36px; height: 36px; border-radius: 11px; background: var(--cream); display: flex; align-items: center; justify-content: center; }
.card .ic .ico { width: 28px; height: 28px; }
.card .tx { display: contents; }
.card .tx b { grid-column: 2; grid-row: 1; font: 900 15px var(--font); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card .tx small { grid-column: 2 / 4; grid-row: 2; font: 700 12px var(--font); opacity: .75; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card .cost { grid-column: 3; grid-row: 1; display: flex; align-items: center; gap: 4px; font: 900 15px var(--font); padding: 3px 8px; border-radius: 10px; background: var(--gold); border: 2px solid var(--ink); white-space: nowrap; font-variant-numeric: tabular-nums; }
.card .cost .ico { width: 15px; height: 15px; }
.card kbd { position: absolute; top: -8px; left: -6px; background: var(--paper); }
.card.no { background: #f3ece0; }
.card.no .cost { background: #eadfcf; color: #2a1b1299; }
.card.max .cost, .card.lock .cost { background: #e9e3ef; }
.card.lock { opacity: .55; cursor: default; }
.card:not(.lock):active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
.card.glow { animation: glow 1.1s ease-in-out infinite; }
@keyframes glow { 50% { box-shadow: 0 4px 0 var(--ink), 0 0 0 5px #FFC94Aaa; background: #FFF6D0; } }
.card.bump { animation: bump .22s ease-out; }
@keyframes bump { 40% { transform: scale(1.04); } }
.card[data-id="domino"] { min-height: 64px; }
.card[data-id="domino"] .tx b { font-size: 18px; }
.card[data-id="domino"] .cost { font-size: 17px; }
#crunchBtn {
  display: flex; align-items: center; gap: 10px; min-height: 56px; padding: 8px 12px; border-radius: 16px; text-align: left; flex: none;
  border: 2.5px solid var(--ink); background: linear-gradient(135deg, var(--purple), var(--navy)); color: var(--star);
  box-shadow: 0 4px 0 var(--ink); cursor: pointer; animation: glow2 1.4s ease-in-out infinite;
}
#crunchBtn .ico { width: 34px; height: 34px; }
#crunchBtn .ctx { display: flex; flex-direction: column; flex: 1; }
#crunchBtn b { font: 900 16px var(--font); }
#crunchBtn small { font: 800 12px var(--font); color: var(--gold); }
#crunchBtn kbd { color: var(--star); border-color: #fff6; }
#crunchBtn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
@keyframes glow2 { 50% { box-shadow: 0 4px 0 var(--ink), 0 0 0 5px #C29BFF99; } }

/* 스케일 사다리 (가로 화면에서 패널 남는 자리) */
#ladder { margin-top: 2px; padding: 8px 10px; border-radius: 16px; border: 2px dashed #2a1b1255; flex: 1; min-height: 0; overflow: hidden; }
#ladder h4 { margin: 0 0 4px; font: 900 13px var(--font); opacity: .7; }
.lrow { display: grid; grid-template-columns: 40px minmax(0, 1fr) auto; column-gap: 8px; align-items: center; padding: 3px 0; border-bottom: 1px dashed #2a1b1222; }
.lrow:last-child { border-bottom: 0; }
.lrow canvas { width: 40px; height: 40px; }
.lrow b { font: 800 13px var(--font); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lrow small { display: block; font: 700 12px var(--font); opacity: .65; }
.lrow em { font: 900 12px var(--font); font-style: normal; color: var(--coral); white-space: nowrap; }
.lrow.now { background: #FFF1C7; border-radius: 10px; }
.lrow.moon em { color: var(--purple); }
body.port #ladder, body.short #ladder { display: none; }

/* 세로 화면: 촘촘한 카드 */
body.port #panel { gap: 6px; padding: 8px 10px; }
body.port #cards { gap: 6px; }
body.port .card { min-height: 48px; padding: 4px 9px; row-gap: 0; box-shadow: 0 3px 0 var(--ink); }
body.port .card .ic { width: 30px; height: 30px; }
body.port .card .ic .ico { width: 24px; height: 24px; }
body.port .card .tx b { font-size: 14px; }
body.port .card .tx small { font-size: 12px; }
body.port .card .cost { font-size: 14px; padding: 2px 7px; }
body.port .card[data-id="domino"] { min-height: 52px; }
body.port .card[data-id="domino"] .tx b { font-size: 16px; }
body.port #crunchBtn { min-height: 48px; padding: 4px 10px; }
/* 좁은 패널 (800x450 iframe 등) */
body.thin .card { column-gap: 7px; padding: 5px 8px; }
body.thin .card .ic { width: 28px; height: 28px; }
body.thin .card .ic .ico { width: 22px; height: 22px; }
body.thin .card .tx b, body.thin .card[data-id="domino"] .tx b { font-size: 14px; }
body.thin .card .cost, body.thin .card[data-id="domino"] .cost { font-size: 13px; padding: 2px 6px; gap: 3px; }
body.thin .card .cost .ico { width: 13px; height: 13px; }

body.short .card { min-height: 50px; padding: 4px 9px; row-gap: 0; }
body.short .card[data-id="domino"] { min-height: 54px; }
body.short #cards, body.short #panel { gap: 6px; }
body.short #panel { padding: 8px; }
body.short .card .ic { width: 30px; height: 30px; }
body.short .card .tx b { font-size: 14px; }
body.short .card[data-id="domino"] .tx b { font-size: 16px; }
body.short .card .tx small { font-size: 12px; }
body.short #crunchBtn { min-height: 48px; padding: 4px 10px; }

/* ---------- 오버레이 ---------- */
.overlay { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; padding: 14px; background: rgba(13, 18, 64, .5); z-index: 5; }
.panel {
  width: 100%; max-width: 440px; max-height: calc(100% - 8px); overflow-y: auto; text-align: center; padding: 18px 20px 20px;
  background: var(--paper); border: 3px solid var(--ink); border-radius: 24px; box-shadow: 0 8px 0 var(--ink); animation: pop .25s ease-out;
}
.panel.wide { max-width: 640px; }
@keyframes pop { from { transform: scale(.92); opacity: 0; } }
h2 { margin: 0 0 10px; font: 900 26px var(--font); }
h3 { margin: 16px 0 6px; font: 900 15px var(--font); opacity: .8; }
p { margin: 8px 0; line-height: 1.5; font-size: 15px; }
p b { color: #D8571F; }
.hint { font-size: 13px; opacity: .75; }
.warn { color: #B42318; opacity: 1; font-weight: 700; }
button.big {
  min-height: 56px; padding: 0 34px; margin: 10px 4px 2px; border-radius: 18px; border: 3px solid var(--ink); cursor: pointer;
  background: var(--coral); color: #fff; font: 900 21px var(--font); box-shadow: 0 5px 0 var(--ink);
}
button.big:active { transform: translateY(3px); box-shadow: 0 2px 0 var(--ink); }
button.mid {
  min-height: 52px; padding: 0 20px; margin: 10px 4px 2px; border-radius: 16px; border: 3px solid var(--ink); cursor: pointer;
  background: var(--paper); font: 800 17px var(--font); box-shadow: 0 5px 0 var(--ink);
}
.row { display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; }
.bignum { display: flex; align-items: center; justify-content: center; gap: 8px; font: 900 44px var(--font); margin: 6px 0; color: var(--purple); }
.bignum small { font: 800 14px var(--font); color: var(--ink); opacity: .7; align-self: flex-end; margin-bottom: 9px; }
.bignum .ico { width: 40px; height: 40px; }
.opts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 14px; }
.opt { min-height: 46px; border-radius: 14px; border: 2.5px solid var(--ink); background: #fff; font: 800 14px var(--font); box-shadow: 0 3px 0 var(--ink); cursor: pointer; }
.opt:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--ink); }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 14px; text-align: left; font-size: 13px; }
.stats div { display: flex; justify-content: space-between; border-bottom: 1px dashed #2a1b1230; padding: 3px 0; }
.stats b { font-weight: 900; }

#momCards { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; margin: 12px 0 4px; }
#momCards .card .cost { background: #E4DAFF; }
#momCards .card .cost .ico { display: none; }
@media (max-width: 560px) { body #momCards { grid-template-columns: 1fr; gap: 7px; } }

#atlas .panel { max-width: 800px; }
#atlasGrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 7px; margin: 8px 0; }
.acell { border: 2px solid var(--ink); border-radius: 14px; background: #fff; padding: 4px 3px 4px; display: flex; flex-direction: column; align-items: center; gap: 1px; }
.acell canvas { width: 52px; height: 52px; }
@media (max-width: 520px) { #atlasGrid { grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); gap: 5px; } .acell canvas { width: 44px; height: 44px; } .acell b { font-size: 12px; } }
.acell b { font: 800 12px var(--font); line-height: 1.15; }
.acell small { font: 700 12px var(--font); opacity: .65; }
.acell.unk { background: #ece5d8; }
.acell.unk b { opacity: .5; }
.acell.next { border-color: var(--coral); border-width: 3px; }

/* 큰 순간: 달·우주를 처음 넘어뜨렸을 때 */
#celebrate { background: radial-gradient(circle at 50% 42%, rgba(255, 201, 74, .42), rgba(13, 18, 64, .78) 72%); }
.panel.celebrate { max-width: 470px; box-shadow: 0 8px 0 var(--ink), 0 0 0 7px #FFC94A99; animation: celPop .55s cubic-bezier(.2, 1.5, .4, 1); }
@keyframes celPop { from { transform: scale(.55) rotate(-5deg); opacity: 0; } }
#celArt { width: 132px; height: 132px; display: block; margin: -6px auto 2px; }
#celTitle { font-size: 30px; color: #D8571F; margin-bottom: 4px; }
#celSub b { color: #D8571F; }
.celstats { display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; margin: 10px 0 6px; }
.celstats div { min-width: 96px; padding: 6px 10px; border-radius: 14px; background: #fff; border: 2px solid var(--ink); box-shadow: 0 3px 0 var(--ink); }
.celstats b { display: block; font: 900 20px var(--font); font-variant-numeric: tabular-nums; }
.celstats span { font: 800 12px var(--font); opacity: .7; }
#celGo { animation: breathe 1.4s ease-in-out infinite; }

/* ---------- 타이틀 ---------- */
#title { background: none; flex-direction: column; justify-content: space-between; padding: max(18px, env(safe-area-inset-top)) 16px max(20px, env(safe-area-inset-bottom)); cursor: pointer; }
#title .tpanel { display: contents; }
.logo {
  margin: 4vh 0 0; text-align: center; line-height: .95; font-weight: 900; color: var(--star);
  -webkit-text-stroke: 9px var(--ink); paint-order: stroke fill; text-shadow: 0 7px 0 var(--ink);
  letter-spacing: 1px; pointer-events: none;
}
.logo span { display: block; }
.logo .l1 { font-size: clamp(30px, 7.5vmin, 72px); }
.logo .l2 { font-size: clamp(48px, 13vmin, 128px); color: var(--gold); }
html[lang="en"] .logo .l1 { font-size: clamp(44px, 11.5vmin, 116px); color: var(--gold); }
html[lang="en"] .logo .l2 { font-size: clamp(26px, 6.6vmin, 66px); color: var(--star); }
#title .sub { margin: 10px 0 0; text-align: center; font: 900 clamp(12px, 2.4vmin, 20px) var(--font); letter-spacing: 6px; color: var(--star); -webkit-text-stroke: 4px var(--ink); paint-order: stroke fill; pointer-events: none; }
#title .hook {
  margin: auto auto 0; max-width: 560px; text-align: center; font: 800 clamp(14px, 2.4vmin, 19px) var(--font); line-height: 1.5;
  padding: 10px 18px; border-radius: 18px; background: #fff8ecdd; border: 2.5px solid var(--ink); pointer-events: none;
}
#title .hook b { color: #D8571F; }
#startBtn { align-self: center; margin-top: 12px; font-size: 24px; min-height: 64px; padding: 0 46px; animation: breathe 1.4s ease-in-out infinite; }
@keyframes breathe { 50% { transform: scale(1.05); } }
#title .hint { text-align: center; margin: 6px auto 0; padding: 3px 12px; border-radius: 12px; background: #fff8ecc8; max-width: 640px; }
#title .hint:empty { display: none; }
#title .tag { display: none; }
.tcorner { position: absolute; top: max(12px, env(safe-area-inset-top)); right: 12px; display: flex; gap: 8px; }
.pillbtn { min-height: 44px; padding: 0 16px; border-radius: 999px; border: 2.5px solid var(--ink); background: var(--paper); font: 800 14px var(--font); box-shadow: 0 3px 0 var(--ink); cursor: pointer; }
.touch { display: none !important; }
@media (pointer: coarse) { .touch { display: block !important; } .pc, kbd.pc, .card kbd { display: none !important; } }

/* 짧은 화면(가로 폰·800x450) */
@media (max-height: 480px) {
  .logo { margin-top: 0; -webkit-text-stroke-width: 7px; text-shadow: 0 5px 0 var(--ink); }
  .logo .l2 { font-size: clamp(40px, 15vmin, 80px); }
  html[lang="en"] .logo .l1 { font-size: clamp(38px, 13vmin, 76px); }
  #title .hook { font-size: 13px; padding: 6px 12px; }
  #startBtn { min-height: 54px; font-size: 20px; margin-top: 6px; }
  #title .hint { font-size: 12px; margin-top: 3px; }
  .panel { padding: 12px 16px 14px; }
  h2 { font-size: 21px; margin-bottom: 4px; }
  p { margin: 4px 0; font-size: 13px; }
  .bignum { font-size: 34px; margin: 2px 0; }
  button.big { min-height: 48px; font-size: 18px; margin-top: 6px; }
  #coinBox { font-size: 20px; padding: 3px 10px 3px 6px; }
  #coinBox .ico { width: 20px; height: 20px; }
  .icon { min-width: 44px; height: 44px; }
  #goal { padding: 4px 10px 5px; }
  #goalEta { display: none; }
  #result { padding: 6px 6px 6px 12px; bottom: 8px; }
  #resTitle { font-size: 15px; }
  #againBtn { min-height: 46px; font-size: 16px; padding: 0 16px; }
  #banner { font-size: 13px; padding: 6px 12px; }
  #celArt { width: 76px; height: 76px; margin-top: -2px; }
  #celTitle { font-size: 22px; }
  .celstats { margin: 4px 0 2px; }
  .celstats div { min-width: 80px; padding: 3px 8px; }
  .celstats b { font-size: 16px; }
}

/* 커버 캡처 모드 (?cover=1|en): UI 없이 로고만 */
body.cover #title .hook, body.cover #startBtn, body.cover #title .hint, body.cover .tcorner { display: none !important; }
body.cover .logo { margin-top: 5vh; }
body.cover .logo .l2 { font-size: min(17vmin, 170px); }
html[lang="en"] body.cover .logo .l1 { font-size: min(15vmin, 150px); }

/* ---------- 2단계: 업적 · 출석 · 추천 · 전환 ---------- */
/* 새 업적 배지 (HUD 도감 버튼 · 업적 탭): 숫자 + ★ 로 표시 */
.icon { position: relative; }
.badge {
  position: absolute; top: -9px; right: -9px; min-width: 24px; height: 22px; padding: 0 5px; border-radius: 11px;
  background: var(--gold); border: 2px solid var(--ink); font: 900 12px/18px var(--font); font-style: normal; color: var(--ink);
  text-align: center; box-shadow: 0 2px 0 var(--ink); animation: badgePop .5s cubic-bezier(.2, 1.6, .4, 1);
}
@keyframes badgePop { from { transform: scale(0); } }
.tab .badge { top: -8px; right: -6px; }

/* 컬렉션 창: 탭과 닫기 버튼은 늘 보이고, 목록만 스크롤 */
#atlas .panel { display: flex; flex-direction: column; overflow: hidden; }
#atlas .tabs, #atlasClose { flex: none; }
#atlasGrid, #featPane { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; touch-action: pan-y; padding: 2px 4px 4px; margin: 0 -4px; }
#atlasClose { align-self: center; }
/* 컬렉션 탭: 선택된 탭은 배경 + 굵은 밑줄 + aria-selected (색만으로 구분하지 않음) */
.tabs { display: flex; gap: 8px; margin: -2px 0 10px; }
.tab {
  position: relative; flex: 1; min-height: 48px; display: flex; align-items: center; justify-content: center; gap: 6px; padding: 0 10px;
  border-radius: 14px; border: 2.5px solid var(--ink); background: #efe6d6; font: 800 15px var(--font); cursor: pointer; box-shadow: 0 3px 0 var(--ink);
}
.tab b { font-weight: 900; opacity: .7; font-variant-numeric: tabular-nums; }
.tab.on { background: #fff; box-shadow: 0 3px 0 var(--ink), inset 0 -5px 0 var(--gold); }
.tab.on b { opacity: 1; }
.tab:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--ink); }
.tab .ico { width: 22px; height: 22px; }
.tab span, .tab b { white-space: nowrap; }
@media (max-width: 480px) {
  .tab { flex-direction: column; gap: 0; padding: 3px 6px; font-size: 14px; line-height: 1.2; }
  .tab .ico { display: none; }
  .tab b { font-size: 12px; }
}
#featBonus { margin: 0 0 8px; font-size: 14px; opacity: .9; }
#featBonus b { color: #D8571F; }
#featList { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; text-align: left; }
@media (max-width: 640px) { #featList { grid-template-columns: 1fr; } }
.feat {
  display: grid; grid-template-columns: 40px minmax(0, 1fr) auto; align-items: center; column-gap: 9px; min-height: 56px; padding: 6px 10px 6px 6px;
  border-radius: 14px; border: 2px solid var(--ink); background: #f3ece0;
}
.feat.done { background: #fff; border-width: 2.5px; box-shadow: 0 3px 0 var(--ink); }
.fic { width: 40px; height: 40px; border-radius: 12px; background: var(--cream); display: flex; align-items: center; justify-content: center; overflow: hidden; }
.fic .ico { width: 28px; height: 28px; }
.feat:not(.done) .fic { filter: grayscale(.85); opacity: .65; }
.ftx { min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.ftx b { font: 900 14px var(--font); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ftx small { font: 700 12px var(--font); opacity: .75; line-height: 1.25; }
.fbar { display: block; height: 6px; margin-top: 3px; border-radius: 4px; background: #2a1b121f; overflow: hidden; }
.fbar i { display: block; height: 100%; border-radius: 4px; background: linear-gradient(90deg, var(--gold), var(--coral)); }
.frw { display: flex; flex-direction: column; align-items: flex-end; gap: 1px; white-space: nowrap; }
.frw b { font: 900 14px var(--font); padding: 1px 7px; border-radius: 9px; background: #E4DAFF; border: 1.5px solid var(--ink); }
.feat.done .frw b { background: var(--gold); }
.frw small { font: 800 12px var(--font); opacity: .75; font-variant-numeric: tabular-nums; }
.feat.done .frw small { opacity: 1; color: #2E7D57; }

/* 업적 토스트: 트로피 아이콘 + 금빛 */
.toast.feat { display: flex; align-items: center; gap: 7px; background: linear-gradient(180deg, #FFE59A, var(--gold)); animation: toastIn .35s cubic-bezier(.2, 1.5, .4, 1), toastOut .4s ease-in 2.7s forwards; }
.toast.feat .ico { width: 22px; height: 22px; flex: none; }

/* 살 수 없을 때: 가격표가 모인 코인만큼 왼쪽부터 차오른다 (꽉 차면 금색 = 살 수 있음) */
.card.no .cost { background: linear-gradient(90deg, #F3D27C var(--p, 0%), #eadfcf var(--p, 0%)); }

/* 빅 크런치 추천: 버튼 리본 + ETA 자리 안내 */
#crunchBtn { position: relative; }
#crunchAdvise {
  font: 900 12px var(--font); font-style: normal; padding: 3px 8px; border-radius: 8px; background: var(--gold); color: var(--ink);
  border: 2px solid var(--ink); white-space: nowrap; animation: breathe 1s ease-in-out infinite;
}
#crunchBtn.advise { animation: glow3 1s ease-in-out infinite; }
@keyframes glow3 { 50% { box-shadow: 0 4px 0 var(--ink), 0 0 0 7px #FFC94Acc; } }
#goalEta.advise { opacity: 1; color: #6B3FD0; font-weight: 900; }
body.narrow #goalEta.advise { display: block; }

/* 출석: 7칸 점 (받은 날 ✓, 오늘 = 굵은 테두리 + 숫자) */
.daily { margin: 6px 0 2px; padding: 10px 12px 6px; border-radius: 18px; background: #fff; border: 2.5px dashed #2a1b1260; }
.dots { display: flex; justify-content: center; gap: 6px; margin-bottom: 8px; }
.dots i {
  width: 34px; height: 34px; border-radius: 50%; border: 2px solid #2a1b1240; display: flex; align-items: center; justify-content: center;
  font: 900 13px var(--font); font-style: normal; color: #2a1b1288; background: #f3ece0;
}
.dots i.got { background: var(--jade); border-color: var(--ink); color: #fff; }
.dots i.today { background: var(--gold); border: 3px solid var(--ink); color: var(--ink); transform: scale(1.15); animation: breathe 1.2s ease-in-out infinite; }
.drow { display: flex; align-items: center; justify-content: center; gap: 8px; font: 800 16px var(--font); }
.drow .ico { width: 26px; height: 26px; }
.dcoin { display: inline-flex; align-items: center; gap: 4px; padding: 2px 10px; border-radius: 12px; background: var(--gold); border: 2px solid var(--ink); font: 900 18px var(--font); }
.dcoin .ico { width: 18px; height: 18px; }

.opts .opt.wide { grid-column: 1 / -1; background: linear-gradient(135deg, #E4DAFF, #fff); }
.tip { background: #FFF1C7; border-radius: 12px; padding: 6px 10px; opacity: 1; font-weight: 700; }

/* 타이틀을 떠날 때: 로고는 위로, 아래 요소는 아래로 빠지며 사라짐 */
#title.leaving { pointer-events: none; }
#title.leaving .logo, #title.leaving .sub { animation: outUp .42s cubic-bezier(.5, 0, .9, .4) forwards; }
#title.leaving .hook, #title.leaving #startBtn, #title.leaving .hint, #title.leaving .tcorner { animation: outDown .34s ease-in forwards; }
@keyframes outUp { to { transform: translateY(-40vh) scale(.8); opacity: 0; } }
@keyframes outDown { to { transform: translateY(30vh); opacity: 0; } }

/* 모션 줄이기 */
body.reduce *, body.reduce *::before, body.reduce *::after { animation-duration: .01s !important; animation-iteration-count: 1 !important; transition: none !important; }
