* {
    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.65rem, 1.2vw, 0.85rem);
    --fs-xs:  clamp(0.8rem, 1.0vw, 0.95rem);
    --fs-sm:  clamp(0.95rem, 1.3vw, 1.05rem);
    --fs-md:  clamp(1.1rem, 1.6vw, 1.15rem);
    --fs-lg:  clamp(1.25rem, 2.2vw, 1.6rem);
    --fs-xl:  clamp(1.8rem, 3.6vw, 2.2rem);
    --fs-2xl: clamp(2.2rem, 5vw, 2.8rem);
}

html { 
    font-size: 1.2rem;
    overflow: hidden;
    height: 100vh;
    width: 100vw;
}

body {
    font-family: 'Arial', sans-serif;
    font-size: 1rem; /* consistent base text size */
    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;
}

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

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

.menu-logo-container {
    position: relative;
    width: 100%;
    max-width: 900px;
    max-height: 90vh;
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    overflow-y: auto;
    overflow-x: hidden;
}

.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: 0.75rem; /* 12px */
    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: 0.9375rem; /* 15px */
    border-radius: 0.9375rem; /* 15px */
    font-size: var(--fs-xs);
    line-height: 1.5;
    border: 0.125rem solid rgba(255, 215, 0, 0.3);
    text-align: center;
    width: 100%;
}

.bubble-legend {
    margin-bottom: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
}

.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; /* 10px */
    font-size: var(--fs-xs);
    text-align: center;
    justify-content: center;
    margin-bottom: 5px;
    width: 100%;
    max-width: 600px;
}

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

.legend-bubble {
    width: 1.175rem; /* 30px */
    height: 1.175rem; /* 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;
    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; /* 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%;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    cursor: pointer;
    box-sizing: border-box;
}

.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.75rem 1.5rem;
    font-size: var(--fs-sm);
    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;
}

.start-btn {
    background: linear-gradient(45deg, #4ECDC4, #44A08D);
    border: none;
    color: white;
    padding: 0.9375rem 1.875rem; /* 15px 30px */
    font-size: var(--fs-md);
    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.75rem 1.5rem;
    font-size: var(--fs-sm);
    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;
}

.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: 0.5rem;
    margin-bottom: 0.25rem;
    flex-wrap: wrap;
    font-size: 0.75rem;
    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.75rem;
    flex-wrap: wrap;
    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;
    /* min-height: 80px;
    max-height: 15vh;
    padding: 0.5rem 0.5rem 0.75rem 0.5rem; */
    margin-bottom: 0.5rem;
    z-index: 100;
    /* background: rgba(102, 126, 234, 0.2); */
    /* border-radius: 0.5rem; */
}

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