/* ═══════════════════════════════════════════════
   BACKPACKER — Into the Wild Dark
   Dark Fantasy CSS
═══════════════════════════════════════════════ */

:root {
  --bg-void:      #05040a;
  --bg-deep:      #0a0814;
  --bg-mid:       #110f1e;
  --bg-panel:     #16132a;
  --bg-card:      #1c1830;
  --bg-card-hover:#22203a;

  --clr-blood:    #8b1a1a;
  --clr-blood-lt: #c42b2b;
  --clr-purple:   #4a1a6b;
  --clr-purple-lt:#7a3aab;
  --clr-gold:     #c9a84c;
  --clr-gold-lt:  #e8c96a;
  --clr-toxic:    #3ddc84;
  --clr-ice:      #6ab4e8;
  --clr-fire:     #e86a2a;

  --txt-parchment:#d4c5a9;
  --txt-faded:    #8a7f6a;
  --txt-dim:      #4a4535;
  --txt-white:    #ede8df;

  --border-dark:  #1e1a30;
  --border-mid:   #2e2a45;
  --border-gold:  #5a4820;

  --hp-green:     #2dbd6e;
  --hp-yellow:    #d4a832;
  --hp-red:       #cc3333;

  --shadow-hard:  0 4px 20px rgba(0,0,0,0.8);
  --shadow-glow-gold: 0 0 20px rgba(201,168,76,0.3);
  --shadow-glow-blood: 0 0 20px rgba(139,26,26,0.4);

  --radius-sm:    6px;
  --radius-md:    10px;
  --radius-lg:    16px;

  --font-title:   'Cinzel', serif;
  --font-body:    'Crimson Text', serif;
}

/* ─── Reset & Base ─── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  width: 100%; height: 100%;
  overflow: hidden;
  background: var(--bg-void);
  color: var(--txt-parchment);
  font-family: var(--font-body);
  font-size: 16px;
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
  touch-action: pan-y;
}

/* ─── Screens ─── */
.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s ease;
}
.screen.active {
  opacity: 1;
  pointer-events: all;
}

/* ─── Buttons ─── */
.btn-primary {
  background: linear-gradient(135deg, var(--clr-blood) 0%, #6b1010 100%);
  color: var(--txt-white);
  border: 1px solid #c42b2b;
  border-radius: var(--radius-md);
  padding: 14px 28px;
  font-family: var(--font-title);
  font-size: 0.95rem;
  letter-spacing: 0.08em;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 2px 12px rgba(139,26,26,0.5), inset 0 1px 0 rgba(255,255,255,0.08);
}
.btn-primary:active { transform: scale(0.97); filter: brightness(0.9); }

.btn-ghost {
  background: transparent;
  color: var(--txt-faded);
  border: 1px solid var(--border-mid);
  border-radius: var(--radius-md);
  padding: 12px 24px;
  font-family: var(--font-title);
  font-size: 0.85rem;
  letter-spacing: 0.06em;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-ghost:active { transform: scale(0.97); border-color: var(--clr-gold); color: var(--clr-gold); }

.btn-back {
  background: none;
  border: none;
  color: var(--txt-faded);
  font-family: var(--font-body);
  font-size: 0.95rem;
  cursor: pointer;
  padding: 8px 0;
}

.full-width { width: 100%; }

/* ═══════════════════════════════════════════════
   TITLE SCREEN
═══════════════════════════════════════════════ */
#screen-title {
  justify-content: flex-end;
}

.title-forest-bg {
  position: absolute;
  inset: 0;
  overflow: hidden;
}

.title-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    to bottom,
    rgba(5,4,10,0.3) 0%,
    rgba(5,4,10,0.5) 40%,
    rgba(5,4,10,0.92) 75%,
    rgba(5,4,10,1) 100%
  );
}

.title-content {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0 28px 50px;
  gap: 14px;
}

.title-emblem {
  width: 80px;
  height: 80px;
  margin-bottom: 8px;
}

.game-title {
  font-family: var(--font-title);
  font-size: 2.8rem;
  font-weight: 900;
  letter-spacing: 0.18em;
  color: var(--txt-white);
  text-shadow: 0 0 40px rgba(139,26,26,0.8), 0 2px 4px rgba(0,0,0,0.9);
  line-height: 1;
}

.game-subtitle {
  font-family: var(--font-body);
  font-style: italic;
  color: var(--txt-faded);
  font-size: 1.1rem;
  letter-spacing: 0.12em;
  margin-bottom: 20px;
}

.title-buttons {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
}

.version-tag {
  font-size: 0.72rem;
  color: var(--txt-dim);
  letter-spacing: 0.1em;
  font-family: var(--font-title);
  margin-top: 4px;
}

