html, body {
    margin: 0;
    padding: 0;
}

body {
    min-height: 100vh;

    display: flex;
    flex-direction: column;

    align-items: center;
    justify-content: flex-start;

    background-color: #2574A9;

    font-family: "Quattrocento Sans", Roboto, sans-serif;
    font-weight: 400;
    font-style: normal;
}

canvas {
    display: block;
    max-width: 100%;
    height: auto;
}

.story-container {
    max-width: 540px;

    margin: 20px auto 10px;
    padding: 10px;

    text-align: center;
}

.story-container .story {
    font-weight: 400;
    font-size: 1.3rem;

    color: #f4f4f4;

    line-height: 1.6;
}

.main-content {
    position: relative;
    width: 100%;
    max-width: 540px;
    margin: 0 auto;
    padding: 0 10px;
}

.note-footer {
    max-width: 80%;

    text-align: center;
    color: #002850;

    margin: 40px auto 10px;
    padding: 10px;

    background-color: #f4f4f4;
    border-radius: 5px;
    border: 1px solid #ddd;

    font-size: 0.8rem;
}

.note-footer a {
    color: #2574A9;
    text-decoration: none;
}

.note-footer a:hover {
    text-decoration: underline;
}

.instruction-area {
    margin: 20px auto;
    padding: 15px 20px;

    display: grid;
    grid-template-columns: 1fr 2fr 1fr;
    gap: 15px;
    align-items: start;

    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    
    max-width: 90%;
}

.selector-label {
    color: #f4f4f4;
    font-size: 1.1rem;
    font-weight: 700;
    margin: 10px 0 10px 0;
}

.data-selector {
    width: 100%;
    max-width: 300px;
    padding: 10px 15px;

    font-size: 1rem;

    background-color: rgba(255, 255, 255, 0.95);
    color: #2574A9;

    border: 2px solid #2574A9;
    border-radius: 5px;

    cursor: pointer;

    transition: all 0.3s ease;
}

.data-selector:hover {
    background-color: #ffffff;
    border-color: #002850;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.data-selector:focus {
    outline: none;
    border-color: #002850;
    box-shadow: 0 0 0 3px rgba(37, 116, 169, 0.2);
}

.control-column {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.left-controls,
.right-controls {
    align-items: stretch;
}

.center-controls {
    align-items: center;
    justify-content: flex-end;
}

.center-controls .selector-label {
    margin-bottom: 5px;
}

/* Control buttons styling */
.control-btn {
    padding: 8px 12px;
    font-size: 0.9rem;

    background-color: rgba(255, 255, 255, 0.95);
    color: #2574A9;

    border: 2px solid #2574A9;
    border-radius: 5px;

    cursor: pointer;
    transition: all 0.3s ease;

    white-space: nowrap;
}

.control-btn:hover {
    background-color: #ffffff;
    border-color: #002850;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    transform: translateY(-1px);
}

.control-btn:active {
    transform: translateY(0);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
}

.control-btn:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(37, 116, 169, 0.3);
}

/* ========================================
   RESPONSIVE DESIGN - MOBILE OPTIMIZATION
   ======================================== */

/* Tablets and smaller devices */
@media (max-width: 768px) {
    .story-container {
        max-width: 90%;
        margin: 15px auto 10px;
        padding: 8px;
    }
    
    .story-container .story {
        font-size: 1.2rem;
        line-height: 1.5;
    }
    
    .instruction-area {
        grid-template-columns: 1fr;
        gap: 20px;
        padding: 15px;
        max-width: 95%;
    }
    
    .control-column {
        width: 100%;
    }
    
    .center-controls {
        order: -1; /* Move dropdown to top */
    }
    
    .left-controls,
    .right-controls {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }
    
    .data-selector {
        max-width: 100%;
        font-size: 0.95rem;
        padding: 10px 12px;
    }
    
    .selector-label {
        font-size: 1rem;
    }
    
    .control-btn {
        padding: 12px 16px;
        font-size: 0.95rem;
        min-height: 44px; /* Touch-friendly */
    }
    
    .note-footer {
        max-width: 90%;
        font-size: 0.75rem;
        margin: 30px auto 10px;
    }
}

/* Mobile phones */
@media (max-width: 480px) {
    .story-container {
        max-width: 95%;
        margin: 10px auto 8px;
        padding: 5px;
    }
    
    .story-container .story {
        font-size: 1.1rem;
        line-height: 1.4;
    }
    
    .instruction-area {
        padding: 12px;
        gap: 15px;
    }
    
    .selector-label {
        font-size: 0.9rem;
        margin: 8px 0;
    }
    
    .data-selector {
        padding: 10px 10px;
        font-size: 0.86rem;
    }
    
    .control-btn {
        padding: 10px 12px;
        font-size: 0.84rem;
        white-space: normal; /* Allow wrapping on very small screens */
    }
    
    .note-footer {
        max-width: 95%;
        font-size: 0.7rem;
        padding: 8px;
        margin: 20px auto 8px;
    }
    
    .note-footer .note {
        line-height: 1.4;
    }
}

/* Very small devices */
@media (max-width: 360px) {
    .story-container .story {
        font-size: 1rem;
    }
    
    .selector-label {
        font-size: 0.82rem;
    }
    
    .data-selector {
        font-size: 0.8rem;
        padding: 9px 8px;
    }
    
    .control-btn {
        font-size: 0.75rem;
        padding: 9px 10px;
    }
    
    .left-controls,
    .right-controls {
        grid-template-columns: 1fr; /* Stack buttons vertically on very small screens */
    }
}

/* Landscape orientation on mobile */
@media (max-height: 600px) and (orientation: landscape) {
    .story-container {
        margin: 8px auto 5px;
    }
    
    .story-container .story {
        font-size: 1.1rem;
        line-height: 1.3;
    }
    
    .instruction-area {
        margin: 10px auto;
        padding: 10px;
    }
    
    .selector-label {
        font-size: 0.9rem;
        margin: 6px 0;
    }
    
    .data-selector {
        font-size: 0.82rem;
        padding: 8px 10px;
    }
    
    .control-btn {
        font-size: 0.8rem;
        padding: 8px 10px;
        min-height: 40px;
    }
    
    .note-footer {
        margin: 15px auto 8px;
    }
}
