/* Container - Main Wrapper */
#bubble-math-container {
  font-family: 'Segoe UI', Arial, sans-serif;
  background: #f0faff;
  padding: 15px;
  border-radius: 12px;
  max-width: 950px;
  margin: 0 auto;
  box-sizing: border-box;
}

/* 1. RESTORED HUD (Top Bar) 
   Balanced spacing for Level, Score, and Time */
.bm-hud {
  display: flex;
  justify-content: space-around;
  background: #fff;
  padding: 15px;
  border-radius: 8px;
  margin-bottom: 20px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.05);
  font-weight: bold;
  font-size: 18px;
  color: #333;
}

.bm-hud span {
  min-width: 120px; /* Prevents layout shifting when numbers change */
  text-align: center;
}

/* 2. BODY LAYOUT 
   Flex structure for Sidebar | Game Area | Calculator */
.bm-body {
  display: flex;
  gap: 15px;
  align-items: flex-start;
}

/* 3. SIDEBAR FIX 
   Controlled width to prevent level text distortion */
#bm-sidebar {
  width: 110px;
  flex-shrink: 0;
}

#bm-levels {
  padding: 0;
  margin: 0;
}

#bm-levels li {
  list-style: none;
  margin-bottom: 8px;
  padding: 10px 5px;
  border-radius: 6px;
  color: #fff;
  text-align: center;
  font-size: 13px;
  font-weight: bold;
  white-space: nowrap; /* Forces text to stay on one line */
  box-shadow: inset 0 -2px 0 rgba(0,0,0,0.1);
}

/* 4. GAME AREA 
   Optimized height for laptop screens */
#bm-game-area {
  position: relative;
  flex-grow: 1;
  height: 420px; 
  background-color: #ffffff;
  border: 2px solid #87ceeb;
  border-radius: 8px;
  overflow: hidden; /* Important: keeps balloons inside */
}

/* 5. CALCULATOR COLUMN & BUTTON PLACEMENT 
   Start button is now moved here, above the number pad */
#bm-calculator {
  width: 180px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Action Buttons (Start/Reset) */
.bm-action-controls {
  display: flex;
  flex-direction: column;
}

.bm-action-controls button {
  width: 100%;
  padding: 12px;
  font-size: 14px;
  font-weight: bold;
  cursor: pointer;
  border: none;
  border-radius: 6px;
  color: white;
  transition: transform 0.1s, opacity 0.2s;
}

#bm-start-btn { background-color: #28a745; }
#bm-reset-btn { background-color: #dc3545; }

.bm-action-controls button:active {
  transform: scale(0.98);
}

/* Display Box */
#bm-calc-display {
  width: 100%;
  height: 45px;
  font-size: 24px;
  text-align: right;
  padding: 5px 10px;
  border: 2px solid #2196f3;
  border-radius: 6px;
  box-sizing: border-box;
  background: #fff;
  color: #333;
}

/* Number Pad */
#bm-calc-buttons .bm-row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 6px;
}

#bm-calc-buttons button {
  width: 31%;
  padding: 12px 0;
  font-size: 18px;
  font-weight: bold;
  cursor: pointer;
  border: none;
  border-radius: 4px;
  background: #2196f3;
  color: white;
}

#bm-calc-buttons button:hover {
  background: #1976d2;
}

/* 6. BALLOON ANIMATION FIXES */
.bm-balloon-wrapper {
  position: absolute;
  bottom: -70px; /* Start just below the game area */
  text-align: center;
  animation: bm-float-up linear forwards;
}

@keyframes bm-float-up {
  from { transform: translateY(0); }
  to { transform: translateY(-550px); } /* Ensures they clear the top */
}

.bm-balloon {
  width: 45px;
  height: auto;
  display: block;
  margin: 0 auto;
}

.bm-label {
  display: block;
  margin-top: -32px; /* Pulls text up into the balloon body */
  font-weight: bold;
  font-size: 14px;
  color: #333;
  position: relative;
  z-index: 5;
}

/* 7. POPUP MESSAGE */
#bm-message-box {
  display: none;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: white;
  padding: 30px;
  border-radius: 15px;
  box-shadow: 0 0 20px rgba(0,0,0,0.3);
  text-align: center;
  z-index: 1000;
  width: 250px;
}

#bm-message-box button {
  margin-top: 15px;
  padding: 10px 20px;
  background: #2196f3;
  color: white;
  border: none;
  border-radius: 5px;
  cursor: pointer;
}
/* Start Overlay Styling */
#bm-start-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7); /* Dim the game board */
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 50;
    border-radius: 6px;
}

.bm-rules-card {
    background: white;
    padding: 25px;
    border-radius: 12px;
    max-width: 80%;
    box-shadow: 0 10px 25px rgba(0,0,0,0.2);
    text-align: left;
}

.bm-rules-card h2 {
    margin-top: 0;
    color: #2196f3;
    text-align: center;
}

.bm-rules-card ul {
    margin: 15px 0;
    padding-left: 20px;
}

.bm-rules-card li {
    margin-bottom: 10px;
    font-size: 14px;
    line-height: 1.4;
    color: #444;
}

#bm-start-btn {
    display: block;
    width: 100%;
    padding: 12px;
    background: #28a745;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: background 0.2s;
}

#bm-start-btn:hover {
    background: #218838;
}