* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Responsive type scale using clamp() so UI scales across viewports and DPRs.
   Tweak these variables to tune type across all games. */
:root {
        --fs-xxs: clamp(0.7rem, 2.5vw, 1rem);
    --fs-xs: clamp(0.6rem, 1.8vw, 0.825rem);
    --fs-sm: clamp(0.9rem, 3vw, 1.25rem);
    --fs-md: clamp(0.6rem, 1.6vw, 1.3rem);
    --fs-lg: clamp(1.2rem, 4vw, 1.75rem);
    --fs-xl: clamp(1.5rem, 5vw, 2.5rem);
    --fs-2xl: clamp(2rem, 6vw, 3rem);
}

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

body {
    font-family: 'Arial', sans-serif;
    font-size: 1rem;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    height: 100vh;
    width: 100vw;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    color: white;
    margin: 0;
    padding: 0;
    position: fixed;
    top: 0;
    left: 0;
    -webkit-text-size-adjust: none;
    -moz-text-size-adjust: none;
    text-size-adjust: none;
}

.game-container {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    height: 100%;
    max-width: 100vw;
    max-height: 100vh;
    overflow: hidden;
    position: relative;
    max-width: 700px;
}

/* Section styles */
.instructions-section, .game-section {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
}

/* Improved menu-logo-container with responsive width behavior:
   - On tall/normal screens: takes full width (100%)
   - On short screens where content would overflow: reduces width to fit content vertically */
.menu-logo-container {
    position: relative;
    width: 100%;
    max-width: 100%;
    max-height: 95vh;
    padding: clamp(0.5rem, 2vh, 1.5rem);
    /* display: flex;
    flex-direction: column; */
    align-items: center;
    justify-content: center;
    overflow-y: auto;
    overflow-x: hidden;
    box-sizing: border-box;
    gap: clamp(0.3rem, 1vh, 0.8rem);
    text-align: center;
}


.menu-logo {
  position: absolute;
  left: 0.75rem;
  top: 0.5rem;
  width: clamp(2.5rem, 9vw, 5rem);
  height: auto;
  object-fit: contain;
  display: block;
  z-index: 20;
  pointer-events: auto;
}

.game-section {
    display: none;
}

/* When the game section is shown we'll use a three-row grid: top / canvas / bottom */
.game-section.show {
    display: flex !important;
    align-items: center;
    justify-content: center;
    height: 100%;
    width: 100%;
}

/* The internal grid that divides the game into top / middle / bottom rows */
.game-grid {
    height: calc(100% - 1rem);
    max-height: 92vh;
    width: 100%;
    max-width: 900px;
    display: grid;
    grid-template-rows: minmax(100px, 15vh) 1fr minmax(80px, 15vh);
    gap: 0.5rem;
    align-items: stretch;
    overflow: hidden;
    margin: 0.5rem auto;
    padding: 0.5rem;
    box-sizing: border-box;
}

h1 {
    margin-bottom: clamp(0.3rem, 1vh, 0.75rem);
    font-size: var(--fs-xl);
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
}


.top-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.15rem;
    /* overflow: hidden; */
    flex-shrink: 0;
    max-height: 15vh;
}

.top-section h1 {
    margin-bottom: 0.15rem;
    font-size: var(--fs-md);
}

.objective {
    background: rgba(255, 255, 255, 0.2);
    padding: clamp(0.5rem, 1.5vh, 0.9375rem);
    border-radius: 0.9375rem;
    font-size: var(--fs-xs);
    line-height: 1.4;
    border: 0.125rem solid rgba(255, 215, 0, 0.3);
    text-align: center;
    width: 100%;
}

.bubble-legend {
    margin-bottom: clamp(0.5rem, 2vh, 1.25rem);
    /* display: flex;
    flex-direction: column; */
    align-items: center;
    width: 100%;
    gap: clamp(0.2rem, 0.8vh, 0.5rem);
}


.bubble-legend h3 {
    font-size: var(--fs-md);
    color: #FFD700;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
    text-align: center;
    width: 100%;
}


.legend-item {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    font-size: var(--fs-xs);
    text-align: left;
    justify-content: center;
    margin-bottom: clamp(0.2rem, 0.5vh, 0.3rem);
    width: 100%;
    max-width: 600px;
    justify-content: left;
}

.learning-block {
    font-size: var(--fs-md);
}

.legend-bubble {
    width: 1.175rem;
    height: 1.175rem;
    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);
    flex-shrink: 0;
}

.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;
    margin-bottom: 0.25rem;
    font-size: var(--fs-sm);
    font-weight: 700;
    flex-wrap: wrap;
}

