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

body {
  background-color: #0e111a;
  color: #f7f9fa;
  font-family: 'Playwrite DE Grund', cursive, sans-serif;
  overflow: hidden;
  width: 100%;
  height: 100vh;  /* fallback for browsers without dvh */
  height: 100dvh; /* tracks the real visible viewport on mobile */
  user-select: none;
  -webkit-user-select: none;
}

/* Container for PixiJS */
#game-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
}

#canvas-container {
  width: 100%;
  height: 100%;
}

canvas {
  display: block;
}

.hud-layer {
  position: absolute;
  top: calc(20px + env(safe-area-inset-top, 0px));
  left: 50%;
  transform: translateX(-50%) scale(var(--ui-scale, 1));
  transform-origin: top center;
  width: 90%;
  max-width: 900px;
  height: auto;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  padding: 0;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  z-index: 10;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  overflow: hidden;
}

.hud-stats-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  padding: 12px 24px;
  /* Gaps keep items apart, and wrapping lets the bar grow taller (it is
     height:auto) instead of letting items overlap on short/narrow landscape
     windows with a high tap count + long upgrades label. */
  flex-wrap: wrap;
  gap: 8px 16px;
}

.hud-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex-shrink: 0;
}

.hud-item .label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #8f9ca6;
  margin-bottom: 2px;
}

.hud-item .value {
  font-size: 18px;
  font-weight: 700;
  color: #ffffff;
}

/* Progress Bar in HUD */
.progress-container {
  flex-grow: 1;
  max-width: 40%;
  margin: 0 20px;
  /* Allow the progress bar to shrink (and absorb tight space) before any
     sibling is forced to overlap or wrap. */
  flex-shrink: 1;
  min-width: 0;
}

.progress-info {
  display: flex;
  justify-content: space-between;
  width: 100%;
  margin-bottom: 4px;
}

.progress-bar-bg {
  width: 100%;
  height: 4px; /* Thin line progression track */
  background: rgba(255, 255, 255, 0.1);
  border-radius: 2px;
  overflow: hidden;
  position: relative;
  border: none;
}

.bar-fill {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  border-radius: 2px;
  width: 0%;
  transition: width 0.3s cubic-bezier(0.1, 0.8, 0.2, 1), opacity 0.3s ease;
}

.base-bar {
  background: linear-gradient(90deg, #a9def9, #d0f4de);
  z-index: 1;
}

.overfill-bar-1 {
  background: #ff99c8;
  z-index: 2;
  box-shadow: 0 0 8px rgba(255, 153, 200, 0.4);
}

.overfill-bar-2 {
  background: #e4c1f9;
  z-index: 3;
  box-shadow: 0 0 8px rgba(228, 193, 249, 0.4);
}

/* Taps Display in HUD */
#taps-indicators {
  display: flex;
  gap: 8px;
  margin-top: 4px;
  /* High starter-tap counts wrap onto a second row of dots rather than
     widening the bar into the upgrades pill. */
  flex-wrap: wrap;
  justify-content: center;
  max-width: 96px;
}

.tap-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: rgba(255, 255, 255, 0.2);
  border: none;
  transition: all 0.3s ease;
}

.tap-dot.active {
  background-color: #ff99c8;
  box-shadow: 0 0 8px #ff99c8, 0 0 16px rgba(255, 153, 200, 0.6);
}

/* Dots Button in HUD (a real <button> for keyboard/screen-reader access) */
.dots-display {
  flex-direction: row;
  gap: 8px;
  background: rgba(252, 246, 189, 0.05);
  border: 1px solid rgba(252, 246, 189, 0.4);
  border-radius: 0;
  padding: 6px 16px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: inherit;
  color: inherit;
}

.dots-display:hover {
  transform: translateY(-1px);
  background: rgba(252, 246, 189, 0.15);
  border-color: rgba(252, 246, 189, 0.8);
  box-shadow: 0 0 10px rgba(252, 246, 189, 0.3);
}

.dots-display .label-dots {
  font-size: 13px;
  font-weight: bold;
  color: #fcf6bd;
}

.hud-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.mastery-display {
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(169, 222, 249, 0.05);
  border: 1px solid rgba(169, 222, 249, 0.4);
  border-radius: 0;
  padding: 6px 12px;
  cursor: pointer;
  transition: all 0.2s ease;
  color: #a9def9;
  height: 100%;
}

.mastery-display:hover {
  transform: translateY(-1px);
  background: rgba(169, 222, 249, 0.15);
  border-color: rgba(169, 222, 249, 0.8);
  box-shadow: 0 0 10px rgba(169, 222, 249, 0.3);
}

.trophy-icon {
  display: block;
  stroke: #a9def9;
  filter: drop-shadow(0 0 4px rgba(169, 222, 249, 0.4));
}

.ad-icon {
  display: block;
  filter: drop-shadow(0 0 4px rgba(255, 153, 200, 0.4));
  flex-shrink: 0;
}

/* Overlay prompts */
.overlay-prompt {
  position: absolute;
  top: 55%;
  left: 50%;
  transform: translate(-50%, -50%) scale(var(--ui-scale, 1));
  transform-origin: center center;
  z-index: 11; /* above the HUD (10) so it is never obscured */
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  padding: 16px 32px;
  border-radius: 0;
  font-size: 15px;
  font-weight: bold;
  color: #a9def9;
  text-shadow: 0 0 8px rgba(169, 222, 249, 0.5);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  text-transform: uppercase;
  letter-spacing: 2px;
  border: none;
  animation: float-pulse-center 2s infinite ease-in-out;
  pointer-events: none;
  white-space: nowrap;
}

@keyframes float-pulse-center {
  0% { transform: translate(-50%, -50%) scale(var(--ui-scale, 1)); opacity: 0.85; }
  50% { transform: translate(-50%, -55%) scale(var(--ui-scale, 1)); opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(var(--ui-scale, 1)); opacity: 0.85; }
}

/* Modal and Screen Overlay System */
.screen-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: radial-gradient(circle at center, rgba(10, 12, 22, 0.2) 0%, rgba(5, 7, 12, 0.96) 100%);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 20;
  transition: opacity 0.3s ease;
  /* Keep modal content clear of notches and home indicators */
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  padding-left: env(safe-area-inset-left, 0px);
  padding-right: env(safe-area-inset-right, 0px);
}

.screen-card {
  background: transparent;
  border: none;
  box-shadow: none;
  padding: 24px 10px;
  max-width: 580px;
  width: 95%;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  transform: scale(var(--ui-scale, 1));
  transform-origin: center center;
  animation: screen-fade-in 0.5s cubic-bezier(0.25, 1, 0.5, 1) forwards;
}

@keyframes screen-fade-in {
  0% { opacity: 0; transform: translateY(20px) scale(var(--ui-scale, 1)); filter: blur(5px); }
  100% { opacity: 1; transform: translateY(0) scale(var(--ui-scale, 1)); filter: blur(0); }
}

.screen-title {
  font-size: 38px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  margin-bottom: 24px;
}

.text-success {
  color: #a9def9; /* Glow theme primary light blue */
  text-shadow: 0 0 12px rgba(169, 222, 249, 0.8), 0 0 30px rgba(169, 222, 249, 0.4), 0 0 60px rgba(169, 222, 249, 0.2);
}

.text-danger {
  color: #ff99c8; /* Glow theme light pink */
  text-shadow: 0 0 12px rgba(255, 153, 200, 0.8), 0 0 30px rgba(255, 153, 200, 0.4), 0 0 60px rgba(255, 153, 200, 0.2);
}

.screen-subtitle {
  font-size: 15px;
  color: #cbd5e1;
  margin-bottom: 32px;
  font-weight: 500;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

/* Reward Box (Level Complete) */
.reward-box {
  background: transparent;
  border: none;
  border-radius: 0;
  padding: 0;
  margin-bottom: 36px;
  display: flex;
  flex-direction: column;
  align-items: center;
  box-shadow: none;
}

.reward-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: #fcf6bd;
  opacity: 0.8;
  margin-bottom: 8px;
}

.reward-amount {
  font-size: 52px; /* Hero stat scaling */
  font-weight: 800;
  color: #ffffff;
  display: flex;
  align-items: center;
  gap: 8px;
  text-shadow: 0 0 15px rgba(252, 246, 189, 0.6), 0 0 40px rgba(252, 246, 189, 0.3);
}

.reward-amount-label {
  color: #fcf6bd;
  font-size: 16px;
  text-transform: uppercase;
  letter-spacing: 2px;
  font-weight: normal;
  margin-right: 6px;
}

.reward-bonus-label {
  font-size: 11px;
  color: #ff99c8;
  margin-top: 8px;
  font-weight: bold;
  letter-spacing: 0.5px;
  text-align: center;
  text-shadow: 0 0 8px rgba(255, 153, 200, 0.4);
}

