body {
    font-family: Arial, sans-serif;
    min-height: 100vh;
    background-color: #f0f0f0;
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

#game-container {
    background-color: #fff;
    padding: 20px;
    width: 100%;
    min-height: 100vh;
    box-sizing: border-box;
    overflow-y: auto;
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    gap: 20px;
}

#main-content-area {
    flex: 1.5;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
}

#sidebar-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 20px;
    padding-top: 20px;
}

h1 {
    color: #333;
    margin-bottom: 10px;
    text-align: center;
}

h2 {
    color: #555;
    margin-top: 0;
    margin-bottom: 10px;
    font-size: 1.2em;
    border-bottom: 1px solid #eee;
    padding-bottom: 5px;
    width: 100%;
    text-align: center;
}

#instructions {
    font-size: 0.9em;
    color: #666;
    margin-bottom: 20px;
    text-align: center;
    max-width: 600px;
}

#source-colors-panel, #mixing-area, #hint-section {
    width: 100%;
    box-sizing: border-box;
}

#source-colors-container { 
    display: flex;
    flex-wrap: wrap; 
    justify-content: center; 
    gap: 15px; 
    margin-bottom: 20px;
}

.color-source {
    width: 100px;
    height: 100px;
    border: 2px solid #ccc;
    border-radius: 10px; 
    display: flex;
    flex-direction: column; 
    justify-content: center;
    align-items: center;
    font-weight: bold;
    cursor: pointer;
    transition: transform 0.1s ease, box-shadow 0.2s ease, filter 0.3s ease;
    box-shadow: 0 3px 6px rgba(0,0,0,0.1);
    font-size: 1em; 
    padding: 8px; 
    box-sizing: border-box; 
    text-align: center; 
}

.color-source span { 
    display: block; 
    line-height: 1.2;
}

.color-hex {
    font-size: 0.8em;
    font-weight: normal;
    opacity: 0.8;
    margin-top: 4px; 
    display: block; 
}

.color-source:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

.color-source.selected {
    border-color: #000; 
    box-shadow: 0 0 12px 3px rgba(0,0,0,0.3); 
    transform: scale(1.1);
}

.color-source.locked {
    filter: grayscale(80%);
    cursor: not-allowed;
    border-color: #aaa;
    background-color: #e0e0e0 !important; 
    color: #777 !important; 
}

.color-source.locked:hover {
    transform: none; 
    box-shadow: 0 2px 4px rgba(0,0,0,0.1); 
}

.lock-icon {
    font-size: 1.4em; 
    margin-top: 6px; 
}

#mixing-area p {
    margin-top: 0;
    margin-bottom: 5px;
    font-size: 0.9em;
    color: #444;
}

#selected-colors-display-container, #result-box-container {
    margin-bottom: 15px;
    padding: 10px;
    background-color: #f9f9f9;
    border-radius: 6px;
}

#selected-colors-display {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 40px; 
    padding: 5px 0;
}

.selected-swatch {
    width: 30px;
    height: 30px;
    border: 1px solid #ddd;
    border-radius: 4px;
    margin: 0 5px; 
    box-shadow: inset 0 0 3px rgba(0,0,0,0.1);
}

#result-color-box {
    width: 100%;
    height: 100px;
    border: 1px solid #ccc;
    border-radius: 6px;
    background-color: white; 
    display: flex;
    justify-content: center;
    align-items: center;
    transition: background-color 0.3s ease;
    margin-top: 5px;
}

#result-color-name {
    font-size: 1.2em;
    font-weight: bold;
    padding: 5px 10px;
    background-color: rgba(255,255,255,0.3); 
    border-radius: 4px;
    color: black; 
    transition: color 0.3s ease;
}

#clear-button {
    padding: 10px 20px;
    font-size: 1em;
    color: white;
    background-color: #d9534f; 
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.2s ease;
    width: 100%; 
    box-sizing: border-box;
}

#clear-button:hover {
    background-color: #c9302c; 
}

#unlock-message-container {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    padding: 10px 20px;
    background-color: #4CAF50; /* Green */
    color: white;
    border-radius: 5px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.5s ease-in-out, visibility 0.5s ease-in-out, bottom 0.5s ease-in-out;
}

