:root {
  color-scheme: dark;
  font-family: "Courier New", ui-monospace, monospace;
  --cyan: #25e9ff;
  --blue: #1684ff;
  --pink: #ff2ead;
  --gold: #ffc739;
  --ink: #030817;
  --panel: rgba(3, 12, 35, 0.86);
}

* { box-sizing: border-box; }

html, body {
  width: 100%;
  min-height: 100%;
  margin: 0;
  overflow: hidden;
  background: #020611;
  touch-action: none;
}

body {
  display: grid;
  place-items: center;
  min-height: 100dvh;
}

button { font: inherit; }

.game-shell {
  position: relative;
  width: min(100vw, calc(100dvh * 16 / 9));
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: #04122c;
  box-shadow: 0 0 80px rgba(0, 166, 255, 0.28);
  isolation: isolate;
  user-select: none;
  -webkit-user-select: none;
}

#game {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
}

.panel {
  border: clamp(1px, .16vw, 3px) solid rgba(72, 205, 255, .7);
  background: linear-gradient(180deg, rgba(7, 23, 54, .94), rgba(2, 8, 27, .88));
  box-shadow: inset 0 0 0 2px rgba(0, 0, 0, .45), 0 0 12px rgba(19, 181, 255, .22);
  clip-path: polygon(8px 0, calc(100% - 8px) 0, 100% 8px, 100% calc(100% - 8px), calc(100% - 8px) 100%, 8px 100%, 0 calc(100% - 8px), 0 8px);
}

.hud {
  position: absolute;
  z-index: 4;
  inset: 2.2% 2% auto;
  display: grid;
  grid-template-columns: 12% 24% 18% 30% 6%;
  gap: 1.3%;
  align-items: start;
  pointer-events: none;
}

.agent-card {
  display: flex;
  align-items: center;
  padding: 3%;
  min-height: clamp(52px, 6.7vw, 108px);
}

.agent-card img {
  width: 48%;
  aspect-ratio: 1;
  object-fit: contain;
  image-rendering: pixelated;
  background: radial-gradient(circle, rgba(37,233,255,.2), transparent 70%);
}

.agent-stats { display: grid; gap: .25em; font-size: clamp(6px, .74vw, 14px); }
.agent-stats strong { color: white; }
.agent-stats span { color: var(--gold); }