/* Button Group layout */
.button-group {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  justify-content: center;
  align-items: stretch;
  gap: 16px;
  width: 100%;
}

/* Buttons */
.btn {
  font-family: 'Playwrite DE Grund', cursive, sans-serif;
  border-radius: 0;
  border: none;
  padding: 14px 24px;
  font-size: 14px;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
  outline: none;
  box-sizing: border-box;
  width: auto;
  min-width: 150px;
  flex: 1;
  max-width: 220px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  line-height: 1.3;
}

.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  background: rgba(169, 222, 249, 0.05);
  color: #a9def9;
  border: 1.5px solid rgba(169, 222, 249, 0.4);
  box-shadow: 0 0 12px rgba(169, 222, 249, 0.1);
  text-shadow: 0 0 8px rgba(169, 222, 249, 0.5);
}

.btn-primary:hover {
  background: rgba(169, 222, 249, 0.18);
  border-color: #a9def9;
  box-shadow: 0 0 22px rgba(169, 222, 249, 0.4);
  transform: translateY(-2px);
}

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

.btn-premium {
  background: linear-gradient(135deg, rgba(255, 153, 200, 0.15), rgba(228, 193, 249, 0.15));
  color: #ffffff;
  border: 1.5px solid #ff99c8;
  box-shadow: 0 0 12px rgba(255, 153, 200, 0.15);
  text-shadow: 0 0 8px rgba(255, 153, 200, 0.5);
  animation: button-premium-pulse 2s infinite ease-in-out;
}

@keyframes button-premium-pulse {
  0% { box-shadow: 0 0 10px rgba(255, 153, 200, 0.15); border-color: rgba(255, 153, 200, 0.7); }
  50% { box-shadow: 0 0 22px rgba(255, 153, 200, 0.4); border-color: rgba(255, 153, 200, 1); }
  100% { box-shadow: 0 0 10px rgba(255, 153, 200, 0.15); border-color: rgba(255, 153, 200, 0.7); }
}

.btn-premium:hover {
  transform: translateY(-2px);
  background: linear-gradient(135deg, rgba(255, 153, 200, 0.3), rgba(228, 193, 249, 0.3));
  box-shadow: 0 0 28px rgba(255, 153, 200, 0.5);
}

.btn-premium:active {
  transform: translateY(0) scale(0.97);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.02);
  border: 1.5px solid rgba(255, 255, 255, 0.15);
  color: #cbd5e1;
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.4);
  color: #ffffff;
  transform: translateY(-2px);
}

.btn-secondary:active {
  transform: translateY(0) scale(0.97);
}

/* Revive Box (Level Failed Screen) */
.revive-box {
  background: transparent;
  border: none;
  border-radius: 0;
  padding: 0;
  margin-bottom: 28px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  width: 100%;
  box-shadow: none;
}

.revive-prompt {
  font-size: 12px;
  font-weight: bold;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: #ff99c8;
  text-shadow: 0 0 8px rgba(255, 153, 200, 0.4);
}

.btn-emergency {
  background: rgba(255, 153, 200, 0.05);
  border: 1.5px solid rgba(255, 153, 200, 0.4);
  border-radius: 0;
  padding: 10px 24px;
  font-family: 'Playwrite DE Grund', cursive, sans-serif;
  color: #ff99c8;
  font-weight: bold;
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
  box-shadow: 0 0 12px rgba(255, 153, 200, 0.1);
  text-shadow: 0 0 8px rgba(255, 153, 200, 0.4);
}

.btn-emergency:hover {
  background: rgba(255, 153, 200, 0.15);
  border-color: #ff99c8;
  box-shadow: 0 0 20px rgba(255, 153, 200, 0.35);
  transform: translateY(-2px);
}

/* Timer Ring Animation */
#revive-timer-ring {
  position: relative;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.timer-svg {
  position: absolute;
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.timer-svg .circle-bg {
  fill: none;
  stroke: rgba(255, 153, 200, 0.15);
  stroke-width: 3;
}

.timer-svg .circle {
  fill: none;
  stroke: #ff99c8;
  stroke-width: 3;
  stroke-linecap: round;
  transition: stroke-dasharray 0.1s linear;
  filter: drop-shadow(0 0 4px #ff99c8);
}

#revive-countdown-text {
  font-size: 11px;
  font-weight: bold;
  color: #ff99c8;
  z-index: 2;
  text-shadow: 0 0 4px #ff99c8;
}

/* Upgrades Constellation Modal */
.upgrades-header {
  position: absolute;
  top: 20px;
  left: 20px;
  right: 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 0;
  padding: 16px 28px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  width: auto;
  box-sizing: border-box;
  z-index: 10;
}

.upgrades-dots-counter {
  font-family: 'Playwrite DE Grund', cursive, sans-serif;
  font-size: 13px;
  font-weight: bold;
  color: #fcf6bd;
  background: rgba(252, 246, 189, 0.05);
  border: 1.5px solid rgba(252, 246, 189, 0.4);
  padding: 6px 16px;
  border-radius: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  text-shadow: 0 0 8px rgba(252, 246, 189, 0.4);
  box-shadow: 0 0 12px rgba(252, 246, 189, 0.1);
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
}

#upgrades-dots-value {
  color: #ffffff;
  text-shadow: 0 0 8px rgba(255, 255, 255, 0.6);
}

.btn-close {
  width: 36px;
  height: 36px;
  border-radius: 0;
  border: 1.5px solid rgba(255, 255, 255, 0.25);
  background: rgba(255, 255, 255, 0.02);
  color: #f7f9fa;
  font-size: 20px;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: none;
}

.btn-close:hover {
  background: rgba(255, 153, 200, 0.15);
  border-color: #ff99c8;
  color: #ff99c8;
  box-shadow: 0 0 10px rgba(255, 153, 200, 0.3);
  transform: scale(1.05);
}

.btn-respec {
  font-family: 'Playwrite DE Grund', cursive, sans-serif;
  height: 36px;
  border-radius: 0;
  border: 1.5px solid rgba(255, 153, 200, 0.4);
  background: rgba(255, 153, 200, 0.05);
  color: #ff99c8;
  font-size: 11px;
  font-weight: bold;
  padding: 0 16px;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: none;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.btn-respec:hover:not(:disabled) {
  background: rgba(255, 153, 200, 0.18);
  border-color: #ff99c8;
  box-shadow: 0 0 10px rgba(255, 153, 200, 0.3);
  transform: scale(1.03);
}

.btn-respec:active:not(:disabled) {
  transform: scale(0.98);
}

.btn-respec:disabled {
  background: rgba(255, 255, 255, 0.02);
  border-color: rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.25);
  cursor: not-allowed;
}

.btn-prestige {
  font-family: 'Playwrite DE Grund', cursive, sans-serif;
  height: 36px;
  border-radius: 0;
  border: 1.5px solid #a9def9;
  background: linear-gradient(135deg, rgba(169, 222, 249, 0.25), rgba(228, 193, 249, 0.25));
  color: #ffffff;
  font-size: 11px;
  font-weight: bold;
  padding: 0 16px;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 12px rgba(169, 222, 249, 0.3);
  text-transform: uppercase;
  letter-spacing: 1px;
  text-shadow: 0 0 8px rgba(169, 222, 249, 0.6);
  animation: prestige-btn-pulse 2s infinite ease-in-out;
}

@keyframes prestige-btn-pulse {
  0% { box-shadow: 0 0 8px rgba(169, 222, 249, 0.3); border-color: rgba(169, 222, 249, 0.7); }
  50% { box-shadow: 0 0 20px rgba(169, 222, 249, 0.75), 0 0 30px rgba(228, 193, 249, 0.4); border-color: rgba(228, 193, 249, 1); }
  100% { box-shadow: 0 0 8px rgba(169, 222, 249, 0.3); border-color: rgba(169, 222, 249, 0.7); }
}

.btn-prestige:hover {
  background: linear-gradient(135deg, rgba(169, 222, 249, 0.45), rgba(228, 193, 249, 0.45));
  box-shadow: 0 0 25px rgba(169, 222, 249, 0.9), 0 0 35px rgba(228, 193, 249, 0.6);
  transform: scale(1.05);
}

.btn-prestige:active {
  transform: scale(0.98);
}



.upgrades-constellation {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 380px;
  overflow-y: auto;
  padding-right: 6px;
  scrollbar-width: thin;
  scrollbar-color: rgba(228, 193, 249, 0.4) rgba(0, 0, 0, 0.3);
}

/* Custom scrollbar for upgrades panel */
.upgrades-constellation::-webkit-scrollbar {
  width: 6px;
}

.upgrades-constellation::-webkit-scrollbar-track {
  background: transparent;
}

.upgrades-constellation::-webkit-scrollbar-thumb {
  background-color: rgba(228, 193, 249, 0.4);
  border-radius: 3px;
}

