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

body {
  font-family: "Segoe UI", system-ui, sans-serif;
  background: #1a1a2e url('../assets/bg_texture.png') repeat;
  color: #e0d6c8;
  height: 100vh;
  display: flex;
  justify-content: center;
  overflow: hidden;
}

.container {
  width: 75%;
  padding: 2rem 1.5rem 0;
  text-align: center;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

header {
  position: relative;
}

.header-banner {
  display: block;
  margin: 0 auto;
  width: 800px; max-width: 100%;
  image-rendering: pixelated;
}

h1 {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 2.5rem;
  color: #f0c040;
  text-shadow: 0 0 20px rgba(240, 192, 64, 0.3);
}

.stat-icon {
  width: 16px;
  height: 16px;
  vertical-align: -2px;
  image-rendering: pixelated;
}

.stat-icon-sm {
  width: 12px;
  height: 12px;
  vertical-align: -1px;
}

.tab-icon {
  width: 16px;
  height: 16px;
  vertical-align: -3px;
  image-rendering: pixelated;
}

.btn-icon {
  width: 20px;
  height: 20px;
  vertical-align: -4px;
  image-rendering: pixelated;
}

.building-icon {
  width: 36px;
  height: 36px;
  image-rendering: pixelated;
  flex-shrink: 0;
  align-self: center;
}

.unit-parade {
  display: flex;
  flex-wrap: wrap;
  width: 400px;
  flex-shrink: 0;
  align-content: center;
  margin-right: 1rem;
}

.unit-parade-icon {
  width: 28px;
  height: 28px;
  image-rendering: pixelated;
  opacity: 0.85;
  margin-right: -8px;
  margin-bottom: -6px;
  position: relative;
}

.unit-parade-overflow {
  font-size: 0.7rem;
  color: #8a7e6b;
  width: 100%;
  margin-top: 0.4rem;
  text-align: center;
}

.stats {
  display: flex;
  justify-content: center;
  gap: 2rem;
  margin: 2rem 0 1.5rem;
}

main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.stat {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.stat-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #8a7e6b;
}

.stat-value {
  font-size: 1.5rem;
  font-weight: bold;
  color: #f0c040;
}

.xp-bar-container {
  position: relative;
  width: 100%;
  height: 1.5rem;
  background: #2a2a3e;
  border-radius: 0.75rem;
  overflow: hidden;
  margin-bottom: 2rem;
  border: 1px solid #3a3a4e;
}

.xp-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #5a3e8a, #8a5ec0);
  border-radius: 0.75rem;
  transition: width 0.3s ease;
}

.xp-text {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  color: #e0d6c8;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

.action-btn {
  position: relative;
  overflow: visible;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.25rem;
  padding: 1rem 2.5rem;
  background: linear-gradient(180deg, #c8902a, #a06820);
  color: #fff;
  border: 2px solid #d4a040;
  border-radius: 0.5rem;
  cursor: pointer;
  transition: transform 0.1s, box-shadow 0.1s;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.action-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.5);
}

.action-btn:active {
  transform: translateY(1px);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
}

.stat-sub {
  font-size: 0.7rem;
  color: #8a7e6b;
}

.rebirth-bar-container {
  margin: 1rem auto 0;
  max-width: 28rem;
  width: 100%;
}

.rebirth-bar {
  position: relative;
  height: 2.5rem;
  background: #1a1028;
  border-radius: 0.5rem;
  overflow: hidden;
  border: 2px solid #5a3080;
  cursor: pointer;
  transition: transform 0.1s, box-shadow 0.1s;
  box-shadow: 0 4px 12px rgba(120, 60, 180, 0.3);
}

.rebirth-bar.disabled {
  cursor: default;
  opacity: 0.6;
  border-color: #3a2050;
  box-shadow: 0 2px 6px rgba(120, 60, 180, 0.15);
}

.rebirth-bar.disabled .rebirth-bar-shimmer {
  animation: none;
}

.rebirth-bar:not(.disabled):hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(120, 60, 180, 0.5);
}

