/* ===== Reset & base ===== */
* {
  box-sizing: border-box;
}
html,
body {
  height: 100%;
}
body {
  margin: 0;
  background: radial-gradient(
    1200px 800px at 50% 20%,
    #0b1240 0%,
    #070a2a 40%,
    #04061a 70%,
    #01030e 100%
  );
  color: #e6e9ff;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, "Helvetica Neue",
    Arial;
  overflow: hidden;
  touch-action: none;
  font-size: clamp(12px, 2.8vw, 16px);
  line-height: 1.5;
  overflow-wrap: anywhere;
  word-break: break-word;
  hyphens: auto;
}

/* Game canvas */
#game {
  position: relative;
  width: 100vw;
  height: 100vh;
}
#gameCanvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

/* HUD (atas) */
.hud {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  padding: 8px 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  pointer-events: none;
  z-index: 5;
  font-variant-numeric: tabular-nums;
  flex-wrap: wrap;
  gap: 6px 8px;
}
.hud .label {
  opacity: 0.7;
  margin-right: 6px;
  font-size: clamp(11px, 2.6vw, 13px);
}
.hud-left {
  display: flex;
  gap: 10px;
  align-items: center;
  font-weight: 600;
  flex-wrap: wrap;
}
#score,
#level {
  display: inline-block;
  min-width: clamp(52px, 14vw, 72px);
  text-align: right;
  white-space: nowrap;
  font-size: clamp(12px, 3.2vw, 16px);
}
.hud-right {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  max-width: 55vw;
}
.bar {
  width: clamp(90px, 28vw, 120px);
  height: 12px;
  background: #1b214f;
  border-radius: 6px;
  overflow: hidden;
  box-shadow: inset 0 0 8px #0d133a;
}
.bar-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #27e0a8, #3af0d5);
  box-shadow: 0 0 12px #2fe2c1;
  transition: width 0.2s ease;
}
#hpText {
  font-size: clamp(11px, 2.8vw, 14px);
  white-space: nowrap;
}

/* Overlay */
.overlay {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
  z-index: 6;
}
.overlay.show {
  display: flex;
}
.overlay.hidden {
  display: none;
}
.overlay-card {
  width: min(780px, 92vw);
  max-height: 86vh;
  padding: clamp(14px, 3.5vw, 18px) clamp(12px, 3.5vw, 16px);
  border-radius: 14px;
  background: rgba(9, 14, 50, 0.82);
  border: 1px solid rgba(71, 97, 255, 0.35);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5),
    inset 0 0 24px rgba(71, 97, 255, 0.15);
  text-align: center;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Judul & sub-judul overlay */
.overlay-card h1 {
  margin: 6px 0 2px;
  letter-spacing: 1.2px;
  font-weight: 800;
  font-size: clamp(18px, 5.6vw, 24px);
  line-height: 1.2;
  text-wrap: balance;
  overflow-wrap: anywhere;
}
.overlay-card .sub {
  opacity: 0.9;
  font-size: clamp(12px, 3.6vw, 14px);
  line-height: 1.4;
  text-wrap: pretty;
}

/* Keterangan/tujuan di menu */
.goals {
  font-size: clamp(12px, 3.6vw, 13px);
  opacity: 0.9;
  line-height: 1.5;
  margin: 6px auto 10px;
  max-width: 78ch;
  text-align: left;
}