.upgrade-node {
  background: rgba(255, 255, 255, 0.03);
  border: 1.5px solid rgba(208, 244, 222, 0.2);
  border-radius: 18px;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  transition: transform 0.2s, box-shadow 0.2s;
}

.upgrade-node:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(208, 244, 222, 0.1);
  background: rgba(255, 255, 255, 0.06);
}

.node-icon {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background: rgba(208, 244, 222, 0.15);
  color: #d0f4de;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: bold;
}

.node-info {
  flex-grow: 1;
  text-align: left;
}

.node-title {
  font-size: 13px;
  font-weight: bold;
  color: #ffffff;
  margin-bottom: 2px;
}

.node-level {
  font-size: 10px;
  color: #a0aec0;
}

.btn-upgrade-action {
  font-family: 'Playwrite DE Grund', cursive, sans-serif;
  border: 1.5px solid #d0f4de;
  background: rgba(208, 244, 222, 0.15);
  color: #d0f4de;
  font-weight: bold;
  font-size: 13px;
  padding: 8px 14px;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s;
  min-width: 75px;
}

.btn-upgrade-action:hover {
  background: rgba(208, 244, 222, 0.35);
  transform: scale(1.05);
}

.btn-upgrade-action:disabled {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.15);
  color: rgba(255, 255, 255, 0.3);
  cursor: not-allowed;
  transform: none;
}

/* Ad Simulator Overlay */
.ad-simulator {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(10, 12, 20, 0.85);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 100;
  backdrop-filter: blur(6px);
}

.ad-card {
  background: #151926;
  border-radius: 20px;
  padding: 24px;
  width: 90%;
  max-width: 500px;
  border: 1.5px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 15px 40px rgba(0, 0, 0, 0.5);
  transform: scale(var(--ui-scale, 1));
  transform-origin: center center;
}

.ad-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  padding-bottom: 12px;
}

.ad-badge {
  background: rgba(255, 255, 255, 0.06);
  color: #a0aec0;
  font-size: 10px;
  font-weight: bold;
  padding: 4px 8px;
  border-radius: 4px;
  letter-spacing: 0.5px;
}

.ad-timer {
  font-size: 13px;
  font-weight: bold;
  color: #ffffff;
}

.ad-close-btn {
  background: rgba(228, 193, 249, 0.2);
  border: 1.5px solid #e4c1f9;
  border-radius: 8px;
  padding: 4px 12px;
  font-family: 'Playwrite DE Grund', cursive, sans-serif;
  font-weight: bold;
  font-size: 12px;
  color: #e4c1f9;
  cursor: pointer;
  transition: all 0.2s;
}

.ad-close-btn:hover {
  background: rgba(228, 193, 249, 0.4);
}

.ad-body {
  text-align: center;
}

.ad-video-mock {
  background: rgba(255, 255, 255, 0.03);
  border: 2px dashed rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 40px 20px;
  position: relative;
  overflow: hidden;
}

.ad-logo-text {
  font-size: 20px;
  font-weight: bold;
  color: #a0aec0;
  background: rgba(255, 255, 255, 0.06);
  border: 1.5px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  display: inline-block;
  padding: 6px 14px;
  margin-bottom: 16px;
  animation: logo-bounce 1s infinite alternate ease-in-out;
}

@keyframes logo-bounce {
  0% { transform: translateY(0); }
  100% { transform: translateY(-6px); }
}

.ad-text-content h3 {
  font-size: 18px;
  margin-bottom: 8px;
  color: #ffffff;
}

.ad-text-content p {
  font-size: 12px;
  color: #a0aec0;
  line-height: 1.5;
  margin-bottom: 24px;
}

.ad-progress-bar {
  width: 100%;
  height: 6px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 3px;
  overflow: hidden;
}

#ad-progress-fill {
  height: 100%;
  background: #a9def9;
  width: 0%;
}

/* Utilities */
.btn-reset-hud {
  position: absolute;
  bottom: 20px;
  left: 20px;
  z-index: 15; /* Above canvas, below screens overlay */
  background: rgba(255, 153, 200, 0.08);
  border: 1.5px solid rgba(255, 153, 200, 0.4);
  color: #ff99c8;
  font-size: 11px;
  padding: 8px 16px;
  border-radius: 12px;
  font-family: 'Playwrite DE Grund', cursive, sans-serif;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-reset-hud:hover {
  background: rgba(255, 153, 200, 0.2);
  box-shadow: 0 4px 12px rgba(255, 153, 200, 0.2);
}

.btn-reset-hud:active {
  transform: scale(0.97);
}

.btn-trigger-anomaly-hud {
  position: absolute;
  bottom: 20px;
  left: 155px;
  z-index: 15;
  background: rgba(0, 243, 255, 0.08);
  border: 1.5px solid rgba(0, 243, 255, 0.4);
  color: #00f3ff;
  font-size: 11px;
  padding: 8px 16px;
  border-radius: 12px;
  font-family: 'Playwrite DE Grund', cursive, sans-serif;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-trigger-anomaly-hud:hover {
  background: rgba(0, 243, 255, 0.2);
  box-shadow: 0 4px 12px rgba(0, 243, 255, 0.2);
}

.btn-trigger-anomaly-hud:active {
  transform: scale(0.97);
}

.btn-grant-keystone-hud {
  position: absolute;
  bottom: 20px;
  left: 310px;
  z-index: 15;
  background: rgba(228, 193, 249, 0.08);
  border: 1.5px solid rgba(228, 193, 249, 0.4);
  color: #e4c1f9;
  font-size: 11px;
  padding: 8px 16px;
  border-radius: 12px;
  font-family: 'Playwrite DE Grund', cursive, sans-serif;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-grant-keystone-hud:hover {
  background: rgba(228, 193, 249, 0.2);
  box-shadow: 0 4px 12px rgba(228, 193, 249, 0.2);
}

.btn-grant-keystone-hud:active {
  transform: scale(0.97);
}

.complete-breakdown {
  background: rgba(255, 255, 255, 0.03);
  border: 1.5px solid rgba(228, 193, 249, 0.15);
  border-radius: 20px;
  padding: 16px;
  margin-bottom: 24px;
  font-size: 13px;
  color: #a0aec0;
}

.breakdown-row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 8px;
}

.breakdown-row:last-child {
  margin-bottom: 0;
}

.hidden {
  display: none !important;
}

/* Rank & EXP mini HUD styles */
.rank-display {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 85px;
}

.exp-bar-mini {
  width: 75px;
  height: 5px;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 3px;
  margin-top: 4px;
  overflow: hidden;
  position: relative;
}

.exp-fill {
  position: absolute;
  left: 0;
  top: 0;
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #ffa500, #ffd700);
  box-shadow: 0 0 6px rgba(255, 215, 0, 0.6);
  transition: width 0.3s cubic-bezier(0.1, 0.8, 0.2, 1);
}

.exp-label {
  font-size: 8px;
  color: #a0aec0;
  margin-top: 2px;
  letter-spacing: 0.5px;
}

/* Complete Screen Rank Progression */
.complete-rank-progress,
.failed-rank-progress {
  background: transparent;
  border: none;
  padding: 0;
  margin-bottom: 32px;
  text-align: left;
  width: 100%;
  box-shadow: none;
}

.rank-progress-labels {
  display: flex;
  justify-content: space-between;
  font-size: 14px;
  font-weight: bold;
  color: #fcf6bd;
  margin-bottom: 8px;
  align-items: center;
}

.rank-up-banner {
  color: #ff99c8;
  font-weight: bold;
  font-size: 20px;
  letter-spacing: 2px;
  text-shadow: 0 0 10px rgba(255, 153, 200, 0.8);
  display: inline-block;
  opacity: 0;
  transform: scale(0.5);
}

.rank-up-banner.animate-rank-up {
  opacity: 1;
  transform: scale(1);
  animation: rank-up-bounce 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) forwards, pulse-glow 1s infinite alternate;
}

@keyframes rank-up-bounce {
  0% { transform: scale(0.5); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

@keyframes pulse-glow {
  0% { transform: scale(1); opacity: 0.8; text-shadow: 0 0 4px rgba(255, 153, 200, 0.4); }
  100% { transform: scale(1.05); opacity: 1; text-shadow: 0 0 12px rgba(255, 153, 200, 0.8); }
}

.rank-bar-bg {
  width: 100%;
  height: 6px; /* ultra thin line style */
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
  overflow: hidden;
  position: relative;
  border: none;
  transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275), box-shadow 0.2s ease;
}

.rank-bar-bg.pulse-bar {
  transform: scale(1.04);
  box-shadow: 0 0 12px rgba(255, 215, 0, 0.35);
}

.rank-bar-fill {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  border-radius: 3px;
  width: 0%;
  background: linear-gradient(90deg, #ffa500, #ffd700);
  box-shadow: 0 0 10px rgba(255, 215, 0, 0.5);
  transition: none;
}

.rank-bar-fill.counting {
  background: linear-gradient(90deg, #ffd700, #ffffff);
  box-shadow: 0 0 18px rgba(255, 215, 0, 0.85);
}

.rank-bar-bg.counting {
  box-shadow: 0 0 18px rgba(255, 215, 0, 0.6);
  transform: scale(1.02);
}

.complete-rank-progress.rank-up-flash {
  animation: rank-up-flash-animation 0.8s ease-out;
}

@keyframes rank-up-flash-animation {
  0% { filter: brightness(1); }
  20% { filter: brightness(1.7) drop-shadow(0 0 20px #ff99c8); }
  100% { filter: brightness(1); }
}

.breakdown-row span {
  transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275), text-shadow 0.2s ease, color 0.2s ease;
}

.breakdown-row.highlight-row {
  color: #ffffff;
  text-shadow: 0 0 10px rgba(169, 222, 249, 0.9);
  transform: scale(1.04);
}

.reward-box.counting-box {
  background: transparent;
  border-color: transparent;
  box-shadow: none;
  transform: scale(1.05);
}

.rank-exp-text {
  font-size: 11px;
  color: #a0aec0;
  margin-top: 6px;
  text-align: center;
  transition: transform 0.2s ease;
}

.rank-exp-text.counting {
  color: #ffffff;
  font-weight: bold;
  transform: scale(1.05);
}

/* Complete Screen EXP breakdown */
.complete-exp-breakdown,
.failed-exp-breakdown {
  background: transparent;
  border: none;
  padding: 0;
  margin-bottom: 32px;
  width: 100%;
  box-shadow: none;
}

.breakdown-section-title {
  font-size: 11px;
  font-weight: bold;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: #a9def9;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  padding-bottom: 4px;
  margin-bottom: 12px;
  text-align: left;
}

.breakdown-row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 12px;
  font-size: 14px;
  color: #cbd5e1;
}

.total-row {
  border-top: 1px solid rgba(169, 222, 249, 0.2);
  padding-top: 12px;
  margin-top: 12px;
  font-weight: bold;
  color: #ffffff;
}

/* Sequential Reveal Animations */
.opacity-0 {
  opacity: 0 !important;
  transform: translateY(10px);
  transition: opacity 0.4s cubic-bezier(0.25, 1, 0.5, 1), transform 0.4s cubic-bezier(0.25, 1, 0.5, 1);
}

.reveal-row {
  opacity: 1 !important;
  transform: translateY(0) !important;
}

/* Complete screen animated components */
#complete-reward-box {
  opacity: 0;
  transform: scale(0.9);
  transition: opacity 0.5s ease, transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
  margin-bottom: 24px;
  padding: 12px 24px;
  background: rgba(255, 153, 200, 0.02);
}

#complete-rank-bonus-text {
  font-size: 20px;
  color: #ff99c8;
  text-shadow: 0 0 10px rgba(255, 153, 200, 0.6);
  text-transform: uppercase;
  font-weight: 800;
  letter-spacing: 2px;
  margin-top: 0;
}

#complete-reward-box.reveal {
  opacity: 1 !important;
  transform: scale(1) !important;
}

.complete-btn-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  width: 100%;
}

