:root {
  color-scheme: dark;
  --ink: #0e0b26; --ink2: #18123a; --ink3: #241a52;
  --gold: #f2b84b; --gold2: #ffd98a; --teal: #2dd4bf; --rose: #ff4d6d; --sky: #7ad8ff;
  --text: #fff6e6; --muted: #cbbfa6;
  --glass: rgba(18, 14, 44, 0.72); --line: rgba(255, 217, 138, 0.22);
  --safe-t: env(safe-area-inset-top, 0px); --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px); --safe-r: env(safe-area-inset-right, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--ink); color: var(--text); font-family: 'Nunito', system-ui, sans-serif; }
body { overscroll-behavior: none; touch-action: none; -webkit-user-select: none; user-select: none; }
#scene { position: fixed; inset: 0; width: 100vw; height: 100vh; display: block; }
button { font: inherit; color: inherit; }
kbd { display: inline-block; min-width: 1.6em; padding: 1px 6px; margin: 0 2px; border-radius: 6px; background: rgba(255,255,255,0.1); border: 1px solid rgba(255,255,255,0.18); border-bottom-width: 2px; font: 700 0.82em 'Nunito', sans-serif; text-align: center; }

.flash { position: fixed; inset: 0; pointer-events: none; opacity: 0; transition: opacity 0.35s; z-index: 5; }
.vignette { position: fixed; inset: 0; pointer-events: none; z-index: 4; background: radial-gradient(ellipse at center, transparent 55%, rgba(6, 3, 18, 0.55) 100%); }

