/* ===== Puzzle Parça Stilleri ===== */
.puzzle-piece {
    width: 100%;
    height: 100%;
    cursor: pointer;
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.25s ease, filter 0.25s ease;
    border: 1px solid rgba(255, 255, 255, 0.08);
    touch-action: manipulation;
    box-sizing: border-box;
    will-change: transform;
    transform-origin: center center;
}

.puzzle-piece:active {
    transform: scale(0.93);
}

.puzzle-piece.selected {
    border-color: #818cf8;
    box-shadow:
        inset 0 0 12px rgba(129, 140, 248, 0.6),
        0 6px 20px rgba(129, 140, 248, 0.5),
        0 0 16px rgba(129, 140, 248, 0.3);
    transform: scale(1.05);
    z-index: 10;
    animation: selected-pulse 1.5s ease-in-out infinite;
}

@keyframes selected-pulse {
    0%, 100% {
        box-shadow: inset 0 0 12px rgba(129, 140, 248, 0.5), 0 6px 20px rgba(129, 140, 248, 0.4), 0 0 16px rgba(129, 140, 248, 0.3);
        transform: scale(1.05);
    }
    50% {
        box-shadow: inset 0 0 18px rgba(129, 140, 248, 0.8), 0 10px 28px rgba(129, 140, 248, 0.6), 0 0 24px rgba(129, 140, 248, 0.5);
        transform: scale(1.07);
    }
}

.puzzle-piece.snap-in {
    animation: snap-in 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes snap-in {
    0%   { transform: scale(1.1); }
    100% { transform: scale(1); }
}

.puzzle-piece.hint-glow {
    animation: hint-glow 0.7s ease-in-out 3;
}

@keyframes hint-glow {
    0%, 100% { filter: brightness(1); }
    50%       { filter: brightness(1.6) drop-shadow(0 0 8px #fbbf24); }
}

/* ===== Solved Preview ===== */
.solved-overlay {
    position: fixed;
    inset: 0;
    z-index: 9997;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px 16px calc(20px + env(safe-area-inset-bottom));
    background: rgba(12, 10, 26, 0.94);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    cursor: pointer;
    animation: fade-in 0.28s ease;
}

.solved-stage {
    width: min(100%, 720px);
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
}

.solved-image {
    width: min(92vw, 620px);
    max-height: min(72vh, 620px);
    object-fit: contain;
    background: rgba(0, 0, 0, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 14px;
    box-shadow: 0 24px 70px rgba(0, 0, 0, 0.5), 0 0 42px rgba(52, 211, 153, 0.18);
}

.solved-badge {
    width: min(92vw, 420px);
    text-align: center;
    background: linear-gradient(135deg, rgba(52, 211, 153, 0.18), rgba(16, 185, 129, 0.09));
    border: 1px solid rgba(52, 211, 153, 0.32);
    border-radius: 18px;
    padding: 14px 16px 16px;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.32);
}

.solved-kicker {
    color: #6ee7b7;
    font-size: 0.74rem;
    font-weight: 800;
    letter-spacing: 1.2px;
    text-transform: uppercase;
    margin-bottom: 4px;
}

.solved-title {
    color: #f8fafc;
    font-size: 1.55rem;
    font-weight: 800;
    line-height: 1.1;
    margin-bottom: 12px;
}

.solved-continue {
    min-width: 130px;
    background: linear-gradient(135deg, #34d399, #10b981);
    color: #06281c;
    border: none;
    border-radius: 13px;
    padding: 12px 24px;
    font-family: inherit;
    font-size: 0.92rem;
    font-weight: 800;
    cursor: pointer;
    box-shadow: 0 8px 24px rgba(52, 211, 153, 0.3);
}

.solved-continue:active { transform: scale(0.96); }

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .puzzle-piece { border-width: 1px; }
    .solved-image { max-height: 66vh; }
    .solved-title { font-size: 1.35rem; }
}

/* ===== Achievement Toast ===== */
.achievement-toast {
    position: fixed;
    top: 80px;
    left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(135deg, rgba(251, 191, 36, 0.97), rgba(245, 158, 11, 0.97));
    color: #000;
    border-radius: 16px;
    padding: 12px 18px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    font-size: 0.85rem;
    z-index: 9998;
    box-shadow: 0 8px 30px rgba(251, 191, 36, 0.45);
    pointer-events: none;
    animation: toast-in 0.45s cubic-bezier(0.34, 1.56, 0.64, 1) forwards, toast-out 0.4s ease-in 2.7s forwards;
    max-width: 320px;
    width: calc(100% - 40px);
}

@keyframes toast-in {
    from { transform: translateX(-50%) translateY(-28px); opacity: 0; }
    to   { transform: translateX(-50%) translateY(0);    opacity: 1; }
}

@keyframes toast-out {
    from { transform: translateX(-50%) translateY(0);    opacity: 1; }
    to   { transform: translateX(-50%) translateY(-28px); opacity: 0; }
}

.achievement-toast .ach-emoji { font-size: 1.5rem; flex-shrink: 0; }
.achievement-toast .ach-title { font-size: 0.72rem; opacity: 0.7; font-weight: 600; }
.achievement-toast .ach-name  { font-size: 0.88rem; font-weight: 800; }

/* ===== Tutorial Overlay ===== */
.tutorial-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.88);
    z-index: 10000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px;
    backdrop-filter: blur(10px);
    animation: fade-in 0.4s ease;
}

@keyframes fade-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}

