:root {
  --bg: #0c0a10;
  --panel: #1a1520;
  --panel2: #241c2a;
  --line: #4a3a2a;
  --gold: #e8c060;
  --gold2: #b08830;
  --text: #ece2cc;
  --mute: #a89a84;
  --u: 2;
  --gw: 320;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); overflow: hidden; touch-action: none; -webkit-user-select: none; user-select: none; }
body { display: flex; align-items: center; justify-content: center; font-family: Georgia, 'Times New Roman', serif; }
#stage { position: relative; width: calc(var(--gw) * 1px * var(--u)); height: calc(180px * var(--u)); font-size: calc(4.6px * var(--u)); line-height: 1.22; }
#screen { position: absolute; inset: 0; width: 100%; height: 100%; image-rendering: pixelated; image-rendering: crisp-edges; display: block; }
.hidden { display: none !important; }
button { font: inherit; color: var(--text); background: linear-gradient(#2e2434, #1c1622); border: 0.15em solid var(--line); border-radius: 0.3em; padding: 0.35em 0.9em; cursor: pointer; box-shadow: inset 0 0.1em 0 rgba(255,255,255,.08), 0 0.15em 0 #000; }
button:hover, button:focus-visible { border-color: var(--gold2); outline: none; color: #fff; }
button:active { transform: translateY(0.1em); box-shadow: none; }
button.gold { background: linear-gradient(#7a5418, #4a3008); border-color: var(--gold); color: #fff3cf; text-shadow: 0 0.1em 0 #000; }
button:disabled { opacity: .45; cursor: default; }
.small { font-size: 0.82em; color: var(--mute); }
h2 { margin: 0 0 0.5em; font-size: 1.35em; color: var(--gold); text-align: center; text-shadow: 0 0.12em 0 #000; letter-spacing: .04em; }
h3 { margin: 0.4em 0 0.3em; font-size: 0.9em; color: var(--mute); text-transform: uppercase; letter-spacing: .12em; }
i.coin { display: inline-block; width: 0.75em; height: 0.75em; border-radius: 50%; background: radial-gradient(circle at 35% 35%, #fff4b0, #ffd84a 45%, #b08820); border: 0.08em solid #120d14; vertical-align: -0.05em; margin-right: 0.25em; }

.screen { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; z-index: 5; }
.screen.dim { background: rgba(8, 6, 12, .62); }
.panel { background: linear-gradient(var(--panel2), var(--panel)); border: 0.2em solid var(--line); outline: 0.1em solid #000; border-radius: 0.4em; padding: 0.9em 1.1em; box-shadow: 0 0.4em 1.2em rgba(0,0,0,.6), inset 0 0 0 0.12em rgba(232,192,96,.12); }
.panel.narrow { min-width: 18em; max-width: 34em; text-align: center; }
.panel.wide { width: 62em; max-width: 96%; }
.menu { display: flex; flex-direction: column; gap: 0.5em; align-items: stretch; min-width: 13em; }
.row { display: flex; justify-content: space-between; gap: 0.6em; margin-top: 0.7em; }

#title { background: radial-gradient(ellipse at 50% 40%, rgba(0,0,0,0) 30%, rgba(0,0,0,.55)); }
.logo { font-size: 4.4em; font-weight: bold; letter-spacing: .08em; color: var(--gold); text-shadow: 0 0.04em 0 #fff2b0, 0 0.08em 0 #7a5418, 0 0.12em 0 #3a2408, 0 0.2em 0.3em #000; }
.tag { margin: 0.2em 0 1.2em; color: #f4ead4; text-shadow: 0 0.1em 0.2em #000; font-style: italic; }
#title .menu { min-width: 14em; }
#saveInfo { margin-top: 0.8em; text-shadow: 0 0.1em 0.2em #000; color: #e8dcc4; }

table.keys { margin: 0 auto 0.6em; border-collapse: collapse; text-align: left; }
table.keys td { padding: 0.15em 0.6em; border-bottom: 0.08em solid #2e2434; }
table.keys td:first-child { color: var(--gold); white-space: nowrap; }

.create { display: grid; grid-template-columns: 1.35fr 1fr; gap: 1em; }
.list { display: grid; grid-template-columns: repeat(5, 1fr); gap: 0.35em; }
.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.35em; }
.pick { display: flex; flex-direction: column; align-items: center; gap: 0.15em; padding: 0.3em 0.2em; font-size: 0.9em; }
.pick canvas { width: calc(23px * var(--u)); height: calc(23px * var(--u)); image-rendering: pixelated; border-radius: 50%; background: #2a2a3a; border: 0.12em solid #6a8aa8; }
.pick.cls { flex-direction: row; justify-content: flex-start; gap: 0.4em; padding: 0.35em 0.5em; }
.pick.cls b { width: 0.6em; height: 0.6em; border-radius: 0.15em; flex: none; }
.pick.on { border-color: var(--gold); background: linear-gradient(#4a3a1a, #2a1e10); color: #fff3cf; }
.preview { display: flex; flex-direction: column; align-items: center; text-align: center; background: rgba(0,0,0,.25); border: 0.12em solid #2e2434; border-radius: 0.3em; padding: 0.4em; }
#pv { width: calc(76px * var(--u)); height: calc(62px * var(--u)); image-rendering: pixelated; }
.pvname { color: var(--gold); font-size: 1.15em; font-weight: bold; }
.skills { width: 100%; margin-top: 0.4em; display: flex; flex-direction: column; gap: 0.25em; text-align: left; }
.skill { display: flex; gap: 0.45em; align-items: center; font-size: 0.85em; }
.skill canvas { width: calc(16px * var(--u)); height: calc(16px * var(--u)); image-rendering: pixelated; flex: none; }
.skill em { font-style: normal; color: var(--mute); }

.maphead { display: flex; align-items: center; gap: 0.7em; margin-bottom: 0.6em; }
#mapPortrait { width: calc(23px * var(--u)); height: calc(23px * var(--u)); image-rendering: pixelated; border-radius: 50%; background: #2a2a3a; border: 0.15em solid #6a8aa8; }
.shop { margin-left: auto; }
.zones { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.45em; }
.zone { text-align: left; padding: 0.45em 0.6em; display: flex; flex-direction: column; gap: 0.1em; min-height: 5.2em; position: relative; }
.zone .zn { color: #fff3cf; font-weight: bold; }
.zone .zs { font-size: 0.78em; color: var(--mute); }
.zone .zb { font-size: 0.78em; color: #d88a7a; margin-top: auto; }
.zone .st { position: absolute; top: 0.4em; right: 0.5em; font-size: 0.78em; color: var(--mute); }
.zone.done .st { color: #7ad86a; }
.zone.on { border-color: var(--gold); background: linear-gradient(#4a3a1a, #2a1e10); }
.zone.locked { filter: grayscale(.8); opacity: .55; }

#hud { position: absolute; inset: 0; pointer-events: none; z-index: 2; }
#coins { position: absolute; left: calc(36px * var(--u)); top: calc(24px * var(--u)); font-size: 0.85em; color: #ffe8a0; text-shadow: 0.1em 0.1em 0 #000; }
#pauseBtn { position: absolute; right: 0.6em; top: 0.6em; pointer-events: auto; padding: 0.15em 0.5em; font-size: 0.85em; opacity: .8; }
#bossName { position: absolute; left: 0; right: 0; top: calc(4px * var(--u)); text-align: center; color: #ffd0c0; font-weight: bold; text-shadow: 0.1em 0.1em 0 #000, 0 0 0.4em #000; font-size: 0.95em; }
#bar { position: absolute; left: 50%; bottom: calc(8px * var(--u)); transform: translateX(-50%); display: flex; gap: calc(2px * var(--u)); }
.slot { position: relative; width: calc(18px * var(--u)); height: calc(18px * var(--u)); border: calc(1px * var(--u)) solid #000; outline: calc(1px * var(--u)) solid #5a4a3a; background: #120d14; overflow: hidden; }
.slot canvas { width: 100%; height: 100%; image-rendering: pixelated; display: block; }
.slot .cd { position: absolute; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,.66); height: 0; }
.slot .k { position: absolute; left: 0.15em; top: 0; font-size: 0.75em; color: #fff; text-shadow: 0.1em 0.1em 0 #000; font-family: monospace; }
.slot .n { position: absolute; right: 0.15em; bottom: 0; font-size: 0.8em; color: #fff; text-shadow: 0.1em 0.1em 0 #000; font-family: monospace; }
.slot.nores canvas { filter: grayscale(1) brightness(.6) sepia(1) hue-rotate(190deg); }
.slot.ready { outline-color: var(--gold2); }

#banner { position: absolute; left: 0; right: 0; top: 30%; text-align: center; pointer-events: none; z-index: 3; animation: fade 3.2s ease forwards; }
#banner .b1 { font-size: 2.2em; font-weight: bold; color: var(--gold); text-shadow: 0 0.06em 0 #7a5418, 0 0.12em 0.25em #000; letter-spacing: .05em; }
#banner .b2 { color: #f4ead4; text-shadow: 0 0.1em 0.25em #000; font-style: italic; }
#banner.lvl .b1 { color: #fff0a0; }
#toast { position: absolute; left: 50%; top: 26%; transform: translateX(-50%); background: rgba(10,8,14,.72); border: 0.1em solid var(--line); padding: 0.25em 0.8em; border-radius: 0.3em; color: #fff3cf; pointer-events: none; z-index: 3; white-space: nowrap; }
@keyframes fade { 0% { opacity: 0; transform: translateY(0.6em); } 12% { opacity: 1; transform: none; } 78% { opacity: 1; } 100% { opacity: 0; } }

#touch { position: fixed; inset: 0; pointer-events: none; z-index: 4; }
#touch button { pointer-events: auto; position: absolute; width: 64px; height: 64px; border-radius: 50%; font-size: 22px; padding: 0; background: rgba(30,24,36,.5); border: 2px solid rgba(232,192,96,.45); color: #fff3cf; box-shadow: none; touch-action: none; }
#touch button.on { background: rgba(232,192,96,.45); }
#touch .tl button[data-k=left] { left: max(16px, env(safe-area-inset-left)); bottom: 22px; }
#touch .tl button[data-k=right] { left: calc(max(16px, env(safe-area-inset-left)) + 76px); bottom: 22px; }
#touch .tr .jp { right: max(16px, env(safe-area-inset-right)); bottom: 22px; width: 76px; height: 76px; }
#touch .tr button[data-k=s0] { right: calc(max(16px, env(safe-area-inset-right)) + 88px); bottom: 16px; }
#touch .tr button[data-k=s1] { right: calc(max(16px, env(safe-area-inset-right)) + 82px); bottom: 90px; }
#touch .tr button[data-k=s2] { right: calc(max(16px, env(safe-area-inset-right)) + 10px); bottom: 110px; }
#touch .tr .pt { right: calc(max(16px, env(safe-area-inset-right)) + 160px); bottom: 22px; width: 48px; height: 48px; font-size: 20px; }

#rotate { position: fixed; inset: 0; background: var(--bg); color: var(--text); display: none; align-items: center; justify-content: center; text-align: center; padding: 16px; z-index: 50; font-size: 18px; }
@media (orientation: portrait) and (pointer: coarse) { #rotate { display: flex; } }
