body { margin: 0; overflow: hidden; font-family: 'Segoe UI', sans-serif; user-select: none; }
canvas { display: block; image-rendering: pixelated; }

/* SAĞ ÜST GÖSTERGE */
#color-indicator {
    position: absolute; top: 20px; right: 20px; width: 60px; height: 60px;
    border-radius: 50%; border: 3px solid white; cursor: pointer;
    box-shadow: 0 4px 10px rgba(0,0,0,0.5); z-index: 300;
    background: conic-gradient(red, orange, yellow, green, blue, indigo, violet, red);
    transition: transform 0.2s;
}
#color-indicator:hover { transform: scale(1.1); }

/* ÜST KONTROL PANELİ */
#controls {
    position: fixed;
    top: 14px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 8px;
    background: rgba(10,10,10,0.9);
    padding: 8px 16px;
    border-radius: 999px;
    color: white;
    align-items: center;
    z-index: 90;
    box-shadow: 0 8px 20px rgba(0,0,0,0.6);
    backdrop-filter: blur(10px);
}

/* Çocuk modu kilit yuvası: her zaman barın en sağına hizalansın */
#kids-lock-slot {
    margin-left: auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    font-size: 18px;
}

/* Yardım overlay ve modalı */
#help-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.65);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 250;
}

#help-modal {
    max-width: 520px;
    width: 90vw;
    max-height: 80vh;
    background: rgba(15,15,20,0.97);
    border-radius: 18px;
    box-shadow: 0 16px 40px rgba(0,0,0,0.8);
    padding: 20px 24px 18px;
    color: #f5f5f5;
    overflow-y: auto;
}

#help-modal h2 {
    margin-top: 0;
    margin-bottom: 10px;
}

#help-body p {
    margin: 6px 0;
    font-size: 14px;
}

#help-body .help-section-title {
    margin-top: 12px;
    font-weight: 600;
}

#help-close-btn {
    margin-top: 12px;
}

/* Hazır kalıp seçici */
#patterns-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.7);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 240;
}

#patterns-modal {
    max-width: 600px;
    width: 90vw;
    max-height: 80vh;
    background: rgba(20,20,25,0.97);
    border-radius: 18px;
    box-shadow: 0 16px 40px rgba(0,0,0,0.85);
    padding: 20px 24px 18px;
    color: #f5f5f5;
    display: flex;
    flex-direction: column;
}

#patterns-modal h2 {
    margin-top: 0;
    margin-bottom: 12px;
}

#patterns-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 8px;
    margin-bottom: 12px;
}

/* New pagination container styles */
#patterns-container {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 20px;
    min-height: 200px;
}

/* Child-friendly pagination buttons */
#patterns-pagination {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-bottom: 15px;
    flex-wrap: wrap;
}

.pagination-btn {
    background: linear-gradient(135deg, #ff6b6b, #ff8e8e);
    border: 2px solid #ff5252;
    color: white;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 40px;
    box-shadow: 0 4px 8px rgba(255, 82, 82, 0.3);
}

.pagination-btn:hover {
    transform: scale(1.1);
    background: linear-gradient(135deg, #ff5252, #ff6b6b);
    box-shadow: 0 6px 12px rgba(255, 82, 82, 0.4);
}

.pagination-btn.active {
    background: linear-gradient(135deg, #4ecdc4, #44a3aa);
    border-color: #3db8af;
    box-shadow: 0 4px 8px rgba(62, 184, 175, 0.3);
}

.pagination-btn.active:hover {
    background: linear-gradient(135deg, #3db8af, #3498a0);
    box-shadow: 0 6px 12px rgba(62, 184, 175, 0.4);
}

.pagination-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* Loading indicator */
.patterns-loading {
    text-align: center;
    color: white;
    font-size: 18px;
    padding: 40px;
}

.pattern-item {
    position: relative;
    font-size: 14px;
    justify-content: center;
    align-items: center;
    height: 90px;
    overflow: hidden;
    padding: 0;
}


.pattern-thumb {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}
.btn {
    background: linear-gradient(135deg, #444, #222);
    border: 1px solid #666;
    color: white;
    padding: 5px 11px;
    cursor: pointer;
    border-radius: 999px;
    font-size: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.btn:hover {
    background: linear-gradient(135deg, #666, #333);
}
input[type=range] {
    width: 110px;
}

/* Toggle buton stili - ikon odaklı, off: siyah, on: kırmızı */
.toggle-btn {
    width: 34px;
    height: 34px;
    padding: 0;
    border-radius: 50%;
    background: radial-gradient(circle at 30% 30%, #444, #000);
    border: 1px solid #666;
    box-shadow: 0 0 6px rgba(0,0,0,0.8);
    font-size: 18px;
}
.toggle-btn.on {
    background: radial-gradient(circle at 30% 30%, #ff5a5a, #610000);
    border-color: #ffb3b3;
    box-shadow: 0 0 0 2px rgba(255,120,120,0.7), 0 0 16px rgba(255,80,80,0.9);
}

/* TAM EKRAN PALET */
#palette-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.9); display: none; z-index: 200;
    justify-content: center; align-items: center; flex-direction: column;
}
#rgb-picker-container {
    position: relative;
    width: 90vw;
    max-width: 900px;
    aspect-ratio: 16 / 7;
    margin-top: 40px;
}
#rgb-canvas {
    width: 100%;
    height: 100%;
    border-radius: 12px;
    box-shadow: 0 0 20px rgba(0,0,0,0.8);
    cursor: crosshair;
}
#rgb-cursor {
    position: absolute;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 2px solid white;
    box-shadow: 0 0 6px rgba(0,0,0,0.8);
    pointer-events: none;
}
#rainbow-btn { 
    position: absolute; top: 20px; left: 20px; 
    background: linear-gradient(45deg, red, orange, yellow, green, blue, violet);
    padding: 15px 30px; font-weight: bold; color: white; border: none; border-radius: 10px; cursor: pointer;
}

/* GİZLİ INPUTLAR */
#file-input-img { display: none; }
#bomb-btn {
    position: relative;
    width: 38px;
    height: 38px;
    padding: 0;
    border-radius: 50%;
    font-size: 20px;
    --cooldown-progress: 0;
}

#bomb-btn.active {
    background: radial-gradient(circle at 30% 30%, #ff5a5a, #610000);
    border-color: #ffb3b3;
    box-shadow: 0 0 0 2px rgba(255,120,120,0.7), 0 0 16px rgba(255,80,80,0.9);
    transform: translateY(1px);
}

/* Bomba cooldown görseli: içte dolan kırmızı halka */
#bomb-btn::after {
    content: '';
    position: absolute;
    inset: 3px;
    border-radius: 50%;
    background:
        conic-gradient(rgba(255,80,80,0.9) 0 var(--cooldown-progress),
                       rgba(80,0,0,0.4) var(--cooldown-progress) 100%);
    opacity: 0;
    transition: opacity 0.15s ease-out;
    pointer-events: none;
}

#bomb-btn.cooldown {
    cursor: default;
}

#bomb-btn.cooldown::after {
    opacity: 1;
}