.rebirth-bar:not(.disabled):active {
  transform: translateY(1px);
}

.rebirth-bar-fill {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  background: linear-gradient(90deg, #5a2080, #7a3ea0, #9050c0);
  border-radius: 0.375rem;
  transition: width 0.4s ease;
  min-width: 0;
}

.rebirth-bar-shimmer {
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.12), transparent);
  animation: rebirth-shimmer 3s ease-in-out infinite;
  pointer-events: none;
}

@keyframes rebirth-shimmer {
  0% { left: -100%; }
  100% { left: 100%; }
}

.rebirth-bar.ready {
  border-color: #a060d0;
  animation: rebirth-glow 2s ease-in-out infinite;
}

@keyframes rebirth-glow {
  0%, 100% { box-shadow: 0 4px 12px rgba(120, 60, 180, 0.4); }
  50% { box-shadow: 0 4px 20px rgba(160, 96, 208, 0.7), 0 0 30px rgba(120, 60, 180, 0.3); }
}

.rebirth-bar-text {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 0.9rem;
  color: #f0d0ff;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
  pointer-events: none;
  z-index: 1;
}

.shop-section {
  margin-top: 1.5rem;
  text-align: left;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.tab-strip {
  display: flex;
  align-items: flex-end;
  gap: 0;
  margin-bottom: 0;
  border-bottom: 2px solid #3a3a4e;
  flex-shrink: 0;
}

.tab-btn {
  background: #1a1a2e;
  color: #8a7e6b;
  border: none;
  border-bottom: 2px solid #3a3a4e;
  padding: 0.5rem 1.25rem;
  cursor: pointer;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1rem;
  margin-bottom: -2px;
  border-radius: 0.375rem 0.375rem 0 0;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}

.tab-btn:hover {
  color: #e0d6c8;
  background: #22223a;
}

.tab-btn.active {
  color: #f0c040;
  font-weight: bold;
  background: #22223a;
  border: 2px solid #3a3a4e;
  border-bottom-color: #22223a;
  margin-bottom: -2px;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
  flex: 1;
  overflow-y: auto;
  padding: 1rem 0.75rem 1rem 0.75rem;
  min-height: 0;
  background: #22223a;
  border: 2px solid #3a3a4e;
  border-top: none;
  border-radius: 0 0 0.5rem 0.5rem;
}

.soul-shop-header {
  text-align: center;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.1rem;
  color: #c0a0e0;
  margin-bottom: 0.75rem;
}

.gem-count {
  color: #d080ff;
  font-weight: bold;
}

.soul-buy {
  background: linear-gradient(180deg, #7a3ea0, #5a2080) !important;
  border-color: #a060d0 !important;
  color: #f0d0ff !important;
}

.soul-buy:hover:not(:disabled) {
  transform: translateY(-1px);
}

.soul-buy:disabled,
.soul-buy.disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.soul-effect-current {
  display: block;
  font-size: 0.8em;
  color: #a8d8a8;
  font-style: italic;
  margin-top: 2px;
}

.auto-buy-toggle {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-right: 12px;
  font-size: 0.85em;
  color: #c8a8e8;
  cursor: pointer;
}

.qty-selector {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-left: auto;
  padding-bottom: 0.35rem;
}

.qty-label {
  font-size: 0.75rem;
  color: #8a7e6b;
  margin-right: 0.15rem;
}

.qty-selector button {
  background: #2a2a3e;
  color: #8a7e6b;
  border: 1px solid #3a3a4e;
  border-radius: 0.25rem;
  padding: 0.25rem 0.75rem;
  cursor: pointer;
  font-size: 0.8rem;
  transition: background 0.15s, color 0.15s;
}

.qty-selector button.active,
.qty-selector button:hover {
  background: #3a3a5e;
  color: #f0c040;
  border-color: #f0c040;
}

.building-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  background: #22223a;
  border: 1px solid #3a3a4e;
  border-radius: 0.5rem;
  padding: 0.75rem 1rem;
  margin-bottom: 0.5rem;
  transition: opacity 0.2s;
}

.building-row.locked {
  opacity: 0.4;
}

.building-info {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  flex: 0 1 auto;
}

.building-actions {
  display: flex;
  align-items: center;
  margin-left: auto;
  flex-shrink: 0;
}

.building-name {
  font-weight: bold;
  color: #e0d6c8;
  font-size: 0.95rem;
}

.building-name small {
  color: #8a7e6b;
  font-weight: normal;
}

.building-desc {
  font-size: 0.7rem;
  color: #6a6a7e;
}

.building-production {
  font-size: 0.7rem;
  color: #5a8a5a;
}

.buy-btn {
  background: linear-gradient(180deg, #c8902a, #a06820);
  color: #fff;
  border: 1px solid #d4a040;
  border-radius: 0.375rem;
  padding: 0.5rem 1rem;
  cursor: pointer;
  font-size: 0.85rem;
  font-family: Georgia, "Times New Roman", serif;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.1rem;
  transition: transform 0.1s, opacity 0.15s;
  min-width: 5.5rem;
}

.buy-btn:hover:not(:disabled) {
  transform: translateY(-1px);
}

.buy-btn:disabled,
.buy-btn.disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.buy-btn small {
  font-size: 0.65rem;
  font-family: "Segoe UI", system-ui, sans-serif;
  opacity: 0.8;
}

.tab-panel.active::-webkit-scrollbar {
  width: 6px;
}

.tab-panel.active::-webkit-scrollbar-track {
  background: transparent;
}

.tab-panel.active::-webkit-scrollbar-thumb {
  background: #3a3a4e;
  border-radius: 3px;
}

.tab-panel.active::-webkit-scrollbar-thumb:hover {
  background: #5a5a7e;
}

.settings-section {
  margin-top: 0.75rem;
  text-align: center;
  flex-shrink: 0;
}

.settings-toggle {
  background: #2a2a3e;
  color: #8a7e6b;
  border: 1px solid #3a3a4e;
  border-radius: 0.375rem;
  padding: 0.5rem 1.5rem;
  cursor: pointer;
  font-size: 0.85rem;
  transition: background 0.15s, color 0.15s;
}

.settings-toggle:hover {
  background: #3a3a5e;
  color: #f0c040;
  border-color: #f0c040;
}

.settings-panel {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease, margin 0.3s ease;
  margin-top: 0;
}

.settings-panel.open {
  max-height: 20rem;
  margin-top: 0.75rem;
}

.settings-buttons {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.settings-btn {
  background: #2a2a3e;
  color: #e0d6c8;
  border: 1px solid #3a3a4e;
  border-radius: 0.375rem;
  padding: 0.4rem 1rem;
  cursor: pointer;
  font-size: 0.8rem;
  transition: background 0.15s, color 0.15s;
}

.settings-btn:hover {
  background: #3a3a5e;
  color: #f0c040;
  border-color: #f0c040;
}

.settings-btn.danger {
  border-color: #6a2a2a;
  color: #d44;
}

.settings-btn.danger:hover {
  background: #4a1a1a;
  border-color: #d44;
}

.import-export-area {
  width: 100%;
  height: 3.5rem;
  background: #1a1a2e;
  color: #e0d6c8;
  border: 1px solid #3a3a4e;
  border-radius: 0.375rem;
  padding: 0.5rem;
  font-size: 0.75rem;
  font-family: monospace;
  resize: none;
}

.offline-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  background: linear-gradient(90deg, #2a5a2a, #3a7a3a);
  color: #e0f0c8;
  text-align: center;
  padding: 0.75rem 1rem;
  font-size: 0.9rem;
  transform: translateY(-100%);
  transition: transform 0.3s ease;
  cursor: pointer;
  z-index: 100;
}

.offline-banner.visible {
  transform: translateY(0);
}

footer {
  margin-top: 0.5rem;
  padding-bottom: 0.5rem;
  font-size: 0.85rem;
  color: #5a5a6e;
  flex-shrink: 0;
}

/* ── Settings options ── */

.settings-options {
  margin-bottom: 0.75rem;
}

.settings-option {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.4rem 0;
}

.settings-option-label {
  font-size: 0.8rem;
  color: #e0d6c8;
}

.settings-select {
  background: #2a2a3e;
  color: #e0d6c8;
  border: 1px solid #3a3a4e;
  border-radius: 0.25rem;
  padding: 0.3rem 0.5rem;
  font-size: 0.75rem;
  cursor: pointer;
}

.settings-select:hover {
  border-color: #f0c040;
}

/* ── Achievements ── */

.achievement-columns {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
}

.achievement-category {
  margin-bottom: 0;
}

.achievement-category-title {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 0.9rem;
  color: #f0c040;
  margin-bottom: 0.4rem;
  text-transform: capitalize;
  border-bottom: 1px solid #3a3a4e;
  padding-bottom: 0.25rem;
}

.achievement-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0.25rem 0;
}

.achievement-icon {
  position: relative;
  width: 40px;
  height: 40px;
  border-radius: 4px;
  border: 2px solid #3a3a4e;
  background: #1a1a2e;
  cursor: pointer;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.achievement-icon img {
  width: 100%;
  height: 100%;
  display: block;
  image-rendering: pixelated;
}

.achievement-icon.locked img {
  opacity: 0.3;
  filter: grayscale(1) brightness(0.5);
}

.achievement-icon.unlocked {
  border-color: #5a8a3a;
  box-shadow: 0 0 6px rgba(90, 138, 58, 0.3);
}

.achievement-icon.newly-unlocked {
  animation: achievement-shimmer 1.5s ease-out;
}

@keyframes achievement-shimmer {
  0% { box-shadow: 0 0 12px rgba(160, 216, 112, 0.8), 0 0 24px rgba(160, 216, 112, 0.4); }
  100% { box-shadow: 0 0 6px rgba(90, 138, 58, 0.3); }
}

.tooltip-wrap .tooltip.achievement-tooltip {
  white-space: normal;
  min-width: 120px;
  max-width: 200px;
  text-align: center;
  line-height: 1.4;
  word-wrap: break-word;
}

.achievement-bonus {
  color: #a0d870;
  font-style: italic;
}

.achievement-counter {
  text-align: center;
  font-size: 0.8rem;
  color: #8a7e6b;
  margin-bottom: 0.75rem;
}

/* ── Statistics ── */

.stats-table {
  width: 100%;
}

.stats-table-row {
  display: flex;
  justify-content: space-between;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid #2a2a3e;
}

.stats-table-row:last-child {
  border-bottom: none;
}

.stats-label {
  font-size: 0.8rem;
  color: #8a7e6b;
}

.stats-value {
  font-size: 0.8rem;
  color: #e0d6c8;
  font-weight: bold;
}

.stats-section-title {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 0.9rem;
  color: #f0c040;
  margin: 0.75rem 0 0.35rem;
}

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

/* ── Achievement toast ── */

.achievement-toast {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: linear-gradient(90deg, #2a4a2a, #3a6a3a);
  border: 1px solid #5a8a3a;
  color: #e0f0c8;
  padding: 0.75rem 1.5rem;
  border-radius: 0.5rem;
  font-size: 0.85rem;
  z-index: 500;
  pointer-events: none;
  opacity: 0;
  animation: toast-in 3s ease forwards;
  text-align: center;
}

.achievement-toast strong {
  color: #f0c040;
}

@keyframes toast-in {
  0% { opacity: 0; transform: translateX(-50%) translateY(100px); }
  10% { opacity: 1; transform: translateX(-50%) translateY(0); }
  80% { opacity: 1; transform: translateX(-50%) translateY(0); }
  100% { opacity: 0; transform: translateX(-50%) translateY(-20px); }
}

/* ── Floating click numbers ── */

.click-float {
  position: absolute;
  pointer-events: none;
  font-weight: bold;
  font-size: 1.1rem;
  color: #f0c040;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.6);
  animation: float-up 0.9s ease-out forwards;
  z-index: 200;
  white-space: nowrap;
}

.float-gold-icon {
  width: 14px;
  height: 14px;
  vertical-align: -2px;
  image-rendering: pixelated;
}

@keyframes float-up {
  0% { opacity: 1; transform: translateY(0) scale(1); }
  100% { opacity: 0; transform: translateY(-60px) scale(0.7); }
}

/* ── Purchase flash ── */

.building-row.flash {
  animation: purchase-flash 0.35s ease-out;
}

@keyframes purchase-flash {
  0% { background: #3a4a2a; }
  100% { background: #22223a; }
}

/* ── Level-up celebration ── */

.level-up-burst {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 300;
  animation: burst-fade 1s ease-out forwards;
}

.level-up-burst::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 50% 50%, rgba(138, 94, 192, 0.35), transparent 70%);
}

.level-up-text {
  position: fixed;
  top: 35%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 2rem;
  color: #d0a0ff;
  text-shadow: 0 0 20px rgba(160, 96, 208, 0.6);
  pointer-events: none;
  z-index: 301;
  animation: level-text 1s ease-out forwards;
}

@keyframes burst-fade {
  0% { opacity: 1; }
  100% { opacity: 0; }
}

@keyframes level-text {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.5); }
  20% { opacity: 1; transform: translate(-50%, -50%) scale(1.15); }
  40% { transform: translate(-50%, -50%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -60%) scale(1); }
}

/* ── Tooltips ── */

.tooltip-wrap {
  position: relative;
}

.tooltip-wrap .tooltip {
  display: none;
  position: fixed;
  background: #1a1a2e;
  border: 1px solid #5a5a7e;
  border-radius: 0.375rem;
  padding: 0.5rem 0.75rem;
  font-size: 0.75rem;
  color: #e0d6c8;
  white-space: nowrap;
  z-index: 400;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
  pointer-events: none;
}

.tooltip-wrap .tooltip.tooltip-visible {
  display: block;
}

/* ── Mobile responsive ── */

@media (max-width: 600px) {
  body {
    align-items: flex-start;
  }

  .container {
    padding: 1.5rem 1rem;
  }

  h1 {
    font-size: 1.75rem;
  }

  .stats {
    flex-wrap: wrap;
    gap: 1rem;
  }

  .action-btn {
    font-size: 1.1rem;
    padding: 0.9rem 2rem;
    min-height: 3rem;
    width: 100%;
  }

  .rebirth-bar-container {
    max-width: 100%;
  }

  .building-row {
    flex-direction: column;
    align-items: stretch;
    gap: 0.5rem;
  }

  .building-actions {
    display: flex;
  }

  .buy-btn {
    width: 100%;
    min-height: 2.75rem;
    font-size: 0.95rem;
  }

  .qty-selector button {
    padding: 0.4rem 1rem;
    font-size: 0.9rem;
    min-height: 2.5rem;
  }

  .settings-buttons {
    flex-wrap: wrap;
  }

  .settings-btn {
    min-height: 2.5rem;
    flex: 1 1 40%;
  }

  .container {
    width: 100%;
  }

  .tab-strip {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    flex-wrap: nowrap;
  }

  .tab-strip::-webkit-scrollbar {
    display: none;
  }

  .tab-btn {
    padding: 0.5rem 0.75rem;
    font-size: 0.8rem;
    white-space: nowrap;
    flex-shrink: 0;
  }

  .achievement-icon {
    width: 36px;
    height: 36px;
  }


}

@media (max-width: 360px) {
  .stats {
    gap: 0.5rem;
  }

  .stat-value {
    font-size: 1.2rem;
  }
}

/* Milestone badges */
.milestone-badges {
  display: flex;
  gap: 0.3rem;
  margin-top: 0.35rem;
  flex-wrap: wrap;
}

.milestone-badge {
  display: inline-block;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 0.15rem 0.4rem;
  border-radius: 0.25rem;
  border: 1px solid;
  cursor: default;
  position: relative;
}

.milestone-badge.locked {
  border-color: #3a3a4e;
  color: #555;
  background: transparent;
}

.milestone-badge.available {
  border-color: #f0c040;
  color: #f0c040;
  background: rgba(240, 192, 64, 0.1);
  cursor: pointer;
  animation: milestone-glow 2s ease-in-out infinite;
}

.milestone-badge.purchased {
  border-color: #4a9;
  color: #1a1a2e;
  background: #4a9;
}

@keyframes milestone-glow {
  0%, 100% { box-shadow: 0 0 4px rgba(240, 192, 64, 0.3); }
  50% { box-shadow: 0 0 10px rgba(240, 192, 64, 0.6); }
}

.milestone-tip {
  white-space: nowrap;
}

.settings-option label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  cursor: pointer;
}

.settings-option input[type="checkbox"] {
  accent-color: #f0c040;
}

/* ── Crystals ── */

.crystal-value {
  color: #40d0f0 !important;
}

/* ── Quest Tracker ── */

.quest-tracker {
  background: #2a2a4e;
  border: 1px solid #5a5aaa;
  border-radius: 0.5rem;
  padding: 0.75rem 1rem;
  margin: 1rem 0;
  text-align: center;
  flex-shrink: 0;
}

.quest-tracker-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.4rem;
}

