:root {
  color-scheme: dark;
  --bg: #050507;
  --panel: rgba(15, 16, 22, 0.95);
  --panel-border: rgba(255, 255, 255, 0.16);
  --text: #f6f7fb;
  --muted: #aeb3c0;
  --accent: #f6be3d;
  --accent-2: #ff6a3d;
  --danger: #ff475f;
  --success: #72f0a6;
  --focus: #fff2a8;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.55);
}

* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; margin: 0; overflow: hidden; background: #000; }
body {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  user-select: none;
}
button, input { font: inherit; }
button { color: inherit; }
button:focus-visible, input:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
.hidden { display: none !important; }

.app { width: 100%; height: 100%; display: grid; place-items: center; background: #000; }
.stage {
  position: relative;
  width: min(100vw, calc(100vh * 16 / 9));
  height: min(100vh, calc(100vw * 9 / 16));
  overflow: hidden;
  background: radial-gradient(circle at 50% 45%, #161820 0%, #050507 58%, #000 100%);
  isolation: isolate;
}
canvas { width: 100%; height: 100%; display: block; background: transparent; cursor: crosshair; }
.vignette { position: absolute; inset: 0; pointer-events: none; z-index: 15; box-shadow: inset 0 0 10vw 3vw rgba(0,0,0,.72); }
.flash-layer { position: absolute; inset: 0; pointer-events: none; z-index: 17; opacity: 0; background: white; }
.flash-layer.active { animation: flash .14s ease-out; }
@keyframes flash { 0% { opacity: .22; } 100% { opacity: 0; } }

.screen { position: absolute; inset: 0; z-index: 30; display: none; align-items: center; justify-content: center; padding: clamp(16px, 3vw, 40px); }
.screen.active { display: flex; }
.screen::before { content: ""; position: absolute; inset: 0; background: rgba(2,3,6,.62); backdrop-filter: blur(8px); z-index: -1; }
.intro-screen { background: radial-gradient(circle at 50% 48%, rgba(99,111,155,.2), transparent 28%), linear-gradient(135deg, #020205, #0c0d12 45%, #020205); }
.intro-screen::before { background: linear-gradient(115deg, rgba(255,255,255,.025), transparent 20%, rgba(255,255,255,.015) 60%, transparent); animation: drift 11s linear infinite alternate; }
@keyframes drift { to { transform: translate3d(3%, -2%, 0) scale(1.05); } }
.intro-content { position: relative; width: min(960px, 94vw); text-align: center; z-index: 2; display: flex; flex-direction: column; align-items: center; }
.intro-title { margin: 0; font-size: clamp(44px, 8vw, 112px); letter-spacing: .08em; line-height: .88; text-shadow: 0 4px 0 #000, 0 0 38px rgba(255,255,255,.16), 0 0 90px rgba(57,71,112,.34); animation: title-in 1.2s cubic-bezier(.2,.7,.15,1) both; }
.intro-subtitle { margin: 20px 0 34px; color: #bfc5d5; font-size: clamp(17px, 2.2vw, 28px); letter-spacing: .32em; text-transform: uppercase; animation: fade-in 1.2s .25s both; }
@keyframes title-in { from { opacity: 0; transform: scale(.84); filter: blur(8px); } to { opacity: 1; transform: none; filter: none; } }
@keyframes fade-in { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
.intro-particles { position: absolute; inset: 0; overflow: hidden; }
.intro-particles i { position: absolute; width: 3px; height: 3px; border-radius: 50%; background: rgba(255,255,255,.35); animation: particle-float var(--duration) linear infinite; }
@keyframes particle-float { from { transform: translateY(105vh); opacity: 0; } 20% { opacity: .6; } to { transform: translateY(-15vh); opacity: 0; } }

.panel, .menu-shell { position: relative; border: 1px solid var(--panel-border); background: linear-gradient(180deg, rgba(24,26,35,.96), rgba(9,10,15,.96)); border-radius: 22px; box-shadow: var(--shadow); }
.panel { width: min(520px, 94vw); padding: clamp(24px, 4vw, 48px); text-align: center; }
.compact-panel { width: min(620px, 92vw); }
.menu-shell { width: min(1180px, 96vw); max-height: 94vh; overflow: auto; padding: clamp(22px, 3vw, 38px); text-align: center; }
.menu-shell h1, .panel h1 { margin: 4px 0 6px; font-size: clamp(30px, 4.5vw, 58px); letter-spacing: .07em; }
.menu-subtitle { margin: 0 0 26px; color: var(--accent); letter-spacing: .28em; font-weight: 800; }
.eyebrow { margin: 0 0 8px; font-size: 12px; color: var(--muted); font-weight: 800; letter-spacing: .24em; }
.small-note { color: var(--muted); font-size: 13px; }

button { border: 0; cursor: pointer; font-weight: 900; letter-spacing: .06em; transition: transform .15s ease, filter .15s ease, background .15s ease; }
button:hover { transform: translateY(-2px); filter: brightness(1.08); }
button:active { transform: translateY(1px); }
.primary-button, .ghost-button, .danger-button { min-height: 48px; padding: 12px 22px; border-radius: 12px; }
.primary-button { background: linear-gradient(180deg, #ffd66b, #eaa821); color: #171006; box-shadow: 0 8px 30px rgba(236,177,44,.25); }
.ghost-button { background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.14); }
.danger-button { background: rgba(255,71,95,.14); border: 1px solid rgba(255,71,95,.5); color: #ff9aa8; }
.huge-button { min-width: 220px; font-size: 22px; padding: 16px 32px; }
.intro-content .ghost-button { display: block; margin: 14px auto 0; min-width: 140px; }
.button-row, .menu-footer { display: flex; justify-content: center; flex-wrap: wrap; gap: 12px; margin-top: 24px; }
.icon-button { width: 42px; height: 42px; border-radius: 50%; background: rgba(255,255,255,.08); font-size: 28px; line-height: 1; }

.progress-track { width: 100%; height: 16px; border-radius: 999px; background: rgba(255,255,255,.08); overflow: hidden; margin: 28px 0 10px; }
.progress-fill { height: 100%; width: 0; background: linear-gradient(90deg, var(--accent-2), var(--accent)); transition: width .18s ease; }

.card-grid { display: grid; gap: 16px; }
.weapon-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.upgrade-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); max-width: 1000px; margin: 0 auto; }
.choice-card { position: relative; display: flex; flex-direction: column; min-height: 300px; padding: 18px; border-radius: 17px; border: 1px solid rgba(255,255,255,.13); background: linear-gradient(180deg, rgba(255,255,255,.075), rgba(255,255,255,.025)); text-align: left; overflow: hidden; }
.choice-card:hover, .choice-card:focus-visible { border-color: rgba(255,214,107,.8); background: linear-gradient(180deg, rgba(255,214,107,.12), rgba(255,255,255,.03)); }
.choice-card::after { content: ""; position: absolute; inset: auto -30% -55% -30%; height: 70%; background: radial-gradient(circle, rgba(255,190,61,.15), transparent 65%); pointer-events: none; }
.card-image { width: 100%; height: 112px; object-fit: contain; margin-bottom: 12px; filter: drop-shadow(0 10px 15px rgba(0,0,0,.45)); }
.card-fallback-icon { height: 112px; display: grid; place-items: center; margin-bottom: 12px; border-radius: 12px; background: rgba(255,255,255,.05); color: var(--accent); font-size: 38px; font-weight: 1000; }
.choice-card h2 { margin: 0 0 8px; font-size: 20px; }
.choice-card p { margin: 0 0 12px; color: #c7cbd5; font-size: 13px; line-height: 1.45; }
.card-meta { display: grid; gap: 7px; margin-top: auto; font-size: 12px; color: #d7dae2; }
.rating-row { display: grid; grid-template-columns: 88px 1fr; gap: 8px; align-items: center; }
.rating-track { height: 7px; background: rgba(255,255,255,.08); border-radius: 999px; overflow: hidden; }
.rating-fill { height: 100%; background: linear-gradient(90deg, var(--accent-2), var(--accent)); }
.rank-badge { display: inline-flex; align-items: center; align-self: flex-start; min-height: 26px; padding: 4px 9px; margin-bottom: 10px; border-radius: 999px; background: rgba(246,190,61,.14); color: #ffd66b; font-size: 11px; font-weight: 900; letter-spacing: .08em; }
.effect-lines { display: grid; gap: 8px; margin-top: 10px; }
.effect-line { padding: 9px 10px; border-radius: 9px; background: rgba(255,255,255,.05); color: #d8dce6; font-size: 12px; line-height: 1.4; }
.effect-line strong { color: white; }

.settings-dialog { position: absolute; inset: 0; z-index: 80; display: grid; place-items: center; padding: 16px; background: rgba(0,0,0,.72); backdrop-filter: blur(8px); }
.settings-panel { width: min(600px, 96vw); text-align: left; }
.dialog-heading { display: flex; align-items: start; justify-content: space-between; margin-bottom: 24px; }
.dialog-heading h2 { margin: 0; font-size: 34px; }
.setting-row { display: grid; grid-template-columns: 1fr minmax(120px, 220px) 46px; align-items: center; gap: 14px; padding: 12px 0; border-bottom: 1px solid rgba(255,255,255,.08); }
.setting-row input { width: 100%; }
.toggle-row { display: flex; align-items: center; gap: 12px; padding: 11px 0; }
.toggle-row input { width: 20px; height: 20px; accent-color: var(--accent); }
.controls-note { margin: 18px 0 0; color: var(--muted); font-size: 13px; line-height: 1.6; }

.hud { position: absolute; inset: 0; z-index: 20; pointer-events: none; padding: 18px 22px; text-shadow: 0 2px 8px #000; font-weight: 800; }
.hud-top-left, .hud-top-center, .hud-top-right { position: absolute; top: 18px; }
.hud-top-left { left: 22px; width: 300px; }
.hud-top-center { left: 50%; transform: translateX(-50%); width: min(500px, 40vw); text-align: center; }
.hud-top-right { right: 22px; width: 250px; text-align: right; }
.health-label-row, .boss-heading { display: flex; justify-content: space-between; font-size: 13px; }
.health-track, .boss-health-track { position: relative; height: 18px; margin-top: 5px; background: rgba(0,0,0,.65); border: 1px solid rgba(255,255,255,.25); border-radius: 999px; overflow: hidden; }
.health-fill, .shield-fill, .boss-health-fill { position: absolute; inset: 0 auto 0 0; width: 100%; transform-origin: left; transition: transform .18s linear; }
.health-fill { background: linear-gradient(90deg, #d42d43, #ff596f); }
.shield-fill { background: linear-gradient(90deg, rgba(57,192,255,.8), rgba(140,232,255,.9)); opacity: .7; }
.weapon-hud, .small-hud-line, .score-hud, .chain-hud { margin-top: 8px; font-size: 14px; }
.level-round-hud { font-size: 21px; letter-spacing: .08em; }
.remaining-hud { margin-top: 4px; color: #d1d5df; font-size: 13px; }
.boss-hud { margin-top: 10px; padding: 9px 12px; border-radius: 12px; background: rgba(0,0,0,.52); }
.boss-health-fill { background: linear-gradient(90deg, #8e37ff, #ff3d7f); }
.boss-attack-name { min-height: 16px; margin-top: 6px; color: #ffd66b; font-size: 12px; letter-spacing: .12em; }
.stat-hud { margin-top: 10px; display: grid; grid-template-columns: repeat(3, auto); justify-content: end; gap: 4px 10px; color: #cbd0db; font-size: 11px; }
.powerup-hud { position: absolute; left: 22px; bottom: 18px; display: flex; flex-wrap: wrap; gap: 7px; width: min(720px, 70vw); }
.powerup-chip { display: inline-flex; align-items: center; gap: 5px; padding: 5px 8px; border-radius: 999px; background: rgba(0,0,0,.62); border: 1px solid rgba(255,255,255,.18); font-size: 10px; }
.powerup-chip img { width: 18px; height: 18px; object-fit: contain; flex: 0 0 18px; }

.banner { position: absolute; z-index: 50; left: 50%; top: 45%; transform: translate(-50%, -50%); width: 100%; text-align: center; font-size: clamp(32px, 6vw, 78px); font-weight: 1000; letter-spacing: .1em; text-shadow: 0 6px 0 #000, 0 0 45px rgba(255,190,61,.42); pointer-events: none; animation: banner-in .9s ease both; }
@keyframes banner-in { 0% { opacity: 0; transform: translate(-50%, -40%) scale(.92); } 25%, 75% { opacity: 1; transform: translate(-50%, -50%) scale(1); } 100% { opacity: 0; transform: translate(-50%, -60%) scale(1.03); } }
.toast { position: absolute; z-index: 55; bottom: 24px; left: 50%; transform: translateX(-50%); padding: 10px 16px; border-radius: 999px; background: rgba(0,0,0,.82); border: 1px solid rgba(255,255,255,.16); color: #f4f5f8; font-size: 13px; }

.result-panel { width: min(760px, 94vw); }
.result-summary { margin-top: 24px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; text-align: left; }
.result-stat { padding: 12px; border-radius: 10px; background: rgba(255,255,255,.055); }
.result-stat span { display: block; color: var(--muted); font-size: 10px; letter-spacing: .12em; text-transform: uppercase; }
.result-stat strong { display: block; margin-top: 4px; font-size: 17px; }

.high-contrast .boss-attack-name, .high-contrast .banner { color: #fff; background: rgba(0,0,0,.88); -webkit-text-stroke: 1px #000; }
.high-contrast canvas { filter: contrast(1.08); }
.low-health::after { content: ""; position: absolute; inset: 0; z-index: 16; pointer-events: none; box-shadow: inset 0 0 95px 35px rgba(255,0,40,.34); animation: low-pulse 1.3s ease-in-out infinite; }
@keyframes low-pulse { 50% { opacity: .45; } }

@media (max-width: 1000px) {
  .weapon-grid { grid-template-columns: repeat(3, 1fr); }
  .choice-card { min-height: 260px; }
  .card-image, .card-fallback-icon { height: 88px; }
}
@media (max-width: 700px) {
  .weapon-grid, .upgrade-grid { grid-template-columns: 1fr; }
  .menu-shell { max-height: 98vh; }
  .choice-card { min-height: 0; }
  .hud { padding: 8px 10px; }
  .hud-top-left { left: 10px; top: 8px; width: 210px; }
  .hud-top-right { right: 10px; top: 8px; width: 130px; }
  .hud-top-center { top: 8px; width: 38vw; }
  .stat-hud, .powerup-hud { display: none; }
  .result-summary { grid-template-columns: repeat(2, 1fr); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}
.reduced-motion *, .reduced-motion *::before, .reduced-motion *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }


/* Expanded ascension title screen */
.intro-status { display: inline-flex; align-items: center; gap: 9px; margin-bottom: 8px; color: #c8cdd8; font-size: 11px; font-weight: 900; letter-spacing: .22em; }
.status-light { width: 8px; height: 8px; border-radius: 50%; background: #72f0a6; box-shadow: 0 0 14px #72f0a6; animation: status-pulse 1.8s ease-in-out infinite; }
@keyframes status-pulse { 50% { opacity: .45; transform: scale(.75); } }
.intro-emblem { position: relative; width: 184px; height: 110px; margin: -4px auto -8px; filter: drop-shadow(0 18px 28px rgba(0,0,0,.55)); }
.emblem-ring { position: absolute; left: 50%; top: 50%; border: 1px solid rgba(255,214,107,.32); border-radius: 50%; transform: translate(-50%,-50%); }
.ring-one { width: 148px; height: 78px; animation: emblem-spin 12s linear infinite; }
.ring-two { width: 104px; height: 104px; border-style: dashed; animation: emblem-spin-reverse 16s linear infinite; }
.emblem-core { position: absolute; left: 50%; top: 50%; width: 58px; height: 58px; display: grid; place-items: center; transform: translate(-50%,-50%); border-radius: 50%; color: #171006; background: radial-gradient(circle at 40% 35%, #fff4b4, #f3b52e 65%, #b16d12); border: 3px solid rgba(255,255,255,.7); box-shadow: 0 0 30px rgba(246,190,61,.45); font-size: 30px; font-weight: 1000; }
@keyframes emblem-spin { to { transform: translate(-50%,-50%) rotate(360deg); } }
@keyframes emblem-spin-reverse { to { transform: translate(-50%,-50%) rotate(-360deg); } }
.intro-weapon-node { position: absolute; width: 40px; height: 40px; display: grid; place-items: center; border-radius: 12px; background: rgba(14,15,21,.9); border: 1px solid rgba(255,214,107,.35); box-shadow: 0 8px 22px rgba(0,0,0,.45); animation: node-float 3s ease-in-out infinite; }
.intro-weapon-node img { width: 34px; height: 34px; object-fit: contain; }
.node-wing { left: 0; top: 40px; }
.node-canes { left: 30px; top: 0; animation-delay: -.7s; }
.node-taco { right: 30px; top: 0; animation-delay: -1.4s; }
.node-coffee { right: 0; top: 40px; animation-delay: -2.1s; }
.node-fry { left: 72px; bottom: -3px; animation-delay: -2.8s; }
@keyframes node-float { 50% { transform: translateY(-7px) rotate(2deg); } }
.intro-tagline { max-width: 760px; margin: 10px auto 14px; color: #c7cbd5; font-size: clamp(13px, 1.4vw, 17px); letter-spacing: .04em; }
.intro-run-facts { display: flex; justify-content: center; gap: clamp(20px, 5vw, 58px); margin: 0 auto 16px; padding: 11px 24px; border-top: 1px solid rgba(255,255,255,.1); border-bottom: 1px solid rgba(255,255,255,.1); color: #aeb3c0; font-size: 11px; font-weight: 900; letter-spacing: .14em; }
.intro-run-facts strong { display: block; color: #ffd66b; font-size: 22px; line-height: 1.1; }
.intro-actions { display: flex; justify-content: center; align-items: center; gap: 12px; }
.intro-actions .ghost-button { display: inline-flex; margin: 0; min-width: 140px; justify-content: center; align-items: center; }
.intro-records { display: flex; justify-content: center; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.intro-records span { padding: 7px 11px; border-radius: 999px; background: rgba(255,255,255,.045); border: 1px solid rgba(255,255,255,.09); color: #9399a7; font-size: 9px; font-weight: 900; letter-spacing: .12em; }
.intro-records strong { color: white; margin-left: 5px; }
.intro-controls { margin-top: 11px; color: #747b89; font-size: 9px; font-weight: 900; letter-spacing: .15em; }
.intro-controls b { color: #d3a634; padding: 0 4px; }
.weapon-hud { display: flex; align-items: center; gap: 8px; min-height: 34px; }
.weapon-hud-icon, .weapon-hud-fallback { width: 34px; height: 34px; flex: 0 0 34px; object-fit: contain; border-radius: 9px; padding: 3px; background: rgba(0,0,0,.62); border: 1px solid rgba(255,214,107,.38); filter: drop-shadow(0 4px 8px rgba(0,0,0,.55)); }
.weapon-hud-fallback { display: grid; place-items: center; color: #ffd66b; font-size: 17px; }

@media (max-height: 720px) {
  .intro-emblem { width: 150px; height: 82px; transform: scale(.82); margin: -10px auto -14px; }
  .intro-tagline { margin: 5px auto 9px; }
  .intro-run-facts { margin-bottom: 10px; padding: 7px 18px; }
  .intro-records { margin-top: 9px; }
}
@media (max-width: 700px) {
  .intro-emblem { transform: scale(.8); margin: -10px auto -14px; }
  .intro-run-facts { gap: 18px; width: 100%; padding-inline: 8px; }
  .intro-actions { flex-direction: column; width: min(300px, 90vw); }
  .intro-actions button { width: 100%; }
  .intro-controls { display: none; }
}
.reduced-motion .status-light, .reduced-motion .emblem-ring, .reduced-motion .intro-weapon-node { animation: none !important; }

.intro-weapon-node span { color: #ffd66b; font-size: 18px; font-weight: 1000; text-shadow: 0 0 12px rgba(255,214,107,.5); }


/* Chazz face integration — visual only; gameplay remains unchanged */
.chazz-loading-badge,
.modal-chazz-face,
.result-chazz-face,
.chazz-hud-portrait,
.menu-chazz-header img,
.menu-chazz-header > span {
  display: grid;
  place-items: center;
  overflow: hidden;
  color: #171006;
  background: radial-gradient(circle at 40% 35%, #fff4b4, #f3b52e 65%, #b16d12);
  border: 2px solid rgba(255,255,255,.72);
  box-shadow: 0 0 30px rgba(246,190,61,.28), 0 12px 28px rgba(0,0,0,.45);
  font-weight: 1000;
}
.chazz-loading-badge img,
.modal-chazz-face img,
.result-chazz-face img,
.chazz-hud-portrait img,
.menu-chazz-header img,
.chazz-face-core img,
.intro-chazz-sigil img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.chazz-loading-badge {
  width: 84px;
  height: 84px;
  margin: 0 auto 14px;
  border-radius: 50%;
  font-size: 38px;
  animation: chazz-ready-pulse 2.2s ease-in-out infinite;
}
@keyframes chazz-ready-pulse {
  50% { transform: scale(1.045); box-shadow: 0 0 42px rgba(246,190,61,.44), 0 12px 28px rgba(0,0,0,.45); }
}
.chazz-face-core { padding: 0; overflow: hidden; }
.chazz-face-core img { border-radius: 50%; transform: scale(1.08); }
.chazz-face-core span { font-size: 30px; }
.intro-chazz-sigil {
  position: absolute;
  top: 50%;
  width: min(35vw, 430px);
  height: min(70vh, 610px);
  transform: translateY(-50%);
  opacity: .09;
  filter: grayscale(1) contrast(1.18) drop-shadow(0 0 45px rgba(246,190,61,.18));
  pointer-events: none;
  overflow: hidden;
  z-index: 0;
}
.intro-chazz-sigil img { object-fit: contain; }
.sigil-left { left: -7%; }
.sigil-right { right: -7%; transform: translateY(-50%) scaleX(-1); }
.menu-chazz-header {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin: -4px auto 10px;
  padding: 6px 12px 6px 7px;
  border-radius: 999px;
  color: #d8dce6;
  background: rgba(255,255,255,.045);
  border: 1px solid rgba(255,255,255,.1);
  font-size: 10px;
  letter-spacing: .16em;
}
.menu-chazz-header img,
.menu-chazz-header > span {
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  border-radius: 50%;
  font-size: 18px;
}
.modal-chazz-face,
.result-chazz-face {
  width: 76px;
  height: 76px;
  margin: -12px auto 14px;
  border-radius: 50%;
  font-size: 32px;
}
.result-chazz-face {
  width: 96px;
  height: 96px;
  margin-top: -20px;
}
.hud-top-left { padding-left: 58px; }
.chazz-hud-portrait {
  position: absolute;
  left: 0;
  top: 0;
  width: 48px;
  height: 48px;
  border-radius: 13px;
  font-size: 22px;
  z-index: 2;
}
.low-health .chazz-hud-portrait {
  animation: chazz-danger-pulse .72s ease-in-out infinite;
  border-color: rgba(255,71,95,.9);
}
@keyframes chazz-danger-pulse { 50% { transform: scale(.93); filter: saturate(1.5) brightness(1.2); } }
.reduced-motion .chazz-loading-badge,
.reduced-motion .low-health .chazz-hud-portrait { animation: none !important; }

@media (max-width: 700px) {
  .intro-chazz-sigil { width: 48vw; opacity: .055; }
  .hud-top-left { padding-left: 44px; }
  .chazz-hud-portrait { width: 36px; height: 36px; border-radius: 10px; }
  .menu-chazz-header { margin-bottom: 7px; }
  .menu-chazz-header b { display: none; }
  .modal-chazz-face { width: 64px; height: 64px; }
  .result-chazz-face { width: 76px; height: 76px; }
}

/* Ascension menu and persistent level checkpoints */
button:disabled {
  cursor: not-allowed;
  transform: none;
  filter: none;
}
button:disabled:hover,
button:disabled:active {
  transform: none;
  filter: none;
}
.ascension-shell { width: min(860px, 96vw); }
.ascension-action-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  max-width: 760px;
  margin: 28px auto 0;
}
.ascension-action-card {
  min-height: 140px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 9px;
  padding: 22px;
  border-radius: 17px;
  border: 1px solid rgba(255,255,255,.14);
  background: linear-gradient(180deg, rgba(255,255,255,.075), rgba(255,255,255,.025));
  text-align: left;
}
.ascension-action-card:hover,
.ascension-action-card:focus-visible {
  border-color: rgba(255,214,107,.8);
  background: linear-gradient(180deg, rgba(255,214,107,.12), rgba(255,255,255,.03));
}
.ascension-action-card strong { color: #fff4c7; font-size: 20px; letter-spacing: .08em; }
.ascension-action-card span { color: #bdc2ce; font-size: 13px; line-height: 1.45; font-weight: 700; letter-spacing: .02em; }
.primary-action-card {
  border-color: rgba(246,190,61,.55);
  box-shadow: inset 0 0 30px rgba(246,190,61,.08), 0 8px 30px rgba(0,0,0,.22);
}
.level-selector-shell { width: min(1180px, 97vw); }
.level-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 13px;
  max-width: 1080px;
  margin: 0 auto;
}
.level-card {
  min-height: 154px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  gap: 8px;
  padding: 16px;
  border-radius: 15px;
  border: 1px solid rgba(255,255,255,.13);
  background: linear-gradient(180deg, rgba(255,255,255,.075), rgba(255,255,255,.025));
  text-align: left;
  overflow: hidden;
}
.level-card:not(:disabled):hover,
.level-card:not(:disabled):focus-visible {
  border-color: rgba(255,214,107,.8);
  background: linear-gradient(180deg, rgba(255,214,107,.13), rgba(255,255,255,.035));
}
.level-card-number { color: #fff; font-size: 20px; font-weight: 1000; letter-spacing: .08em; }
.level-card-state {
  display: inline-flex;
  align-self: flex-start;
  min-height: 24px;
  align-items: center;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(114,240,166,.12);
  border: 1px solid rgba(114,240,166,.28);
  color: #9cffc5;
  font-size: 10px;
  font-weight: 1000;
  letter-spacing: .12em;
}
.level-card-weapon { color: #f3f4f8; font-size: 12px; font-weight: 900; line-height: 1.35; }
.level-card-message { margin-top: auto; color: #aeb3c0; font-size: 11px; line-height: 1.35; font-weight: 800; letter-spacing: .035em; }
.level-card.locked,
.level-card.no-checkpoint {
  opacity: .48;
  border-style: dashed;
  background: rgba(255,255,255,.025);
}
.level-card.locked .level-card-state {
  color: #ffd0d7;
  background: rgba(255,71,95,.12);
  border-color: rgba(255,71,95,.32);
}
.level-card.no-checkpoint .level-card-state {
  color: #ffe49a;
  background: rgba(246,190,61,.1);
  border-color: rgba(246,190,61,.28);
}
.level-card.fresh-start .level-card-state {
  color: #ffe49a;
  background: rgba(246,190,61,.1);
  border-color: rgba(246,190,61,.28);
}
@media (max-width: 1000px) {
  .level-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
  .ascension-action-grid { grid-template-columns: 1fr; }
  .ascension-action-card { min-height: 112px; }
  .level-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .level-card { min-height: 138px; }
}
@media (max-width: 430px) {
  .level-grid { grid-template-columns: 1fr; }
}


/* Weapon-specific level progression selector */
.level-weapon-tabs {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  max-width: 1080px;
  margin: 0 auto 12px;
}
.level-weapon-tab {
  min-height: 82px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 10px 12px;
  border-radius: 13px;
  border: 1px solid rgba(255,255,255,.13);
  background: rgba(255,255,255,.045);
  color: #d8dce6;
  font-size: 11px;
  line-height: 1.25;
  text-align: left;
}
.level-weapon-tab img,
.level-weapon-fallback {
  width: 46px;
  height: 46px;
  flex: 0 0 46px;
  object-fit: contain;
  display: grid;
  place-items: center;
  border-radius: 10px;
  padding: 3px;
  background: rgba(0,0,0,.45);
  border: 1px solid rgba(255,255,255,.1);
  color: #ffd66b;
  font-size: 13px;
  font-weight: 1000;
}
.level-weapon-tab:hover,
.level-weapon-tab:focus-visible {
  border-color: rgba(255,214,107,.65);
  background: rgba(255,214,107,.08);
}
.level-weapon-tab.selected {
  border-color: rgba(255,214,107,.9);
  background: rgba(255,214,107,.14);
  color: #fff4c7;
  box-shadow: inset 0 0 24px rgba(246,190,61,.09);
}
.level-weapon-summary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  max-width: 1080px;
  margin: 0 auto 14px;
  padding: 10px 13px;
  border-radius: 11px;
  border: 1px solid rgba(255,255,255,.1);
  background: rgba(0,0,0,.25);
  text-align: left;
}
.level-weapon-summary strong {
  color: #ffd66b;
  font-size: 12px;
  letter-spacing: .1em;
}
.level-weapon-summary span {
  color: #aeb3c0;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .06em;
}
@media (max-width: 900px) {
  .level-weapon-tabs { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .level-weapon-summary { align-items: flex-start; flex-direction: column; }
}
@media (max-width: 600px) {
  .level-weapon-tabs { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .level-weapon-tab { min-height: 68px; }
  .level-weapon-tab img,
  .level-weapon-fallback { width: 38px; height: 38px; flex-basis: 38px; }
}

/* Mobile/touch controls. Desktop behavior is unchanged unless mobile mode is active. */
.settings-panel select {
  width: 100%;
  min-height: 38px;
  padding: 6px 10px;
  border: 1px solid rgba(255,255,255,.16);
  border-radius: 9px;
  background: #12141b;
  color: var(--text);
  font: inherit;
  font-weight: 800;
}
.settings-panel select:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }

body.mobile-mode {
  overscroll-behavior: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}
body.mobile-mode canvas { touch-action: none; cursor: none !important; }
body.mobile-mode button,
body.mobile-mode .mobile-joystick {
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  user-select: none;
}

.mobile-controls {
  position: absolute;
  inset: 0;
  z-index: 26;
  pointer-events: none;
  touch-action: none;
  overflow: hidden;
}
.mobile-controls.hidden { display: none !important; }
.mobile-controls * {
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}
.mobile-joystick {
  position: absolute;
  width: clamp(82px, min(17vw, 28vh), 156px);
  aspect-ratio: 1;
  border-radius: 50%;
  pointer-events: auto;
  opacity: .82;
}
.mobile-move-joystick {
  left: max(14px, env(safe-area-inset-left));
  bottom: max(14px, env(safe-area-inset-bottom));
}
.mobile-fire-joystick {
  right: max(14px, env(safe-area-inset-right));
  bottom: max(14px, env(safe-area-inset-bottom));
}
.mobile-joystick-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,.34);
  background: radial-gradient(circle, rgba(255,255,255,.055) 0 34%, rgba(0,0,0,.42) 35% 100%);
  box-shadow: inset 0 0 22px rgba(255,255,255,.04), 0 5px 20px rgba(0,0,0,.38);
}
.mobile-joystick-knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 44%;
  aspect-ratio: 1;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  background: rgba(255,214,107,.88);
  border: 2px solid rgba(255,255,255,.72);
  box-shadow: 0 4px 15px rgba(0,0,0,.48), 0 0 18px rgba(246,190,61,.24);
  will-change: transform;
}
.mobile-fire-joystick .mobile-joystick-knob {
  background: rgba(255,106,61,.9);
  box-shadow: 0 4px 15px rgba(0,0,0,.48), 0 0 18px rgba(255,106,61,.26);
}
.mobile-joystick.active { opacity: 1; }
.mobile-joystick-label {
  position: absolute;
  left: 50%;
  bottom: 10%;
  transform: translateX(-50%);
  color: rgba(255,255,255,.68);
  font-size: clamp(8px, 1.4vw, 11px);
  font-weight: 1000;
  letter-spacing: .16em;
  pointer-events: none;
}
.mobile-action-button {
  position: absolute;
  z-index: 2;
  min-width: clamp(58px, 8vw, 82px);
  min-height: clamp(42px, 7vh, 58px);
  padding: 7px 10px;
  border-radius: 999px;
  pointer-events: auto;
  border: 1px solid rgba(255,255,255,.27);
  background: rgba(7,8,12,.72);
  box-shadow: 0 5px 18px rgba(0,0,0,.38);
  color: #fff;
  font-size: clamp(9px, 1.3vw, 12px);
  backdrop-filter: blur(5px);
}
.mobile-action-button:active {
  transform: scale(.94);
  filter: brightness(1.18);
}
.mobile-dash-button {
  left: clamp(86px, 14vw, 160px);
  bottom: clamp(92px, 20vh, 156px);
}
.mobile-reload-button {
  right: clamp(86px, 14vw, 160px);
  bottom: clamp(92px, 20vh, 156px);
}
.mobile-pause-button {
  right: max(10px, env(safe-area-inset-right));
  top: max(10px, env(safe-area-inset-top));
  min-width: 44px;
  min-height: 38px;
  padding: 4px 10px;
  font-size: 18px;
}
.mobile-rotate-hint {
  position: absolute;
  z-index: 27;
  left: 50%;
  bottom: 8px;
  transform: translateX(-50%);
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(0,0,0,.72);
  border: 1px solid rgba(255,255,255,.18);
  color: rgba(255,255,255,.82);
  font-size: 9px;
  font-weight: 900;
  letter-spacing: .1em;
  pointer-events: none;
}

body.mobile-mode .hud { padding: 8px 10px; }
body.mobile-mode .hud-top-left { left: 10px; top: 8px; width: min(240px, 31vw); }
body.mobile-mode .hud-top-center { top: 8px; width: min(390px, 42vw); }
body.mobile-mode .hud-top-right { right: 58px; top: 8px; width: min(165px, 20vw); }
body.mobile-mode .health-track,
body.mobile-mode .boss-health-track { height: 14px; }
body.mobile-mode .health-label-row,
body.mobile-mode .boss-heading { font-size: clamp(9px, 1.3vw, 12px); }
body.mobile-mode .weapon-hud,
body.mobile-mode .small-hud-line,
body.mobile-mode .score-hud,
body.mobile-mode .chain-hud { font-size: clamp(9px, 1.4vw, 12px); margin-top: 5px; }
body.mobile-mode .level-round-hud { font-size: clamp(13px, 2vw, 18px); }
body.mobile-mode .remaining-hud,
body.mobile-mode .boss-attack-name { font-size: clamp(8px, 1.2vw, 11px); }
body.mobile-mode .stat-hud,
body.mobile-mode .powerup-hud { display: none; }

@media (orientation: portrait) {
  body.mobile-mode .mobile-action-button { opacity: .88; }
  body.mobile-mode .mobile-joystick { width: clamp(72px, 22vw, 106px); }
  body.mobile-mode .mobile-dash-button { left: 27vw; bottom: 12px; }
  body.mobile-mode .mobile-reload-button { right: 27vw; bottom: 12px; }
}


/* Mobile viewport stabilization. These rules only activate in mobile control mode. */
body.mobile-mode {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  min-height: 100dvh;
  overflow: hidden;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
body.mobile-mode * {
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
}
body.mobile-mode .app {
  position: fixed;
  left: 0;
  top: 0;
  width: var(--mobile-vw, 100dvw);
  height: var(--mobile-vh, 100dvh);
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  display: block;
}
body.mobile-mode .stage {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  overflow: hidden;
}
/* Keep gameplay at its native 16:9 geometry; only the surrounding mobile UI uses the full phone viewport. */
body.mobile-mode #gameCanvas {
  position: absolute;
  left: 50%;
  top: 50%;
  width: min(var(--mobile-vw, 100dvw), calc(var(--mobile-vh, 100dvh) * 16 / 9));
  height: min(var(--mobile-vh, 100dvh), calc(var(--mobile-vw, 100dvw) * 9 / 16));
  transform: translate(-50%, -50%);
  max-width: var(--mobile-vw, 100dvw);
  max-height: var(--mobile-vh, 100dvh);
}
body.mobile-mode .vignette,
body.mobile-mode .flash-layer,
body.mobile-mode .hud {
  position: absolute;
  left: 50%;
  top: 50%;
  right: auto;
  bottom: auto;
  width: min(var(--mobile-vw, 100dvw), calc(var(--mobile-vh, 100dvh) * 16 / 9));
  height: min(var(--mobile-vh, 100dvh), calc(var(--mobile-vw, 100dvw) * 9 / 16));
  transform: translate(-50%, -50%);
}
/* Menus/settings use the actual visible mobile viewport instead of the short 16:9 game rectangle. */
body.mobile-mode .screen,
body.mobile-mode .settings-dialog {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  padding-top: max(10px, env(safe-area-inset-top));
  padding-right: max(10px, env(safe-area-inset-right));
  padding-bottom: max(10px, env(safe-area-inset-bottom));
  padding-left: max(10px, env(safe-area-inset-left));
}
body.mobile-mode .menu-shell,
body.mobile-mode .panel,
body.mobile-mode .settings-panel {
  max-height: calc(var(--mobile-vh, 100dvh) - max(20px, env(safe-area-inset-top)) - max(20px, env(safe-area-inset-bottom)));
  max-width: calc(var(--mobile-vw, 100dvw) - max(20px, env(safe-area-inset-left)) - max(20px, env(safe-area-inset-right)));
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
}
body.mobile-mode .screen button,
body.mobile-mode .settings-dialog button,
body.mobile-mode .settings-dialog input,
body.mobile-mode .settings-dialog select {
  touch-action: manipulation;
}
body.mobile-mode .mobile-controls,
body.mobile-mode .mobile-rotate-hint {
  position: absolute;
}

/* In portrait, keep menu content usable while gameplay remains a contained 16:9 canvas. */
@media (orientation: portrait) {
  body.mobile-mode .screen {
    align-items: center;
    overflow: hidden;
  }
  body.mobile-mode .intro-content {
    max-height: calc(var(--mobile-vh, 100dvh) - max(20px, env(safe-area-inset-top)) - max(20px, env(safe-area-inset-bottom)));
    overflow-y: auto;
    overflow-x: hidden;
    padding: 8px 0;
    touch-action: pan-y;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
  }
}


/* Mobile-only rotation / browser-zoom hardening. */
body.mobile-mode .stage,
body.mobile-mode #gameCanvas,
body.mobile-mode .mobile-controls,
body.mobile-mode .mobile-controls * {
  touch-action: none;
}
body.mobile-mode .screen,
body.mobile-mode .settings-dialog,
body.mobile-mode .menu-shell,
body.mobile-mode .panel,
body.mobile-mode .intro-content {
  touch-action: pan-y;
}
body.mobile-mode .screen button,
body.mobile-mode .settings-dialog button,
body.mobile-mode .settings-dialog input,
body.mobile-mode .settings-dialog select {
  touch-action: manipulation;
}
body.mobile-mode .mobile-controls {
  left: max(0px, env(safe-area-inset-left));
  right: max(0px, env(safe-area-inset-right));
  top: max(0px, env(safe-area-inset-top));
  bottom: max(0px, env(safe-area-inset-bottom));
  width: auto;
  height: auto;
  inset-block: max(0px, env(safe-area-inset-top)) max(0px, env(safe-area-inset-bottom));
  inset-inline: max(0px, env(safe-area-inset-left)) max(0px, env(safe-area-inset-right));
}
body.mobile-mode .mobile-move-joystick { left: 12px; bottom: 12px; }
body.mobile-mode .mobile-fire-joystick { right: 12px; bottom: 12px; }
body.mobile-mode .mobile-pause-button { right: 8px; top: 8px; }
body.mobile-mode .mobile-dash-button {
  left: clamp(88px, 15vw, 150px);
  bottom: clamp(82px, 17vh, 132px);
}
body.mobile-mode .mobile-reload-button {
  right: clamp(88px, 15vw, 150px);
  bottom: clamp(82px, 17vh, 132px);
}
@media (orientation: landscape) and (max-height: 500px) {
  body.mobile-mode .mobile-joystick {
    width: clamp(76px, min(15vw, 24vh), 118px);
  }
  body.mobile-mode .mobile-action-button {
    min-width: 56px;
    min-height: 38px;
    font-size: 9px;
  }
  body.mobile-mode .mobile-dash-button {
    left: clamp(82px, 14vw, 132px);
    bottom: clamp(72px, 16vh, 108px);
  }
  body.mobile-mode .mobile-reload-button {
    right: clamp(82px, 14vw, 132px);
    bottom: clamp(72px, 16vh, 108px);
  }
}
/* ============================================================
   Automatic performance profile
   Activated by JavaScript only when Auto detects a struggling/
   software-rendered browser, or when Performance is selected.
   Gameplay rules are unchanged; these are visual-only reductions.
   ============================================================ */
body.performance-mode .screen::before,
body.performance-mode .settings-dialog,
body.performance-mode .mobile-action-button {
  -webkit-backdrop-filter: none !important;
  backdrop-filter: none !important;
}

body.performance-mode .intro-particles {
  display: none !important;
}

body.performance-mode .intro-screen::before,
body.performance-mode .status-light,
body.performance-mode .emblem-ring,
body.performance-mode .intro-weapon-node,
body.performance-mode .chazz-loading-badge,
body.performance-mode .low-health .chazz-hud-portrait {
  animation: none !important;
}

body.performance-mode .intro-title,
body.performance-mode .intro-subtitle {
  animation-duration: .001ms !important;
  animation-iteration-count: 1 !important;
}

body.performance-mode .panel,
body.performance-mode .menu-shell {
  box-shadow: 0 10px 28px rgba(0,0,0,.42);
}

body.performance-mode .card-image,
body.performance-mode .weapon-hud-icon,
body.performance-mode .intro-emblem {
  filter: none !important;
}

body.performance-mode .status-light,
body.performance-mode .emblem-core,
body.performance-mode .intro-weapon-node,
body.performance-mode .mobile-joystick-ring,
body.performance-mode .mobile-joystick-knob,
body.performance-mode .mobile-action-button {
  box-shadow: none !important;
}

body.performance-mode .low-health::after {
  animation: none !important;
  box-shadow: inset 0 0 55px 20px rgba(255,0,40,.27);
}

/* Pro Vision reskin: branded truck visual on the title screen. */
.intro-pjr-truck {
  width: min(260px, 32vw);
  max-height: 92px;
  object-fit: contain;
  margin: -2px auto 10px;
  filter: drop-shadow(0 12px 18px rgba(0,0,0,.55));
  pointer-events: none;
}
@media (max-height: 760px) {
  .intro-pjr-truck { width: min(210px, 28vw); max-height: 68px; margin-bottom: 6px; }
}
@media (max-width: 700px) {
  .intro-pjr-truck { width: min(220px, 58vw); max-height: 72px; }
}

/* ============================================================
   Lightweight rendering cleanup
   Visual-only optimizations. Mobile Auto mode enters this profile
   immediately; gameplay, collisions, balance, AI and timings are unchanged.
   ============================================================ */
body.performance-mode .stage,
body.performance-mode .app {
  background: #050507 !important;
}

body.performance-mode .vignette,
body.performance-mode .flash-layer,
body.performance-mode .choice-card::after {
  display: none !important;
}

body.performance-mode .screen::before {
  background: rgba(2,3,6,.74) !important;
}

body.performance-mode .intro-screen,
body.performance-mode .panel,
body.performance-mode .menu-shell,
body.performance-mode .choice-card,
body.performance-mode .ascension-action-card,
body.performance-mode .level-card,
body.performance-mode .primary-button,
body.performance-mode .progress-fill,
body.performance-mode .rating-fill,
body.performance-mode .health-fill,
body.performance-mode .shield-fill,
body.performance-mode .boss-health-fill {
  background-image: none !important;
}

body.performance-mode .intro-screen { background-color: #07080c !important; }
body.performance-mode .panel,
body.performance-mode .menu-shell { background-color: rgba(12,13,18,.97) !important; }
body.performance-mode .choice-card,
body.performance-mode .ascension-action-card,
body.performance-mode .level-card { background-color: rgba(255,255,255,.055) !important; }
body.performance-mode .primary-button { background-color: #e8ad32 !important; }
body.performance-mode .progress-fill,
body.performance-mode .rating-fill { background-color: var(--accent) !important; }
body.performance-mode .health-fill { background-color: #e33b52 !important; }
body.performance-mode .shield-fill { background-color: rgba(92,208,255,.85) !important; }
body.performance-mode .boss-health-fill { background-color: #c43f8e !important; }

body.performance-mode button,
body.performance-mode .progress-fill,
body.performance-mode .health-fill,
body.performance-mode .shield-fill,
body.performance-mode .boss-health-fill {
  transition: none !important;
}

body.performance-mode .intro-title,
body.performance-mode .banner,
body.performance-mode .hud {
  text-shadow: 0 2px 4px #000 !important;
}

body.performance-mode .intro-pjr-truck {
  filter: none !important;
}