.tutorial-card {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.18), rgba(244, 114, 182, 0.1));
    border: 1px solid rgba(129, 140, 248, 0.3);
    border-radius: 24px;
    padding: 36px 24px 28px;
    max-width: 340px;
    width: 100%;
    text-align: center;
}

.tutorial-step {
    display: none;
    animation: step-in 0.35s ease;
}

.tutorial-step.active { display: block; }

@keyframes step-in {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
}

.tutorial-emoji  { font-size: 3.8rem; display: block; margin-bottom: 16px; }
.tutorial-title  { font-size: 1.25rem; font-weight: 800; color: #f1f5f9; margin-bottom: 10px; }
.tutorial-desc   { color: #94a3b8; font-size: 0.9rem; line-height: 1.65; margin-bottom: 24px; }

.tutorial-dots {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-bottom: 22px;
}

.tutorial-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    transition: all 0.3s;
}

.tutorial-dot.active {
    background: #818cf8;
    width: 24px;
    border-radius: 4px;
}

.btn-tutorial-next {
    background: linear-gradient(135deg, #6366f1, #7c3aed);
    color: white;
    border: none;
    border-radius: 14px;
    padding: 14px 32px;
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
    width: 100%;
    transition: transform 0.2s;
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.35);
}

.btn-tutorial-next:active { transform: scale(0.96); }

/* ===== Settings Overlay ===== */
.settings-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.65);
    z-index: 9990;
    display: flex;
    align-items: flex-end;
    backdrop-filter: blur(6px);
    animation: fade-in 0.3s ease;
}

