/* Modern Game UI - WaspBuster */
@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@400;700&display=swap');

body {
  margin: 0;
  padding: 0;
  background-color: #222;
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100vh;
  font-family: 'Outfit', sans-serif;
  color: white;
  overflow: hidden;
}

#game-container {
  position: relative;
  box-shadow: 0 0 30px rgba(0, 0, 0, 0.7);
  border: 4px solid #333;
  border-radius: 4px;
  overflow: hidden; /* Ensure UI stays within bounds */
}

canvas {
  background-color: #4da64d;
  display: block;
  cursor: crosshair;
}

#ui-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

/* --- Stats Panel (Top Right) --- */
#stats-panel {
  position: absolute;
  top: 10px;
  right: 10px;
  width: auto; /* Fit content */
  left: auto; /* Remove left anchor */
  background: rgba(20, 20, 30, 0.4);
  -webkit-backdrop-filter: blur(5px);
  backdrop-filter: blur(5px);
  padding: 4px 8px; /* Very compact */
  border-radius: 20px; /* Rounder for pill look? User didn't ask but looks better small */
  display: flex;
  align-items: center;
  gap: 15px; /* Separation between stats and buttons */
  font-weight: 700;
  font-size: 16px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 4px 6px rgba(0,0,0,0.3);

  align-items: center;
  pointer-events: auto; /* Fix for clicking */
  z-index: 1001; /* Above pause overlay */
  cursor: pointer; /* Click to minimize */
  transition: all 0.3s ease;
  overflow: hidden;
}

#stats-panel.collapsed {
  padding: 8px;
  gap: 0;
  background: rgba(20, 20, 30, 0.2);
}

#stats-panel.collapsed .stats-group {
    display: none;
}



.controls-group {
    display: flex;
    gap: 8px;
}

.stats-group {
    display: flex;
    gap: 8px; /* Reduced from 15px */
}

.top-bar-btn {
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255,255,255,0.3);
  color: #fff;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  transition: all 0.2s;
  z-index: 100;
}

.top-bar-btn:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: scale(1.1);
}

#stats-panel span {
  display: flex;
  align-items: center;
  gap: 8px;
}

#money-display { color: #ffd700; min-width: 50px; text-align: right; }
#wave-display { color: #ff5555; min-width: 60px; text-align: left;}
#watermelon-display { color: #ff88aa; min-width: 80px; text-align: right; } /* Fruit display */

/* --- Controls Panel (Bottom) --- */
/* --- Side Menu (Pop-out) --- */
#controls-container {
    position: absolute;
    bottom: 10px;
    left: 20px;
    /* transform: translateX(-50%); Removed to align left */
    display: flex;
    align-items: flex-end;
    gap: 10px;
    z-index: 50;
    pointer-events: none; /* Let clicks pass through container (interactables set to auto) */
    width: max-content;
    max-width: 100%;
}

#tower-toggle-btn {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #FFD700, #FFA500);
    border: 3px solid #fff;
    color: #333;
    font-size: 28px;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(0,0,0,0.5);
    transition: transform 0.2s, background 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

#tower-toggle-btn:hover {
    transform: scale(1.1);
    background: linear-gradient(135deg, #FFE700, #FFB500);
}

/* Make interactable elements auto */
#tower-toggle-btn { pointer-events: auto; }
#controls-panel { pointer-events: auto; }

#controls-panel {
    background: rgba(30, 30, 40, 0.4);
    -webkit-backdrop-filter: blur(5px);
    backdrop-filter: blur(5px);
    border-radius: 12px;
    padding: 10px;
    display: flex;
    gap: 8px; /* Reduced gap */
    align-items: center;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 8px 32px rgba(0,0,0,0.6);
    flex-wrap: wrap; /* Safety wrap */
    justify-content: center;
    
    /* Animation helper */
    transform-origin: bottom left;
    transition: opacity 0.3s ease, transform 0.3s ease;
}

#controls-panel.hidden-panel {
    opacity: 0;
    transform: scale(0.8) translateX(-20px);
    pointer-events: none;
}

.tower-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
}

.tower-label {
    color: #ccc;
    font-size: 10px;
    text-align: center;
    line-height: 1.2;
    font-weight: 600;
}

.tower-btn {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255,255,255,0.2);
  color: #eee;
  padding: 0;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  cursor: pointer;
  font-family: 'Outfit', sans-serif;
  font-weight: 600;
  font-size: 1.5rem;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.tower-btn:hover {
  background: rgba(255, 255, 255, 0.25);
  transform: translateY(-5px);
  border-color: #fff;
  box-shadow: 0 0 10px rgba(255,255,255,0.2);
}

.tower-btn:active {
  transform: scale(0.95);
}

/* Separator & Old btn styles removed from here */

#info-desc {
    font-style: italic;
    color: #aaa;
    margin-top: 5px;
}

#info-upgrade-btn {
    /* width: 100%;  Managed by flex */
    /* margin-top: 10px; Managed by container */
    border-radius: 8px; 
    height: auto;
    aspect-ratio: auto;
    padding: 10px;
    font-size: 16px;
    background: #ffcc00;
    color: black;
    text-transform: uppercase;
    letter-spacing: 1px;
    border: none;
    font-weight: 700;
}

#info-upgrade-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(255, 204, 0, 0.4);
    background: #ffdb4d;
}

.info-btn-container {
    display: flex;
    gap: 8px;
    width: 100%;
    margin-top: 10px;
}

.upgrade-col {
    flex: 3; /* 3/4 Width */
}

