:root {
  --font: "Avenir Next", "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  --accent: #ff7a2f;
  --cyan: #6fe8ff;
  --ink: #07080c;
  --paper: #f1ede4;
  --panel-img: none;
  --btn-img: none;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: #07080c; overflow: hidden; touch-action: none; user-select: none; -webkit-user-select: none; }
#app { position: fixed; inset: 0; overflow: hidden; font-family: var(--font); color: var(--paper); }
#stage { position: absolute; inset: 0; }
#stage canvas { display: block; width: 100%; height: 100%; }
.hidden { display: none !important; }
.ol { text-shadow: 1px 1px 0 var(--ink), -1px -1px 0 var(--ink), 1px -1px 0 var(--ink), -1px 1px 0 var(--ink), 0 2px 0 var(--ink), 0 3px 6px rgba(0,0,0,.6); }

/* HUD */
#hud { position: absolute; inset: 0; pointer-events: none; }
#hud-left { position: absolute; left: calc(12px + env(safe-area-inset-left)); top: calc(10px + env(safe-area-inset-top)); min-width: 96px; }
#hud-left .lbl { font-size: 12px; font-weight: 800; letter-spacing: .12em; opacity: .75; }
#hud-depth { font-size: 40px; font-weight: 900; line-height: 1; color: #fff; }
#hud-score { font-size: 17px; font-weight: 800; margin-top: 2px; font-variant-numeric: tabular-nums; }
#hud-gold { display: flex; align-items: center; gap: 4px; font-size: 16px; font-weight: 800; margin-top: 4px; color: var(--cyan); }
#hud-gold img { width: 22px; height: 22px; object-fit: contain; }
#hud-center { position: absolute; left: 50%; transform: translateX(-50%); top: calc(12px + env(safe-area-inset-top)); width: 150px; display: flex; flex-direction: column; align-items: center; gap: 6px; }
#hud-shields { display: flex; gap: 6px; height: 20px; }
#hud-shields i { width: 16px; height: 16px; margin-top: 2px; transform: rotate(45deg); border: 2px solid var(--paper); background: var(--accent); box-shadow: 0 0 6px rgba(255,122,47,.7); transition: transform .2s; }
#hud-shields i.off { background: transparent; opacity: .35; box-shadow: none; }
#hud-shields i.pop { animation: pop .35s ease-out; }
@keyframes pop { 0% { transform: rotate(45deg) scale(1.8); } 100% { transform: rotate(45deg) scale(1); } }
#hud-focus { width: 120px; height: 7px; border: 1.5px solid rgba(241,237,228,.7); border-radius: 4px; background: rgba(7,8,12,.6); overflow: hidden; }
#hud-focus i { display: block; height: 100%; width: 100%; background: var(--cyan); transform-origin: left; transition: background .2s; }
#hud-focus.on i { background: #fff; }
#hud-combo { font-size: 15px; font-weight: 900; color: var(--accent); min-height: 18px; }
#hud-addr { font-size: 12px; font-weight: 700; letter-spacing: .08em; opacity: .75; font-family: ui-monospace, Menlo, Consolas, monospace; white-space: nowrap; }

#vignette { position: absolute; inset: 0; pointer-events: none; opacity: 0; transition: opacity .25s; background: radial-gradient(ellipse at center, rgba(0,0,0,0) 45%, rgba(40,140,180,.45) 100%); }
#flash { position: absolute; inset: 0; pointer-events: none; opacity: 0; background: #ff5a3c; }

#banner { position: absolute; left: 0; right: 0; top: 30%; text-align: center; font-size: 34px; font-weight: 900; letter-spacing: .04em; pointer-events: none; opacity: 0; }
#banner.show { animation: banner 1.4s ease-out forwards; }
#banner small { display: block; font-size: 15px; font-weight: 700; letter-spacing: .1em; opacity: .8; margin-top: 4px; }
@keyframes banner { 0% { opacity: 0; transform: scale(1.6); } 12% { opacity: 1; transform: scale(.95); } 20% { transform: scale(1); } 75% { opacity: 1; } 100% { opacity: 0; transform: translateY(-14px); } }
#subtitle { position: absolute; left: 8%; right: 8%; top: 21%; text-align: center; font-size: 17px; font-weight: 700; font-style: italic; pointer-events: none; opacity: 0; transition: opacity .3s; }
#subtitle.show { opacity: 1; }

/* Title */
.screen { position: absolute; inset: 0; }
#title { cursor: pointer; overflow: hidden; }
#title-bg { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; animation: drift 18s ease-in-out infinite alternate; }
@keyframes drift { from { transform: scale(1.02); } to { transform: scale(1.08) translateY(-1%); } }
#title-logo { position: absolute; left: 50%; top: 9%; width: 80%; max-height: 30%; object-fit: contain; transform: translateX(-50%); animation: logoIn .7s cubic-bezier(.2,1.6,.4,1) both, float 4s ease-in-out .7s infinite; filter: drop-shadow(0 6px 18px rgba(0,0,0,.6)); }
@keyframes logoIn { from { opacity: 0; transform: translateX(-50%) scale(.6) translateY(-30px); } to { opacity: 1; transform: translateX(-50%) scale(1); } }
@keyframes float { 0%,100% { transform: translateX(-50%) translateY(0); } 50% { transform: translateX(-50%) translateY(-6px); } }
#title-prompt { position: absolute; left: 0; right: 0; bottom: 11%; text-align: center; font-size: 19px; font-weight: 800; letter-spacing: .08em; animation: pulse 1.8s ease-in-out infinite; }
@keyframes pulse { 0%,100% { opacity: .55; } 50% { opacity: 1; } }
.corner { position: absolute; top: calc(12px + env(safe-area-inset-top)); width: 48px; height: 48px; border-radius: 50%; border: 1.5px solid rgba(241,237,228,.35); background: rgba(7,8,12,.5); padding: 0; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: transform .12s, background .15s; }
.corner svg { width: 30px; height: 30px; }
.corner:hover { background: rgba(30,32,44,.75); }
.corner:active { transform: scale(.9); }
.corner.left { left: calc(12px + env(safe-area-inset-left)); }
.corner.right { right: calc(12px + env(safe-area-inset-right)); }
.corner .key { position: absolute; bottom: -18px; font-size: 12px; font-weight: 800; color: rgba(241,237,228,.7); font-family: var(--font); }
body.touch .corner .key { display: none; }

/* Intro */
#intro { background: #07080c url(../assets/cover-bg.webp) center / cover no-repeat; z-index: 20; }
#intro video { width: 100%; height: 100%; object-fit: cover; display: block; }
#intro-sub { position: absolute; left: 8%; right: 8%; bottom: 12%; text-align: center; font-size: 18px; font-weight: 700; font-style: italic; opacity: 0; transition: opacity .4s; }
#intro-sub.show { opacity: 1; }
#intro-skip { position: absolute; top: calc(12px + env(safe-area-inset-top)); right: calc(12px + env(safe-area-inset-right)); }

/* Panels & buttons */
.overlay { position: absolute; inset: 0; z-index: 10; display: flex; align-items: center; justify-content: center; background: rgba(4,5,8,.72); }
.panel { position: relative; width: min(88%, 360px); max-height: 92%; overflow: hidden; padding: 30px 26px 26px; border: 18px solid transparent; border-image: var(--panel-img) 13% fill / 18px stretch; background: transparent; display: flex; flex-direction: column; align-items: stretch; gap: 10px; animation: panelIn .28s cubic-bezier(.2,1.5,.4,1) both; }
.nopanel .panel { border: 2px solid rgba(241,237,228,.55); background: rgba(14,16,24,.94); border-radius: 6px; }
@keyframes panelIn { from { opacity: 0; transform: scale(.8); } to { opacity: 1; transform: scale(1); } }
.panel h2 { margin: 0; text-align: center; font-size: 26px; font-weight: 900; letter-spacing: .06em; color: #fff; }
.btns { display: flex; flex-direction: column; gap: 10px; margin-top: 6px; }
.btns.row { flex-direction: row; flex-wrap: wrap; justify-content: center; }
.btns.row .btn { flex: 1 1 0; min-width: 0; }
.btn { font-family: var(--font); min-height: 48px; padding: 6px 16px; font-size: 17px; font-weight: 800; color: #fff; cursor: pointer; border: 14px solid transparent; border-image: var(--btn-img) 30% 14% fill / 14px stretch; background: transparent; display: flex; align-items: center; justify-content: center; gap: 8px; transition: transform .1s, filter .15s; text-shadow: 0 2px 0 var(--ink), 0 0 3px var(--ink); line-height: 1.1; }
.nopanel .btn { border: 2px solid var(--accent); background: rgba(20,22,30,.9); border-radius: 10px; }
.btn img { width: 24px; height: 24px; object-fit: contain; }
.btn:hover, .btn.focus { filter: brightness(1.35) drop-shadow(0 0 6px rgba(255,122,47,.7)); transform: scale(1.03); }
.btn:active { transform: scale(.94); }
.btn.dim { filter: grayscale(1) brightness(.6); pointer-events: none; }
.btn.small { min-height: 44px; font-size: 15px; padding: 4px 12px; }
.btn.quiet { opacity: .85; font-size: 15px; }
#rv-stats { text-align: center; font-size: 17px; font-weight: 800; }
#rv-earn { display: flex; align-items: center; justify-content: center; gap: 6px; font-size: 18px; font-weight: 900; color: var(--cyan); }
#rv-earn img { width: 26px; height: 26px; object-fit: contain; }

/* Hangar */
.world { display: flex; gap: 12px; align-items: center; }
#seal { width: 84px; height: 84px; border: 1.5px solid rgba(241,237,228,.4); border-radius: 50%; flex: 0 0 auto; }
.winfo { min-width: 0; }
.winfo .lbl { font-size: 13px; font-weight: 700; opacity: .8; }
.code { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 20px; font-weight: 800; color: var(--accent); letter-spacing: .06em; }
#hg-best { font-size: 14px; font-weight: 700; }
.inv { display: flex; gap: 16px; justify-content: center; font-size: 16px; font-weight: 800; }
.inv span { display: flex; align-items: center; gap: 4px; }
.inv img { width: 24px; height: 24px; object-fit: contain; }
.skins { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.skin { font-family: var(--font); color: #fff; background: rgba(241,237,228,.06); border: 1.5px solid rgba(241,237,228,.25); border-radius: 8px; padding: 6px 4px; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 2px; min-height: 96px; transition: transform .1s, border-color .15s, background .15s; }
.skin img, .skin svg { width: 52px; height: 52px; object-fit: contain; }
.skin b { font-size: 15px; font-weight: 800; }
.skin small { font-size: 12px; font-weight: 700; opacity: .85; display: flex; align-items: center; gap: 3px; }
.skin small img { width: 16px; height: 16px; }
.skin.sel { border-color: var(--accent); background: rgba(255,122,47,.16); }
.skin.focus, .skin:hover { border-color: #fff; transform: scale(1.03); }
.skin.locked img { opacity: .55; }
#help-text { font-size: 15px; line-height: 1.5; font-weight: 600; }
#help-text p { margin: 0 0 8px; }
