* {
  box-sizing: border-box;
}

html {
  touch-action: manipulation;
  height: 100%;
  background: #060810;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, Arial, sans-serif;
  background: radial-gradient(ellipse at 50% 0%, #1e1030 0%, #0d1020 40%, #060810 100%);
  color: #e8edf5;
  height: 100%;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  /* Safe areas for iOS notch and Android cutout */
  padding-top: env(safe-area-inset-top);
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}

h1, h2, h3 {
  font-family: 'Cinzel', serif;
  margin-top: 0;
}

h3, p {
  margin-top: 0;
}

h1 { margin-bottom: 4px; }
h2 { margin-bottom: 10px; }
h3 { margin-bottom: 6px; font-size: 15px; letter-spacing: 0.4px; }

.hidden {
  display: none !important;
}

/* ── App shell ── */
.app {
  width: min(900px, 100%);
  margin: 0 auto;
  padding: 6px 10px 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
  background: rgba(4, 6, 14, 0.98);
}

.create-profile {
  position: fixed;
  inset: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 24px 18px 48px;
}

.profile-create-card {
  max-width: 430px;
  width: 100%;
}

/* ── Inputs ── */
.profile-create-card input,
.chat-input-row input {
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(5, 8, 18, 0.9);
  color: white;
  border-radius: 12px;
  padding: 13px;
  font-size: 16px;
  margin-bottom: 10px;
  transition: border-color 0.2s;
}

.profile-create-card input:focus,
.chat-input-row input:focus {
  outline: none;
  border-color: rgba(250, 204, 21, 0.4);
}

/* ── Starter stat selector ── */
.starter-stat {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(8, 12, 24, 0.85);
  border: 1px solid rgba(255,255,255,0.06);
  padding: 12px;
  border-radius: 12px;
  margin-bottom: 10px;
}

.starter-stat div {
  display: flex;
  align-items: center;
  gap: 10px;
}

.starter-stat button {
  width: 42px;
  height: 42px;
  padding: 0;
}

.error-text {
  color: #f87171;
  margin-bottom: 0;
  font-size: 14px;
}

/* ── Mini Chat (legacy stub — element now lives in .auto-chat-preview) ── */

/* ── Presence dots ── */
.presence-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}
.dot-online  { background: #4ade80; box-shadow: 0 0 5px rgba(74,222,128,.7); }
.dot-offline { background: #374151; }

.topbar p,
.muted {
  color: #6b7a99;
  font-size: 13px;
}

/* ── Cards ── */
.card {
  background: rgba(10, 15, 28, 0.97);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 18px;
  padding: 16px;
  margin-bottom: 10px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
}

/* ── Action / combat log card ── */
.action-card {
  flex-shrink: 0;
  backdrop-filter: blur(16px);
  background: rgba(6, 10, 22, 0.96);
  border-color: rgba(99, 102, 241, 0.25);
  box-shadow: 0 4px 24px rgba(0,0,0,0.5), 0 0 0 1px rgba(99,102,241,0.1);
  padding: 8px 12px;
}

/* ── Leaderboard card (fills remaining vertical space, scrolls internally) ── */
.leaderboard-card {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 8px 10px;
}

.leaderboard-card #leaderboard {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}

/* ── Automation card — flush to nav bar, no visible gap ── */
.auto-card {
  flex-shrink: 0;
  margin-bottom: 0;
  border-radius: 18px 18px 0 0;
  border-left: none;
  border-right: none;
  border-bottom: none;
  padding: 8px 12px 68px;
}

.action-card h2 {
  font-size: 10px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: #4b5473;
  margin-bottom: 5px;
}

#lastAction {
  background: rgba(5, 8, 18, 0.7);
  border-left: 3px solid #6366f1;
  padding: 7px 10px;
  border-radius: 8px;
  line-height: 1.45;
  font-size: 12px;
  color: #c8d4f0;
  height: calc(2 * 12px * 1.45 + 14px);
  overflow: hidden;
}

/* ── Hero card ── */
.hero-card {
  background: linear-gradient(145deg, rgba(18, 12, 36, 0.99) 0%, rgba(8, 12, 26, 0.99) 100%);
  border-color: rgba(250, 204, 21, 0.2);
  box-shadow: 0 6px 32px rgba(0,0,0,0.5), inset 0 1px 0 rgba(250,204,21,0.06);
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  padding: 11px 14px;
}

.hero-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.hero-avatar {
  font-size: 32px;
  line-height: 1;
  flex-shrink: 0;
  filter: drop-shadow(0 3px 8px rgba(0,0,0,0.7));
}

.hero-info h2 {
  font-size: 18px;
  color: #facc15;
  margin-bottom: 2px;
  letter-spacing: 0.6px;
  text-shadow: 0 0 14px rgba(250,204,21,0.25);
}

.hero-info .muted {
  font-size: 11px;
}

/* ── Quick stats pills ── */
.quick-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin: 0 0 8px;
}

.quick-stats span {
  background: rgba(8, 12, 26, 0.9);
  border: 1px solid rgba(255,255,255,0.08);
  padding: 4px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.2px;
}

/* ── Hero HP/XP bars ── */
.hero-bars {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 4px;
}