/* ═══════════════════════════════════════════════
   HUB SCREEN
═══════════════════════════════════════════════ */
#screen-hub {
  background: linear-gradient(180deg, var(--bg-void) 0%, var(--bg-deep) 100%);
}

.hub-header {
  padding: 48px 20px 12px;
  background: linear-gradient(180deg, rgba(0,0,0,0.6) 0%, transparent 100%);
}

.hub-player-bar {
  display: flex;
  align-items: center;
  gap: 12px;
}

.hub-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 2px solid var(--border-gold);
  overflow: hidden;
  flex-shrink: 0;
}

.hub-player-info {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.hub-player-name {
  font-family: var(--font-title);
  font-size: 1rem;
  color: var(--txt-white);
}

.hub-player-level {
  font-size: 0.78rem;
  color: var(--txt-faded);
  font-style: italic;
}

.hub-gold-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(201,168,76,0.1);
  border: 1px solid var(--border-gold);
  border-radius: 20px;
  padding: 6px 14px;
  font-family: var(--font-title);
  font-size: 1rem;
  color: var(--clr-gold);
}

.gold-icon {
  font-size: 1rem;
  color: var(--clr-gold-lt);
}

.hub-campfire-area {
  height: 160px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.hub-tabs {
  display: flex;
  border-bottom: 1px solid var(--border-dark);
  padding: 0 16px;
  gap: 4px;
  flex-shrink: 0;
}

.hub-tab {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--txt-faded);
  font-family: var(--font-title);
  font-size: 0.8rem;
  letter-spacing: 0.06em;
  padding: 10px 14px;
  cursor: pointer;
  transition: all 0.2s;
  margin-bottom: -1px;
}

.hub-tab.active {
  color: var(--clr-gold);
  border-bottom-color: var(--clr-gold);
}

.hub-panel {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  -webkit-overflow-scrolling: touch;
}

.hub-panel.hidden { display: none; }

.hub-footer {
  padding: 16px;
  border-top: 1px solid var(--border-dark);
  background: var(--bg-void);
  flex-shrink: 0;
  padding-bottom: max(16px, env(safe-area-inset-bottom));
}

/* Upgrade cards */
.upgrade-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.upgrade-card {
  background: var(--bg-card);
  border: 1px solid var(--border-dark);
  border-radius: var(--radius-md);
  padding: 14px;
  display: flex;
  align-items: center;
  gap: 14px;
  transition: border-color 0.2s;
}

.upgrade-card.can-afford { border-color: var(--border-gold); }
.upgrade-card.maxed { opacity: 0.5; }

.upgrade-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  background: var(--bg-mid);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  flex-shrink: 0;
}

.upgrade-info { flex: 1; min-width: 0; }

.upgrade-name {
  font-family: var(--font-title);
  font-size: 0.85rem;
  color: var(--txt-white);
}

.upgrade-desc {
  font-size: 0.8rem;
  color: var(--txt-faded);
  margin-top: 2px;
}

.upgrade-tiers {
  display: flex;
  gap: 4px;
  margin-top: 6px;
}

.tier-pip {
  width: 18px;
  height: 4px;
  border-radius: 2px;
  background: var(--border-dark);
}

.tier-pip.filled { background: var(--clr-gold); }

.upgrade-buy-btn {
  background: none;
  border: 1px solid var(--border-gold);
  color: var(--clr-gold);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-family: var(--font-title);
  font-size: 0.75rem;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
  transition: all 0.2s;
}

.upgrade-buy-btn:active { background: rgba(201,168,76,0.15); }
.upgrade-buy-btn.cannot-afford { opacity: 0.4; cursor: default; }
.upgrade-buy-btn.maxed-label { border-color: var(--border-dark); color: var(--txt-dim); cursor: default; }

/* Stat grid */
.stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.stat-cell {
  background: var(--bg-card);
  border: 1px solid var(--border-dark);
  border-radius: var(--radius-md);
  padding: 14px;
  text-align: center;
}

.stat-cell-value {
  font-family: var(--font-title);
  font-size: 1.6rem;
  color: var(--txt-white);
  display: block;
}

.stat-cell-label {
  font-size: 0.75rem;
  color: var(--txt-faded);
  letter-spacing: 0.06em;
}

/* Offline panel */
.offline-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 20px;
  text-align: center;
}

.offline-reward-badge {
  font-family: var(--font-title);
  font-size: 2rem;
  color: var(--clr-gold);
  text-shadow: var(--shadow-glow-gold);
}

.offline-time-label {
  font-size: 0.85rem;
  color: var(--txt-faded);
  font-style: italic;
}

/* ═══════════════════════════════════════════════
   LOADOUT SCREEN
═══════════════════════════════════════════════ */
#screen-loadout {
  background: var(--bg-deep);
  padding: 0;
}