.status-stack { display: grid; gap: .7vw; padding-top: .35vw; }
.meter-row {
  display: grid;
  grid-template-columns: 20% 1fr auto;
  gap: 2%;
  align-items: center;
  padding: 2.5% 3%;
  font-weight: 900;
  font-size: clamp(6px, .76vw, 14px);
  background: rgba(1, 8, 25, .88);
  border: 2px solid #28486e;
  transform: skewX(-4deg);
}
.meter-row > * { transform: skewX(4deg); }
.meter { height: clamp(5px, .9vw, 15px); overflow: hidden; background: #10182c; border: 1px solid #4c6384; }
.meter i { display: block; height: 100%; width: 100%; transition: width .18s ease; }
.hp-row span { color: #ff6274; }
.hp-row i { background: linear-gradient(90deg, #ff2449, #ff6e8e); box-shadow: 0 0 9px #ff2449; }
.energy-row span { color: var(--cyan); }
.energy-row i { background: linear-gradient(90deg, #0968ff, #26efff); box-shadow: 0 0 9px #17bdff; }

.score-card {
  justify-self: center;
  min-width: 100%;
  padding: 4% 7%;
  text-align: center;
  line-height: 1;
}
.score-card span, .mission-card span { display: block; color: #bcd7f8; font-size: clamp(7px, .72vw, 14px); }
.score-card strong { display: block; margin: .15em 0; font-size: clamp(14px, 2vw, 38px); letter-spacing: .08em; text-shadow: 0 0 10px rgba(255,255,255,.45); }
.score-card em { color: var(--gold); font-size: clamp(8px, 1vw, 18px); font-style: normal; }

.mission-card { min-height: clamp(44px, 5.8vw, 92px); padding: 4% 6%; }
.mission-card strong { display: block; margin-top: .5em; color: white; font-size: clamp(7px, .9vw, 17px); }
.boss-meter { height: clamp(4px, .65vw, 10px); margin-top: .6em; background: #19051c; border: 1px solid #9b1c80; }
.boss-meter i { display: block; height: 100%; width: 100%; background: linear-gradient(90deg, #ed167e, #ff66d8); }

.icon-button {
  pointer-events: auto;
  width: 100%;
  aspect-ratio: 1;
  color: white;
  font-weight: 900;
  cursor: pointer;
}

.ability-bar {
  position: absolute;
  z-index: 5;
  left: 50%;
  bottom: 2.1%;
  display: flex;
  gap: .65vw;
  transform: translateX(-50%);
}
.ability-bar button {
  position: relative;
  min-width: clamp(74px, 8vw, 140px);
  padding: clamp(5px, .55vw, 11px) clamp(5px, .8vw, 14px);
  color: white;
  border: 2px solid #3477a7;
  background: linear-gradient(180deg, rgba(4,31,67,.94), rgba(2,12,30,.94));
  box-shadow: inset 0 0 12px rgba(0,194,255,.12), 0 3px 0 #020612;
  cursor: pointer;
}
.ability-bar button:active, .ability-bar button.active { transform: translateY(2px); border-color: var(--cyan); box-shadow: 0 0 14px rgba(37,233,255,.5); }
.ability-bar span { position: absolute; top: 2px; right: 4px; color: #7fa0c0; font-size: clamp(6px, .58vw, 11px); }
.ability-bar b { display: block; color: var(--cyan); font-size: clamp(7px, .72vw, 14px); }
.ability-bar small { font-size: clamp(7px, .9vw, 16px); }

.touch-controls {
  position: absolute;
  z-index: 5;
  inset: auto 2.8% 2.2%;
  display: flex;
  justify-content: space-between;
  pointer-events: none;
}
.move-controls, .action-controls { display: flex; gap: 1.2vw; align-items: end; }
.touch-controls button {
  pointer-events: auto;
  display: grid;
  place-items: center;
  width: clamp(48px, 7vw, 112px);
  aspect-ratio: 1;
  color: #d7e8ff;
  border: 3px solid rgba(198,224,255,.72);
  border-radius: 17%;
  background: rgba(8,24,49,.78);
  box-shadow: inset 0 0 18px rgba(126,194,255,.14), 0 0 0 3px rgba(3,8,20,.5);
  font-size: clamp(18px, 2.4vw, 44px);
  cursor: pointer;
}
.touch-controls .jump, .touch-controls .shoot { border-radius: 50%; }
.touch-controls .drop { color: #67f7ff; }
.touch-controls .shoot { width: clamp(58px, 8.3vw, 132px); }
.touch-controls button.pressed { color: white; border-color: var(--cyan); background: rgba(10,92,128,.72); transform: scale(.96); }
.touch-controls span { font-size: clamp(6px, .62vw, 12px); font-weight: 900; }

.overlay {
  position: absolute;
  z-index: 10;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 4%;
  background: radial-gradient(circle at 50% 40%, rgba(4,26,58,.55), rgba(0,3,12,.94));
  backdrop-filter: blur(3px);
}
.start-overlay {
  background:
    linear-gradient(90deg, rgba(0,5,19,.95) 0%, rgba(0,7,24,.75) 42%, rgba(0,5,19,.35) 100%),
    url('/assets/concept-art.png') center/cover;
  place-items: center start;
}
.overlay[hidden] { display: none; }
.overlay-card {
  width: min(44%, 620px);
  margin-left: 4%;
  padding: clamp(18px, 3.2vw, 56px);
  border-left: clamp(4px, .5vw, 9px) solid var(--cyan);
  background: linear-gradient(135deg, rgba(3,12,34,.96), rgba(4,17,42,.82));
  box-shadow: 0 0 60px rgba(0,183,255,.2), inset 0 0 40px rgba(0,132,255,.09);
  clip-path: polygon(0 0, 92% 0, 100% 13%, 100% 100%, 8% 100%, 0 87%);
}
.overlay-card.compact { width: min(48%, 560px); margin: 0; text-align: center; }
.eyebrow { margin: 0 0 .7em; color: var(--cyan); font-size: clamp(8px, 1vw, 17px); letter-spacing: .2em; }
.overlay h1 { margin: 0; font-size: clamp(30px, 5.7vw, 100px); line-height: .8; letter-spacing: -.07em; text-shadow: 4px 5px 0 #09142f, 0 0 25px rgba(38,235,255,.35); }
.overlay h1 span, .overlay h2 { color: var(--pink); }
.overlay h2 { margin: .15em 0 .45em; font-size: clamp(24px, 4vw, 66px); }
.overlay-card > p:not(.eyebrow) { max-width: 38em; font-size: clamp(8px, .9vw, 16px); line-height: 1.6; color: #b9cae4; }
.overlay-card > p strong { color: #ff55c8; }
.primary-button {
  display: block;
  min-width: 70%;
  margin: 1.5em 0 .7em;
  padding: .9em 1.3em;
  color: #00121b;
  border: 0;
  background: linear-gradient(90deg, #20dcff, #37ffce);
  box-shadow: 0 5px 0 #077b91, 0 0 24px rgba(33,234,255,.42);
  font-weight: 900;
  font-size: clamp(10px, 1.1vw, 20px);
  cursor: pointer;
}
.compact .primary-button { margin-inline: auto; }
.primary-button:hover { filter: brightness(1.14); }
.primary-button:active { transform: translateY(3px); box-shadow: 0 2px 0 #077b91; }
.overlay small { color: #7892b6; font-size: clamp(6px, .65vw, 12px); }
.result-score { display: grid; gap: .1em; color: #9db1cc; }
.result-score strong { color: var(--gold); font-size: clamp(24px, 4.5vw, 76px); }
.rotate-hint { display: none; }

@media (hover: hover) and (pointer: fine) {
  .touch-controls { opacity: .24; }
  .touch-controls:hover { opacity: 1; }
}

@media (max-aspect-ratio: 1/1) and (orientation: portrait) {
  .game-shell { width: 100vw; height: 100dvh; aspect-ratio: auto; }
  #game, .hud, .ability-bar, .touch-controls, .overlay { filter: blur(7px) brightness(.4); }
  .rotate-hint {
    position: absolute;
    z-index: 30;
    inset: 0;
    display: grid;
    place-items: center;
    margin: 0;
    padding: 20vw;
    text-align: center;
    color: white;
    font-size: 5vw;
    background: rgba(0,4,16,.6);
  }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; transition: none !important; }
}
