:root {
  --accent: #34f5c5;
  --hot: #ff4b5c;
  --ink: #eafff9;
  --muted: #86a9a2;
  --panel: rgba(3, 12, 12, 0.82);
  --line: rgba(126, 255, 222, 0.28);
}

* { box-sizing: border-box; }

html, body { width: 100%; height: 100%; margin: 0; overflow: hidden; background: #020505; color: var(--ink); }

body {
  font-family: "Arial Narrow", "Bahnschrift Condensed", "Segoe UI", sans-serif;
  letter-spacing: 0.035em;
}

button { font: inherit; }
button, .touch-stick { -webkit-tap-highlight-color: transparent; user-select: none; }

.game { position: relative; width: 100vw; height: 100vh; background: #020505; isolation: isolate; }

#cityCanvas { position: absolute; inset: 0; width: 100%; height: 100%; outline: none; touch-action: none; }

.topbar {
  position: absolute;
  top: 18px;
  left: 18px;
  right: 18px;
  min-height: 76px;
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 24px;
  align-items: center;
  padding: 12px 16px;
  background: linear-gradient(90deg, rgba(2, 11, 11, .94), rgba(3, 17, 16, .74));
  border: 1px solid var(--line);
  border-top: 2px solid var(--accent);
  clip-path: polygon(0 0, 98.5% 0, 100% 25%, 100% 100%, 1.5% 100%, 0 75%);
  backdrop-filter: blur(12px);
}

.brand { display: flex; gap: 13px; align-items: center; }
.brand img { width: 46px; height: 46px; object-fit: contain; filter: drop-shadow(0 0 12px rgba(52,245,197,.25)); }
.brand div, .city-readout { display: flex; flex-direction: column; }
.brand span, .city-readout span, .city-readout small, .eyebrow, .power-stack > span, .combo-meter > span {
  color: var(--muted); font-size: 10px; font-weight: 800; letter-spacing: .18em;
}
.brand strong { font-size: clamp(20px, 2.2vw, 32px); line-height: .95; letter-spacing: .03em; }
.brand b { color: var(--accent); }
.city-readout { align-items: flex-end; min-width: 155px; }
.city-readout strong { color: var(--accent); font-size: 22px; }
.city-readout small { margin-top: 2px; }

.icon-button, .message button {
  border: 1px solid var(--accent); color: var(--accent); background: rgba(4, 28, 24, .82); font-weight: 900; cursor: pointer;
}
.icon-button { width: 48px; height: 48px; }

.mission-panel, .controls-panel, .player-panel, .boss-panel, .run-panel {
  position: absolute; background: var(--panel); border: 1px solid var(--line); backdrop-filter: blur(10px); box-shadow: 0 16px 50px rgba(0,0,0,.22);
}

.mission-panel { top: 112px; left: 18px; width: min(350px, calc(100vw - 36px)); padding: 14px 16px; }
.mission-panel strong { display: block; margin: 4px 0 9px; font-size: 15px; }
.mission-panel > span:last-child { display: block; margin-top: 7px; color: var(--muted); font-size: 10px; }
.progress-track, .boss-track, .combo-track { height: 5px; background: rgba(255,255,255,.09); overflow: hidden; }
.progress-track i, .boss-track i, .combo-track i { display: block; width: 0%; height: 100%; background: var(--accent); box-shadow: 0 0 14px var(--accent); transition: width .18s ease; }

.pattern-readout { margin-top: 11px; padding-top: 9px; border-top: 1px solid rgba(255,255,255,.08); }
.pattern-readout span { display: block; color: var(--accent); font-size: 9px; letter-spacing: .16em; }
.pattern-readout strong { margin: 4px 0 0; color: #d9eee8; font-size: 10px; letter-spacing: .09em; }

.run-panel { top: 112px; right: 18px; display: grid; grid-template-columns: repeat(3, auto); gap: 22px; padding: 12px 16px; }
.run-panel div { display: flex; flex-direction: column; align-items: flex-end; }
.run-panel span { color: var(--muted); font-size: 8px; font-weight: 900; letter-spacing: .16em; }
.run-panel strong { margin-top: 3px; color: var(--accent); font-size: 16px; font-variant-numeric: tabular-nums; }

.boss-panel { top: 112px; left: 50%; width: min(510px, 52vw); padding: 12px 16px; transform: translateX(-50%); }
.boss-panel div:first-child { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; }
.boss-panel span { color: var(--hot); font-size: 10px; letter-spacing: .16em; }
.boss-panel strong { font-size: 16px; }
.boss-track i { width: 100%; background: var(--hot); box-shadow: 0 0 16px var(--hot); }

.player-panel { left: 18px; bottom: 18px; display: flex; align-items: center; gap: 18px; padding: 12px 16px; }
.health-ring { width: 60px; height: 60px; display: grid; place-content: center; text-align: center; border: 2px solid var(--accent); border-radius: 50%; box-shadow: inset 0 0 18px rgba(52,245,197,.18), 0 0 18px rgba(52,245,197,.12); }
.health-ring span { font-size: 9px; color: var(--muted); }
.health-ring strong { font-size: 22px; line-height: 1; }
.power-stack { min-width: 150px; }
.power-chips { display: flex; gap: 5px; margin-top: 7px; }
.power-chip { padding: 5px 7px; color: var(--muted); border: 1px solid rgba(255,255,255,.12); font-size: 9px; }
.power-chip.is-active { color: #04110e; background: var(--accent); border-color: var(--accent); }
.power-chip.is-locked { opacity: .34; }
.combo-meter { width: 150px; }
.combo-meter strong { display: block; margin: 5px 0; color: var(--accent); font-size: 12px; }

.controls-panel { right: 18px; bottom: 18px; max-width: 360px; padding: 11px 14px; color: var(--muted); font-size: 10px; }
.controls-panel span { color: var(--ink); font-weight: 900; margin-left: 10px; }
.controls-panel span:first-child { margin-left: 0; }

.touch-controls { display: none; }

.message {
  position: absolute; top: 50%; left: 50%; width: min(560px, calc(100vw - 40px)); padding: 28px; transform: translate(-50%, -50%);
  text-align: center; background: rgba(2, 10, 10, .95); border: 1px solid var(--accent); box-shadow: 0 0 80px rgba(52,245,197,.16); z-index: 8;
}
.message span { color: var(--accent); font-size: 11px; letter-spacing: .22em; }
.message strong { display: block; margin: 8px 0; font-size: clamp(26px, 5vw, 54px); line-height: .92; }
.message p { max-width: 430px; margin: 14px auto 22px; color: #b5cbc5; line-height: 1.55; }
.message button { padding: 12px 20px; }
.message .secondary-button { margin-left: 8px; color: var(--ink); border-color: rgba(255,255,255,.24); background: rgba(255,255,255,.04); }

.depth-reticle { position: absolute; inset: 22% 39% 24%; z-index: 4; pointer-events: none; border: 1px solid rgba(255,255,255,.12); box-shadow: inset 0 0 60px rgba(0,0,0,.24); }
.depth-reticle::before, .depth-reticle::after { content: ""; position: absolute; left: 50%; top: 50%; background: var(--accent); box-shadow: 0 0 10px var(--accent); }
.depth-reticle::before { width: 34px; height: 1px; transform: translate(-50%, -50%); }
.depth-reticle::after { width: 1px; height: 34px; transform: translate(-50%, -50%); }
.depth-reticle i, .depth-reticle b { position: absolute; left: -34vw; right: -34vw; height: 1px; background: linear-gradient(90deg, transparent, rgba(255,255,255,.18), transparent); transform-origin: center; }
.depth-reticle i { top: 0; transform: rotate(12deg); }
.depth-reticle b { bottom: 0; transform: rotate(-12deg); }
.depth-reticle span { position: absolute; top: -20px; left: 50%; transform: translateX(-50%); color: var(--accent); font-size: 9px; letter-spacing: .24em; }

.loading { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 7px; background: #020606; z-index: 10; transition: opacity .4s ease; }
.game:not(.is-loading) .loading { opacity: 0; pointer-events: none; }
.loader-mark { width: 62px; height: 62px; border: 2px solid rgba(52,245,197,.18); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
.loading strong { margin-top: 10px; color: var(--accent); }
.loading span { color: var(--muted); font-size: 11px; }

.scanlines { position: absolute; inset: 0; pointer-events: none; opacity: .13; background: repeating-linear-gradient(0deg, transparent 0 3px, rgba(128,255,226,.16) 4px); mix-blend-mode: screen; }
.damage-flash { position: absolute; inset: 0; pointer-events: none; background: rgba(255,30,54,.32); opacity: 0; transition: opacity .18s ease; }
.damage-flash.is-active { opacity: 1; transition: none; }

@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 760px), (max-width: 950px) and (max-height: 600px), (pointer: coarse) {
  .topbar { top: 8px; left: 8px; right: 8px; min-height: 62px; grid-template-columns: 1fr auto; gap: 8px; padding: 8px 10px; }
  .brand { gap: 8px; min-width: 0; }
  .brand img { width: 36px; height: 36px; }
  .brand span { display: none; }
  .brand strong { font-size: clamp(17px, 5.2vw, 23px); white-space: nowrap; }
  .icon-button { width: 42px; height: 42px; }
  .city-readout { display: none; }
  .mission-panel { top: 78px; left: 8px; width: min(285px, calc(100vw - 16px)); padding: 10px 12px; }
  .mission-panel strong { margin: 2px 0 6px; font-size: 12px; }
  .run-panel { top: 78px; right: 8px; bottom: auto; gap: 9px; padding: 7px 8px; }
  .run-panel strong { font-size: 13px; }
  .controls-panel { display: none; }
  .player-panel { left: 8px; right: auto; bottom: 122px; gap: 8px; padding: 7px 9px; transform: scale(.82); transform-origin: left bottom; }
  .health-ring { width: 48px; height: 48px; }
  .health-ring strong { font-size: 18px; }
  .power-stack { min-width: 88px; }
  .combo-meter { display: none; }
  .pattern-readout { display: none; }
  .depth-reticle { inset: 25% 32% 31%; }
  .message { width: calc(100vw - 20px); max-height: calc(100dvh - 24px); overflow: auto; padding: 20px 16px; }
  .message strong { font-size: clamp(27px, 10vw, 44px); }
  .message p { margin: 11px auto 16px; font-size: 14px; line-height: 1.4; }
  .message button { min-height: 48px; padding: 11px 14px; }
  .message .secondary-button { margin: 8px 0 0; }

  .touch-controls {
    position: absolute; z-index: 7; left: 10px; right: 10px; bottom: max(10px, env(safe-area-inset-bottom));
    display: flex; align-items: flex-end; justify-content: space-between; pointer-events: none;
  }
  .touch-guide { position: absolute; right: 0; bottom: 118px; padding: 5px 8px; color: #b8d5ce; border: 1px solid rgba(126,255,222,.22); background: rgba(2,12,12,.84); font-size: 8px; letter-spacing: .08em; white-space: nowrap; }
  .touch-guide b { color: var(--accent); }
  .touch-guide span { margin: 0 3px; color: var(--hot); }
  .touch-stick {
    position: relative; width: 104px; height: 104px; flex: 0 0 104px; border: 1px solid rgba(126,255,222,.5); border-radius: 50%;
    background: radial-gradient(circle, rgba(52,245,197,.14) 0 18%, rgba(3,18,17,.72) 19% 64%, rgba(52,245,197,.08) 65%);
    box-shadow: inset 0 0 24px rgba(52,245,197,.1); touch-action: none; pointer-events: auto;
  }
  .touch-stick::before, .touch-stick::after { content: ""; position: absolute; left: 50%; top: 50%; background: rgba(126,255,222,.22); transform: translate(-50%, -50%); }
  .touch-stick::before { width: 76%; height: 1px; }
  .touch-stick::after { width: 1px; height: 76%; }
  .touch-stick i { position: absolute; z-index: 1; left: calc(50% - 21px); top: calc(50% - 21px); width: 42px; height: 42px; border: 2px solid var(--accent); border-radius: 50%; background: rgba(2,22,18,.92); box-shadow: 0 0 18px rgba(52,245,197,.3); }
  .touch-stick > span { position: absolute; z-index: 2; left: 50%; bottom: 6px; transform: translateX(-50%); padding: 2px 5px; color: var(--accent); background: rgba(2,12,12,.82); font-size: 9px; font-weight: 900; letter-spacing: .14em; }
  .touch-actions { width: 184px; display: grid; grid-template-columns: repeat(3, 52px); grid-template-rows: repeat(2, 52px); gap: 8px; justify-content: end; pointer-events: auto; }
  .touch-actions button { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; border: 1px solid rgba(126,255,222,.62); border-radius: 50%; color: var(--ink); background: rgba(3,18,17,.94); font-weight: 900; touch-action: none; box-shadow: 0 0 14px rgba(0,0,0,.32); }
  .touch-actions button b { font-size: 15px; line-height: 1; }
  .touch-actions button small { color: #a8c9c1; font-size: 6px; line-height: 1; letter-spacing: .08em; }
  .touch-actions button.is-pressed { color: #03110e; background: var(--accent); transform: scale(.94); }
  .touch-actions .touch-fire { grid-column: 3; grid-row: 1 / span 2; align-self: center; width: 72px; height: 72px; margin-left: -12px; color: var(--hot); border: 2px solid var(--hot); background: rgba(35,5,10,.96); box-shadow: 0 0 20px rgba(255,75,92,.2); }
  .touch-actions .touch-fire b { font-size: 23px; }
  .touch-actions .touch-fire small { color: #ffb1ba; font-size: 7px; }
}

@media (max-width: 560px) {
  .mission-panel { width: calc(100vw - 136px); }
  .run-panel span { font-size: 7px; }
}

@media (max-height: 520px) and (orientation: landscape) {
  .topbar { min-height: 52px; }
  .brand img { width: 30px; height: 30px; }
  .mission-panel { top: 68px; width: 230px; }
  .run-panel { top: 68px; }
  .player-panel { bottom: 8px; left: 126px; }
  .touch-stick { width: 92px; height: 92px; flex-basis: 92px; }
  .touch-actions { transform: scale(.88); transform-origin: right bottom; }
}