.loadout-header {
  padding: 48px 20px 16px;
  flex-shrink: 0;
}

.loadout-header h2 {
  font-family: var(--font-title);
  font-size: 1.4rem;
  color: var(--txt-white);
  margin: 8px 0 4px;
}

.subtitle {
  font-size: 0.9rem;
  color: var(--txt-faded);
  font-style: italic;
}

.starting-choices {
  flex: 1;
  overflow-y: auto;
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  -webkit-overflow-scrolling: touch;
}

/* Item cards (loadout + loot) */
.item-card {
  background: var(--bg-card);
  border: 2px solid var(--border-dark);
  border-radius: var(--radius-md);
  padding: 14px;
  display: flex;
  align-items: center;
  gap: 14px;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
  overflow: hidden;
}

.item-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, transparent 60%, rgba(201,168,76,0.04) 100%);
}

.item-card:active, .item-card.selected {
  border-color: var(--clr-gold);
  background: var(--bg-card-hover);
  transform: scale(0.99);
}

.item-card.selected::after {
  content: '✓';
  position: absolute;
  top: 8px;
  right: 12px;
  color: var(--clr-gold);
  font-family: var(--font-title);
  font-size: 0.9rem;
}

.item-card.full {
  opacity: 0.4;
  cursor: not-allowed;
}