.sell-col {
    flex: 1; /* 1/4 Width (1/3 of upgrade) */
    border-radius: 8px;
    height: auto;
    aspect-ratio: auto; /* Override circular default */
    padding: 0; /* Centered text */
    font-size: 12px !important;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 700;
    
    background: rgba(255, 68, 68, 0.2) !important;
    border: 1px solid #ff4444 !important;
    color: #ff4444 !important;
    transition: all 0.2s;
}
.sell-col:hover {
    background: #ff4444 !important;
    color: white !important;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(255, 68, 68, 0.3);
}

.hidden { display: none !important; }

/* --- Game Over --- */
#game-over-screen {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: rgba(10, 10, 10, 0.95);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  pointer-events: auto;
  z-index: 20;
}

#game-over-screen h1 {
  font-size: 64px;
  margin-bottom: 10px;
  background: linear-gradient(to bottom, #ff4444, #aa0000);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

#restart-btn {
  padding: 15px 40px;
  font-size: 20px;
  background: #4caf50;
  color: white;
  border: none;
  font-family: 'Outfit', sans-serif;
  font-weight: bold;
  border-radius: 50px;
  cursor: pointer;
  box-shadow: 0 4px 15px rgba(76, 175, 80, 0.4);
  transition: transform 0.2s;
}
#restart-btn:hover { transform: scale(1.05); }

/* --- Pause Overlay --- */
#pause-overlay {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.4);
    -webkit-backdrop-filter: blur(5px);
    backdrop-filter: blur(5px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    pointer-events: none;
}
#pause-overlay h1 {
    font-size: 60px;
    color: white;
    letter-spacing: 5px;
    text-shadow: 0 4px 10px rgba(0,0,0,0.5);
    font-weight: 900;
}

/* --- Info Box --- */
#info-box {
    position: absolute;
    background: rgba(20, 20, 30, 0.95);
    border: 1px solid #444;
    padding: 15px;
    border-radius: 8px;
    color: white;
    font-size: 14px;
    display: none;
    z-index: 100;
    pointer-events: auto; /* Allow clicking buttons inside */
    min-width: 150px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.5);
}
#info-box h3 {
    margin: 0 0 10px 0;
    color: #ffd700;
    border-bottom: 1px solid #444;
    padding-bottom: 5px;
}
#info-box p { margin: 5px 0; color: #ccc; }
#info-box .stat { display: flex; justify-content: space-between; }
#info-box .val { color: #fff; font-weight: bold; }

/* Old classes removed or overridden above */

.disabled-tower {
    filter: grayscale(100%) !important;
    opacity: 0.3 !important;
    pointer-events: none; /* Prevent clicks */
    border-color: rgba(255,255,255,0.1) !important;
}

/* Ensure hover doesn't break style when disabled */
.tower-btn.disabled-tower:hover {
    transform: none;
    box-shadow: none;
    background: rgba(255, 255, 255, 0.1);
}




/* --- Orientation Overlay --- */
#orientation-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: #222;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    color: white;
    text-align: center;
}

#orientation-overlay .phone-icon {
    font-size: 80px;
    margin-bottom: 20px;
    animation: rotate-phone 2s infinite ease-in-out;
}

#orientation-overlay p {
    font-size: 24px;
    font-weight: bold;
    font-family: 'Outfit', sans-serif;
}

@keyframes rotate-phone {
    0% { transform: rotate(0deg); }
    25% { transform: rotate(-90deg); }
    50% { transform: rotate(-90deg); }
    75% { transform: rotate(0deg); }
    100% { transform: rotate(0deg); }
}

@keyframes pulse-red {
    0% { box-shadow: 0 0 0 0 rgba(255, 68, 68, 0.7); }
    70% { box-shadow: 0 0 0 10px rgba(255, 68, 68, 0); }
    100% { box-shadow: 0 0 0 0 rgba(255, 68, 68, 0); }
}

.highlight-recharge {
    animation: pulse-red 1.5s infinite;
    background: #ff4444 !important; /* Force red attention */
    color: white !important;
}

/* --- Scaling Wrapper --- */
#game-container {
    transform-origin: center center; /* Scale from center */
    transition: transform 0.2s ease-out; /* Smooth resize */
}

/* --- Intro Screen --- */
#intro-screen {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.85);
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    text-align: center;
}

.intro-content {
    background: rgba(255, 255, 255, 0.1);
    padding: 40px;
    border-radius: 20px;
    border: 1px solid rgba(255,255,255,0.2);
    max-width: 600px;
    box-shadow: 0 0 50px rgba(0,0,0,0.5);
}

.intro-content h1 {
    font-size: 72px;
    margin: 0 0 20px 0;
    background: linear-gradient(135deg, #FFD700, #FFA500);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 4px 10px rgba(0,0,0,0.5));
}

.story-text {
    font-size: 18px;
    line-height: 1.6;
    color: #eee;
    margin-bottom: 40px;
}

#start-game-btn {
    padding: 20px 60px;
    font-size: 32px;
    background: linear-gradient(135deg, #4caf50, #45a049);
    color: white;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    font-family: 'Outfit', sans-serif;
    font-weight: 900;
    letter-spacing: 2px;
    box-shadow: 0 10px 30px rgba(76, 175, 80, 0.4);
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

#start-game-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 15px 40px rgba(76, 175, 80, 0.6);
}

.version-tag {
    position: absolute;
    bottom: 10px;
    right: 15px;
    font-size: 14px;
    color: rgba(255, 255, 255, 0.4);
    font-family: monospace;
    pointer-events: none;
}