/* Tombol */
.btn {
  pointer-events: auto;
  appearance: none;
  border: none;
  border-radius: 10px;
  padding: clamp(10px, 2.8vw, 12px) clamp(12px, 3.2vw, 16px);
  background: #2737a0;
  color: #fff;
  font-weight: 700;
  letter-spacing: 0.2px;
  box-shadow: 0 8px 18px rgba(71, 97, 255, 0.35),
    inset 0 0 10px rgba(255, 255, 255, 0.1);
  font-size: clamp(12px, 3.8vw, 16px);
}
.btn.primary {
  background: linear-gradient(135deg, #5b69ff, #2b48ff);
}
.btn:active {
  transform: translateY(1px);
}
.btn.btn-small {
  padding: clamp(7px, 2.4vw, 8px) clamp(10px, 3vw, 12px);
  font-size: clamp(11px, 3.2vw, 12px);
  border-radius: 8px;
  background: #3a49d0;
}

/* Menu header & coins */
.menu-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}
.coins-badge {
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(30, 40, 110, 0.85);
  border: 1px solid rgba(120, 150, 255, 0.35);
  font-weight: 700;
  box-shadow: inset 0 0 10px rgba(120, 150, 255, 0.2);
  white-space: nowrap;
  font-size: clamp(12px, 3.6vw, 14px);
}
.menu-buttons {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
}

/* ===== Index Book ===== */
.index-content {
  overflow: auto;
  padding: 8px;
  display: grid;
  gap: 12px;
  grid-template-columns: 1fr;
}
.enemy-card {
  display: grid;
  grid-template-columns: 92px 1fr;
  gap: clamp(8px, 2.8vw, 12px);
  align-items: center;
  text-align: left;
  padding: clamp(10px, 3.2vw, 12px);
  border-radius: 12px;
  background: rgba(16, 22, 60, 0.85);
  border: 1px solid rgba(120, 150, 255, 0.18);
}
.enemy-fig {
  width: clamp(72px, 22vw, 92px);
  height: clamp(72px, 22vw, 92px);
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: radial-gradient(
    80px 80px at 50% 40%,
    rgba(60, 80, 160, 0.25),
    rgba(20, 30, 80, 0.25)
  );
  box-shadow: inset 0 0 16px rgba(71, 97, 255, 0.15);
}
.enemy-info .index-tag {
  display: inline-block;
  font-weight: 800;
  letter-spacing: 0.3px;
  margin-bottom: 6px;
  padding: 6px 10px;
  border-radius: 8px;
  background: #5b69ff;
  font-size: clamp(12px, 3.6vw, 14px);
}
.enemy-info p {
  margin: 4px 0;
  font-size: clamp(12px, 3.6vw, 13px);
  opacity: 0.92;
  line-height: 1.5;
  max-inline-size: 85ch;
}
.enemy-info .lore {
  opacity: 0.98;
}

/* Enemy Icon */
.enemy-icon {
  width: clamp(56px, 18vw, 64px);
  height: clamp(56px, 18vw, 64px);
  color: inherit;
  filter: drop-shadow(0 4px 10px rgba(80, 120, 255, 0.35));
  animation: floaty 3.5s ease-in-out infinite;
}
@keyframes floaty {
  0% {
    transform: translateY(0px);
  }
  50% {
    transform: translateY(-3px);
  }
  100% {
    transform: translateY(0px);
  }
}

/* Theme colors (match in-game) */
.enemy-basic {
  color: #f7d15f;
}
.enemy-shooter {
  color: #ff6e6e;
}
.enemy-dasher {
  color: #58dbff;
}
.enemy-shield {
  color: #9cf05b;
}
.enemy-splitter {
  color: #d685ff;
}
.enemy-boss-arc {
  color: #ff4edb;
}
.enemy-boss-chrono {
  color: #62ffd5;
}
.index-tag.red {
  background: #ff6e6e;
}
.index-tag.cyan {
  background: #58dbff;
}
.index-tag.green {
  background: #9cf05b;
  color: #0b1240;
}
.index-tag.purple {
  background: #d685ff;
}
.index-tag.boss {
  background: linear-gradient(135deg, #ff4edb, #ff9bdd);
  color: #220327;
}
.boss-pink {
  border-color: rgba(255, 78, 219, 0.35);
}
.boss-teal {
  border-color: rgba(98, 255, 213, 0.35);
}

/* ===== Shop ===== */
.shop-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  padding: 6px;
  overflow: auto;
}
.shop-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-start;
  padding: 12px;
  border-radius: 12px;
  background: rgba(16, 22, 60, 0.85);
  border: 1px solid rgba(120, 150, 255, 0.18);
}
.shop-card h3 {
  margin: 0;
  font-size: clamp(14px, 4.2vw, 16px);
  display: flex;
  align-items: center;
  gap: 8px;
  line-height: 1.2;
}
.shop-card p {
  margin: 0;
  font-size: clamp(11px, 3.4vw, 12px);
  opacity: 0.9;
}
.shop-price {
  font-weight: 800;
  background: rgba(30, 40, 110, 0.85);
  border: 1px solid rgba(120, 150, 255, 0.35);
  padding: 4px 8px;
  border-radius: 999px;
  white-space: nowrap;
  font-size: clamp(12px, 3.6vw, 14px);
}
.shop-actions {
  display: flex;
  justify-content: center;
  gap: 10px;
  padding-top: 4px;
}
.shop-card .btn {
  align-self: stretch;
}

