:root { --ink: #e8ecf6; --dim: #9aa6c0; --gold: #ffc94a; --red: #ff4a3a; --panel: rgba(12, 16, 30, 0.88); --line: rgba(160, 180, 230, 0.18); --acc: #5fd4ff; }
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #05070f; color: var(--ink); font-family: system-ui, -apple-system, 'Segoe UI', 'Apple SD Gothic Neo', 'Malgun Gothic', sans-serif; }
canvas#gl { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
.hidden { display: none !important; }
.dim { color: var(--dim); } .small { font-size: 12px; }
.home-btn { position: fixed; left: 12px; top: 12px; z-index: 50; padding: 7px 12px; border-radius: 10px; background: rgba(10, 14, 28, 0.7); color: var(--ink); text-decoration: none; font-size: 14px; border: 1px solid var(--line); backdrop-filter: blur(6px); }
.home-btn:hover { background: rgba(30, 40, 70, 0.8); }
body.playing .home-btn { display: none; }

/* 화면 */
.screen { position: fixed; inset: 0; z-index: 40; display: flex; align-items: center; justify-content: center; padding: 56px 14px 14px; overflow-y: auto; background: radial-gradient(ellipse at 50% 120%, rgba(5, 7, 15, 0.2), rgba(5, 7, 15, 0.75)); }
#loading { background: #05070f; }
.panel { width: min(640px, 100%); max-height: 100%; overflow-y: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 20px; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5); backdrop-filter: blur(8px); }
.panel.wide { width: min(980px, 100%); }
.panel.center { text-align: center; }
.head { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.head h2 { margin: 0; flex: 1; }
.money { color: var(--gold); font-weight: 700; }
.logo { font-size: 30px; margin: 4px 0 8px; letter-spacing: 0.02em; background: linear-gradient(180deg, #fff, #ffd27a 60%, #ff8a3a); -webkit-background-clip: text; background-clip: text; color: transparent; text-shadow: 0 0 30px rgba(255, 160, 60, 0.25); }
.logo.big { font-size: clamp(40px, 9vw, 76px); margin: 0 0 10px; }
.title-wrap { text-align: center; max-width: 720px; }
.eyebrow { color: var(--acc); font-weight: 700; letter-spacing: 0.08em; margin: 0; font-size: 13px; }
.sub { color: #c7d0e6; font-size: 16px; line-height: 1.6; margin: 0 auto 14px; max-width: 560px; text-shadow: 0 2px 8px #000; }
.money-line { color: var(--dim); margin-bottom: 16px; } .money-line b { color: var(--gold); }
.menu { display: flex; flex-direction: column; gap: 10px; align-items: center; margin-top: 12px; }
.menu.row-btns { flex-direction: row; flex-wrap: wrap; justify-content: center; }
.btn { appearance: none; border: 1px solid var(--line); background: rgba(40, 52, 90, 0.75); color: var(--ink); padding: 11px 22px; border-radius: 12px; font-size: 16px; font-weight: 600; cursor: pointer; min-width: 220px; text-decoration: none; font-family: inherit; }
.menu.row-btns .btn { min-width: 140px; }
.btn:hover { background: rgba(60, 78, 130, 0.9); }
.btn.primary { background: linear-gradient(180deg, #ffb347, #ff7a2a); color: #241000; border: none; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.sm { min-width: 0; padding: 6px 12px; font-size: 14px; }
.btn:disabled { opacity: 0.45; cursor: default; }
.bar { height: 8px; background: rgba(255, 255, 255, 0.08); border-radius: 6px; overflow: hidden; margin-top: 12px; }
#load-bar { height: 100%; width: 0; background: linear-gradient(90deg, #ff8a3a, #ffd27a); transition: width 0.2s; }

/* 미션 카드 */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.card { position: relative; border: 1px solid var(--line); border-radius: 14px; padding: 14px; background: linear-gradient(160deg, rgba(50, 62, 110, 0.6), rgba(20, 26, 48, 0.8)); cursor: pointer; text-align: left; color: inherit; font: inherit; }
.card:hover { border-color: rgba(255, 200, 100, 0.6); }
.card.sel { border-color: var(--gold); box-shadow: 0 0 0 2px rgba(255, 200, 80, 0.3); }
.card.locked { opacity: 0.5; cursor: default; }
.card .em { font-size: 34px; }
.card h3 { margin: 6px 0 2px; font-size: 17px; }
.card .meta { color: var(--dim); font-size: 13px; }
.card .st { color: var(--gold); letter-spacing: 2px; margin-top: 6px; }
.card .lock { position: absolute; right: 12px; top: 10px; font-size: 20px; }
.brief { margin-top: 14px; border-top: 1px solid var(--line); padding-top: 14px; }
.brief h3 { margin: 0 0 6px; }
.brief p { margin: 6px 0; line-height: 1.55; color: #cfd6ea; }
.brief .tip { color: #a6e3ff; }
.tlist { list-style: none; padding: 0; margin: 8px 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 4px 12px; }
.tlist li { font-size: 14px; }
.tag { display: inline-block; font-size: 11px; padding: 1px 6px; border-radius: 6px; margin-left: 4px; background: rgba(255, 255, 255, 0.1); }
.tag.req { background: rgba(255, 200, 70, 0.25); color: var(--gold); }
.tag.al { background: rgba(255, 70, 60, 0.25); color: #ff8a80; }
.brief .go { display: flex; justify-content: flex-end; margin-top: 10px; }

/* 상점 */
.upg { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.upg .ic { font-size: 28px; width: 40px; text-align: center; }
.upg .info { flex: 1; }
.upg .info b { display: block; }
.upg .pips { color: var(--gold); letter-spacing: 3px; font-size: 13px; }
.upg .desc { color: var(--dim); font-size: 13px; }
.upg .btn { min-width: 110px; }

.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.row.chk { justify-content: flex-start; }
.row select, .row input[type=range] { width: 180px; }
select { background: #1a2240; color: var(--ink); border: 1px solid var(--line); border-radius: 8px; padding: 6px; font: inherit; }
.help-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.help-grid h3 { margin: 6px 0; color: var(--acc); font-size: 15px; }
.help-grid ul { margin: 0 0 10px; padding-left: 18px; line-height: 1.6; font-size: 14px; color: #cfd6ea; }
.stars { font-size: 40px; color: var(--gold); letter-spacing: 6px; margin: 4px 0 10px; text-shadow: 0 0 18px rgba(255, 200, 60, 0.5); }
.stars .off, .card .st .off { color: rgba(255, 255, 255, 0.18); text-shadow: none; }
#res-body { text-align: left; margin: 0 auto; max-width: 420px; line-height: 1.7; }
#res-body .pay { font-size: 22px; color: var(--gold); font-weight: 800; text-align: center; margin: 8px 0; }

/* HUD */
#hud { position: fixed; inset: 0; z-index: 20; pointer-events: none; }
#vignette { position: absolute; inset: 0; box-shadow: inset 0 0 160px rgba(0, 0, 0, 0.6); transition: box-shadow 0.3s; }
#vignette.alarm { animation: alarmPulse 0.9s infinite; }
@keyframes alarmPulse { 0%, 100% { box-shadow: inset 0 0 160px rgba(255, 20, 10, 0.55); } 50% { box-shadow: inset 0 0 90px rgba(255, 20, 10, 0.2); } }
#crosshair { position: absolute; left: 50%; top: 50%; width: 22px; height: 22px; transform: translate(-50%, -50%); }
#crosshair i { position: absolute; left: 50%; top: 50%; width: 4px; height: 4px; margin: -2px; border-radius: 50%; background: #fff; box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.6); }
#crosshair.focus i { width: 10px; height: 10px; margin: -5px; background: transparent; border: 2px solid var(--gold); }
#grab-ring { position: absolute; left: 50%; top: 50%; width: 46px; height: 46px; transform: translate(-50%, -50%) rotate(-90deg); }
#grab-ring circle { fill: none; stroke: var(--gold); stroke-width: 4; stroke-dasharray: 100.5; stroke-dashoffset: 100.5; }
#prompt { position: absolute; left: 50%; top: calc(50% + 34px); transform: translateX(-50%); font-size: 15px; text-shadow: 0 2px 6px #000; white-space: nowrap; font-weight: 600; }
#prompt .req { color: var(--gold); } #prompt .al { color: #ff8a80; }
#phase { position: absolute; top: 12px; left: 50%; transform: translateX(-50%); text-align: center; }
#phase-label { font-size: 13px; padding: 4px 12px; border-radius: 10px; background: rgba(10, 14, 28, 0.6); color: #b8f0c8; }
#phase.alarm #phase-label { color: #fff; background: rgba(200, 20, 10, 0.75); }
#timer { font-size: 44px; font-weight: 900; color: #fff; text-shadow: 0 0 18px rgba(255, 40, 20, 0.9), 0 2px 4px #000; font-variant-numeric: tabular-nums; }
#timer.low { color: #ff5a4a; animation: blink 0.5s infinite; }
@keyframes blink { 50% { opacity: 0.6; } }
#detect { position: absolute; top: 64px; left: 50%; transform: translateX(-50%); width: 160px; height: 16px; border-radius: 8px; background: rgba(0, 0, 0, 0.5); overflow: hidden; border: 1px solid rgba(255, 200, 80, 0.5); }
#detect-fill { height: 100%; width: 0; background: linear-gradient(90deg, #ffcf4a, #ff3a2a); }
#detect span { position: absolute; inset: 0; text-align: center; font-size: 11px; line-height: 16px; font-weight: 700; }
#objectives { position: absolute; left: 12px; top: 12px; background: rgba(10, 14, 28, 0.55); border-radius: 12px; padding: 8px 12px; font-size: 13px; line-height: 1.6; max-width: 46vw; }
#objectives h4 { margin: 0 0 2px; font-size: 13px; color: var(--acc); }
#objectives .done { color: #7fe09a; text-decoration: line-through; opacity: 0.7; }
#objectives .req { color: var(--gold); }
#toolbar { position: absolute; bottom: 14px; left: 50%; transform: translateX(-50%); display: flex; gap: 8px; }
.slot { width: 74px; padding: 6px 4px; border-radius: 12px; background: rgba(10, 14, 28, 0.6); border: 2px solid transparent; text-align: center; font-size: 12px; }
.slot .ic { font-size: 22px; display: block; }
.slot.on { border-color: var(--gold); background: rgba(60, 50, 20, 0.6); }
.slot .k { position: absolute; margin: -4px 0 0 -4px; font-size: 10px; color: var(--dim); }
.slot .fuel { height: 4px; border-radius: 2px; background: rgba(255, 255, 255, 0.15); margin-top: 3px; overflow: hidden; }
.slot .fuel i { display: block; height: 100%; background: #6cc8ff; }
#toasts { position: absolute; left: 50%; bottom: 100px; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 6px; width: min(92vw, 640px); }
.toast { background: rgba(10, 14, 28, 0.78); padding: 7px 14px; border-radius: 10px; font-size: 14px; text-align: center; animation: toastIn 0.2s; }
@keyframes toastIn { from { opacity: 0; transform: translateY(8px); } }
#banner { position: absolute; top: 28%; left: 50%; transform: translateX(-50%); text-align: center; opacity: 0; transition: opacity 0.3s; width: 90vw; }
#banner.show { opacity: 1; }
#banner h2 { margin: 0; font-size: clamp(26px, 6vw, 46px); color: #ff5040; text-shadow: 0 0 24px rgba(255, 30, 10, 0.8), 0 3px 6px #000; }
#banner p { margin: 4px 0; font-size: 17px; text-shadow: 0 2px 6px #000; }
#markers { position: absolute; inset: 0; overflow: hidden; }
.mk { position: absolute; transform: translate(-50%, -100%); font-size: 11px; text-align: center; white-space: nowrap; text-shadow: 0 1px 3px #000; opacity: 0.9; }
.mk::before { content: ''; display: block; width: 10px; height: 10px; margin: 0 auto 2px; transform: rotate(45deg); border: 2px solid currentColor; }
.mk.req { color: var(--gold); } .mk.opt { color: #c8d4ee; } .mk.car { color: #6fffa0; }
.mk.edge::before { background: currentColor; }
#fps { position: absolute; right: 10px; bottom: 10px; font: 12px monospace; color: var(--dim); background: rgba(0, 0, 0, 0.4); padding: 3px 6px; border-radius: 6px; }
.hud-btn { pointer-events: auto; position: absolute; right: 12px; top: 12px; width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--line); background: rgba(10, 14, 28, 0.6); color: var(--ink); font-size: 18px; cursor: pointer; }

/* 터치 */
#touch { position: fixed; inset: 0; z-index: 25; pointer-events: none; }
#stick-base { position: absolute; width: 120px; height: 120px; margin: -60px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, 0.25); background: rgba(255, 255, 255, 0.06); left: 90px; bottom: 30px; display: none; }
#stick-base.on { display: block; }
#stick-knob { position: absolute; left: 50%; top: 50%; width: 52px; height: 52px; margin: -26px; border-radius: 50%; background: rgba(255, 255, 255, 0.35); }
.tbtns { position: absolute; right: 10px; bottom: 14px; display: grid; grid-template-columns: repeat(3, 64px); grid-template-rows: repeat(3, 56px); gap: 8px; pointer-events: none; }
.tb { white-space: nowrap; padding: 0 2px; pointer-events: auto; border-radius: 16px; border: 1px solid rgba(255, 255, 255, 0.25); background: rgba(20, 28, 50, 0.55); color: #fff; font: 600 13px system-ui, sans-serif; touch-action: none; user-select: none; -webkit-user-select: none; }
.tb.on { background: rgba(255, 170, 60, 0.6); }
.tb.big { grid-column: 2 / 4; grid-row: 3; font-size: 17px; background: rgba(255, 130, 40, 0.45); }
#tb-grab { grid-column: 1; grid-row: 3; }
.tb.sm { font-size: 18px; }
#tb-bomb.dim { opacity: 0.35; }
body.touch #toolbar { bottom: auto; top: 54px; left: auto; right: 10px; transform: none; flex-direction: column; gap: 4px; }
body.touch .slot { width: 64px; padding: 3px; font-size: 10px; }
body.touch .slot .ic { font-size: 18px; }
body.touch #objectives { font-size: 11px; max-width: 40vw; top: 40px; left: 8px; padding: 6px 9px; }
body.touch #toasts { bottom: 46%; }
body.touch #prompt { font-size: 13px; }
body.touch .hud-btn { top: 8px; right: 84px; }
@media (max-width: 720px) {
  .help-grid { grid-template-columns: 1fr; }
  .panel { padding: 14px; }
  .btn { min-width: 180px; padding: 10px 16px; font-size: 15px; }
  #timer { font-size: 34px; }
  .tbtns { grid-template-columns: repeat(3, 58px); grid-template-rows: repeat(3, 50px); gap: 6px; }
}
@media (max-height: 480px) {
  .tbtns { grid-template-rows: repeat(3, 44px); gap: 5px; }
  #objectives { display: none; }
  body.touch #toolbar { top: 6px; left: 8px; right: auto; flex-direction: row; }
  body.touch #phase { left: auto; right: 130px; transform: none; }
  #timer { font-size: 28px; }
}
