body {
    font-family: Arial, Helvetica, sans-serif;
    margin: 0;
    padding: 15px; /* Overall page padding */
    background-color: #f0f2f5;
    color: #333;
    display: flex;
    flex-direction: column;
    align-items: center; /* Center main content blocks */
}

h1 {
    color: #2c3e50;
    margin-top: 0;
    margin-bottom: 15px;
    font-size: 1.8em;
    text-align: center;
}

#controls {
    width: 100%; /* Allow controls to span width for better wrapping */
    max-width: 800px; /* Or match konva-container width, or set a specific max */
    margin-bottom: 15px;
    padding: 10px;
    background-color: #ffffff;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    
    /* Flexbox for single-line layout with wrapping */
    display: flex;
    flex-wrap: wrap; /* Allow items to wrap to the next line on small screens */
    justify-content: center; /* Center items if they don't fill the line */
    align-items: center; /* Vertically align items in the line */
    gap: 8px; /* Spacing between control items */
}

#controls button {
    padding: 8px 12px; /* Adjust padding for button size */
    cursor: pointer;
    background-color: #3498db;
    color: white;
    border: none;
    border-radius: 5px;
    font-size: 0.9em; /* Adjust font size for button text */
    transition: background-color 0.2s ease;
    white-space: nowrap; /* Prevent text inside buttons from wrapping */
}

#controls button:hover {
    background-color: #2980b9;
}

#controls button:active {
    background-color: #2471a3;
}

.control-divider {
    display: inline-block;
    width: 1px;
    background-color: #d0d0d0;
    height: 20px; /* Adjust height to align with buttons */
    margin: 0 5px; /* Space around divider */
}

#mode-display-wrapper {
    padding: 6px 10px;
    background-color: #f0f0f0;
    border: 1px solid #ccc;
    border-radius: 5px;
    font-size: 0.9em;
    margin-left: 5px; /* Space it from the last button group */
}

#currentModeDisplay {
    font-weight: bold;
    color: #e74c3c;
}

#konva-container {
    width: 800px;
    height: 460px; /* Matches stageWidth/Height in script.js */
    border: 2px solid #bdc3c7;
    background-color: #ffffff;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    position: relative; /* Important for Konva */
    border-radius: 5px;
    overflow: hidden; /* Ensures canvas content doesn't spill */
    margin-left: auto; /* Center if parent is wider and allows */
    margin-right: auto;
}

/* Responsive adjustments */
@media (max-width: 840px) { /* When screen is about the size of the canvas */
    #controls {
        justify-content: space-around; /* Distribute space more evenly when wrapping */
    }
    #konva-container {
        width: 98%; /* Make canvas container responsive */
        /* Note: Konva stage itself remains fixed size unless script.js is updated
           to handle responsive resizing of the stage and its contents. */
    }
}

@media (max-width: 480px) {
    h1 {
        font-size: 1.5em;
    }
    #controls button {
        font-size: 0.85em;
        padding: 6px 8px; /* Smaller buttons */
    }
    .control-divider {
        display: none; /* Hide dividers to save space */
    }
}

footer {
    margin-top: 25px;
    font-size: 0.85em;
    color: #7f8c8d;
    text-align: center;
}

footer a {
    color: #3498db;
    text-decoration: none;
}

footer a:hover {
    text-decoration: underline;
}