/* Arkaplan renk kutusu */
#bg-color-box {
    width: 40px;
    height: 24px;
    border-radius: 5px;
    border: 1px solid #666;
    background: linear-gradient(135deg, #555, #222);
    box-shadow: 0 2px 4px rgba(0,0,0,0.6);
    cursor: pointer;
}

/* Clear Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content-sand {
    background: rgba(20,20,20,0.95);
    padding: 30px;
    border-radius: 15px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.9);
    text-align: center;
    max-width: 400px;
    color: white;
}

.modal-content-sand h2 {
    margin: 0 0 15px 0;
    font-size: 24px;
}

.modal-content-sand p {
    margin: 0 0 25px 0;
    font-size: 16px;
    color: #ccc;
}

.modal-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
}

.modal-buttons .btn {
    padding: 12px 30px;
    font-size: 16px;
    font-weight: bold;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    pointer-events: auto !important;
    z-index: 1001 !important;
    position: relative;
}

.modal-buttons .btn:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 15px rgba(0,0,0,0.5);
}

/* Replay ilerleme çubuğu */
#replay-bar {
    position: fixed;
    left: 50%;
    bottom: 20px;
    transform: translateX(-50%);
    width: 320px;
    height: 32px;
    background: rgba(0,0,0,0.85);
    border-radius: 16px;
    overflow: visible;
    box-shadow: 0 6px 20px rgba(0,0,0,0.8), 0 2px 4px rgba(0,0,0,0.6);
    z-index: 95;
    display: flex;
    align-items: center;
    padding: 0 12px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease-out, transform 0.2s ease-out;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255,255,255,0.1);
}

#replay-bar:hover {
    transform: translateX(-50%) translateY(-2px);
    box-shadow: 0 8px 25px rgba(0,0,0,0.9), 0 4px 8px rgba(0,0,0,0.7);
}

#replay-bar button {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: none;
    background: rgba(255,255,255,0.15);
    color: white;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

#replay-bar button:hover {
    background: rgba(255,255,255,0.25);
    transform: scale(1.05);
}

#replay-bar button:active {
    transform: scale(0.95);
}

#replay-bar button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

#replay-progress-container {
    flex: 1;
    height: 8px;
    background: rgba(255,255,255,0.1);
    border-radius: 4px;
    margin: 0 10px;
    position: relative;
    overflow: hidden;
}

#replay-progress {
    height: 100%;
    width: 0;
    background: linear-gradient(90deg, #ff6b35, #f7931e, #ffd23f);
    border-radius: 4px;
    transition: width 0.1s linear;
    position: relative;
    overflow: hidden;
}

#replay-progress::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
    animation: shimmer 2s infinite;
}

@keyframes shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

#replay-label {
    position: absolute;
    top: -22px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 12px;
    color: #fff;
    text-shadow: 0 1px 3px rgba(0,0,0,0.9), 0 0 6px rgba(0,0,0,0.5);
    font-weight: 500;
    white-space: nowrap;
    pointer-events: none;
}
