:root {
    --fs-xxs: 2.0vh;
    --fs-xs:  2.2vh;
    --fs-sm:  2.0vh;
    --fs-md:  3vh;
    --fs-lg:  4vw;
    --fs-xl:  5vh;
    --fs-2xl: clamp(3vw, 6vw, 4.5vw);
}

html {
  overflow: hidden;
  height: 100vh;
  width: 100vw;
  -webkit-text-size-adjust: none;
  -moz-text-size-adjust: none;
  text-size-adjust: none;
}

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    height: 100vh;
    width: 100vw;
    overflow: hidden;
    position: fixed;
    top: 0;
    left: 0;
    -webkit-text-size-adjust: none;
    -moz-text-size-adjust: none;
    text-size-adjust: none;
}

#root {
    width: 100%;
    min-height: 100vh;
}

.App {
    width: 100%;
    min-height: 100vh;
    margin: 0;
    padding: 0;
}


.budget-game {
  margin: 0 auto;
  font-family: 'Arial', sans-serif;
  color: white;
  padding: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: stretch;
  height: 100vh;
  width: 100%;
}


/* Common button styles */
.start-btn, .menu-btn, .hint-btn, .reset-btn, .done-btn, .music-btn, .pause-btn {
  border: none;
  color: white;
  padding: clamp(0.7vh, 1.5vh, 1.1vh) clamp(1.2vw, 3vw, 2.2vw);
  font-size: var(--fs-sm);
  border-radius: 1.8vw;
  font-weight: bold;
  cursor: pointer;
  box-shadow: 0 0.4vh 0.7vh rgba(0, 0, 0, 0.2);
  /* transition: all 0.3s ease; */
  white-space: nowrap;
  flex-shrink: 1;
}

