:root {
  --cyan: #00e5ff;
  --cyan-hot: #7af6ff;
  --cyan-deep: #00b4d4;
  --cyan-dim: #1488a8;
  --magenta: #e040e8;
  --magenta-hot: #ff5ae0;
  --pink: #ff48c8;
  --orange: #ff9a28;
  --green: #40ff62;
  --hp: #e84a6a;
  --hp-hot: #ff6a88;
  --navy: #041018;
  --panel: rgba(4, 16, 28, 0.72);
  --ink: #d8f6ff;
  --muted: #5aa0b8;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #030b12;
  color: var(--ink);
  font-family: "Rajdhani", "Exo 2", "Segoe UI", sans-serif;
  user-select: none;
}

#stage {
  position: fixed;
  inset: 0;
  background: #030b12;
}

#c {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  z-index: 0;
}

.hidden { display: none !important; }

button { font-family: inherit; cursor: pointer; }

/* ========== FLOATING WORLD LABELS ========== */
#float-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 6;
  overflow: hidden;
}

.floater {
  position: absolute;
  transform: translate(-50%, -100%);
  white-space: nowrap;
  pointer-events: none;
  font-family: "Orbitron", "Share Tech Mono", sans-serif;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.floater.dmg {
  font-size: 14px;
  color: #ff9ad8;
  text-shadow: 0 0 10px #ff40c8;
}

.floater.score {
  font-size: 16px;
  color: #ff5ae0;
  text-shadow: 0 0 12px #ff40c8;
}

.floater.chain {
  font-size: 13px;
  color: #7af6ff;
  text-shadow: 0 0 12px #00e5ff;
}

.floater.hpbar {
  width: 42px;
  height: 5px;
  background: rgba(0, 0, 0, 0.55);
  border: 1px solid rgba(0, 229, 255, 0.25);
  border-radius: 2px;
  transform: translate(-50%, 8px);
}
.floater.hpbar i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, #e84a6a, #ff8aa0);
  width: 70%;
}

/* ========== HUD ========== */
#hud {
  position: absolute;
  inset: 0;
  z-index: 5;
  pointer-events: none;
}

#hud-tl {
  position: absolute;
  top: 10px;
  left: 14px;
  display: flex;
  gap: 14px;
  align-items: flex-start;
  pointer-events: none;
}

#title-block {
  display: flex;
  flex-direction: column;
  line-height: 0.92;
  filter: drop-shadow(0 0 10px rgba(0, 229, 255, 0.45));
}

.echo-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.echo, .loc {
  font-family: "Orbitron", "Exo 2", sans-serif;
  font-weight: 800;
  color: var(--cyan);
  letter-spacing: 0.04em;
  text-shadow: 0 0 14px rgba(0, 229, 255, 0.7), 0 0 28px rgba(0, 180, 212, 0.4);
}

.echo { font-size: clamp(22px, 2.4vw, 34px); }

.loc {
  font-size: clamp(18px, 1.9vw, 28px);
  margin-top: 1px;
}

.turn-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
  width: 100%;
}

.turn {
  font-family: "Orbitron", sans-serif;
  font-weight: 700;
  font-size: clamp(11px, 1.05vw, 15px);
  letter-spacing: 0.42em;
  color: var(--cyan);
  text-shadow: 0 0 10px rgba(0, 229, 255, 0.55);
}

.turn-rule {
  flex: 1;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--cyan), transparent);
  box-shadow: 0 0 8px var(--cyan);
  opacity: 0.85;
}

.sonar-mark {
  width: 28px;
  height: 28px;
  margin-left: 2px;
  position: relative;
}
.sonar-mark::before,
.sonar-mark::after {
  content: "";
  position: absolute;
  left: 4px;
  top: 50%;
  transform: translateY(-50%);
  border: 2px solid var(--cyan);
  border-left-color: transparent;
  border-bottom-color: transparent;
  border-radius: 50%;
}
.sonar-mark::before {
  width: 14px; height: 14px;
  opacity: 0.95;
}
.sonar-mark::after {
  width: 22px; height: 22px;
  left: 0;
  opacity: 0.55;
}

#kairo-chip {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 4px 8px 4px 4px;
}

