:root { --s: 1; --gold: #ffd23f; --ink: #14161a; --pink: #ff4fa3; --cyan: #4ff0ff; }
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: #0b0710; color: #f3eee6; font-family: "Gowun Dodum", system-ui, sans-serif; overflow: hidden; touch-action: none; user-select: none; -webkit-user-select: none; }
#app { position: absolute; left: 50%; top: 50%; width: 960px; height: 540px; transform: translate(-50%, -50%) scale(var(--s)); transform-origin: center; }
#cv { position: absolute; inset: 0; width: 960px; height: 540px; image-rendering: auto; }
#ui { position: absolute; inset: 0; pointer-events: none; }
#ui > * { pointer-events: auto; }
button { font: inherit; cursor: pointer; border: 2px solid var(--ink); background: #3a3350; color: #fff; padding: 7px 14px; border-radius: 8px; box-shadow: 0 3px 0 var(--ink); }
button:hover:not(:disabled) { background: #4d4470; }
button:active:not(:disabled) { transform: translateY(2px); box-shadow: 0 1px 0 var(--ink); }
button:disabled { opacity: .4; cursor: default; }
button.big { font-family: "Black Han Sans", sans-serif; font-size: 22px; padding: 10px 26px; background: #e2513a; }
button.big:hover { background: #f06a50; }
input, select { font: inherit; padding: 5px 8px; border-radius: 6px; border: 2px solid var(--ink); background: #f3eee6; color: #222; }
kbd { display: inline-block; background: #f3eee6; color: #222; border-radius: 4px; padding: 0 6px; margin: 0 2px; font-size: 13px; border-bottom: 2px solid #999; }
h1, h2, h4 { font-family: "Black Han Sans", sans-serif; font-weight: normal; margin: 6px 0; }
h2 small { font-family: "Gowun Dodum"; font-size: 15px; opacity: .8; margin-left: 10px; }
.panel { position: absolute; inset: 18px; background: rgba(22, 16, 32, .94); border: 3px solid var(--ink); border-radius: 16px; padding: 16px 22px; overflow: auto; box-shadow: 0 0 0 2px #3a3350 inset; }
.panel.story { inset: 60px 230px; text-align: center; background: rgba(22, 16, 32, .8); }
.sub { margin: 0 0 14px; opacity: .9; }
.fine { font-size: 12px; opacity: .6; margin-top: 12px; }
.col { display: flex; flex-direction: column; gap: 9px; align-items: stretch; max-width: 300px; margin: 0 auto; }
.row { display: flex; gap: 10px; align-items: center; justify-content: center; flex-wrap: wrap; margin: 8px 0; }
.quote { font-size: 18px; color: #ffe8a3; margin: 10px 0; }
.dim { opacity: .65; font-size: 14px; }
.warn { color: #ffb4a2; }
.how { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; text-align: left; font-size: 14px; }
.how p { margin: 5px 0; line-height: 1.6; }
.panel.how { inset: 18px; }
.hud { position: absolute; left: 0; right: 0; top: 0; display: flex; gap: 16px; align-items: center; padding: 6px 12px; background: linear-gradient(rgba(10,8,16,.8), transparent); font-size: 15px; pointer-events: auto; }
.hud .hint { flex: 1; text-align: center; color: var(--gold); }
.tabs { display: flex; gap: 6px; margin: 4px 0 10px; }
.tabs button.on { background: var(--gold); color: var(--ink); }
.crates { display: grid; grid-template-columns: repeat(9, 1fr); gap: 8px; margin: 14px 0; }
.crate { height: 120px; font-size: 40px; display: flex; flex-direction: column; align-items: center; justify-content: center; background: #6b4f2a; }
.crate small { font-size: 11px; line-height: 1.2; }
.crate.open { background: #2d6a4f; }
.crate.missed { opacity: .45; background: #3a3350; }
.shoplist { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.sitem, .cand { display: flex; gap: 10px; align-items: center; background: rgba(255,255,255,.05); padding: 6px; border-radius: 10px; }
.sitem > div, .cand > div { flex: 1; }
.sitem p, .cand p { margin: 2px 0; font-size: 12.5px; }
.stats { color: #9ad1ff; }
.kits { display: flex; gap: 10px; align-items: center; padding: 8px; background: rgba(255,210,63,.1); border-radius: 10px; }
.kits span { flex: 1; }
.build { display: grid; grid-template-columns: 300px 1fr; gap: 14px; }
.bl canvas { display: block; margin: 0 auto; background: radial-gradient(circle at 50% 70%, #3a3350, transparent 70%); border-radius: 12px; }
.sb { display: grid; grid-template-columns: 82px 1fr 38px; align-items: center; gap: 6px; font-size: 13px; margin: 3px 0; }
.sb i { display: block; height: 9px; background: var(--gold); border-radius: 5px; }
.sb em { font-style: normal; text-align: right; opacity: .8; }
.spl { color: #7cf; font-size: 13px; }
.badge { background: #6b4f2a; padding: 4px 8px; border-radius: 8px; font-size: 13px; }
.slots { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.slots button { text-align: left; display: flex; flex-direction: column; position: relative; padding-bottom: 12px; }
.slots button.on { background: #5a4a8a; outline: 2px solid var(--gold); }
.slots small { opacity: .7; font-size: 11px; }
.cond { position: absolute; left: 6px; bottom: 4px; height: 4px; border-radius: 2px; max-width: calc(100% - 12px); }
.cands { display: flex; flex-direction: column; gap: 6px; }
.cand.on { outline: 2px solid var(--gold); }
.tag { background: var(--gold); color: var(--ink); padding: 2px 8px; border-radius: 6px; font-size: 12px; }
.tag.dim { background: #555; color: #ddd; }
.ladder { display: flex; flex-direction: column; gap: 8px; }
.rung { display: flex; align-items: center; gap: 14px; background: rgba(255,255,255,.05); padding: 6px 12px; border-radius: 12px; }
.rung > div { flex: 1; } .rung p { margin: 2px 0; font-size: 14px; }
.rung.beat { background: rgba(60,224,122,.12); }
.rung.locked { opacity: .45; }
.rung.boss { border: 2px solid #ff7b00; }
.tier { margin: 10px 0; padding: 8px 10px; border-radius: 14px; background: rgba(255,255,255,.04); border: 1px solid rgba(255,255,255,.08); }
.tier.locked { opacity: .5; }
.tierhead { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 18px; margin-bottom: 2px; }
.tierhead .cap { margin-left: auto; font-size: 13px; padding: 2px 10px; border-radius: 999px; background: rgba(60,224,122,.16); color: #bdeccb; }
.tierhead .cap.over { background: rgba(255,120,90,.2); color: #ffb4a2; }
.vs { display: flex; justify-content: center; align-items: center; gap: 30px; text-align: center; }
.vs > div { display: flex; flex-direction: column; align-items: center; }
.vs b { font-family: "Black Han Sans"; font-size: 24px; }
.vsx { font-family: "Black Han Sans"; font-size: 70px; color: var(--gold); text-shadow: 0 0 20px var(--pink); }
.panel.vsp, .panel.result { text-align: center; overflow: hidden; }
.panel.vsp .fit, .panel.result .fit { transform-origin: top left; } /* 줄인 만큼 폭을 넓혀 두므로(fitPanel) 왼쪽 위 기준이어야 가운데에 옴 */
.result h1.win { font-size: 64px; color: var(--gold); text-shadow: 0 0 20px var(--pink); }
.result h1.lose { font-size: 54px; color: #9ab; }
.gold { color: var(--gold); font-size: 22px; font-family: "Black Han Sans"; }
.dmg span { display: inline-block; margin: 3px; padding: 3px 8px; background: #6b4f2a; border-radius: 6px; }
.dmg span.broke { background: #a4161a; }
.ach { padding: 10px; margin: 8px 0; border-radius: 10px; background: rgba(255,255,255,.05); opacity: .55; }
.ach.got { opacity: 1; background: rgba(255,210,63,.18); outline: 2px solid var(--gold); }
/* 이음 ② 그림: 얼굴 초상 · 보스 전신 · 칭호 배지 (파일 없으면 JS 가 숨김) */
img.art { display: inline-block; }
/* 작은 UI 아이콘(체중계·지구본·자물쇠·메달). 글줄에 자연스럽게 얹힘. */
img.uicon { height: 20px; width: auto; vertical-align: middle; margin-right: 4px; image-rendering: auto; }
img.uicon.lk { height: 22px; margin-right: 5px; }
img.uicon.wt { height: 17px; margin-right: 3px; }
img.uicon.medal { height: 30px; margin-right: 4px; }
.rung.locked img.uicon.lk { opacity: .9; }
.vscol { position: relative; }
.vsface { width: 100px; height: 100px; border-radius: 50%; object-fit: cover; border: 3px solid var(--gold); background: #241a2e; box-shadow: 0 0 16px rgba(0,0,0,.55); margin-bottom: -16px; position: relative; z-index: 2; }
/* 보스 전신(손그림)은 상대 칸의 코드-로봇 캔버스 위에 겹침 → 칸 높이를 안 늘림(시작 버튼 안 가림). 그림 없으면 숨고 캔버스가 보임. */
.bossentry { position: absolute; left: 50%; transform: translateX(-50%); top: 104px; height: 206px; width: auto; z-index: 1; filter: drop-shadow(0 5px 8px rgba(0,0,0,.6)); pointer-events: none; }
.bossportrait { display: block; width: 124px; height: 124px; margin: 8px auto 2px; border-radius: 18px; object-fit: cover; border: 3px solid var(--gold); box-shadow: 0 0 24px var(--pink); }
.tbadge { height: 42px; vertical-align: middle; margin-right: 4px; }
.rbadge { height: 26px; vertical-align: middle; margin: 0 2px; }
.rface { width: 48px; height: 48px; border-radius: 50%; object-fit: cover; border: 2px solid rgba(255,255,255,.3); background: #241a2e; }
.art.reg { filter: brightness(1.18) contrast(1.07) drop-shadow(0 0 3px rgba(255,255,255,.4)); }
/* 수리 */
.panel.cornerp { inset: 10px; padding: 10px; }
.repair .rhead { display: flex; gap: 16px; align-items: center; margin-bottom: 8px; }
.repair .rhead b { font-family: "Black Han Sans"; font-size: 24px; color: var(--gold); }
.rtime { font-size: 20px; } .rtime.hurry { color: #ff5a5a; animation: blink .4s infinite alternate; }
@keyframes blink { to { opacity: .4; } }
.rscrap { flex: 1; }
.rbody { display: grid; grid-template-columns: 300px 1fr; gap: 12px; }
.rleft canvas { display: block; margin: 0 auto; }
.rlist { display: flex; flex-direction: column; gap: 4px; }
.rlist button { text-align: left; position: relative; padding: 5px 8px 9px; font-size: 13px; display: flex; flex-direction: column; }
.rlist button i { position: absolute; left: 6px; bottom: 3px; height: 4px; background: #3ce07a; border-radius: 2px; max-width: calc(100% - 12px); }
.rlist button.bad i { background: #ff9f1c; } .rlist button.broke i { background: #e84a3c; } .rlist button.broke { background: #5a1a22; }
.rlist button.ok { opacity: .55; } .rlist button.sel { outline: 2px solid var(--gold); }
.rlist em { font-style: normal; font-size: 11px; opacity: .75; }
.rright canvas { width: 100%; max-width: max(560px, min(960px, calc((100vh - 340px) * 1.6))); border-radius: 12px; border: 3px solid var(--ink); touch-action: none; cursor: crosshair; display: block; }
.rhint { color: #9ff6ff; margin-bottom: 6px; min-height: 22px; }
.rmsg { color: var(--gold); font-size: 18px; min-height: 26px; margin-top: 6px; }
.garage .rwrap .repair { }
/* 기술 공방 */
.editor { display: grid; grid-template-columns: 560px 1fr; gap: 14px; }
.ecv { border-radius: 12px; border: 3px solid var(--ink); touch-action: none; width: 560px; }
.ekeys { display: flex; gap: 6px; margin-top: 6px; overflow-x: auto; }
.ekey { background: rgba(255,255,255,.06); border-radius: 8px; padding: 4px; font-size: 11px; display: flex; flex-direction: column; align-items: center; cursor: pointer; min-width: 88px; border: 2px solid transparent; }
.ekey.sel { border-color: #7cf; } .ekey.hit { background: rgba(255,210,63,.22); }
.ekey input[type=range] { width: 70px; }
.erow { display: flex; gap: 6px; margin-top: 6px; flex-wrap: wrap; }
.ecol.side label { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin: 5px 0; }
.estat { background: rgba(0,0,0,.3); padding: 8px; border-radius: 10px; margin: 8px 0; }
.ev { margin-bottom: 4px; } .ev.small { font-size: 12px; opacity: .85; margin-top: 4px; }
.mrow { display: flex; gap: 6px; align-items: center; font-size: 13px; margin: 3px 0; } .mrow span { flex: 1; }
.ehelp { font-size: 12px; opacity: .7; line-height: 1.5; }
.esave { width: 100%; margin-top: 8px; }
/* 터치 */
#touch { display: none; position: absolute; inset: 0; pointer-events: none; }
body.touch[data-mode="fight"] #touch, body.touch[data-mode="town"] #touch { display: block; }
.stick { position: absolute; left: 30px; bottom: 30px; width: 150px; height: 150px; border-radius: 50%; background: rgba(255,255,255,.08); border: 2px solid rgba(255,255,255,.25); pointer-events: auto; }
.stick .nub { position: absolute; left: 45px; top: 45px; width: 60px; height: 60px; border-radius: 50%; background: rgba(255,255,255,.35); }
.tbtns { position: absolute; right: 24px; bottom: 26px; display: grid; grid-template-columns: repeat(3, 72px); gap: 10px; pointer-events: auto; }
.tbtns button { height: 64px; border-radius: 50%; background: rgba(58,51,80,.6); font-size: 15px; padding: 0; }
.tbtns button.on { background: var(--gold); color: var(--ink); }
.tbtns .sp { background: rgba(226,81,58,.7); } .tbtns .su { background: rgba(42,123,216,.7); }
body[data-mode="town"] .tbtns button:not([data-k="lp"]) { display: none; }
body[data-mode="town"] .tbtns { grid-template-columns: 90px; }
#rotate { display: none; position: fixed; inset: 0; background: #0b0710; color: #fff; font-size: 22px; align-items: center; justify-content: center; text-align: center; z-index: 9; }
@media (orientation: portrait) and (pointer: coarse) { #rotate { display: flex; } }
.mlist table { width: 100%; border-collapse: collapse; font-size: 14px; }
.mlist td { padding: 4px 8px; border-bottom: 1px solid rgba(255,255,255,.08); vertical-align: top; }
.mlist td small { opacity: .65; }
.mlist .ek { color: var(--gold); font-weight: bold; white-space: nowrap; }
.tbtns { grid-template-columns: repeat(3, 66px) !important; }
.tbtns button { height: 58px; font-size: 13px; }
.attach { display: grid; grid-template-columns: 470px 1fr; gap: 14px; }
.acv { border-radius: 12px; border: 3px solid var(--ink); touch-action: none; }
.arow { display: flex; gap: 6px; margin-top: 6px; flex-wrap: wrap; } .arow button.on { background: var(--gold); color: var(--ink); }
.wbar { display: grid; grid-template-columns: 50px 1fr 90px; align-items: center; gap: 8px; }
.wbar > div { position: relative; height: 14px; background: #222; border-radius: 7px; overflow: hidden; }
.wbar i { display: block; height: 100%; border-radius: 7px; }
.wbar .capline { position: absolute; top: 0; bottom: 0; width: 2px; background: #fff; }
.wbar em { font-style: normal; text-align: right; }
.bag { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.bitem { display: flex; gap: 6px; align-items: center; background: rgba(255,255,255,.06); border-radius: 8px; padding: 4px; cursor: grab; touch-action: none; }
.bitem.none { opacity: .4; cursor: default; } .bitem small { display: block; font-size: 11px; opacity: .75; }
.notes { margin: 4px 0; padding-left: 18px; font-size: 13.5px; line-height: 1.6; } .notes .warn { color: #ffb4a2; }
.small { font-size: 12px; }
.elib { margin-top: 6px; font-size: 12px; display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.elib button { padding: 3px 7px; font-size: 12px; box-shadow: 0 2px 0 var(--ink); }
.stars { color: var(--gold); letter-spacing: 1px; }
.mrow.on { background: rgba(255,210,63,.12); border-radius: 6px; }
.enew { margin-top: 4px; }
.editor .ecol.side { padding-right: 6px; }
.editor .ecol.side .estat { margin: 4px 0; padding: 6px; }
.editor .ecol.side label { margin: 3px 0; }
.editor .esave.big { font-size: 18px; padding: 7px 14px; }
.forge { display: grid; grid-template-columns: 470px 1fr; gap: 14px; }
.fcv { border-radius: 12px; border: 3px solid var(--ink); touch-action: none; cursor: crosshair; }
.frow { display: flex; gap: 6px; margin-top: 6px; flex-wrap: wrap; align-items: center; }
.frow.tools button.on { background: var(--gold); color: var(--ink); }
.fside { padding-right: 6px; }
.fnew { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; } .fnew button { font-size: 13px; padding: 4px 8px; } .fnew small { opacity: .7; font-size: 11px; }
.fstat { background: rgba(0,0,0,.3); padding: 6px 8px; border-radius: 10px; margin: 6px 0; }
.flist { display: flex; flex-direction: column; gap: 4px; } .fitem { display: flex; gap: 8px; align-items: center; background: rgba(255,255,255,.06); border-radius: 8px; padding: 3px 6px; cursor: pointer; } .fitem small { opacity: .7; font-size: 11px; }
.bitem.forged { outline: 1px solid var(--gold); }

.panel.garage { overflow: hidden; }
.panel.garage .fit { transform-origin: top left; }
/* 마을 폰 버튼 (터치 또는 세로 화면). #app 밖이라 세로 화면에선 그림 아래 빈 곳에 놓임 */
#vpad { display: none; position: fixed; left: 0; right: 0; bottom: 0; padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); justify-content: space-between; gap: 12px; z-index: 5; pointer-events: none; }
#vpad button { pointer-events: auto; width: 76px; height: 64px; font-size: 26px; border-radius: 14px; background: rgba(58,51,80,.75); touch-action: none; }
#vpad button.on { background: var(--gold); color: var(--ink); }
#vpad #vIn { margin-left: auto; background: rgba(226,81,58,.85); }
body.touch[data-hub="village"][data-mode="town"] #vpad { display: flex; }
@media (orientation: portrait) { body[data-hub="village"][data-mode="town"] #vpad { display: flex; } }
body[data-hub="village"] #touch { display: none !important; }
body[data-hub="village"][data-mode="town"] #rotate { display: none; }
body[data-mode="title"] #rotate { display: none; }

/* ───── 처음 화면: 마을(이음 그림) 흐리게 + 녹슨 간판 + 철판/나무 버튼. 움직임은 누를 때만(≤.15s) ───── */
#front { --u: min(1vh, .5625vw); position: fixed; inset: 0; z-index: 6; overflow: hidden; display: flex; flex-direction: column; align-items: center; justify-content: center; color: #f6e7cc; background: #2a1a10; }
#front[hidden] { display: none; }
#front .ts-bg { position: absolute; inset: -16px; background: url(assets/village/village_bg.webp?v=20261201b) center 70% / cover no-repeat; filter: blur(3px) brightness(.6) saturate(1.05); }
#front::after { content: ""; position: absolute; inset: 0; pointer-events: none; background: radial-gradient(ellipse 60% 70% at 50% 45%, rgba(25,12,5,.42), rgba(25,12,5,0) 70%), radial-gradient(ellipse at 50% 50%, rgba(0,0,0,0) 45%, rgba(18,8,3,.8) 100%); }
#front > * { position: relative; z-index: 1; }
#front .ts-bot { position: absolute; bottom: calc(5 * var(--u)); height: calc(58 * var(--u)); width: auto; aspect-ratio: 220 / 300; filter: drop-shadow(0 calc(1 * var(--u)) calc(1.5 * var(--u)) rgba(0,0,0,.55)); pointer-events: none; z-index: 1; }
#front .ts-bot.l { left: max(2vw, calc(50vw - 92 * var(--u))); }
#front .ts-bot.r { right: max(2vw, calc(50vw - 92 * var(--u))); }
#front .ts-main { z-index: 2; display: flex; flex-direction: column; align-items: center; text-align: center; margin-top: calc(-3 * var(--u)); }
/* 간판: 녹슨 철판 + 볼트 4개 + 매단 쇠줄 (마을 「고물상」「차고」 간판처럼) */
#front .ts-sign { position: relative; margin-top: calc(6 * var(--u)); padding: calc(1.4 * var(--u)) calc(5.5 * var(--u)) calc(1.9 * var(--u)); transform: rotate(-1.5deg);
  background:
    radial-gradient(circle at 9% 28%, rgba(125,52,16,.6) 0 calc(1.2 * var(--u)), rgba(125,52,16,0) calc(3.4 * var(--u))),
    radial-gradient(circle at 88% 78%, rgba(135,60,20,.55) 0 calc(1.6 * var(--u)), rgba(135,60,20,0) calc(4.4 * var(--u))),
    radial-gradient(circle at 64% 12%, rgba(100,44,14,.4) 0 calc(.8 * var(--u)), rgba(100,44,14,0) calc(2.6 * var(--u))),
    radial-gradient(circle at 30% 92%, rgba(100,44,14,.35) 0 calc(.6 * var(--u)), rgba(100,44,14,0) calc(2.2 * var(--u))),
    linear-gradient(176deg, #e2cfa9 0%, #cdb084 42%, #ab8659 100%);
  border: calc(.7 * var(--u)) solid #3a2313; border-radius: calc(1.3 * var(--u));
  box-shadow: inset 0 0 0 calc(.35 * var(--u)) rgba(255,240,215,.35), inset 0 calc(-1 * var(--u)) calc(2 * var(--u)) rgba(80,38,12,.45), 0 calc(1.1 * var(--u)) 0 #24140a, 0 calc(2.2 * var(--u)) calc(3 * var(--u)) rgba(0,0,0,.6); }
#front .ts-sign::before, #front .ts-sign::after { content: ""; position: absolute; bottom: 100%; width: calc(.7 * var(--u)); height: calc(6.5 * var(--u)); background: repeating-linear-gradient(180deg, #6d5a48 0 calc(.9 * var(--u)), #2e2118 calc(.9 * var(--u)) calc(1.3 * var(--u))); border-radius: 2px; }
#front .ts-sign::before { left: 18%; } #front .ts-sign::after { right: 18%; }
#front .ts-sign h1 { margin: 0; font-family: "Black Han Sans", sans-serif; font-weight: normal; font-size: min(max(30px, calc(10.5 * var(--u))), 11vw); line-height: 1.12; letter-spacing: .05em; color: #4a2914; white-space: nowrap;
  text-shadow: 0 calc(.28 * var(--u)) 0 rgba(255,242,215,.6), 0 calc(-.18 * var(--u)) 0 rgba(40,18,6,.55); }
#front[data-lang="en"] .ts-sign h1 { font-size: min(max(28px, calc(10 * var(--u))), 8.6vw); }
#front[data-lang="en"] .ts-neon { letter-spacing: .12em; padding-left: .12em; font-size: max(15px, calc(3.6 * var(--u))); text-shadow: 0 0 calc(.2 * var(--u)) #fff, 0 0 calc(.7 * var(--u)) #4ff0ff, 0 0 calc(1.6 * var(--u)) #1fb8e0; }
#front .ts-bolt { position: absolute; width: calc(1.7 * var(--u)); height: calc(1.7 * var(--u)); border-radius: 50%; background: radial-gradient(circle at 35% 32%, #f0e2c8 0 15%, #9b8160 45%, #4b3624 100%); box-shadow: 0 calc(.15 * var(--u)) 0 rgba(0,0,0,.55); }
#front .ts-bolt.a { left: calc(1.2 * var(--u)); top: calc(1.1 * var(--u)); } #front .ts-bolt.b { right: calc(1.2 * var(--u)); top: calc(1.1 * var(--u)); }
#front .ts-bolt.c { left: calc(1.2 * var(--u)); bottom: calc(1.1 * var(--u)); } #front .ts-bolt.d { right: calc(1.2 * var(--u)); bottom: calc(1.1 * var(--u)); }
/* 네온 줄 (마을 「부품」 톱니 네온처럼 하늘색, 깜빡임 없음) */
#front .ts-neon { margin: calc(2.6 * var(--u)) 0 0; font-family: "Black Han Sans", sans-serif; font-size: max(13px, calc(3.3 * var(--u))); letter-spacing: .32em; padding-left: .32em; color: #eaffff;
  text-shadow: 0 0 calc(.3 * var(--u)) #fff, 0 0 calc(1 * var(--u)) #4ff0ff, 0 0 calc(2.2 * var(--u)) #1fb8e0, 0 0 calc(4 * var(--u)) #ff7a2a; }
#front .ts-sub { margin: calc(1 * var(--u)) 0 calc(2.8 * var(--u)); font-size: max(13px, calc(2.4 * var(--u))); color: #ffe6bd; text-shadow: 0 2px 4px rgba(0,0,0,.8); }
#front .ts-btns { display: flex; flex-direction: column; align-items: center; gap: calc(1.8 * var(--u)); }
#front .ts-pair { display: flex; gap: calc(1.6 * var(--u)); justify-content: center; flex-wrap: wrap; }
/* 철판 버튼: 양옆 리벳, 아래로 두꺼운 그림자. 누르면 쑥 들어감 */
#front .ts-plate { position: relative; font-family: "Black Han Sans", sans-serif; font-size: max(15px, calc(3 * var(--u))); color: #ffecc9; padding: calc(1.1 * var(--u)) calc(4.4 * var(--u)); min-width: calc(30 * var(--u));
  border: calc(.45 * var(--u)) solid #24140a; border-radius: calc(1 * var(--u)); text-shadow: 0 calc(.25 * var(--u)) 0 rgba(40,18,6,.8);
  background: repeating-linear-gradient(0deg, rgba(0,0,0,.07) 0 calc(.3 * var(--u)), rgba(0,0,0,0) calc(.3 * var(--u)) calc(1.5 * var(--u))), linear-gradient(180deg, #a5713f, #7c4f2a 60%, #623c1f);
  box-shadow: inset 0 calc(.3 * var(--u)) 0 rgba(255,225,180,.3), inset 0 calc(-.5 * var(--u)) 0 rgba(40,18,6,.35), 0 calc(.7 * var(--u)) 0 #24140a, 0 calc(1.2 * var(--u)) calc(1.6 * var(--u)) rgba(0,0,0,.5);
  transition: transform .12s ease-out, box-shadow .12s ease-out, filter .12s ease-out; }
#front .ts-plate::before, #front .ts-plate::after { content: ""; position: absolute; top: 50%; width: calc(1.1 * var(--u)); height: calc(1.1 * var(--u)); margin-top: calc(-.55 * var(--u)); border-radius: 50%; background: radial-gradient(circle at 35% 32%, #f0dcb8 0 15%, #8c6a46 50%, #3b2414 100%); }
#front .ts-plate::before { left: calc(1.3 * var(--u)); } #front .ts-plate::after { right: calc(1.3 * var(--u)); }
#front .ts-plate.main { font-size: max(19px, calc(4.6 * var(--u))); min-width: calc(44 * var(--u)); padding: calc(1.4 * var(--u)) calc(6 * var(--u)); color: #fff4e0; text-shadow: 0 calc(.3 * var(--u)) 0 #5a1c06;
  background: radial-gradient(circle at 14% 80%, rgba(110,40,10,.5) 0 calc(1 * var(--u)), rgba(110,40,10,0) calc(3 * var(--u))), radial-gradient(circle at 86% 22%, rgba(110,40,10,.45) 0 calc(.8 * var(--u)), rgba(110,40,10,0) calc(2.6 * var(--u))), linear-gradient(180deg, #f39a55, #d65a2c 52%, #a23a19);
  box-shadow: inset 0 calc(.35 * var(--u)) 0 rgba(255,225,190,.5), inset 0 calc(-.6 * var(--u)) 0 rgba(80,20,4,.35), 0 calc(.8 * var(--u)) 0 #2a1206, 0 calc(1.4 * var(--u)) calc(2 * var(--u)) rgba(0,0,0,.55), 0 0 calc(3 * var(--u)) rgba(255,140,60,.25); }
#front .ts-plate:hover { filter: brightness(1.1); transform: translateY(calc(-.2 * var(--u))); }
#front .ts-plate:active { transform: translateY(calc(.6 * var(--u))); box-shadow: inset 0 calc(.3 * var(--u)) 0 rgba(255,225,180,.3), 0 calc(.1 * var(--u)) 0 #24140a; filter: brightness(.95); }
#front button:focus-visible { outline: 3px solid #4ff0ff; outline-offset: 3px; }
#front .ts-line { cursor: pointer; margin: calc(1.6 * var(--u)) 0 0; }
/* 설정: ⚙ 하나 → 누르면 작은 철판 줄이 펼쳐짐 */
#front .ts-gear { margin-top: calc(2.2 * var(--u)); display: flex; align-items: center; justify-content: center; gap: calc(1 * var(--u)); flex-wrap: wrap; max-width: 92vw; }
#front .ts-gear button { font-family: "Gowun Dodum", sans-serif; font-size: max(12px, calc(1.9 * var(--u))); padding: calc(.6 * var(--u)) calc(1.4 * var(--u)); color: #f3e4c6; border: 2px solid #1e130b; border-radius: calc(.8 * var(--u));
  background: linear-gradient(180deg, #6e6658, #4b443a); box-shadow: inset 0 1px 0 rgba(255,255,255,.2), 0 calc(.4 * var(--u)) 0 #1e130b; transition: transform .12s ease-out, box-shadow .12s ease-out, filter .12s ease-out; }
#front .ts-gear button:hover { filter: brightness(1.15); }
#front .ts-gear button:active { transform: translateY(calc(.3 * var(--u))); box-shadow: inset 0 1px 0 rgba(255,255,255,.2), 0 0 0 #1e130b; }
#front .ts-cog { display: inline-flex; align-items: center; gap: .4em; }
#front .ts-cog span { font-size: .9em; }
#front .ts-gear.open .ts-cog { background: linear-gradient(180deg, #ffd23f, #c99a1c); color: #2a1a08; }
#front .ts-set { display: none; gap: calc(.8 * var(--u)); flex-wrap: wrap; justify-content: center; }
#front .ts-gear.open .ts-set { display: flex; }
#front .ts-fine { font-size: max(11px, calc(1.6 * var(--u))); color: #f1dcb8; opacity: .8; text-shadow: 0 1px 3px #000; }
#front .ts-foot { position: absolute; bottom: calc(1.4 * var(--u)); left: 0; right: 0; margin: 0; text-align: center; z-index: 3; }
/* 세로 폰: 위에서부터 쌓고, 로봇은 아래 양옆에 작게 */
@media (orientation: portrait) {
  #front { --u: min(1.55vw, .8vh); justify-content: flex-start; padding-top: 7vh; }
  #front .ts-bot { height: min(30vh, 62vw); bottom: calc(4 * var(--u) + 14px); }
  #front .ts-bot.l { left: -2vw; } #front .ts-bot.r { right: -2vw; }
  #front .ts-plate.main { min-width: 64vw; } #front .ts-plate { min-width: 40vw; }
  #front .ts-pair { flex-direction: column; align-items: center; gap: calc(1.8 * var(--u)); }
  #front .ts-pair .ts-plate { min-width: 56vw; }
}
#testTag { position: fixed; left: 8px; bottom: 8px; z-index: 80; pointer-events: none; font-size: 15px; padding: 4px 12px; border-radius: 999px; background: rgba(255,210,63,.92); color: #2a1a08; font-weight: bold; box-shadow: 0 2px 6px rgba(0,0,0,.4); }
/* 버스 지도 (마을 옮기기) — 카드는 가만히, 고른 뒤 한 컷만 움직임 */
.vcards { display: flex; gap: 16px; margin: 14px 0; }
.vcard { flex: 1; background: #2a2238; border-radius: 14px; padding: 12px; outline: 2px solid #3a3350; display: flex; flex-direction: column; gap: 6px; }
.vcard.here { outline: 3px solid var(--gold); }
.vcard.locked { opacity: .55; filter: grayscale(.7); }
.vcard .vpic { position: relative; aspect-ratio: 16/9; border-radius: 10px; overflow: hidden; background: linear-gradient(160deg, var(--vc), #1a1424); display: flex; align-items: flex-end; }
.vcard .vpic img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.vcard .vpic b { position: relative; font-family: "Black Han Sans"; font-size: 26px; padding: 6px 10px; text-shadow: 0 2px 6px #000; }
.vcard .vleague { color: var(--gold); margin: 0; }
.vcard p { margin: 0; }
.vcard button, .vcard .tag { align-self: flex-start; margin-top: auto; }
.vcard .vlock { margin-top: auto; color: #ffb38a; font-size: 14px; }
.panel.buscut { display: flex; align-items: center; justify-content: center; background: rgba(12,10,20,.96); }
.buscut { width: 100%; text-align: center; }
.buscut p { font-family: "Black Han Sans"; font-size: 34px; color: var(--gold); }
.busroad { position: relative; height: 140px; overflow: hidden; border-bottom: 6px solid #4a3b2a; }
.bus { position: absolute; bottom: 0; left: 100%; font-size: 110px; line-height: 1; animation: busPass 2s linear 1 forwards; }
.bus img { height: 130px; display: block; }
@keyframes busPass { from { left: 100%; } to { left: -30%; } }
@media (orientation: portrait), (max-height: 500px) { .vcards { gap: 8px; } .vcard { padding: 8px; } .vcard .vpic b { font-size: 18px; } .vcard .dim { display: none; } }
/* 시험 표시(?allclear)가 폰 ◀ ▶ 버튼을 덮던 것 → 버튼이 보일 때는 버튼 위로 */
body.touch[data-hub="village"][data-mode="town"] #testTag { bottom: calc(92px + env(safe-area-inset-bottom)); }
@media (orientation: portrait) { body[data-hub="village"][data-mode="town"] #testTag { bottom: calc(92px + env(safe-area-inset-bottom)); } }

/* ───────── 탑 (js/towerui.js). 가만히 있는 패널 — 움직임 없음. 배경 = 이음 탑 안 그림을 어둡게 */
.panel.towerp { background: linear-gradient(rgba(18, 14, 24, .86), rgba(18, 14, 24, .93)), url(assets/bg/stage_tower.webp?v=20261202a) center/cover; overflow: hidden; }
.panel.towerp .fit { transform-origin: top left; }
.thead { display: flex; align-items: center; gap: 12px; }
.thead h2 { margin: 0; font-size: 30px; }
.thead .tcls { margin: 2px 0 0; color: #ffe8a3; font-size: 15px; }
.tbadge { width: 64px; height: 64px; flex: none; vertical-align: middle; }
.tbadge.sm { width: 38px; height: 38px; margin-right: 8px; }
p .tbadge { width: 48px; height: 48px; }
.tghost { width: 48px; height: 48px; flex: none; vertical-align: middle; }
.tghost.sm { width: 22px; height: 22px; margin-right: 5px; }
.tbest { margin-left: auto; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; justify-content: flex-end; font-size: 13px; }
.tbest span { background: #2a2238; outline: 2px solid #3a3350; border-radius: 8px; padding: 4px 9px; }
.tbest span.on { outline-color: var(--gold); }
.tbest b { font-family: "Black Han Sans"; font-size: 20px; color: var(--gold); margin-left: 3px; }
.tbest em { font-style: normal; opacity: .65; width: 100%; text-align: right; font-size: 12px; }
.tfloors { display: flex; gap: 10px; margin: 8px 0; }
.tfl { position: relative; flex: 1; min-width: 0; background: rgba(42, 34, 56, .92); outline: 2px solid #3a3350; border-radius: 12px; padding: 6px 6px 8px; display: flex; flex-direction: column; align-items: center; text-align: center; }
.tfl.next { outline: 3px solid var(--gold); }
.tfl.done { opacity: .5; }
.tfl.keeper { background: rgba(70, 40, 40, .92); }
.tfl .tfn { align-self: flex-start; font-family: "Black Han Sans"; font-size: 20px; color: var(--gold); }
.tfl canvas { width: 116px; height: 124px; max-width: 100%; }
.tfl .tname { font-weight: bold; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.tfl small { opacity: .75; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.tfl .tface { position: absolute; right: 6px; top: 6px; width: 46px; height: 46px; border-radius: 50%; border: 2px solid var(--gold); background: #241a2e; object-fit: cover; }
.tfl .tok { position: absolute; right: 8px; bottom: 6px; font-style: normal; color: #7dff9a; font-size: 22px; }
.trew { margin: 6px 0; font-size: 15px; }
.tsw { display: inline-block; width: 16px; height: 16px; border-radius: 4px; border: 2px solid var(--ink); vertical-align: -3px; margin: 0 4px; }
.tnote { margin: 4px 0 0; }
.twant { display: inline-flex; align-items: center; justify-content: center; min-width: 46px; min-height: 46px; padding: 2px 6px; border: 2px dashed #b9a98a; border-radius: 8px; color: #b9a98a; font-size: 11px; vertical-align: middle; }
h2.tfloor { margin: 0 0 4px; }
.treg { display: flex; gap: 16px; align-items: flex-start; margin: 6px 0; }
.tregL { flex: none; width: 180px; text-align: center; background: rgba(42, 34, 56, .92); border-radius: 12px; padding: 8px; }
.tregL b { display: block; font-family: "Black Han Sans"; font-size: 20px; color: var(--gold); }
.tregR { flex: 1; min-width: 0; }
.tregR h4 { margin: 6px 0 4px; } .tregR h4 small { font-weight: normal; opacity: .7; }
.tstyles { display: flex; gap: 8px; }
.tstyles button { position: relative; flex: 1; display: flex; flex-direction: column; align-items: center; padding: 6px 4px; }
.tstyles button small { opacity: .75; font-size: 12px; }
.tstyles button i { position: absolute; right: -6px; top: -8px; font-style: normal; font-size: 11px; background: var(--gold); color: var(--ink); border-radius: 6px; padding: 1px 6px; }
.tstyles button.on, .tbias button.on { background: #e2513a; }
.tbias { display: flex; gap: 14px; margin-top: 6px; font-size: 14px; flex-wrap: wrap; }
.tbias button { padding: 2px 9px; margin-left: 2px; }
.tbn select { font: inherit; padding: 5px 8px; border-radius: 8px; border: 2px solid var(--ink); background: #3a3350; color: #fff; margin-right: 6px; }
.tcols { display: flex; gap: 6px; flex-wrap: wrap; }
.tcols button { width: 30px; height: 30px; padding: 0; border-radius: 50%; }
.tcols button.on { outline: 3px solid #fff; outline-offset: 1px; }
@media (max-height: 500px) { .panel.towerp { inset: 8px; padding: 10px 14px; } }
/* 대장간: 용접 재료 줄은 용접 도구일 때만 (.frow 의 display:flex 가 hidden 을 이겨서 늘 보였음 → 재료 버튼이 오른쪽·아래 두 군데) */
.frow[hidden] { display: none; }
/* 시험 표시(?allclear): 판이 열린 화면에서는 오른쪽 위 구석에 작게 — 나가기 같은 버튼을 덮지 않게 */
body[data-mode="menu"] #testTag { left: auto; right: 4px; bottom: auto; top: 4px; font-size: 11px; padding: 2px 8px; opacity: .85; }

/* ───── 차고 (조립·고철 덧붙이기·대장간·수리·기술 공방): 이음 차고 그림(어둡게·비네트) + 녹슨 철판 9-slice.
   border-image-width 를 border 보다 크게 → 테두리 그림은 안쪽(패딩)에 그려지고 칸 크기·줄 바꿈은 그대로(fitPanel 배율 안 흔들림).
   움직임은 누를 때만(≤.12s). 그림: tools/build_garage.py → assets/garage/ (바꾸면 ?v= 올림) */
.panel.garage { color: #f6e7cc; border-color: #1c0f07; box-shadow: inset 0 0 0 2px rgba(255,196,130,.14), inset 0 0 60px rgba(0,0,0,.65);
  background: radial-gradient(ellipse 70% 65% at 50% 48%, rgba(28,15,8,.84), rgba(28,15,8,.7) 72%, rgba(14,7,3,.86) 100%), url(assets/garage/garage_bg.webp?v=20261202a) center 40% / cover no-repeat #2a1a10; }
.panel.garage .ghead { display: flex; align-items: center; gap: 8px; color: #ffe2b0; text-shadow: 0 2px 0 #24140a, 0 0 10px rgba(0,0,0,.6); }
.panel.garage .ghead small { margin-left: 4px; color: #f6e7cc; opacity: .9; }
.panel.garage .gprop { height: 34px; width: auto; flex: none; filter: drop-shadow(0 2px 2px rgba(0,0,0,.6)); pointer-events: none; }
.panel.garage .gprop.can { margin-left: auto; height: 36px; }
/* 버튼·탭: 녹슨 철판 */
.panel.garage button { background: transparent; border-color: transparent; border-radius: 6px; color: #fff1d6; text-shadow: 0 1px 0 rgba(30,12,4,.95), 0 0 3px rgba(30,12,4,.7);
  border-image: url(assets/garage/scrap_plate.webp?v=20261202a) 32 fill / 9px / 0 stretch; box-shadow: 0 3px 0 rgba(20,9,3,.9), 0 4px 6px rgba(0,0,0,.35);
  transition: transform .12s ease-out, box-shadow .12s ease-out, filter .12s ease-out; }
.panel.garage button:hover:not(:disabled) { background: transparent; filter: brightness(1.14); }
.panel.garage button:active:not(:disabled) { box-shadow: 0 1px 0 rgba(20,9,3,.9); }
.panel.garage button.big, .panel.garage .fsave, .panel.garage .esave { border-image-source: url(assets/garage/scrap_hot.webp?v=20261202a); color: #fff6e6; }
/* 고른 것(탭·도구·칸): 같은 철판 + 금빛 테 + 금빛 글 */
.panel.garage :is(.tabs button.on, .arow button.on, .frow.tools button.on, .slots button.on, .rlist button.sel) { background: transparent; color: var(--gold); outline: none;
  box-shadow: 0 0 0 2px var(--gold), 0 0 10px rgba(255,190,60,.45), 0 3px 0 rgba(20,9,3,.9); filter: brightness(1.1); }
.panel.garage .tabs { flex-wrap: wrap; }
.panel.garage .rlist button.broke { border-image-source: url(assets/garage/scrap_hot.webp?v=20261202a); }
/* 카드·칸: 녹슨 테 + 어두운 철판 안쪽(글이 많아 대비 우선) */
.panel.garage :is(.cand, .bitem, .fitem, .estat, .fstat, .ekey, .kits, .badge) { background: transparent; border: 0 solid transparent; border-radius: 6px;
  border-image: url(assets/garage/scrap_card.webp?v=20261202a) 32 fill / 10px / 0 stretch; }
.panel.garage .ekey { border-width: 2px; }
.panel.garage .ekey.sel { outline: 2px solid #7cf; } .panel.garage .ekey.hit { outline: 2px solid var(--gold); }
.panel.garage .cand.on, .panel.garage .bitem.forged { outline: 2px solid var(--gold); }
.panel.garage :is(.cand, .bitem, .fitem) small, .panel.garage .dim { color: #f1dcb8; }
.panel.garage .stats { color: #a9dcff; }
/* 그리는 판(대장간·덧붙이기·기술 공방·수리): 쇠 테두리 */
.panel.garage :is(.fcv, .acv, .ecv, .rright canvas) { border-color: #24140a; box-shadow: 0 0 0 2px rgba(150,80,40,.55), 0 4px 10px rgba(0,0,0,.5); }
/* 조립: 로봇 미리보기는 작업대 앞에 섬 */
.panel.garage .bl canvas { background: url(assets/garage/prop_workbench.webp?v=20261202a) 50% 96% / 94% auto no-repeat, radial-gradient(ellipse 60% 40% at 50% 92%, rgba(0,0,0,.45), transparent 70%); }
.panel.garage .sb i { background: linear-gradient(90deg, #d65a2c, var(--gold)); }
/* 랭킹의 탑: 최고 층 순위판·설계도 */
.tboard { list-style: none; margin: 6px auto; padding: 0; max-width: 420px; text-align: left; font-size: 17px; }
.tboard li { padding: 4px 8px; border-bottom: 1px dashed rgba(255, 226, 168, .22); }
.tboard li i { display: inline-block; width: 26px; font-style: normal; opacity: .65; }
.tboard li b { float: right; color: var(--gold); }
.tboard li.me { color: #7dff9a; font-weight: bold; }
.thead .tcls button { font-size: 13px; padding: 3px 9px; }
.thead .tcls button.on { outline: 2px solid var(--gold); }
.tbp { display: flex; flex-wrap: wrap; gap: 4px 12px; margin: 2px 0 6px; font-size: 14px; }