#unlock-message-container.show {
    opacity: 1;
    visibility: visible;
    bottom: 30px; /* Slide up effect */
}

#unlock-message {
    margin: 0;
    font-size: 1.1em;
    font-weight: bold;
}

#hint-section {
    padding: 15px;
    background-color: #f9f9f9;
    border-radius: 6px;
    border: 1px solid #eee;
}

#hint-section h2 {
    margin-top: 0;
    font-size: 1.1em;
}

#hint-button {
    padding: 10px 15px;
    font-size: 0.9em;
    color: white;
    background-color: #5bc0de; /* Info blue */
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.2s ease, opacity 0.2s ease;
    margin-bottom: 10px;
}

#hint-button:hover {
    background-color: #31b0d5;
}

#hint-button:disabled {
    background-color: #aaa;
    cursor: not-allowed;
    opacity: 0.7;
}

#hint-cooldown-display {
    font-size: 0.85em;
    color: #777;
    min-height: 1.2em; /* Reserve space to prevent layout shift */
    margin-bottom: 5px;
}

#hint-message-display {
    font-size: 0.9em;
    color: #333;
    background-color: #eef;
    padding: 8px;
    border-radius: 4px;
    min-height: 1.5em; /* Reserve space */
    border: 1px solid #dde;
}

#speedrun-timer-section {
    padding: 15px;
    background-color: #f9f9f9; 
    border-radius: 6px;
    border: 1px solid #eee;
    text-align: center;
    width: 100%; 
    box-sizing: border-box;
}

#speedrun-timer-section h2 {
    color: #555; 
}

#timer-display {
    font-size: 2em;
    font-weight: bold;
    color: #333;
    margin: 10px 0;
    padding: 10px;
    background-color: #fff;
    border: 1px solid #ddd;
    border-radius: 4px;
}

#timer-controls {
    margin-bottom: 10px;
}

#timer-controls button {
    padding: 8px 15px;
    font-size: 0.9em;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.2s ease;
    margin: 0 5px;
}

#start-timer-button { background-color: #5cb85c; /* Green */ }
#start-timer-button:hover { background-color: #4cae4c; }
#stop-timer-button { background-color: #f0ad4e; /* Orange */ }
#stop-timer-button:hover { background-color: #eea236; }
#reset-timer-button { background-color: #d9534f; /* Red */ }
#reset-timer-button:hover { background-color: #c9302c; }

#timer-controls button:disabled {
    background-color: #aaa;
    cursor: not-allowed;
    opacity: 0.7;
}

#timer-status {
    font-size: 0.9em;
    color: #777;
    margin-top: 5px;
}

#ai-helper-section {
    padding: 15px;
    background-color: #e9efff; 
    border-radius: 8px;
    border: 1px solid #d0d9f0;
    text-align: left;
    width: 100%; 
    box-sizing: border-box;
}

#ai-helper-section h2 {
    margin-top: 0;
    font-size: 1.1em;
    color: #334a7d;
    border-bottom: 1px solid #c0c9e0;
    padding-bottom: 5px;
    text-align: center;
}

#chat-log {
    height: 150px;
    overflow-y: auto;
    border: 1px solid #ccc;
    padding: 10px;
    margin-bottom: 10px;
    background-color: #fff;
    border-radius: 4px;
    font-size: 0.9em;
}

.chat-message {
    margin-bottom: 8px;
    padding: 6px 10px;
    border-radius: 4px;
    line-height: 1.4;
}

.user-message {
    background-color: #dcf8c6; /* Light green for user */
    text-align: right;
    margin-left: auto;
    max-width: 80%;
    word-wrap: break-word;
}

.ai-message {
    background-color: #f1f0f0; /* Light grey for AI */
    text-align: left;
    margin-right: auto;
    max-width: 80%;
    word-wrap: break-word;
}

#chat-input-container {
    display: flex;
    gap: 10px;
    align-items: center;
}

#chat-input {
    flex-grow: 1;
    padding: 8px 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 0.9em;
}

#send-chat-button {
    padding: 8px 15px;
    font-size: 0.9em;
    color: white;
    background-color: #007bff; /* Bootstrap primary blue */
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

#send-chat-button:hover {
    background-color: #0056b3;
}

