/* Dungeon Quest — DOM UI (mobile-first) */
:root {
  --bg: #0b1220; --panel: #131c2e; --panel2: #1a2438; --border: #c8963c; --border-dim: #6b5530;
  --text: #e8e2d0; --muted: #9aa3b8; --gold: #ffd23c; --hp: #d83b3b; --mp: #3b7bd8; --xp: #7bd83b;
  --gain: #5fe36a; --loss: #ff5c5c; --radius: 10px; --safe-b: env(safe-area-inset-bottom, 0px); --safe-t: env(safe-area-inset-top, 0px); --safe-l: env(safe-area-inset-left, 0px); --safe-r: env(safe-area-inset-right, 0px); --edge: 8px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; height: 100%; background: #05070c; overflow: hidden; font-family: 'Trebuchet MS', 'Segoe UI', Verdana, sans-serif; color: var(--text); font-size: 14px; }
body { overscroll-behavior: none; touch-action: none; user-select: none; -webkit-user-select: none; }
#app { position: fixed; inset: 0; }
#game-container { position: absolute; inset: 0; }
#game-container canvas { display: block; }
#vignette { position: absolute; inset: 0; pointer-events: none; background: radial-gradient(ellipse at center, rgba(0,0,0,0) 55%, rgba(0,0,0,0.35) 100%); }
#ui { position: absolute; inset: 0; pointer-events: none; }
#ui.touch { --edge: 20px; }  /* phones: keep HUD away from rounded corners / camera bar */
#ui > * { pointer-events: auto; }
.hidden { display: none !important; }
.muted { color: var(--muted); } .small { font-size: 12px; } .center { text-align: center; }
h4 { margin: 10px 0 6px; color: var(--gold); font-size: 13px; letter-spacing: .5px; text-transform: uppercase; }
img { -webkit-user-drag: none; }
button { font-family: inherit; }
.btn { background: linear-gradient(#2a3650, #1a2438); color: var(--text); border: 1px solid var(--border-dim); border-radius: 8px; padding: 8px 14px; font-size: 14px; cursor: pointer; box-shadow: 0 2px 0 #0a0f1a; }
.btn:hover { border-color: var(--border); } .btn:active { transform: translateY(1px); box-shadow: none; }
.btn.primary { background: linear-gradient(#c8963c, #8a6120); color: #1a1208; border-color: #ffd97a; font-weight: bold; }
.btn.danger { border-color: #7a2a2a; color: #ffb0b0; }
.btn.small { padding: 4px 10px; font-size: 12px; } .btn.big { padding: 14px 22px; font-size: 17px; }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
.btn small { display: block; font-size: 11px; font-weight: normal; opacity: .8; }

/* loading */
#loading { position: fixed; inset: 0; background: #05070c; display: flex; align-items: center; justify-content: center; z-index: 50; color: var(--text); }
#loading.hidden { display: none; }
.loading-box { text-align: center; width: 280px; }
.loading-title { font-size: 28px; font-weight: bold; letter-spacing: 3px; color: var(--gold); text-shadow: 0 2px 0 #4a3010, 0 0 20px rgba(255,180,60,.4); margin-bottom: 16px; }
.loading-bar { height: 10px; background: #1a2438; border: 1px solid var(--border-dim); border-radius: 6px; overflow: hidden; }
#loading-fill { height: 100%; width: 0; background: linear-gradient(90deg, #8a6120, #ffd23c); transition: width .2s; }
#loading-text { margin-top: 8px; font-size: 12px; color: var(--muted); }

/* HUD */
#hud { position: absolute; inset: 0; pointer-events: none; }
#hud > * { pointer-events: auto; }
.hud-left { position: absolute; left: calc(var(--edge) + var(--safe-l)); top: calc(8px + var(--safe-t)); display: flex; gap: 8px; align-items: flex-start; }
.hud-portrait-wrap { position: relative; width: 60px; height: 64px; background: #0d1424; border: 2px solid var(--border); border-radius: 8px; overflow: hidden; cursor: pointer; }
.portrait { width: 56px; height: 60px; image-rendering: pixelated; }
.hud-level { position: absolute; right: -2px; bottom: -2px; background: var(--gold); color: #1a1208; font-weight: bold; font-size: 12px; padding: 1px 6px; border-radius: 8px 0 6px 0; }
.hud-bars { width: 180px; }
.hud-top { display: flex; justify-content: space-between; align-items: center; font-size: 12px; margin-bottom: 3px; text-shadow: 0 1px 2px #000; }
.hud-name { font-weight: bold; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 120px; }
.hud-gold { display: flex; align-items: center; gap: 3px; color: var(--gold); font-weight: bold; }
.hud-gold img { width: 16px; height: 16px; }
.bar { position: relative; height: 13px; background: #0d1424; border: 1px solid #2a3650; border-radius: 4px; margin-bottom: 3px; overflow: hidden; }
.bar .fill { height: 100%; transition: width .2s; }
.bar.hp .fill { background: linear-gradient(#ff6a6a, var(--hp)); } .bar.mp .fill { background: linear-gradient(#6aa6ff, var(--mp)); } .bar.xp .fill { background: linear-gradient(#b0ff6a, var(--xp)); }
.bar.xp { height: 8px; }
.bar-text { position: absolute; inset: 0; font-size: 10px; line-height: 12px; text-align: center; text-shadow: 0 1px 2px #000; }
.bar.xp .bar-text { font-size: 8px; line-height: 7px; }
.hud-buffs { display: flex; gap: 4px; flex-wrap: wrap; }
.buff { font-size: 10px; background: rgba(200,150,60,.25); border: 1px solid var(--border-dim); border-radius: 4px; padding: 1px 5px; }
.hud-right { position: absolute; right: calc(var(--edge) + var(--safe-r)); top: calc(8px + var(--safe-t)); display: flex; gap: 6px; }
.hud-btn { width: 44px; height: 44px; border-radius: 8px; border: 1px solid var(--border-dim); background: rgba(13,20,36,.85); padding: 0; cursor: pointer; }
.hud-btn img { width: 40px; height: 40px; }
.hud-btn:hover { border-color: var(--border); }
.hud-center { position: absolute; left: 50%; top: calc(8px + var(--safe-t)); transform: translateX(-50%); text-align: center; pointer-events: none; max-width: 40vw; }
.hud-map { font-size: 12px; color: var(--gold); text-shadow: 0 1px 2px #000; letter-spacing: 1px; }
.hud-quest { font-size: 11px; text-shadow: 0 1px 2px #000; }
.quest-line { display: flex; align-items: center; justify-content: center; gap: 4px; }
.quest-line img { width: 14px; height: 14px; }

/* tutorial */
#tutorial { position: absolute; left: 50%; top: calc(70px + var(--safe-t)); transform: translateX(-50%); width: min(92vw, 420px); background: rgba(13,20,36,.92); border: 1px solid var(--border); border-radius: var(--radius); padding: 8px 12px 10px; text-align: center; box-shadow: 0 4px 20px rgba(0,0,0,.5); z-index: 5; }
.tut-step { font-size: 10px; color: var(--gold); letter-spacing: 1px; text-transform: uppercase; }
.tut-text { font-size: 14px; margin: 4px 0 6px; }
.tut-text b { color: var(--gold); }
.tut-skip { background: none; border: none; color: var(--muted); font-size: 11px; text-decoration: underline; cursor: pointer; }
.tut-highlight { animation: pulse 1s infinite; box-shadow: 0 0 0 3px var(--gold), 0 0 18px var(--gold) !important; }
@keyframes pulse { 0%, 100% { filter: brightness(1); } 50% { filter: brightness(1.5); } }

/* boss bar */
#boss-bar { position: absolute; left: 50%; bottom: calc(120px + var(--safe-b)); transform: translateX(-50%); width: min(80vw, 460px); text-align: center; pointer-events: none; }
.boss-name { font-size: 13px; font-weight: bold; color: #ff8080; text-shadow: 0 1px 3px #000; letter-spacing: 1px; }
.boss-track { height: 12px; background: #0d1424; border: 1px solid #7a2a2a; border-radius: 6px; overflow: hidden; }
.boss-fill { height: 100%; background: linear-gradient(#ff6a6a, #a01818); transition: width .15s; }

/* controls */
#controls { position: absolute; inset: 0; pointer-events: none; }
#controls > * { pointer-events: auto; }
#joystick { position: absolute; left: calc(22px + var(--safe-l)); bottom: calc(22px + var(--safe-b)); width: 130px; height: 130px; border-radius: 50%; background: rgba(13,20,36,.45); border: 2px solid rgba(200,150,60,.4); touch-action: none; display: none; }
#ui.touch #joystick { display: block; }
#joystick .stick { position: absolute; left: 50%; top: 50%; width: 56px; height: 56px; margin: -28px 0 0 -28px; border-radius: 50%; background: radial-gradient(circle at 35% 35%, #4a5a80, #1a2438); border: 2px solid var(--border); box-shadow: 0 3px 8px rgba(0,0,0,.6); }
#actions { position: absolute; right: calc(14px + var(--safe-r)); bottom: calc(16px + var(--safe-b)); display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
.action-cluster { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
.skill-row { display: flex; gap: 8px; }
.main-row { display: flex; gap: 10px; align-items: flex-end; }
.btn-attack, .btn-skill, .btn-potion { position: relative; border-radius: 50%; border: 2px solid var(--border); background: radial-gradient(circle at 40% 35%, #2a3650, #0d1424); padding: 0; overflow: hidden; cursor: pointer; touch-action: none; box-shadow: 0 3px 10px rgba(0,0,0,.6); }
.btn-attack { width: 84px; height: 84px; border-width: 3px; }
.btn-attack img { width: 66px; height: 66px; }
.btn-skill { width: 58px; height: 58px; } .btn-potion { width: 54px; height: 54px; }
.btn-skill .cd, .btn-attack .cd { position: absolute; left: 0; right: 0; bottom: 0; height: 0; background: rgba(0,0,0,.6); pointer-events: none; }
.btn-skill .key, .btn-potion .key { position: absolute; left: 4px; top: 2px; font-size: 10px; color: var(--muted); }
.btn-skill .mp { position: absolute; right: 3px; bottom: 2px; font-size: 9px; color: #8ab4ff; text-shadow: 0 1px 2px #000; }
.btn-skill.nomp { border-color: #6a4a4a; filter: saturate(.4); }
.btn-potion .qty { position: absolute; right: 4px; bottom: 2px; font-size: 11px; font-weight: bold; color: var(--gold); text-shadow: 0 1px 2px #000; }
.btn-potion.empty { opacity: .5; }
.btn-attack.active, .btn-skill.active, .btn-potion.active { filter: brightness(1.4); transform: scale(.96); }
.btn-interact { background: linear-gradient(#c8963c, #8a6120); color: #1a1208; font-weight: bold; border: 2px solid #ffd97a; border-radius: 10px; padding: 10px 18px; font-size: 15px; box-shadow: 0 3px 10px rgba(0,0,0,.6); animation: pulse 1.2s infinite; cursor: pointer; }
.icon-canvas { display: block; }

/* toasts */
#toasts { position: absolute; right: calc(12px + var(--safe-r)); top: calc(64px + var(--safe-t)); display: flex; flex-direction: column; gap: 6px; align-items: flex-end; pointer-events: none; z-index: 6; }
.toast { background: rgba(13,20,36,.92); border: 1px solid var(--border-dim); border-left: 4px solid var(--border); padding: 6px 12px; border-radius: 6px; font-size: 13px; opacity: 0; transform: translateX(20px); transition: all .3s; max-width: 60vw; }
.toast.show { opacity: 1; transform: none; }
.toast.warn { border-left-color: #ff5c5c; } .toast.quest { border-left-color: #7bd83b; } .toast.levelup { border-left-color: var(--gold); color: var(--gold); font-weight: bold; }
.toast.map { border-left-color: #6aa6ff; font-size: 16px; letter-spacing: 1px; } .toast.boss { border-left-color: #ff3030; color: #ff9090; } .toast.buff { border-left-color: #c561ff; }
.screen-flash { position: absolute; inset: 0; pointer-events: none; animation: flash .9s ease-out forwards; }
.screen-flash.levelup { background: radial-gradient(circle, rgba(255,210,60,.5), rgba(255,210,60,0) 70%); }
@keyframes flash { from { opacity: 1; } to { opacity: 0; } }

/* panels */
#panel-layer { position: absolute; inset: 0; background: rgba(3,5,10,.6); display: flex; align-items: center; justify-content: center; z-index: 10; padding: 8px; }
.panel { width: min(96vw, 820px); max-height: min(94vh, 640px); background: var(--panel); border: 2px solid var(--border); border-radius: var(--radius); display: flex; flex-direction: column; box-shadow: 0 10px 40px rgba(0,0,0,.7); }
.panel-head { display: flex; justify-content: space-between; align-items: center; padding: 8px 12px; border-bottom: 1px solid var(--border-dim); background: var(--panel2); border-radius: var(--radius) var(--radius) 0 0; }
.panel-title { font-weight: bold; color: var(--gold); letter-spacing: 1px; font-size: 16px; }
.btn-close { background: none; border: 1px solid var(--border-dim); color: var(--text); width: 34px; height: 34px; border-radius: 8px; font-size: 16px; cursor: pointer; }
.panel-body { padding: 10px 12px; overflow: auto; -webkit-overflow-scrolling: touch; touch-action: pan-y; }

/* inventory */
.inv-layout { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 640px) { .inv-layout { grid-template-columns: 1fr; } }
.inv-toolbar { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.inv-toolbar .gold { display: flex; align-items: center; gap: 4px; color: var(--gold); } .inv-toolbar img { width: 18px; }
.inv-toolbar .expand { margin-left: auto; display: inline-flex; align-items: center; gap: 3px; border-color: var(--border); }
.inv-toolbar .expand img { width: 14px; } .inv-toolbar .expand.cant { opacity: .6; }
.inv-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 5px; }
.inv-slot { position: relative; aspect-ratio: 1; background: #0d1424; border: 2px solid #2a3650; border-radius: 6px; display: flex; align-items: center; justify-content: center; cursor: pointer; }
.inv-slot.filled:hover { filter: brightness(1.2); } .inv-slot.selected { box-shadow: 0 0 0 2px var(--gold); }
.inv-slot .qty { position: absolute; right: 3px; bottom: 1px; font-size: 11px; font-weight: bold; text-shadow: 0 1px 2px #000; }
.inv-slot .lvl { position: absolute; left: 3px; top: 1px; font-size: 10px; color: var(--muted); } .inv-slot .lvl.bad { color: var(--loss); font-weight: bold; }
.inv-slot .up { position: absolute; right: 2px; top: 0; font-size: 11px; color: var(--gain); text-shadow: 0 1px 2px #000; }
.inv-slot .plus { position: absolute; left: 3px; bottom: 1px; font-size: 10px; font-weight: bold; color: var(--gold); text-shadow: 0 1px 2px #000; }
.upgrade-box { background: #0d1424; border: 1px solid var(--border-dim); border-radius: 8px; padding: 8px 10px; margin-top: 10px; }
.upgrade-mats { display: flex; flex-wrap: wrap; gap: 6px 14px; margin: 8px 0 2px; }
.upgrade-mat { display: flex; align-items: center; gap: 4px; font-size: 12px; }
.upgrade-mat.ok { color: var(--gain); } .upgrade-mat.bad { color: var(--loss); }
.inv-slot.mini { width: 40px; height: 40px; aspect-ratio: auto; }
.inv-equipped { margin-top: 10px; }
.equipped-row { display: flex; gap: 5px; flex-wrap: wrap; margin-top: 4px; }
.inv-detail { min-height: 200px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }

/* item card & compare */
.item-card { background: var(--panel2); border: 1px solid var(--border-dim); border-left-width: 4px; border-radius: 8px; padding: 8px 10px; margin-bottom: 8px; }
.item-card.empty { opacity: .7; }
.card-title { font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); margin-bottom: 4px; }
.card-head { display: flex; gap: 10px; align-items: center; }
.card-name { font-weight: bold; font-size: 15px; } .card-meta { font-size: 11px; color: var(--muted); }
.card-req { display: flex; gap: 10px; flex-wrap: wrap; font-size: 11px; margin: 6px 0; }
.card-req .ok { color: var(--gain); } .card-req .bad { color: var(--loss); font-weight: bold; }
.card-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 14px; }
.stat-row { display: flex; justify-content: space-between; font-size: 12px; padding: 1px 0; border-bottom: 1px dashed rgba(255,255,255,.06); }
.stat-row.affix span::before { content: '✦ '; color: #c561ff; }
.card-desc { font-size: 12px; margin-top: 6px; color: #d8d0b8; font-style: italic; }
.card-value { font-size: 11px; margin-top: 4px; }
.compare { background: #0d1424; border: 1px solid var(--border-dim); border-radius: 8px; padding: 8px 10px; margin-bottom: 8px; }
.compare-header { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; font-size: 12px; margin-bottom: 6px; }
.compare-table { font-size: 12px; }
.compare-row { display: grid; grid-template-columns: 1.4fr 1fr 1fr 1fr; padding: 2px 0; border-bottom: 1px dashed rgba(255,255,255,.06); }
.compare-row.head { color: var(--muted); font-size: 10px; text-transform: uppercase; }
.compare-row span:not(:first-child) { text-align: right; }
.gain { color: var(--gain); font-weight: bold; } .loss { color: var(--loss); font-weight: bold; } .same { color: var(--muted); }
.compare-verdict { margin-top: 6px; text-align: center; font-size: 13px; }

/* floating item tooltip */
#tooltip { position: absolute; z-index: 30; width: 300px; max-width: 92vw; pointer-events: none; filter: drop-shadow(0 8px 18px rgba(0,0,0,.7)); }
#tooltip.pinned { pointer-events: auto; }
#tooltip .tip-body { background: rgba(9,14,26,.97); border: 1px solid var(--border); border-radius: 8px; padding: 6px; }
#tooltip .item-card { margin-bottom: 4px; }
#tooltip .compare { margin-bottom: 4px; }
#tooltip .actions { margin-top: 4px; }
#tooltip .card-stats { grid-template-columns: 1fr; }

/* character */
.char-layout { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 640px) { .char-layout { grid-template-columns: 1fr; } }
.char-header { display: flex; gap: 12px; align-items: center; }
.char-preview { width: 112px; height: 120px; image-rendering: pixelated; background: #0d1424; border: 1px solid var(--border-dim); border-radius: 8px; }
.char-name { font-size: 18px; font-weight: bold; color: var(--gold); }
.equip-slots { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.equip-slot { position: relative; height: 62px; background: #0d1424; border: 2px solid #2a3650; border-radius: 6px; display: flex; flex-direction: column; align-items: center; justify-content: center; cursor: pointer; }
.equip-slot.empty canvas { opacity: .3; } .equip-slot.disabled { opacity: .35; cursor: not-allowed; }
.slot-label { font-size: 10px; color: var(--muted); position: absolute; bottom: 2px; }
.char-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 14px; }
.stat-group h4 { margin-top: 4px; }
.skill-list .skill-item, .skill-mini .skill-item { display: flex; gap: 8px; align-items: center; margin: 6px 0; font-size: 12px; }

/* quests */
.quest-card { background: var(--panel2); border: 1px solid var(--border-dim); border-radius: 8px; padding: 8px 10px; margin-bottom: 8px; }
.quest-card.done { opacity: .6; }
.quest-title { display: flex; align-items: center; gap: 6px; } .quest-title img { width: 18px; }
.quest-progress { display: flex; align-items: center; gap: 8px; margin: 6px 0; font-size: 12px; }
.quest-progress .track { flex: 1; height: 8px; background: #0d1424; border-radius: 4px; overflow: hidden; }
.quest-progress .fill { height: 100%; background: linear-gradient(90deg, #8a6120, var(--gold)); }

/* map */
.map-layout { display: grid; grid-template-columns: auto 1fr; gap: 16px; }
@media (max-width: 640px) { .map-layout { grid-template-columns: 1fr; } }
.minimap { border: 1px solid var(--border-dim); border-radius: 6px; image-rendering: pixelated; max-width: 100%; }
.area-card { background: var(--panel2); border: 1px solid var(--border-dim); border-radius: 8px; padding: 8px 10px; margin-bottom: 8px; display: flex; flex-direction: column; gap: 4px; }
.area-card.locked { opacity: .5; } .tag { color: var(--gain); font-size: 12px; }

/* menu */
.menu-list { display: flex; flex-direction: column; gap: 8px; max-width: 320px; margin: 0 auto 12px; }
.help { border-top: 1px solid var(--border-dim); padding-top: 6px; }

/* overlays */
#overlay-layer { position: absolute; inset: 0; background: rgba(3,5,10,.75); display: flex; align-items: center; justify-content: center; z-index: 12; }
.overlay-box { background: var(--panel); border: 2px solid var(--border); border-radius: var(--radius); padding: 20px 26px; text-align: center; width: min(92vw, 420px); }
.overlay-box h2 { margin: 0 0 8px; color: var(--gold); }
.overlay-box.death h2 { color: #ff6a6a; }
.stats-grid { display: grid; grid-template-columns: 1fr auto; gap: 4px 16px; text-align: left; margin: 10px 0; }

/* screens */
#screen-layer { position: absolute; inset: 0; z-index: 8; overflow: auto; touch-action: pan-y; }
.screen { min-height: 100%; display: flex; flex-direction: column; align-items: center; padding: calc(16px + var(--safe-t)) 12px calc(16px + var(--safe-b)); }
.screen.title { justify-content: center; gap: 18px; }
.title-logo { text-align: center; }
.logo-main { font-size: clamp(34px, 8vw, 64px); font-weight: 900; letter-spacing: 4px; color: var(--gold); text-shadow: 0 3px 0 #4a3010, 0 0 30px rgba(255,180,60,.5), 0 6px 18px rgba(0,0,0,.8); }
.logo-sub { color: var(--muted); letter-spacing: 3px; font-size: 13px; }
.title-heroes { display: flex; gap: 12px; }
.title-heroes img { height: clamp(110px, 24vh, 170px); filter: drop-shadow(0 6px 10px rgba(0,0,0,.7)); }
.title-buttons { display: flex; flex-direction: column; gap: 10px; width: min(90vw, 320px); }
.title-buttons .btn { width: 100%; }
.screen.create { background: rgba(5,7,12,.85); }
.create-head { display: flex; align-items: center; gap: 12px; width: 100%; max-width: 980px; }
.create-head h2 { margin: 0; color: var(--gold); }
.create-layout { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; width: 100%; max-width: 980px; }
@media (max-width: 760px) { .create-layout { grid-template-columns: 1fr; } }
.create-col { background: var(--panel); border: 1px solid var(--border-dim); border-radius: var(--radius); padding: 10px 12px; }
.class-cards { display: flex; gap: 6px; }
.class-card { flex: 1; background: #0d1424; border: 2px solid #2a3650; border-radius: 8px; padding: 6px; text-align: center; cursor: pointer; font-size: 12px; }
.class-card img { width: 100%; max-width: 90px; }
.class-card.selected { border-color: var(--gold); box-shadow: 0 0 12px rgba(255,210,60,.35); }
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; margin: 8px 0; }
.stat-grid span { background: #0d1424; border-radius: 6px; padding: 3px; text-align: center; display: flex; flex-direction: column; }
.stat-grid small { color: var(--muted); font-size: 10px; }
.preview-wrap { display: flex; align-items: center; justify-content: center; gap: 10px; background: #0d1424; border: 1px solid var(--border-dim); border-radius: 8px; padding: 8px; }
.create-preview { width: 168px; height: 180px; image-rendering: pixelated; }
.create-preview-weapon { width: 60px; height: 60px; }
.part-row { display: flex; align-items: center; gap: 6px; margin: 6px 0; }
.part-label { width: 60px; color: var(--muted); font-size: 12px; } .part-name { flex: 1; text-align: center; font-size: 13px; }
.weapon-choice { display: flex; gap: 8px; align-items: center; background: #0d1424; border: 2px solid #2a3650; border-radius: 8px; padding: 4px 8px; margin: 4px 0; cursor: pointer; }
.weapon-choice.selected { border-color: var(--gold); }
.name-input { width: 100%; padding: 10px; font-size: 16px; background: #0d1424; border: 1px solid var(--border-dim); color: var(--text); border-radius: 8px; margin-bottom: 12px; }
.start-btn { width: 100%; margin-bottom: 10px; }

/* landscape-only: shown on touch devices held in portrait */
#rotate-overlay { position: absolute; inset: 0; z-index: 40; background: #05070c; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; text-align: center; padding: 20px; }
.rotate-title { font-size: 22px; font-weight: bold; color: var(--gold); letter-spacing: 1px; }
.rotate-phone { width: 46px; height: 84px; border: 4px solid var(--gold); border-radius: 10px; position: relative; animation: rotatePhone 1.8s ease-in-out infinite; }
.rotate-phone::after { content: ''; position: absolute; left: 50%; bottom: 6px; width: 10px; height: 10px; margin-left: -5px; border-radius: 50%; background: var(--gold); }
@keyframes rotatePhone { 0%, 20% { transform: rotate(0); } 60%, 100% { transform: rotate(-90deg); } }

/* narrow / portrait phones: HUD in two rows (portrait+bars | buttons) and the trackers under them */
@media (max-width: 600px) {
  .hud-portrait-wrap { width: 50px; height: 54px; }
  .portrait { width: 46px; height: 50px; }
  .hud-bars { width: 138px; }
  .hud-name { max-width: 90px; font-size: 11px; }
  .hud-right { top: calc(6px + var(--safe-t)); gap: 4px; }
  .hud-btn { width: 36px; height: 36px; } .hud-btn img { width: 32px; height: 32px; }
  .hud-left { top: calc(6px + var(--safe-t)); }
  .hud-right { top: calc(48px + var(--safe-t)); }
  .hud-center { left: 8px; top: calc(66px + var(--safe-t)); transform: none; text-align: left; max-width: 52vw; }
  .quest-line { justify-content: flex-start; }
  #tutorial { top: calc(104px + var(--safe-t)); width: 94vw; }
  #toasts { top: calc(150px + var(--safe-t)); }
  #boss-bar { bottom: calc(150px + var(--safe-b)); }
  .toast { max-width: 80vw; font-size: 12px; }
}

@media (max-height: 480px) {
  .hud-bars { width: 140px; } .btn-attack { width: 68px; height: 68px; } .btn-attack img { width: 54px; height: 54px; } .btn-skill { width: 48px; height: 48px; } .btn-potion { width: 46px; height: 46px; }
  #joystick { width: 110px; height: 110px; } #tutorial { top: calc(58px + var(--safe-t)); padding: 4px 10px 6px; } .tut-text { font-size: 12px; }
}
