:root {
  --gold: #e8c46a;
  --gold-deep: #b8892e;
  --ink: #0b0706;
  --blood: #c4302b;
  --parch: #efe6d2;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #120a08; color: var(--parch); font-family: Inter, system-ui, sans-serif; user-select: none; }
#game { position: fixed; inset: 0; }
#game canvas { display: block; width: 100%; height: 100%; }
.hidden { display: none !important; }

/* overlays */
#vignette { position: fixed; inset: 0; pointer-events: none; opacity: 0;
  background: radial-gradient(ellipse at center, rgba(0,0,0,0) 45%, rgba(170,10,0,0.75) 100%); }
#flash { position: fixed; inset: 0; pointer-events: none; opacity: 0; background: radial-gradient(circle, #fff8e0 0%, #ffd27a 60%, #c88a2a 100%); mix-blend-mode: screen; }

/* HUD */
#hud { position: fixed; inset: 0; pointer-events: none; }
#status { position: absolute; left: 24px; top: 20px; width: min(420px, 60vw); }
#status .name { font-family: Cinzel, serif; font-weight: 700; font-size: 20px; letter-spacing: 2px; color: var(--gold); text-shadow: 0 2px 6px #000; margin-bottom: 6px; }
#status .name span { font-family: Inter, sans-serif; font-weight: 500; font-size: 11px; letter-spacing: 1.5px; color: #cdbb9a; text-transform: uppercase; margin-left: 8px; }
.bar { position: relative; height: 16px; background: rgba(10,6,5,0.75); border: 1px solid var(--gold-deep); box-shadow: 0 0 0 1px #000, 0 3px 10px rgba(0,0,0,0.6); margin-bottom: 6px; overflow: hidden; transform: skewX(-12deg); }
.bar .fill, .bar .lag { position: absolute; left: 0; top: 0; bottom: 0; width: 100%; transform-origin: left; }
.bar.hp .fill { background: linear-gradient(180deg, #ff7a6a, #c4302b 55%, #7d1512); }
.bar.hp .lag { background: #f4e2b0; opacity: 0.8; }
.bar.musou { height: 12px; width: 85%; }
.bar.musou .fill { background: linear-gradient(90deg, #6d4a12, #e8b740 60%, #fff0b0); }
.bar.musou .label { position: absolute; right: 8px; top: -1px; font: 700 10px Cinzel, serif; letter-spacing: 2px; color: #1a1006; }
.bar.musou.ready { animation: ready 0.6s ease-in-out infinite alternate; border-color: #fff2b8; }
.bar.musou.ready .label { color: #2a1400; }
@keyframes ready { from { box-shadow: 0 0 6px #ffcf5a, 0 0 0 1px #000; } to { box-shadow: 0 0 22px #ffe08a, 0 0 0 1px #000; } }
.bar.heat { height: 5px; width: 50%; border-color: #6a5a3a; }
.bar.heat .fill { background: linear-gradient(90deg, #ffcc66, #ff6633); }
.bar.heat.over .fill { background: #ff2a1a; animation: blink 0.25s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0.3; } }

#objective { margin-top: 10px; font-family: Cinzel, serif; font-size: 14px; font-weight: 700; letter-spacing: 1px; color: #f3e7c8; text-shadow: 0 2px 4px #000, 0 0 12px rgba(0,0,0,0.8); }
#objective .cross { color: var(--blood); margin-right: 8px; }

#boss { position: absolute; top: 22px; left: 50%; transform: translateX(-50%); width: min(560px, 50vw); text-align: center; }
#boss .bname { font-family: Cinzel, serif; font-weight: 900; letter-spacing: 4px; font-size: 18px; color: #ffb39a; text-shadow: 0 0 12px #c00, 0 2px 4px #000; margin-bottom: 4px; }
#boss .bar { height: 12px; border-color: #8a2a1a; }
#boss .bar .fill { background: linear-gradient(180deg, #ffb340, #d0461c 60%, #7a1a08); }

#radarWrap { position: absolute; right: 22px; top: 18px; display: flex; flex-direction: column; align-items: center; }
#radar { width: 150px; height: 150px; border-radius: 50%; border: 2px solid var(--gold-deep); box-shadow: 0 0 0 2px #000, 0 6px 20px rgba(0,0,0,0.6); }
#ko { margin-top: 8px; font-family: Cinzel, serif; color: var(--gold); text-shadow: 0 2px 4px #000; display: flex; align-items: baseline; gap: 8px; }
#ko span { font-size: 14px; letter-spacing: 2px; }
#ko b { font-size: 34px; font-weight: 900; }

#combo { position: absolute; right: 40px; top: 42%; text-align: right; font-family: Cinzel, serif; color: #fff2c8; text-shadow: 0 0 18px rgba(255,180,60,0.8), 0 3px 6px #000; transform-origin: right center; }
#combo b { display: block; font-size: 72px; font-weight: 900; line-height: 1; }
#combo span { font-size: 18px; letter-spacing: 6px; color: var(--gold); }

#banner { position: absolute; left: 0; right: 0; top: 30%; text-align: center; opacity: 0; transform: scale(1.08); transition: opacity 0.5s, transform 0.5s; }
#banner.show { opacity: 1; transform: scale(1); }
#banner .main { font-family: Cinzel, serif; font-weight: 900; font-size: clamp(32px, 6vw, 72px); letter-spacing: 6px; color: #fff4d6;
  text-shadow: 0 0 30px rgba(255,170,60,0.9), 0 4px 10px #000; }
#banner .sub { margin-top: 6px; font-family: Cinzel, serif; font-size: clamp(14px, 2vw, 22px); letter-spacing: 3px; color: var(--gold); text-shadow: 0 2px 6px #000; }

#hint { position: absolute; bottom: 14px; left: 0; right: 0; text-align: center; font-size: 12px; letter-spacing: 1px; color: rgba(240,225,190,0.55); text-shadow: 0 1px 3px #000; }

/* screens */
.screen { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; padding: 16px;
  background: radial-gradient(ellipse at 50% 40%, rgba(20,8,4,0.25), rgba(8,3,2,0.85) 75%); overflow-y: auto; }
#title { background: linear-gradient(90deg, rgba(8,3,2,0.92) 0%, rgba(8,3,2,0.7) 45%, rgba(8,3,2,0.05) 80%); justify-content: flex-start; padding-left: clamp(16px, 7vw, 120px); }
.title-inner { max-width: 640px; }
.title-inner.small { text-align: center; max-width: 520px; }
.kicker { font-family: Cinzel, serif; letter-spacing: 6px; color: #cfa964; font-size: 14px; text-transform: uppercase; }
h1 { font-family: Cinzel, serif; font-weight: 900; font-size: clamp(44px, 7.5vw, 96px); line-height: 0.95; margin: 8px 0 6px; letter-spacing: 3px;
  background: linear-gradient(180deg, #fff7dc 0%, #f0cf7a 45%, #a8741f 100%); -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 4px 14px rgba(0,0,0,0.8)); }
h2 { font-family: Cinzel, serif; font-weight: 900; font-size: 54px; margin: 0 0 12px; letter-spacing: 4px; color: #fff0c8; text-shadow: 0 0 30px rgba(255,170,60,0.6); }
.deus { font-family: Cinzel, serif; color: var(--blood); letter-spacing: 8px; font-weight: 700; margin-bottom: 18px; text-shadow: 0 0 10px rgba(200,30,20,0.5); }
.lore { font-size: 15px; line-height: 1.65; color: #e6d8bb; max-width: 560px; }
.lore em { color: var(--gold); font-style: normal; font-family: Cinzel, serif; font-weight: 700; }
.btn { pointer-events: auto; cursor: pointer; font-family: Cinzel, serif; font-weight: 700; letter-spacing: 3px; font-size: 18px; text-transform: uppercase;
  color: #1c1205; background: linear-gradient(180deg, #fff0bf, #e2b552 50%, #a87422); border: 1px solid #fff3c8; padding: 14px 34px; margin: 14px 10px 0 0;
  box-shadow: 0 0 0 2px #000, 0 6px 24px rgba(232,180,80,0.35); transition: transform 0.12s, box-shadow 0.12s; }
.btn:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 0 0 2px #000, 0 8px 34px rgba(255,200,90,0.6); }
.btn:disabled { filter: grayscale(0.7) brightness(0.7); cursor: wait; }
.btn.small { font-size: 12px; padding: 9px 16px; background: rgba(20,12,8,0.8); color: var(--gold); border-color: var(--gold-deep); box-shadow: 0 0 0 1px #000; }
.opts { margin-bottom: 18px; }
.controls { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 22px; font-size: 13px; color: #d8c8a6; max-width: 600px; }
kbd { font-family: Inter, sans-serif; font-size: 11px; font-weight: 600; padding: 2px 6px; border: 1px solid #8a6a3a; border-bottom-width: 2px; border-radius: 3px; background: rgba(40,25,12,0.8); color: #f6e2b0; margin-right: 4px; }
.tip { margin-top: 14px; font-size: 12px; color: #a8987a; max-width: 560px; line-height: 1.5; }
.tip b { color: var(--gold); }
#endStats { display: grid; grid-template-columns: auto auto; gap: 6px 26px; justify-content: center; font-family: Cinzel, serif; font-size: 16px; margin: 14px 0 6px; color: #e9dbbd; }
#endStats b { color: var(--gold); text-align: right; }

@media (max-width: 700px) {
  .controls { grid-template-columns: 1fr; }
  #title { background: rgba(8,3,2,0.85); }
  #combo b { font-size: 48px; }
  #radar { width: 110px; height: 110px; }
}

/* weapon / allies panel */
#weapon { position: absolute; left: 24px; bottom: 44px; font-family: Cinzel, serif; color: #f3e7c8; text-shadow: 0 2px 4px #000;
  padding: 8px 14px; background: linear-gradient(90deg, rgba(14,8,6,0.75), rgba(14,8,6,0)); border-left: 3px solid var(--gold); min-width: 220px; }
#weapon span { font-size: 14px; letter-spacing: 2px; font-weight: 700; }
#weapon b { margin-left: 12px; font-size: 24px; color: var(--gold); }
#weapon[data-w="hmg"] { border-left-color: #8ac8ff; }
#weapon[data-w="rocket"] { border-left-color: #ff9a3a; }
#weapon .allies { font-size: 12px; letter-spacing: 1.5px; color: #cdbb9a; margin-top: 2px; }
#weapon .allies b { font-size: 14px; margin-left: 4px; color: #9fd0ff; }
#waypoint { position: absolute; transform: translate(-50%, -50%); text-align: center; font: 700 12px Cinzel, serif; color: #ffe8a8; text-shadow: 0 1px 3px #000; }
#waypoint .gem { width: 14px; height: 14px; margin: 0 auto 2px; background: #ffd56a; transform: rotate(45deg); box-shadow: 0 0 12px #ffcf5a, 0 0 0 2px #000; animation: ready 0.8s ease-in-out infinite alternate; }
.chapter2 { display: flex; align-items: center; gap: 12px; margin: 4px 0 6px; flex-wrap: wrap; }
.chapter2 .btn { margin: 8px 0 0; }
.chapter2 span { font-size: 12px; color: #a8987a; max-width: 300px; margin-top: 8px; }
.settings { display: grid; gap: 10px; margin: 22px auto 6px; max-width: 380px; text-align: left; font-size: 14px; color: #e6d8bb; }
.settings label { display: grid; grid-template-columns: 1fr 150px 38px; align-items: center; gap: 10px; }
.settings input[type="range"] { accent-color: #e2b552; width: 150px; pointer-events: auto; }
.settings input[type="checkbox"] { accent-color: #e2b552; width: 18px; height: 18px; pointer-events: auto; }
.settings output { font-size: 12px; color: var(--gold); text-align: right; }
.settings .btn { margin: 0; padding: 6px 12px; }
.pause-actions .btn { margin-right: 6px; }

/* ---------- touch / mobile ---------- */
html, body { touch-action: none; overscroll-behavior: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent; }
.screen, .screen * { touch-action: pan-y; }
.touch-help { display: none; font-size: 13px; line-height: 1.5; color: #d8c8a6; max-width: 560px; margin-top: 4px; }
.touch-help b { color: var(--gold); }
body.touch .controls, body.touch #hint { display: none; }
body.touch .touch-help { display: block; }
#touch { position: fixed; inset: 0; z-index: 5; }
#touchZone { position: absolute; inset: 0; touch-action: none; }
#stickBase { position: absolute; width: 130px; height: 130px; margin: -65px 0 0 -65px; border-radius: 50%;
  border: 2px solid rgba(232,196,106,0.5); background: radial-gradient(circle, rgba(232,196,106,0.12), rgba(10,6,4,0.25)); pointer-events: none; }
#stickKnob { position: absolute; left: 50%; top: 50%; width: 58px; height: 58px; margin: -29px 0 0 -29px; border-radius: 50%;
  background: radial-gradient(circle at 40% 35%, #fff2c6, #d9a642 60%, #8a5d18); box-shadow: 0 0 14px rgba(255,200,90,0.6); }
.tbtn { position: absolute; width: 62px; height: 62px; border-radius: 50%; touch-action: none; user-select: none;
  border: 2px solid rgba(232,196,106,0.75); background: radial-gradient(circle at 40% 35%, rgba(60,40,18,0.85), rgba(14,8,6,0.8));
  color: #f6e2b0; font: 700 22px Cinzel, serif; display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1;
  box-shadow: 0 0 0 1px #000, 0 4px 14px rgba(0,0,0,0.5); }
.tbtn span { font-size: 8px; letter-spacing: 1px; margin-top: 3px; text-transform: uppercase; }
.tbtn.down { transform: scale(0.92); background: radial-gradient(circle, rgba(232,196,106,0.6), rgba(60,40,18,0.9)); }
.tbtn.big { width: 92px; height: 92px; font-size: 32px; }
#tAttack { right: calc(24px + env(safe-area-inset-right)); bottom: 28px; }
#tCharge { right: calc(128px + env(safe-area-inset-right)); bottom: 22px; }
#tFire { right: calc(206px + env(safe-area-inset-right)); bottom: 22px; }
#tJump { right: calc(30px + env(safe-area-inset-right)); bottom: 132px; }
#tDodge { right: calc(112px + env(safe-area-inset-right)); bottom: 104px; }
#tWrath { right: calc(186px + env(safe-area-inset-right)); bottom: 100px; }
#tWrath.ready { border-color: #fff3c8; animation: ready 0.6s ease-in-out infinite alternate; background: radial-gradient(circle, rgba(255,214,110,0.7), rgba(90,60,20,0.9)); color: #2a1400; }
#tPause { left: 50%; top: calc(8px + env(safe-area-inset-top)); width: 40px; height: 40px; margin-left: -20px; font-size: 14px; }

/* portrait phones */
@media (orientation: portrait) and (max-width: 600px) {
  #status { left: 10px; top: calc(8px + env(safe-area-inset-top)); width: 58vw; }
  #status .name { font-size: 13px; margin-bottom: 3px; }
  #status .name span { display: none; }
  .bar { height: 10px; margin-bottom: 4px; }
  .bar.musou { height: 8px; }
  .bar.musou .label { font-size: 7px; top: -2px; }
  #objective { font-size: 11px; margin-top: 4px; }
  #radarWrap { right: 8px; top: calc(8px + env(safe-area-inset-top)); }
  #radar { width: 84px; height: 84px; }
  #ko b { font-size: 20px; } #ko span { font-size: 10px; }
  #boss { top: calc(118px + env(safe-area-inset-top)); width: 80vw; }
  #boss .bname { font-size: 12px; letter-spacing: 2px; } #boss .bar { height: 8px; }
  #combo { right: 12px; top: 30%; } #combo b { font-size: 40px; } #combo span { font-size: 11px; }
  #banner { top: 26%; } #banner .main { font-size: 24px; letter-spacing: 2px; } #banner .sub { font-size: 12px; }
  body.touch #weapon { left: 10px; bottom: auto; top: calc(92px + env(safe-area-inset-top)); min-width: 0; padding: 3px 8px; }
  #weapon span { font-size: 10px; } #weapon b { font-size: 15px; } #weapon .allies { font-size: 9px; }
  #tPause { top: auto; bottom: calc(250px + env(safe-area-inset-bottom)); left: auto; right: 14px; margin: 0; }
  .tbtn { width: 54px; height: 54px; font-size: 19px; }
  .tbtn.big { width: 80px; height: 80px; font-size: 28px; }
  #tAttack { right: 14px; bottom: calc(24px + env(safe-area-inset-bottom)); }
  #tCharge { right: 102px; bottom: calc(18px + env(safe-area-inset-bottom)); }
  #tFire { right: 168px; bottom: calc(70px + env(safe-area-inset-bottom)); }
  #tJump { right: 22px; bottom: calc(116px + env(safe-area-inset-bottom)); }
  #tDodge { right: 92px; bottom: calc(90px + env(safe-area-inset-bottom)); }
  #tWrath { right: 60px; bottom: calc(176px + env(safe-area-inset-bottom)); }
  #title { padding: 16px; align-items: flex-start; }
  h1 { font-size: 42px; } .lore { font-size: 13px; }
}

/* compact HUD for phones in landscape */
@media (max-height: 520px) {
  #status { left: calc(12px + env(safe-area-inset-left)); top: 8px; width: min(300px, 42vw); }
  #status .name { font-size: 14px; margin-bottom: 3px; }
  #status .name span { display: none; }
  .bar { height: 11px; margin-bottom: 4px; }
  .bar.musou { height: 8px; }
  .bar.musou .label { font-size: 7px; top: -2px; }
  #objective { font-size: 11px; margin-top: 4px; }
  #radarWrap { right: calc(10px + env(safe-area-inset-right)); top: 8px; }
  #radar { width: 92px; height: 92px; }
  #ko b { font-size: 22px; }
  #ko span { font-size: 11px; }
  #combo { right: 18px; top: 34%; }
  #combo b { font-size: 44px; }
  #combo span { font-size: 12px; }
  #boss { top: 52px; width: 44vw; }
  #boss .bname { font-size: 12px; letter-spacing: 2px; }
  #boss .bar { height: 8px; }
  #banner { top: 22%; }
  body.touch #weapon { left: calc(12px + env(safe-area-inset-left)); bottom: auto; top: 86px; min-width: 0; padding: 3px 10px; }
  #banner .main { font-size: 26px; letter-spacing: 3px; }
  #banner .sub { font-size: 12px; }
  #weapon span { font-size: 10px; } #weapon b { font-size: 16px; } #weapon .allies { font-size: 9px; }
  h1 { font-size: 40px; } .lore { font-size: 12px; line-height: 1.5; } .btn { font-size: 14px; padding: 10px 22px; }
  #title { padding-left: 24px; align-items: flex-start; padding-top: 14px; }
  h2 { font-size: 34px; }
  .settings { gap: 6px; margin-top: 10px; font-size: 12px; }
}
