/* ===== STATS BAR ===== */
#stats-bar {
    height: 80px;
    background: linear-gradient(135deg, #2c3e50, #34495e);
    color: white;
    display: flex;
    align-items: center;
    justify-content: space-around;
    border-bottom: 4px solid #1a252f;
    font-size: 14px;
    padding: 0 20px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.3);
}

.stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.stat img {
    width: 24px;
    height: 24px;
}

.stat-bar {
    width: 100px;
    height: 10px;
    background: #1a252f;
    border: 2px solid #34495e;
    border-radius: 5px;
    overflow: hidden;
}

.stat-fill {
    height: 100%;
    transition: width 0.5s ease;
    border-radius: 3px;
}

#happiness-fill { background: linear-gradient(90deg, #e74c3c, #c0392b); }
#hunger-fill { background: linear-gradient(90deg, #f39c12, #e67e22); }
#cleanliness-fill { background: linear-gradient(90deg, #3498db, #2980b9); }

/* ===== CONTROL PANEL ===== */
#control-panel {
    height: 100px;
    background: linear-gradient(135deg, #34495e, #2c3e50);
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    border-top: 4px solid #1a252f;
    padding: 0 20px;
    box-shadow: 0 -4px 8px rgba(0,0,0,0.3);
}

.control-btn {
    width: 80px;
    height: 60px;
    background: linear-gradient(135deg, #3498db, #2980b9);
    border: 3px solid #2471a3;
    border-radius: 12px;
    color: white;
    font-size: 12px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.3);
}

.control-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 12px rgba(0,0,0,0.4);
}

.control-btn:active {
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

.control-btn img {
    width: 24px;
    height: 24px;
}

#feed-btn { background: linear-gradient(135deg, #e67e22, #d35400); border-color: #ca5100; }
#shower-btn { background: linear-gradient(135deg, #1abc9c, #16a085); border-color: #138d75; }
#play-btn { background: linear-gradient(135deg, #9b59b6, #8e44ad); border-color: #7d3c98; }
#hat-btn { background: linear-gradient(135deg, #e74c3c, #c0392b); border-color: #a93226; }

/* ===== MODALS ===== */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(5px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    background: linear-gradient(135deg, #ecf0f1, #bdc3c7);
    border-radius: 20px;
    border: 4px solid #34495e;
    box-shadow: 0 20px 40px rgba(0,0,0,0.5);
    animation: slideIn 0.3s ease;
    max-width: 95vw;
    max-height: 95vh;
    overflow: hidden;
}

@keyframes slideIn {
    from { transform: scale(0.8) translateY(-50px); opacity: 0; }
    to { transform: scale(1) translateY(0); opacity: 1; }
}

/* ===== HAT MODAL SPECIFIC STYLES ===== */
.hat-modal-content {
    width: 800px;
    min-height: 600px;
    display: flex;
    flex-direction: column;
}

.modal-header {
    background: linear-gradient(135deg, #34495e, #2c3e50);
    color: white;
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid #1a252f;
}

.modal-header h3 {
    font-size: 24px;
    font-weight: bold;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.5);
}

.close-btn {
    background: none;
    border: none;
    color: white;
    font-size: 28px;
    cursor: pointer;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.close-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.1);
}

.hat-designer-container {
    flex: 1;
    display: flex;
    gap: 20px;
    padding: 20px;
}

.canvas-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
}

.canvas-wrapper {
    position: relative;
    border: 4px solid #34495e;
    border-radius: 12px;
    background: #fff;
    padding: 20px;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.1);
}

#hat-designer {
    display: block;
    border: 2px solid #bdc3c7;
    border-radius: 4px;
    cursor: crosshair;
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
    background: 
        linear-gradient(90deg, rgba(200,200,200,0.3) 50%, transparent 50%),
        linear-gradient(rgba(200,200,200,0.3) 50%, transparent 50%);
    background-size: 8px 4px; 
}

.canvas-info {
    text-align: center;
    color: #34495e;
    font-size: 14px;
    font-style: italic;
}

.tools-section {
    width: 220px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.tool-group {
    background: #fff;
    border: 2px solid #bdc3c7;
    border-radius: 10px;
    padding: 15px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.tool-label {
    display: block;
    font-weight: bold;
    color: #2c3e50;
    margin-bottom: 10px;
    font-size: 14px;
}

.color-palette {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
}

.color-btn {
    width: 32px;
    height: 32px;
    border: 3px solid #34495e;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
}

.color-btn:hover {
    transform: scale(1.1);
    border-color: #2c3e50;
}

.color-btn.active {
    border-color: #e74c3c;
    box-shadow: 0 0 8px rgba(231, 76, 60, 0.5);
    transform: scale(1.15);
}

.color-btn.active::after {
    content: '✓';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: white;
    font-weight: bold;
    font-size: 14px;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.7);
}

.brush-controls {
    display: flex;
    align-items: center;
    gap: 10px;
}

#brush-size {
    flex: 1;
    height: 6px;
    background: #bdc3c7;
    border-radius: 3px;
    outline: none;
    cursor: pointer;
}

