/* 남부터미널 v1 — 픽셀 코지 */
@font-face {
  font-family: 'DGM';
  src: url('fonts/DungGeunMo.woff2') format('woff2'), url('fonts/DungGeunMo.woff') format('woff');
  font-display: swap;
}
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  font-family: 'DGM', 'Galmuri11', 'Apple SD Gothic Neo', 'Noto Sans KR', sans-serif;
  background: #1b1530; color: #f3ead8;
  overscroll-behavior: none;
  -webkit-user-select: none; user-select: none;
  line-height: 1.55;
}
img { image-rendering: pixelated; }
button { font: inherit; color: inherit; }

#app { max-width: 520px; margin: 0 auto; height: 100dvh; display: flex; flex-direction: column; position: relative; overflow: hidden; }
.scr { flex: 1; display: flex; flex-direction: column; min-height: 0; }

/* ── 공용 버튼 ── */
.pxbtn {
  display: block; width: 100%; text-align: center;
  background: #2e2450; border: 3px solid #0e0a1e;
  box-shadow: inset 0 -4px 0 #201740, 0 3px 0 #0e0a1e;
  color: #f3ead8; padding: 12px 14px; margin: 6px 0;
  font-size: 16px; cursor: pointer; border-radius: 6px;
}
.pxbtn:active { transform: translateY(2px); box-shadow: inset 0 -2px 0 #201740, 0 1px 0 #0e0a1e; }
.pxbtn.hot { background: #b3502e; box-shadow: inset 0 -4px 0 #8a3a20, 0 3px 0 #0e0a1e; }
.pxbtn.ghost { background: transparent; box-shadow: none; border-color: #4a3e78; }
.pxbtn:disabled { opacity: .5; cursor: default; }
.pxbtn small { display: block; font-size: 12px; color: #cdbfa4; margin-top: 3px; }
.pxbtn small.dis { color: #e08a8a; }
.pxbtn em { font-style: normal; color: #ffd76a; }

/* ── 타이틀 ── */
#scr-title { background: #1b1530 center/cover no-repeat; justify-content: flex-end; position: relative; }
.title-veil { position: absolute; inset: 0; background: linear-gradient(180deg, rgba(20,12,40,.15) 30%, rgba(20,12,40,.88) 78%); }
.title-inner { position: relative; padding: 24px 28px calc(30px + env(safe-area-inset-bottom)); text-align: center; }
.title-pre { color: #ffd76a; font-size: 14px; text-shadow: 0 2px 0 #000; }
#scr-title h1 { font-size: 52px; letter-spacing: 4px; text-shadow: 0 4px 0 #000, 0 0 24px rgba(255,190,80,.35); margin: 4px 0 18px; }
.btns { max-width: 260px; margin: 0 auto; }
.hint { margin-top: 12px; font-size: 12px; color: #cdbfa4; }
.credit { margin-top: 10px; font-size: 11px; color: #8d7fb5; }

/* ── 전공 선택 ── */
#scr-major { justify-content: center; background: radial-gradient(circle at 50% 20%, #2e2450, #1b1530); }
.major-wrap { padding: 28px; text-align: center; }
.major-wrap h2 { font-size: 26px; }
.major-sub { color: #cdbfa4; font-size: 13px; margin: 6px 0 18px; }
.major-card b { font-size: 20px; }

/* ── HUD ── */
#hud { display: flex; align-items: center; gap: 10px; padding: 8px 12px; padding-top: calc(8px + env(safe-area-inset-top)); background: #241b42; border-bottom: 3px solid #0e0a1e; }
#hud-face { width: 44px; height: 44px; border-radius: 8px; border: 2px solid #0e0a1e; object-fit: cover; }
.hud-mid { flex: 1; min-width: 0; }
#hud-date { font-size: 15px; color: #ffd76a; }
#week-ask { font-size: 11px; color: #cdbfa4; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hud-right { text-align: right; }
#hud-money { font-size: 15px; }
#hud-fame { font-size: 12px; color: #ffd76a; }

/* ── 지도 ── */
#map-wrap { flex: 1; min-height: 0; overflow: hidden; position: relative; background: #131022; }
#map {
  position: absolute; left: 0; top: 0; width: 100%; height: 100%;
  background: url('art/generated/map.png?v=1') no-repeat;
  background-size: 100% 100%;
}
.mk {
  position: absolute; transform: translate(-50%, -50%);
  background: rgba(20, 14, 40, .82); border: 2px solid #0e0a1e; border-radius: 10px;
  padding: 4px 8px; cursor: pointer; text-align: center;
  box-shadow: 0 3px 0 rgba(0,0,0,.5);
}
.mk-ico { display: block; font-size: 20px; line-height: 1.1; }
.mk-lb { display: block; font-size: 10px; color: #f3ead8; text-shadow: 0 1px 0 #000; }
.mk:active { transform: translate(-50%, -50%) scale(.94); }
.mk.glow { border-color: #ffd76a; box-shadow: 0 0 14px rgba(255, 215, 106, .8), 0 3px 0 rgba(0,0,0,.5); animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 4px rgba(255,215,106,.4), 0 3px 0 rgba(0,0,0,.5); } }
.mk.nav { background: rgba(179, 80, 46, .92); padding: 6px 11px; }
.mk.nav .mk-lb { font-size: 11px; }
#map.pagefade { animation: pgfade .35s ease-out; }
@keyframes pgfade { from { opacity: .12; } }

/* ── 행인·주인공 — 머리·몸·다리 폭이 다른 실루엣 ── */
.mk { z-index: 4; }
.walker {
  position: absolute; width: 22px; height: 26px; z-index: 2;
  transform: translate(-50%, -100%); cursor: pointer;
}
.walker-px {
  position: absolute; left: 50%; bottom: 0; width: 8px; height: 11px;
  transform: translateX(-50%); pointer-events: none;
  background:
    linear-gradient(#e8c39a, #e8c39a) 50% 0 / 4px 3px no-repeat,
    linear-gradient(var(--pc, #c94f4f), var(--pc, #c94f4f)) 50% 3px / 6px 5px no-repeat,
    linear-gradient(#2a2233, #2a2233) 50% 8px / 4px 3px no-repeat;
  filter: drop-shadow(0 1px 0 rgba(0, 0, 0, .4));
  animation: bob .55s steps(2) infinite;
}
.bubble {
  position: absolute; z-index: 6; pointer-events: none;
  transform: translate(-50%, calc(-100% - 20px));
  background: rgba(16, 11, 34, .94); border: 2px solid #0e0a1e; border-radius: 9px;
  padding: 5px 9px; font-size: 10px; line-height: 1.4; max-width: 150px; width: max-content;
  color: #f3ead8; opacity: 1; transition: opacity .45s;
  animation: pop .15s ease-out;
}
.bubble.out { opacity: 0; }
.loc-line { color: #ffd76a; font-style: normal; display: block; margin-top: 3px; }
.hero {
  position: absolute; width: 9px; height: 14px; z-index: 3; pointer-events: none;
  transform: translate(-50%, -100%);
  background:
    linear-gradient(#2b2320, #2b2320) 50% 0 / 5px 3px no-repeat,
    linear-gradient(#e8c39a, #e8c39a) 50% 3px / 5px 3px no-repeat,
    linear-gradient(#d9b98c, #d9b98c) 50% 6px / 7px 5px no-repeat,
    linear-gradient(#2a2233, #2a2233) 50% 11px / 4px 3px no-repeat;
  filter: drop-shadow(0 0 3px rgba(255, 215, 106, .9)) drop-shadow(0 1px 0 rgba(0, 0, 0, .4));
}
.hero.go { animation: bob .3s steps(2) infinite; }
@keyframes bob { 50% { margin-top: -1px; } }
#walk-catch {
  position: absolute; inset: 0; z-index: 5; background: transparent;
  display: flex; align-items: flex-end; justify-content: center; padding-bottom: 14px;
}
#walk-catch span {
  background: rgba(14, 10, 30, .88); border: 2px solid #0e0a1e; border-radius: 9px;
  padding: 6px 11px; font-size: 11px; color: #cdbfa4;
}

/* ── 하단 정보 ── */
#piece-bar { padding: 7px 12px 0; font-size: 12px; color: #cdbfa4; background: #241b42; border-top: 3px solid #0e0a1e; }
#piece-bar b { color: #ffd76a; }
#stats { padding: 4px 12px 6px; background: #241b42; display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.stat { display: flex; align-items: center; gap: 6px; font-size: 11px; padding: 1px 0; }
.sl { width: 52px; color: #cdbfa4; }
.sv { width: 26px; text-align: right; }
.sbar { flex: 1; height: 8px; background: #131022; border: 1px solid #0e0a1e; border-radius: 4px; overflow: hidden; display: inline-block; }
.sbar i { display: block; height: 100%; background: #7ec8ff; transition: width .4s; }
.sbar i.good { background: #79d97c; }
.sbar i.warn { background: #e08a5a; }
.sbar.wide { width: 90px; height: 9px; vertical-align: middle; }
#piece-bar .sbar i { background: #ffd76a; }
.stat-foot { grid-column: 1 / -1; font-size: 11px; color: #8d7fb5; padding-top: 2px; }
#log { padding: 5px 12px calc(7px + env(safe-area-inset-bottom)); font-size: 11px; color: #8d7fb5; background: #241b42; min-height: 26px; }

/* ── 바텀시트 ── */
#sheet { position: absolute; inset: 0; z-index: 30; }
#sheet-bd { position: absolute; inset: 0; background: rgba(10, 6, 24, .6); }
#sheet-card {
  position: absolute; left: 0; right: 0; bottom: 0; max-height: 78%;
  background: #241b42; border-top: 4px solid #0e0a1e; border-radius: 18px 18px 0 0;
  overflow-y: auto; padding-bottom: calc(14px + env(safe-area-inset-bottom));
  animation: rise .22s ease-out;
}
@keyframes rise { from { transform: translateY(40%); } }
#sheet-img { width: 100%; height: 150px; object-fit: cover; display: block; border-radius: 14px 14px 0 0; }
#sheet-card .x { position: absolute; top: 10px; right: 10px; width: 34px; height: 34px; border-radius: 50%; border: 2px solid #0e0a1e; background: rgba(20,14,40,.85); cursor: pointer; }
#sheet-title { padding: 10px 16px 0; font-size: 19px; color: #ffd76a; }
#sheet-desc { padding: 0 16px; font-size: 12px; color: #cdbfa4; }
#sheet-actions { padding: 8px 16px 4px; }
.sheet-note { font-size: 11px; color: #8d7fb5; padding: 4px 2px; }

/* ── 모달 ── */
#modal { position: absolute; inset: 0; z-index: 40; background: rgba(10, 6, 24, .72); display: flex; align-items: center; padding: 20px; }
.m-card { width: 100%; max-height: 92%; overflow-y: auto; background: #241b42; border: 4px solid #0e0a1e; border-radius: 14px; box-shadow: 0 8px 0 rgba(0,0,0,.4); animation: pop .18s ease-out; }
@keyframes pop { from { transform: scale(.92); opacity: .4; } }
#m-img { width: 100%; height: 160px; object-fit: cover; display: block; }
#m-title { padding: 10px 16px 0; color: #ffd76a; font-size: 18px; }
#m-text { padding: 8px 16px; font-size: 14px; }
#m-notes { padding: 0 16px; }
.chip { display: inline-block; font-size: 11px; border: 2px solid #0e0a1e; border-radius: 8px; padding: 2px 7px; margin: 2px 3px 2px 0; background: #131022; }
.chip.up { color: #79d97c; }
.chip.down { color: #e08a8a; }
#m-actions { padding: 8px 16px 14px; }

/* ── 콩쿨 / 엔딩 ── */
#comp { position: absolute; inset: 0; z-index: 50; background: #0b0718; }
#comp-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.comp-veil { position: absolute; inset: 0; background: radial-gradient(circle at 50% 30%, rgba(10,6,20,.1), rgba(10,6,20,.9) 75%); }
.comp-inner { position: relative; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; padding: 24px; padding-bottom: calc(26px + env(safe-area-inset-bottom)); text-align: center; }
#comp-title { font-size: 26px; color: #ffd76a; text-shadow: 0 3px 0 #000; }
#comp-sub { font-size: 13px; color: #cdbfa4; margin-bottom: 10px; }
#comp-stage { min-height: 120px; display: flex; flex-direction: column; justify-content: center; gap: 4px; }
.perform { font-size: 20px; letter-spacing: 6px; animation: blink 1.4s infinite; }
@keyframes blink { 50% { opacity: .35; } }
.rank { font-size: 44px; text-shadow: 0 4px 0 #000; }
.rank.win { color: #ffd76a; }
.rank.lose { color: #8d7fb5; }
.score { font-size: 13px; color: #cdbfa4; }
.end-face { width: 110px; height: 110px; object-fit: cover; border-radius: 12px; border: 3px solid #0e0a1e; margin: 0 auto 8px; }
.end-text { font-size: 14px; }
.end-stats { font-size: 12px; color: #cdbfa4; margin-top: 8px; }
#comp-btns { max-width: 300px; margin: 12px auto 0; width: 100%; }

/* ── 토스트 ── */
#toast {
  position: absolute; left: 16px; right: 16px; bottom: calc(96px + env(safe-area-inset-bottom));
  z-index: 60; background: rgba(14, 10, 30, .94); border: 2px solid #0e0a1e; border-radius: 10px;
  padding: 10px 14px; font-size: 13px; text-align: center;
  opacity: 0; transform: translateY(8px); transition: all .25s; pointer-events: none;
}
#toast.on { opacity: 1; transform: none; }

@media (min-width: 521px) {
  #app { border-left: 4px solid #0e0a1e; border-right: 4px solid #0e0a1e; }
}

/* ── 가로모드(태블릿·PC): 지도 왼쪽 + 상태 패널 오른쪽 ── */
@media (orientation: landscape) and (min-width: 640px) {
  #app { max-width: none; border: none; }
  #scr-game { display: grid; grid-template-columns: minmax(0, 1fr) 340px;
    grid-template-rows: auto auto auto minmax(0, 1fr); }
  #hud { grid-column: 1 / -1; grid-row: 1; }
  #map-wrap { grid-column: 1; grid-row: 2 / 5; }
  #piece-bar { grid-column: 2; grid-row: 2; border-top: none; border-left: 3px solid #0e0a1e; }
  #stats { grid-column: 2; grid-row: 3; border-left: 3px solid #0e0a1e;
    grid-template-columns: 1fr; }
  #log { grid-column: 2; grid-row: 4; border-left: 3px solid #0e0a1e; }
  #sheet-card { max-width: 520px; margin: 0 auto; border-left: 4px solid #0e0a1e; border-right: 4px solid #0e0a1e; }
  .m-card { max-width: 520px; margin: auto; }
  .btns { max-width: 300px; }
}