#complete-button-group {
  opacity: 0;
  transition: opacity 0.5s ease;
  pointer-events: none;
}

#complete-button-group.reveal {
  opacity: 1 !important;
  pointer-events: auto;
}

#btn-double-reward {
  max-width: 380px !important;
  width: 100% !important;
}

/* ==========================================================================
   Reaction Upgrades Tree Panel & SVG Constellation Graph
   ========================================================================== */
.upgrades-panel-card {
  position: absolute !important;
  top: 0 !important;
  left: 0 !important;
  width: 100% !important;
  height: 100vh !important;
  height: 100dvh !important;
  max-width: none !important;
  padding: 0 !important;
  display: flex;
  flex-direction: column !important;
  background: radial-gradient(circle at center, rgba(10, 12, 22, 0.2) 0%, rgba(5, 7, 12, 0.96) 100%) !important;
  backdrop-filter: blur(14px) !important;
  -webkit-backdrop-filter: blur(14px) !important;
  border: none !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  box-sizing: border-box !important;
  overflow: hidden !important;
  touch-action: none !important;
}

.upgrades-panel-card h2.screen-title {
  margin-bottom: 0 !important;
  font-size: 28px !important;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: #e4c1f9;
  text-shadow: 0 0 12px rgba(228, 193, 249, 0.6), 0 0 30px rgba(228, 193, 249, 0.3);
}

.upgrades-tree-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
}

/* Drag-to-pan tree viewport with cockpit visual grid */
.tree-viewport {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(10, 12, 22, 0.2);
  background-image: 
    radial-gradient(rgba(255, 255, 255, 0.04) 1px, transparent 1px),
    linear-gradient(rgba(255, 255, 255, 0.02) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.02) 1px, transparent 1px);
  background-size: 40px 40px, 40px 40px, 40px 40px;
  background-position: center center;
  border: none;
  border-radius: 0;
  overflow: hidden;
  cursor: grab;
  user-select: none;
  z-index: 1;
  touch-action: none !important;
}

.tree-viewport:active {
  cursor: grabbing;
}

#upgrade-tree-svg {
  width: 100%;
  height: 100%;
}

#upgrade-tree-svg text {
  font-family: 'Playwrite DE Grund', cursive, sans-serif;
  pointer-events: none;
  user-select: none;
}

/* Zoom controls overlay */
.tree-zoom-hud {
  position: absolute;
  top: 100px;
  left: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 10;
}

.tree-zoom-hud button {
  width: 36px;
  height: 36px;
  border-radius: 0;
  border: 1.5px solid rgba(255, 255, 255, 0.25);
  background: rgba(0, 0, 0, 0.4);
  color: #f7f9fa;
  font-size: 18px;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: none;
}

.tree-zoom-hud button:hover {
  background: rgba(255, 255, 255, 0.15);
  border-color: rgba(255, 255, 255, 0.6);
  box-shadow: 0 0 10px rgba(255, 255, 255, 0.2);
  transform: translateY(-1px);
}

.tree-zoom-hud button:active {
  transform: scale(0.95);
}

/* Side Detail Panel - Glassmorphic Console */
.upgrade-detail-panel {
  position: absolute;
  top: 100px;
  right: 20px;
  bottom: 20px;
  width: 320px;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 0;
  padding: 24px;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  gap: 20px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  box-sizing: border-box;
  z-index: 10;
}



.detail-content {
  display: flex;
  flex-direction: column;
  gap: 14px;
  height: 100%;
}

