* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Base font sizing: reduce slightly so everything scales down a bit */
html { font-size: 0.7rem; } /* was 16px — reduced ~6% */

body {
    font-family: 'Arial', sans-serif;
    font-size: 1rem; /* consistent base text size */
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: stretch; /* allow .game-container to fill vertical space */
    color: white;
}

.game-container {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 1.25rem; /* 20px */
    padding: 1.25rem; /* 20px */
    backdrop-filter: blur(10px);
    box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.37);
    border: 1px solid rgba(255, 255, 255, 0.18);
    text-align: center;
    max-width: 900px;
    width: 100%;
    margin: 0; /* fill the viewport without extra margins */
    /* Make the container fill the viewport height so grid can use full space */
    height: 100vh;
    max-height: none;
    overflow: hidden; /* prevent outer scrolling while game is active */
}

/* Section styles */
.instructions-section, .game-section {
    width: 100%;
}

.game-section {
    display: none;
}

/* When the game section is shown we'll use a three-row grid: top / canvas / bottom */
.game-section.show {
    display: block; /* keep block so inner .game-grid controls layout */
    height: 100%;
    width: 100%;
}

/* The internal grid that divides the game into top / middle / bottom rows */
.game-grid {
    height: 100%;
    display: grid;
    grid-template-rows: auto 1fr auto; /* top, middle (flexible), bottom */
    gap: 0.75rem;
    align-items: stretch;
    width: 100%;
}

h1 {
    margin-bottom: 0.75rem; /* 12px */
    font-size: 1.8rem; /* consistent using rem */
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
}

.objective {
    background: rgba(255, 255, 255, 0.2);
    padding: 0.9375rem; /* 15px */
    border-radius: 0.9375rem; /* 15px */
    margin-bottom: 1.25rem; /* 20px */
    font-size: 1.1rem;
    line-height: 1.5;
    border: 0.125rem solid rgba(255, 215, 0, 0.3);
}

.bubble-legend {
    margin-bottom: 20px;
    flex-direction: column;
}

.bubble-legend h3 {
    margin-bottom: 15px;
    font-size: 1.3em;
    color: #FFD700;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.625rem; /* 10px */
    background: rgba(255, 255, 255, 0.1);
    padding: 0.625rem 0.9375rem; /* 10px 15px */
    border-radius: 0.625rem; /* 10px */
    font-size: 1rem;
    font-weight: bold;
    margin-bottom: 0.625rem; /* 10px */
    text-align: left;
    justify-content: flex-start;
}

.legend-bubble {
    width: 1.875rem; /* 30px */
    height: 1.875rem; /* 30px */
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: bold;
    color: white;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
}