#send-chat-button:disabled {
    background-color: #aaa;
    cursor: not-allowed;
}

#ai-typing-indicator {
    font-size: 0.85em;
    color: #555;
    text-align: center;
    margin-top: 5px;
}

/* --- Pixel Art Section Styles --- */
#pixel-art-section {
    width: 100%;
    max-width: 600px;
    margin: 0 auto 20px auto;
    padding: 15px;
    background-color: #fafafa;
    border: 1px solid #ddd;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    box-sizing: border-box;
}

#pixel-art-section h2, #paint-palette-container h3 {
    width: 100%;
    text-align: center;
    margin: 0 0 10px 0;
    color: #444;
}
#paint-palette-container h3 {
    font-size: 1em;
    border-bottom: 1px solid #eee;
    padding-bottom: 5px;
}

#pixel-art-controls {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 10px 20px;
    margin-bottom: 10px;
    width: 100%;
}

.control-group {
    display: flex;
    align-items: center;
    gap: 8px;
}
.control-label {
    font-weight: bold;
    font-size: 0.9em;
    color: #555;
}

.tool-button {
    padding: 5px 12px;
    border: 1px solid #ccc;
    background-color: #f0f0f0;
    cursor: pointer;
    border-radius: 4px;
    font-size: 1.2em;
    line-height: 1;
    transition: background-color 0.2s, border-color 0.2s;
}

.tool-button:hover {
    background-color: #e0e0e0;
}

.tool-button.active {
    background-color: #007bff;
    color: white;
    border-color: #006fe6;
}

.upload-btn {
    padding: 8px 15px;
    font-size: 0.9em;
    color: white;
    background-color: #5bc0de; /* Info blue */
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.2s;
    line-height: normal; /* To align text vertically */
}

.upload-btn:hover {
    background-color: #31b0d5;
}

#clear-canvas-button {
    padding: 8px 15px;
    font-size: 0.9em;
    color: white;
    background-color: #d9534f;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.2s;
}
#clear-canvas-button:hover {
    background-color: #c9302c;
}

#brush-size-display {
    font-weight: bold;
    min-width: 20px;
    text-align: center;
    background-color: #eee;
    padding: 3px 6px;
    border-radius: 4px;
    font-size: 0.9em;
}

#paint-color-preview {
    width: 30px;
    height: 30px;
    border: 2px solid #333;
    border-radius: 5px;
    background-clip: padding-box; /* Makes sure background doesn't go under border */
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

#pixel-canvas-container {
    padding: 6px;
    background: #ccc;
    border: 1px solid #999;
    border-radius: 4px;
    box-shadow: inset 0 0 5px rgba(0,0,0,0.1);
}

#pixel-canvas {
    --grid-size: 64;
    --pixel-size: 6px; /* Canvas will be 384x384px */
    display: grid;
    grid-template-columns: repeat(var(--grid-size), var(--pixel-size));
    grid-template-rows: repeat(var(--grid-size), var(--pixel-size));
    width: calc(var(--grid-size) * var(--pixel-size));
    height: calc(var(--grid-size) * var(--pixel-size));
    background-color: #fff;
    image-rendering: pixelated; /* Ensures sharp pixels */
    cursor: crosshair;
}

.pixel {
    width: var(--pixel-size);
    height: var(--pixel-size);
    background-color: #fff;
    /* No border on pixels for a seamless look, and better performance */
}

#paint-palette-container {
    width: 100%;
}

#paint-palette {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    padding: 10px;
    background: #f0f0f0;
    border-radius: 4px;
    border: 1px solid #ddd;
    margin-top: 5px;
    max-height: 150px;
    overflow-y: auto;
}

.palette-color {
    width: 30px;
    height: 30px;
    border-radius: 5px;
    cursor: pointer;
    border: 2px solid transparent;
    transition: transform 0.1s, border-color 0.2s, box-shadow 0.2s;
    box-shadow: 0 1px 2px rgba(0,0,0,0.15);
}

.palette-color:hover {
    transform: scale(1.1);
}

.palette-color.selected {
    border-color: #007bff;
    transform: scale(1.15);
    box-shadow: 0 0 8px rgba(0, 123, 255, 0.7);
}