.bar-row {
  display: flex;
  align-items: center;
  gap: 9px;
}

.bar-label {
  font-size: 10px;
  font-weight: 800;
  color: #4b5473;
  width: 20px;
  flex-shrink: 0;
  text-transform: uppercase;
  letter-spacing: 0.8px;
}

.bar-track {
  flex: 1;
  height: 7px;
  background: rgba(5, 8, 18, 0.9);
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,0.04);
}

.bar-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.35s ease, background 0.35s ease;
}

#hpFill {
  background: linear-gradient(90deg, #16a34a, #22c55e);
  width: 100%;
}

.xp-fill {
  background: linear-gradient(90deg, #4f46e5, #818cf8);
  width: 0%;
}

.stat-footer {
  font-size: 12px;
  color: #4b5473;
  margin: 0;
}

/* ── Deprecated single-bar styles (boss HP bars in modals) ── */
.xp-bar,
.hp-bar {
  width: 100%;
  height: 8px;
  background: rgba(5,8,18,0.9);
  border-radius: 999px;
  overflow: hidden;
  margin: 10px 0;
}

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

/* ── Buttons ── */
button {
  border: 0;
  border-radius: 12px;
  padding: 11px 14px;
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: white;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: filter 0.15s, transform 0.1s;
  letter-spacing: 0.2px;
}

button:hover {
  filter: brightness(1.18);
}

button:active {
  transform: scale(0.97);
}

button:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  filter: none;
  transform: none;
}

button.active {
  background: linear-gradient(135deg, #15803d, #16a34a);
  box-shadow: 0 0 12px rgba(22, 163, 74, 0.3);
}

.secondary {
  background: rgba(30, 42, 72, 0.9);
  border: 1px solid rgba(255,255,255,0.08);
}

.btn-danger {
  background: linear-gradient(135deg, #991b1b, #b91c1c);
}

/* ── Auto row (chat preview + idle toggle) ── */
.auto-row {
  display: flex;
  gap: 10px;
  align-items: stretch;
}

.auto-chat-preview {
  flex: 1;
  min-width: 0;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 3px;
  overflow: hidden;
}

.auto-chat-preview .mini-chat-msg {
  display: block;
  background: rgba(255,255,255,.05);
  border-radius: 8px;
  padding: 3px 8px;
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: #e2e8f0;
  text-shadow: none;
}

#autoIdleBtn {
  flex-shrink: 0;
  width: 130px;
  font-size: 12px;
  line-height: 1.3;
  white-space: nowrap;
}

/* ── Shared button grids ── */
.boss-actions,
.profile-actions,
.chat-input-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.chat-input-row {
  grid-template-columns: 1fr 90px;
  margin-top: 10px;
}

/* ── Section dividers ── */
.section-label {
  font-family: 'Cinzel', serif;
  font-size: 10px;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: #3b4466;
  margin: 18px 0 10px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.section-label:first-child {
  margin-top: 0;
}

.section-label::after {
  content: '';
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, rgba(255,255,255,0.07), transparent);
}

/* ── Leaderboard ── */
#leaderboard,
#bossList,
#shopList {
  display: grid;
  gap: 6px;
}

.leaderboard-row {
  background: rgba(8, 12, 22, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.055);
  border-radius: 12px;
  padding: 7px 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  cursor: pointer;
  transition: border-color 0.15s;
}

.lb-top {
  display: grid;
  grid-template-columns: 36px 1fr auto;
  gap: 8px;
  align-items: center;
}

.lb-stats {
  display: flex;
  gap: 10px;
  font-size: 11px;
  color: #8a9bbf;
  padding-left: 2px;
}

.lb-stats span { font-weight: 600; }

.lb-hpbar {
  height: 4px;
  background: rgba(255,255,255,0.06);
  border-radius: 999px;
  overflow: hidden;
}

.leaderboard-row:hover {
  border-color: rgba(255,255,255,0.12);
}

.leaderboard-row.you {
  background: linear-gradient(90deg, rgba(10, 28, 18, 0.95), rgba(8, 12, 22, 0.95));
  border-color: rgba(34, 197, 94, 0.3);
}

.rank {
  font-size: 15px;
  font-weight: 900;
  font-family: 'Cinzel', serif;
  text-align: center;
}