.settings-sheet {
    background: linear-gradient(180deg, #1e1b38, #0f172a);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 24px 24px 0 0;
    padding: 8px 24px 32px;
    width: 100%;
    animation: slide-up 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes slide-up {
    from { transform: translateY(100%); }
    to   { transform: translateY(0); }
}

.settings-handle {
    width: 40px;
    height: 4px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 2px;
    margin: 12px auto 20px;
}

.settings-title { font-size: 1.1rem; font-weight: 800; color: #f1f5f9; margin-bottom: 16px; }

.settings-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 15px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.settings-row:last-of-type { border-bottom: none; }

.settings-label {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.95rem;
    font-weight: 600;
    color: #e2e8f0;
}

.settings-label .s-icon { font-size: 1.3rem; }

/* Toggle Switch */
.toggle { position: relative; width: 50px; height: 28px; flex-shrink: 0; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-track {
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.12);
    border-radius: 14px;
    cursor: pointer;
    transition: background 0.3s;
}
.toggle-track::after {
    content: '';
    position: absolute;
    width: 22px;
    height: 22px;
    background: white;
    border-radius: 50%;
    top: 3px;
    left: 3px;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.35);
}
.toggle input:checked + .toggle-track { background: #6366f1; }
.toggle input:checked + .toggle-track::after { transform: translateX(22px); }

/* ===== App Bar Settings Button ===== */
.btn-settings {
    background: rgba(255, 255, 255, 0.07);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #94a3b8;
    border-radius: 10px;
    width: 36px;
    height: 36px;
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}
.btn-settings:active { background: rgba(255, 255, 255, 0.14); transform: scale(0.91); }

/* ===== Stats Panel ===== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-bottom: 12px;
}

.stat-card {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 14px;
    padding: 14px;
    text-align: center;
}

.stat-card-value {
    font-size: 1.7rem;
    font-weight: 800;
    color: #818cf8;
    line-height: 1;
    margin-bottom: 5px;
}

.stat-card-label {
    font-size: 0.7rem;
    font-weight: 600;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.8px;
}

.best-times-list { margin-top: 4px; }

.best-time-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 7px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    font-size: 0.82rem;
}

.best-time-row:last-child { border-bottom: none; }
.best-time-label { color: #94a3b8; font-weight: 600; }
.best-time-value { color: #34d399; font-weight: 700; }

/* ===== Resume Banner ===== */
.resume-banner {
    background: linear-gradient(135deg, rgba(251, 191, 36, 0.14), rgba(245, 158, 11, 0.07));
    border: 1px solid rgba(251, 191, 36, 0.3);
    border-radius: 16px;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    animation: fade-in-up 0.5s ease-out;
    cursor: pointer;
    transition: transform 0.2s;
}

.resume-banner:active { transform: scale(0.98); }

@keyframes fade-in-up {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
}

.resume-info { display: flex; align-items: center; gap: 10px; }
.resume-emoji { font-size: 1.5rem; }
.resume-text { font-size: 0.85rem; font-weight: 700; color: #fbbf24; }
.resume-sub  { font-size: 0.72rem; color: #94a3b8; margin-top: 2px; }

.btn-resume {
    background: linear-gradient(135deg, #fbbf24, #f59e0b);
    color: #000;
    border: none;
    border-radius: 10px;
    padding: 8px 14px;
    font-family: inherit;
    font-size: 0.78rem;
    font-weight: 800;
    cursor: pointer;
    flex-shrink: 0;
    transition: transform 0.2s;
}
.btn-resume:active { transform: scale(0.94); }

/* ===== Game Action Buttons (Undo / Hint) ===== */
.game-actions { display: flex; gap: 6px; }

.btn-action {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #94a3b8;
    border-radius: 10px;
    padding: 5px 11px;
    font-family: inherit;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 4px;
    transition: all 0.2s;
    line-height: 1;
}

.btn-action:not(:disabled):active {
    background: rgba(255, 255, 255, 0.13);
    transform: scale(0.93);
}

.btn-action:disabled {
    opacity: 0.28;
    cursor: not-allowed;
}

.undo-count { font-size: 0.7rem; opacity: 0.8; }

/* ===== Difficulty Sub-label ===== */
.diff-sub {
    font-size: 0.65rem;
    color: #475569;
    font-weight: 500;
    margin-top: 1px;
}

.diff-option.active .diff-sub { color: rgba(129, 140, 248, 0.7); }

/* ===== New Record Badge ===== */
.new-record-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: linear-gradient(135deg, #fbbf24, #f59e0b);
    color: #000;
    border-radius: 50px;
    padding: 5px 14px;
    font-size: 0.75rem;
    font-weight: 800;
    letter-spacing: 0.5px;
    margin-bottom: 14px;
    animation: bounce-in 0.55s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes bounce-in {
    0%   { transform: scale(0.3); opacity: 0; }
    50%  { transform: scale(1.08); }
    70%  { transform: scale(0.95); }
    100% { transform: scale(1); opacity: 1; }
}