.detail-content h3 {
  font-size: 18px;
  font-weight: 800;
  color: #ffffff;
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.branch-badge {
  font-size: 9px;
  font-weight: 800;
  padding: 4px 10px;
  border-radius: 0;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  width: fit-content;
}

.branch-badge.core { background: rgba(255, 255, 255, 0.1); color: #ffffff; border: 1px solid rgba(255, 255, 255, 0.2); }
.branch-badge.shapes { background: rgba(255, 153, 200, 0.15); color: #ff99c8; border: 1px solid rgba(255, 153, 200, 0.3); }
.branch-badge.projectiles { background: rgba(169, 222, 249, 0.15); color: #a9def9; border: 1px solid rgba(169, 222, 249, 0.3); }
.branch-badge.overfill { background: rgba(252, 246, 189, 0.15); color: #fcf6bd; border: 1px solid rgba(252, 246, 189, 0.3); }
.branch-badge.shield { background: rgba(228, 193, 249, 0.15); color: #e4c1f9; border: 1px solid rgba(228, 193, 249, 0.3); }

.detail-content p {
  font-size: 12.5px;
  color: #a0aec0;
  line-height: 1.6;
  margin: 0;
}

.detail-reqs {
  font-size: 11px;
  color: #8f9ca6;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  padding-top: 12px;
  margin-top: auto;
}

.detail-reqs span {
  font-weight: bold;
}

.btn-buy-upgrade {
  font-family: 'Playwrite DE Grund', cursive, sans-serif;
  border-radius: 0;
  padding: 14px 20px;
  font-size: 14px;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  outline: none;
  width: 100%;
  box-sizing: border-box;
}

/* Branch specific outline purchase buttons */
.detail-content.core .btn-buy-upgrade {
  border: 1.5px solid rgba(255, 255, 255, 0.4);
  background: rgba(255, 255, 255, 0.05);
  color: #ffffff;
  box-shadow: 0 0 12px rgba(255, 255, 255, 0.1);
  text-shadow: 0 0 8px rgba(255, 255, 255, 0.4);
}
.detail-content.core .btn-buy-upgrade:hover:not(:disabled) {
  border-color: #ffffff;
  background: rgba(255, 255, 255, 0.15);
  box-shadow: 0 0 22px rgba(255, 255, 255, 0.35);
  transform: translateY(-2px);
}

.detail-content.shapes .btn-buy-upgrade {
  border: 1.5px solid rgba(255, 153, 200, 0.4);
  background: rgba(255, 153, 200, 0.05);
  color: #ff99c8;
  box-shadow: 0 0 12px rgba(255, 153, 200, 0.1);
  text-shadow: 0 0 8px rgba(255, 153, 200, 0.4);
}
.detail-content.shapes .btn-buy-upgrade:hover:not(:disabled) {
  border-color: #ff99c8;
  background: rgba(255, 153, 200, 0.15);
  box-shadow: 0 0 22px rgba(255, 153, 200, 0.35);
  transform: translateY(-2px);
}

.detail-content.projectiles .btn-buy-upgrade {
  border: 1.5px solid rgba(169, 222, 249, 0.4);
  background: rgba(169, 222, 249, 0.05);
  color: #a9def9;
  box-shadow: 0 0 12px rgba(169, 222, 249, 0.1);
  text-shadow: 0 0 8px rgba(169, 222, 249, 0.4);
}
.detail-content.projectiles .btn-buy-upgrade:hover:not(:disabled) {
  border-color: #a9def9;
  background: rgba(169, 222, 249, 0.15);
  box-shadow: 0 0 22px rgba(169, 222, 249, 0.35);
  transform: translateY(-2px);
}

.detail-content.overfill .btn-buy-upgrade {
  border: 1.5px solid rgba(252, 246, 189, 0.4);
  background: rgba(252, 246, 189, 0.05);
  color: #fcf6bd;
  box-shadow: 0 0 12px rgba(252, 246, 189, 0.1);
  text-shadow: 0 0 8px rgba(252, 246, 189, 0.4);
}
.detail-content.overfill .btn-buy-upgrade:hover:not(:disabled) {
  border-color: #fcf6bd;
  background: rgba(252, 246, 189, 0.15);
  box-shadow: 0 0 22px rgba(252, 246, 189, 0.35);
  transform: translateY(-2px);
}

.detail-content.shield .btn-buy-upgrade {
  border: 1.5px solid rgba(228, 193, 249, 0.4);
  background: rgba(228, 193, 249, 0.05);
  color: #e4c1f9;
  box-shadow: 0 0 12px rgba(228, 193, 249, 0.1);
  text-shadow: 0 0 8px rgba(228, 193, 249, 0.4);
}
.detail-content.shield .btn-buy-upgrade:hover:not(:disabled) {
  border-color: #e4c1f9;
  background: rgba(228, 193, 249, 0.15);
  box-shadow: 0 0 22px rgba(228, 193, 249, 0.35);
  transform: translateY(-2px);
}

.btn-buy-upgrade:active:not(:disabled) {
  transform: translateY(0) scale(0.97);
}

.btn-buy-upgrade:disabled {
  background: rgba(255, 255, 255, 0.02) !important;
  border: 1.5px solid rgba(255, 255, 255, 0.1) !important;
  color: rgba(255, 255, 255, 0.25) !important;
  box-shadow: none !important;
  text-shadow: none !important;
  cursor: not-allowed;
  transform: none !important;
}

/* Interactive SVG Node classes */
.node-g {
  pointer-events: auto;
  transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1), transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.node-circle {
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  transform-origin: center;
  transform-box: fill-box;
}

.node-g:hover .node-circle {
  transform: scale(1.18);
  filter: drop-shadow(0 0 8px currentColor) !important;
}

.node-circle.purchased {
  stroke-width: 3.5;
  filter: url(#svg-glow);
}

.node-circle.unlockable {
  stroke-width: 2.5;
  stroke-dasharray: 2, 2;
  animation: pulse-node 2.2s infinite ease-in-out;
}

.node-circle.locked {
}

/* Branch specific node colors */
.node-circle.core.purchased { fill: rgba(255,255,255,0.9); stroke: #ffffff; }
.node-circle.core.unlockable { fill: rgba(255,255,255,0.25); stroke: #ffffff; }
.node-circle.core.locked { fill: rgba(255,255,255,0.05); stroke: rgba(255,255,255,0.3); }

.node-circle.shapes.purchased { fill: #ff99c8; stroke: #ffffff; }
.node-circle.shapes.unlockable { fill: rgba(255, 153, 200, 0.25); stroke: #ff99c8; }
.node-circle.shapes.locked { fill: rgba(255, 153, 200, 0.05); stroke: rgba(255, 153, 200, 0.3); }

.node-circle.projectiles.purchased { fill: #a9def9; stroke: #ffffff; }
.node-circle.projectiles.unlockable { fill: rgba(169, 222, 249, 0.25); stroke: #a9def9; }
.node-circle.projectiles.locked { fill: rgba(169, 222, 249, 0.05); stroke: rgba(169, 222, 249, 0.3); }

.node-circle.overfill.purchased { fill: #fcf6bd; stroke: #ffffff; }
.node-circle.overfill.unlockable { fill: rgba(252, 246, 189, 0.25); stroke: #fcf6bd; }
.node-circle.overfill.locked { fill: rgba(252, 246, 189, 0.05); stroke: rgba(252, 246, 189, 0.3); }

.node-circle.shield.purchased { fill: #e4c1f9; stroke: #ffffff; }
.node-circle.shield.unlockable { fill: rgba(228, 193, 249, 0.25); stroke: #e4c1f9; }
.node-circle.shield.locked { fill: rgba(228, 193, 249, 0.05); stroke: rgba(228, 193, 249, 0.3); }

/* SVG Connect Lines */
.link-path {
  fill: none;
  transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1), stroke-width 0.3s cubic-bezier(0.4, 0, 0.2, 1), filter 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.link-path.locked {
  stroke: rgba(255, 255, 255, 0.1);
  stroke-dasharray: 4, 4;
  stroke-width: 1.5px;
}

.link-path.purchased {
  stroke-width: 3.5px;
  filter: url(#svg-glow);
  stroke-dasharray: 8, 4;
  animation: link-flow 1.5s linear infinite;
}

.link-path.purchased.core { stroke: #ffffff; }
.link-path.purchased.shapes { stroke: #ff99c8; }
.link-path.purchased.projectiles { stroke: #a9def9; }
.link-path.purchased.overfill { stroke: #fcf6bd; }
.link-path.purchased.shield { stroke: #e4c1f9; }

/* SVG Node text labels */
.node-text {
  font-family: 'Outfit', sans-serif;
  font-size: 11px;
  fill: #8f9ca6;
  text-anchor: middle;
  transition: fill 0.25s cubic-bezier(0.4, 0, 0.2, 1), font-weight 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

#upgrade-tree-svg text {
  font-family: 'Outfit', sans-serif;
}

.node-g:hover .node-text {
  fill: #ffffff;
  font-weight: bold;
}

.node-g.selected .node-text {
  fill: #ffffff;
  font-weight: bold;
}

.node-g.selected .node-circle {
  stroke-width: 4px !important;
  stroke: #ffffff !important;
  transform: scale(1.18);
  filter: drop-shadow(0 0 10px currentColor) !important;
}


/* Keyframe animations */
@keyframes pulse-node {
  0% { filter: drop-shadow(0 0 1px currentColor); }
  50% { filter: drop-shadow(0 0 8px currentColor); }
  100% { filter: drop-shadow(0 0 1px currentColor); }
}

@keyframes node-complete-pulse {
  0% { transform: scale(1); filter: drop-shadow(0 0 8px currentColor); }
  30% { transform: scale(1.25); filter: drop-shadow(0 0 25px currentColor); }
  100% { transform: scale(1); filter: drop-shadow(0 0 10px currentColor); }
}

.node-g.node-complete-anim {
  transform-origin: center;
  transform-box: fill-box;
  animation: node-complete-pulse 0.8s cubic-bezier(0.25, 1, 0.5, 1) forwards;
}

@keyframes link-flow {
  to {
    stroke-dashoffset: -12;
  }
}

/* ==========================================================================
   Shining Upgrades Unlock Button
   ========================================================================== */
.shining-btn, .shining-btn * {
  position: relative;
  color: #220924 !important;
}

.shining-btn {
  position: relative !important;
  overflow: hidden !important;
  background: linear-gradient(135deg, #e4c1f9, #a9def9) !important;
  border: none !important;
  font-weight: 800 !important;
  animation: shining-pulse 2s infinite !important;
}

.shining-btn::after {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: linear-gradient(to right, transparent, rgba(255, 255, 255, 0.4), transparent);
  transform: rotate(30deg);
  animation: shine-sweep 3s infinite linear;
}

@keyframes shine-sweep {
  0% { transform: translate(-100%, -100%) rotate(30deg); }
  100% { transform: translate(100%, 100%) rotate(30deg); }
}

@keyframes shining-pulse {
  0% { box-shadow: 0 0 6px rgba(228, 193, 249, 0.4); }
  50% { box-shadow: 0 0 22px rgba(169, 222, 249, 0.95); }
  100% { box-shadow: 0 0 6px rgba(228, 193, 249, 0.4); }
}

/* Pulsing ring for affordable and unlockable upgrades */
.node-pulse-ring {
  fill: none;
  stroke-width: 1.5px;
  transform-origin: center;
  transform-box: fill-box;
  animation: pulse-ring-animation 1.8s infinite cubic-bezier(0.215, 0.610, 0.355, 1);
  pointer-events: none;
}

@keyframes pulse-ring-animation {
  0% {
    transform: scale(0.95);
    opacity: 0.9;
  }
  100% {
    transform: scale(1.25);
    opacity: 0;
  }
}

/* Mobile and landscape layout styles for Upgrades constellation tree screen */
@media (max-width: 768px), (max-height: 500px) {
  .upgrades-panel-card {
    padding: 0 !important;
  }
  .upgrades-header {
    position: absolute !important;
    top: 12px !important;
    left: 12px !important;
    right: 12px !important;
    width: auto !important;
    margin: 0 !important;
    z-index: 10 !important;
    padding: 12px 16px !important;
    display: grid !important;
    grid-template-columns: 1fr auto !important;
    align-items: center !important;
    gap: 8px !important;
  }
  .upgrades-header h2.screen-title {
    font-size: 20px !important;
    margin-bottom: 0 !important;
    line-height: 1.2 !important;
  }
  .upgrades-dots-counter {
    grid-column: 1 / span 2 !important;
    width: fit-content !important;
    margin-top: 4px !important;
    font-size: 12px !important;
    padding: 4px 12px !important;
    position: static !important;
    transform: none !important;
    left: auto !important;
  }
  .btn-close {
    grid-column: 2 !important;
    grid-row: 1 !important;
    justify-self: end !important;
    margin: 0 !important;
    width: 36px !important;
    height: 36px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
  }

  .upgrades-tree-container {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
  }
  .tree-viewport {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    z-index: 1 !important;
    border: none !important;
    box-shadow: none !important;
  }
  .tree-zoom-hud {
    position: absolute !important;
    top: 110px !important;
    left: 12px !important;
    z-index: 10 !important;
  }
  .tree-zoom-hud button {
    width: 44px !important;
    height: 44px !important;
    font-size: 20px !important;
  }
  .upgrade-detail-panel {
    position: absolute !important;
    height: auto !important;
    overflow-y: auto !important;
    z-index: 10 !important;
    margin: 0 !important;
    padding: 16px !important;
    background: rgba(0, 0, 0, 0.55) !important;
    backdrop-filter: blur(16px) !important;
    -webkit-backdrop-filter: blur(16px) !important;
    border: 1px solid rgba(255, 255, 255, 0.08) !important;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5) !important;
    gap: 12px !important;
  }

  .detail-content {
    gap: 8px !important;
  }
  .detail-content p {
    font-size: 11.5px !important;
    line-height: 1.5 !important;
  }
  .detail-reqs {
    padding-top: 8px !important;
    margin-top: 8px !important;
  }
  .btn-buy-upgrade {
    padding: 12px 16px !important;
    font-size: 13px !important;
    border-radius: 0 !important;
  }
}

/* Portrait mobile specific detail panel positioning (bottom) */
@media (max-width: 768px) and (orientation: portrait) {
  .upgrade-detail-panel {
    bottom: 12px !important;
    left: 12px !important;
    right: 12px !important;
    top: auto !important;
    width: auto !important;
    max-height: 40vh !important;
  }
}

/* Landscape mobile / small screen landscape specific overrides (detail panel on the right, compact header) */
@media (orientation: landscape) and (max-height: 500px), (orientation: landscape) and (max-width: 950px) {
  .upgrades-header {
    display: flex !important;
    flex-direction: row !important;
    justify-content: space-between !important;
    align-items: center !important;
    padding: 8px 16px !important;
    top: 8px !important;
    left: 8px !important;
    right: 8px !important;
    height: auto !important;
  }
  .upgrades-header h2.screen-title {
    font-size: 18px !important;
  }
  .upgrades-dots-counter {
    position: absolute !important;
    left: 50% !important;
    transform: translateX(-50%) !important;
    margin-top: 0 !important;
    font-size: 11px !important;
    padding: 3px 10px !important;
  }
  .tree-zoom-hud {
    top: 70px !important;
    left: 8px !important;
  }
  .upgrade-detail-panel {
    top: 60px !important;
    right: 8px !important;
    bottom: 8px !important;
    left: auto !important;
    width: 280px !important;
    height: auto !important;
    max-height: calc(100vh - 68px) !important;
    padding: 12px 16px !important;
    gap: 12px !important;
  }
}


/* Mastery Progress UI Styles */
.mastery-list {
  width: 100%;
  max-height: 60vh;
  overflow-y: auto;
  padding-right: 8px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  scrollbar-width: thin;
  scrollbar-color: rgba(252, 246, 189, 0.4) rgba(0, 0, 0, 0.3);
}

.mastery-list::-webkit-scrollbar {
  width: 6px;
}

.mastery-list::-webkit-scrollbar-track {
  background: transparent;
}

.mastery-list::-webkit-scrollbar-thumb {
  background-color: rgba(252, 246, 189, 0.4);
  border-radius: 3px;
}

.mastery-item {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 0;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  text-align: left;
  transition: all 0.2s ease;
}

.mastery-item:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(252, 246, 189, 0.3);
}

.mastery-item-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.mastery-name {
  font-size: 16px;
  font-weight: bold;
  color: #ffffff;
}

.mastery-tier-badge {
  font-size: 11px;
  font-weight: bold;
  text-transform: uppercase;
  letter-spacing: 1px;
  padding: 3px 8px;
  border-radius: 0;
}

.mastery-tier-badge.tier-0 {
  background: rgba(255, 255, 255, 0.1);
  color: #cbd5e1;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.mastery-tier-badge.tier-1 {
  background: rgba(208, 244, 222, 0.15);
  color: #d0f4de;
  border: 1px solid rgba(208, 244, 222, 0.4);
}

.mastery-tier-badge.tier-2 {
  background: rgba(169, 222, 249, 0.15);
  color: #a9def9;
  border: 1px solid rgba(169, 222, 249, 0.4);
}

.mastery-tier-badge.tier-3 {
  background: rgba(228, 193, 249, 0.15);
  color: #e4c1f9;
  border: 1px solid rgba(228, 193, 249, 0.4);
}

.mastery-tier-badge.tier-4 {
  background: rgba(252, 246, 189, 0.15);
  color: #fcf6bd;
  border: 1px solid rgba(252, 246, 189, 0.4);
  box-shadow: 0 0 8px rgba(252, 246, 189, 0.3);
}

.mastery-desc {
  font-size: 12px;
  color: #8f9ca6;
}

.mastery-progress-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 4px;
}

.mastery-progress-bar-bg {
  flex-grow: 1;
  height: 6px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 3px;
  overflow: hidden;
  position: relative;
}

.mastery-progress-bar-fill {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  background: linear-gradient(90deg, #fcf6bd, #e4c1f9);
  border-radius: 3px;
  width: 0%;
  transition: width 0.3s ease;
}

.mastery-progress-bar-fill.maxed {
  background: linear-gradient(90deg, #e4c1f9, #ff99c8);
  box-shadow: 0 0 8px rgba(255, 153, 200, 0.4);
}

.mastery-progress-text {
  font-size: 13px;
  font-weight: bold;
  color: #ffffff;
  min-width: 90px;
  text-align: right;
}

.btn-icon-only {
  min-width: 50px !important;
  max-width: 50px !important;
  padding: 14px 0 !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
}

.mastery-toast-container {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(var(--ui-scale, 1));
  transform-origin: center center;
  pointer-events: none;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  width: 90%;
  max-width: 500px;
}

.mastery-toast {
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: none;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  padding: 16px 20px;
  border-radius: 0;
  color: #ffffff;
  display: flex;
  align-items: center;
  gap: 16px;
  animation: mastery-toast-in 0.45s cubic-bezier(0.175, 0.885, 0.32, 1.2) forwards;
  width: 100%;
  max-width: 420px;
  min-width: min(320px, 90vw); /* never wider than small phone viewports */
  pointer-events: none;
  position: relative;
  overflow: visible;
  box-sizing: border-box;
}

.mastery-toast.fade-out {
  opacity: 0;
  transform: scale(0.85);
  filter: blur(4px);
  transition: all 0.4s cubic-bezier(0.6, -0.28, 0.735, 0.045);
}

@keyframes mastery-toast-in {
  0% { transform: scale(0.6); opacity: 0; filter: blur(4px); }
  100% { transform: scale(1.0); opacity: 1; filter: blur(0); }
}

.mastery-toast-icon {
  background: rgba(252, 246, 189, 0.1);
  border: none;
  border-radius: 0;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fcf6bd;
  flex-shrink: 0;
  box-shadow: 0 0 12px rgba(252, 246, 189, 0.15);
}

.mastery-toast-content {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.mastery-toast-title {
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: #a0aec0;
  margin-bottom: 2px;
}

.mastery-toast-desc {
  font-size: 14px;
  font-weight: bold;
  color: #ffffff;
  line-height: 1.3;
}

.mastery-toast-progress-wrapper {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 8px;
  width: 100%;
}

.mastery-toast-bar-container {
  background: rgba(255, 255, 255, 0.08);
  height: 8px;
  border-radius: 0;
  flex-grow: 1;
  overflow: hidden;
  position: relative;
  border: none;
}

.mastery-toast-bar-fill {
  background: linear-gradient(90deg, #fcf6bd, #d0f4de);
  height: 100%;
  border-radius: 0;
  width: 0%;
  transition: width 1s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow: 0 0 8px rgba(252, 246, 189, 0.4);
}

.mastery-toast-progress-label {
  font-size: 11px;
  font-weight: 800;
  color: #fcf6bd;
  min-width: 60px;
  text-align: right;
  font-family: monospace;
}

.mastery-toast.tier-up {
  border: none;
  box-shadow: 0 10px 40px rgba(255, 159, 28, 0.35), inset 0 0 15px rgba(255, 159, 28, 0.15);
  background: rgba(15, 10, 5, 0.75);
  animation: mastery-toast-in 0.45s cubic-bezier(0.175, 0.885, 0.32, 1.2) forwards,
             mastery-toast-pulse 2s infinite ease-in-out 0.45s;
}

@keyframes mastery-toast-pulse {
  0%, 100% { box-shadow: 0 10px 40px rgba(255, 159, 28, 0.35), inset 0 0 15px rgba(255, 159, 28, 0.15); }
  50% { box-shadow: 0 10px 50px rgba(255, 159, 28, 0.55), inset 0 0 25px rgba(255, 159, 28, 0.3); }
}

.mastery-toast.tier-up .mastery-toast-icon {
  background: rgba(255, 159, 28, 0.15);
  border: none;
  color: #ff9f1c;
  box-shadow: 0 0 15px rgba(255, 159, 28, 0.3);
  animation: icon-bounce 0.8s ease-out infinite alternate;
}

@keyframes icon-bounce {
  0% { transform: translateY(0); }
  100% { transform: translateY(-4px); }
}

.mastery-toast.tier-up .mastery-toast-title {
  color: #ff9f1c;
  text-shadow: 0 0 8px rgba(255, 159, 28, 0.5);
  font-weight: 900;
}

.mastery-toast.tier-up .mastery-toast-bar-fill {
  background: linear-gradient(90deg, #ff9f1c, #ffe3a8);
  box-shadow: 0 0 12px rgba(255, 159, 28, 0.6);
}

.mastery-toast-reward {
  font-size: 12px;
  font-weight: 800;
  color: #d0f4de;
  background: rgba(208, 244, 222, 0.1);
  border: none;
  border-radius: 0;
  padding: 4px 8px;
  margin-top: 6px;
  text-shadow: 0 0 6px rgba(208, 244, 222, 0.3);
  display: inline-block;
  align-self: flex-start;
}

.mastery-particle {
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
  z-index: 1000;
  animation: mastery-particle-out 1.2s cubic-bezier(0.1, 0.8, 0.3, 1) forwards;
}

@keyframes mastery-particle-out {
  0% {
    transform: translate(-50%, -50%) translate(0, 0) scale(1.5);
    opacity: 1;
  }
  80% {
    opacity: 0.8;
  }
  100% {
    transform: translate(-50%, -50%) translate(var(--tx), var(--ty)) scale(0);
    opacity: 0;
  }
}

/* Media query for constrained-height viewports (e.g., mobile landscape or small desktop/iframe windows) */
@media (max-height: 640px) {
  .screen-overlay {
    align-items: flex-start !important;
    padding-top: 20px !important;
    overflow-y: auto !important;
  }

  .screen-card {
    padding: 16px 10px !important;
    transform: scale(var(--ui-scale, 1)) !important;
    transform-origin: top center !important;
    margin-bottom: 20px !important;
  }

  .screen-title {
    font-size: 24px !important;
    margin-bottom: 12px !important;
    letter-spacing: 0.1em !important;
  }

  .screen-subtitle {
    margin-bottom: 16px !important;
  }

  .complete-rank-progress,
  .failed-rank-progress {
    margin-bottom: 16px !important;
  }

  .rank-progress-labels {
    font-size: 12px !important;
    margin-bottom: 4px !important;
  }

  .rank-up-banner {
    font-size: 16px !important;
  }

  .complete-exp-breakdown,
  .failed-exp-breakdown {
    margin-bottom: 16px !important;
  }

  .breakdown-section-title {
    margin-bottom: 6px !important;
  }

  .breakdown-row {
    margin-bottom: 6px !important;
    font-size: 12px !important;
  }

  .total-row {
    padding-top: 6px !important;
    margin-top: 6px !important;
  }

  #complete-reward-box {
    margin-bottom: 12px !important;
    padding: 6px 16px !important;
  }

  #complete-reward-box .reward-bonus-label {
    font-size: 14px !important;
  }

  .complete-btn-container {
    gap: 8px !important;
  }

  .button-group {
    gap: 8px !important;
  }

  .btn {
    padding: 10px 16px !important;
    font-size: 12px !important;
    min-width: 120px !important;
  }

  #btn-double-reward {
    padding: 10px 16px !important;
  }

  .revive-box {
    margin-bottom: 12px !important;
    gap: 6px !important;
  }

  .revive-prompt {
    font-size: 11px !important;
  }

  .btn-emergency {
    padding: 8px 16px !important;
  }

  .ad-simulator {
    align-items: flex-start !important;
    padding-top: 20px !important;
    overflow-y: auto !important;
  }

  .ad-card {
    transform: scale(var(--ui-scale, 1)) !important;
    transform-origin: top center !important;
    padding: 16px !important;
  }
}

/* ==========================================================================
   Daily Anomalies and Keystone Upgrades Styles
   ========================================================================== */

/* Glitch Anomaly Button */
.btn-anomaly {
  background: rgba(0, 243, 255, 0.05) !important;
  border: 1.5px solid rgba(0, 243, 255, 0.4) !important;
  color: #00f3ff !important;
  box-shadow: 0 0 12px rgba(0, 243, 255, 0.15) !important;
  text-shadow: 0 0 8px rgba(0, 243, 255, 0.5) !important;
  font-family: 'Playwrite DE Grund', cursive, sans-serif;
  animation: glitch-btn-flicker 3s infinite ease-in-out;
  position: relative;
  overflow: hidden;
}

.btn-anomaly:hover {
  background: rgba(0, 243, 255, 0.2) !important;
  border-color: #00f3ff !important;
  box-shadow: 0 0 20px rgba(0, 243, 255, 0.45) !important;
  text-shadow: 0 0 12px rgba(0, 243, 255, 0.8) !important;
  transform: translateY(-2px);
}

/* Digital Glitch Button Keyframes */
@keyframes glitch-btn-flicker {
  0%, 100% { opacity: 0.95; }
  31% { opacity: 0.95; }
  32% { opacity: 0.5; filter: hue-rotate(90deg); }
  33% { opacity: 0.95; }
  34% { opacity: 0.95; }
  35% { opacity: 0.3; filter: skewX(10deg); }
  36% { opacity: 0.95; }
  70% { opacity: 0.95; }
  71% { opacity: 0.4; filter: contrast(200%); }
  72% { opacity: 0.95; }
}

/* Daily Anomaly row — attached beneath the main HUD glass bar */
.hud-anomaly-row {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  width: 100%;
  padding: 8px 24px 10px;
  border-top: 1px solid rgba(255, 51, 102, 0.22);
  background: rgba(255, 51, 102, 0.07);
  text-align: center;
  animation: anomaly-bar-pulse 2s infinite ease-in-out;
}

.anomaly-row-title {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: center;
  gap: 6px 8px;
}

.anomaly-row-label {
  font-family: 'Outfit', sans-serif;
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: rgba(255, 51, 102, 0.75);
}

.anomaly-row-name {
  font-family: 'Outfit', sans-serif;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: #ff3366;
  text-shadow: 0 0 8px rgba(255, 51, 102, 0.35);
}

.anomaly-row-desc {
  font-family: 'Outfit', sans-serif;
  font-size: 11px;
  font-weight: 400;
  line-height: 1.35;
  letter-spacing: 0.02em;
  color: rgba(247, 249, 250, 0.82);
  margin: 0;
  max-width: 36em;
}

@keyframes anomaly-bar-pulse {
  0%, 100% { background: rgba(255, 51, 102, 0.06); border-top-color: rgba(255, 51, 102, 0.18); }
  50% { background: rgba(255, 51, 102, 0.11); border-top-color: rgba(255, 51, 102, 0.45); }
}

/* Keystone Upgrades SVG styling */
.node-circle.keystone.purchased { fill: #00f3ff !important; stroke: #ffffff !important; }
.node-circle.keystone.unlockable { fill: rgba(0, 243, 255, 0.25) !important; stroke: #00f3ff !important; }
.node-circle.keystone.locked { fill: rgba(0, 243, 255, 0.05) !important; stroke: rgba(0, 243, 255, 0.3) !important; }

/* Link Paths for Keystone */
.link-path.purchased.keystone {
  stroke: #00f3ff !important;
}

.node-pulse-ring.keystone {
  stroke: #00f3ff !important;
}

/* Glitch node styling */
.node-circle.core-glitch.purchased { fill: #ffffff !important; stroke: #ff0055 !important; }
.node-circle.core-glitch.unlockable { fill: rgba(255, 0, 85, 0.25) !important; stroke: #ff0055 !important; }
.node-circle.core-glitch.locked { fill: rgba(255, 0, 85, 0.05) !important; stroke: rgba(255, 0, 85, 0.3) !important; }

/* Inverted center node for Keystone view */
.node-circle.center-glitch {
  fill: #0e111a !important;
  stroke: #00f3ff !important;
  stroke-width: 3px !important;
  filter: drop-shadow(0 0 8px #00f3ff) !important;
  animation: center-glitch-spin 4s infinite linear;
}

@keyframes center-glitch-spin {
  100% { transform: rotate(360deg); }
}

/* Screen glitch shake for matrix teleportation */
@keyframes canvas-matrix-glitch {
  0% { transform: translate(0, 0); filter: hue-rotate(0deg) contrast(100%); }
  10% { transform: translate(-4px, 2px); filter: hue-rotate(90deg) contrast(150%); }
  20% { transform: translate(4px, -2px); filter: hue-rotate(-90deg) contrast(100%); }
  30% { transform: translate(0, 0); }
  100% { transform: translate(0, 0); }
}

.screen-glitch-active {
  animation: canvas-matrix-glitch 0.15s ease-out;
}

/* Debug anomaly panel styles */
.debug-anomaly-panel {
  position: absolute;
  top: 50%;
  right: 15px;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  gap: 5px;
  background: rgba(14, 17, 26, 0.95);
  border: 1px solid rgba(0, 243, 255, 0.3);
  padding: 12px;
  border-radius: 8px;
  z-index: 10000;
  box-shadow: 0 0 15px rgba(0, 243, 255, 0.15);
  max-height: 90vh;
  overflow-y: auto;
  width: 160px;
}
.debug-anomaly-panel.hidden {
  display: none !important;
}
.debug-anomaly-panel .debug-title {
  font-family: 'Outfit', sans-serif;
  font-size: 11px;
  font-weight: 800;
  color: #00f3ff;
  text-align: center;
  margin-bottom: 8px;
  letter-spacing: 1px;
  border-bottom: 1px solid rgba(0, 243, 255, 0.2);
  padding-bottom: 6px;
}
.btn-debug-select {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: #cdd6f4;
  padding: 6px 10px;
  font-family: 'Outfit', sans-serif;
  font-size: 10px;
  border-radius: 4px;
  cursor: pointer;
  text-align: left;
  transition: all 0.2s ease;
}
.btn-debug-select:hover {
  background: rgba(0, 243, 255, 0.12);
  border-color: #00f3ff;
  color: #ffffff;
  box-shadow: 0 0 8px rgba(0, 243, 255, 0.3);
}

/* Blind Spot Nebula HTML overlay */
.blind-spot-nebula {
  position: absolute;
  left: 0;
  top: 0;
  width: 720px;
  height: 720px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.92);
  filter: blur(55px);
  pointer-events: none;
  z-index: 2;
  /* Positioned every frame from JS via a single composited transform */
  transform: translate3d(0, 0, 0) translate(-50%, -50%);
  will-change: transform;
  display: block;
}
.blind-spot-nebula.hidden {
  display: none !important;
}

/* UI Toggle for local development */
body.ui-hidden #hud,
body.ui-hidden .hud-layer,
body.ui-hidden #screen-overlay,
body.ui-hidden #anomaly-bar,
body.ui-hidden #debug-anomaly-panel,
body.ui-hidden #btn-reset-game-hud,
body.ui-hidden #btn-trigger-anomaly-hud,
body.ui-hidden #btn-grant-keystone-hud,
body.ui-hidden #mastery-toast-container,
body.ui-hidden #ad-simulator,
body.ui-hidden #gameplay-prompt {
  display: none !important;
}

/* Custom dialog overlay system */
.custom-dialog-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7); /* Transparent black background */
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 99999; /* Ensure it is above all screens, panels and tooltips */
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.custom-dialog-overlay:not(.hidden) {
  opacity: 1;
  pointer-events: auto;
}

.custom-dialog-content {
  background: transparent;
  border: none;
  box-shadow: none;
  padding: 32px;
  max-width: 580px;
  width: 90%;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  transform: scale(0.9) translateY(10px);
  transition: transform 0.25s cubic-bezier(0.25, 1, 0.5, 1);
}

.custom-dialog-overlay:not(.hidden) .custom-dialog-content {
  transform: scale(1) translateY(0);
}

.custom-dialog-title {
  font-size: 24px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 16px;
  color: #ff99c8; /* Neon pink theme highlight */
  text-shadow: 0 0 12px rgba(255, 153, 200, 0.6);
}

.custom-dialog-content.confirm-theme .custom-dialog-title {
  color: #e4c1f9; /* Light purple for confirm themes */
  text-shadow: 0 0 12px rgba(228, 193, 249, 0.6);
}

.custom-dialog-content.info-theme .custom-dialog-title {
  color: #a9def9; /* Light blue for info/alert themes */
  text-shadow: 0 0 12px rgba(169, 222, 249, 0.6);
}

.custom-dialog-message {
  font-size: 15px;
  line-height: 1.6;
  color: #cbd5e1;
  margin-bottom: 28px;
  white-space: pre-line; /* Support newlines in alert messages */
  font-family: 'Outfit', sans-serif;
  letter-spacing: 0.02em;
}

/* Ascension dots in HUD */
.ascension-dots-container {
  display: flex;
  gap: 4px;
  margin-top: 4px;
  justify-content: center;
}

.ascension-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: #00f3ff;
  box-shadow: 0 0 6px #00f3ff, 0 0 12px rgba(0, 243, 255, 0.6);
  display: inline-block;
}

/* Rewarded Ad Locked and Disabled Buttons */
.btn:disabled,
.btn.locked-ad {
  background: rgba(255, 255, 255, 0.05) !important;
  border-color: rgba(255, 255, 255, 0.1) !important;
  color: rgba(255, 255, 255, 0.3) !important;
  cursor: not-allowed !important;
  transform: none !important;
  box-shadow: none !important;
  animation: none !important;
  text-shadow: none !important;
}

.btn:disabled .ad-icon,
.btn.locked-ad .ad-icon {
  filter: grayscale(1) opacity(0.3) !important;
}

/* ==========================================================================
   Narrow-screen layout (small phones, 320-480px)
   ========================================================================== */

/* Stack end-screen buttons vertically so they never overflow the card */
@media (max-width: 480px) {
  .button-group {
    flex-direction: column;
    align-items: stretch;
  }

  .btn {
    max-width: none;
    width: 100%;
  }
}

/* Compact HUD so rank/level/progress/taps don't collide on small phones */
@media (max-width: 420px) {
  .hud-layer {
    width: 96%;
  }

  .hud-item .label {
    font-size: 8px;
    letter-spacing: 0.5px;
  }

  .hud-item .value {
    font-size: 14px;
  }

  .progress-container {
    margin: 0 8px;
    max-width: 34%;
  }

  .exp-label {
    font-size: 8px;
  }

  .hud-stats-row {
    padding: 10px 14px;
  }

  .hud-anomaly-row {
    padding: 6px 14px 8px;
  }

  .anomaly-row-label {
    font-size: 8px;
    letter-spacing: 1px;
  }

  .anomaly-row-name {
    font-size: 10px;
    letter-spacing: 1px;
  }

  .anomaly-row-desc {
    font-size: 10px;
    max-width: 100%;
  }

  .overlay-prompt {
    font-size: 12px;
    padding: 12px 20px;
    letter-spacing: 1px;
    max-width: 92vw;
    white-space: normal;
    text-align: center;
  }
}


