/* Set BG and color palette variables */
body {
  --bg: #1f2326;
  /* dark gray */
  --panel: #2a2d31;
  /* slightly lighter */
  --accent: #ffd43b;
  /* yellow */
  --muted: #bdbdbd;
  /* light gray */
  --text: #ffffff;

  background-color: var(--bg);
  background-image: linear-gradient(180deg, rgba(255, 255, 255, 0.02) 0%, transparent 40%), url('./images/bg.png');
  background-repeat: no-repeat;
  background-size: cover;
  background-position: center;
  background-attachment: fixed;
  scrollbar-color: var(--accent) #222;
}

/* Other setups */
body {
  height: 100vh;
}

/* Center Level Button */
#level-btn {
  text-align: center;
}

/* Center Button */
#clicker-btn {
  display: block;
  margin: 0 auto;
  width: fit-content;
}

/* Make the moon image responsive and constrained to viewport */
#moon {
  display: block;
  width: min(520px, 80vw);
  max-width: 90vw;
  height: auto;
  margin: 0 auto;
}

/* Make clicker button match moon size to avoid overflow and layout shifts */
#clicker-btn {
  padding: 0;
  border: none;
  background: transparent;
}

/* Container for both shops */
#shops {
  display: flex;
  flex-direction: column;
  gap: 20px;
  margin-right: 30px;
  /* Keep shops in normal flow (not sticky) so they don't move while scrolling */
  position: static;
  top: auto;
  align-self: flex-start;
}

/* Shared shop styling */
.shop-section {
  width: 260px;
  max-height: 40vh;
  /* each takes half the screen roughly */
  border-left: 3px solid var(--accent);
  box-shadow: -4px 6px 18px rgba(0, 0, 0, 0.6);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.02), transparent);
  overflow-y: auto;
  /* allows scrolling inside */
  scrollbar-width: thin;
  scrollbar-color: var(--accent) #222;
}

/* custom scrollbar (for WebKit browsers) */
.shop-section::-webkit-scrollbar {
  width: 8px;
}

.shop-section::-webkit-scrollbar-thumb {
  background-color: #ffcc00;
  border-radius: 4px;
}

.upgrade-button {
  position: relative;
  overflow: visible !important;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.04);
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.upgrade-button:hover {
  transform: translateY(-4px);
  background: rgba(255, 212, 59, 0.06);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.6);
}

#upgrade-click:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.6);
}

/* Make sure main body aligns clicker + shops side by side */
#body {
  display: flex;
  justify-content: center;
  align-items: flex-start;
}

/* Responsive: stack shops below clicker on mobile */
@media (max-width: 992px) {
  #body {
    flex-direction: column;
    align-items: center;
  }

  /* On phones stack shops vertically under the clicker */
  #shops {
    flex-direction: column;
    width: 100%;
    justify-content: center;
  }

  .shop-section {
    width: 100%;
    max-height: 270px;
    /* roughly fits 4 buttons + title */
    border-left: 3px solid #ffcc00;
    box-shadow: -2px 0 8px rgba(255, 204, 0, 0.3);
    overflow-y: auto;
    /* makes it scrollable */
    scrollbar-width: thin;
    scrollbar-color: #ffcc00 #222;
    border-radius: 10px;
  }
}

/* Header layout improvements */
header.d-flex {
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

header.d-flex {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.02), transparent);
  padding: 10px 0;
}

header.d-flex .fs-4 {
  color: var(--accent);
  font-weight: 800;
}

/* Shop headings and warning buttons use the accent color */
.shop-section h3,
h3.text-warning {
  color: var(--accent) !important;
}

.btn.btn-warning {
  background: linear-gradient(180deg, var(--accent), #e6b800);
  border-color: rgba(0, 0, 0, 0.15);
  color: #000;
}

.btn.btn-warning:hover {
  filter: brightness(0.95);
}

/* Ensure header doesn't overlap content */
section#header {
  position: relative;
  z-index: 50;
}

/* On small screens stack header elements vertically */
@media (max-width: 768px) {
  header.d-flex {
    flex-direction: column;
    align-items: center;
  }

  #music-center {
    order: 2;
    margin: 6px 0;
  }

  header .me-md-auto {
    order: 1;
  }

  header .btn.btn-warning {
    order: 3;
  }
}

