* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: #000; overflow: hidden; font-family: 'Gowun Dodum', 'Malgun Gothic', 'Apple SD Gothic Neo', sans-serif; color: #ece4cc; }
#stage { position: absolute; left: 50%; top: 50%; width: 960px; height: 540px; transform-origin: center; }
#game { display: block; width: 960px; height: 540px; cursor: crosshair; }
#ui { position: absolute; inset: 0; pointer-events: none; }
#ui > * { pointer-events: auto; }
h2, h3, .speaker { font-family: 'Black Han Sans', 'Malgun Gothic', sans-serif; font-weight: normal; letter-spacing: 0.5px; }

/* ── 버튼: 낡은 군용 장비 느낌 ── */
.btn {
  font: inherit; font-size: 15px; padding: 9px 18px; border-radius: 4px; cursor: pointer;
  color: #ece4cc; text-shadow: 0 1px 0 rgba(0,0,0,0.6);
  background: linear-gradient(#45472f, #2b2c1d);
  border: 1px solid #77704e; border-bottom-color: #3a3726;
  box-shadow: 0 2px 0 #14140c, inset 0 1px 0 rgba(255,250,220,0.12);
  transition: transform 0.05s, filter 0.1s;
}
.btn:hover { filter: brightness(1.18); }
.btn:active { transform: translateY(2px); box-shadow: 0 0 0 #14140c, inset 0 1px 0 rgba(255,250,220,0.12); }
.btn.primary {
  color: #2a1a08; text-shadow: 0 1px 0 rgba(255,230,170,0.5); font-weight: bold;
  background: linear-gradient(#e6b75a, #b07c2c); border-color: #f0cd80; border-bottom-color: #7a5218;
  box-shadow: 0 2px 0 #4a3010, inset 0 1px 0 rgba(255,255,230,0.5);
}
.btn.small { font-size: 12px; padding: 4px 10px; }

.btn-row { position: absolute; left: 0; right: 0; display: flex; justify-content: center; gap: 12px; pointer-events: none !important; }
.btn-row .btn { pointer-events: auto; min-width: 120px; }

.hud-buttons { position: absolute; right: 16px; bottom: 14px; display: flex; gap: 8px; }
.hud-buttons .btn { font-size: 13px; padding: 6px 12px; background: linear-gradient(rgba(60,62,42,0.92), rgba(30,31,20,0.92)); }

/* ── 무전: 초록 CRT 화면 ── */
.dialog {
  position: absolute; left: 60px; right: 60px; bottom: 22px; min-height: 116px; cursor: pointer;
  padding: 14px 22px 22px; border-radius: 10px;
  background:
    repeating-linear-gradient(0deg, rgba(0,0,0,0.22) 0 2px, rgba(0,0,0,0) 2px 4px),
    radial-gradient(ellipse at 50% 40%, #12261a, #060c08 75%);
  border: 3px solid #2c2f24; outline: 2px solid #55573f; outline-offset: -1px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.7), inset 0 0 40px rgba(80,255,120,0.08);
  color: #b9f5b4; text-shadow: 0 0 6px rgba(120,255,140,0.45);
  animation: flicker 4s infinite;
}
.dialog .speaker { color: #7fea7a; font-size: 15px; margin-bottom: 6px; }
.dialog .line { font-size: 18px; line-height: 1.6; }
.dialog .next { position: absolute; right: 18px; bottom: 8px; font-size: 12px; color: #5fa85a; animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0; } }
@keyframes flicker { 0%, 96%, 100% { filter: none; } 97% { filter: brightness(1.25); } 98% { filter: brightness(0.85); } }

/* ── 모달 ── */
.modal-back { position: absolute; inset: 0; background: rgba(0,0,0,0.6); display: flex; align-items: center; justify-content: center; }
.modal {
  position: relative; min-width: 400px; max-width: 640px; max-height: 500px; overflow-y: auto; padding: 20px 28px 18px; border-radius: 6px;
  background: linear-gradient(#2a2a1e, #18180f); border: 2px solid #6b6448;
  box-shadow: 0 16px 40px rgba(0,0,0,0.75), inset 0 0 0 1px rgba(255,240,200,0.06);
}
.modal h2 { margin: 0 0 10px; color: #f0c870; font-size: 24px; }
.modal p { line-height: 1.65; }
.modal label { display: block; margin: 12px 0; }
.modal input[type=range] { width: 100%; accent-color: #d6a648; }
.modal small { color: #a8a088; }
.modal-buttons { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; }
/* 주운 쪽지는 누런 종이 */
.modal.paper {
  color: #2e2414; font-size: 16px;
  background:
    repeating-linear-gradient(0deg, rgba(90,70,40,0.12) 0 1px, rgba(0,0,0,0) 1px 28px),
    radial-gradient(ellipse at 30% 20%, #f3e7c8, #d9c595 85%);
  border: none; transform: rotate(-0.6deg);
  box-shadow: 0 18px 40px rgba(0,0,0,0.8), inset 0 0 50px rgba(120,80,30,0.35);
}
.modal.paper h2 { color: #5a2a14; }
.modal.paper small { color: #6a5838; }
.modal.paper::before { content: ''; position: absolute; left: 50%; top: -6px; width: 110px; height: 26px; margin-left: -55px; background: rgba(230,220,180,0.75); transform: rotate(2deg); box-shadow: 0 1px 3px rgba(0,0,0,0.3); }
.pol1 { color: #9ccc65; } .pol2 { color: #ffb74d; } .pol3 { color: #ef7a6a; }
.no { color: #ef8a7a; } .ok { color: #9ccc65; }
.upg { border-top: 1px dashed #4a4636; padding: 10px 0; }
.upg.owned { opacity: 0.6; }
.upg .btn { float: right; }
.modal h3 { margin: 16px 0 4px; color: #d8c890; font-size: 15px; border-bottom: 1px solid #4a4636; padding-bottom: 3px; }
.tier { font-size: 11px; padding: 1px 7px; border-radius: 3px; margin-right: 4px; font-weight: normal; font-family: 'Gowun Dodum', sans-serif; }
.tier.t0 { background: #5a554a; } .tier.t1 { background: #4a6a3a; } .tier.t2 { background: #3e5a6e; } .tier.t3 { background: #6e3a6a; } .tier.t4 { background: #9a7418; color: #fff6d0; }
.gear-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 12px; }
.gear-sel { display: flex !important; flex-direction: column; margin: 0 !important; font-size: 12px; color: #a8a088; }
.gear-sel select { font: inherit; font-size: 13px; background: #1a1a12; color: #ece4cc; border: 1px solid #6b6448; border-radius: 3px; padding: 4px; margin-top: 2px; }

/* ── 패널 (캠프, 파밍) ── */
.panel {
  position: absolute; padding: 18px 24px; border-radius: 6px;
  background: linear-gradient(rgba(36,35,25,0.94), rgba(18,17,12,0.94));
  border: 2px solid #5f5a42; box-shadow: 0 12px 34px rgba(0,0,0,0.65), inset 0 0 0 1px rgba(255,240,200,0.05);
}
.panel::before { content: ''; position: absolute; left: 24px; top: -9px; width: 90px; height: 20px; background: rgba(220,205,150,0.45); transform: rotate(-3deg); }
.panel h2 { margin: 0 0 8px; color: #f0c870; font-size: 24px; }
.panel h2 small { font-size: 13px; color: #a8a088; margin-left: 8px; font-family: 'Gowun Dodum', sans-serif; }
.panel h3 { margin: 14px 0 6px; font-size: 14px; color: #c9bf9a; }
.camp { left: 30px; top: 30px; width: 540px; max-height: 480px; overflow-y: auto; }
.camp .stats { font-size: 14px; line-height: 1.7; color: #d0c8ae; }
.chip { display: inline-block; background: #2b4248; border: 1px solid #4a6a72; border-radius: 3px; padding: 3px 10px; margin: 2px; font-size: 13px; }
.chip.mat { background: #3e3522; border-color: #6b5a3a; }
.camp-buttons { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }

.scav { left: 30px; top: 30px; width: 480px; max-height: 480px; overflow-y: auto; }
.scav .stats { font-size: 13px; color: #c8bfa4; line-height: 1.6; }
.zone-list { margin: 10px 0; }
.zone { display: flex; justify-content: space-between; align-items: center; padding: 8px 4px; border-top: 1px dashed #4a4636; }
.zone small { color: #8a8470; margin-left: 6px; }
.zone .final { color: #ef7a6a; }
.scav-log { font-size: 13px; color: #c8bfa4; min-height: 60px; }
.scav-log div { padding: 2px 0; }
.scav-log div:first-child { color: #fff4d6; }

.map-tip { position: absolute; left: 50%; transform: translateX(-50%); background: rgba(0,0,0,0.6); padding: 6px 14px; border-radius: 14px; font-size: 14px; pointer-events: none !important; }

/* ── 도감: 낡은 현장 노트 ── */
.dex {
  inset: 14px; display: grid; grid-template-columns: minmax(0, 1fr) 340px; grid-template-rows: auto 1fr auto; gap: 8px 16px;
  color: #2e2414; border: none; border-radius: 4px;
  background:
    linear-gradient(90deg, rgba(0,0,0,0) 0 calc(100% - 362px), rgba(120,80,40,0.25) calc(100% - 362px) calc(100% - 358px), rgba(0,0,0,0) calc(100% - 358px)),
    repeating-linear-gradient(0deg, rgba(90,70,40,0.1) 0 1px, rgba(0,0,0,0) 1px 26px),
    radial-gradient(ellipse at 40% 30%, #efe2c0, #d2bd8c 90%);
  box-shadow: 0 14px 40px rgba(0,0,0,0.8), inset 0 0 60px rgba(110,70,30,0.35);
}
.dex::before { background: rgba(200,190,150,0.6); }
.dex h2 { color: #4a2410; }
.dex h2 small { color: #7a6440; }
.dex-head { grid-column: 1 / 3; display: flex; justify-content: space-between; align-items: center; border-bottom: 2px solid rgba(90,60,30,0.4); padding-bottom: 4px; }
.dex-head h2 { margin: 0; }
.tabs { display: flex; gap: 6px; }
.dex-grid { min-width: 0; min-height: 0; display: flex; flex-wrap: wrap; gap: 8px; overflow-y: auto; overflow-x: hidden; align-content: flex-start; padding: 6px; }
.dex-grid .dex-card { width: calc(20% - 7px); flex: none; }
.dex-card {
  position: relative; background: #fbf5e4; border: 1px solid #c8b488; border-radius: 2px; padding: 4px 4px 6px; text-align: center; cursor: pointer;
  box-shadow: 1px 2px 4px rgba(80,50,20,0.3); transition: transform 0.1s;
}
.dex-card:nth-child(odd) { transform: rotate(-0.8deg); }
.dex-card:nth-child(even) { transform: rotate(0.7deg); }
.dex-card:hover { transform: rotate(0) scale(1.05); z-index: 1; }
.dex-card.sel { outline: 3px solid #b0402a; }
.dex-card canvas { display: block; width: 100%; height: auto; aspect-ratio: 12 / 7; }
.dex-card .name { font-size: 13px; font-weight: bold; color: #2e2414; }
.dex-card .st { font-size: 11px; color: #8a7a5a; }
.dex-card.full .st { color: #3a7a2a; }
.dex-card.partial .st { color: #b06a10; }
.dex-card.unknown { background: #e6dcc2; }
.dex-card.full::after { content: '연구 완료'; position: absolute; right: 2px; top: 4px; font-size: 9px; color: #b0402a; border: 1.5px solid #b0402a; padding: 0 3px; transform: rotate(12deg); font-weight: bold; }
.dex-detail { min-height: 0; overflow-y: auto; font-size: 13px; }
.dex-detail canvas { width: 300px; height: 180px; background: radial-gradient(ellipse, #fffaf0, #e8dbb8); border: 1px solid #c8b488; box-shadow: 1px 2px 5px rgba(80,50,20,0.3); }
.dex-detail h3 { margin: 6px 0; color: #4a2410; font-size: 19px; }
.dex-detail p { line-height: 1.55; }
.dex-detail table { border-collapse: collapse; width: 100%; margin-bottom: 8px; }
.dex-detail th { text-align: left; color: #7a6440; font-weight: normal; padding: 3px 8px 3px 0; white-space: nowrap; vertical-align: top; }
.dex-detail td { padding: 3px 0; border-bottom: 1px dotted rgba(90,60,30,0.3); }
.dex-detail .q { color: #a8987a; }
.dex-detail .hint, .notes .hint { color: #7a6a4a; }
.dex .back { grid-column: 1 / 3; justify-self: end; }
.notes { grid-column: 1 / 3; overflow-y: auto; }
.note { border-top: 1px dashed rgba(90,60,30,0.35); padding: 10px 4px; }
.note b { color: #5a2a14; }
.note p { margin: 4px 0 0; line-height: 1.6; font-size: 14px; color: #3a2e1a; }
.note small { color: #8a7a5a; }

/* ── 캠프 아이콘 막대 ── */
.dock { position: absolute; right: 10px; top: 10px; bottom: 10px; width: 78px; display: flex; flex-direction: column; gap: 4px; padding: 5px;
  background: linear-gradient(rgba(36,35,25,0.85), rgba(18,17,12,0.85)); border: 2px solid #5f5a42; border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,0.6); }
.dock-btn { position: relative; flex: 1 1 0; min-height: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0; padding: 1px; cursor: pointer;
  background: linear-gradient(#3a3b28, #24251a); border: 1px solid #5a5440; border-radius: 6px; color: #e8dfc4; font: inherit; font-size: 11px; }
.dock-btn:hover { filter: brightness(1.25); transform: translateX(-3px); }
.dock-btn.main { background: linear-gradient(#e6b75a, #b07c2c); color: #2a1a08; font-weight: bold; border-color: #f0cd80; }
.dock-btn canvas { width: 28px !important; height: 28px !important; }
.dock-btn .badge { position: absolute; right: 4px; top: 3px; background: #c62828; color: #fff; font-style: normal; font-size: 10px; border-radius: 8px; padding: 0 5px; }

/* ── 공용 창 ── */
.win { position: relative; width: 880px; height: 470px; display: flex; flex-direction: column; border-radius: 6px;
  background: linear-gradient(#2a2a1e, #16160e); border: 2px solid #6b6448; box-shadow: 0 16px 40px rgba(0,0,0,0.8); }
.win-head { display: flex; justify-content: space-between; align-items: center; padding: 10px 16px 6px; border-bottom: 1px solid #4a4636; }
.win-head h2 { margin: 0; color: #f0c870; font-size: 22px; }
.win-body { flex: 1; min-height: 0; display: flex; gap: 12px; padding: 12px 16px; }
.win .hint { color: #a8a088; font-size: 13px; margin: 4px 0; }
.grid { display: flex; flex-wrap: wrap; gap: 6px; align-content: flex-start; overflow-y: auto; padding: 4px; }
.cell { position: relative; width: 58px; height: 58px; display: flex; align-items: center; justify-content: center; cursor: pointer; touch-action: none;
  background: radial-gradient(#3a3a2c, #1e1e16); border: 1px solid #5a5440; border-radius: 6px; }
.cell:hover { border-color: #e0c070; filter: brightness(1.2); }
.cell.sel { border: 2px solid #f0c870; box-shadow: 0 0 10px rgba(240,200,112,0.5); }
.cell .cnt { position: absolute; right: 3px; bottom: 1px; font-size: 11px; color: #fff; text-shadow: 0 0 3px #000, 0 0 3px #000; }
.cell.t1 { border-color: #6a9a5a; } .cell.t2 { border-color: #5a7aa0; } .cell.t3 { border-color: #a05aa0; } .cell.t4 { border-color: #e0b040; }
.drag-ghost { position: absolute; pointer-events: none !important; z-index: 99; filter: drop-shadow(0 6px 6px rgba(0,0,0,0.6)); }
[data-drop].hover { border-color: #ffe082 !important; box-shadow: 0 0 14px rgba(255,224,130,0.7) !important; }
.win .ok { color: #9ccc65; } .win .no { color: #ef8a7a; }

.bag .grid { width: 520px; }
.bag .detail { flex: 1; text-align: center; padding: 6px 10px; border-left: 1px dashed #4a4636; }
.bag .detail h3 { margin: 6px 0; color: #f0c870; }
.bag .detail h3 small { color: #a8a088; font-size: 12px; font-family: 'Gowun Dodum', sans-serif; }
.bag .detail p { font-size: 14px; line-height: 1.55; }
.bag .detail .food { color: #f0c060; }
.bag .detail .row { display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; }
.bag-status { position: absolute; left: 20px; bottom: 10px; font-size: 13px; color: #c8bfa4; }

.equip .doll { position: relative; width: 360px; height: 330px; flex: none; border-radius: 8px; background: radial-gradient(ellipse at 50% 40%, #3a3a2c, #1a1a12); border: 1px solid #4a4636; }
.equip .figure { position: absolute; left: 135px; top: 30px; width: 90px; height: 270px; opacity: 0.55;
  background: radial-gradient(circle at 50% 12%, #2a2d2e 0 22px, transparent 23px), radial-gradient(ellipse at 50% 45%, #4f5a33 0 40px, transparent 41px), linear-gradient(90deg, transparent 30px, #3c4429 30px 60px, transparent 60px); }
.equip .slot { position: absolute; width: 74px; height: 86px; display: flex; flex-direction: column; align-items: center; justify-content: center; border: 2px dashed #6b6448; border-radius: 8px; background: rgba(0,0,0,0.3); }
.equip .slabel { font-size: 11px; color: #c8bfa4; }
.equip .gear-list { flex: 1; overflow-y: auto; }
.equip .gear-row { display: flex; align-items: center; gap: 6px; margin: 6px 0; flex-wrap: wrap; }
.equip .gname { width: 60px; font-size: 13px; color: #d8c890; }
.equip-info { position: absolute; left: 20px; bottom: 12px; width: 360px; font-size: 13px; color: #e8dfc4; }

.bench .inv, .cook .inv { width: 250px; flex: none; border-right: 1px dashed #4a4636; }
.table, .pot { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.slots { display: flex; align-items: center; gap: 8px; }
.slots .slot { width: 66px; height: 66px; display: flex; align-items: center; justify-content: center; border: 2px dashed #8a8060; border-radius: 8px; background: rgba(0,0,0,0.35); cursor: pointer; }
.slots .plus { color: #8a8060; font-size: 20px; }
.pot .slots { padding: 16px 22px 26px; border-radius: 0 0 60px 60px; background: linear-gradient(#4a4a48, #2a2a28); border: 3px solid #1a1a18; box-shadow: 0 14px 30px rgba(255,120,40,0.25); }
.result { display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; font-size: 13px; min-height: 120px; }
.result b { color: #f0c870; font-size: 15px; }
.recipes { width: 250px; flex: none; overflow-y: auto; border-left: 1px dashed #4a4636; padding-left: 10px; }
.recipes h3 { margin: 0 0 6px; color: #d8c890; font-size: 15px; }
.recipe { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; padding: 4px; border-bottom: 1px dotted #3a3628; font-size: 12px; cursor: pointer; }
.recipe:hover { background: rgba(255,240,200,0.06); }
.recipe.done { opacity: 0.4; }
.recipe.ready .rname { color: #9ccc65; }
.recipe .rname { flex: 1 0 100px; }
.recipe .mats { display: flex; align-items: center; gap: 2px; }
.recipe canvas { vertical-align: middle; }

.garage .win-body { flex-direction: column; }
.garage-top { display: flex; align-items: center; gap: 12px; font-size: 14px; }
.upgrades { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; overflow-y: auto; }
.upg-card { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border: 1px solid #4a4636; border-radius: 6px; background: rgba(0,0,0,0.25); font-size: 13px; }
.upg-card.done { opacity: 0.55; }
.upg-card.locked { opacity: 0.45; }
.upg-card .utxt { flex: 1; }
.upg-card .mats { display: flex; align-items: center; gap: 3px; margin-top: 2px; }

.region-list { display: flex; flex-direction: column; gap: 8px; }
.region { padding: 10px 12px; border: 1px solid #5a5440; border-radius: 6px; background: rgba(0,0,0,0.25); cursor: pointer; }
.region:hover { border-color: #f0c870; background: rgba(240,200,112,0.08); }
.region.locked { opacity: 0.5; cursor: not-allowed; }
.region .rname { font-family: 'Black Han Sans', sans-serif; font-size: 18px; color: #f0c870; }
.region .rname .no { font-family: 'Gowun Dodum', sans-serif; font-size: 13px; margin-left: 8px; }
.region .rdesc { font-size: 14px; margin: 3px 0; }
.region .rmeta { font-size: 12px; color: #a8a088; }
.modal.paper.small { min-width: 340px; max-width: 520px; }
.close { padding: 2px 10px !important; }
/* ── 로그인 ── */
.modal.login { width: 380px; }
.modal.login label { display: flex; flex-direction: column; gap: 4px; font-size: 14px; color: #d8c890; }
.modal.login input { font: inherit; font-size: 16px; padding: 8px 10px; border-radius: 4px; border: 1px solid #6b6448; background: #14140e; color: #f0e8d0; outline: none; }
.modal.login input:focus { border-color: #f0c870; box-shadow: 0 0 8px rgba(240,200,112,0.35); }
.modal.login .err { min-height: 20px; font-size: 13px; margin: 6px 0 0; }
/* ── 모바일 터치 ── */
html, body { touch-action: none; overscroll-behavior: none; -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent; }
input { -webkit-user-select: text; user-select: text; }
.joy { position: absolute; left: 26px; bottom: 26px; width: 150px; height: 150px; border-radius: 50%; touch-action: none;
  background: radial-gradient(circle, rgba(255,250,230,0.10), rgba(0,0,0,0.35)); border: 2px solid rgba(240,220,160,0.45); box-shadow: 0 0 20px rgba(0,0,0,0.4); }
.joy .knob { position: absolute; left: 44px; top: 44px; width: 62px; height: 62px; border-radius: 50%; pointer-events: none;
  background: radial-gradient(circle at 35% 30%, #f6d590, #a87a2a); border: 2px solid #f0d890; box-shadow: 0 4px 10px rgba(0,0,0,0.5); }
.act-btn { position: absolute; right: 36px; bottom: 76px; width: 86px; height: 86px; border-radius: 50%; touch-action: none; cursor: pointer;
  font: 32px 'Black Han Sans', sans-serif; color: #2a1a08; background: radial-gradient(circle at 35% 30%, #f2c870, #b07c2c);
  border: 3px solid #f0cd80; box-shadow: 0 4px 0 #4a3010, 0 0 16px rgba(240,200,112,0.4); }
.act-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 #4a3010; }
body.touch .hud-buttons .btn { font-size: 16px; padding: 10px 14px; }
body.touch .btn.small { font-size: 14px; padding: 7px 12px; }
body.touch .cell { width: 64px; height: 64px; }
#rotate { display: none; }
@media (orientation: portrait) and (pointer: coarse) {
  #rotate { display: flex; position: fixed; inset: 0; z-index: 999; align-items: center; justify-content: center; text-align: center;
    background: #0b0b08; color: #f0c870; font: 24px/1.6 'Black Han Sans', sans-serif; }
}.modal ol.guide { padding-left: 22px; line-height: 1.9; font-size: 15px; }
.modal ol.guide .share { display: inline-block; padding: 0 6px; border: 1px solid #8a8060; border-radius: 4px; color: #8ac8ff; }