.rank.rank-1 { color: #facc15; text-shadow: 0 0 10px rgba(250,204,21,0.4); }
.rank.rank-2 { color: #94a3b8; text-shadow: 0 0 8px rgba(148,163,184,0.3); }
.rank.rank-3 { color: #c2773a; text-shadow: 0 0 8px rgba(194,119,58,0.3); }
.rank.rank-other { color: #3b4466; }

.name {
  font-weight: 700;
  font-size: 13px;
  color: #e2e8f0;
}

.mini-stats {
  color: #4b5a7a;
  font-size: 11px;
  margin-top: 1px;
}

/* ── Boss cards ── */
.boss-card {
  background: linear-gradient(145deg, rgba(22, 6, 6, 0.97), rgba(10, 12, 24, 0.97));
  border: 1px solid rgba(220, 38, 38, 0.18);
  border-radius: 14px;
  padding: 14px;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: border-color 0.2s;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4), inset 0 1px 0 rgba(255,50,50,0.04);
}

.boss-card:hover {
  border-color: rgba(220, 38, 38, 0.35);
}

.boss-card h3 {
  color: #fca5a5;
  font-size: 15px;
  margin-bottom: 8px;
  letter-spacing: 0.3px;
}

/* ── Shop cards ── */
.shop-card {
  background: linear-gradient(145deg, rgba(8, 14, 32, 0.97), rgba(10, 16, 36, 0.97));
  border: 1px solid rgba(99, 130, 255, 0.12);
  border-radius: 14px;
  padding: 14px;
  transition: border-color 0.2s;
}

.shop-card:hover {
  border-color: rgba(99, 130, 255, 0.22);
}

.leaderboard-info {
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

/* ── Requirement text ── */
.requirement-ok {
  color: #22c55e;
  font-weight: 700;
  font-size: 13px;
}

.requirement-bad {
  color: #f87171;
  font-weight: 700;
  font-size: 13px;
}

/* ── Badge ── */
.badge {
  background: rgba(22, 38, 80, 0.9);
  border: 1px solid rgba(59, 90, 180, 0.4);
  padding: 5px 11px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  color: #93c5fd;
}

/* ── Card header ── */
.card-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 14px;
}

.card-header h2 {
  margin: 0;
}

/* ── Overlays ── */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  justify-content: center;
  align-items: flex-end;
  padding: 0;
  z-index: 100;
  backdrop-filter: blur(4px);
}

.modal {
  background: rgba(10, 15, 28, 0.97);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-bottom: none;
  border-radius: 22px 22px 0 0;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
  width: min(680px, 100%);
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: slideUp 0.22s cubic-bezier(0.32, 0.72, 0, 1);
}

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

.modal-header {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  padding: 14px 16px;
  flex-shrink: 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.modal-header h2 {
  flex: 1;
  margin: 0;
  font-size: 18px;
  letter-spacing: 1px;
  color: #facc15;
}

.modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 18px 18px 36px;
  min-height: 0;
}

.modal-footer {
  flex-shrink: 0;
  padding: 10px 18px 18px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.modal h2 {
  font-size: 18px;
  letter-spacing: 1px;
  color: #facc15;
  margin-bottom: 16px;
}

.close-btn {
  width: 38px;
  height: 38px;
  padding: 0;
  border-radius: 50%;
  background: rgba(30, 42, 72, 0.9);
  font-size: 22px;
  line-height: 1;
  color: #8a9bbf;
  border: 1px solid rgba(255,255,255,0.08);
  flex-shrink: 0;
}

/* ── Bottom navigation ── */
.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: 60px;
  background: rgba(4, 6, 14, 0.98);
  backdrop-filter: blur(20px);
  border-top: 1px solid rgba(255, 255, 255, 0.07);
  display: flex;
  align-items: stretch;
  z-index: 60;
}

.nav-tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  background: transparent;
  border: none;
  border-radius: 0;
  padding: 5px 4px;
  color: #3b4466;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  position: relative;
  transition: color 0.15s;
  touch-action: manipulation;
  letter-spacing: 0.3px;
}

.nav-tab:hover {
  background: rgba(255, 255, 255, 0.03);
  color: #8a9bbf;
  filter: none;
}

.nav-tab:active {
  background: rgba(255, 255, 255, 0.06);
  transform: none;
}

.nav-icon {
  font-size: 20px;
  line-height: 1;
  display: block;
}

.nav-label {
  font-size: 10px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.nav-badge {
  position: absolute;
  top: 5px;
  right: calc(50% - 20px);
  background: #ef4444;
  color: white;
  font-size: 10px;
  font-weight: 800;
  min-width: 16px;
  height: 16px;
  border-radius: 999px;
  padding: 0 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid rgba(4, 6, 14, 0.98);
  box-shadow: 0 0 6px rgba(239, 68, 68, 0.5);
}

/* ── Profile grid ── */
.profile-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 14px 0;
}

.profile-grid div {
  background: rgba(5, 8, 18, 0.9);
  border: 1px solid rgba(255,255,255,0.06);
  padding: 12px 10px;
  border-radius: 12px;
  text-align: center;
}

.profile-grid span {
  display: block;
  color: #4b5a7a;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin-bottom: 4px;
}

.profile-grid strong {
  font-size: 19px;
}

.damage-list p {
  margin: 5px 0;
  color: #93c5fd;
  font-size: 13px;
}

/* ── Chat ── */
#chatContent {
  display: grid;
  gap: 8px;
}

.chat-message {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255,255,255,0.09);
  border-left: 3px solid rgba(250,204,21,0.4);
  border-radius: 12px;
  padding: 9px 12px;
  line-height: 1.45;
}

.guild-msg { border-left-color: rgba(245,158,11,0.5); }
.pm-msg    { border-left-color: rgba(168,85,247,0.5); }

.chat-name {
  color: #facc15;
  font-weight: 700;
  font-size: 13px;
}

.chat-name.clickable {
  cursor: pointer;
  text-decoration: underline dotted;
}
.chat-name.clickable:hover { color: #fde68a; }

.chat-text {
  color: #d1d8e8;
  font-size: 14px;
}

/* ── Chat Tabs ── */
.chat-tab-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 8px 14px;
  border-bottom: 1px solid rgba(255,255,255,0.07);
  background: rgba(0,0,0,0.15);
}