.portrait-hex {
  width: 72px;
  height: 78px;
  clip-path: polygon(50% 0%, 95% 25%, 95% 75%, 50% 100%, 5% 75%, 5% 25%);
  background: radial-gradient(circle at 50% 40%, #2a1848 0%, #0a1020 70%);
  box-shadow: 0 0 0 2px #00e5ff, 0 0 16px rgba(0, 229, 255, 0.55), inset 0 0 18px rgba(180, 60, 255, 0.35);
  overflow: hidden;
  flex: 0 0 72px;
  filter: drop-shadow(0 0 8px rgba(0, 229, 255, 0.5));
}
.portrait-hex img {
  width: 118%;
  height: 118%;
  object-fit: cover;
  transform: translate(-8%, -6%);
  mix-blend-mode: screen;
}

.kairo-stats {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 230px;
}

.stat-row {
  display: grid;
  grid-template-columns: 58px 1fr 54px;
  align-items: center;
  gap: 8px;
}

.stat-lab {
  font-family: "Orbitron", "Rajdhani", sans-serif;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
}
.stat-lab.hp { color: #ff6a88; }
.stat-lab.sonar { color: var(--cyan); }

.stat-num {
  font-family: "Orbitron", "Share Tech Mono", sans-serif;
  font-size: 11px;
  font-weight: 700;
  color: var(--cyan-hot);
  text-align: right;
  text-shadow: 0 0 8px rgba(0, 229, 255, 0.5);
}

.bar {
  height: 9px;
  background: rgba(4, 10, 18, 0.85);
  border: 1px solid rgba(0, 229, 255, 0.22);
  border-radius: 2px;
  overflow: hidden;
  position: relative;
}
.bar i {
  display: block;
  height: 100%;
  width: 68%;
  border-radius: 1px;
}
.bar.hp i {
  background: linear-gradient(90deg, #c03050, #e84a6a 40%, #ff7a94);
  box-shadow: 0 0 8px #e84a6a;
  width: 68%;
}
.bar.sonar i {
  background: linear-gradient(90deg, #007a98, #00c8e8 50%, #7af6ff);
  box-shadow: 0 0 8px #00e5ff;
  width: 95%;
}
.bar.combo {
  height: 10px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(4, 10, 18, 0.8);
  flex: 1;
}
.bar.combo i {
  width: 78%;
  background: linear-gradient(90deg, #ff4aa0, #ff9a40 28%, #ffe060 48%, #40e878 70%, #40d0ff);
  box-shadow: 0 0 10px rgba(255, 80, 180, 0.45);
}

.kairo-id {
  font-family: "Orbitron", sans-serif;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.16em;
  color: var(--cyan);
  text-shadow: 0 0 10px rgba(0, 229, 255, 0.55);
  margin-top: 2px;
}

/* TOP RIGHT */
#hud-tr {
  position: absolute;
  top: 10px;
  right: 16px;
  display: flex;
  gap: 16px;
  align-items: flex-start;
}

#score-block {
  text-align: right;
  min-width: 220px;
  padding-top: 6px;
}

.score-lab {
  font-family: "Orbitron", sans-serif;
  font-size: clamp(16px, 1.6vw, 22px);
  font-weight: 800;
  color: var(--cyan);
  letter-spacing: 0.04em;
  text-shadow: 0 0 12px rgba(0, 229, 255, 0.6);
}

.combo-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
}

.combo-pct {
  font-family: "Orbitron", sans-serif;
  font-size: 12px;
  font-weight: 700;
  color: var(--cyan-hot);
  min-width: 36px;
}

.combo-lab {
  font-family: "Orbitron", "Rajdhani", sans-serif;
  font-size: 10px;
  letter-spacing: 0.14em;
  color: var(--muted);
  margin-top: 4px;
  font-weight: 700;
}

#radar-block {
  width: 168px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

#radar {
  width: 150px;
  height: 150px;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 45%, rgba(8, 40, 58, 0.55), rgba(2, 10, 18, 0.85));
  box-shadow: 0 0 0 2px rgba(0, 229, 255, 0.55), 0 0 22px rgba(0, 229, 255, 0.25), inset 0 0 24px rgba(0, 40, 60, 0.65);
}

.radar-lab {
  font-family: "Orbitron", sans-serif;
  font-size: 10px;
  letter-spacing: 0.18em;
  color: var(--cyan);
  margin-top: 6px;
  text-shadow: 0 0 8px rgba(0, 229, 255, 0.5);
  font-weight: 700;
}

/* CHAIN BANNER */
#chain-banner {
  position: absolute;
  top: 13%;
  left: 50%;
  transform: translateX(-50%);
  z-index: 20;
  min-width: 280px;
  padding: 14px 28px 16px;
  text-align: center;
  background: linear-gradient(180deg, rgba(8, 32, 52, 0.96), rgba(4, 16, 32, 0.97));
  border: 2px solid var(--cyan);
  border-radius: 16px;
  box-shadow: 0 0 24px rgba(0, 229, 255, 0.45), inset 0 0 18px rgba(0, 80, 120, 0.25);
  pointer-events: none;
  animation: chainPop 0.35s ease-out;
}