/* ---------------- loader */
.loader { position: fixed; inset: 0; display: none; place-items: center; z-index: 50; background: radial-gradient(circle at 50% 40%, #2a1d5a, var(--ink) 70%); }
.loader.show { display: grid; }
.loader-card { display: flex; flex-direction: column; align-items: center; gap: 14px; font-weight: 800; color: var(--gold2); letter-spacing: 0.02em; }
.lamp-ico { width: 84px; color: var(--gold); filter: drop-shadow(0 0 12px rgba(242,184,75,0.7)); }
.lamp-ico.spin { animation: rub 1.4s ease-in-out infinite; }
@keyframes rub { 0%,100% { transform: rotate(-6deg) translateY(0); } 50% { transform: rotate(6deg) translateY(-4px); } }

/* ---------------- menu */
.menu { position: fixed; inset: 0; z-index: 10; display: none; overflow-y: auto; -webkit-overflow-scrolling: touch; touch-action: pan-y;
  background: linear-gradient(90deg, rgba(8,5,24,0.82) 0%, rgba(8,5,24,0.45) 45%, rgba(8,5,24,0) 75%), linear-gradient(0deg, rgba(8,5,24,0.7), transparent 40%); }
.menu.show { display: block; }
.menu-inner { min-height: 100%; padding: calc(70px + var(--safe-t)) max(28px, var(--safe-r)) calc(28px + var(--safe-b)) max(36px, var(--safe-l)); display: flex; flex-direction: column; justify-content: center; gap: 26px; max-width: 980px; }
.brand .kicker { font: 800 13px 'Nunito'; letter-spacing: 0.32em; text-transform: uppercase; color: var(--teal); margin-bottom: 4px; }
.brand h1 { margin: 0; font: 800 clamp(58px, 11vw, 132px)/0.9 'Cinzel', serif; letter-spacing: 0.02em;
  background: linear-gradient(180deg, #fff3cf 0%, #ffd98a 35%, #f2b84b 60%, #b9761f 100%); -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 4px 0 rgba(90,40,0,0.55)) drop-shadow(0 0 26px rgba(242,184,75,0.45)); }
.brand .pre { margin: 0 0 2px; font: 600 clamp(22px, 3.4vw, 38px) 'Cinzel', serif; color: var(--gold2); letter-spacing: 0.14em; text-shadow: 0 2px 12px rgba(0,0,0,0.6); }
.brand .sub { margin: 6px 0 0; font: 600 clamp(18px, 2.6vw, 28px) 'Cinzel', serif; color: var(--text); letter-spacing: 0.12em; text-shadow: 0 2px 12px rgba(0,0,0,0.6); }
.modes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; max-width: 900px; }
.mode-card { display: flex; flex-direction: column; text-align: left; padding: 0; border-radius: 22px; overflow: hidden; cursor: pointer; border: 1px solid var(--line);
  background: var(--glass); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px); box-shadow: 0 18px 50px rgba(0,0,0,0.45); transition: transform 0.18s, border-color 0.18s, box-shadow 0.18s; }
.mode-card:hover, .mode-card:focus-visible { transform: translateY(-4px); border-color: rgba(255,217,138,0.6); box-shadow: 0 22px 60px rgba(0,0,0,0.5), 0 0 0 2px rgba(242,184,75,0.25); outline: none; }
.mc-art { position: relative; height: 150px; background-size: cover; background-position: center; }
.mc-art.side { background-image: linear-gradient(0deg, rgba(14,11,38,0.85), transparent 60%), url('assets/card-side.jpg'), linear-gradient(160deg, #ff9a4a, #7a2a6a); }
.mc-art.quest { background-image: linear-gradient(0deg, rgba(14,11,38,0.85), transparent 60%), url('assets/card-quest.jpg'), linear-gradient(160deg, #f2b84b, #1c4f8a); }
.mc-tag { position: absolute; top: 12px; left: 12px; font: 900 13px 'Nunito'; padding: 4px 10px; border-radius: 999px; background: rgba(14,11,38,0.75); color: var(--gold2); border: 1px solid var(--line); }
.mc-body { padding: 14px 18px 18px; }
.mc-body h2 { margin: 0 0 6px; font: 800 26px 'Cinzel', serif; color: var(--gold2); }
.mc-body p { margin: 0 0 12px; color: var(--text); opacity: 0.9; font-size: 15px; line-height: 1.4; }
.mc-meta { display: flex; flex-wrap: wrap; gap: 8px; font-size: 12px; font-weight: 800; color: var(--muted); }
.mc-meta span { padding: 3px 9px; border-radius: 999px; background: rgba(255,255,255,0.07); }
.menu-row { display: flex; gap: 12px; flex-wrap: wrap; }

.cta, .ghost { min-height: 46px; padding: 0 22px; border-radius: 14px; font-weight: 900; font-size: 16px; cursor: pointer; letter-spacing: 0.02em; }
.cta { border: 0; color: #2a1600; background: linear-gradient(180deg, #ffe2a0, #f2b84b 55%, #d9922a); box-shadow: 0 6px 0 #8a5512, 0 10px 24px rgba(242,184,75,0.35); }
.cta:active { transform: translateY(3px); box-shadow: 0 3px 0 #8a5512; }
.ghost { border: 1px solid var(--line); background: rgba(255,255,255,0.06); color: var(--text); }
.ghost:hover { background: rgba(255,255,255,0.12); }

/* ---------------- overlays + sheets */
.overlay { position: fixed; inset: 0; z-index: 30; display: none; place-items: center; padding: 16px; background: rgba(6,4,20,0.6); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); overflow-y: auto; touch-action: pan-y; }
.overlay.show { display: grid; }
.sheet { width: min(460px, 100%); padding: 24px; border-radius: 22px; background: linear-gradient(180deg, rgba(36,26,82,0.95), rgba(18,14,44,0.97)); border: 1px solid var(--line); box-shadow: 0 30px 80px rgba(0,0,0,0.6); }
.sheet.wide { width: min(860px, 100%); }
.sheet.small { width: min(400px, 100%); text-align: center; }
.sheet h2 { margin: 0 0 16px; font: 800 30px 'Cinzel', serif; color: var(--gold2); text-align: center; }
.sheet h3 { margin: 0 0 8px; color: var(--teal); font-weight: 900; }
.sheet p, .sheet li { line-height: 1.5; }
.sheet ul { padding-left: 18px; margin: 0; }
.sheet .fine { color: var(--muted); font-size: 14px; text-align: center; }
.sheet-btns { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 18px; }
.sheet-btns.col { flex-direction: column; align-items: stretch; }
.how-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; }
.overlay.lock { background: rgba(6,4,20,0.45); }
.esc-hint { position: absolute; left: max(14px, var(--safe-l)); top: calc(96px + var(--safe-t)); font-weight: 800; font-size: 13px; color: var(--muted); text-shadow: 0 1px 4px #000; }
body.touch .esc-hint { display: none; }

.set-grid { display: grid; gap: 12px; }
.set { display: flex; align-items: center; justify-content: space-between; gap: 14px; font-weight: 800; }
.set select { min-height: 40px; padding: 0 10px; border-radius: 10px; border: 1px solid var(--line); background: var(--ink2); color: var(--text); font: 700 15px 'Nunito'; }
.set input[type=range] { width: 52%; accent-color: var(--gold); }
.set.switch input { display: none; }
.set.switch i { width: 52px; height: 30px; border-radius: 999px; background: rgba(255,255,255,0.15); position: relative; transition: background 0.2s; flex: none; cursor: pointer; }
.set.switch i::after { content: ''; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; transition: transform 0.2s; }
.set.switch input:checked + i { background: var(--gold); }
.set.switch input:checked + i::after { transform: translateX(22px); }

.level-cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.level-card { text-align: left; padding: 0; border-radius: 16px; overflow: hidden; border: 1px solid var(--line); background: rgba(255,255,255,0.05); cursor: pointer; }
.level-card:disabled { opacity: 0.45; cursor: not-allowed; }
.level-card .lc-art { height: 92px; background-size: cover; background-position: center; position: relative; }
.level-card .lc-art.t1 { background-image: linear-gradient(0deg, rgba(14,11,38,0.6), transparent), url('assets/level-1.jpg'), linear-gradient(160deg, #ffb26a, #a8406a); }
.level-card .lc-art.t2 { background-image: linear-gradient(0deg, rgba(14,11,38,0.6), transparent), url('assets/level-2.jpg'), linear-gradient(160deg, #3a1f6a, #0a6a7a); }
.level-card .lc-art.t3 { background-image: linear-gradient(0deg, rgba(14,11,38,0.6), transparent), url('assets/level-3.jpg'), linear-gradient(160deg, #1c1d5a, #b8862a); }
.level-card .lc-body { padding: 10px 12px 12px; }
.level-card b { display: block; font: 800 16px 'Cinzel', serif; color: var(--gold2); }
.level-card small { display: block; color: var(--muted); font-size: 13px; margin: 4px 0 6px; line-height: 1.35; }
.lc-stars { display: flex; gap: 4px; }
.lc-stars i, .stars i, .res-stars i { width: 18px; height: 18px; display: inline-block; background: rgba(255,255,255,0.18); clip-path: polygon(50% 0%, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%); }
.lc-stars i.on, .stars i.on, .res-stars i.on { background: linear-gradient(180deg, #fff1b0, #f2b84b); filter: drop-shadow(0 0 6px rgba(255,200,80,0.8)); }
.lock-badge { position: absolute; inset: 0; display: grid; place-items: center; font-weight: 900; color: var(--text); background: rgba(6,4,20,0.55); }

/* ---------------- HUD */
.hud { position: fixed; inset: 0; z-index: 8; pointer-events: none; display: none; }
.hud.show { display: block; }
.hud-btn { pointer-events: auto; position: fixed; z-index: 12; min-width: 44px; min-height: 44px; border-radius: 10px; border: 0; background: rgba(0,0,0,0.55); color: #fff; font-weight: 900; cursor: pointer; -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); }
.pause-btn { top: max(10px, var(--safe-t)); right: calc(max(12px, var(--safe-r)) + 54px); }
.hud-top { position: absolute; top: calc(62px + var(--safe-t)); left: max(14px, var(--safe-l)); right: max(14px, var(--safe-r)); display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.hud-left, .hud-right { display: flex; flex-direction: column; gap: 6px; }
.hud-right { align-items: flex-end; }
.hud-mid { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; min-width: 0; }
.hearts { display: flex; gap: 3px; flex-wrap: wrap; max-width: 240px; }
.hearts i { width: 26px; height: 24px; display: inline-block; position: relative; filter: drop-shadow(0 2px 3px rgba(0,0,0,0.6)); }
.hearts i::before, .hearts i::after { content: ''; position: absolute; inset: 0; clip-path: path('M13 22 C 6 16 1 12 1 7 C 1 3 4 1 7 1 C 10 1 12 3 13 5 C 14 3 16 1 19 1 C 22 1 25 3 25 7 C 25 12 20 16 13 22 Z'); }
.hearts i::before { background: rgba(255,255,255,0.18); }
.hearts i.full::after { background: linear-gradient(180deg, #ff8aa0, #ff2d55); }
.hearts i.half::after { background: linear-gradient(90deg, #ff2d55 50%, transparent 50%); }
.lives, .score, .gems { font-weight: 900; font-size: 18px; text-shadow: 0 2px 6px rgba(0,0,0,0.8); display: flex; align-items: center; gap: 6px; }
.score b { font-size: 24px; color: var(--gold2); font-variant-numeric: tabular-nums; }
.gems b { font-variant-numeric: tabular-nums; }
.scarab { width: 18px; height: 14px; border-radius: 50% 50% 45% 45%; background: linear-gradient(180deg, #ffe08a, #c98a2a); display: inline-block; }
.gem-ico { width: 14px; height: 18px; display: inline-block; background: linear-gradient(180deg, #8ff3ff, #2d8aff); clip-path: polygon(50% 0, 100% 40%, 50% 100%, 0 40%); }
.stars { display: flex; gap: 4px; }
.stars i { width: 22px; height: 22px; }
.lvl-name { font: 800 15px 'Cinzel', serif; color: var(--gold2); text-shadow: 0 2px 6px rgba(0,0,0,0.8); padding: 4px 12px; border-radius: 999px; background: rgba(10,6,30,0.45); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.shards { display: flex; gap: 6px; }
.shards i { width: 16px; height: 26px; display: inline-block; background: rgba(255,255,255,0.16); clip-path: polygon(50% 0, 100% 35%, 70% 100%, 30% 100%, 0 35%); }
.shards i.on { background: linear-gradient(180deg, #e0ffff, #2ad8ff); filter: drop-shadow(0 0 8px #2ad8ff); }
.objective { font-weight: 800; font-size: 14px; padding: 4px 12px; border-radius: 999px; background: rgba(10,6,30,0.5); text-shadow: 0 1px 4px rgba(0,0,0,0.8); text-align: center; }

.minimap { position: absolute; left: max(16px, var(--safe-l)); bottom: calc(16px + var(--safe-b)); width: 170px; height: 170px; border-radius: 50%; border: 3px solid rgba(242,184,75,0.7); box-shadow: 0 6px 20px rgba(0,0,0,0.5); background: #2a1d10; }
.crosshair { position: absolute; left: 50%; top: 50%; width: 30px; height: 30px; transform: translate(-50%, -50%); }
.crosshair i { position: absolute; background: rgba(255,246,230,0.9); box-shadow: 0 0 3px rgba(0,0,0,0.8); border-radius: 2px; }
.crosshair i:nth-child(1) { left: 14px; top: 0; width: 2px; height: 9px; } .crosshair i:nth-child(2) { left: 14px; bottom: 0; width: 2px; height: 9px; }
.crosshair i:nth-child(3) { top: 14px; left: 0; height: 2px; width: 9px; } .crosshair i:nth-child(4) { top: 14px; right: 0; height: 2px; width: 9px; }
.crosshair.hit i { background: #ff5a5a; }
.dmg-dir { position: absolute; left: 50%; top: 50%; width: 220px; height: 220px; margin: -110px; border-radius: 50%; opacity: 0; transition: opacity 0.5s; background: conic-gradient(from -20deg, rgba(255,40,40,0.75) 0deg, transparent 40deg, transparent 360deg); -webkit-mask: radial-gradient(circle, transparent 62%, #000 63%, #000 70%, transparent 71%); mask: radial-gradient(circle, transparent 62%, #000 63%, #000 70%, transparent 71%); }
.weapons { position: absolute; left: 50%; bottom: calc(18px + var(--safe-b)); transform: translateX(-50%); display: flex; gap: 8px; }
.weapons .w { min-width: 92px; padding: 6px 10px; border-radius: 12px; background: rgba(10,6,30,0.6); border: 1px solid rgba(255,255,255,0.12); font-weight: 800; font-size: 12px; text-align: center; color: var(--muted); }
.weapons .w b { display: block; font-size: 13px; color: var(--text); }
.weapons .w.on { border-color: var(--gold); color: var(--gold2); background: rgba(60,40,10,0.65); box-shadow: 0 0 14px rgba(242,184,75,0.35); }

.boss-bar { position: fixed; z-index: 9; left: 50%; top: calc(122px + var(--safe-t)); transform: translateX(-50%); width: min(560px, 76vw); display: none; text-align: center; pointer-events: none; }
.boss-bar.show { display: block; }
.boss-name { font: 800 16px 'Cinzel', serif; color: #e8c0ff; text-shadow: 0 2px 8px #000; margin-bottom: 4px; }
.boss-track { height: 14px; border-radius: 999px; background: rgba(10,6,30,0.7); border: 1px solid rgba(200,140,255,0.5); overflow: hidden; }
.boss-fill { height: 100%; width: 100%; background: linear-gradient(90deg, #8a2aff, #e070ff); transition: width 0.2s; }

.djinn { position: fixed; z-index: 9; left: 50%; bottom: calc(96px + var(--safe-b)); transform: translate(-50%, 20px); width: min(560px, 92vw); display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-radius: 18px;
  background: linear-gradient(135deg, rgba(60,30,10,0.92), rgba(30,16,50,0.92)); border: 1px solid rgba(255,190,90,0.5); box-shadow: 0 12px 30px rgba(0,0,0,0.5), 0 0 24px rgba(255,150,40,0.25); opacity: 0; pointer-events: none; transition: opacity 0.3s, transform 0.3s; }
.djinn.show { opacity: 1; transform: translate(-50%, 0); }
.dj-face { flex: none; width: 46px; height: 46px; border-radius: 50%; background: radial-gradient(circle at 40% 35%, #ffd08a, #ff8c1a 70%); box-shadow: 0 0 18px rgba(255,150,40,0.8); position: relative; }
.dj-face i { position: absolute; top: 16px; width: 9px; height: 11px; border-radius: 50%; background: #fff; }
.dj-face i::after { content: ''; position: absolute; left: 3px; top: 3px; width: 5px; height: 6px; border-radius: 50%; background: #2a1200; }
.dj-face i:first-child { left: 11px; } .dj-face i:last-child { right: 11px; }
.dj-text { font-weight: 800; font-size: 16px; line-height: 1.35; }
.dj-text b { color: var(--gold2); }

.toasts { position: fixed; z-index: 9; left: 50%; top: 32%; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 6px; pointer-events: none; }
.toast { padding: 8px 16px; border-radius: 999px; background: rgba(10,6,30,0.72); border: 1px solid var(--line); font-weight: 900; animation: toast 2.2s forwards; }
@keyframes toast { 0% { opacity: 0; transform: translateY(8px); } 12% { opacity: 1; transform: none; } 80% { opacity: 1; } 100% { opacity: 0; transform: translateY(-8px); } }
.popups { position: fixed; inset: 0; z-index: 7; pointer-events: none; overflow: hidden; }
.pop { position: absolute; font: 900 18px 'Nunito'; color: var(--gold2); text-shadow: 0 2px 4px #000, 0 0 10px rgba(242,184,75,0.6); animation: pop 0.9s forwards; white-space: nowrap; transform: translate(-50%, -50%); }
.pop.heart { color: #ff8aa0; } .pop.blue { color: var(--sky); } .pop.big { font-size: 26px; color: #fff1b0; }
@keyframes pop { 0% { opacity: 0; margin-top: 0; } 15% { opacity: 1; } 100% { opacity: 0; margin-top: -46px; } }

/* ---------------- results */
.res-kicker { text-align: center; font-weight: 900; letter-spacing: 0.24em; text-transform: uppercase; color: var(--teal); font-size: 12px; margin-bottom: 4px; }
.res-stars { display: flex; justify-content: center; gap: 10px; margin: 4px 0 14px; }
.res-stars i { width: 44px; height: 44px; }
.res-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.res-stats div { padding: 10px 12px; border-radius: 12px; background: rgba(255,255,255,0.06); }
.res-stats small { display: block; color: var(--muted); font-weight: 800; font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; }
.res-stats b { font-size: 22px; color: var(--gold2); }
.res-stats .best { color: var(--teal); font-size: 12px; font-weight: 900; }

/* ---------------- touch controls */
.touch-ui { display: none; }
body.touch .touch-ui { display: block; }
.t-btn { pointer-events: auto; border: 2px solid rgba(255,217,138,0.45); background: rgba(20,12,50,0.45); color: var(--gold2); border-radius: 50%; width: 74px; height: 74px; font-weight: 900; font-size: 15px; -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); touch-action: none; }
.t-btn.on { background: rgba(242,184,75,0.45); color: #fff; transform: scale(0.94); }
.touch-ui.side .t-left { position: absolute; left: max(16px, var(--safe-l)); bottom: calc(18px + var(--safe-b)); display: flex; gap: 14px; }
.dpad { pointer-events: auto; touch-action: none; width: 200px; height: 92px; border-radius: 46px; display: flex; border: 2px solid rgba(255,217,138,0.45); background: rgba(20,12,50,0.45); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); overflow: hidden; }
.dpad span { flex: 1; display: grid; place-items: center; font-size: 28px; color: var(--gold2); transition: background 0.08s; }
.dpad .dp-l { border-right: 1px solid rgba(255,217,138,0.25); }
.dpad span.on { background: rgba(242,184,75,0.45); color: #fff; }
.touch-ui.side .t-right { position: absolute; right: max(16px, var(--safe-r)); bottom: calc(18px + var(--safe-b)); display: flex; gap: 14px; align-items: flex-end; }
.touch-ui.side .t-btn.jump { width: 92px; height: 92px; }
.touch-ui.side .t-btn.fire { font-size: 30px; margin-bottom: 38px; }
.touch-ui.quest .look-zone { pointer-events: auto; position: absolute; top: 0; right: 0; bottom: 0; left: 40%; touch-action: none; }
.touch-ui.quest .stick { pointer-events: auto; position: absolute; left: max(22px, var(--safe-l)); bottom: calc(26px + var(--safe-b)); width: 136px; height: 136px; border-radius: 50%; background: rgba(20,12,50,0.4); border: 2px solid rgba(255,217,138,0.4); touch-action: none; }
.touch-ui.quest .knob { position: absolute; left: 50%; top: 50%; width: 58px; height: 58px; margin: -29px; border-radius: 50%; background: radial-gradient(circle at 40% 35%, #ffe2a0, #c98a2a); box-shadow: 0 4px 12px rgba(0,0,0,0.5); }
.touch-ui.quest .t-right { position: absolute; right: max(14px, var(--safe-r)); bottom: calc(18px + var(--safe-b)); width: 190px; height: 190px; }
.touch-ui.quest .t-btn { position: absolute; width: 60px; height: 60px; font-size: 12px; line-height: 1.1; }
.touch-ui.quest .t-btn.big { right: 0; bottom: 0; width: 92px; height: 92px; font-size: 34px; }
.touch-ui.quest .t-btn.jump { right: 104px; bottom: 0; }
.touch-ui.quest .t-btn.alt { right: 0; bottom: 104px; color: var(--sky); border-color: rgba(122,216,255,0.5); }
.touch-ui.quest .t-btn.wpn { right: 100px; bottom: 100px; width: 50px; height: 50px; font-size: 22px; }
body.touch .minimap { left: auto; right: max(14px, var(--safe-r)); bottom: auto; top: calc(150px + var(--safe-t)); width: 104px; height: 104px; }
body.touch .weapons { bottom: auto; top: calc(124px + var(--safe-t)); left: max(14px, var(--safe-l)); transform: none; flex-direction: column; gap: 4px; }
body.touch .weapons .w { min-width: 0; padding: 4px 8px; font-size: 10px; }
body.touch .weapons .w b { font-size: 11px; }
body.touch .djinn { bottom: auto; top: calc(266px + var(--safe-t)); }
body.touch .boss-bar { top: calc(118px + var(--safe-t)); width: min(420px, 56vw); }

.rotate-hint { position: fixed; z-index: 9; left: 50%; bottom: calc(120px + var(--safe-b)); transform: translateX(-50%); padding: 8px 14px; border-radius: 999px; background: rgba(10,6,30,0.75); font-weight: 800; font-size: 13px; display: none; pointer-events: none; white-space: nowrap; }

@media (max-width: 760px) {
  .modes { grid-template-columns: 1fr; }
  .mc-art { height: 110px; }
  .how-grid { grid-template-columns: 1fr; }
  .level-cards { grid-template-columns: 1fr; }
  .menu { background: linear-gradient(0deg, rgba(8,5,24,0.88) 25%, rgba(8,5,24,0.25) 70%, rgba(8,5,24,0.5)); }
  .menu-inner { padding-left: max(18px, var(--safe-l)); padding-right: max(18px, var(--safe-r)); justify-content: flex-end; gap: 18px; }
  .hearts i { width: 21px; height: 20px; }
  .hearts i::before, .hearts i::after { transform: scale(0.81); transform-origin: 0 0; }
  .score b { font-size: 20px; }
  .lvl-name { display: none; }
  .djinn .dj-text { font-size: 14px; }
  .dj-face { width: 36px; height: 36px; }
  .dj-face i { top: 12px; width: 7px; height: 9px; } .dj-face i:first-child { left: 8px; } .dj-face i:last-child { right: 8px; }
}
@media (max-height: 500px) {
  .hud-top { top: calc(58px + var(--safe-t)); }
  body.touch .minimap { top: calc(110px + var(--safe-t)); width: 88px; height: 88px; }
  body.touch .djinn { top: auto; bottom: calc(12px + var(--safe-b)); width: min(440px, 50vw); }
  body.touch .weapons { top: calc(104px + var(--safe-t)); }
  .touch-ui.quest .stick { width: 120px; height: 120px; }
}

/* narrow phones in portrait: stack the spark button above JUMP so the run pad has room */
@media (max-width: 520px) {
  .touch-ui.side .t-right { flex-direction: column-reverse; align-items: flex-end; gap: 10px; }
  .touch-ui.side .t-btn.fire { margin: 0 10px 0 0; width: 66px; height: 66px; }
  .dpad { width: 180px; height: 86px; }
}
/* phones in landscape: the djinn's bubble sits between the pad and the buttons */
@media (max-height: 500px) {
  body.touch .djinn { width: min(400px, 44vw); }
}

/* phones in landscape: the boss bar takes the level-name slot in the top HUD row */
@media (max-height: 500px) {
  .boss-bar, body.touch .boss-bar { top: calc(52px + var(--safe-t)); width: min(300px, 36vw); }
  .boss-name { font-size: 12px; margin-bottom: 2px; }
  .boss-track { height: 10px; }
  body.boss-on .lvl-name { visibility: hidden; }
}