/* Touch-only: remove pointer cursors to avoid 'hand' flicker on mobile */
@media (hover: none) {

  button,
  .upgrade-button,
  .transparent-button {
    cursor: default;
  }
}

/* Ensure shops have breathing room on small screens */
@media (max-width: 576px) {
  #shops {
    padding-bottom: 20px;
  }

  .shop-section {
    margin-bottom: 18px;
  }
}


/* First Centering Method */
/* @media (max-width: 575px) {
  #moon {
    margin-left: -140px;
  }
} */

/* @media (min-width: 576px) and (max-width: 767px) {
  #moon {
    margin-left: -120px;
  }
} 

/* @media (min-width: 768px) and (max-width: 991px) {
  #moon {
    margin-left: -60px;
  }
} */

/* @media (min-width: 992px) and (max-width: 1199px) {
  #moon {
    margin-left: -10px;
  }
} */

/* @media (min-width: 1200px) and (max-width: 1919px) {
  #moon {
    margin-left: 80px;
  }
} */

/* @media (min-width: 1920px) {
  #moon {
    margin-left: 200px;
  }
} */

/* Make the clicker area taller */

/* Make the clicker area taller */
#clicker-area {
  height: 85vh;
}

/* Make the button transperent */
.transparent-button {
  background-color: transparent;
  border: none;
  color: #000;
  padding: 10px 20px;
  cursor: pointer;
}

/* animations */
#moon {
  transition: transform 0.1s ease;
}

/* Make the moon grow if a mouse hovers on it. */
#moon:hover {
  transform: scale(1.05);
}

/* Make the moon bounce when clicked */
#clicker-btn:active #moon {
  transform: scale(1.02);
}

.cheese-popup {
  position: fixed;
  pointer-events: none;
  display: flex;
  align-items: center;
  gap: 4px;
  font-weight: bold;
  font-size: 18px;
  z-index: 9999;
}

.popup-text {
  color: #ffd43b;
  /* cheese-ish yellow */
  text-shadow: 0 0 6px #0006;
}

.fade-out-up {
  animation: fadeOutUp 1s ease-out forwards;
}

@keyframes fadeOutUp {
  0% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }

  100% {
    opacity: 0;
    transform: translateY(-200px) scale(0.7);
  }
}

/* Meteor animation */
.meteor-shower {
  position: absolute;
  top: 0;
  left: 0;
  width: 20px;
  height: 20px;
  pointer-events: none;
  animation: meteor linear forwards;
}

.meteor {
  position: absolute;
  top: 0;
  left: 0;
  width: 250px;
  height: 250px;
  pointer-events: auto;
  animation: meteor linear 3s forwards;
}

@keyframes meteor {
  0% {
    transform: translateX(var(--startX)) translateY(-50px);
  }
  100% {
    transform: translateX(var(--endX, var(--startX))) translateY(var(--endY));
  }
}

.meteor img, .meteor-shower img {
  width: 100%;
  height: 100%;
}

.meteor button {
  padding: 0;
  border: none;
  background: transparent;
}


/* Upgrade tooltip styling */
.upgrade-tooltip {
  position: absolute;
  background: rgba(23, 23, 23, 0.98);
  color: var(--accent);
  border: 1px solid rgba(255, 212, 59, 0.9);
  padding: 10px 12px;
  border-radius: 8px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.6);
  z-index: 10000;
  pointer-events: none;
  /* don't block mouse events */
  max-width: 90vw;
  min-width: 140px;
  font-weight: 600;
  font-size: 13px;
  line-height: 1.2;
}

.upgrade-tooltip .ut-title {
  color: #fff;
  font-weight: 800;
  margin-bottom: 6px;
}

.upgrade-tooltip .ut-meta {
  color: #ffd43b;
}

.upgrade-tooltip .ut-owned {
  color: #ffffff;
  font-weight: 700;
  margin-left: 4px;
}

/* Small fade & slide effect */
.upgrade-tooltip {
  transform: translateY(6px);
  transition: transform 120ms ease, opacity 120ms ease;
  opacity: 0;
}