.legend-bubble.green {
    background: linear-gradient(135deg, #4CAF50, #45a049);
}

.legend-bubble.yellow {
    background: linear-gradient(135deg, #FFD700, #FFA500);
}

.legend-bubble.blue {
    background: linear-gradient(135deg, #2196F3, #1976D2);
}

.game-info {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.75rem; /* 12px */
    margin-bottom: 0.625rem; /* 10px */
    font-size: 1.15rem;
    font-weight: 700;
    flex-wrap: wrap;
}

.score, .timer {
    background: rgba(255, 255, 255, 0.18);
    padding: 0.5rem 0.875rem; /* 8px 14px */
    border-radius: 0.75rem; /* 12px */
    border: 0.125rem solid #FFD700;
    flex: 0 0 auto;
    min-width: 6.875rem; /* 110px */
}

.middle-section {
    height: 100%;
}

.canvas-container {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    margin: 0 auto;
    height: 100%; /* fill the middle grid row */
    max-height: none;
}

#gameCanvas {
    border: 0.1875rem solid #FFD700; /* 3px */
    border-radius: 0.75rem; /* 12px */
    background: linear-gradient(to bottom, #87CEEB 0%, #98FB98 100%);
    display: block;
    box-shadow: 0 0.25rem 0.5rem rgba(0, 0, 0, 0.18); /* 4px/8px */
    width: 100%;
    height: 100%; /* fill its container (middle section) */
    max-width: none;
    max-height: none;
    cursor: pointer;
}

.controls {
    font-size: 1rem;
    margin-bottom: 0.9375rem; /* 15px */
    padding: 0 0.625rem; /* 10px */
}

.replay-btn {
    background: linear-gradient(45deg, #FF6B6B, #4ECDC4);
    border: none;
    color: white;
    padding: 0.9375rem 1.875rem; /* 15px 30px */
    font-size: 1.2rem;
    border-radius: 1.5625rem; /* 25px */
    cursor: pointer;
    box-shadow: 0 0.25rem 0.9375rem rgba(0, 0, 0, 0.2); /* 4px 15px */
    transition: transform 0.2s;
    margin: 0.3125rem; /* 5px */
}

.start-btn {
    background: linear-gradient(45deg, #4ECDC4, #44A08D);
    border: none;
    color: white;
    padding: 0.9375rem 1.875rem; /* 15px 30px */
    font-size: 1.2rem;
    border-radius: 1.5625rem; /* 25px */
    cursor: pointer;
    box-shadow: 0 0.25rem 0.9375rem rgba(0, 0, 0, 0.2);
    transition: transform 0.2s;
    margin: 1.25rem 0.3125rem; /* 20px 5px */
}

.back-btn {
    background: linear-gradient(45deg, #667eea, #764ba2);
    border: none;
    color: white;
    padding: 0.625rem 1.25rem; /* 10px 20px */
    font-size: 1rem;
    border-radius: 1.25rem; /* 20px */
    cursor: pointer;
    box-shadow: 0 0.25rem 0.9375rem rgba(0, 0, 0, 0.2);
    transition: transform 0.2s;
    margin: 0.3125rem; /* 5px */
}

.hint-btn {
    background: linear-gradient(45deg, #FFA726, #FB8C00);
    border: none;
    color: white;
    padding: 0.625rem 1.25rem; /* 10px 20px */
    font-size: 1rem;
    border-radius: 1.25rem; /* 20px */
    cursor: pointer;
    box-shadow: 0 0.25rem 0.9375rem rgba(0, 0, 0, 0.2);
    transition: transform 0.2s;
    margin: 0.3125rem; /* 5px */
}

/* Color coding reminder styles */
.color-reminder {
    display: flex;
    justify-content: center;
    gap: 1.25rem; /* 20px */
    margin-bottom: 0.9375rem; /* 15px */
    flex-wrap: wrap;
    font-size: 0.9rem;
    font-weight: bold;
}

.color-item {
    display: flex;
    align-items: center;
    gap: 0.3125rem; /* 5px */
    background: rgba(255, 255, 255, 0.15);
    padding: 0.3125rem 0.625rem; /* 5px 10px */
    border-radius: 0.9375rem; /* 15px */
}

.color-dot {
    width: 0.75rem; /* 12px */
    height: 0.75rem; /* 12px */
    border-radius: 50%;
    display: inline-block;
}

.color-dot.green {
    background-color: #4CAF50;
}

.color-dot.yellow {
    background-color: #FFD700;
}

.color-dot.blue {
    background-color: #2196F3;
}

.game-buttons {
    display: flex;
    justify-content: center;
    gap: 0.5rem; /* 8px */
    flex-wrap: nowrap;
    margin-top: 0.5rem; /* 8px */
    align-items: center;
}

.replay-btn:hover, .start-btn:hover, .back-btn:hover, .hint-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.24);
}

.replay-btn:active, .start-btn:active, .back-btn:active, .hint-btn:active {
    transform: translateY(0);
}

/* Mobile Responsive Styles */
@media screen and (max-width: 768px) {
    
    .game-container {
        padding: 0.9375rem; /*15px*/
        margin: 0.3125rem; /*5px*/
        border-radius: 0.9375rem; /*15px*/
    }
    
    h1 {
        font-size: 1.6rem; /* smaller on mobile */
        margin-bottom: 0.75rem; /*12px*/
    }
    
    .bubble-legend {
        align-items: center;
        gap: 10px;
    }
    
    .score, .timer {
        padding: 0.375rem 0.75rem; /*6px 12px*/
        width: auto;
        max-width: none;
        margin: 0;
    }
    
    .canvas-container {
        width: 100%;
        max-width: 100%;
        overflow: hidden;
    }
    
    #gameCanvas {
        width: 100%;
        max-width: 100%;
        height: auto;
        border-width: 0.125rem; /*2px*/
    }
  
    
    .objective {
        font-size: 1rem;
        padding: 0.75rem; /*12px*/
        margin-bottom: 0.9375rem; /*15px*/
    }
}