.quest-tracker-title {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1rem;
  color: #40d0f0;
}

.quest-tracker-abandon {
  background: #4a1a1a;
  color: #d44;
  border: 1px solid #6a2a2a;
  border-radius: 0.25rem;
  padding: 0.2rem 0.6rem;
  cursor: pointer;
  font-size: 0.7rem;
  transition: background 0.15s;
}

.quest-tracker-abandon:hover {
  background: #5a2a2a;
}

/* ── Quests ── */

.quest-debuff {
  font-size: 0.8rem;
  color: #d44;
  margin-bottom: 0.5rem;
}

.quest-progress-bar {
  position: relative;
  width: 100%;
  height: 1.25rem;
  background: #1a1a2e;
  border-radius: 0.5rem;
  overflow: hidden;
  border: 1px solid #3a3a4e;
  margin-bottom: 0.25rem;
}

.quest-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #2a8a9a, #40d0f0);
  border-radius: 0.375rem;
  transition: width 0.4s ease;
}

.quest-progress-text {
  font-size: 0.75rem;
  color: #e0d6c8;
  margin-bottom: 0.25rem;
}

.quest-timer {
  font-size: 0.75rem;
  color: #f0c040;
}

.quest-warning {
  font-size: 0.75rem;
  color: #d44;
  font-style: italic;
}


