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

body, html {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: #0b0c10;
  font-family: 'Outfit', sans-serif;
  color: #f1f5f9;
}

#game-container {
  position: relative;
  width: 100vw;
  height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  background: radial-gradient(circle at center, #171b26 0%, #08090d 100%);
}

#gameCanvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: block;
  cursor: crosshair;
}

/* HUD Overlay */
.overlay-ui {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 20px 28px;
}

.hud-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
}

.stat-badge {
  display: flex;
  align-items: center;
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  padding: 8px 16px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.6);
  min-width: 250px;
  gap: 12px;
}

.gem-badge {
  border-color: rgba(56, 189, 248, 0.5);
  box-shadow: 0 0 15px rgba(56, 189, 248, 0.25);
}

.player-badge {
  border-color: rgba(52, 211, 153, 0.5);
  box-shadow: 0 0 15px rgba(52, 211, 153, 0.25);
}

.stat-badge .icon {
  font-size: 24px;
}

.bar-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.label-row {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.label-row .label {
  color: #94a3b8;
}

.label-row .val {
  color: #f8fafc;
  font-family: monospace;
}

.bar {
  width: 100%;
  height: 10px;
  background: rgba(30, 41, 59, 0.9);
  border-radius: 6px;
  overflow: hidden;
  position: relative;
}

.bar-fill {
  height: 100%;
  width: 100%;
  transition: width 0.15s ease-out;
}

.hp-gem {
  background: linear-gradient(90deg, #0284c7, #38bdf8, #a5f3fc);
  box-shadow: 0 0 8px #38bdf8;
}

.hp-player {
  background: linear-gradient(90deg, #059669, #10b981, #6ee7b7);
  box-shadow: 0 0 8px #10b981;
}

/* Wave Display */
.wave-display {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid rgba(245, 158, 11, 0.4);
  padding: 8px 24px;
  border-radius: 14px;
  box-shadow: 0 0 25px rgba(245, 158, 11, 0.25);
  min-width: 220px;
}

.wave-title {
  font-size: 18px;
  font-weight: 800;
  color: #fbbf24;
  letter-spacing: 1.5px;
}

.wave-sub {
  font-size: 11px;
  color: #cbd5e1;
  margin-top: 2px;
}

.wave-progress-bar {
  width: 100%;
  height: 4px;
  background: #1e293b;
  border-radius: 2px;
  margin-top: 6px;
  overflow: hidden;
}

.wave-progress-fill {
  width: 0%;
  height: 100%;
  background: #fbbf24;
  transition: width 0.2s linear;
}

/* Secondary Top Bar (Resources & XP) */
.hud-top-sub {
  display: flex;
  justify-content: center;
  gap: 16px;
  margin-top: 10px;
}

.resource-badge {
  display: flex;
  align-items: center;
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 5px 14px;
  border-radius: 20px;
  font-size: 12px;
  gap: 8px;
  font-weight: 600;
}

.res-label {
  color: #94a3b8;
}

.res-val {
  color: #f1f5f9;
  font-weight: 800;
}

.xp-bar-mini {
  width: 60px;
  height: 6px;
  background: #334155;
  border-radius: 3px;
  overflow: hidden;
  margin-left: 4px;
}

.xp-fill {
  width: 0%;
  height: 100%;
  background: #818cf8;
  box-shadow: 0 0 6px #818cf8;
}

/* Bottom HUD (Weapons & Skills) */
.hud-bottom {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 20px;
  pointer-events: auto;
}

.weapon-slots {
  display: flex;
  gap: 10px;
}

.weapon-card {
  width: 64px;
  height: 64px;
  background: rgba(15, 23, 42, 0.9);
  border: 2px solid rgba(255, 255, 255, 0.15);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  cursor: pointer;
  transition: all 0.15s ease;
}

.weapon-card.active {
  border-color: #38bdf8;
  box-shadow: 0 0 16px rgba(56, 189, 248, 0.4);
  transform: translateY(-4px);
  background: rgba(30, 58, 138, 0.5);
}

.weapon-card .key-badge {
  position: absolute;
  top: 3px;
  left: 6px;
  font-size: 10px;
  color: #94a3b8;
  font-weight: bold;
}

.weapon-card .wpn-icon {
  font-size: 24px;
}

.weapon-card .wpn-level {
  position: absolute;
  bottom: 2px;
  font-size: 10px;
  color: #cbd5e1;
  font-weight: bold;
}

.ability-slot {
  width: 60px;
  height: 60px;
  background: rgba(15, 23, 42, 0.9);
  border: 2px solid rgba(255, 255, 255, 0.15);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.ability-key {
  position: absolute;
  top: 3px;
  font-size: 9px;
  color: #94a3b8;
  font-weight: bold;
}

.ability-name {
  font-size: 11px;
  font-weight: 700;
  margin-top: 10px;
}

.ability-cd {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 0%;
  background: rgba(0, 0, 0, 0.7);
  pointer-events: none;
  transition: height 0.05s linear;
}

/* Boss Bar */
.boss-bar-container {
  position: absolute;
  top: 110px;
  left: 50%;
  transform: translateX(-50%);
  width: 500px;
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid #dc2626;
  border-radius: 8px;
  padding: 6px 12px;
  box-shadow: 0 0 20px rgba(220, 38, 38, 0.4);
  text-align: center;
}

.boss-name {
  font-size: 12px;
  font-weight: 800;
  color: #f87171;
  letter-spacing: 1px;
  margin-bottom: 4px;
}

.boss-bar {
  width: 100%;
  height: 10px;
  background: #450a0a;
  border-radius: 4px;
  overflow: hidden;
}

.boss-fill {
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, #dc2626, #ef4444);
}

/* Menu Modals */
.menu-modal {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(3, 7, 18, 0.85);
  backdrop-filter: blur(10px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 100;
  animation: fadeIn 0.3s ease-out;
}

.hidden {
  display: none !important;
}

.modal-box {
  background: linear-gradient(145deg, #1e293b, #0f172a);
  border: 2px solid rgba(255, 255, 255, 0.15);
  border-radius: 20px;
  padding: 40px;
  max-width: 620px;
  width: 90%;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.8);
  position: relative;
}

.title-gem-glow {
  font-size: 56px;
  margin-bottom: 10px;
  animation: pulse 2s infinite ease-in-out;
}

.game-title {
  font-family: 'MedievalSharp', cursive, sans-serif;
  font-size: 42px;
  font-weight: 800;
  color: #38bdf8;
  letter-spacing: 2px;
  text-shadow: 0 0 20px rgba(56, 189, 248, 0.5);
}

.subtitle {
  font-size: 14px;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 3px;
  margin-bottom: 20px;
}

.lore {
  font-size: 14px;
  line-height: 1.6;
  color: #cbd5e1;
  background: rgba(0, 0, 0, 0.25);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 24px;
}

.controls-guide {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 28px;
  text-align: left;
  background: rgba(0, 0, 0, 0.2);
  padding: 14px;
  border-radius: 12px;
}

.ctrl-item {
  font-size: 13px;
  color: #cbd5e1;
  display: flex;
  align-items: center;
  gap: 6px;
}

.key {
  background: #334155;
  border: 1px solid #64748b;
  border-radius: 4px;
  padding: 2px 7px;
  font-size: 11px;
  font-weight: 700;
  color: #f8fafc;
  box-shadow: 0 2px 0 #1e293b;
}

.btn {
  border: none;
  padding: 14px 32px;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 1px;
  cursor: pointer;
  transition: all 0.2s ease;
  pointer-events: auto;
}

.primary-btn {
  background: linear-gradient(135deg, #0284c7, #2563eb);
  color: #ffffff;
  box-shadow: 0 4px 15px rgba(37, 99, 235, 0.4);
}

.primary-btn:hover {
  background: linear-gradient(135deg, #0369a1, #1d4ed8);
  box-shadow: 0 6px 20px rgba(37, 99, 235, 0.6);
  transform: translateY(-2px);
}

.primary-btn:active {
  transform: translateY(0);
}

.menu-buttons-group {
  display: flex;
  gap: 12px;
  justify-content: center;
}

.secondary-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #f1f5f9;
}

.secondary-btn:hover {
  background: rgba(255, 255, 255, 0.16);
  border-color: #38bdf8;
  transform: translateY(-2px);
}

/* Options Form */
.options-form {
  display: flex;
  flex-direction: column;
  gap: 18px;
  background: rgba(0, 0, 0, 0.25);
  padding: 20px;
  border-radius: 12px;
  text-align: left;
  margin-top: 10px;
}

.option-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 14px;
  color: #cbd5e1;
  font-weight: 600;
}

.slider-group {
  display: flex;
  align-items: center;
  gap: 12px;
}

.slider-group input[type="range"] {
  accent-color: #38bdf8;
  cursor: pointer;
  width: 140px;
}

.slider-group span {
  font-family: monospace;
  color: #38bdf8;
  width: 40px;
  text-align: right;
}

.option-row input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: #38bdf8;
  cursor: pointer;
}

/* Upgrade Roguelike Modal */
.upgrade-box {
  max-width: 900px;
  width: 95%;
}

.upgrade-heading {
  font-family: 'MedievalSharp', cursive, sans-serif;
  font-size: 32px;
  color: #fbbf24;
  margin-bottom: 6px;
  text-shadow: 0 0 15px rgba(251, 191, 36, 0.4);
}

.upgrade-sub {
  color: #94a3b8;
  font-size: 14px;
  margin-bottom: 24px;
}

.cards-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
}

.upgrade-card {
  background: rgba(15, 23, 42, 0.95);
  border: 2px solid rgba(255, 255, 255, 0.15);
  border-radius: 16px;
  padding: 24px 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
  overflow: hidden;
}

.upgrade-card:hover {
  transform: translateY(-8px);
  border-color: #38bdf8;
  box-shadow: 0 12px 30px rgba(56, 189, 248, 0.35);
  background: rgba(30, 41, 59, 0.95);
}

.upgrade-card.rarity-common { border-color: #64748b; }
.upgrade-card.rarity-rare { border-color: #3b82f6; box-shadow: 0 0 10px rgba(59, 130, 246, 0.2); }
.upgrade-card.rarity-epic { border-color: #a855f7; box-shadow: 0 0 15px rgba(168, 85, 247, 0.3); }
.upgrade-card.rarity-legendary { border-color: #f59e0b; box-shadow: 0 0 20px rgba(245, 158, 11, 0.4); }

.card-icon {
  font-size: 40px;
  margin-bottom: 12px;
}

.card-title {
  font-size: 17px;
  font-weight: 700;
  margin-bottom: 6px;
  color: #f8fafc;
}

.card-tag {
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 12px;
  margin-bottom: 12px;
  letter-spacing: 0.5px;
}

.tag-common { background: #334155; color: #cbd5e1; }
.tag-rare { background: #1e3a8a; color: #93c5fd; }
.tag-epic { background: #581c87; color: #d8b4fe; }
.tag-legendary { background: #78350f; color: #fde68a; }

.card-desc {
  font-size: 13px;
  line-height: 1.5;
  color: #94a3b8;
  margin-bottom: 16px;
  flex: 1;
}

.card-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #f1f5f9;
  padding: 8px 18px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 700;
  transition: all 0.15s ease;
}

.upgrade-card:hover .card-btn {
  background: #0284c7;
  border-color: #38bdf8;
}

/* Banner Notification */
.banner-popup {
  position: absolute;
  top: 15%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(15, 23, 42, 0.95);
  border: 2px solid #fbbf24;
  border-radius: 16px;
  padding: 16px 36px;
  box-shadow: 0 0 35px rgba(251, 191, 24, 0.4);
  text-align: center;
  z-index: 50;
  animation: bannerPop 0.4s ease-out;
}

.banner-content h2 {
  font-family: 'MedievalSharp', cursive, sans-serif;
  color: #fbbf24;
  font-size: 26px;
  letter-spacing: 1.5px;
}

.banner-content p {
  color: #cbd5e1;
  font-size: 13px;
  margin-top: 4px;
}

/* Game Over Box */
.gameover-box {
  border-color: rgba(239, 68, 68, 0.6);
  box-shadow: 0 0 50px rgba(239, 68, 68, 0.3);
}

.gameover-title {
  font-family: 'MedievalSharp', cursive, sans-serif;
  color: #ef4444;
  font-size: 40px;
  margin-bottom: 6px;
}

.gameover-reason {
  color: #94a3b8;
  font-size: 14px;
  margin-bottom: 24px;
}

.gameover-stats {
  background: rgba(0, 0, 0, 0.3);
  border-radius: 12px;
  padding: 18px;
  margin-bottom: 28px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.stat-line {
  display: flex;
  justify-content: space-between;
  font-size: 14px;
  color: #cbd5e1;
}

.stat-line b {
  color: #38bdf8;
  font-size: 15px;
}

@keyframes pulse {
  0% { transform: scale(1); filter: drop-shadow(0 0 10px rgba(56, 189, 248, 0.4)); }
  50% { transform: scale(1.1); filter: drop-shadow(0 0 25px rgba(56, 189, 248, 0.9)); }
  100% { transform: scale(1); filter: drop-shadow(0 0 10px rgba(56, 189, 248, 0.4)); }
}

@keyframes fadeIn {
  from { opacity: 0; transform: scale(0.98); }
  to { opacity: 1; transform: scale(1); }
}

@keyframes bannerPop {
  from { opacity: 0; transform: translate(-50%, -60%) scale(0.9); }
  to { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}