.score, .timer {
    background: rgba(255, 255, 255, 0.18);
    padding: 0.35rem 0.65rem;
    border-radius: 0.5rem;
    border: 0.125rem solid #FFD700;
    flex: 0 0 auto;
    min-width: 5.5rem;
    font-size: var(--fs-xs);
}

.middle-section {
    height: 100%;
    min-height: 0;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 1;
}

.canvas-container {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    height: 100%;
    min-height: 0;
    max-width: 100%;
    max-height: 100%;
    overflow: hidden;
    box-sizing: border-box;
}

#gameCanvas {
    border: 0.1875rem solid #FFD700;
    border-radius: 0.75rem;
    background: linear-gradient(to bottom, #87CEEB 0%, #98FB98 100%);
    display: block;
    box-shadow: 0 0.25rem 0.5rem rgba(0, 0, 0, 0.18);
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    cursor: pointer;
    box-sizing: border-box;
}

.controls {
    font-size: 1rem;
    margin-bottom: 0.9375rem;
    padding: 0 0.625rem;
}

.replay-btn {
    background: linear-gradient(45deg, #FF6B6B, #4ECDC4);
    border: none;
    color: white;
    padding: clamp(0.5rem, 1.5vh, 0.75rem) clamp(0.8rem, 3vw, 1.5rem);
    font-size: var(--fs-xs);
    border-radius: 1.5625rem;
    cursor: pointer;
    box-shadow: 0 0.25rem 0.75rem rgba(0, 0, 0, 0.2);
    transition: transform 0.2s;
    margin: 0.25rem;
    white-space: nowrap;
    flex-shrink: 1;
}

.start-btn {
    background: linear-gradient(45deg, #4ECDC4, #44A08D);
    border: none;
    color: white;
    padding: clamp(0.6rem, 2vh, 0.9375rem) clamp(1rem, 3vw, 1.875rem);
    font-size: var(--fs-md);
    border-radius: 1.5625rem;
    cursor: pointer;
    box-shadow: 0 0.25rem 0.9375rem rgba(0, 0, 0, 0.2);
    transition: transform 0.2s;
    margin: clamp(0.5rem, 2vh, 1.25rem) 0.3125rem;
}


.back-btn {
    background: linear-gradient(45deg, #667eea, #764ba2);
    border: none;
    color: white;
    padding: clamp(0.5rem, 1.5vh, 0.75rem) clamp(0.8rem, 3vw, 1.5rem);
    font-size: var(--fs-xs);
    border-radius: 1.25rem;
    cursor: pointer;
    box-shadow: 0 0.25rem 0.75rem rgba(0, 0, 0, 0.2);
    transition: transform 0.2s;
    margin: 0.25rem;
    white-space: nowrap;
    flex-shrink: 1;
}

.hint-btn {
    background: linear-gradient(45deg, #FFA726, #FB8C00);
    border: none;
    color: white;
    padding: clamp(0.5rem, 1.5vh, 0.625rem) clamp(0.8rem, 3vw, 1.25rem);
    font-size: var(--fs-xs);
    border-radius: 1.25rem;
    cursor: pointer;
    box-shadow: 0 0.25rem 0.9375rem rgba(0, 0, 0, 0.2);
    transition: transform 0.2s;
    margin: 0.3125rem;
    flex-shrink: 1;
}

/* Color coding reminder styles */
.color-reminder {
    display: flex;
    justify-content: center;
    gap: clamp(0.2rem, 1vw, 0.5rem);
    margin-bottom: 0.25rem;
    flex-wrap: nowrap;
    font-size: clamp(0.6rem, 2vw, 0.75rem);
    font-weight: bold;
    width: 100%;
}

.color-item {
    display: flex;
    align-items: center;
    gap: clamp(0.15rem, 0.5vw, 0.3125rem);
    background: rgba(255, 255, 255, 0.15);
    padding: clamp(0.2rem, 0.8vw, 0.3125rem) clamp(0.3rem, 1.2vw, 0.625rem);
    border-radius: 0.9375rem;
    white-space: nowrap;
    flex-shrink: 1;
}

.color-dot {
    width: 0.75rem;
    height: 0.75rem;
    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: clamp(0.3rem, 1.5vw, 0.75rem);
    flex-wrap: nowrap;
    align-items: center;
    padding: 0.5rem;
    width: 100%;
}

.bottom-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow: visible;
    flex-shrink: 0;
    margin-bottom: 0.5rem;
    z-index: 100;
}

.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);
}
