/* --- Basic Setup --- */
* {
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 10px;
    font-family: 'Poppins', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: #051032; /* Match sketch background */
    color: #f0f0f0;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 100vh;
}

/* --- 1. Explanation --- */
#explanation {
    width: 100%;
    max-width: 550px; /* Match canvas width */
    margin: 10px 0;
    text-align: center;
    font-size: 0.8rem;
    line-height: 1.5;
}

#explanation h2 {
    margin: 0 0 10px 0;
    color: #fff;
}

#explanation p {
    margin: 5px 0;
    color: #a8c4e6;
}

/* --- 2. Canvas Wrapper (for responsiveness) --- */
#canvas-wrapper {
    width: 100%;
    max-width: 550px; /* Max width from your sketch */
    margin: 0 auto;
    border: 1px solid #1a295c;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

/* This targets the canvas p5.js creates */
#canvas-wrapper > canvas {
    display: block;
    width: 100% !important;
    height: auto !important; /* Maintain aspect ratio */
}

/* --- 3. Tooltip --- */
.tooltip {
    font-size: 0.9rem;
    font-weight: 300;
    color: #fff;
    text-align: center;
    margin: 15px 0 20px 0;
    padding: 8px 15px;
    background-color: #1a296c;
    border-radius: 5px;
    min-height: 1.5em; /* Prevent layout shift while loading */
}

/* --- 4. Footer --- */
footer {
    width: 100%;
    max-width: 550px; /* Match canvas width */
    margin: 40px auto 20px auto; /* Add space above it */
    padding: 20px;
    border-top: 1px solid #1a295c; /* Separator line */
    text-align: center;
    font-size: 0.85rem;
    color: #c0c8e0;
}

footer p {
    margin: 5px 0;
}

footer a {
    color: #88aaff;
    text-decoration: none;
}

footer a:hover {
    text-decoration: none;
}

/* --- Footer Icon Styling --- */
.social-icons {
    margin-top: 10px; /* Space above icons */
}

.social-icons a {
    font-size: 1.2rem; /* Icon size */
    color: #c0c8e0;     /* Icon color */
    margin: 0 10px;     /* Space between icons */
    text-decoration: none;
    transition: color 0.2s ease;
}

.social-icons a:hover {
    color: #ffffff;     /* Brighter color on hover */
}

.social-icons a svg {
    width: 1.2rem;   /* Match the font-size of the other icons */
    height: 1.2rem;  /* Match the font-size of the other icons */
    vertical-align: middle; /* Helps align it with the others */
}

/* --- Mobile Controls --- */
#mobile-controls {
    display: none; /* Hidden by default */
    width: 100%;
    max-width: 550px;
    margin: 15px auto 0;
    justify-content: space-between;
}

#mobile-controls button {
    font-family: 'Poppins', sans-serif;
    font-size: 0.9rem; /* Slightly smaller to fit */
    font-weight: 600;
    flex: 1 1 23%; /* Allow buttons to grow/shrink, aiming for ~23% width */
    margin: 0 1%; /* Add small margin */
    padding: 12px 5px; /* Adjust padding */
    background-color: #1a295c;
    color: white;
    border: 1px solid #3c509e;
    border-radius: 8px;
    cursor: pointer;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

#mobile-controls button:active {
    background-color: #3c509e;
}

/* --- Media Query for Touch Devices --- */
/* Show controls on devices that have a coarse pointer (like a finger) 
   and don't support hover (a good proxy for touch-only) */
@media (hover: none) and (pointer: coarse) {
    #mobile-controls {
        display: flex;
    }
    
    /* Hide keyboard instructions on mobile */
    #explanation p:last-child {
        display: none;
    }

    .tooltip {
        display: none;
    }
}

/* --- Desktop Layout Adjustments --- */
@media (min-width: 600px) {
    #explanation {
        max-width: 950px; /* Make text box wider than canvas */
    }

    #explanation h2 {
        font-size: 2.2rem; /* Make heading larger */
    }
}

/* --- Styling for inactive buttons --- */
.inactive-btn {
    opacity: 0.4;
    cursor: default;
    pointer-events: none; /* Makes the button unclickable */
}