.chat-tab {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  background: rgba(255,255,255,0.05);
  color: #94a3b8;
  border: 1px solid rgba(255,255,255,0.09);
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s;
}
.chat-tab.active {
  background: rgba(99,102,241,0.2);
  color: #c7d2fe;
  border-color: rgba(99,102,241,0.35);
}

.pm-tab-wrap { display: inline-flex; align-items: center; }

.chat-tab-x {
  background: none;
  border: none;
  color: #475569;
  font-size: 15px;
  padding: 2px 4px;
  cursor: pointer;
  border-radius: 50%;
  line-height: 1;
  margin-left: -3px;
}
.chat-tab-x:hover { color: #ef4444; background: rgba(239,68,68,0.1); }

.chat-tab-badge {
  font-size: 10px;
  padding: 1px 5px;
  border-radius: 999px;
  color: #fff;
  font-weight: 700;
}
.guild-badge { background: #f59e0b; }
.pm-badge    { background: #a855f7; }

/* ── Chat icon notification badge ── */
.auto-chat-preview { position: relative; }
.chat-notif-badge {
  position: absolute;
  top: 4px;
  right: 4px;
  font-size: 10px;
  font-weight: 700;
  color: #fff;
  padding: 1px 5px;
  border-radius: 999px;
  min-width: 16px;
  text-align: center;
  pointer-events: none;
  z-index: 2;
}

/* ── PM request card ── */
.pm-request-card {
  text-align: center;
  padding: 24px 16px;
  border: 1px solid rgba(168,85,247,0.25);
  border-radius: 12px;
  background: rgba(168,85,247,0.05);
  margin: 4px 0;
}
.pm-request-card p { color: #c4b5fd; margin-bottom: 4px; }

/* ── Tutorial ── */
.tutorial-card {
  text-align: center;
}

.tutorial-card h2 {
  font-size: 22px;
  margin-bottom: 14px;
}

.tutorial-card p {
  line-height: 1.75;
  color: #b0bcd4;
}

.tutorial-buttons {
  margin-top: 22px;
}

.tutorial-buttons button {
  width: 100%;
  padding: 14px;
  font-size: 16px;
  letter-spacing: 0.5px;
}

/* ── Pulse animation (boss auto active) ── */
@keyframes bossPulse {
  0%   { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.4); }
  70%  { box-shadow: 0 0 0 8px rgba(220, 38, 38, 0); }
  100% { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0); }
}

/* ── Mobile ── */
@media (max-width: 720px) {
  .card-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .top-actions {
    width: 100%;
  }

  .top-actions button {
    flex: 1;
  }

  .boss-actions,
  .profile-actions,
  .chat-input-row {
    grid-template-columns: 1fr;
  }

  .lb-top {
    grid-template-columns: 40px 1fr auto;
  }
}

/* ══════════════════════════════════════
   LEVEL-UP OVERLAY
══════════════════════════════════════ */
#levelUpOverlay {
  position: fixed;
  inset: 0;
  z-index: 99998;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  opacity: 0;
}
#levelUpOverlay.lu-active {
  animation: luBg 2s ease-out forwards;
}
@keyframes luBg {
  0%   { opacity: 0; }
  10%  { opacity: 1; }
  72%  { opacity: 1; }
  100% { opacity: 0; }
}
.lu-badge {
  text-align: center;
  background: radial-gradient(ellipse at 50% 50%, rgba(250,204,21,.18) 0%, transparent 70%);
  padding: 32px 52px;
  border-radius: 28px;
}
.lu-main {
  font-family: 'Cinzel', serif;
  font-size: 46px;
  font-weight: 900;
  letter-spacing: 4px;
  color: #facc15;
  text-shadow: 0 0 30px rgba(250,204,21,.9), 0 0 60px rgba(250,204,21,.4);
  display: block;
  animation: luPop 2s ease-out forwards;
}
.lu-sub {
  font-family: 'Cinzel', serif;
  font-size: 17px;
  letter-spacing: 1px;
  color: rgba(255,255,255,.8);
  display: block;
  margin-top: 8px;
  animation: luPop 2s ease-out 0.08s both;
}
@keyframes luPop {
  0%   { opacity: 0; transform: scale(.55); }
  14%  { opacity: 1; transform: scale(1.08); }
  22%  { transform: scale(1); }
  72%  { opacity: 1; }
  100% { opacity: 0; transform: translateY(-22px); }
}

/* ══════════════════════════════════════
   RARE LOOT NOTIFICATIONS
══════════════════════════════════════ */
#notificationBell.rare-glow {
  animation: rareGlowBell 1.4s ease-in-out infinite !important;
}
@keyframes rareGlowBell {
  0%,100% { filter: none; }
  50%     { filter: drop-shadow(0 0 8px rgba(168,85,247,.95)) drop-shadow(0 0 18px rgba(249,115,22,.4)); }
}

