/* DigitGalaxy — screens, HUD, buttons (the 3D scene is the <canvas id="gl">). */
:root {
  --cyan: #5fe3ff; --cyan2: #b9f4ff; --pink: #ff4f9a; --green: #4dff9a; --red: #ff3a52; --amber: #ffc24a;
  --panel: rgba(6, 18, 32, 0.62); --edge: rgba(95, 227, 255, 0.45);
  --font: "Baloo 2", "Nunito", "Trebuchet MS", "Segoe UI", Roboto, system-ui, sans-serif;
  --safe-t: env(safe-area-inset-top, 0px); --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #02040a; color: #e8f6ff; font-family: var(--font);
  -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent; overscroll-behavior: none; }
#gl { position: fixed; inset: 0; width: 100vw; height: 100vh; height: 100dvh; display: block; touch-action: none; }
button { font-family: inherit; }

/* ---------------------------------------------------------------- screens */
.screen { position: fixed; inset: 0; display: none; flex-direction: column; align-items: center; justify-content: center;
  gap: 18px; text-align: center; z-index: 20; padding: 24px; }
.mode-loading #loading, .mode-title #title { display: flex; }
#loading { background: radial-gradient(ellipse at 50% 40%, #11204a 0%, #04060f 70%); }
#title { background: linear-gradient(180deg, rgba(2,4,12,0.55) 0%, rgba(2,4,12,0) 35%, rgba(2,4,12,0) 60%, rgba(2,4,12,0.75) 100%); justify-content: space-between; padding: calc(36px + var(--safe-t)) 24px calc(30px + var(--safe-b)); }
.logo { font-weight: 900; font-size: clamp(42px, 9vw, 96px); letter-spacing: 0.02em; line-height: 1; filter: drop-shadow(0 0 18px rgba(95,227,255,0.55)); }
.logo span { color: #fff; }
.logo b { background: linear-gradient(90deg, #5fe3ff, #b78bff 55%, #ff6fb4); -webkit-background-clip: text; background-clip: text; color: transparent; }
.logo.big { font-size: clamp(54px, 12vw, 128px); animation: float 4s ease-in-out infinite; }
@keyframes float { 50% { transform: translateY(-8px); } }
.tag { margin: 6px 0 0; font-size: clamp(18px, 3.2vw, 26px); color: var(--cyan2); text-shadow: 0 2px 8px #000; }
.bar { width: min(420px, 70vw); height: 12px; border-radius: 8px; background: rgba(255,255,255,0.1); overflow: hidden; border: 1px solid var(--edge); }
.bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--cyan), #b78bff); transition: width 0.2s; }
#loadtxt { color: var(--cyan2); opacity: 0.8; }

.btn { border: 0; border-radius: 18px; padding: 14px 28px; font-size: 22px; font-weight: 800; color: #fff; cursor: pointer;
  background: rgba(20, 40, 70, 0.8); box-shadow: inset 0 0 0 2px var(--edge), 0 6px 18px rgba(0,0,0,0.4); transition: transform 0.1s; }
.btn:active { transform: scale(0.95); }
.btn.primary { font-size: clamp(24px, 4.2vw, 34px); padding: 18px 46px; border-radius: 26px;
  background: linear-gradient(180deg, #ff8a3a, #ff3f6c); box-shadow: 0 0 0 3px rgba(255,255,255,0.25), 0 0 34px rgba(255,90,110,0.6), 0 10px 24px rgba(0,0,0,0.45);
  animation: pulse 1.8s ease-in-out infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 3px rgba(255,255,255,0.35), 0 0 56px rgba(255,90,110,0.9), 0 10px 24px rgba(0,0,0,0.45); } }
.opts { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.chip { display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px; border-radius: 20px; background: var(--panel);
  border: 1px solid var(--edge); font-size: 15px; color: var(--cyan2); }
.chip.dim { opacity: 0.75; }
.chip input { width: 18px; height: 18px; accent-color: var(--cyan); }

/* ---------------------------------------------------------------- HUD */
#hud { position: fixed; inset: 0; pointer-events: none; display: none; z-index: 10; }
.mode-play #hud, .mode-cut #hud { display: block; }
.panel { position: absolute; background: var(--panel); border: 1px solid var(--edge); border-radius: 16px;
  box-shadow: 0 0 22px rgba(95,227,255,0.15), inset 0 0 18px rgba(95,227,255,0.08); }
#engines { left: 12px; top: calc(12px + var(--safe-t)); width: clamp(120px, 17vw, 190px); padding: 8px 10px 6px; }
#engines svg { width: 100%; display: block; overflow: visible; }
#engines .hull { fill: url(#hullg); stroke: #2c3a4a; stroke-width: 2; opacity: 0.9; }
#engines .canopy { fill: #0d3550; stroke: #5fe3ff; stroke-width: 1.5; }
#engines .lbl { font-size: 13px; font-weight: 800; letter-spacing: 0.08em; color: var(--cyan2); text-align: center; }
#engines .lbl b { color: #fff; }
.eng circle.core { transition: fill 0.3s; }
.eng.ok circle.core { fill: #4dff9a; filter: drop-shadow(0 0 6px #4dff9a); }
.eng.ok .flame { fill: #6fe6ff; opacity: 0.85; animation: flick 0.12s infinite alternate; }
.eng.broken circle.core { fill: #ff3a52; animation: blink 0.6s infinite; }
.eng.broken .flame { display: none; }
.eng.broken .crack { display: block; }
.eng .crack { display: none; stroke: #fff; stroke-width: 2.4; fill: none; stroke-linecap: round; }
.eng .smoke { display: none; fill: #8a8f99; opacity: 0.6; }
.eng.broken .smoke { display: block; animation: smoke 1.4s linear infinite; }
.eng.broken .smoke.s2 { animation-delay: 0.7s; }
.eng .num { font: 800 13px var(--font); fill: #081622; text-anchor: middle; dominant-baseline: central; }
.eng.just { animation: boom 0.9s ease-out; transform-box: fill-box; transform-origin: center; }
@keyframes flick { to { opacity: 0.45; } }
@keyframes blink { 50% { fill: #5a0a14; } }
@keyframes smoke { from { transform: translateY(0) scale(0.6); opacity: 0.7; } to { transform: translateY(26px) scale(1.8); opacity: 0; } }
@keyframes boom { 0% { transform: scale(2.6); } 100% { transform: scale(1); } }

#target { left: 50%; top: calc(12px + var(--safe-t)); transform: translateX(-50%); padding: 8px 18px 10px; min-width: min(46vw, 360px); text-align: center; }
#target .sector { font-size: 13px; letter-spacing: 0.12em; color: var(--cyan2); font-weight: 800; text-transform: uppercase; }
#target .aname { font-size: clamp(18px, 2.6vw, 26px); font-weight: 900; color: #fff; text-shadow: 0 0 12px rgba(255,79,154,0.7); }
#target .hp { display: flex; gap: 5px; margin-top: 6px; }
#target .hp i { flex: 1; height: 12px; border-radius: 6px; background: linear-gradient(180deg, #ff86c0, #ff2f7a); box-shadow: 0 0 10px rgba(255,79,154,0.6); transition: all 0.4s; }
#target .hp i.off { background: rgba(255,79,154,0.14); box-shadow: none; }
#target .hp i.hit { animation: hpHit 0.6s; }
@keyframes hpHit { 0% { transform: scaleY(2.2); background: #fff; } }
#tools { position: absolute; right: 12px; top: calc(12px + var(--safe-t)); display: flex; gap: 8px; pointer-events: auto; }
.round { width: 48px; height: 48px; border-radius: 50%; border: 1px solid var(--edge); background: var(--panel); color: #fff; font-size: 22px; cursor: pointer; }

/* controls placed next to the 3D touch screen by main.js */
#controls { position: fixed; display: none; z-index: 12; gap: 12px; }
.mode-play #controls { display: flex; }
#controls.vertical { flex-direction: column; }
.ctl { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; padding: 8px 10px; min-width: 86px; min-height: 76px;
  font-size: 30px; border-radius: 20px; }
.ctl span { font-size: 15px; font-weight: 800; letter-spacing: 0.04em; }
.ctl.fire { background: linear-gradient(180deg, #ff6a3a, #e21f4a); box-shadow: 0 0 0 3px rgba(255,255,255,0.25), 0 0 26px rgba(255,60,80,0.7); min-height: 96px; font-size: 36px; }
.ctl.fire span { font-size: 19px; }
.ctl.fire.ready { animation: pulse 1.1s ease-in-out infinite; }
.ctl:disabled { opacity: 0.35; filter: grayscale(0.6); animation: none; }
.ctl.say { background: rgba(30, 60, 110, 0.85); }

/* ---------------------------------------------------------------- banners and effects */
#banner { position: fixed; left: 0; right: 0; top: 30%; z-index: 15; text-align: center; pointer-events: none; opacity: 0; }
#banner .b1 { font-size: clamp(30px, 6.4vw, 68px); padding: 0 12px; line-height: 1.05; font-weight: 900; color: #fff; text-shadow: 0 0 24px var(--bc, #5fe3ff), 0 4px 14px #000; }
#banner .b2 { font-size: clamp(18px, 3.2vw, 28px); font-weight: 700; color: var(--cyan2); text-shadow: 0 2px 8px #000; margin-top: 6px; }
#banner.show { animation: bannerIn 2.6s ease-out forwards; }
@keyframes bannerIn { 0% { opacity: 0; transform: scale(1.6); letter-spacing: 0.3em; } 12% { opacity: 1; transform: scale(1); letter-spacing: 0.02em; }
  80% { opacity: 1; } 100% { opacity: 0; transform: scale(0.96); } }
#flash { position: fixed; inset: 0; pointer-events: none; z-index: 14; opacity: 0; background: #fff; }
#flash.go { animation: flash var(--fd, 0.5s) ease-out; }
@keyframes flash { 0% { opacity: var(--fo, 0.9); } 100% { opacity: 0; } }
#vignette { position: fixed; inset: 0; pointer-events: none; z-index: 13; opacity: 0; transition: opacity 0.5s;
  background: radial-gradient(ellipse at center, transparent 55%, rgba(255, 20, 40, 0.55) 100%); }
#vignette.on { opacity: 1; animation: vig 0.8s ease-in-out infinite alternate; }
@keyframes vig { to { opacity: 0.45; } }
#cracks { position: fixed; inset: 0; pointer-events: none; z-index: 13; opacity: 0; transition: opacity 1.5s; }
#cracks.on { opacity: 1; transition: opacity 0.05s; }
#cracks svg { width: 100%; height: 100%; }

.mode-menu #menu, .mode-end #end { display: flex; background: rgba(2,4,12,0.6); }
.card { background: rgba(8, 20, 38, 0.92); border: 1px solid var(--edge); border-radius: 26px; padding: 26px 30px; display: flex; flex-direction: column; gap: 14px;
  min-width: min(420px, 88vw); box-shadow: 0 0 40px rgba(95,227,255,0.25); }
.card h2 { margin: 0; font-size: clamp(32px, 6vw, 52px); }
#endText { margin: 0; font-size: 20px; color: var(--cyan2); }
#endStats { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
#endStats div { background: rgba(95,227,255,0.1); border-radius: 14px; padding: 8px 14px; font-size: 16px; }
#endStats b { display: block; font-size: 30px; color: #fff; }
#toast { position: fixed; bottom: calc(16px + var(--safe-b)); left: 50%; transform: translateX(-50%) translateY(120%); z-index: 30; background: var(--panel);
  border: 1px solid var(--edge); border-radius: 14px; padding: 10px 16px; font-size: 15px; transition: transform 0.35s, opacity 0.35s; pointer-events: none; max-width: 92vw; opacity: 0; }
#toast.on { transform: translateX(-50%) translateY(0); opacity: 1; }
.mode-cut #controls { display: none; }
@media (min-aspect-ratio: 85/100) { #target { left: auto; right: 124px; transform: none; min-width: 0; width: clamp(180px, 24vw, 300px); } }
@media (max-width: 520px) { #engines { width: 112px; } #target { min-width: 0; width: 44vw; padding: 6px 10px 8px; } .round { width: 40px; height: 40px; font-size: 18px; } #tools { gap: 6px; } }
