* {
    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, #FF6B9D 0%, #C44569 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    color: white;
}

.game-container {
    /* layout: three vertical rows (top / middle / bottom)
       - top-row: title + game-info (small)
       - middle-row: canvas container (flex: 1) -> takes remaining space
       - bottom-row: controls + buttons (small)
    */
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    text-align: center;
    height: 100vh; /* fill viewport so middle can flex */
    max-width: 1100px;
    margin: 0 auto;
    padding: 0.8rem;
    justify-content: center;
}

h1 {
    margin-bottom: 5px;
    font-size: var(--fs-xl);
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
}

.game-info {
    display: flex;
    justify-content: space-between;
    margin-bottom: 20px;
    font-size: var(--fs-md);
    font-weight: bold;
    flex-wrap: wrap;
    gap: 0.7rem;
}

.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;
}

.score, .temptations, .timer {
    background: rgba(255, 255, 255, 0.2);
    padding: 0.6rem 1.2rem;
    border-radius: 0.7rem;
    border: 0.14rem solid #FFD700;
    flex: 1;
    min-width: 120px;
    font-size: var(--fs-sm);
}

.top-row {
    flex: 0 0 auto;
    padding: 0.6rem 0;
}

.middle-row {
    flex: 1 1 auto; /* take remaining vertical space */
    display: flex;
    align-items: stretch;
    justify-content: center;
    padding: 0.4rem 0;
    min-height: 48vh; /* ensure canvas area is tall enough on most viewports */
}

.bottom-row {
    flex: 0 0 auto;
    padding: 0.6rem 0;
}

.canvas-container {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    margin: 0 auto;
    height: 100%; /* let the middle-row determine height */
    min-height: 40vh; /* fallback minimum for smaller screens */
}

#gameCanvas {
    border: 0.21rem solid #FFD700;
    border-radius: 0.7rem;
    background: linear-gradient(to bottom, #87CEEB 0%, #98FB98 100%);
    display: block;
    box-shadow: 0 0.28rem 0.57rem rgba(0, 0, 0, 0.3);
    width: 100%;
    height: 100%; /* JS will set backing buffer; CSS stretch to container */
    max-height: 100%;
}

.controls {
    /* margin-top: 1.4rem; */
    font-size: var(--fs-sm);
}

.replay-btn {
    background: linear-gradient(45deg, #FF6B6B, #4ECDC4);
    border: none;
    color: white;
    padding: 1.07rem 2.14rem;
    font-size: var(--fs-md);
    border-radius: 1.8rem;
    cursor: pointer;
    margin: 0.7rem;
    box-shadow: 0 0.28rem 1.07rem rgba(0, 0, 0, 0.2);
    transition: transform 0.2s;
    justify-self: center;
    width: max-content;
    place-self: center;
}

.replay-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

.replay-btn:active {
    transform: translateY(0);
}

@keyframes pulse {
    from { transform: scale(1); }
    to { transform: scale(1.05); }
}

.hidden {
    display: none;
}

.page-container {
    min-height: 100vh;
    /* display: flex; */
    /* justify-content: center;
    align-items: center; */
    width: 100%;
    align-content: center;
}

.instructions-content {
    text-align: left;
    /* max-width: 600px; */
    margin: 0 auto;
    padding: 0.7rem;

    background: rgba(255, 255, 255, 0.2);
    padding: 0.9375rem;
    border-radius: 0.9375rem;
    margin-bottom: 1.25rem;
    font-size: var(--fs-md);
    line-height: 1.5;
    border: 0.125rem solid rgba(255, 215, 0, 0.3);
}

.simple-instructions {
    place-self: anchor-center;
}

.instructions-content h2 {
    text-align: center;
    margin-bottom: 2rem;
    font-size: 1.6rem;
    color: #FFD700;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
}

.instruction-section {
    background: rgba(255, 255, 255, 0.1);
    padding: 1.4rem;
    border-radius: 1.07rem;
    margin-bottom: 1.4rem;
    border: 0.14rem solid rgba(255, 215, 0, 0.3);
}

.instruction-section h3 {
    color: #FFD700;
    margin-bottom: 1rem;
    font-size: 1.1rem;
}

.instruction-section p, .instruction-section li {
    font-size: 0.95rem;
    line-height: 1.6;
    margin-bottom: 0.7rem;
}

.instruction-section ul {
    padding-left: 20px;
}

.instruction-section ul li {
    margin-bottom: 8px;
}

.back-btn {
    background: linear-gradient(45deg, #6c757d, #495057);
    border: none;
    color: white;
    padding: 0.7rem 1.4rem;
    font-size: 0.95rem;
    border-radius: 1.43rem;
    cursor: pointer;
    margin-top: 1.07rem;
    box-shadow: 0 0.28rem 1.07rem rgba(0, 0, 0, 0.2);
    transition: transform 0.2s;
}

.back-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

.back-btn:active {
    transform: translateY(0);
}

/* Button row to align start and back buttons horizontally with equal height */
.button-row {
    display: flex;
    gap: 0.86rem;
    justify-content: center;
    align-items: stretch; /* make children the same height */
    /* margin-top: 0.86rem; */
}

.button-row .replay-btn,
.button-row .back-btn {
    /* unify height and vertical padding so both buttons match exactly */
    padding: 0.86rem 1.86rem;
    height: 3.43rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 1.71rem;
}