.notif-rare {
  position: relative;
  overflow: hidden;
  border-color: rgba(168,85,247,.4) !important;
}
.notif-legendary {
  border-color: rgba(249,115,22,.45) !important;
}
.notif-mythic {
  border-color: rgba(239,68,68,.45) !important;
}
.notif-rare::before {
  content: '';
  position: absolute;
  top: 0; bottom: 0; left: -100%;
  width: 55%;
  background: linear-gradient(105deg, transparent 25%, rgba(255,255,255,.16) 50%, transparent 75%);
  animation: notifBeam .65s ease-out .2s forwards;
}
@keyframes notifBeam {
  from { left: -100%; }
  to   { left: 160%; }
}

/* ══════════════════════════════════════
   DUNGEON SYSTEM
══════════════════════════════════════ */

/* ── Dungeon Wait Split Screen ── */
.dg-wait-screen {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  background: #060810;
}

.dg-wait-header {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  padding-top: max(10px, env(safe-area-inset-top));
  background: rgba(10, 15, 30, 0.98);
  border-bottom: 1px solid rgba(255,255,255,0.08);
  min-height: 54px;
}

.dg-wait-body {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
}

.dg-wait-pane {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.dg-wait-pane + .dg-wait-pane {
  border-left: 1px solid rgba(255,255,255,0.06);
}

.dg-wait-pane-title {
  flex-shrink: 0;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: #4b5473;
  padding: 7px 12px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  font-family: system-ui, -apple-system, Arial, sans-serif;
}

.dg-wait-msgs {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.dg-wait-input-row {
  flex-shrink: 0;
  display: flex;
  gap: 6px;
  padding: 7px 8px;
  padding-bottom: max(7px, env(safe-area-inset-bottom));
  border-top: 1px solid rgba(255,255,255,0.06);
  background: rgba(6,8,18,0.98);
}

.dg-wait-input-row input {
  flex: 1;
  background: rgba(5,8,18,0.9);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 8px;
  padding: 7px 10px;
  color: #e8edf5;
  font-size: 13px;
  min-width: 0;
  outline: none;
}
.dg-wait-input-row input:focus { border-color: rgba(99,102,241,0.4); }

.dg-wait-input-row button {
  padding: 7px 11px;
  background: rgba(99,102,241,0.18);
  border: 1px solid rgba(99,102,241,0.3);
  border-radius: 8px;
  color: #a5b4fc;
  font-size: 15px;
  cursor: pointer;
  flex-shrink: 0;
}

.dg-wait-lb-inner {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.dg-wait-lb-row {
  padding: 8px 10px;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  cursor: pointer;
  transition: background 0.1s;
}
.dg-wait-lb-row:active { background: rgba(255,255,255,0.03); }
.dg-wait-lb-you { background: rgba(250,204,21,0.04); }

.dg-wait-header-btn {
  font-size: 12px;
  padding: 5px 10px;
  border-radius: 8px;
  cursor: pointer;
  border: 1px solid;
  flex-shrink: 0;
  font-family: system-ui, -apple-system, Arial, sans-serif;
  line-height: 1.4;
}

.dg-lobby { display: flex; flex-direction: column; gap: 14px; }

.dg-def-card {
  border-radius: 18px;
  background: linear-gradient(135deg, rgba(79,70,229,.12) 0%, rgba(109,40,217,.08) 100%);
  border: 1px solid rgba(139,92,246,.25);
  padding: 16px;
  transition: border-color .2s;
}
.dg-def-card:not(.dg-locked):hover { border-color: rgba(139,92,246,.5); }
.dg-locked { opacity: .5; pointer-events: none; }

.dg-def-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}
.dg-def-icon { font-size: 32px; flex-shrink: 0; }
.dg-def-name { font-weight: 700; font-size: 15px; color: #e2e8f0; margin-bottom: 3px; }
.dg-def-meta { font-size: 11px; color: #6b7a99; }
.dg-soon-badge {
  margin-left: auto;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1px;
  color: #fbbf24;
  background: rgba(251,191,36,.12);
  border: 1px solid rgba(251,191,36,.3);
  border-radius: 8px;
  padding: 3px 8px;
  flex-shrink: 0;
}
.dg-locked-badge {
  margin-left: auto;
  font-size: 11px;
  color: #6b7a99;
  background: rgba(255,255,255,.04);
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 8px;
  padding: 3px 8px;
  flex-shrink: 0;
}
.dg-def-rewards { font-size: 12px; color: #94a3b8; margin-bottom: 12px; }

.dg-parties { display: flex; flex-direction: column; gap: 6px; margin-bottom: 8px; }
.dg-party-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: rgba(255,255,255,.04);
  border-radius: 10px;
  font-size: 13px;
}
.dg-party-row button {
  background: linear-gradient(135deg,#4f46e5,#7c3aed);
  border: none;
  color: white;
  padding: 5px 14px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
}
.dg-create-btn {
  width: 100%;
  padding: 12px;
  background: linear-gradient(135deg,#4f46e5,#7c3aed);
  border: none;
  color: white;
  border-radius: 12px;
  cursor: pointer;
  font-weight: 700;
  font-size: 14px;
  transition: opacity .2s;
}
.dg-create-btn:hover { opacity: .85; }

/* ── Waiting Room ── */
.dg-waiting { text-align: center; }
.dg-waiting-title { font-size: 20px; font-weight: 700; color: #e2e8f0; margin-bottom: 4px; }
.dg-waiting-sub { font-size: 13px; color: #6b7a99; margin-bottom: 20px; }
.dg-player-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 20px; }
.dg-player-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  background: rgba(255,255,255,.05);
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 12px;
}
.dg-empty-slot { border-style: dashed; opacity: .4; }
.dg-player-name { font-weight: 600; font-size: 14px; }
.dg-player-hp { font-size: 12px; color: #6b7a99; }
.dg-start-btn {
  width: 100%;
  padding: 16px;
  background: linear-gradient(135deg,#059669,#10b981);
  border: none;
  color: white;
  border-radius: 14px;
  cursor: pointer;
  font-weight: 800;
  font-size: 15px;
  margin-bottom: 12px;
  letter-spacing: .5px;
}
.dg-btn-dim { opacity: .45; cursor: not-allowed; }
.btn-loading { opacity: .55; cursor: not-allowed; }
.dg-waiting-hint { font-size: 13px; color: #94a3b8; margin-bottom: 12px; }
.dg-leave-btn {
  background: rgba(239,68,68,.1);
  border: 1px solid rgba(239,68,68,.25);
  color: #f87171;
  padding: 10px 20px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  width: 100%;
}

/* ── Fight Screen ── */
.dg-fight { display: flex; flex-direction: column; align-items: stretch; gap: 14px; }
.dg-wave-dots {
  display: flex;
  gap: 10px;
  justify-content: center;
}
.dg-wave-dot {
  width: 38px; height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-size: 17px;
  background: rgba(255,255,255,.06);
  border: 2px solid rgba(255,255,255,.12);
  color: #6b7a99;
}
.dg-dot-done {
  background: rgba(16,185,129,.2);
  border-color: #10b981;
  color: #10b981;
  font-size: 14px;
}
.dg-dot-active {
  background: rgba(139,92,246,.2);
  border-color: #8b5cf6;
  color: white;
  animation: wavePulse 1.5s ease-in-out infinite;
}
@keyframes wavePulse {
  0%,100% { box-shadow: 0 0 0 0 rgba(139,92,246,.4); }
  50%     { box-shadow: 0 0 0 6px rgba(139,92,246,0); }
}
.dg-enemy-section {
  text-align: center;
  padding: 16px;
  background: rgba(239,68,68,.06);
  border: 1px solid rgba(239,68,68,.2);
  border-radius: 16px;
}
.dg-enemy-icon { font-size: 52px; line-height: 1; }
.dg-enemy-name { font-size: 17px; font-weight: 700; color: #e2e8f0; margin: 6px 0 3px; }
.dg-enemy-stats { font-size: 12px; color: #94a3b8; margin-bottom: 10px; }
.dg-hp-bar-wrap {
  height: 12px;
  background: rgba(255,255,255,.08);
  border-radius: 6px;
  overflow: hidden;
  margin-bottom: 4px;
}
.dg-hp-bar {
  height: 100%;
  background: linear-gradient(90deg,#dc2626,#ef4444,#f97316);
  border-radius: 6px;
  transition: width .3s ease;
}
.dg-hp-text { font-size: 12px; color: #94a3b8; }
.dg-players-section { display: flex; gap: 10px; }
.dg-player-card {
  flex: 1;
  padding: 12px 10px;
  background: rgba(255,255,255,.05);
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 14px;
  text-align: center;
}
.dg-dead { opacity: .5; border-color: rgba(239,68,68,.3) !important; }
.dg-player-card .dg-player-name { font-size: 12px; margin-bottom: 4px; }
.dg-player-hp-bar-wrap {
  height: 8px;
  background: rgba(255,255,255,.08);
  border-radius: 4px;
  overflow: hidden;
  margin: 4px 0;
}
.dg-player-hp-bar {
  height: 100%;
  border-radius: 4px;
  transition: width .3s ease;
}
.dg-player-hp-text { font-size: 11px; color: #94a3b8; }
.dg-player-buffs { font-size: 14px; margin-top: 4px; letter-spacing: 2px; }
.dg-attack-btn {
  width: 100%;
  padding: 18px;
  background: linear-gradient(90deg,#dc2626,#ef4444,#f97316,#ef4444,#dc2626);
  background-size: 300% 100%;
  border: none;
  color: white;
  border-radius: 16px;
  cursor: pointer;
  font-size: 18px;
  font-weight: 900;
  letter-spacing: 1px;
  animation: attackBtnShimmer 3s linear infinite;
  transition: transform .1s;
}
@keyframes attackBtnShimmer {
  0% { background-position: 0% 0; }
  100% { background-position: 300% 0; }
}
.dg-attack-btn:active { transform: scale(.96); }
.dg-dead-msg { font-size: 14px; color: #6b7a99; padding: 16px; text-align: center; }

/* ── Buff Select ── */
.dg-buff-select { text-align: center; }
.dg-buff-title { font-size: 20px; font-weight: 700; color: #a78bfa; margin-bottom: 6px; }
.dg-buff-sub { font-size: 13px; color: #94a3b8; margin-bottom: 20px; }
.dg-buff-cards { display: flex; gap: 10px; margin-bottom: 20px; }
.dg-buff-card {
  flex: 1;
  padding: 16px 8px;
  background: rgba(109,40,217,.12);
  border: 1px solid rgba(139,92,246,.35);
  border-radius: 16px;
  cursor: pointer;
  transition: all .2s;
  text-align: center;
}
.dg-buff-card:hover {
  background: rgba(109,40,217,.28);
  border-color: rgba(139,92,246,.75);
  transform: translateY(-3px);
}
.dg-buff-icon { font-size: 28px; display: block; margin-bottom: 8px; }
.dg-buff-name { font-size: 12px; font-weight: 700; color: #e2e8f0; margin-bottom: 4px; }
.dg-buff-desc { font-size: 10px; color: #94a3b8; line-height: 1.3; }

/* ── Complete / Failed ── */
.dg-complete, .dg-failed { text-align: center; padding: 10px 0; }
.dg-complete-icon, .dg-failed-icon { font-size: 64px; display: block; margin-bottom: 12px; line-height: 1; }
.dg-complete-title { font-size: 24px; font-weight: 800; color: #facc15; margin-bottom: 4px; }
.dg-failed-title { font-size: 24px; font-weight: 800; color: #ef4444; margin-bottom: 4px; }
.dg-complete-sub, .dg-failed-sub { font-size: 14px; color: #94a3b8; margin-bottom: 20px; }
.dg-rewards {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 24px;
  padding: 14px;
  background: rgba(250,204,21,.06);
  border: 1px solid rgba(250,204,21,.15);
  border-radius: 14px;
  text-align: left;
}
.dg-reward-row { font-size: 14px; color: #e2e8f0; }
.dg-exit-btn {
  width: 100%;
  padding: 16px;
  background: linear-gradient(135deg,#4f46e5,#7c3aed);
  border: none;
  color: white;
  border-radius: 14px;
  cursor: pointer;
  font-weight: 800;
  font-size: 15px;
  transition: opacity .2s;
}
.dg-exit-btn:hover { opacity: .85; }


/* ══════════════════════════════════════
   JOURNAL / DAILY QUESTS
══════════════════════════════════════ */

.journal-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 6px;
}

.streak-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 14px;
  background: rgba(251, 191, 36, .08);
  border: 1px solid rgba(251, 191, 36, .2);
  border-radius: 14px;
}
.streak-fire { font-size: 20px; }
.streak-text { font-weight: 800; font-size: 15px; color: #fbbf24; }
.streak-sub  { font-size: 11px; color: rgba(255,255,255,.4); margin-left: 2px; }

.quest-card {
  background: rgba(15,23,42,.7);
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 14px;
  padding: 12px 14px;
  transition: border-color .2s;
}
.quest-card.quest-complete {
  border-color: rgba(34,197,94,.35);
  background: rgba(34,197,94,.06);
}

.quest-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}
.quest-icon { font-size: 22px; flex-shrink: 0; }
.quest-info { flex: 1; min-width: 0; }
.quest-label { font-weight: 800; font-size: 14px; color: #e2e8f0; }
.quest-desc  { font-size: 12px; color: rgba(255,255,255,.5); margin-top: 1px; }
.quest-count { font-size: 13px; font-weight: 700; color: #94a3b8; flex-shrink: 0; }
.quest-card.quest-complete .quest-count { color: #4ade80; }

.quest-bar {
  height: 6px;
  background: rgba(255,255,255,.08);
  border-radius: 99px;
  overflow: hidden;
}
.quest-fill {
  height: 100%;
  background: linear-gradient(90deg, #6366f1, #8b5cf6);
  border-radius: 99px;
  transition: width .4s ease;
}
.quest-card.quest-complete .quest-fill {
  background: linear-gradient(90deg, #22c55e, #4ade80);
}

.chest-btn {
  width: 100%;
  padding: 14px;
  background: linear-gradient(135deg, #f59e0b, #d97706);
  border: none;
  color: #1c1400;
  font-weight: 900;
  font-size: 15px;
  border-radius: 14px;
  cursor: pointer;
  animation: chestPulse 1.6s ease-in-out infinite;
}
@keyframes chestPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(245,158,11,.4); }
  50%       { box-shadow: 0 0 0 8px rgba(245,158,11,0); }
}
.chest-btn:hover { opacity: .9; }

.chest-claimed {
  text-align: center;
  padding: 14px;
  background: rgba(34,197,94,.08);
  border: 1px solid rgba(34,197,94,.2);
  border-radius: 14px;
  font-size: 14px;
  color: #4ade80;
  font-weight: 600;
}

.chest-locked {
  text-align: center;
  padding: 12px;
  background: rgba(255,255,255,.03);
  border: 1px dashed rgba(255,255,255,.12);
  border-radius: 14px;
  font-size: 13px;
  color: rgba(255,255,255,.4);
}

.journal-divider {
  text-align: center;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: rgba(255,255,255,.3);
  margin: 8px 0 4px;
  position: relative;
}
.journal-divider::before,
.journal-divider::after {
  content: '';
  position: absolute;
  top: 50%;
  width: 30%;
  height: 1px;
  background: rgba(255,255,255,.1);
}
.journal-divider::before { left: 0; }
.journal-divider::after  { right: 0; }


/* ══════════════════════════════════════
   DUNGEON INVITE CARD (floating)
══════════════════════════════════════ */
#dungeonInviteCard {
  position: fixed;
  bottom: 72px;
  left: 12px;
  right: 12px;
  background: linear-gradient(135deg, rgba(15,23,42,.97) 0%, rgba(30,27,75,.97) 100%);
  border: 1px solid rgba(139,92,246,.55);
  border-radius: 20px;
  padding: 16px;
  z-index: 800;
  box-shadow: 0 8px 32px rgba(0,0,0,.7), 0 0 0 1px rgba(139,92,246,.15);
  animation: inviteSlideUp .28s cubic-bezier(.22,.61,.36,1) both;
}
@keyframes inviteSlideUp {
  from { transform: translateY(24px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}
.dinv-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 13px;
}
.dinv-icon { font-size: 34px; flex-shrink: 0; }
.dinv-info { flex: 1; min-width: 0; }
.dinv-from { font-size: 14px; color: #e2e8f0; line-height: 1.3; }
.dinv-dungeon { font-size: 12px; color: rgba(255,255,255,.45); margin-top: 2px; }
.dinv-countdown {
  font-size: 13px;
  font-weight: 700;
  color: #94a3b8;
  flex-shrink: 0;
  min-width: 28px;
  text-align: right;
}
.dinv-actions { display: flex; gap: 10px; }
.dinv-accept {
  flex: 1;
  padding: 13px;
  background: linear-gradient(135deg, #16a34a, #15803d);
  color: white;
  font-weight: 900;
  font-size: 15px;
  border: none;
  border-radius: 13px;
  cursor: pointer;
  transition: opacity .15s;
}
.dinv-reject {
  flex: 1;
  padding: 13px;
  background: linear-gradient(135deg, #dc2626, #b91c1c);
  color: white;
  font-weight: 900;
  font-size: 15px;
  border: none;
  border-radius: 13px;
  cursor: pointer;
  transition: opacity .15s;
}
.dinv-accept:hover { opacity: .85; }
.dinv-reject:hover { opacity: .85; }

/* ── Invite list inside waiting room ── */
.dg-invite-section {
  margin-top: 12px;
  border-top: 1px solid rgba(255,255,255,.07);
  padding-top: 12px;
}
.dg-invite-title {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: rgba(255,255,255,.35);
  margin-bottom: 8px;
}
.dg-invite-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 0;
  border-bottom: 1px solid rgba(255,255,255,.05);
}
.dg-invite-row:last-child { border-bottom: none; }
.dg-invite-name { font-size: 14px; color: #e2e8f0; }
.dg-invite-btn {
  padding: 6px 14px;
  background: linear-gradient(135deg, #4f46e5, #7c3aed);
  color: white;
  font-weight: 700;
  font-size: 13px;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  transition: opacity .15s;
}
.dg-invite-btn:hover { opacity: .85; }
.dg-invite-sent {
  background: rgba(255,255,255,.08) !important;
  color: #4ade80 !important;
  cursor: default !important;
}

/* ── Toast Notifications ── */
#toastContainer {
  position: fixed;
  bottom: calc(72px + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  z-index: 8500;
  display: flex;
  flex-direction: column-reverse;
  align-items: center;
  gap: 6px;
  pointer-events: none;
  width: 92%;
  max-width: 360px;
}
.toast {
  background: rgba(15,23,42,0.96);
  border: 1px solid rgba(255,255,255,0.12);
  color: #e2e8f0;
  padding: 10px 18px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 600;
  text-align: center;
  backdrop-filter: blur(10px);
  animation: toastIn .22s ease, toastOut .3s ease 2.8s forwards;
  width: 100%;
}
.toast-error   { border-color: rgba(239,68,68,.45);  color: #fca5a5; }
.toast-success { border-color: rgba(34,197,94,.45);  color: #86efac; }
.toast-info    { border-color: rgba(99,102,241,.45); color: #a5b4fc; }
@keyframes toastIn  { from { opacity:0; transform:translateY(10px); } to { opacity:1; transform:translateY(0); } }
@keyframes toastOut { from { opacity:1; } to { opacity:0; } }

/* ── First Steps Card ── */
.fs-card { padding: 14px 16px !important; }
.fs-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 0;
  border-bottom: 1px solid rgba(255,255,255,.06);
  font-size: 14px;
  color: #e2e8f0;
}
.fs-row:last-child { border-bottom: none; }
.fs-done { opacity: .45; text-decoration: line-through; color: #64748b; }
.fs-icon { font-size: 18px; width: 24px; text-align: center; flex-shrink: 0; }
.fs-text { flex: 1; }

/* ── Stat Points Badge ── */
.sp-badge {
  color: #facc15;
  font-weight: 800;
  font-size: 12px;
  animation: spPulse 1.4s ease-in-out infinite;
}
@keyframes spPulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.45; }
}
.hero-card.hero-has-points {
  border-color: rgba(250, 204, 21, 0.45);
  box-shadow: 0 6px 32px rgba(0,0,0,0.5), 0 0 18px rgba(250,204,21,0.12), inset 0 1px 0 rgba(250,204,21,0.1);
}