/* Status kepemilikan: visual */
.shop-card.owned {
  opacity: 0.95;
  border-color: rgba(120, 255, 170, 0.25);
}
/* Equip/Unequip */
.equip-btn {
  background: #3a49d0;
}
.shop-card.equipped .equip-btn {
  background: #2d7a43;
  box-shadow: inset 0 0 10px rgba(255, 255, 255, 0.08);
}

/* Pendant icon colors */
.pendant-icon {
  width: 24px;
  height: 24px;
  display: inline-block;
  color: #7ea8ff;
  vertical-align: middle;
}
.pendant-fleet {
  color: #7db7ff;
}
.pendant-vitalis {
  color: #4bd47e;
}
.pendant-precision {
  color: #e6e9ff;
}
.pendant-zephyr {
  color: #58dbff;
}
.pendant-aegis {
  color: #9cf05b;
}
.pendant-pierce {
  color: #ff9a5b;
}
.pendant-photon {
  color: #ff4edb;
}
.pendant-focus {
  color: #c0c7ff;
}
.pendant-regen {
  color: #3af06b;
}
.pendant-drone {
  color: #a7ffda;
}
.pendant-voidflare {
  color: #ff7ed6;
}
.pendant-gravwell {
  color: #7fb3ff;
}

/* ==== SHOP TABS ==== */
.shop-tabs {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
  margin: 6px 0 4px;
}
.shop-tab {
  appearance: none;
  border: 1px solid rgba(120, 150, 255, 0.35);
  background: rgba(30, 40, 110, 0.65);
  color: #e6e9ff;
  font-weight: 700;
  border-radius: 999px;
  padding: 6px 12px;
  font-size: clamp(12px, 3.4vw, 14px);
}
.shop-tab.active {
  background: linear-gradient(135deg, #5b69ff, #2b48ff);
  box-shadow: 0 8px 18px rgba(71, 97, 255, 0.35),
    inset 0 0 10px rgba(255, 255, 255, 0.1);
}

/* ==== Consumables Dock ==== */
.cons-dock {
  pointer-events: auto;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  max-width: 48vw;
}
.cons-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  border-radius: 999px;
  background: rgba(30, 40, 110, 0.85);
  border: 1px solid rgba(120, 150, 255, 0.35);
  color: #cfe5ff;
  font-weight: 700;
  font-size: clamp(11px, 3.2vw, 12px);
}
.cons-chip .qty {
  display: inline-block;
  min-width: 18px;
  text-align: center;
  background: #2737a0;
  color: #fff;
  border-radius: 6px;
  padding: 2px 6px;
  font-weight: 800;
}
.cons-chip:active {
  transform: translateY(1px);
}
.cons-chip.disabled {
  opacity: 0.45;
  pointer-events: none;
}

/* ===== Extra: layar sangat kecil (<= 360px) ===== */
@media (max-width: 360px) {
  .overlay-card {
    width: 95vw;
  }
  .enemy-card {
    grid-template-columns: 80px 1fr;
  }
  .enemy-fig {
    width: 80px;
    height: 80px;
  }
  .hud {
    padding: 6px 8px;
  }
}
