@font-face { font-family: 'Jua'; src: url('assets/fonts/Jua-Regular.ttf') format('truetype'); font-display: swap; }
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { width: 100%; height: 100%; background: #1a1612; overflow: hidden; font-family: 'Jua', system-ui, sans-serif; touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }

#stage { position: fixed; inset: 0; padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); display: flex; align-items: center; justify-content: center; }
#game { position: relative; flex: 0 0 auto; width: 900px; height: 420px; transform-origin: center center; background: #e8f4ff; overflow: hidden; border-radius: 18px; }

#world { position: absolute; left: 0; top: 0; width: 900px; height: 330px; display: block; }

/* HUD */
#hud { position: absolute; left: 0; top: 0; width: 900px; height: 46px; pointer-events: none; }
.hud-bar { position: absolute; left: 12px; top: 8px; height: 32px; padding: 0 14px; display: flex; gap: 22px; align-items: center;
  background: rgba(255,255,255,.75); border-radius: 12px; font-size: 15px; color: #26263a; }
.retry { color: #e6405a; letter-spacing: 2px; }
.env-row { position: absolute; left: 50%; transform: translateX(-50%); margin-left: -110px; top: 8px; height: 32px; padding: 0 8px; display: flex; gap: 8px; align-items: center;
  background: rgba(255,255,255,.35); border-radius: 12px; }
.chip { display: inline-block; height: 22px; line-height: 22px; padding: 0 10px; border-radius: 8px; font-size: 12px; color: #fff; background: rgba(51,77,140,.6); }
.chip.on { background: rgba(230,120,40,.85); }
.chip.ghost { width: 60px; background: rgba(51,77,140,.15); }
.hud-btns { position: absolute; right: 12px; top: 8px; display: flex; gap: 6px; pointer-events: auto; }
.icon-btn { width: 32px; height: 32px; border: 0; border-radius: 10px; background: rgba(255,255,255,.75); font-size: 16px; color: #26263a; cursor: pointer; font-family: inherit; }

#hint { position: absolute; left: 50%; top: 52px; transform: translateX(-50%); padding: 5px 18px; border-radius: 14px;
  background: rgba(26,30,46,.72); color: #fff; font-size: 14px; white-space: nowrap; pointer-events: none; transition: background .15s; }
#hint.flash { background: #f2c21a; color: #2b1d05; }

/* Tray */
#tray { position: absolute; left: 0; top: 330px; width: 900px; height: 90px; background: #2a1f14; }
#tray-title { position: absolute; left: 240px; top: 6px; font-size: 12px; color: #ffe6b3; }
#tray-slots { position: absolute; left: 240px; top: 24px; right: 12px; height: 60px; display: flex; gap: 12px; align-items: center; overflow-x: auto; }
.slot { position: relative; flex: 0 0 auto; width: 46px; height: 46px; background: rgba(255,255,255,.06); border-radius: 8px; border: 2px solid #26263a; cursor: pointer; transition: transform .1s; }
.slot canvas { position: absolute; left: 0; top: 0; width: 100%; height: 100%; border-radius: 6px; }
.slot.locked { opacity: .18; pointer-events: none; }
.slot.selected { border-color: #ffc71a; transform: scale(1.12); box-shadow: 0 0 12px rgba(255,199,26,.8); }
.slot .nm { position: absolute; left: 0; right: 0; top: 50%; transform: translateY(-50%); text-align: center; color: #fff; font-size: 10px; text-shadow: 0 1px 2px #000; pointer-events: none; }

/* Result */
#result { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(40,50,90,.35); }
#result.hidden { display: none; }
.panel { width: 400px; padding: 16px 20px 14px; border-radius: 20px; background: rgba(255,255,255,.95); text-align: center; color: #26263a; }
.panel .title { font-size: 22px; }
.panel .stars { font-size: 30px; color: #ffb81a; margin: 2px 0; letter-spacing: 6px; }
.panel .label { font-size: 12px; color: #73738c; }
.panel .pct { font-size: 44px; color: #334d8c; line-height: 1; }
.panel .bar { position: relative; height: 10px; margin: 12px 20px 2px; border-radius: 5px; background: #e6e6f2; }
.panel .bar .fill { height: 100%; width: 0; border-radius: 5px; background: #3380e6; transition: width .6s ease-out; }
.panel .bar i { position: absolute; top: -4px; width: 2px; height: 18px; background: #66667f; }
.panel .ticks { position: relative; height: 14px; margin: 0 20px; font-size: 9px; color: #73738c; }
.panel .ticks span { position: absolute; transform: translateX(-50%); white-space: nowrap; }
.panel .summary { font-size: 12px; color: #66667f; margin: 8px 0 10px; min-height: 16px; }
.btns { display: flex; gap: 10px; }
.btns button { flex: 1; height: 42px; border: 0; border-radius: 12px; font-family: inherit; font-size: 16px; cursor: pointer; background: #f0f0f8; color: #334d8c; }
.btns button.primary { background: #ffb81a; color: #402604; }

#rotate-notice { position: fixed; inset: 0; display: none; align-items: center; justify-content: center; background: #1a1612; color: #fff; font-size: 26px; z-index: 50; }
@media (orientation: portrait) and (max-width: 700px) { body.web #rotate-notice { display: flex; } } /* 앱은 OS가 가로로 고정하므로 안내를 띄우지 않음 */
#quit { position: absolute; inset: 0; z-index: 7; display: flex; align-items: center; justify-content: center; background: rgba(20,30,50,.55); }
#quit.hidden { display: none; }

.score-btn { height: 40px; padding: 0 16px; border: 0; border-radius: 10px; background: #ffb81a; color: #402604; font-family: inherit; font-size: 15px; cursor: pointer; }

/* Map — 왕국 길 */
#map { position: absolute; inset: 0; background: #7cbd66; z-index: 5; display: flex; flex-direction: column; }
#map.hidden { display: none; }
.map-head { display: flex; align-items: center; gap: 10px; height: 44px; padding: 0 14px; background: rgba(20,30,20,.55); color: #fff; }
.map-head .logo { font-size: 22px; }
.pill { font-size: 14px; background: rgba(255,255,255,.9); color: #4a3a10; padding: 3px 12px; border-radius: 12px; border: 0; font-family: inherit; }
.pill.btn { background: #ffb81a; color: #402604; cursor: pointer; font-size: 15px; }
/* 개발자 모드(CB_DEV 빌드)에서만 보이는 버튼 */
.dev { display: none; }
body.devmode .dev { display: inline-block; }
.map-head .dev { border: 0; background: rgba(255,120,120,.55); border-radius: 8px; padding: 4px 8px; font-family: inherit; font-size: 11px; color: #fff; cursor: pointer; }
body.devmode .map-head .logo { display: none; }
.icon-btn.dev { background: rgba(255,150,150,.85); }
/* 개발자 모드 표시: 어느 화면에서든 구석에 DEV */
body.devmode::after { content: "DEV"; position: fixed; left: 6px; bottom: 4px; z-index: 9999; padding: 1px 7px; border-radius: 6px; background: rgba(224,36,36,.85); color: #fff; font-size: 11px; letter-spacing: 1px; pointer-events: none; }
#btn-unlock { margin-left: auto; border: 0; background: rgba(255,255,255,.35); border-radius: 8px; padding: 4px 10px; font-family: inherit; font-size: 11px; color: #fff; cursor: pointer; }
#map-scroll { position: relative; flex: 1; overflow-x: auto; overflow-y: hidden; }
#map-track { position: relative; height: 330px; zoom: var(--map-zoom, 1); }
.world-band { position: absolute; top: 0; height: 100%; background: linear-gradient(var(--sky) 0, var(--sky) 62%, var(--ground) 62%); }
.band-name { position: absolute; left: 16px; top: 10px; font-size: 15px; color: #26263a; background: rgba(255,255,255,.7); padding: 2px 10px; border-radius: 8px; }
.band-deco { position: absolute; left: 20px; bottom: 14px; font-size: 22px; letter-spacing: 30px; opacity: .8; }
#map-path { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
#map-path .road-under { fill: none; stroke: rgba(60,40,20,.35); stroke-width: 22; stroke-linecap: round; }
#map-path .road { fill: none; stroke: #f3dca0; stroke-width: 14; stroke-linecap: round; stroke-dasharray: 2 20; stroke-linejoin: round; }
.node { position: absolute; width: 64px; height: 64px; margin: -32px 0 0 -32px; border-radius: 50%; border: 4px solid #fff; background: #fff; padding: 0; cursor: pointer; box-shadow: 0 4px 0 rgba(0,0,0,.25); font-family: inherit; }
.node canvas { width: 52px; height: 52px; display: block; margin: 2px; border-radius: 50%; }
.node.open { border-color: #ffb81a; box-shadow: 0 0 0 5px rgba(255,184,26,.35), 0 4px 0 rgba(0,0,0,.25); animation: pulse 1.4s infinite; }
.node.done { border-color: #6fcf5f; }
.node.locked { background: #cfd4d8; border-color: #b8bec4; cursor: default; }
.node .num { position: absolute; left: -6px; top: -8px; width: 22px; height: 22px; border-radius: 50%; background: #26263a; color: #fff; font-size: 12px; line-height: 22px; }
.node .stars { position: absolute; left: 50%; top: 66px; transform: translateX(-50%); white-space: nowrap; font-size: 13px; color: #ffa800; text-shadow: 0 1px 2px rgba(0,0,0,.4); }
.node.locked .stars { font-size: 16px; }
.node .wind { position: absolute; right: -10px; top: -8px; font-size: 10px; color: #fff; background: rgba(230,120,40,.95); border-radius: 6px; padding: 1px 5px; }
#map-marker { position: absolute; font-size: 30px; transform: translateX(-50%); animation: bob 1s infinite alternate; pointer-events: none; filter: drop-shadow(0 2px 2px rgba(0,0,0,.4)); }
@keyframes pulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.08); } }
@keyframes bob { from { margin-top: 0; } to { margin-top: -8px; } }
@media (prefers-reduced-motion: reduce) { .node.open, #map-marker { animation: none; } }

/* Stage popup / Shop */
#stage-pop, #shop { position: absolute; inset: 0; z-index: 6; display: flex; align-items: center; justify-content: center; background: rgba(20,30,50,.45); }
#stage-pop.hidden, #shop.hidden { display: none; }
.pop { width: 380px; padding: 16px 18px 14px; border-radius: 18px; background: #fffdf7; color: #26263a; }
.pop-title { font-size: 22px; text-align: center; }
.pop-row { display: flex; gap: 14px; align-items: center; margin: 10px 0 6px; }
#pop-thumb canvas { width: 120px; height: 120px; background: #e8f4ff; border-radius: 12px; }
.pop-info { font-size: 15px; line-height: 1.6; flex: 1; }
.pop-reward { font-size: 13px; color: #8a6a10; background: #fff3cf; border-radius: 8px; padding: 6px 10px; margin-bottom: 10px; }
.shop-panel { width: 560px; max-height: 380px; padding: 12px 16px 14px; border-radius: 18px; background: #fffdf7; color: #26263a; display: flex; flex-direction: column; }
.shop-head { display: flex; align-items: center; gap: 12px; font-size: 20px; margin-bottom: 8px; }
.shop-head button { margin-left: auto; border: 0; background: #eee; border-radius: 10px; padding: 6px 14px; font-family: inherit; font-size: 14px; cursor: pointer; }
#shop-list { display: flex; flex-direction: column; gap: 8px; overflow-y: auto; }
.upg { display: flex; align-items: center; gap: 12px; padding: 8px 10px; border-radius: 12px; background: #f5f1e6; }
.upg.maxed { opacity: .7; }
.upg .icon { font-size: 28px; width: 40px; text-align: center; }
.upg .body { flex: 1; }
.upg .nm { font-size: 16px; }
.upg .dots { font-size: 11px; color: #ffa800; margin-left: 6px; letter-spacing: 2px; }
.upg .ds { font-size: 12px; color: #66667f; }
.upg .ef { font-size: 12px; color: #2c7a3e; }
.upg .buy { border: 0; border-radius: 10px; background: #ffb81a; color: #402604; font-family: inherit; font-size: 15px; padding: 8px 14px; cursor: pointer; min-width: 84px; }
.upg .buy.no { background: #ddd; color: #888; cursor: default; }
.panel .gold { font-size: 16px; color: #b37400; margin: -4px 0 8px; min-height: 18px; }

/* 스킨 가게 */
.tabs { display: flex; gap: 6px; margin-bottom: 8px; }
.tab { border: 0; border-radius: 10px; padding: 6px 14px; font-family: inherit; font-size: 14px; background: #eee; color: #55607a; cursor: pointer; }
.tab.on { background: #26263a; color: #fff; }
.skins { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.skin { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 8px 6px; border-radius: 12px; background: #f5f1e6; border: 2px solid transparent; }
.skin.on { border-color: #ffb81a; background: #fff3cf; }
.skin canvas { width: 72px; height: 48px; border-radius: 8px; }
.skin .nm { font-size: 13px; color: #26263a; }
.skin .buy { border: 0; border-radius: 8px; background: #ffb81a; color: #402604; font-family: inherit; font-size: 13px; padding: 5px 10px; cursor: pointer; min-width: 64px; }
.skin .buy.no { background: #ddd; color: #888; cursor: default; }
.skin .buy.eq { background: #cfe8d0; color: #1f5a2a; }
.skin.on .buy { background: #26263a; color: #fff; }

.world-band { background-size: auto 100%; background-repeat: repeat-x; background-position: left bottom; } /* 시대 띠가 20판 폭이라 그림을 늘리지 않고 옆으로 이어 붙임 */
.world-band.dark .band-name { background: rgba(0,0,0,.45); color: #fff; }
#map-path .road.img { stroke-dasharray: none; stroke-width: 26; }
.node .stars img { display: inline-block; }

#menu { position: absolute; inset: 0; z-index: 7; display: flex; align-items: center; justify-content: center; background: rgba(20,30,50,.45); }
#menu.hidden { display: none; }
.pop.menu { width: 300px; display: flex; flex-direction: column; gap: 8px; }
.menu-btn { height: 44px; border: 0; border-radius: 12px; background: #ffb81a; color: #402604; font-family: inherit; font-size: 16px; cursor: pointer; }
.menu-btn.light { background: #eee; color: #55607a; }

#hint:empty { display: none; }
.env-row:not(:has(.chip:not(:empty))) { visibility: hidden; }

/* 까다로운 의뢰인 */
.client-say { display: flex; align-items: center; gap: 8px; }
.client-say.hidden { display: none; }
.client-say .face { flex: none; width: 54px; height: 54px; border-radius: 50%; background: #fff3cf; border: 3px solid #fff; box-shadow: 0 2px 6px rgba(0,0,0,.25); overflow: hidden; display: flex; align-items: center; justify-content: center; font-size: 28px; }
.client-say .face img { width: 100%; height: 100%; object-fit: cover; object-position: 50% 20%; }
.client-say .bubble { min-width: 0; box-sizing: border-box; position: relative; background: #fffdf7; color: #26263a; border-radius: 12px; padding: 7px 11px; font-size: 13px; line-height: 1.35; text-align: left; box-shadow: 0 2px 6px rgba(0,0,0,.18); }
.client-say .bubble::before { content: ''; position: absolute; left: -6px; top: 50%; margin-top: -6px; border: 6px solid transparent; border-left: 0; border-right-color: #fffdf7; }
.client-say .bubble b { display: block; font-weight: normal; font-size: 11px; color: #b37400; }
#client-order { position: absolute; left: 12px; top: 58px; max-width: 330px; z-index: 3; pointer-events: none; }
.client-say.res { margin: 4px 0 2px; }
.client-say.res .face { width: 64px; height: 64px; }
.client-say.res .bubble { flex: 1; font-size: 14px; background: #fff6de; }
.client-say.res .bubble::before { border-right-color: #fff6de; }
.client-say.pop { margin: 2px 0 8px; width: 100%; }
.client-say.pop .bubble { flex: 1; background: #f3f1f8; }
.client-say.pop .bubble::before { border-right-color: #f3f1f8; }

/* 보상형 광고 버튼 */
.icon-btn.ad.hidden, .ad-btn.hidden { display: none; }
.ad-btn { border: 0; border-radius: 10px; padding: 3px 10px; margin-left: 6px; font-family: inherit; font-size: 13px; background: #ffb81a; color: #2b1d05; cursor: pointer; vertical-align: 1px; }
.skin .buy.trial { margin-top: 4px; background: #fff3cf; color: #8a6a10; }

/* 파울 목숨 · 공사장 재도전(↶ 버튼) */
#hud-lives { color: #ff6b8a; font-size: 14px; letter-spacing: 1px; margin-left: 6px; }
#btn-undo.dim { opacity: .35; }
#btn-undo.flash { animation: undoflash .6s ease-in-out 5; background: #ffb81a; }
@keyframes undoflash { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.18); background: #fff0b0; } }

/* 타이틀 · 엔딩 */
#title { position: absolute; inset: 0; z-index: 40; background: #1a1612; overflow: hidden; cursor: pointer; }
#title.hidden { display: none; }
#title-art { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
#title-logo { position: absolute; left: 0; right: 0; top: 10%; text-align: center; font-size: 64px; color: #fff; text-shadow: 0 4px 0 #8a5a2b, 0 8px 18px rgba(0,0,0,.45); letter-spacing: 2px; }
#title-tap { position: absolute; left: 0; right: 0; bottom: 38%; text-align: center; font-size: 20px; color: #fff; text-shadow: 0 2px 6px rgba(0,0,0,.6); animation: blink 1.4s ease-in-out infinite; }
#title-ver { position: absolute; right: 12px; bottom: 8px; font-size: 11px; color: rgba(255,255,255,.7); }
@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }
#ending { position: absolute; inset: 0; z-index: 8; display: flex; align-items: center; justify-content: center; background: rgba(20,30,50,.6); }
#ending.hidden { display: none; }
.pop.ending { width: 520px; text-align: center; }
#ending-faces { display: flex; justify-content: center; gap: 4px; margin: 10px 0; }
#ending-faces img { width: 44px; height: 44px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 2px 5px rgba(0,0,0,.25); }
#ending-body { font-size: 14px; line-height: 1.5; margin: 6px 0 12px; }

/* 시대 안내 */
#intro { position: absolute; inset: 0; z-index: 9; display: flex; align-items: center; justify-content: center; background: rgba(20,30,50,.6); }
#intro.hidden { display: none; }
.pop.intro { width: 440px; text-align: center; }
.pop.intro .face { width: 72px; height: 72px; margin: 0 auto 6px; border-radius: 50%; background: #fff3cf; border: 3px solid #fff; box-shadow: 0 2px 6px rgba(0,0,0,.25); overflow: hidden; display: flex; align-items: center; justify-content: center; font-size: 36px; }
.pop.intro .face img { width: 100%; height: 100%; object-fit: cover; object-position: 50% 20%; }
#intro-body { font-size: 14px; line-height: 1.5; margin: 8px 0 12px; }

/* 세로 화면에서도 가로로: #stage 를 90도 돌림 (앱이 세로로 켜지는 폴더블·태블릿 대비) */
body.rot #stage { position: fixed; left: 0; top: 0; inset: auto; transform-origin: top left; transform: rotate(90deg) translateY(-100%); }
body.rot.native #rotate-notice { display: none !important; }

/* 메인 메뉴 · 준비 화면 */
#title-menu { position: absolute; left: 0; right: 0; bottom: 36%; display: flex; gap: 14px; justify-content: center; }
#title-menu.hidden { display: none; }
.main-btn { min-width: 150px; padding: 12px 22px; border: 0; border-radius: 16px; font-family: inherit; font-size: 20px; background: rgba(255,255,255,.92); color: #26263a; box-shadow: 0 4px 0 rgba(0,0,0,.25); cursor: pointer; }
.main-btn.primary { background: #ffb81a; color: #2b1d05; }
/* 웹판 전용: 플레이 스토어로 가는 작은 버튼. 앱(body.native)에서는 안 보인다 */
.main-btn.sm { min-width: 0; padding: 7px 14px; border-radius: 12px; font-size: 15px; box-shadow: 0 3px 0 rgba(0,0,0,.25); }
#btn-store { display: none; position: absolute; top: calc(10px + env(safe-area-inset-top)); right: calc(12px + env(safe-area-inset-right)); text-decoration: none; }
body.web #btn-store { display: block; }
#btn-home { margin-right: 6px; background: rgba(255,255,255,.3); }
#ready { position: absolute; left: 50%; top: 110px; transform: translateX(-50%); z-index: 4; padding: 12px 16px; border-radius: 16px; background: rgba(255,253,247,.95); color: #26263a; text-align: center; box-shadow: 0 4px 14px rgba(0,0,0,.25); min-width: 230px; }
#ready.hidden { display: none; }
#ready-info { font-size: 14px; line-height: 1.5; margin-bottom: 10px; }
#ready-info b { font-size: 18px; font-weight: normal; }
#ready .btns { display: flex; gap: 8px; justify-content: center; }
#ready button { border: 0; border-radius: 12px; padding: 9px 18px; font-family: inherit; font-size: 16px; background: #ececf4; color: #26263a; cursor: pointer; }
#ready button.primary { background: #ffb81a; color: #2b1d05; min-width: 110px; font-size: 18px; }
#title-tap.hidden { display: none; }
#btn-menu-map.hidden { display: none; }