.item-icon {
  width: 52px;
  height: 52px;
  border-radius: var(--radius-sm);
  background: var(--bg-mid);
  border: 1px solid var(--border-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
}

.item-icon svg {
  width: 100%;
  height: 100%;
}

.item-info { flex: 1; min-width: 0; }

.item-name {
  font-family: var(--font-title);
  font-size: 0.88rem;
  color: var(--txt-white);
}

.item-type-tag {
  display: inline-block;
  font-size: 0.65rem;
  letter-spacing: 0.08em;
  font-family: var(--font-title);
  padding: 2px 7px;
  border-radius: 3px;
  margin: 4px 0;
}

.item-type-tag.weapon  { background: rgba(139,26,26,0.3); color: #e07070; border: 1px solid rgba(139,26,26,0.4); }
.item-type-tag.armor   { background: rgba(30,80,150,0.3); color: #70a0e0; border: 1px solid rgba(30,80,150,0.4); }
.item-type-tag.consumable { background: rgba(50,130,70,0.3); color: #70e090; border: 1px solid rgba(50,130,70,0.4); }
.item-type-tag.utility { background: rgba(100,60,140,0.3); color: #b070e0; border: 1px solid rgba(100,60,140,0.4); }

.item-desc {
  font-size: 0.78rem;
  color: var(--txt-faded);
  line-height: 1.4;
  font-style: italic;
}

.item-stats {
  display: flex;
  gap: 8px;
  margin-top: 4px;
  flex-wrap: wrap;
}

.item-stat-pill {
  font-size: 0.72rem;
  font-family: var(--font-title);
  color: var(--clr-gold);
  background: rgba(201,168,76,0.08);
  border: 1px solid rgba(201,168,76,0.2);
  border-radius: 3px;
  padding: 2px 6px;
}

.item-rarity {
  width: 4px;
  border-radius: 2px;
  align-self: stretch;
  flex-shrink: 0;
}
.item-rarity.common   { background: #6a6a7a; }
.item-rarity.uncommon { background: #2dbd6e; }
.item-rarity.rare     { background: #4a90e8; }
.item-rarity.epic     { background: #9a4ae8; }

/* Backpack slots */
.backpack-section, .loot-backpack-section {
  padding: 12px 16px;
  flex-shrink: 0;
  border-top: 1px solid var(--border-dark);
}

.backpack-label {
  display: flex;
  justify-content: space-between;
  font-family: var(--font-title);
  font-size: 0.78rem;
  color: var(--txt-faded);
  letter-spacing: 0.06em;
  margin-bottom: 8px;
}

.backpack-slots {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.bp-slot {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-sm);
  border: 1px dashed var(--border-mid);
  background: var(--bg-mid);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.65rem;
  color: var(--txt-dim);
  position: relative;
  overflow: hidden;
  transition: border-color 0.2s;
}

.bp-slot.filled {
  border-style: solid;
  border-color: var(--border-gold);
}

.bp-slot svg {
  width: 80%;
  height: 80%;
}

.bp-slot .slot-name {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(0,0,0,0.75);
  font-size: 0.55rem;
  text-align: center;
  color: var(--txt-parchment);
  padding: 2px;
  font-family: var(--font-title);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.loadout-footer {
  padding: 12px 16px;
  padding-bottom: max(12px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--border-dark);
  flex-shrink: 0;
}

/* ═══════════════════════════════════════════════
   COMBAT SCREEN
═══════════════════════════════════════════════ */
#screen-combat {
  background: var(--bg-void);
}

.combat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 48px 16px 10px;
  flex-shrink: 0;
}

.wave-label {
  font-family: var(--font-title);
  font-size: 0.88rem;
  color: var(--txt-faded);
  letter-spacing: 0.1em;
}

.wave-track {
  display: flex;
  gap: 5px;
  align-items: center;
}

.wave-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--border-mid);
  transition: background 0.3s;
}

.wave-dot.done     { background: var(--clr-gold); }
.wave-dot.current  { background: var(--clr-blood-lt); box-shadow: 0 0 6px var(--clr-blood-lt); width: 10px; height: 10px; }
.wave-dot.boss     { border-radius: 2px; background: #6b1a1a; }
.wave-dot.boss.done    { background: var(--clr-gold); }
.wave-dot.boss.current { background: #ff4444; box-shadow: 0 0 8px #ff4444; }

.combat-gold {
  font-family: var(--font-title);
  font-size: 0.88rem;
  color: var(--clr-gold);
}

/* Arena */
.combat-arena {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: space-around;
  padding: 0 8px;
  position: relative;
  min-height: 0;
}

.combatant {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: 44%;
}

.enemy-side { flex-direction: column; }
.player-side { flex-direction: column-reverse; }

.enemy-name-tag {
  font-family: var(--font-title);
  font-size: 0.78rem;
  color: var(--clr-blood-lt);
  letter-spacing: 0.06em;
  text-align: center;
  order: -1;
}

.sprite-container {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sprite-container.enemy-container { width: 110px; height: 140px; }
.sprite-container.player-container { width: 110px; height: 140px; }

.sprite { width: 100%; height: 100%; }
.sprite svg { width: 100%; height: 100%; }

.status-icons {
  position: absolute;
  bottom: -4px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 3px;
}

.status-icon {
  width: 18px;
  height: 18px;
  border-radius: 3px;
  font-size: 0.65rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255,255,255,0.15);
}

.status-icon.burn    { background: rgba(232,106,42,0.4); }
.status-icon.bleed   { background: rgba(180,30,30,0.4); }
.status-icon.poison  { background: rgba(60,200,80,0.3); }
.status-icon.stun    { background: rgba(230,200,30,0.3); }
.status-icon.regen   { background: rgba(50,200,120,0.3); }
.status-icon.shield  { background: rgba(80,130,220,0.3); }

/* HP Bars */
.hp-bar-wrap {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}

.hp-bar-track {
  width: 100%;
  height: 8px;
  background: rgba(255,255,255,0.07);
  border-radius: 4px;
  overflow: hidden;
  border: 1px solid var(--border-dark);
}

.hp-bar {
  height: 100%;
  border-radius: 4px;
  transition: width 0.4s ease, background-color 0.4s ease;
}

.player-bar { background: var(--hp-green); }
.enemy-bar  { background: var(--clr-blood-lt); }

.hp-text {
  font-family: var(--font-title);
  font-size: 0.7rem;
  color: var(--txt-faded);
}

/* Stat rows */
.player-stat-row, .enemy-stat-row {
  display: flex;
  gap: 6px;
  font-size: 0.68rem;
  font-family: var(--font-title);
  color: var(--txt-dim);
}

.mini-stat { color: var(--txt-faded); }

/* VS divider */
.combat-vs {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.vs-text {
  font-family: var(--font-title);
  font-size: 0.75rem;
  color: var(--border-mid);
  letter-spacing: 0.15em;
}

.combat-sparks {
  width: 2px;
  height: 40px;
  background: linear-gradient(180deg, transparent, var(--border-mid), transparent);
}

/* Combat log */
.combat-log-wrap {
  height: 110px;
  overflow: hidden;
  border-top: 1px solid var(--border-dark);
  border-bottom: 1px solid var(--border-dark);
  flex-shrink: 0;
  position: relative;
}

.combat-log-wrap::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 30px;
  background: linear-gradient(180deg, var(--bg-void), transparent);
  z-index: 1;
  pointer-events: none;
}

.combat-log {
  height: 100%;
  overflow-y: auto;
  padding: 8px 16px;
  display: flex;
  flex-direction: column-reverse;
  gap: 4px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.combat-log::-webkit-scrollbar { display: none; }

.log-line {
  font-size: 0.8rem;
  line-height: 1.4;
  color: var(--txt-faded);
  font-family: var(--font-body);
}

.log-line.player-hit { color: var(--clr-gold); }
.log-line.enemy-hit  { color: #e07070; }
.log-line.status-msg { color: var(--clr-toxic); font-style: italic; }
.log-line.critical   { color: #ff6666; font-weight: 600; }
.log-line.system-msg { color: var(--txt-dim); font-size: 0.72rem; font-style: italic; }

/* Combat backpack bar */
.combat-backpack-bar {
  padding: 8px 16px;
  padding-bottom: max(8px, env(safe-area-inset-bottom));
  flex-shrink: 0;
}

.bp-bar-label {
  font-family: var(--font-title);
  font-size: 0.68rem;
  color: var(--txt-dim);
  letter-spacing: 0.08em;
  margin-bottom: 6px;
}

.combat-bp-slots {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
  padding-bottom: 2px;
}
.combat-bp-slots::-webkit-scrollbar { display: none; }

.combat-bp-slot {
  width: 50px;
  height: 50px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-dark);
  background: var(--bg-card);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
}
.combat-bp-slot svg { width: 70%; height: 70%; }
.combat-bp-slot.used-up { opacity: 0.25; }

/* ═══════════════════════════════════════════════
   LOOT SCREEN
═══════════════════════════════════════════════ */
#screen-loot {
  background: var(--bg-deep);
}

.loot-header {
  padding: 48px 20px 16px;
  text-align: center;
  flex-shrink: 0;
}

.loot-wave-badge {
  display: inline-block;
  font-family: var(--font-title);
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  color: var(--clr-gold);
  border: 1px solid var(--border-gold);
  border-radius: 12px;
  padding: 4px 14px;
  margin-bottom: 10px;
}

.loot-title {
  font-family: var(--font-title);
  font-size: 1.4rem;
  color: var(--txt-white);
}

.loot-next-hint {
  font-size: 0.82rem;
  color: var(--txt-faded);
  font-style: italic;
  margin-top: 4px;
}

.loot-choices {
  flex: 1;
  overflow-y: auto;
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  -webkit-overflow-scrolling: touch;
}

.loot-skip {
  margin: 8px 16px;
  margin-bottom: max(8px, env(safe-area-inset-bottom));
  flex-shrink: 0;
}

/* ═══════════════════════════════════════════════
   RUN END SCREEN
═══════════════════════════════════════════════ */
#screen-run-end {
  justify-content: center;
  align-items: center;
}

.run-end-bg {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at 50% 30%, rgba(139,26,26,0.15) 0%, transparent 70%);
}

.run-end-content {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 28px;
  gap: 14px;
  width: 100%;
  max-width: 360px;
}

.run-end-icon {
  width: 90px;
  height: 90px;
}

.run-end-title {
  font-family: var(--font-title);
  font-size: 2rem;
  color: var(--txt-white);
  text-align: center;
}

.run-end-sub {
  font-size: 0.95rem;
  color: var(--txt-faded);
  font-style: italic;
  text-align: center;
  line-height: 1.5;
}

.run-end-stats {
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border-dark);
  border-radius: var(--radius-md);
  overflow: hidden;
  margin: 8px 0;
}

.re-stat {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-dark);
}

.re-stat:last-child { border-bottom: none; }

.re-stat-label {
  font-size: 0.85rem;
  color: var(--txt-faded);
  font-family: var(--font-title);
  letter-spacing: 0.04em;
}

.re-stat-val {
  font-family: var(--font-title);
  font-size: 1.1rem;
  color: var(--clr-gold);
}

#btn-return-hub, #btn-retry-run { margin-top: 4px; }

/* ═══════════════════════════════════════════════
   FLOATING NUMBERS
═══════════════════════════════════════════════ */
#float-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1000;
}

.float-num {
  position: absolute;
  font-family: var(--font-title);
  font-weight: 700;
  pointer-events: none;
  animation: floatUp 1.2s ease-out forwards;
  white-space: nowrap;
}

.float-num.dmg-player { color: #ff5555; font-size: 1.4rem; }
.float-num.dmg-enemy  { color: var(--clr-gold); font-size: 1.4rem; }
.float-num.heal       { color: var(--clr-toxic); font-size: 1.1rem; }
.float-num.status     { color: #c080ff; font-size: 0.9rem; }
.float-num.crit       { color: #ff3333; font-size: 1.8rem; text-shadow: 0 0 10px rgba(255,50,50,0.6); }

@keyframes floatUp {
  0%   { opacity: 1; transform: translateY(0) scale(1); }
  30%  { opacity: 1; transform: translateY(-30px) scale(1.1); }
  100% { opacity: 0; transform: translateY(-70px) scale(0.8); }
}

/* ═══════════════════════════════════════════════
   TOAST
═══════════════════════════════════════════════ */
#toast-layer {
  position: fixed;
  top: 60px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  background: var(--bg-panel);
  border: 1px solid var(--border-mid);
  border-radius: var(--radius-md);
  padding: 10px 18px;
  font-family: var(--font-title);
  font-size: 0.8rem;
  color: var(--txt-parchment);
  letter-spacing: 0.06em;
  animation: toastIn 0.3s ease, toastOut 0.3s ease 2.2s forwards;
  white-space: nowrap;
  box-shadow: var(--shadow-hard);
}

.toast.success { border-color: var(--clr-toxic); color: var(--clr-toxic); }
.toast.error   { border-color: var(--clr-blood-lt); color: var(--clr-blood-lt); }
.toast.gold    { border-color: var(--clr-gold); color: var(--clr-gold); }

@keyframes toastIn  { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: none; } }
@keyframes toastOut { from { opacity: 1; } to { opacity: 0; } }

/* ═══════════════════════════════════════════════
   HIT ANIMATIONS
═══════════════════════════════════════════════ */
@keyframes shakeLeft {
  0%,100% { transform: translateX(0); }
  20%      { transform: translateX(-12px); }
  40%      { transform: translateX(6px); }
  60%      { transform: translateX(-8px); }
  80%      { transform: translateX(4px); }
}

@keyframes shakeRight {
  0%,100% { transform: translateX(0); }
  20%      { transform: translateX(12px); }
  40%      { transform: translateX(-6px); }
  60%      { transform: translateX(8px); }
  80%      { transform: translateX(-4px); }
}

@keyframes flashRed {
  0%,100% { filter: none; }
  50%      { filter: brightness(2) sepia(1) hue-rotate(-20deg) saturate(5); }
}

@keyframes flashGold {
  0%,100% { filter: none; }
  50%      { filter: brightness(2) sepia(1) hue-rotate(20deg) saturate(4); }
}

@keyframes deathFade {
  0%   { opacity: 1; transform: scale(1); }
  50%  { opacity: 0.3; transform: scale(0.95) rotate(-5deg); }
  100% { opacity: 0; transform: scale(0.8) rotate(-10deg); }
}

.shake-right { animation: shakeRight 0.4s ease; }
.shake-left  { animation: shakeLeft 0.4s ease; }
.flash-hit   { animation: flashRed 0.3s ease; }
.flash-deal  { animation: flashGold 0.2s ease; }
.death-anim  { animation: deathFade 0.8s ease forwards; }

/* ═══════════════════════════════════════════════
   CAMPFIRE ANIMATION
═══════════════════════════════════════════════ */
@keyframes flicker {
  0%,100% { transform: scaleY(1) scaleX(1); opacity: 1; }
  25%      { transform: scaleY(1.08) scaleX(0.96); opacity: 0.95; }
  50%      { transform: scaleY(0.94) scaleX(1.04); opacity: 1; }
  75%      { transform: scaleY(1.05) scaleX(0.97); opacity: 0.97; }
}

@keyframes flickerInner {
  0%,100% { transform: scaleY(1); }
  33%      { transform: scaleY(1.12) scaleX(0.9); }
  66%      { transform: scaleY(0.88) scaleX(1.1); }
}

.flame-outer { animation: flicker 1.4s ease-in-out infinite; transform-origin: bottom center; }
.flame-inner { animation: flickerInner 0.9s ease-in-out infinite; transform-origin: bottom center; }
.flame-core  { animation: flickerInner 0.6s ease-in-out infinite reverse; transform-origin: bottom center; }

@keyframes ember {
  0%   { transform: translate(0,0) scale(1); opacity: 0.8; }
  100% { transform: translate(var(--dx), -60px) scale(0); opacity: 0; }
}

.ember { animation: ember 2s ease-out infinite; }

/* ═══════════════════════════════════════════════
   SCREEN TRANSITIONS
═══════════════════════════════════════════════ */
.screen-slide-out {
  animation: slideOut 0.3s ease forwards;
}
.screen-slide-in {
  animation: slideIn 0.3s ease forwards;
}

@keyframes slideOut {
  to { opacity: 0; transform: translateX(-20px); }
}
@keyframes slideIn {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: none; }
}

/* ═══════════════════════════════════════════════
   MISC
═══════════════════════════════════════════════ */
.hidden { display: none !important; }

.text-gold   { color: var(--clr-gold); }
.text-blood  { color: var(--clr-blood-lt); }
.text-toxic  { color: var(--clr-toxic); }

/* ═══════════════════════════════════════════════
   AUTH MODAL
═══════════════════════════════════════════════ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(5,4,10,0.88);
  z-index: 500;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
  animation: modalIn 0.25s ease;
}

.modal-overlay.hidden { display: none; }

@keyframes modalIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.modal-box {
  background: var(--bg-panel);
  border: 1px solid var(--border-mid);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  padding: 28px 24px;
  padding-bottom: max(28px, env(safe-area-inset-bottom));
  width: 100%;
  max-width: 480px;
  position: relative;
  animation: sheetUp 0.3s ease;
}

@keyframes sheetUp {
  from { transform: translateY(60px); opacity: 0; }
  to   { transform: none; opacity: 1; }
}

.modal-close {
  position: absolute;
  top: 16px; right: 16px;
  background: none;
  border: none;
  color: var(--txt-faded);
  font-size: 1rem;
  cursor: pointer;
  padding: 4px 8px;
}

.modal-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--border-dark);
}

.modal-tab {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--txt-faded);
  font-family: var(--font-title);
  font-size: 0.85rem;
  letter-spacing: 0.06em;
  padding: 10px 18px;
  cursor: pointer;
  margin-bottom: -1px;
  transition: all 0.2s;
}

.modal-tab.active {
  color: var(--clr-gold);
  border-bottom-color: var(--clr-gold);
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.auth-form.hidden { display: none; }

.auth-form label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-family: var(--font-title);
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  color: var(--txt-faded);
}

.auth-form input {
  background: var(--bg-mid);
  border: 1px solid var(--border-mid);
  border-radius: var(--radius-sm);
  color: var(--txt-white);
  font-family: var(--font-body);
  font-size: 1rem;
  padding: 12px 14px;
  outline: none;
  transition: border-color 0.2s;
}

.auth-form input:focus { border-color: var(--clr-gold); }

.auth-error {
  font-size: 0.82rem;
  color: var(--clr-blood-lt);
  font-style: italic;
  min-height: 1.2em;
}

.btn-link {
  background: none;
  border: none;
  color: var(--txt-faded);
  font-family: var(--font-body);
  font-size: 0.78rem;
  text-decoration: underline;
  cursor: pointer;
  padding: 4px 0;
  display: block;
  width: 100%;
  text-align: center;
  font-style: italic;
}

.btn-link:hover { color: var(--clr-gold); }

.auth-note {
  font-size: 0.72rem;
  color: var(--txt-dim);
  text-align: center;
  margin-top: 12px;
  font-style: italic;
}

/* Verify email state */
.verify-icon {
  font-size: 2.8rem;
  text-align: center;
  margin-bottom: 8px;
  filter: grayscale(0.3);
}

.verify-title {
  font-family: var(--font-title);
  font-size: 1.1rem;
  color: var(--txt-white);
  text-align: center;
  letter-spacing: 0.06em;
  margin-bottom: 10px;
}

.verify-body {
  font-size: 0.88rem;
  color: var(--txt-faded);
  text-align: center;
  line-height: 1.6;
  font-style: italic;
}

.verify-body strong {
  color: var(--clr-gold);
  font-style: normal;
  font-weight: 600;
}

/* Profile modal extras */
.modal-heading {
  font-family: var(--font-title);
  font-size: 1.1rem;
  color: var(--txt-white);
  letter-spacing: 0.08em;
  margin-bottom: 18px;
}

.profile-danger-zone {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border-dark);
}

/* Hub player name — tappable */
.hub-player-name {
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
}

.hub-player-name::after {
  content: '✎';
  font-size: 0.7rem;
  color: var(--txt-dim);
  opacity: 0.7;
}

/* Verified badge */
.verified-badge {
  display: inline-block;
  font-size: 0.6rem;
  font-family: var(--font-title);
  color: var(--clr-toxic);
  border: 1px solid var(--clr-toxic);
  border-radius: 3px;
  padding: 1px 5px;
  letter-spacing: 0.06em;
  vertical-align: middle;
  margin-left: 4px;
  opacity: 0.8;
}

/* ─── Offline mode banner ─── */
.offline-banner {
  background: rgba(201,168,76,0.08);
  border: 1px solid var(--border-gold);
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  font-size: 0.75rem;
  color: var(--clr-gold);
  font-family: var(--font-title);
  letter-spacing: 0.05em;
  text-align: center;
  margin: 0 16px 8px;
  flex-shrink: 0;
}

/* ════════════════════════════════════════
   CO-OP SCREENS
════════════════════════════════════════ */

/* Generic screen inner wrapper */
.screen-inner {
  display: flex;
  flex-direction: column;
  padding: 20px 16px 32px;
  max-width: 420px;
  margin: 0 auto;
  min-height: 100%;
  box-sizing: border-box;
}

.screen-heading {
  font-family: var(--font-title);
  font-size: 1.4rem;
  color: var(--txt-white);
  letter-spacing: 0.1em;
  text-align: center;
  margin: 8px 0 4px;
}

.screen-sub {
  font-size: 0.82rem;
  color: var(--txt-faded);
  text-align: center;
  font-style: italic;
  margin-bottom: 24px;
  line-height: 1.5;
}

/* ── Co-op lobby ── */
.coop-options {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.coop-option-card {
  background: var(--bg-card);
  border: 1px solid var(--border-dark);
  border-radius: var(--radius);
  padding: 20px;
  text-align: center;
}

.coop-option-card h3 {
  font-family: var(--font-title);
  font-size: 0.95rem;
  color: var(--txt-white);
  letter-spacing: 0.08em;
  margin-bottom: 6px;
}

.coop-option-card p {
  font-size: 0.8rem;
  color: var(--txt-faded);
  font-style: italic;
  margin-bottom: 14px;
  line-height: 1.4;
}

.coop-option-icon {
  font-size: 2rem;
  margin-bottom: 10px;
}

.coop-or {
  text-align: center;
  font-size: 0.7rem;
  color: var(--txt-dim);
  letter-spacing: 0.1em;
  padding: 14px 0;
  font-family: var(--font-title);
}

.coop-join-row {
  display: flex;
  gap: 8px;
  margin-bottom: 0;
}

.coop-code-input {
  flex: 1;
  background: var(--bg-deep);
  border: 1px solid var(--border-mid);
  border-radius: var(--radius-sm);
  color: var(--txt-white);
  font-family: var(--font-title);
  font-size: 1.1rem;
  letter-spacing: 0.2em;
  text-align: center;
  padding: 10px;
  text-transform: uppercase;
  outline: none;
}

.coop-code-input:focus {
  border-color: var(--clr-gold);
}

/* ── Waiting room ── */
.coop-code-display {
  background: var(--bg-card);
  border: 1px solid var(--clr-gold);
  border-radius: var(--radius);
  padding: 18px 16px;
  text-align: center;
  margin-bottom: 24px;
}

.coop-code-label {
  font-size: 0.72rem;
  color: var(--txt-faded);
  font-style: italic;
  margin-bottom: 8px;
  letter-spacing: 0.04em;
}

.coop-code-big {
  font-family: var(--font-title);
  font-size: 2.2rem;
  font-weight: 700;
  color: var(--clr-gold);
  letter-spacing: 0.3em;
  text-shadow: 0 0 20px rgba(201,168,76,0.4);
}

.coop-code-hint {
  font-size: 0.68rem;
  color: var(--txt-dim);
  margin-top: 6px;
  font-style: italic;
}

.coop-party {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin: 4px 0 20px;
}

.coop-party-slot {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  flex: 1;
  background: var(--bg-card);
  border: 1px solid var(--border-dark);
  border-radius: var(--radius);
  padding: 14px 8px;
}

.coop-slot-guest {
  opacity: 0.45;
  transition: opacity 0.4s;
}

.coop-slot-guest.joined {
  opacity: 1;
  border-color: var(--clr-gold);
}

.coop-party-avatar {
  font-size: 1.8rem;
}

.coop-party-name {
  font-family: var(--font-title);
  font-size: 0.78rem;
  color: var(--txt-white);
  letter-spacing: 0.05em;
  text-align: center;
}

.coop-party-tag {
  font-size: 0.65rem;
  color: var(--txt-dim);
  letter-spacing: 0.06em;
  font-family: var(--font-title);
}

.coop-party-sword {
  font-size: 1.4rem;
  color: var(--clr-blood);
  flex-shrink: 0;
}

.coop-status-msg {
  text-align: center;
  font-size: 0.8rem;
  color: var(--txt-faded);
  font-style: italic;
  margin-bottom: 24px;
}

.coop-waiting-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: auto;
}

/* ── Co-op combat: partner HP bar strip ── */
.coop-partner-bar {
  background: var(--bg-panel);
  border-top: 1px solid var(--border-dark);
  padding: 6px 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.72rem;
  color: var(--txt-faded);
}

.coop-partner-bar .partner-label {
  font-family: var(--font-title);
  font-size: 0.65rem;
  letter-spacing: 0.06em;
  white-space: nowrap;
}

.coop-partner-bar .hp-bar-track {
  flex: 1;
  height: 6px;
}

.coop-partner-bar .hp-text {
  font-size: 0.65rem;
  white-space: nowrap;
}

/* ── Loot screen: partner status pill ── */
.loot-partner-status {
  text-align: center;
  font-size: 0.75rem;
  font-style: italic;
  padding: 8px 0 2px;
  color: var(--txt-faded);
}

.loot-partner-status.done {
  color: var(--clr-toxic);
  font-style: normal;
}

/* Hub co-op button spacing */
.hub-footer {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Scrollbar styling for desktop previews */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-mid); border-radius: 2px; }
