:root { --ink: #f4ecd8; --gold: #e8c060; --panel: rgba(18, 24, 16, 0.82); --edge: rgba(232, 192, 96, 0.45); --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif; --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #0e140c; color: var(--ink); font-family: var(--sans); -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent; touch-action: none; }
#view { position: fixed; inset: 0; width: 100vw; height: 100vh; height: 100dvh; display: block; }
button { font: inherit; color: inherit; cursor: pointer; border: 1px solid var(--edge); background: rgba(255, 255, 255, 0.06); border-radius: 12px; padding: 0.7em 1.2em; transition: transform 0.08s, background 0.2s; }
button:hover { background: rgba(255, 255, 255, 0.12); }
button:active { transform: scale(0.97); }
button.primary { background: linear-gradient(#e8c060, #b88a2a); color: #1d150a; border-color: #f4dc90; font-weight: 700; box-shadow: 0 4px 18px rgba(232, 192, 96, 0.25); }
button:disabled { opacity: 0.45; cursor: default; }
[hidden] { display: none !important; }

/* HUD */
#hud { position: fixed; top: 0; left: 0; right: 0; display: flex; justify-content: space-between; align-items: flex-start; padding: max(10px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) 0 max(14px, env(safe-area-inset-left)); pointer-events: none; opacity: 0; transition: opacity 0.4s; }
body.playing #hud { opacity: 1; }
#hud .left { display: flex; flex-direction: column; gap: 6px; }
#hearts { display: flex; gap: 3px; filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.5)); }
#hearts .h { width: 26px; height: 24px; }
.stats { display: flex; gap: 8px; }
.stats span:empty { display: none; }
.stats span { display: inline-flex; align-items: center; gap: 6px; background: rgba(0, 0, 0, 0.42); border: 1px solid rgba(255, 255, 255, 0.12); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); padding: 4px 10px 4px 6px; border-radius: 999px; font-weight: 700; font-size: 15px; font-variant-numeric: tabular-nums; }
.coin { width: 16px; height: 16px; border-radius: 50%; background: radial-gradient(circle at 35% 35%, #fff2b0, #e8b830 45%, #a07010); box-shadow: inset 0 0 0 1.5px #8a5a08; }
.ico { font-style: normal; font-size: 14px; }
#hud .right { display: flex; align-items: center; gap: 10px; }
#zone { font-family: var(--serif); font-size: 17px; letter-spacing: 0.04em; text-shadow: 0 1px 4px rgba(0, 0, 0, 0.8); }
#bM { pointer-events: auto; width: 46px; height: 46px; padding: 10px; border-radius: 50%; background: rgba(0, 0, 0, 0.45); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
#bM svg { width: 100%; height: 100%; }
#boss { position: fixed; top: max(64px, calc(env(safe-area-inset-top) + 54px)); left: 50%; transform: translateX(-50%); width: min(460px, 80vw); text-align: center; font-family: var(--serif); text-shadow: 0 1px 4px #000; pointer-events: none; }
#boss .bar { height: 10px; margin-top: 4px; background: rgba(0, 0, 0, 0.55); border: 1px solid rgba(255, 255, 255, 0.3); border-radius: 6px; overflow: hidden; }
#bossFill { height: 100%; width: 100%; background: linear-gradient(#e5484d, #8a1a20); transition: width 0.2s; }
#banner { position: fixed; top: 22%; left: 0; right: 0; text-align: center; pointer-events: none; opacity: 0; font-family: var(--serif); text-shadow: 0 2px 12px rgba(0, 0, 0, 0.85); }
#banner b { display: block; font-size: clamp(30px, 6vw, 56px); font-weight: 600; letter-spacing: 0.06em; }
#banner span { display: block; font-size: 15px; letter-spacing: 0.25em; text-transform: uppercase; color: var(--gold); margin-top: 4px; }
#banner.show { animation: banner 3s ease forwards; }
@keyframes banner { 0% { opacity: 0; transform: translateY(10px); } 15% { opacity: 1; transform: none; } 75% { opacity: 1; } 100% { opacity: 0; } }
#contestBar { position: fixed; top: 30%; left: 50%; transform: translateX(-50%); background: var(--panel); border: 1px solid var(--edge); padding: 8px 18px; border-radius: 999px; font-weight: 700; color: var(--gold); pointer-events: none; }
#prompt { position: fixed; left: 0; top: 0; pointer-events: none; white-space: nowrap; margin: -14px 0 0 0; translate: -50% -100%; background: rgba(10, 14, 8, 0.75); border: 1px solid var(--edge); padding: 3px 10px 3px 4px; border-radius: 999px; font-size: 13px; font-weight: 600; display: flex; gap: 6px; align-items: center; }
#prompt kbd { font: inherit; font-size: 11px; background: var(--gold); color: #1d150a; border-radius: 999px; padding: 1px 7px; }
#toast { position: fixed; bottom: 26%; left: 50%; transform: translate(-50%, 10px); background: var(--panel); border: 1px solid var(--edge); padding: 10px 20px; border-radius: 999px; font-weight: 600; opacity: 0; pointer-events: none; transition: opacity 0.25s, transform 0.25s; max-width: 90vw; text-align: center; backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
#toast.show { opacity: 1; transform: translate(-50%, 0); }
body.touch #toast { bottom: 44%; }
#hurt { position: fixed; inset: 0; pointer-events: none; background: radial-gradient(ellipse at center, transparent 50%, rgba(200, 20, 20, 0.55)); opacity: 0; }
#hurt.on { animation: hurt 0.45s ease-out; }
@keyframes hurt { from { opacity: 1; } to { opacity: 0; } }
#lowhp { position: fixed; inset: 0; pointer-events: none; box-shadow: inset 0 0 120px rgba(180, 0, 0, 0.5); opacity: 0; }
#lowhp.on { animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { opacity: 1; } }

/* touch pad */
#pad { display: none; }
body.touch.playing[data-mode="play"] #pad { display: block; }
#stick { position: fixed; left: max(18px, env(safe-area-inset-left)); bottom: max(22px, env(safe-area-inset-bottom)); width: 150px; height: 150px; border-radius: 50%; background: radial-gradient(circle, rgba(255, 255, 255, 0.1), rgba(0, 0, 0, 0.25)); border: 2px solid rgba(255, 255, 255, 0.25); touch-action: none; }
#knob { position: absolute; left: 50%; top: 50%; width: 64px; height: 64px; margin: -32px; border-radius: 50%; background: radial-gradient(circle at 40% 35%, rgba(255, 255, 255, 0.7), rgba(255, 255, 255, 0.25)); box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4); }
#btns { position: fixed; right: max(18px, env(safe-area-inset-right)); bottom: max(22px, env(safe-area-inset-bottom)); width: 190px; height: 170px; }
#btns button { position: absolute; border-radius: 50%; padding: 18px; background: rgba(0, 0, 0, 0.38); border: 2px solid rgba(255, 255, 255, 0.35); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); touch-action: none; }
#btns button::after { content: attr(data-label); position: absolute; left: 50%; bottom: -16px; transform: translateX(-50%); font-size: 11px; font-weight: 700; text-shadow: 0 1px 3px #000; white-space: nowrap; }
#btns button.on { background: rgba(232, 192, 96, 0.55); }
#btns button.off { opacity: 0.35; }
#btns svg { width: 100%; height: 100%; }
#bA { right: 0; bottom: 10px; width: 92px; height: 92px; border-color: var(--gold) !important; }
#bB { right: 104px; bottom: 0; width: 70px; height: 70px; }
#bP { right: 30px; bottom: 116px; width: 54px; height: 54px; padding: 13px !important; }
body.touch .keys { display: none; }

/* overlays */
.ov { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; padding: 20px; }
.panel { background: var(--panel); border: 1px solid var(--edge); border-radius: 20px; padding: 22px 24px; width: min(520px, 100%); max-height: 92vh; overflow: auto; backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5); }
.panel.wide { width: min(1080px, 100%); }
.panel.center { text-align: center; }
.panel header { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; border-bottom: 1px solid rgba(255, 255, 255, 0.12); padding-bottom: 10px; margin-bottom: 12px; }
h1, h2 { font-family: var(--serif); font-weight: 600; margin: 0; }
h2 { font-size: 26px; }
.kicker { text-transform: uppercase; letter-spacing: 0.3em; font-size: 12px; color: var(--gold); margin: 0 0 6px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px; }
.panel.center .row, .panel.center button { margin-left: auto; margin-right: auto; }
#shopGold, #fame { color: var(--gold); font-weight: 700; }
#shopNote { color: #f0b090; margin: 0 0 10px; }
#shopNote:empty { display: none; }
#shopList { display: grid; gap: 8px; margin-bottom: 16px; }
#shopList button { display: grid; grid-template-columns: 34px 1fr auto; align-items: center; text-align: left; gap: 10px; padding: 12px 14px; }
#shopList i { font-style: normal; font-size: 22px; }
#shopList b { color: var(--gold); }
.cols { display: grid; grid-template-columns: 1.6fr 1fr; gap: 18px; }
#mapCanvas { width: 100%; border-radius: 12px; border: 1px solid rgba(255, 255, 255, 0.15); image-rendering: auto; }
.q { padding: 10px 12px; border-radius: 12px; background: rgba(255, 255, 255, 0.06); margin-bottom: 8px; }
.q b { display: block; font-family: var(--serif); font-size: 17px; color: var(--gold); }
.q span { font-size: 14px; line-height: 1.4; }
.q.done { opacity: 0.55; }
.q.done b { color: var(--ink); text-decoration: line-through; }
.hint { opacity: 0.8; }
#kit { font-size: 14px; opacity: 0.85; }
@media (max-width: 760px) { .cols { grid-template-columns: 1fr; } }

/* dialog */
#dlg { align-items: flex-end; padding-bottom: max(24px, env(safe-area-inset-bottom)); }
#dlg .box { position: relative; width: min(760px, 100%); background: var(--panel); border: 1px solid var(--edge); border-radius: 18px; padding: 18px 22px 22px; backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); box-shadow: 0 16px 50px rgba(0, 0, 0, 0.5); cursor: pointer; }
#dlgName { font-family: var(--serif); color: var(--gold); font-size: 19px; font-weight: 600; margin-bottom: 4px; }
#dlgText { margin: 0; font-size: 18px; line-height: 1.5; min-height: 3em; }
#dlgOpts { display: grid; gap: 8px; margin-top: 12px; }
#dlgOpts button { text-align: left; }
#dlgMore { position: absolute; right: 18px; bottom: 8px; color: var(--gold); animation: bob 1s infinite; font-size: 12px; }
@keyframes bob { 50% { transform: translateY(3px); } }

/* title */
#title { background: linear-gradient(90deg, rgba(8, 12, 6, 0.85) 0%, rgba(8, 12, 6, 0.55) 45%, rgba(8, 12, 6, 0) 75%); justify-content: flex-start; padding: 6vw; }
.tcard { max-width: 560px; }
#title h1 { font-size: clamp(54px, 10vw, 108px); line-height: 0.92; letter-spacing: 0.01em; text-shadow: 0 6px 30px rgba(0, 0, 0, 0.6); }
#title h1 span { display: block; color: var(--gold); font-style: italic; font-size: 0.62em; letter-spacing: 0.08em; }
.sub { font-size: 18px; line-height: 1.5; opacity: 0.9; max-width: 460px; }
.keys { font-size: 13px; opacity: 0.6; margin-top: 18px; }
#btnContinue:not([hidden]) + #btnNew { background: rgba(255, 255, 255, 0.06); color: var(--ink); border-color: var(--edge); box-shadow: none; font-weight: 600; }
#iosHint { position: fixed; bottom: max(16px, env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%); background: var(--panel); border: 1px solid var(--edge); border-radius: 14px; padding: 10px 14px; display: flex; gap: 10px; align-items: center; width: max-content; max-width: 92vw; }
#iosHint button { padding: 4px 12px; }
@media (max-width: 700px) { #title { align-items: flex-end; background: linear-gradient(0deg, rgba(8, 12, 6, 0.92) 0%, rgba(8, 12, 6, 0.6) 55%, rgba(8, 12, 6, 0) 85%); } .sub { font-size: 16px; } #hearts .h { width: 22px; height: 20px; } #zone { display: none; } }