.quest-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.quest-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #22223a;
  border: 1px solid #3a3a4e;
  border-radius: 0.5rem;
  padding: 0.75rem 1rem;
}

.quest-card.active {
  border-color: #40d0f0;
}

.quest-card.maxed {
  opacity: 0.4;
}

.quest-info {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.quest-name {
  font-weight: bold;
  font-size: 0.95rem;
  color: #e0d6c8;
}

.quest-name small {
  color: #8a7e6b;
  font-weight: normal;
}

.quest-desc {
  font-size: 0.7rem;
  color: #6a6a7e;
}

.quest-req {
  font-size: 0.7rem;
  color: #8a7e6b;
}

.quest-reward {
  font-size: 0.7rem;
  color: #40d0f0;
}

.quest-btn {
  background: linear-gradient(180deg, #2a8a9a, #1a6a7a);
  color: #fff;
  border: 1px solid #40d0f0;
  border-radius: 0.375rem;
  padding: 0.5rem 1rem;
  cursor: pointer;
  font-size: 0.85rem;
  font-family: Georgia, "Times New Roman", serif;
  min-width: 5.5rem;
  transition: transform 0.1s;
}

.quest-btn:hover:not(:disabled) {
  transform: translateY(-1px);
}

.quest-btn:disabled,
.quest-btn.disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ── Crystal Shop ── */

.crystal-shop-header {
  text-align: center;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.1rem;
  color: #80e0f0;
  margin-bottom: 0.75rem;
}

.crystal-count {
  color: #40d0f0;
  font-weight: bold;
}

.crystal-shop-empty {
  text-align: center;
  color: #6a6a7e;
  font-size: 0.85rem;
  padding: 2rem 1rem;
  font-style: italic;
}

.crystal-section {
  margin-bottom: 1rem;
}

.crystal-section-title {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 0.95rem;
  color: #80e0f0;
  cursor: pointer;
  padding: 0.4rem 0.6rem;
  background: rgba(64, 208, 240, 0.08);
  border-radius: 4px;
  margin-bottom: 0.4rem;
  user-select: none;
}

.crystal-section-title:hover {
  background: rgba(64, 208, 240, 0.15);
}

.crystal-buy-cap,
.crystal-buy-upgrade,
.crystal-buy-mutation {
  background: linear-gradient(180deg, #1a6a7a, #0e4a5a) !important;
  border-color: #40d0f0 !important;
  color: #c0f0ff !important;
}

/* ── Confirm Modal ── */

.confirm-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  z-index: 1000;
  justify-content: center;
  align-items: center;
  animation: confirm-fade-in 0.15s ease;
}

.confirm-overlay.visible {
  display: flex;
}

.confirm-dialog {
  background: #22223a;
  border: 2px solid #5a5a7e;
  border-radius: 0.75rem;
  padding: 1.5rem 2rem;
  max-width: 28rem;
  width: 90%;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6);
  animation: confirm-slide-in 0.15s ease;
}

.confirm-message {
  font-size: 0.9rem;
  color: #e0d6c8;
  line-height: 1.5;
  margin-bottom: 1.25rem;
  white-space: pre-line;
}

.confirm-buttons {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

.confirm-btn {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 0.9rem;
  padding: 0.5rem 1.25rem;
  border-radius: 0.375rem;
  cursor: pointer;
  transition: transform 0.1s, box-shadow 0.1s;
  border: 1px solid;
}

.confirm-yes {
  background: linear-gradient(180deg, #c8902a, #a06820);
  color: #fff;
  border-color: #d4a040;
}

.confirm-yes:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.confirm-yes:active {
  transform: translateY(1px);
}

.confirm-no {
  background: #3a3a5e;
  color: #e0d6c8;
  border-color: #5a5a7e;
}

.confirm-no:hover {
  color: #e0d6c8;
  border-color: #5a5a7e;
}

.confirm-no:active {
  transform: translateY(1px);
}

@keyframes confirm-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes confirm-slide-in {
  from { transform: translateY(-10px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* ── Button active states ── */

.buy-btn:active:not(:disabled) {
  transform: translateY(1px);
  opacity: 0.85;
}

.quest-btn:active:not(:disabled) {
  transform: translateY(1px);
}

.soul-buy:active:not(:disabled) {
  transform: translateY(1px);
}

.crystal-buy-cap:hover:not(:disabled),
.crystal-buy-upgrade:hover:not(:disabled),
.crystal-buy-mutation:hover:not(:disabled) {
  background: linear-gradient(180deg, #20808a, #145a6a) !important;
}

.crystal-buy-cap:active:not(:disabled),
.crystal-buy-upgrade:active:not(:disabled),
.crystal-buy-mutation:active:not(:disabled) {
  transform: translateY(1px);
  opacity: 0.85;
}

/* ── Stat counter pop ── */

.stat-value.pop {
  animation: stat-pop 0.3s ease-out;
}

@keyframes stat-pop {
  0% { transform: scale(1); }
  40% { transform: scale(1.18); }
  100% { transform: scale(1); }
}

.gold-float {
  font-size: 0.85rem;
  transform: translateX(-50%);
}

/* ── Purchase flash (crystal shop) ── */

.crystal-buy-cap.flash,
.crystal-buy-upgrade.flash,
.crystal-buy-mutation.flash,
.soul-buy.flash {
  animation: purchase-flash 0.35s ease-out;
}

/* ── Rebirth transition ── */

.rebirth-overlay {
  position: fixed;
  inset: 0;
  z-index: 500;
  pointer-events: none;
  opacity: 0;
}

.rebirth-overlay.active {
  animation: rebirth-fade 1.4s ease-in-out forwards;
  background: radial-gradient(circle at 50% 40%, rgba(200, 160, 255, 0.6), rgba(255, 255, 255, 0.9) 60%, rgba(200, 160, 255, 0.4));
}

.rebirth-overlay.quest-start.active {
  background: radial-gradient(circle at 50% 40%, rgba(100, 180, 255, 0.6), rgba(255, 255, 255, 0.9) 60%, rgba(100, 180, 255, 0.4));
}

.rebirth-overlay.quest-start + .rebirth-splash {
  color: #80c0ff;
  text-shadow: 0 0 24px rgba(80, 140, 220, 0.7);
}

@keyframes rebirth-fade {
  0% { opacity: 0; }
  30% { opacity: 1; }
  60% { opacity: 1; }
  100% { opacity: 0; }
}

.rebirth-splash {
  position: fixed;
  top: 40%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 501;
  pointer-events: none;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 2.2rem;
  color: #d0a0ff;
  text-shadow: 0 0 24px rgba(160, 96, 208, 0.7);
  opacity: 0;
}

.rebirth-splash.active {
  animation: rebirth-splash-text 1.4s ease-in-out forwards;
}

/* Run history */
.run-history-table {
  margin-top: 0.5rem;
  font-size: 0.85em;
}

.run-history-header,
.run-history-row {
  display: grid;
  grid-template-columns: 2rem 4rem 3rem 5rem 1fr;
  gap: 0.25rem;
  padding: 0.25rem 0.5rem;
  align-items: center;
}

.run-history-header {
  color: #aaa;
  font-weight: bold;
  border-bottom: 1px solid #333;
}

.run-history-row:nth-child(even) {
  background: rgba(255, 255, 255, 0.03);
}

.run-bar-cell {
  position: relative;
  padding-left: 0.25rem;
}

.run-bar {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  background: rgba(255, 215, 0, 0.15);
  border-radius: 3px;
  z-index: 0;
}

.run-bar-cell > .run-bar ~ * {
  position: relative;
  z-index: 1;
}

/* Shortcuts overlay */
.shortcuts-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  z-index: 1001;
  justify-content: center;
  align-items: center;
}

.shortcuts-dialog {
  background: #22223a;
  border: 2px solid #5a5a7e;
  border-radius: 0.75rem;
  padding: 1.5rem 2rem;
  text-align: center;
  max-width: 320px;
}

.shortcuts-dialog h3 {
  margin: 0 0 1rem;
  color: #ffd700;
}

.shortcuts-table {
  width: 100%;
  text-align: left;
  margin-bottom: 1rem;
}

.shortcuts-table td {
  padding: 0.3rem 0.5rem;
}

.shortcuts-table kbd {
  background: #33334d;
  border: 1px solid #5a5a7e;
  border-radius: 4px;
  padding: 2px 6px;
  font-family: monospace;
  font-size: 0.9em;
  color: #ffd700;
}

.shortcuts-hint {
  margin-top: 0.5rem;
  font-size: 0.8em;
  color: #888;
  text-align: center;
}

.shortcuts-hint kbd {
  background: #33334d;
  border: 1px solid #5a5a7e;
  border-radius: 3px;
  padding: 1px 4px;
  font-family: monospace;
  color: #aaa;
}

@keyframes rebirth-splash-text {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.6); }
  25% { opacity: 1; transform: translate(-50%, -50%) scale(1.1); }
  40% { transform: translate(-50%, -50%) scale(1); }
  65% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -55%) scale(1); }
}
