:root {
  --ink: #1c1f26;
  --ink-2: #5a6070;
  --paper: #fffdf8;
  --line: #e4ded2;
  --accent: #3b6fd8;
  --accent-2: #e0a526;
  --good: #2f9e5b;
  --bad: #d0453a;
  --shadow: 0 10px 30px rgba(20, 24, 33, .18);
  --radius: 16px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #c9d6e3; }
body { font-family: 'Pretendard Variable', Pretendard, -apple-system, 'Apple SD Gothic Neo', sans-serif; color: var(--ink); -webkit-font-smoothing: antialiased; }
button { font: inherit; cursor: pointer; border: 0; }
.hidden { display: none !important; }

#map { position: fixed; inset: 0; }
#tint { position: fixed; inset: 0; pointer-events: none; mix-blend-mode: multiply; transition: background 1.2s; z-index: 1; }
#weather { position: fixed; inset: 0; pointer-events: none; z-index: 2; width: 100%; height: 100%; }

/* HUD */
#hud { position: fixed; top: 12px; left: 12px; right: 12px; display: flex; justify-content: space-between; gap: 8px; z-index: 10; pointer-events: none; }
.card { background: rgba(255, 253, 248, .94); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 10px 14px; pointer-events: auto; backdrop-filter: blur(6px); }
.player { min-width: 230px; }
.player .row { display: flex; gap: 14px; font-size: 14px; color: var(--ink-2); }
.player b { color: var(--ink); }
.xpbar { height: 8px; background: #ece6da; border-radius: 99px; margin-top: 8px; overflow: hidden; }
.xpbar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--accent), #6c9cf0); transition: width .6s; }
.xptext { font-size: 11px; color: var(--ink-2); margin-top: 4px; }
.env { display: flex; gap: 6px; align-items: center; }
.env button { background: #f3efe6; border-radius: 10px; padding: 6px 10px; font-size: 13px; }
.env button:hover { background: #e9e3d6; }

#dock { position: fixed; bottom: 14px; left: 50%; transform: translateX(-50%); display: flex; gap: 6px; z-index: 10; background: rgba(255,253,248,.95); padding: 6px; border-radius: 99px; box-shadow: var(--shadow); border: 1px solid var(--line); }
#dock button { background: transparent; padding: 9px 14px; border-radius: 99px; font-size: 14px; white-space: nowrap; }
#dock button:hover, #dock button.on { background: var(--ink); color: #fff; }

#panel { position: fixed; top: 96px; right: 12px; bottom: 76px; width: min(380px, calc(100vw - 24px)); background: var(--paper); border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid var(--line); z-index: 11; display: flex; flex-direction: column; animation: slideIn .25s ease-out; }
.panel-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px 8px; }
.panel-head h2 { margin: 0; font-size: 18px; }
.panel-head button { background: none; font-size: 18px; color: var(--ink-2); }
#panelBody { overflow-y: auto; padding: 0 16px 16px; }
.chapter { margin: 10px 0 16px; }
.chapter h3 { font-size: 14px; margin: 0 0 6px; display: flex; justify-content: space-between; color: var(--ink-2); }
.place-row { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 12px; background: #f6f2ea; margin-bottom: 6px; cursor: pointer; }
.place-row:hover { background: #ece6da; }
.place-row .ic { font-size: 20px; width: 28px; text-align: center; }
.place-row .nm { flex: 1; font-weight: 600; font-size: 14px; }
.place-row .st { font-size: 12px; color: var(--ink-2); }
.place-row.done .st { color: var(--good); font-weight: 600; }
.atlas-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.kcard { border-radius: 12px; padding: 12px; background: linear-gradient(160deg, #fff, #f1ebdd); border: 1px solid var(--line); min-height: 96px; cursor: pointer; }
.kcard .ic { font-size: 24px; }
.kcard .t { font-weight: 700; font-size: 13px; margin-top: 6px; }
.kcard .p { font-size: 11px; color: var(--ink-2); }
.kcard.locked { background: #eee9df; color: #aaa; cursor: default; filter: grayscale(1); }
.stat { margin-bottom: 12px; }
.stat .lbl { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 4px; }
.stat .bar { height: 10px; background: #ece6da; border-radius: 99px; overflow: hidden; }
.stat .bar i { display: block; height: 100%; border-radius: 99px; }
.titles span { display: inline-block; background: #fff4d6; border: 1px solid #ecd28d; border-radius: 99px; padding: 4px 10px; font-size: 12px; margin: 0 4px 4px 0; }

/* map markers */
.lm { display: flex; flex-direction: column; align-items: center; cursor: pointer; transform-origin: bottom center; transition: transform .15s; }
.lm:hover { transform: scale(1.1); }
.lm .pin { width: 40px; height: 40px; border-radius: 50%; background: #fff; display: grid; place-items: center; font-size: 21px; box-shadow: 0 4px 14px rgba(0,0,0,.25); border: 3px solid var(--accent-2); position: relative; }
.lm.done .pin { border-color: var(--good); }
.lm.questless .pin { border-color: #9aa3b5; }
.lm .pin .badge { position: absolute; top: -6px; right: -6px; background: var(--accent-2); color: #fff; font-size: 11px; font-weight: 800; width: 18px; height: 18px; border-radius: 50%; display: grid; place-items: center; }
.lm.done .pin .badge { background: var(--good); }
.lm .label { margin-top: 4px; background: rgba(28,31,38,.82); color: #fff; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 99px; white-space: nowrap; }
.player-marker { font-size: 30px; filter: drop-shadow(0 4px 6px rgba(0,0,0,.35)); transition: transform .1s; }

/* travel */
#travelbar { position: fixed; bottom: 76px; left: 50%; transform: translateX(-50%); z-index: 10; background: rgba(28,31,38,.9); color: #fff; border-radius: 14px; padding: 10px 14px; display: flex; gap: 12px; align-items: center; min-width: 320px; box-shadow: var(--shadow); }
#travelText { font-size: 13px; white-space: nowrap; }
.tbar { flex: 1; height: 6px; background: rgba(255,255,255,.2); border-radius: 99px; overflow: hidden; min-width: 80px; }
.tbar i { display: block; height: 100%; width: 0; background: var(--accent-2); }
#btnSkip { background: rgba(255,255,255,.14); color: #fff; padding: 6px 10px; border-radius: 10px; font-size: 12px; }

#subway { position: fixed; inset: 0; z-index: 9; background: radial-gradient(ellipse at center, #2b3140 0%, #12151c 70%); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; }
.sw-window { width: min(560px, 80vw); height: 180px; border-radius: 28px; border: 10px solid #c9ced8; overflow: hidden; background: #0b0d12; box-shadow: inset 0 0 40px rgba(0,0,0,.8); }
.sw-tunnel { width: 300%; height: 100%; background: repeating-linear-gradient(90deg, #0b0d12 0 120px, #f2d27a 120px 128px, #0b0d12 128px 260px); animation: tunnel .5s linear infinite; opacity: .7; }
.sw-info { color: #fff; font-size: 16px; background: rgba(255,255,255,.08); padding: 10px 18px; border-radius: 99px; }
@keyframes tunnel { from { transform: translateX(0); } to { transform: translateX(-260px); } }

/* modal */
#modal { position: fixed; inset: 0; z-index: 20; background: rgba(15,18,25,.45); display: grid; place-items: center; padding: 16px; animation: fade .2s; }
#modalCard { width: min(560px, 100%); max-height: calc(100vh - 32px); overflow-y: auto; background: var(--paper); border-radius: 20px; box-shadow: 0 24px 60px rgba(0,0,0,.35); animation: pop .28s cubic-bezier(.2,1.3,.4,1); }
.m-head { padding: 18px 20px 6px; }
.m-kicker { font-size: 12px; font-weight: 700; color: var(--accent); letter-spacing: .04em; }
.m-title { font-size: 21px; font-weight: 800; margin: 4px 0 0; }
.m-body { padding: 10px 20px 20px; }
.m-actions { display: flex; gap: 8px; justify-content: flex-end; padding: 0 20px 20px; flex-wrap: wrap; }
.primary { background: var(--ink); color: #fff; padding: 11px 18px; border-radius: 12px; font-weight: 700; }
.primary:hover { background: #333846; }
.ghost { background: #efe9dd; color: var(--ink); padding: 11px 18px; border-radius: 12px; font-weight: 600; }

/* snippet slides */
.snip-stage { position: relative; height: 210px; border-radius: 16px; overflow: hidden; background: linear-gradient(135deg, #1e2a4a, #3b4f86); color: #fff; }
.snip-slide { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 18px 26px; opacity: 0; transform: translateX(40px); transition: all .5s; }
.snip-slide.on { opacity: 1; transform: none; }
.snip-slide.off { opacity: 0; transform: translateX(-40px); }
.snip-slide .ic { font-size: 54px; margin-bottom: 12px; animation: bob 2.4s ease-in-out infinite; font-weight: 800; }
.snip-slide .tx { font-size: 16px; line-height: 1.6; font-weight: 500; }
.snip-dots { display: flex; gap: 6px; justify-content: center; margin-top: 10px; }
.snip-dots i { width: 22px; height: 4px; border-radius: 99px; background: #ddd5c4; overflow: hidden; position: relative; }
.snip-dots i.done { background: var(--accent); }
.snip-dots i.cur::after { content: ''; position: absolute; inset: 0; background: var(--accent); animation: fill var(--dur, 5s) linear forwards; transform-origin: left; }
@keyframes fill { from { transform: scaleX(0); } to { transform: scaleX(1); } }

/* NPC + quiz */
.npc { display: flex; gap: 14px; align-items: flex-start; }
.portrait { width: 76px; height: 76px; border-radius: 20px; display: grid; place-items: center; font-size: 42px; flex-shrink: 0; box-shadow: inset 0 -8px 0 rgba(0,0,0,.12); }
.portrait.svg { overflow: hidden; padding: 0; box-shadow: 0 4px 12px rgba(0,0,0,.12); }
.portrait.svg svg { width: 100%; height: 100%; display: block; }
.big-ic svg { border-radius: 24px; box-shadow: 0 8px 20px rgba(0,0,0,.15); }
.npc-name { font-weight: 800; font-size: 16px; }
.npc-role { font-size: 12px; color: var(--ink-2); margin-bottom: 6px; }
.bubble { background: #fff; border: 1px solid var(--line); border-radius: 4px 14px 14px 14px; padding: 10px 12px; font-size: 15px; line-height: 1.55; min-height: 46px; }
.qmeta { display: flex; gap: 6px; margin: 14px 0 8px; font-size: 12px; }
.chip { background: #efe9dd; padding: 3px 9px; border-radius: 99px; font-weight: 600; }
.chip.tier { background: #e5edfb; color: var(--accent); }
.qtext { font-size: 17px; font-weight: 700; line-height: 1.5; margin-bottom: 12px; }
.choices { display: grid; gap: 8px; }
.choice { text-align: left; background: #fff; border: 2px solid var(--line); padding: 12px 14px; border-radius: 12px; font-size: 15px; transition: all .15s; }
.choice:hover:not(:disabled) { border-color: var(--accent); background: #f4f8ff; }
.choice.right { border-color: var(--good); background: #eaf7ef; }
.choice.wrong { border-color: var(--bad); background: #fdeceb; }
.choice:disabled { cursor: default; color: var(--ink); }
.explain { margin-top: 12px; padding: 12px 14px; border-radius: 12px; background: #f6f2ea; font-size: 14px; line-height: 1.6; animation: fade .3s; }
.explain b.ok { color: var(--good); } .explain b.ng { color: var(--bad); }
.report { background: none; color: var(--ink-2); font-size: 12px; text-decoration: underline; padding: 0; margin-top: 8px; }
.reward { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 12px; }
.reward div { background: #f6f2ea; border-radius: 12px; padding: 10px; text-align: center; font-size: 12px; color: var(--ink-2); }
.reward b { display: block; font-size: 18px; color: var(--ink); }
.big-ic { font-size: 56px; text-align: center; animation: pop .5s; }

/* travel picker */
.tp { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.tp button { background: #fff; border: 2px solid var(--line); border-radius: 14px; padding: 12px; text-align: left; }
.tp button:hover:not(:disabled) { border-color: var(--accent); }
.tp button:disabled { opacity: .45; cursor: not-allowed; }
.tp .ti { font-size: 24px; }
.tp .tn { font-weight: 800; font-size: 15px; }
.tp .td { font-size: 12px; color: var(--ink-2); margin-top: 2px; line-height: 1.4; }
.tp .tc { font-size: 12px; font-weight: 700; margin-top: 6px; }

/* title */
#title { position: fixed; inset: 0; z-index: 30; display: grid; place-items: center; background: linear-gradient(180deg, rgba(14,20,36,.55), rgba(14,20,36,.85)); color: #fff; text-align: center; padding: 20px; }
.title-inner { animation: rise .8s ease-out; }
.eyebrow { letter-spacing: .3em; font-size: 12px; opacity: .7; margin: 0; }
#title h1 { font-size: clamp(32px, 7vw, 56px); margin: 10px 0 6px; font-weight: 900; }
#title .sub { opacity: .85; margin: 0 0 28px; font-size: 17px; }
.big { font-size: 18px; padding: 14px 28px; background: var(--accent-2); color: #1c1f26; }
.big:hover { background: #f0b83a; }
#btnContinue { display: block; margin: 12px auto 0; background: rgba(255,255,255,.12); color: #fff; }
.note { font-size: 11px; opacity: .55; margin-top: 30px; }
.caption { position: fixed; top: 22%; left: 50%; transform: translateX(-50%); z-index: 12; background: rgba(14,20,36,.78); color: #fff; padding: 12px 20px; border-radius: 14px; font-size: 16px; text-align: center; animation: fade .5s; max-width: calc(100vw - 32px); }

#toast { position: fixed; top: 92px; left: 50%; transform: translateX(-50%) translateY(-20px); z-index: 25; background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 12px; font-size: 14px; opacity: 0; transition: all .3s; pointer-events: none; max-width: calc(100vw - 32px); text-align: center; }
#toast.on { opacity: 1; transform: translateX(-50%); }

@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: scale(.92); } }
@keyframes rise { from { opacity: 0; transform: translateY(20px); } }
@keyframes slideIn { from { opacity: 0; transform: translateX(20px); } }
@keyframes bob { 50% { transform: translateY(-6px); } }

@media (max-width: 640px) {
  #hud { flex-direction: column; align-items: stretch; }
  .player { min-width: 0; }
  .env { justify-content: space-between; }
  #panel { top: auto; height: 60vh; bottom: 70px; }
  #dock button { padding: 8px 10px; font-size: 13px; }
  .snip-stage { height: 230px; }
  #toast { top: auto; bottom: 84px; }
  #toast.on { transform: translateX(-50%); }
}