.chain-icon {
  position: absolute;
  top: -18px;
  left: 50%;
  transform: translateX(-50%);
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 2px solid var(--cyan);
  background: rgba(4, 18, 32, 0.95);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 12px rgba(0, 229, 255, 0.45);
}
.chain-icon img { width: 22px; height: 22px; object-fit: contain; }

.chain-title {
  font-family: "Orbitron", sans-serif;
  font-weight: 800;
  font-size: 22px;
  letter-spacing: 0.04em;
  color: #ff6ad8;
  margin-top: 8px;
  text-shadow: 0 0 12px rgba(0, 229, 255, 0.55), 0 0 18px rgba(255, 72, 200, 0.55);
}

.chain-score {
  font-family: "Orbitron", sans-serif;
  font-size: 16px;
  font-weight: 700;
  color: #ff48c8;
  text-shadow: 0 0 12px rgba(255, 72, 200, 0.7);
  margin-top: 4px;
}

@keyframes chainPop {
  from { transform: translateX(-50%) scale(0.7); opacity: 0; }
  to { transform: translateX(-50%) scale(1); opacity: 1; }
}

/* ABILITY BAR */
#ability-bar {
  position: absolute;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  display: flex;
  align-items: flex-end;
  gap: 18px;
  padding: 18px 28px 10px;
  pointer-events: auto;
  background: linear-gradient(180deg, rgba(4, 18, 32, 0.0), rgba(4, 16, 28, 0.55));
}

.abil-rail {
  position: absolute;
  left: 36px;
  right: 36px;
  top: 42px;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--cyan) 10%, var(--cyan) 90%, transparent);
  box-shadow: 0 0 10px var(--cyan);
  opacity: 0.75;
  pointer-events: none;
}

.abil {
  position: relative;
  background: transparent;
  border: 0;
  color: var(--cyan);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  min-width: 88px;
  pointer-events: auto;
}

.abil-frame {
  width: 58px;
  height: 58px;
  border-radius: 12px;
  border: 2px solid var(--cyan);
  background: rgba(4, 16, 28, 0.82);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 12px rgba(0, 229, 255, 0.28), inset 0 0 10px rgba(0, 40, 60, 0.4);
  transition: transform 0.12s ease, box-shadow 0.12s ease, border-color 0.12s;
}
.abil-frame img {
  width: 34px;
  height: 34px;
  object-fit: contain;
  filter: drop-shadow(0 0 6px rgba(0, 229, 255, 0.6));
}
.abil-frame.mag {
  border-color: #d060ff;
  background: radial-gradient(circle at 50% 40%, rgba(160, 40, 220, 0.85), rgba(40, 8, 70, 0.92));
  box-shadow: 0 0 16px rgba(208, 80, 255, 0.55), inset 0 0 12px rgba(180, 40, 255, 0.35);
}
.abil-frame.mag img { filter: drop-shadow(0 0 8px #ff80ff); }
.abil-frame.dim {
  border-color: #6a8898;
  box-shadow: none;
}
.abil:hover .abil-frame { transform: translateY(-2px); }
.abil.selected .abil-frame {
  border-color: #d060ff;
  box-shadow: 0 0 18px rgba(208, 80, 255, 0.6);
}
.abil.disabled { opacity: 0.4; pointer-events: none; }

.abil-name {
  font-family: "Rajdhani", "Exo 2", sans-serif;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--cyan);
  text-shadow: 0 0 8px rgba(0, 229, 255, 0.4);
}
.abil-name.mag { color: #e8a0ff; }
.abil-name.dim { color: #8aa0b0; }

.abil-key {
  position: absolute;
  top: -8px;
  right: 8px;
  font-size: 9px;
  font-family: "Share Tech Mono", monospace;
  color: rgba(0, 229, 255, 0.55);
}

/* CRYSTALS */
#crystal-bar {
  position: absolute;
  right: 18px;
  bottom: 22px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  pointer-events: none;
}

.gems {
  display: flex;
  gap: 6px;
  align-items: flex-end;
}

.gem {
  width: 28px;
  height: 44px;
  object-fit: contain;
  filter: drop-shadow(0 0 8px rgba(0, 200, 255, 0.55));
}
.gem.empty {
  filter: grayscale(1) brightness(0.55) drop-shadow(0 0 0 transparent);
  opacity: 0.7;
}

.gem-count {
  font-family: "Orbitron", sans-serif;
  font-size: 13px;
  font-weight: 700;
  color: var(--cyan);
  letter-spacing: 0.08em;
  text-shadow: 0 0 8px rgba(0, 229, 255, 0.5);
}

#turn-toast {
  position: absolute;
  top: 8%;
  left: 50%;
  transform: translateX(-50%);
  z-index: 21;
  font-family: "Orbitron", sans-serif;
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 0.28em;
  color: var(--cyan-hot);
  text-shadow: 0 0 16px rgba(0, 229, 255, 0.8);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s;
}
#turn-toast.show { opacity: 1; }

#hint {
  position: absolute;
  left: 16px;
  bottom: 16px;
  font-size: 12px;
  letter-spacing: 0.04em;
  color: rgba(120, 180, 200, 0.7);
  font-weight: 600;
  max-width: 280px;
  text-shadow: 0 1px 4px #000;
}

