/* ==============================
   VibeSurvivors - Global Styles
   ============================== */

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

html, body {
  width: 100%;
  height: 100%;
  background: #0a0a14;
  color: #e8e8ee;
  font-family: 'Trebuchet MS', 'Segoe UI', system-ui, sans-serif;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
}

#app {
  position: relative;
  width: 100vw;
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at center, #1a1230 0%, #05050d 70%);
}

#game {
  position: absolute;
  top: 0;
  left: 0;
  background: #0a0a14;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  display: block;
  cursor: crosshair;
}

/* Screens layered above canvas */
.screen, .modal, .hud, .toast {
  position: absolute;
  top: 0; left: 0;
  width: 100%;
  height: 100%;
  display: none;
  align-items: center;
  justify-content: center;
  flex-direction: column;
}

.screen.visible, .hud.visible, .modal.visible { display: flex; }
.hidden { display: none !important; }

/* ====== Buttons ====== */
.btn {
  font-family: inherit;
  font-weight: bold;
  font-size: 18px;
  letter-spacing: 1px;
  padding: 12px 28px;
  margin: 6px 0;
  min-width: 220px;
  background: linear-gradient(180deg, #3a2a5c, #221836);
  color: #f0e6ff;
  border: 2px solid #6a4ab0;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s ease;
  text-shadow: 0 2px 0 rgba(0,0,0,0.4);
  box-shadow: 0 4px 0 #1a0f30, inset 0 1px 0 rgba(255,255,255,0.15);
}
.btn:hover {
  background: linear-gradient(180deg, #4a3a7c, #2a1f46);
  transform: translateY(-2px);
  box-shadow: 0 6px 0 #1a0f30, inset 0 1px 0 rgba(255,255,255,0.2);
}
.btn:active {
  transform: translateY(2px);
  box-shadow: 0 2px 0 #1a0f30, inset 0 1px 0 rgba(255,255,255,0.1);
}
.btn-primary {
  background: linear-gradient(180deg, #d04060, #802030);
  border-color: #f06080;
  color: #fff;
}
.btn-primary:hover {
  background: linear-gradient(180deg, #e05070, #902840);
}
.btn:disabled, .btn.disabled {
  opacity: 0.4;
  cursor: not-allowed;
  filter: grayscale(0.7);
}
.btn:disabled:hover, .btn.disabled:hover {
  transform: none;
  background: linear-gradient(180deg, #3a2a5c, #221836);
}
.btn-back {
  position: absolute;
  top: 20px;
  left: 20px;
  min-width: auto;
  font-size: 14px;
  padding: 8px 16px;
}

.menu-buttons { display: flex; flex-direction: column; align-items: center; gap: 4px; }

/* ====== Main Menu ====== */
.menu-bg {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 30% 30%, rgba(160, 80, 220, 0.18), transparent 50%),
    radial-gradient(circle at 70% 70%, rgba(220, 60, 100, 0.18), transparent 50%);
  z-index: 0;
}
.menu-content {
  position: relative;
  z-index: 1;
  text-align: center;
  padding: 30px;
}
.game-title {
  font-size: 72px;
  font-weight: 900;
  letter-spacing: 6px;
  color: #fff;
  text-shadow:
    0 0 10px #c060f0,
    0 0 25px #8030c0,
    0 0 40px #6020a0,
    0 4px 0 #1a0f30,
    0 6px 0 #000;
  margin-bottom: 10px;
  animation: titleGlow 3s ease-in-out infinite alternate;
}
.game-title span {
  background: linear-gradient(180deg, #ff80a0, #c03060);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 0 20px rgba(255, 80, 120, 0.7));
}
@keyframes titleGlow {
  from { text-shadow: 0 0 10px #c060f0, 0 0 25px #8030c0, 0 4px 0 #1a0f30; }
  to   { text-shadow: 0 0 18px #d080ff, 0 0 35px #a040d0, 0 4px 0 #1a0f30; }
}
.subtitle {
  color: #c0b0e0;
  font-size: 16px;
  margin-bottom: 30px;
  font-style: italic;
}
.currency-bar {
  margin-top: 30px;
  display: flex;
  gap: 20px;
  justify-content: center;
}
.currency {
  background: rgba(0,0,0,0.5);
  padding: 8px 16px;
  border-radius: 20px;
  border: 1px solid #4a3a7c;
  font-size: 16px;
}
.cur-icon {
  display: inline-block;
  width: 22px; height: 22px;
  line-height: 22px;
  text-align: center;
  border-radius: 50%;
  background: #f0c050;
  color: #5a3010;
  font-weight: bold;
  margin-right: 6px;
}
.cur-icon.gold { background: linear-gradient(180deg, #ffe080, #c08020); }
.version {
  position: absolute;
  bottom: 20px;
  width: 100%;
  text-align: center;
  font-size: 12px;
  color: #6a5a8c;
}

/* ====== Character Select ====== */
#screen-characters h2, #screen-levels h2, #screen-codex h2, #screen-achievements h2 {
  font-size: 36px;
  margin: 30px 0 16px;
  color: #fff;
  text-shadow: 0 0 12px #8040c0, 0 3px 0 #1a0f30;
  letter-spacing: 3px;
}
.hint { color: #9a8ac0; font-size: 14px; margin-bottom: 20px; }

.char-grid, .level-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  padding: 0 20px;
  width: 720px;
  max-width: 100%;
  box-sizing: border-box;
}
.char-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 720px;
  max-width: 100%;
  box-sizing: border-box;
}
.char-card, .level-card {
  background: linear-gradient(180deg, #2a1f4a, #1a0f30);
  border: 2px solid #4a3a7c;
  border-radius: 10px;
  padding: 14px;
  cursor: pointer;
  transition: all 0.15s ease;
  text-align: center;
}
.char-card:hover, .level-card:hover {
  border-color: #c060f0;
  transform: translateY(-3px);
  box-shadow: 0 6px 16px rgba(192, 96, 240, 0.3);
}
.char-card.locked, .level-card.locked {
  opacity: 0.5;
  filter: grayscale(0.6);
}
.char-card.locked:hover, .level-card.locked:hover { transform: none; }
.char-card.selected { border-color: #ffd060; box-shadow: 0 0 16px rgba(255, 208, 96, 0.5); }
.char-portrait {
  width: 60px; height: 60px;
  border-radius: 50%;
  margin: 0 auto 8px;
  border: 3px solid #6a4ab0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  background: #0a0a14;
}
.char-portrait.big { width: 100px; height: 100px; font-size: 56px; }
.char-name { font-weight: bold; color: #fff; font-size: 16px; margin-bottom: 4px; }
.char-title { font-size: 11px; color: #c0b0e0; font-style: italic; }
.char-card .lock-msg { font-size: 10px; color: #d0a060; margin-top: 4px; }

.char-detail {
  margin-top: 16px;
  padding: 16px 20px;
  background: rgba(0,0,0,0.5);
  border: 1px solid #4a3a7c;
  border-radius: 10px;
  width: 100%;
  max-width: 720px;
  box-sizing: border-box;
  min-height: 100px;
  text-align: left;
}
.char-detail h3 { color: #ffd060; font-size: 20px; margin-bottom: 6px; }
.char-detail .stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 10px 0; }
.char-detail .stat-cell { background: rgba(106, 74, 176, 0.2); padding: 6px; border-radius: 6px; text-align: center; }
.char-detail .stat-cell .label { font-size: 10px; color: #9a8ac0; }
.char-detail .stat-cell .val { font-size: 16px; color: #fff; font-weight: bold; }
.char-detail .unlock { color: #ffb060; font-size: 13px; margin-top: 8px; }
.char-detail .desc { color: #c0b0e0; font-size: 13px; line-height: 1.4; }

/* ====== Codex ====== */
.codex-tabs { display: flex; gap: 8px; margin-bottom: 16px; }
.tab {
  background: #221836;
  color: #c0b0e0;
  border: 1px solid #4a3a7c;
  padding: 8px 18px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  font-weight: bold;
}
.tab.active { background: #6a4ab0; color: #fff; border-color: #c060f0; }
.codex-content {
  max-width: 700px;
  max-height: 50vh;
  overflow-y: auto;
  padding: 0 20px;
}
.codex-entry {
  display: flex;
  align-items: center;
  background: rgba(34, 24, 54, 0.7);
  border: 1px solid #4a3a7c;
  border-radius: 8px;
  padding: 10px 14px;
  margin-bottom: 8px;
  text-align: left;
}
.codex-icon {
  width: 48px; height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  border-radius: 8px;
  margin-right: 12px;
  flex-shrink: 0;
  background: #0a0a14;
  border: 2px solid #6a4ab0;
}
.codex-text { flex: 1; }
.codex-text .name { font-weight: bold; color: #fff; font-size: 15px; }
.codex-text .desc { font-size: 12px; color: #b0a0d0; margin-top: 2px; }
.codex-entry.locked { opacity: 0.4; }

/* ====== Achievements ====== */
.ach-list {
  max-width: 700px;
  max-height: 60vh;
  overflow-y: auto;
  padding: 0 20px;
}
.ach-entry {
  display: flex;
  align-items: center;
  background: rgba(34, 24, 54, 0.7);
  border: 1px solid #4a3a7c;
  border-radius: 8px;
  padding: 12px 14px;
  margin-bottom: 8px;
  text-align: left;
}
.ach-entry.done { border-color: #ffd060; background: rgba(80, 60, 30, 0.4); }
.ach-icon { font-size: 28px; margin-right: 14px; }
.ach-text { flex: 1; }
.ach-text .name { font-weight: bold; color: #fff; font-size: 15px; }
.ach-text .desc { font-size: 12px; color: #b0a0d0; margin-top: 2px; }
.ach-reward { font-size: 12px; color: #ffd060; margin-top: 4px; }
.ach-entry.locked .name { color: #6a5a8c; }

/* ====== HUD ====== */
.hud { pointer-events: none; align-items: stretch; justify-content: space-between; padding: 16px; }
.hud > * { pointer-events: auto; }
.hud-top { display: flex; justify-content: space-between; align-items: flex-start; }
.hud-info { display: flex; flex-direction: column; gap: 6px; align-items: flex-end; }
.info-pill {
  background: rgba(10, 10, 30, 0.85);
  border: 1px solid #4a3a7c;
  border-radius: 14px;
  padding: 4px 12px;
  font-size: 13px;
  font-weight: bold;
}
.info-key { color: #9a8ac0; margin-right: 6px; font-size: 10px; letter-spacing: 1px; }
.stat-row { display: flex; flex-direction: column; gap: 6px; min-width: 280px; }
.stat { display: flex; align-items: center; gap: 8px; }
.stat-label { width: 50px; font-weight: bold; color: #c0b0e0; font-size: 12px; }
.bar { flex: 1; height: 14px; background: rgba(10, 10, 30, 0.85); border: 1px solid #4a3a7c; border-radius: 4px; overflow: hidden; }
.bar-fill { height: 100%; transition: width 0.2s; }
.hp-fill { background: linear-gradient(180deg, #ff4060, #c02040); width: 100%; }
.xp-fill { background: linear-gradient(180deg, #60c0ff, #2080c0); width: 0%; }
.boss-fill { background: linear-gradient(180deg, #ff8040, #c04020); width: 100%; }
.stat-num { font-size: 12px; color: #c0b0e0; min-width: 80px; text-align: right; }

.hud-bottom { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; }
.weapon-bar { display: flex; gap: 4px; }
.weapon-slot {
  width: 44px; height: 44px;
  background: linear-gradient(180deg, rgba(40, 30, 70, 0.9), rgba(20, 15, 40, 0.9));
  border: 2px solid #6a4ab0;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  position: relative;
  box-shadow: 0 0 8px rgba(106, 74, 176, 0.4), inset 0 1px 0 rgba(255,255,255,0.1);
}
.weapon-slot.empty { border-style: dashed; opacity: 0.3; }
.weapon-slot .lvl {
  position: absolute;
  bottom: 0; right: 0;
  background: #802030;
  color: #fff;
  font-size: 10px;
  padding: 1px 4px;
  border-radius: 4px 0 4px 0;
  font-weight: bold;
}
.weapon-slot .cd {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  border-radius: 4px;
  pointer-events: none;
}
.buff-bar { display: flex; gap: 4px; flex-wrap: wrap; max-width: 400px; }
.buff-icon {
  width: 32px; height: 32px;
  background: rgba(10, 10, 30, 0.85);
  border: 1px solid #6a4ab0;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  position: relative;
}
.buff-icon .stack {
  position: absolute;
  bottom: -4px; right: -4px;
  background: #6a4ab0;
  color: #fff;
  font-size: 9px;
  padding: 1px 4px;
  border-radius: 6px;
  font-weight: bold;
}

.boss-bar {
  position: absolute;
  top: 70px;
  left: 50%;
  transform: translateX(-50%);
  width: 60%;
  max-width: 500px;
  background: rgba(10, 10, 30, 0.85);
  border: 2px solid #c04020;
  border-radius: 8px;
  padding: 8px 14px;
}
.boss-name { text-align: center; color: #ff8060; font-weight: bold; font-size: 14px; margin-bottom: 4px; letter-spacing: 2px; }
.boss-bar .bar { background: rgba(0, 0, 0, 0.6); border-color: #802010; }

/* ====== Modals ====== */
.modal-bg {
  position: absolute;
  inset: 0;
  /* Slightly translucent so the HUD/weapon slots behind the modal
     remain visible. No backdrop-blur (we want the player to see
     what weapons/upgrades they already have while picking). */
  background: rgba(5, 5, 13, 0.55);
  z-index: 0;
}
.modal-content {
  position: relative;
  z-index: 1;
  background: linear-gradient(180deg, #2a1f4a, #1a0f30);
  border: 3px solid #6a4ab0;
  border-radius: 12px;
  padding: 30px 40px;
  text-align: center;
  max-width: 720px;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 0 30px rgba(192, 96, 240, 0.4);
}
.modal-content h2 { font-size: 36px; margin-bottom: 10px; color: #fff; text-shadow: 0 0 12px #c060f0, 0 3px 0 #1a0f30; }
.modal-sub { color: #c0b0e0; font-size: 14px; margin-bottom: 20px; }

.levelup-choices {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}
.levelup-card {
  width: 200px;
  background: linear-gradient(180deg, #3a2a5c, #221836);
  border: 2px solid #6a4ab0;
  border-radius: 10px;
  padding: 14px 10px;
  cursor: pointer;
  transition: all 0.15s;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.levelup-card:hover {
  border-color: #ffd060;
  background: linear-gradient(180deg, #4a3a7c, #2a1f46);
  transform: translateY(-3px);
}
.levelup-card.evolution {
  border-color: #ff60c0;
  background: linear-gradient(180deg, #5a2050, #3a1030);
}
.levelup-card.evolution:hover {
  border-color: #ffa0e0;
  box-shadow: 0 0 20px rgba(255, 96, 192, 0.5);
}
.levelup-card .icon {
  width: 60px; height: 60px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  margin-bottom: 8px;
  background: #0a0a14;
  border: 2px solid #6a4ab0;
}
.levelup-card.evolution .icon { border-color: #ff60c0; }
.levelup-card .name { font-weight: bold; color: #fff; font-size: 15px; margin-bottom: 4px; }
.levelup-card .type { font-size: 10px; color: #c0b0e0; letter-spacing: 1px; margin-bottom: 6px; }
.levelup-card.evolution .type { color: #ff80d0; }
.levelup-card .desc { font-size: 11px; color: #b0a0d0; line-height: 1.3; }

.levelup-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid #4a3a7c;
}
.btn-reroll, .btn-skip {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 8px 20px;
  font-size: 13px;
  font-weight: bold;
  letter-spacing: 1px;
  border: 2px solid #6a4ab0;
  background: linear-gradient(180deg, #3a2a5c, #221836);
  color: #fff;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s;
  min-width: 110px;
}
.btn-reroll .reroll-cost, .btn-skip .skip-cost {
  font-size: 11px;
  color: #ffd060;
  font-weight: bold;
  letter-spacing: 0.5px;
}
.btn-reroll:hover, .btn-skip:hover {
  border-color: #ffd060;
  background: linear-gradient(180deg, #4a3a7c, #2a1f46);
  transform: translateY(-2px);
}
.btn-reroll.disabled, .btn-skip.disabled {
  opacity: 0.4;
  cursor: not-allowed;
  filter: grayscale(0.6);
}
.btn-reroll.disabled:hover, .btn-skip.disabled:hover {
  border-color: #6a4ab0;
  background: linear-gradient(180deg, #3a2a5c, #221836);
  transform: none;
}

.gameover-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 16px 0;
}
.go-stat { background: rgba(0,0,0,0.4); padding: 8px; border-radius: 6px; border: 1px solid #4a3a7c; }
.go-stat .label { font-size: 11px; color: #9a8ac0; }
.go-stat .val { font-size: 18px; color: #fff; font-weight: bold; }

#gameover-title { color: #ff4060; text-shadow: 0 0 12px #ff0000, 0 3px 0 #1a0f30; }
#victory-title { color: #ffd060; text-shadow: 0 0 12px #ff8000, 0 3px 0 #1a0f30; }
.unlock-list { margin: 12px 0; }
.unlock-pill {
  display: inline-block;
  background: linear-gradient(180deg, #ff60c0, #c03090);
  color: #fff;
  padding: 6px 14px;
  border-radius: 16px;
  margin: 4px;
  font-size: 13px;
  font-weight: bold;
}

/* ====== Top buffs HUD (top center) ====== */
.top-buffs {
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  gap: 6px;
  pointer-events: none;
  z-index: 10;
  max-width: 70%;
  justify-content: center;
}
.top-buffs .buff {
  background: linear-gradient(180deg, rgba(40, 30, 70, 0.92), rgba(20, 15, 40, 0.92));
  border: 1px solid #6a4ab0;
  border-radius: 6px;
  padding: 5px 8px 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 56px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.5), inset 0 1px 0 rgba(255,255,255,0.1);
}
.top-buffs .buff .icon {
  font-size: 20px;
  line-height: 1;
  margin-bottom: 2px;
}
.top-buffs .buff .name {
  font-size: 9px;
  color: #f0e0ff;
  text-transform: uppercase;
  font-weight: bold;
  letter-spacing: 0.5px;
  white-space: nowrap;
  text-shadow: 0 1px 0 #000;
}
.top-buffs .buff .time {
  font-size: 10px;
  color: #ffd060;
  font-family: 'Consolas', 'Monaco', monospace;
  font-weight: bold;
  margin-top: 1px;
}
.top-buffs .buff.time-low .time {
  color: #ff6060;
  animation: timeLow 0.5s steps(2) infinite;
}
.top-buffs .buff.time-low {
  border-color: #ff6060;
}
.top-buffs .buff.powerup {
  border-left-width: 3px;
}
@keyframes timeLow {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.5; }
}

/* ====== Pickup log (bottom right) ====== */
.pickup-log {
  position: absolute;
  bottom: 80px;
  right: 16px;
  width: 240px;
  height: 320px;
  pointer-events: none;
  z-index: 10;
}
/* Each entry is absolutely positioned; transform moves it up the stack */
.pickup-log .entry {
  position: absolute;
  right: 0;
  bottom: 0;
  background: rgba(10, 10, 30, 0.85);
  border: 1px solid #4a3a7c;
  border-left: 3px solid #80c0ff;
  border-radius: 4px;
  padding: 4px 10px;
  color: #c0b0e0;
  font-size: 12px;
  font-weight: bold;
  text-align: right;
  text-shadow: 0 1px 0 rgba(0,0,0,0.6);
  font-family: 'Consolas', 'Monaco', monospace;
  min-width: 140px;
  max-width: 240px;
  transition: transform 0.3s ease-out, opacity 0.3s;
  animation: pickupSlideUp 0.3s ease-out;
  transform-origin: bottom right;
}
.pickup-log .entry.xp { border-left-color: #80c0ff; color: #80d0ff; }
.pickup-log .entry.gold { border-left-color: #ffd060; color: #ffe080; }
.pickup-log .entry.powerup { border-left-color: #ff80a0; color: #ffb0c0; }
.pickup-log .entry.chest { border-left-color: #ff80c0; color: #ffb0e0; }
@keyframes pickupSlideUp {
  from { opacity: 0; transform: translateY(28px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ====== Toast ====== */
.toast {
  pointer-events: none;
  z-index: 100;
}
.toast-content {
  position: absolute;
  top: 100px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(10, 10, 30, 0.95);
  border: 2px solid #ffd060;
  color: #ffd060;
  padding: 10px 20px;
  border-radius: 8px;
  font-weight: bold;
  font-size: 16px;
  text-shadow: 0 0 8px #ff8000;
  animation: toastIn 0.3s ease-out;
}
@keyframes toastIn {
  from { opacity: 0; transform: translate(-50%, -20px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}

/* ====== Pause control hint ====== */
.controls-hint {
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(10, 10, 30, 0.7);
  padding: 6px 14px;
  border-radius: 14px;
  font-size: 12px;
  color: #9a8ac0;
}
.controls-hint kbd {
  background: #4a3a7c;
  padding: 2px 6px;
  border-radius: 3px;
  color: #fff;
  font-family: monospace;
}

/* ====== Pause button overlay ====== */
.pause-btn {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 40px; height: 40px;
  background: rgba(10, 10, 30, 0.85);
  border: 1px solid #4a3a7c;
  border-radius: 6px;
  color: #c0b0e0;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
}
.pause-btn:hover { border-color: #c060f0; color: #fff; }

/* ====== Mobile / scaling ====== */
@media (max-width: 980px) {
  #game { transform: translate(-50%, -50%) scale(0.85); }
}
@media (max-width: 800px) {
  #game { transform: translate(-50%, -50%) scale(0.7); }
}
