* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Responsive type scale using clamp() so UI scales across viewports and DPRs. */
: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(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; }

body {
    font-family: 'Arial', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: flex-start; /* ensure page content starts at top so full-height game doesn't overflow */
    color: white;
}

.game-container {
    /* keep layout simple for mobile/desktop */
    text-align: center;
    align-self: center;
    width: 100%;
    height: 100%;
}

/* Layout: make game container a column so canvas can take remaining height */
.game-section {
    display: flex;
    flex-direction: column;
    /* max-width: 1100px; */
    margin: 0 auto;
    height: 100vh;
}

.menu-logo-container {
    position: relative;
    width: 100%;
    height: 100%;
    align-content: center;
    padding: 20px;
    max-width: 900px;
}

.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;
}

.top-row {
    flex: 0 0 auto;
}

.middle-row {
    flex: 1 1 auto; /* take remaining vertical space */
    display: flex;
    align-items: stretch;
    justify-content: center;
    /* padding: 0.4rem 0; */
}

.bottom-row {
    flex: 0 0 auto;
}

/* Section styles */
.instructions-section, .game-section {
    width: 100vw;
    height: 100vh;
    align-content: center;
    padding: 20px;
}

.game-section {
    display: none;
}

h1 {
    margin-bottom: 10px;
    font-size: var(--fs-xl);
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
}

.objective {
    background: rgba(255, 255, 255, 0.2);
    padding: 15px;
    border-radius: 15px;
    margin-bottom: 20px;
    font-size: var(--fs-md);
    /* line-height: 1.5; */
    border: 2px solid rgba(255, 215, 0, 0.3);

    max-width: 640px;
    margin: 20px auto;
}

.game-rules {
    background: rgba(255, 255, 255, 0.15);
    padding: 20px;
    border-radius: 15px;
    margin-bottom: 20px;
    text-align: left;
}

.game-rules h3 {
    text-align: center;
    margin-bottom: 15px;
    color: #FFD700;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
}

.game-rules ul {
    list-style: none;
    padding-left: 0;
}

.game-rules li {
    margin-bottom: 8px;
    padding-left: 20px;
    position: relative;
}

.game-rules li:before {
    content: "→";
    position: absolute;
    left: 0;
    color: #FFD700;
    font-weight: bold;
}

.game-info {
    display: flex;
    justify-content: space-between;
    margin-bottom: 1rem; /* ~14px */
    font-size: var(--fs-md);
    font-weight: bold;
    flex-wrap: wrap;
    gap: 0.9rem; /* ~13px */
    align-items: center;
}

.score, .timer {
    background: rgba(255, 255, 255, 0.18);
    padding: 0.45rem 0.9rem; /* ~6px 13px */
    border-radius: 0.9rem; /* ~12px */
    border: 0.14rem solid #FFD700; /* ~2px */
    flex: 0 0 auto;
    min-width: 8.5rem; /* ~150px -> 10.7rem previously; slightly smaller */
    font-size: var(--fs-sm);
    margin: 0 0.25rem;
}

.score span, .timer span {
    font-weight: 800;
}

.canvas-container {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    height: 100%; /* fill middle-row */
}

#gameCanvas {
    border: 0.21rem solid #FFD700; /* ~3px */
    border-radius: 1.07rem; /* ~15px */
    background: #2C3E50;
    display: block;
    box-shadow: 0 0.28rem 0.57rem rgba(0, 0, 0, 0.3); /* ~4px/8px */
    width: 100%;
    height: 100%; /* fill canvas-container */
    max-height: 100%;
}

.controls {
    font-size: var(--fs-sm); /* slightly smaller */
}

.start-btn {
    background: linear-gradient(45deg, #4ECDC4, #44A08D);
    border: none;
    color: white;
    padding: 1.07rem 2.14rem; /* ~15px 30px */
    font-size: var(--fs-md); /* slightly smaller */
    border-radius: 1.79rem; /* ~25px */
    cursor: pointer;
    box-shadow: 0 0.28rem 1rem rgba(0, 0, 0, 0.2);
    transition: transform 0.2s;
}

.replay-btn {
    background: linear-gradient(45deg, #FF6B6B, #4ECDC4);
    border: none;
    color: white;
    padding: 1.07rem 2.14rem;
    font-size: 1.05rem;
    border-radius: 1.79rem;
    cursor: pointer;
    box-shadow: 0 0.28rem 1rem rgba(0, 0, 0, 0.2);
    transition: transform 0.2s;
    margin: 0.35rem; /* ~5px */
}

.back-btn {
    background: linear-gradient(45deg, #667eea, #764ba2);
    border: none;
    color: white;
    padding: 0.71rem 1.43rem; /* ~10px 20px */
    font-size: 0.95rem;
    border-radius: 1.43rem; /* ~20px */
    cursor: pointer;
    box-shadow: 0 0.28rem 1rem rgba(0, 0, 0, 0.2);
    transition: transform 0.2s;
    margin: 0.35rem; /* ~5px */
}

.game-buttons {
    display: flex;
    justify-content: center;
    gap: 0.71rem; /* ~10px */
    flex-wrap: wrap;
    margin-top: 1.07rem; /* ~15px */
}

.start-btn:hover, .replay-btn:hover, .back-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

.start-btn:active, .replay-btn:active, .back-btn:active {
    transform: translateY(0);
}