/* ========== MENU / PAUSE / RESULTS ========== */
#menu, #pause, #results {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at 50% 40%, rgba(4, 24, 40, 0.55), rgba(2, 8, 14, 0.88));
}

.menu-card {
  width: min(640px, 92vw);
  padding: 28px 32px 24px;
  background: linear-gradient(180deg, rgba(6, 22, 38, 0.92), rgba(4, 12, 22, 0.95));
  border: 1.5px solid rgba(0, 229, 255, 0.55);
  border-radius: 16px;
  box-shadow: 0 0 40px rgba(0, 180, 220, 0.18), inset 0 0 40px rgba(0, 40, 70, 0.25);
  text-align: center;
}

.menu-card.slim { width: min(360px, 90vw); padding: 28px 24px; }

.menu-title { align-items: center; margin: 0 auto 8px; width: fit-content; }
.menu-title .echo { font-size: 42px; }
.menu-title .loc { font-size: 34px; }

.menu-sub {
  font-family: "Orbitron", sans-serif;
  font-size: 11px;
  letter-spacing: 0.22em;
  color: var(--cyan-dim);
  margin: 10px 0 14px;
  font-weight: 700;
}

.menu-blurb {
  font-size: 15px;
  line-height: 1.45;
  color: #b8dce8;
  margin: 0 auto 16px;
  max-width: 520px;
}
.menu-blurb b { color: var(--cyan-hot); }

.menu-art {
  display: flex;
  justify-content: center;
  align-items: flex-end;
  gap: 18px;
  margin: 8px 0 18px;
  height: 110px;
}
.menu-art img {
  height: 100px;
  width: auto;
  object-fit: contain;
  filter: drop-shadow(0 0 12px rgba(0, 229, 255, 0.35));
}
.menu-art img:nth-child(2) { filter: drop-shadow(0 0 12px rgba(255, 154, 40, 0.45)); }
.menu-art img:nth-child(3) { filter: drop-shadow(0 0 12px rgba(64, 255, 98, 0.45)); }

.menu-btns {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-bottom: 14px;
}

.menu-card button {
  background: linear-gradient(180deg, #00c8e8, #007a98);
  color: #041018;
  border: 0;
  border-radius: 6px;
  padding: 10px 22px;
  font-family: "Orbitron", sans-serif;
  font-weight: 800;
  letter-spacing: 0.12em;
  font-size: 13px;
  box-shadow: 0 0 16px rgba(0, 229, 255, 0.35);
}
.menu-card button:hover { filter: brightness(1.12); }
.menu-card button:disabled { opacity: 0.45; cursor: wait; }
.menu-card button.ghost {
  background: transparent;
  color: var(--cyan);
  border: 1.5px solid var(--cyan);
  box-shadow: none;
}

.menu-controls {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.6;
}
kbd {
  display: inline-block;
  border: 1px solid rgba(0, 229, 255, 0.4);
  padding: 0 5px;
  border-radius: 3px;
  font-family: "Share Tech Mono", monospace;
  font-size: 11px;
  color: var(--cyan-hot);
}

.res-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 18px;
  margin: 16px 0 20px;
  font-family: "Orbitron", sans-serif;
  font-size: 12px;
  letter-spacing: 0.08em;
  color: var(--muted);
}
.res-grid b {
  display: block;
  color: var(--cyan-hot);
  font-size: 20px;
  margin-top: 2px;
}

@media (max-width: 900px) {
  .portrait-hex { width: 56px; height: 60px; flex-basis: 56px; }
  .kairo-stats { min-width: 180px; }
  #radar { width: 110px; height: 110px; }
  #radar-block { width: 120px; }
  .abil { min-width: 70px; }
  .abil-frame { width: 48px; height: 48px; }
  #hint { display: none; }
}