.start-btn, .pause-btn { background: linear-gradient(45deg, #4ECDC4, #44A08D); }
.menu-btn { background: linear-gradient(45deg, #32CD32, #228B22); }
.hint-btn { background: linear-gradient(45deg, #FF9800, #F57C00); }
.reset-btn, .done-btn, .music-btn { background: linear-gradient(45deg, #32CD32, #228B22); }

.start-btn:hover, .menu-btn:hover, .hint-btn:hover, .reset-btn:hover, .done-btn:hover, .music-btn:hover {
  transform: translateY(-0.2vh);
  box-shadow: 0 0.5vh 1vh rgba(0, 0, 0, 0.3);
}

.gameplay-screen {
  width: 100%;
  height: 100vh;
  display: grid;
  grid-template-rows: 10% 90%;
  overflow: hidden;
}

.items-container {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.game-header {
  /* Header layout: left = budget-display, center = timer, right = game-controls.
     Uses a single flex container; timer is centered with absolute centering so
     it stays visually centered regardless of left/right content. */
  display: flex;
  width: 100%;
  justify-content: space-between;
  align-items: center;
  background: rgba(255,255,255,0.15);
  padding: clamp(0.7vh, 1.5vh, 1.1vh) clamp(0.7vw, 2vw, 1.5vw);
  border-radius: 0;
  backdrop-filter: blur(0.9vw);
  margin: 0;
  top: 0;
  position: relative;
  min-height: 3vh;
}

.game-info {
  display: flex;
  flex-direction: column;
  gap: 0.9vh;
}

.budget-display {
  display: flex;
  gap: 0.7vw;
  font-size: var(--fs-sm);
  font-weight: bold;
  align-items: center;
  margin-left: 1.5vw;
}

/* budget-display sits at the left edge of the header */
.game-header .budget-display { justify-content: flex-start; }

.spent {
  color: #FFD700;
}

.budget {
  color: #98FB98;
}

.remaining {
  color: #F0E68C;
}

.timer {
  /* Center timer visually in header. On narrow screens it falls back to normal flow. */
  font-size: var(--fs-md);
  font-weight: bold;
  color: #FF6B6B;
  text-align: center;
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 2;
  pointer-events: none;
}

.game-controls { display: flex; gap: 0.7vw; }
.game-header .game-controls { margin-left: auto; margin-right: 1.8vw; }

/* Header control buttons */
.game-header .done-btn {
  padding: 0.7vh 1.8vw;
  height: 3.8vh;
  border-radius: 3vw;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: var(--fs-xs);
}

.game-header .pause-btn,
.game-header .resume-btn {
  padding: 0;
  width: 3.8vh;
  height: 3.8vh;
  min-width: 3.8vh;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: var(--fs-sm);
}





.game-area {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  flex: 1;
  width: 100%;
  overflow: auto;
}

.welcome-screen {
  /* position this card so absolutely-positioned children (menu logo)
     are anchored to the welcome card rather than the whole page */
  position: relative;
  text-align: center;
  align-content: center;
  width: 100%;
  height: 100%;
  place-items: center;
}

.welcome-text { 
    margin: 0;
    padding: 1.5vh;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 1.4vw;
    margin-bottom: 1.8vh;
    font-size: var(--fs-md);
    line-height: 1.5;
    border: 0.2vw solid rgba(255, 215, 0, 0.3);
    max-width: 65vw;
    /* max-height: 55vh; */
}

.welcome-screen h2 {
  font-size: var(--fs-lg);
  margin: 0;
  color: #FFD700;
  text-shadow: 0.2vw 0.2vw 0.4vw rgba(0, 0, 0, 0.3);
  margin-bottom: 1.1vh;
}

/* Match Coin_Catch menu title sizing and the boxed instruction look */
.welcome-screen h1 {
  margin-bottom: 1.1vh;
  font-size: var(--fs-2xl);
  color: #FFD700;
  text-shadow: 0.3vw 0.3vw 0.6vw rgba(0,0,0,0.5);
}

.welcome-screen .objective {
  background: rgba(255,255,255,0.12);
  padding: 1.4vh;
  border-radius: 1.4vw;
  margin: 1.1vh auto 1.8vh auto;
  font-size: var(--fs-md);
  line-height: 1.45;
  border: 0.2vw solid rgba(255,215,0,0.28);
  max-width: 95vw;
  text-align: left;
}

.welcome-screen .objective p { text-align: left; margin: 0.7vh 0; }

/* Small logo anchored to the welcome card's bottom-right. Keeps image aspect ratio
   via height:auto and uses a clamp() width so it stays small on mobile and modest on desktop. */
.menu-logo {
  position: absolute;
  left: 1.1vw;
  top: 0.7vh;
  width: clamp(3.5vw, 9vw, 7vw);
  height: auto;
  object-fit: contain;
  display: block;
  z-index: 20;
  pointer-events: auto;
}

.welcome-screen p {
  font-size: var(--fs-sm);
  margin: 0.9vh;
  line-height: 1.6;
  text-align: center;
}

/* Ensure objective uses the same size as Coin_Catch and keep text comfortable */
.welcome-screen .objective { font-size: var(--fs-md); }

.welcome-screen ul {
  text-align: left;
  max-width: 55vw;
  margin: 0 auto;
  font-size: var(--fs-md);
  line-height: 1.6;
}

.welcome-screen li {
  margin-bottom: 0.7vh;
}

.items-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-auto-rows: 1fr;
  gap: 0.7vw;
  width: 100%;
  max-width: 85vw;
  align-content: start;
  padding: 1.5vh;
  box-sizing: border-box;
  overflow-y: auto;
  max-height: 100%;
  -webkit-overflow-scrolling: touch;
}

.item-card {
  background: rgba(255, 255, 255, 0.9);
  color: #333;
  border-radius: 1.1vw;
  text-align: center;
  cursor: pointer;
  /* transition: all 0.3s ease; */
  box-shadow: 0 0.4vh 0.7vh rgba(0, 0, 0, 0.2);
  position: relative;
  overflow: hidden;
  border: 0.3vw solid #CCC;
  display: flex;
  flex-direction: column;
  align-items: stretch; /* allow children to stretch horizontally */
  /* gap: 0.5rem; */
  box-sizing: border-box;
  /* allow card to grow/shrink to fit grid cell; use max constraints so it doesn't explode */
  width: 100%;
  max-width: 100%;
  height: 100%;
  max-height: 18vh;
  min-height: 0; /* allow compression inside flex/grid */
}

.item-card:hover {
  transform: translateY(-0.5vh);
  box-shadow: 0 0.7vh 1.5vh rgba(0, 0, 0, 0.3);
}

.item-icon {
  font-size: 5vh; /* slightly smaller so icons scale better */
  margin-bottom: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  flex: 0 0 auto; /* keep icon from stretching vertically */
  filter: drop-shadow(0.2vw 0.2vw 0.4vw rgba(0, 0, 0, 0.1));
}

.item-card.purchased {
  opacity: 0.6;
  transform: scale(0.95);
  cursor: not-allowed;
}

.item-card.purchased:hover {
  transform: scale(0.95);
}

.item-name {
  font-size: var(--fs-xxs);
  font-weight: bold;
  margin: 0.3vh 0 0.15vh 0;
  line-height: 1.2;
  /* make name flexible so it can take remaining vertical space */
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.item-price {
  font-size: var(--fs-xxs);
  font-weight: 700;
  color: #2E8B57;
  margin: 0.35vh 0 0.3vh 0;
  flex: 0 0 auto; /* price should not stretch */
}

.purchased-overlay {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(34, 139, 34, 0.9);
  color: white;
  padding: 0.7vh 1.5vw;
  border-radius: 1.8vw;
  font-weight: bold;
  font-size: var(--fs-md);
}

.game-over-screen {
  text-align: center;
  padding: 0.9vh;
}

.game-over-screen h2 {
  font-size: var(--fs-2xl);
  margin: 0;
  text-shadow: 0.2vw 0.2vw 0.4vw rgba(0, 0, 0, 0.3);
}

.game-over-screen.win h2 {
  color: #32CD32;
}

.game-over-screen.lose h2 {
  color: #FF6B6B;
}

.game-message {
  font-size: var(--fs-md);
  font-weight: bold;
  margin-bottom: 2.8vh;
  padding: 1.8vh;
  border-radius: 0.9vw;
  background: rgba(255, 255, 255, 0.1);
}

/* .final-stats {
  background: rgba(255, 255, 255, 0.1);
  padding: 1.25rem;
  border-radius: 0.625rem;
  margin: 1.25rem auto;
  max-width: 25rem;
} */

.final-stats p {
  font-size: var(--fs-md);
  margin-bottom: 0.9vh;
}

.game-end-controls {
  margin: 1.8vh 0;
}

.hint-display {
  background: rgba(255, 255, 255, 0.1);
  padding: 1.8vh;
  border-radius: 0.9vw;
  margin-top: 1.4vh;
  text-align: left;
  max-width: 46vw;
  margin-left: auto;
  margin-right: auto;
}

.hint-display h4 {
  color: #FFD700;
  margin-bottom: 0.9vh;
  font-size: var(--fs-md);
}

.hint-display ul {
  list-style: disc;
  padding-left: 1.8vw;
  margin-bottom: 1.4vh;
}

.hint-display li {
  margin-bottom: 0.5vh;
  font-size: var(--fs-sm);
}

.how-to-play {
  background: rgba(255, 255, 255, 0.1);
  padding: 1.8vh;
  border-radius: 0.9vw;
  margin-top: 1.8vh;
  text-align: left;
  max-width: 55vw;
  margin-left: auto;
  margin-right: auto;
}

.how-to-play h3 {
  color: #FFD700;
  margin-bottom: 1.4vh;
  font-size: var(--fs-lg);
  text-align: center;
}

.how-to-play ul {
  list-style: disc;
  padding-left: 1.8vw;
}

.how-to-play li {
  margin-bottom: 0.7vh;
  font-size: var(--fs-sm);
  line-height: 1.5;
}

.game-instructions {
  background: rgba(255, 255, 255, 0.1);
  padding: 1.8vh;
  border-radius: 0.9vw;
  backdrop-filter: blur(0.9vw);
  margin-top: 1.8vh;
}

.game-instructions h3 {
  color: #FFD700;
  margin-bottom: 1.4vh;
  font-size: var(--fs-lg);
}

.game-instructions ul {
  list-style: none;
  padding: 0;
}

.game-instructions li {
  margin-bottom: 0.7vh;
  font-size: var(--fs-sm);
  line-height: 1.5;
}




/* Animation for item purchase */
@keyframes purchase {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.1);
  }
  100% {
    transform: scale(0.95);
  }
}

.item-card.purchased {
  animation: purchase 0.3s ease-out;
}

/* Timer warning animation */
@keyframes timer-warning {
  0%, 100% {
    color: #FF6B6B;
  }
  50% {
    color: #FF0000;
    transform: scale(1.1);
  }
}

.timer.warning {
  animation: timer-warning 1s infinite;
}

/* Pause Popup Styles */
.pause-popup-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  backdrop-filter: blur(0.5vw);
}

.pause-popup {
  background: linear-gradient(135deg, #2E8B57 0%, #3CB371 100%);
  border-radius: 1.8vw;
  padding: 0;
  box-shadow: 0 1.8vh 3.5vh rgba(0, 0, 0, 0.3);
  border: 0.3vw solid rgba(255, 255, 255, 0.2);
  max-width: 46vw;
  width: 90%;
  max-height: 90vh;
  overflow: hidden;
  animation: popup-appear 0.3s ease-out;
}

@keyframes popup-appear {
  from {
    opacity: 0;
    transform: scale(0.8) translateY(-4.5vh);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.pause-popup-header {
  background: rgba(255, 255, 255, 0.1);
  padding: 1.8vh 2.3vw;
  border-bottom: 0.2vh solid rgba(255, 255, 255, 0.1);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.pause-popup-header h2 {
  margin: 0;
  color: white;
  font-size: var(--fs-lg);
  font-weight: bold;
}

.close-btn {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: white;
  width: 3.2vh;
  height: 3.2vh;
  border-radius: 50%;
  cursor: pointer;
  font-size: var(--fs-md);
  display: flex;
  align-items: center;
  justify-content: center;
  /* transition: all 0.3s ease; */
}

.close-btn:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: scale(1.1);
}

.pause-popup-content {
  padding: 2.3vh;
  color: white;
  overflow: auto;
}

.pause-popup-content p {
  text-align: center;
  font-size: var(--fs-md);
  margin-bottom: 2.3vh;
  color: rgba(255, 255, 255, 0.9);
}

.pause-stats {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 1.4vw;
  padding: 1.8vh;
  margin-bottom: 2.3vh;
}

.stat-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.7vh 0;
  border-bottom: 0.1vh solid rgba(255, 255, 255, 0.1);
}

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

.stat-label {
  font-weight: bold;
  color: rgba(255, 255, 255, 0.8);
}

.stat-value {
  font-weight: bold;
  color: #FFD700;
  font-size: var(--fs-sm);
}

.pause-popup-actions {
  display: flex;
  gap: 1.4vw;
  justify-content: center;
  flex-wrap: wrap;
}

.resume-btn-popup {
  background: linear-gradient(45deg, #00CED1, #008B8B);
  color: white;
  border: none;
  padding: 1.4vh 2.3vw;
  border-radius: 4.5vw;
  font-size: var(--fs-md);
  font-weight: bold;
  cursor: pointer;
  /* transition: all 0.3s ease; */
  box-shadow: 0 0.4vh 1.1vh rgba(0, 206, 209, 0.3);
  display: flex;
  align-items: center;
  gap: 0.7vw;
  min-width: 13vw;
  justify-content: center;
}

.resume-btn-popup:hover {
  background: linear-gradient(45deg, #008B8B, #006666);
  transform: translateY(-0.2vh) scale(1.05);
  box-shadow: 0 0.5vh 1.5vh rgba(0, 206, 209, 0.4);
}

/* Game Over Buttons */
.game-over-buttons {
  display: flex;
  gap: clamp(0.5vw, 1.5vw, 1.1vw);
  justify-content: center;
  margin-top: 2.8vh;
  flex-wrap: nowrap;
}

.game-over-buttons .start-btn,
.game-over-buttons .menu-btn,
.game-over-buttons .hint-btn {
  margin: 0.35vh;
}