#brush-size::-webkit-slider-thumb {
    appearance: none;
    width: 20px;
    height: 20px;
    background: linear-gradient(135deg, #3498db, #2980b9);
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid #fff;
    box-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

#brush-size-value {
    font-weight: bold;
    color: #2c3e50;
    min-width: 30px;
    text-align: center;
}

.quick-tools {
    display: flex;
    gap: 8px;
}

.tool-btn {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, #ecf0f1, #bdc3c7);
    border: 2px solid #95a5a6;
    border-radius: 8px;
    cursor: pointer;
    font-size: 16px;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.tool-btn:hover {
    background: linear-gradient(135deg, #3498db, #2980b9);
    border-color: #2471a3;
    transform: translateY(-2px);
}

.tool-btn:active {
    transform: translateY(0);
}

.preset-hats {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.preset-btn {
    background: linear-gradient(135deg, #f8f9fa, #e9ecef);
    border: 2px solid #95a5a6;
    border-radius: 8px;
    padding: 8px 12px;
    cursor: pointer;
    font-size: 12px;
    font-weight: bold;
    transition: all 0.2s ease;
    text-align: left;
}

.preset-btn:hover {
    background: linear-gradient(135deg, #3498db, #2980b9);
    color: white;
    border-color: #2471a3;
    transform: translateX(5px);
}

.modal-footer {
    background: #ecf0f1;
    border-top: 2px solid #bdc3c7;
    padding: 20px;
    display: flex;
    gap: 15px;
    justify-content: flex-end;
}

.primary-btn, .secondary-btn {
    padding: 12px 24px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    border: none;
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

.primary-btn {
    background: linear-gradient(135deg, #27ae60, #229954);
    color: white;
}

.primary-btn:hover {
    background: linear-gradient(135deg, #2ecc71, #27ae60);
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0,0,0,0.3);
}

.secondary-btn {
    background: linear-gradient(135deg, #e74c3c, #c0392b);
    color: white;
}

.secondary-btn:hover {
    background: linear-gradient(135deg, #ec7063, #e74c3c);
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0,0,0,0.3);
}

/* ===== DRAWING TOOLS BELOW CANVAS ===== */
.drawing-tools {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-top: 15px;
    padding: 15px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    border: 2px solid #bdc3c7;
}

.drawing-tools .tool-btn {
    width: 50px;
    height: 50px;
    background: linear-gradient(135deg, #ecf0f1, #bdc3c7);
    border: 2px solid #95a5a6;
    border-radius: 10px;
    cursor: pointer;
    font-size: 18px;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.drawing-tools .tool-btn:hover {
    background: linear-gradient(135deg, #3498db, #2980b9);
    border-color: #2471a3;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

.drawing-tools .tool-btn.active {
    background: linear-gradient(135deg, #27ae60, #229954);
    border-color: #1e8449;
    color: white;
    box-shadow: 0 0 10px rgba(39, 174, 96, 0.5);
}

.drawing-tools .tool-btn:active {
    transform: translateY(0);
}

/* Brush size controls */
.brush-size-container {
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: center;
}

.brush-size-slider {
    display: flex;
    align-items: center;
    gap: 10px;
}

#brush-size-slider {
    width: 120px;
    height: 6px;
    background: #bdc3c7;
    border-radius: 3px;
    outline: none;
    cursor: pointer;
}

#brush-size-slider::-webkit-slider-thumb {
    appearance: none;
    width: 18px;
    height: 18px;
    background: linear-gradient(135deg, #3498db, #2980b9);
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid #fff;
    box-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

.brush-size-display {
    font-weight: bold;
    color: #2c3e50;
    font-size: 12px;
    min-width: 60px;
    text-align: center;
}

/* ===== RESPONSIVE DESIGN ===== */
@media (max-width: 1024px) {
    .hat-modal-content {
        width: 95vw;
        min-height: auto;
        max-height: 95vh;
    }
    
    .hat-designer-container {
        flex-direction: column;
        gap: 15px;
        padding: 15px;
    }
    
    .tools-section {
        width: 100%;
        flex-direction: row;
        flex-wrap: wrap;
    }
    
    .tool-group {
        flex: 1;
        min-width: 200px;
        padding: 10px;
    }
    
    .color-palette {
        grid-template-columns: repeat(6, 1fr);
    }
    
    .preset-hats {
        flex-direction: row;
        flex-wrap: wrap;
    }
    
    .preset-btn {
        flex: 1;
        min-width: 80px;
        text-align: center;
    }
}

@media (max-width: 768px) {
    .drawing-tools {
        gap: 8px;
        padding: 10px;
    }
    
    .drawing-tools .tool-btn {
        width: 45px;
        height: 45px;
        font-size: 16px;
    }
    
    .canvas-wrapper {
        padding: 10px;
    }
}

/* ===== PIXEL PERFECT GRID OVERLAY ===== */
.canvas-wrapper::after {
    content: '';
    position: absolute;
    top: 20px;
    left: 20px;
    width: 512px;
    height: 256px;
    pointer-events: none;
    background-image: 
        linear-gradient(to right, rgba(0,0,0,0.2) 1px, transparent 1px),
        linear-gradient(to bottom, rgba(0,0,0,0.2) 1px, transparent 1px);
    background-size: 8px 8px;
    z-index: 1;
}