.upgrade-tooltip.show {
  transform: translateY(0);
  opacity: 1;
}

/* RTL adjustments when Hebrew is active */
.rtl-text .upgrade-tooltip {
  direction: rtl;
  text-align: right;
}

.rtl-text header.d-flex {
  text-align: right;
}

/* Make images inside upgrade buttons non-interactable so hover/clicks hit the button */
.upgrade-button img {
  pointer-events: none;
  -webkit-user-drag: none;
  user-select: none;
}

/* Spawned upgrade icon that appears on the moon */
.moon-upgrade {
  position: absolute;
  width: 56px;
  height: 56px;
  pointer-events: none;
  transform: translate(-50%, -50%) scale(0.9);
  z-index: 9998;
  opacity: 0;
  transition: transform 260ms ease, opacity 260ms ease;
}

.moon-upgrade.show {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

/* Chill floating: small up/down bob and subtle rotation so icons 'sit' on the moon */
@keyframes chill {
  0% {
    transform: translate(-50%, -50%) translateY(0) rotate(-2deg) scale(1);
  }

  50% {
    transform: translate(-50%, -50%) translateY(-8px) rotate(2deg) scale(1.02);
  }

  100% {
    transform: translate(-50%, -50%) translateY(0) rotate(-2deg) scale(1);
  }
}

.moon-upgrade.chill {
  animation: chill 3000ms ease-in-out infinite;
}

/* Hint the browser to use higher-quality scaling for small icons */
.moon-upgrade,
.moon-upgrade img {
  image-rendering: -webkit-optimize-contrast;
  image-rendering: crisp-edges;
  image-rendering: pixelated;
}

/* Music control styles */
.music-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.music-toggle {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.03), rgba(255, 255, 255, 0.01));
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.06);
  padding: 6px 10px;
  border-radius: 20px;
  font-weight: 700;
  min-width: 54px;
}

.music-toggle[aria-pressed="true"] {
  background: linear-gradient(180deg, rgba(255, 212, 59, 0.15), rgba(255, 212, 59, 0.06));
  color: white;
  border-color: rgba(255, 212, 59, 0.9);
}

.music-toggle:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #ffcc00;
}

.mute-wrapper {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.music-mute {
  background: transparent;
  border: none;
  color: var(--accent);
  font-size: 18px;
  padding: 6px;
  border-radius: 8px;
  cursor: pointer;
}

.music-mute:hover {
  background: rgba(255, 255, 255, 0.03);
}

.volume-popout {
  position: absolute;
  right: 100%;
  top: 50%;
  transform: translateY(-50%);
  background: var(--panel);
  padding: 8px;
  border-radius: 8px;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.6);
  display: none;
  white-space: nowrap;
}

.volume-popout .form-range {
  width: 140px;
}

.mute-wrapper:hover .volume-popout,
.mute-wrapper:focus-within .volume-popout {
  display: block;
}

@media (max-width: 576px) {
  #music-center {
    gap: 6px;
  }

  #music-volume {
    width: 110px;
  }

  #music-toggle,
  #music-mute {
    height: 30px;
    min-width: 34px;
    font-size: 14px;
  }
}

/* Mobile centering improvements */
@media (max-width: 768px) {

  /* Stack header elements and center them */
  header.d-flex {
    flex-direction: column;
    align-items: center;
    text-align: center;
  }

  header.d-flex>a {
    margin-bottom: 6px;
  }

  #music-center {
    margin: 6px 0;
  }

  /* Ensure the clicker area and moon are centered */
  #clicker-area {
    width: 100%;
    display: flex;
    justify-content: center;
  }

  #clicker {
    display: flex;
    flex-direction: column;
    align-items: center;
  }

  #cheese-count,
  #cps {
    text-align: center;
  }

  /* Make shops full width and centered under the moon */
  #shops {
    width: 100%;
    padding: 0 12px;
    box-sizing: border-box;
  }

  .shop-section {
    margin: 12px auto;
    width: calc(100% - 24px);
    max-width: 720px;
  }
}

.text-popup {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%); /* perfectly center */
    color: #fff;
    font-size: 24px;
    pointer-events: none;
    z-index: 9999;
    text-align: center;
}