html, body { height: 100%; overscroll-behavior: none; -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent; }
body { position: fixed; inset: 0; width: 100%; overflow: hidden; }
button, a, canvas { -webkit-touch-callout: none; -webkit-user-drag: none; }
#app { position: fixed; inset: 0; height: 100dvh; background: radial-gradient(ellipse at 50% 30%, #2a1a14 0%, #0c0807 75%); overflow: hidden; user-select: none; -webkit-user-select: none; }
#game { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); image-rendering: pixelated; image-rendering: crisp-edges; touch-action: none; background: #0c0807; cursor: crosshair; }
#game.menu { cursor: default; }

/* ---------- HUD ---------- */
#hud { position: absolute; inset: 0; pointer-events: none; font-family: var(--font-display); font-size: clamp(8px, 1.5vmin + 4px, 12px); text-shadow: 2px 2px 0 #000; padding: max(8px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) 8px max(10px, env(safe-area-inset-left)); }
.hud-tl { position: absolute; left: max(10px, env(safe-area-inset-left)); top: 10px; width: min(44vw, 260px); }
.hud-tr { position: absolute; right: max(10px, env(safe-area-inset-right)); top: 10px; text-align: right; display: grid; gap: 6px; justify-items: end; }
.bar { position: relative; height: 18px; background: #0b0706; border: 2px solid #000; box-shadow: 0 0 0 2px #5a4a40, 3px 3px 0 2px #000; margin-bottom: 8px; overflow: hidden; }
.bar i { position: absolute; inset: 0 auto 0 0; width: 100%; transition: width 0.12s steps(4); }
.bar span { position: absolute; inset: 0; display: grid; place-items: center; font-size: 0.85em; }
.bar.hp i { background: linear-gradient(#ff6a55 0 40%, #d8302a 40% 70%, #8f1c1c 70%); }
.bar.xp { height: 12px; }
.bar.xp i { background: linear-gradient(#a8f0ff 0 40%, #46c8ff 40% 70%, #1f7ab8 70%); width: 0; }
.bar.xp span { font-size: 0.7em; }
.bar.boss { height: 16px; margin: 6px auto 0; width: min(70vw, 420px); }
.bar.boss i { background: linear-gradient(#ffb36a 0 40%, #ee7939 40% 70%, #a8401a 70%); }
.weapon-line { font-size: 0.8em; line-height: 1.5; }
.zone-line { color: var(--gold); }
.stat-line { font-size: 0.9em; }
.gold { color: var(--gold); }
.hud-btns { display: flex; gap: 6px; pointer-events: auto; }
.mini { width: 34px; height: 34px; background: var(--surface-2); border: 2px solid #5a4a40; box-shadow: 3px 3px 0 #000; font-family: var(--font-display); font-size: 12px; padding: 0; }
.mini:hover { background: #3a2c24; border-color: var(--accent); }
.boss-bar { position: absolute; left: 50%; transform: translateX(-50%); width: min(90vw, 420px); top: 112px; text-align: center; color: var(--accent); }
@media (min-aspect-ratio: 1/1) { .boss-bar { top: 10px; width: clamp(140px, calc(100vw - 560px), 420px); } }
.banner { position: absolute; left: 0; right: 0; top: 34%; text-align: center; font-size: clamp(14px, 4vmin, 30px); color: var(--ink); opacity: 0; letter-spacing: 2px; }
.banner.show { animation: banner 2.4s steps(24) both; }
.banner small { display: block; margin-top: 12px; font-size: 0.45em; color: var(--accent-2); }
@keyframes banner { 0% { opacity: 0; transform: scale(1.4); } 12% { opacity: 1; transform: scale(1); } 80% { opacity: 1; } 100% { opacity: 0; } }

body:not(.touch) .special, body:not(.touch) .dash, body:not(.touch) #stick { display: none; }
body.touch #hud .special, body.touch #hud .dash, body.touch #hud #stick { display: grid; }
body.touch #hud .special, body.touch #hud .dash { touch-action: none; }
.special { position: absolute; right: max(16px, env(safe-area-inset-right)); bottom: max(16px, env(safe-area-inset-bottom)); width: 96px; height: 96px; background: #1a1210; border: 3px solid var(--accent-2); box-shadow: 4px 4px 0 #000, inset 0 0 0 2px #000; pointer-events: auto; overflow: hidden; font-family: var(--font-display); font-size: 8px; line-height: 1.4; color: var(--ink); text-shadow: 2px 2px 0 #000; display: grid; place-content: center; text-align: center; padding: 0; }
.special i { position: absolute; inset: auto 0 0 0; height: 100%; background: repeating-linear-gradient(0deg, #1d6a7a 0 4px, #2b8fa3 4px 8px); opacity: 0.8; transform-origin: bottom; transition: transform 0.1s steps(5); }
.special span, .special small { position: relative; }
.special small { display: block; margin-top: 6px; color: var(--accent-2); font-size: 7px; }
.special.ready { animation: pulse 0.9s steps(2) infinite; border-color: var(--gold); }
.special.ready i { background: repeating-linear-gradient(0deg, #8a5a10 0 4px, #c8861c 4px 8px); }
@keyframes pulse { 50% { box-shadow: 4px 4px 0 #000, 0 0 0 4px rgba(255, 201, 60, 0.45); } }
body.touch .special small { display: none; }
.dash { position: absolute; right: calc(max(16px, env(safe-area-inset-right)) + 96px + 14px); bottom: max(16px, env(safe-area-inset-bottom)); width: 72px; height: 72px; background: #1a1210; border: 3px solid #5a4a40; box-shadow: 4px 4px 0 #000, inset 0 0 0 2px #000; pointer-events: auto; overflow: hidden; font-family: var(--font-display); font-size: 8px; color: var(--ink); text-shadow: 2px 2px 0 #000; place-content: center; text-align: center; padding: 0; }
.dash i { position: absolute; inset: auto 0 0 0; height: 100%; background: repeating-linear-gradient(0deg, #1d6a7a 0 4px, #2b8fa3 4px 8px); opacity: 0.7; transform-origin: bottom; }
.dash span { position: relative; }
.dash.ready { border-color: var(--accent-2); }
.dash:active, .special:active { filter: brightness(1.4); }

#stick { position: absolute; left: max(16px, env(safe-area-inset-left)); bottom: max(16px, env(safe-area-inset-bottom)); width: 144px; height: 144px; border: 3px solid rgba(253, 238, 232, 0.45); border-radius: 50%; background: rgba(20, 14, 11, 0.4); pointer-events: auto; touch-action: none; }
#stick i { position: absolute; left: 50%; top: 50%; width: 60px; height: 60px; margin: -30px 0 0 -30px; pointer-events: none; border-radius: 50%; background: rgba(238, 121, 57, 0.75); border: 3px solid #fdeee8; }

/* ---------- Screens ---------- */
.screen { position: absolute; inset: 0; display: grid; place-items: center; overflow-y: auto; padding: 12px; background: linear-gradient(180deg, rgba(10, 6, 8, 0.55), rgba(10, 6, 8, 0.15) 40%, rgba(10, 6, 8, 0.8)); }
.screen.dim { background: rgba(8, 5, 7, 0.78); z-index: 5; }
.title-inner { width: min(860px, 100%); display: grid; gap: 10px; justify-items: center; text-align: center; margin: auto; }
.logo { margin: 0; font-family: var(--font-display); font-weight: 400; font-size: clamp(26px, 7.5vmin + 4px, 68px); line-height: 1; letter-spacing: 2px; display: flex; gap: 0.12em; flex-wrap: wrap; justify-content: center; }
.logo span { color: #ffd37a; text-shadow: 0 0.06em 0 #ff9a3c, 0 0.12em 0 #ee5a2a, 0 0.18em 0 #a8301a, 0 0.24em 0 #5a1410, 0.08em 0.3em 0 #000; }
.logo span:last-child { color: #ffe9c8; text-shadow: 0 0.06em 0 #8be5f5, 0 0.12em 0 #46a8d8, 0 0.18em 0 #1f5a8a, 0 0.24em 0 #0e2a4a, 0.08em 0.3em 0 #000; }
.tag { margin: 12px 0 0; color: var(--ink-soft); font-size: 24px; letter-spacing: 1px; }
.fame-line { margin: 0; font-family: var(--font-display); font-size: clamp(8px, 1.6vmin + 3px, 11px); color: var(--ink-soft); line-height: 1.8; }
.fame-line b { color: var(--gold); font-weight: 400; }

.cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; width: 100%; margin-top: 4px; }
.card { background: linear-gradient(180deg, #2b211b, #1a1311); border: 3px solid #4a3d35; box-shadow: var(--pixel-shadow); padding: 8px 6px 10px; display: grid; gap: 4px; justify-items: center; text-align: center; transition: transform 0.08s steps(2); }
.card:hover { transform: translateY(-3px); border-color: var(--accent); }
.card[aria-checked="true"] { border-color: var(--gold); background: linear-gradient(180deg, #4a3320, #241a14); box-shadow: 4px 4px 0 #000, 0 0 0 3px rgba(255, 201, 60, 0.35); }
.card canvas { width: min(18vw, 84px); height: min(18vw, 84px); image-rendering: pixelated; }
.card h3 { margin: 0; font-family: var(--font-display); font-weight: 400; font-size: clamp(9px, 1.8vmin + 2px, 13px); }
.card p { margin: 0; font-size: 19px; color: var(--ink-soft); line-height: 1.05; }
.card p b { color: var(--accent-2); font-weight: 400; }
.card .stats { font-size: 17px; color: var(--gold); }

.lower { display: grid; grid-template-columns: 1fr auto; gap: 14px; align-items: stretch; width: 100%; }
.vault { background: rgba(20, 14, 11, 0.85); border: 3px solid #4a3d35; box-shadow: var(--pixel-shadow); padding: 8px 10px; text-align: left; min-height: 96px; }
.vault h2, .panel h2 { margin: 0 0 6px; font-family: var(--font-display); font-weight: 400; font-size: 11px; color: var(--accent); }
.vault-list { display: grid; gap: 4px; max-height: 150px; overflow-y: auto; }
.vault-list > :not(.vitem) { font-size: 17px; }
.vitem { display: flex; justify-content: space-between; gap: 8px; align-items: center; background: #120d0b; border: 2px solid #3b3430; padding: 3px 8px; text-align: left; font-size: 20px; width: 100%; }
.vitem:hover { border-color: var(--accent-2); }
.vitem[aria-checked="true"] { border-color: var(--gold); background: #2a2016; }
.vitem small { color: var(--ink-soft); font-size: 17px; white-space: nowrap; }
.start-col { display: grid; align-content: center; gap: 8px; }
.note { margin: 0; font-size: 17px; color: var(--ink-soft); max-width: 190px; }

.big { font-family: var(--font-display); font-size: 14px; letter-spacing: 1px; padding: 16px 22px; background: linear-gradient(180deg, #ffb36a 0 12%, #ee7939 12% 60%, #b8481c 60%); color: #140e0b; border: 3px solid #000; box-shadow: 4px 4px 0 #000, inset 0 0 0 2px #ffd9a8; text-shadow: 1px 1px 0 #ffc48a; }
.big:hover { transform: translate(-2px, -2px); box-shadow: 6px 6px 0 #000, inset 0 0 0 2px #fff0d0; }
.big:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 #000; }
.ghost { font-family: var(--font-display); font-size: 10px; padding: 12px 16px; background: transparent; border: 3px solid #5a4a40; color: var(--ink-soft); }
.ghost:hover { border-color: var(--accent-2); color: var(--ink); }
.help { margin: 0; font-size: 19px; color: var(--ink-soft); max-width: 720px; }
.help b { color: var(--accent-2); font-weight: 400; }
.foot { margin: 0; font-size: 18px; }

.panel { background: linear-gradient(180deg, #2b211b, #17100e); border: 4px solid #5a4a40; box-shadow: 6px 6px 0 #000; padding: 22px 26px; display: grid; gap: 14px; justify-items: center; text-align: center; min-width: min(320px, 92vw); }
.panel.wide { width: min(560px, 94vw); }
.panel h2 { font-size: clamp(16px, 4vmin, 26px); color: var(--ink); margin: 0; }
.panel.win h2 { color: var(--gold); }
.end-sub { margin: 0; color: var(--ink-soft); font-size: 22px; }
.tally { display: grid; grid-template-columns: 1fr auto; gap: 2px 18px; margin: 0; width: min(380px, 100%); text-align: left; font-size: 22px; }
.tally dt { color: var(--ink-soft); }
.tally dd { margin: 0; text-align: right; color: var(--gold); }
.tally .total { color: var(--accent); }
.end-loot { font-size: 21px; min-height: 26px; }

@media (max-width: 640px) {
  .lower { grid-template-columns: 1fr; }
  .start-col { justify-items: center; }
  .card p { font-size: 17px; }
  .card .stats { font-size: 15px; }
  .help { font-size: 17px; }
}
body.touch .mini { width: 40px; height: 40px; }
html, body { touch-action: none; }
.screen { touch-action: pan-y; }
@media (max-height: 520px) and (orientation: landscape) {
  .special { width: 88px; height: 88px; }
  .dash { right: calc(max(16px, env(safe-area-inset-right)) + 88px + 12px); }
  #stick { width: 128px; height: 128px; }
  .hud-tl { width: min(34vw, 220px); }
  .panel { padding: 12px 16px; gap: 8px; }
  .title-inner { gap: 6px; }
  .tag { display: none; }
  .card canvas { width: 44px; height: 44px; }
  .card p:not(.stats) { display: none; }
  .vault { min-height: 0; }
  .vault-list { max-height: 54px; }
  .help { display: none; }
}
