/* ============================================
   PUZZLE OYUNU - CSS
   ============================================ */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #1a1a2e;
    color: #fff;
    overflow: hidden;
    width: 100vw;
    height: 100vh;
    user-select: none;
    -webkit-user-select: none;
}

/* ============================================
   BAŞLANGIÇ EKRANI
   ============================================ */

#start-screen {
    width: 100vw;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
}

#start-content {
    text-align: center;
    max-width: 1050px;
    width: 95%;
}

#start-content h1 {
    font-size: 3em;
    margin-bottom: 30px;
    text-shadow: 0 4px 15px rgba(0,0,0,0.3);
}

#start-content h2 {
    font-size: 1.5em;
    margin-bottom: 25px;
    color: #e0e0e0;
}

/* Mod Kartları */
.mode-cards {
    display: flex;
    gap: 20px;
    justify-content: center;
    flex-wrap: wrap;
}

.difficulty-cards {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
}

.mode-card, .difficulty-card {
    background: rgba(255,255,255,0.06);
    border: 2px solid rgba(255,255,255,0.12);
    border-radius: 16px;
    padding: 20px 15px;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    backdrop-filter: blur(4px);
}

.mode-card {
    width: 220px;
    padding: 30px 25px;
}

.difficulty-card {
    width: 140px;
    text-align: center;
}

/* Completed card */
.difficulty-card.completed {
    border-color: rgba(255, 215, 0, 0.35);
    background: rgba(255, 215, 0, 0.06);
}

/* Locked card */
.difficulty-card.locked {
    opacity: 0.45;
    cursor: not-allowed;
    filter: grayscale(0.5);
}

.difficulty-card.locked::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 14px;
    background: repeating-linear-gradient(
        45deg,
        transparent,
        transparent 8px,
        rgba(255,255,255,0.02) 8px,
        rgba(255,255,255,0.02) 16px
    );
    pointer-events: none;
}

.difficulty-card.locked:hover {
    transform: none;
    box-shadow: none;
    border-color: rgba(255,255,255,0.12);
    background: rgba(255,255,255,0.06);
}

/* Lock badge */
.lock-badge {
    position: absolute;
    top: 8px;
    right: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.locked-badge {
    opacity: 0.6;
}

.unlocked-badge {
    opacity: 1;
    animation: unlockPulse 2s ease-in-out infinite;
}

@keyframes unlockPulse {
    0%, 100% { opacity: 0.8; }
    50% { opacity: 1; }
}

/* Star container */
.diff-stars {
    display: flex;
    justify-content: center;
    margin-bottom: 8px;
    min-height: 52px;
    align-items: center;
}

.diff-stars svg {
    display: block;
}

.mode-card:hover, .difficulty-card:hover {
    background: rgba(255,255,255,0.12);
    border-color: #e94560;
    transform: translateY(-5px);
    box-shadow: 0 10px 30px rgba(233, 69, 96, 0.2);
}

.difficulty-card.completed:hover {
    border-color: #ffd700;
    box-shadow: 0 10px 30px rgba(255, 215, 0, 0.15);
}

.mode-card.selected, .difficulty-card.selected {
    background: rgba(233, 69, 96, 0.2);
    border-color: #e94560;
}

.mode-icon {
    font-size: 3em;
    margin-bottom: 10px;
}

.mode-card h3, .difficulty-card h3 {
    font-size: 1.15em;
    margin-bottom: 4px;
}

.mode-card p, .difficulty-card p {
    font-size: 0.9em;
    color: #aaa;
}

/* Geri Butonu */
.back-btn {
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.2);
    color: #fff;
    padding: 10px 20px;
    border-radius: 8px;
    cursor: pointer;
    margin-top: 20px;
    font-size: 1em;
    transition: all 0.2s ease;
}

.back-btn:hover {
    background: rgba(255,255,255,0.2);
}

/* Kategori Seçimi */
#categories-container {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    justify-content: center;
    margin-bottom: 15px;
    min-height: 150px;
}

.category-item {
    width: 160px;
    height: 180px;
    border-radius: 14px;
    overflow: hidden;
    cursor: pointer;
    border: 3px solid rgba(255,255,255,0.1);
    transition: all 0.3s ease;
    background: rgba(0,0,0,0.3);
    display: flex;
    flex-direction: column;
}

.category-item:hover {
    border-color: #e94560;
    transform: scale(1.05);
    box-shadow: 0 5px 20px rgba(233, 69, 96, 0.3);
}

.category-item .cat-thumb {
    width: 100%;
    height: 130px;
    object-fit: cover;
}

.category-item .cat-name {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9em;
    font-weight: 600;
    padding: 4px 8px;
    text-align: center;
    background: rgba(0,0,0,0.4);
}

.category-item.upload-card {
    border: 3px dashed rgba(255,255,255,0.2);
    background: rgba(233, 69, 96, 0.06);
    justify-content: center;
    align-items: center;
    gap: 8px;
}

.category-item.upload-card:hover {
    border-color: #e94560;
    background: rgba(233, 69, 96, 0.12);
}

.upload-card-icon {
    font-size: 2.8em;
    line-height: 1;
}

.upload-card-text {
    font-size: 0.85em;
    font-weight: 600;
    color: #ccc;
    text-align: center;
    padding: 0 8px;
}

#categories-pagination {
    display: flex;
    gap: 8px;
    justify-content: center;
    margin-bottom: 15px;
}

/* Resim Seçimi */
#patterns-container {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    justify-content: center;
    margin-bottom: 15px;
    min-height: 150px;
}

.pattern-item {
    width: 140px;
    height: 140px;
    border-radius: 12px;
    overflow: hidden;
    cursor: pointer;
    border: 3px solid rgba(255,255,255,0.1);
    transition: all 0.3s ease;
    background: rgba(0,0,0,0.3);
    padding: 0;
}

.pattern-item:hover {
    border-color: #e94560;
    transform: scale(1.05);
    box-shadow: 0 5px 20px rgba(233, 69, 96, 0.3);
}

.pattern-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.patterns-loading {
    color: #aaa;
    padding: 40px;
    font-size: 1.1em;
}

/* Pagination */
#patterns-pagination {
    display: flex;
    gap: 8px;
    justify-content: center;
    margin-bottom: 15px;
}

.pagination-btn {
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.2);
    color: #fff;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1em;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.pagination-btn:hover:not(:disabled) {
    background: rgba(255,255,255,0.2);
}

.pagination-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.pagination-btn.active {
    background: #e94560;
    border-color: #e94560;
}

/* ============================================
   OYUN EKRANI
   ============================================ */

#game-screen {
    width: 100vw;
    height: 100vh;
    display: flex;
    flex-direction: column;
    background: #1a1a2e;
}

#game-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 15px;
    background: rgba(0,0,0,0.3);
    border-bottom: 1px solid rgba(255,255,255,0.1);
    z-index: 10;
    min-height: 50px;
}

#game-topbar .btn {
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.2);
    color: #fff;
    padding: 6px 12px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1.1em;
    transition: all 0.2s ease;
}

#game-topbar .btn:hover {
    background: rgba(255,255,255,0.2);
}

#topbar-center {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    flex: 1;
}

#game-info {
    font-size: 0.85em;
    color: #fff;
    background: linear-gradient(135deg, #e94560, #c93650);
    padding: 3px 14px;
    border-radius: 20px;
    font-weight: 600;
    letter-spacing: 0.5px;
}

#progress-wrap {
    width: 180px;
    height: 14px;
    background: rgba(255,255,255,0.1);
    border-radius: 10px;
    overflow: hidden;
    position: relative;
}

#progress-bar {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #4ade80, #22c55e);
    border-radius: 10px;
    transition: width 0.4s ease;
}

#progress-text {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.65em;
    font-weight: 700;
    color: #fff;
    text-shadow: 0 1px 2px rgba(0,0,0,0.5);
}

/* ============================================
   OYUN ALANI
   ============================================ */

#game-area {
    flex: 1;
    display: flex;
    overflow: hidden;
}

/* PLACEMENT MODE */
#placement-area {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: row;
}

#puzzle-board {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    background: rgba(0,0,0,0.2);
}

#board-canvas {
    background: transparent;
}

.pieces-tray {
    width: 180px;
    min-width: 180px;
    background: rgba(0,0,0,0.3);
    overflow-y: auto;
    padding: 8px;
    display: grid;
    grid-template-columns: 1fr;
    gap: 6px;
    align-content: start;
    justify-items: center;
}

.tray-slot {
    width: 100%;
    min-height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
}

#pieces-tray-left {
    border-right: 1px solid rgba(255,255,255,0.1);
}

#pieces-tray-right {
    border-left: 1px solid rgba(255,255,255,0.1);
}

.puzzle-piece {
    cursor: grab;
    position: absolute;
    transition: box-shadow 0.2s ease;
}

.puzzle-piece:active {
    cursor: grabbing;
}

.puzzle-piece.placed {
    cursor: default;
    pointer-events: none;
}

.puzzle-piece.dragging {
    z-index: 1000;
    box-shadow: 0 8px 25px rgba(0,0,0,0.5);
}

.puzzle-piece.returning {
    transition: left 0.6s ease-in-out, top 0.6s ease-in-out, width 0.6s ease-in-out, height 0.6s ease-in-out, transform 0.6s ease-in-out;
}

.puzzle-piece.snapping {
    transition: left 0.2s ease, top 0.2s ease;
}

/* Tray içindeki parçalar */
.tray-piece {
    position: relative !important;
    left: auto !important;
    top: auto !important;
    transition: transform 0.3s ease;
}

/* ROTATION MODE */
#rotation-area {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

#rotation-canvas {
    cursor: pointer;
}

/* SLIDING MODE */
#sliding-area {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,0.2);
}

#sliding-board {
    display: grid;
    gap: 2px;
    background: rgba(0,0,0,0.6);
    border: 2px solid rgba(255,255,255,0.15);
    border-radius: 8px;
    padding: 2px;
    position: relative;
}

.sliding-tile {
    border-radius: 4px;
    overflow: hidden;
    cursor: pointer;
    position: relative;
    transition: transform 0.15s ease-out;
    background-size: cover;
    background-repeat: no-repeat;
}

.sliding-tile:hover:not(.sliding-empty) {
    outline: 2px solid rgba(233, 69, 96, 0.6);
    outline-offset: -2px;
    z-index: 1;
}

.sliding-tile.sliding-movable {
    cursor: pointer;
    box-shadow: 0 0 8px rgba(233, 69, 96, 0.3);
}

.sliding-empty {
    background: rgba(0,0,0,0.4) !important;
    cursor: default;
    border: 2px dashed rgba(255,255,255,0.1);
}

.sliding-tile.sliding-moving {
    transition: none;
    z-index: 10;
}

#sliding-board.shuffling {
    opacity: 0.85;
    transition: opacity 0.3s ease;
}

#sliding-board.shuffling .sliding-tile:not(.sliding-empty) {
    cursor: not-allowed;
}

/* Move counter for sliding mode */
#move-counter {
    font-size: 0.95em;
    color: #ffd700;
    font-weight: bold;
}

/* ============================================
   TAMAMLANDI MODAL
   ============================================ */

#complete-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0,0,0,0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    animation: fadeIn 0.5s ease;
}

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

#complete-modal {
    background: linear-gradient(135deg, #16213e, #0f3460);
    border: 2px solid #e94560;
    border-radius: 20px;
    padding: 40px;
    text-align: center;
    max-width: 500px;
    width: 90%;
    animation: scaleIn 0.5s ease;
}

@keyframes scaleIn {
    from { transform: scale(0.8); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

#complete-modal h2 {
    font-size: 2.2em;
    margin-bottom: 10px;
}

#complete-modal p {
    font-size: 1.1em;
    color: #ccc;
    margin-bottom: 20px;
}

#complete-image {
    margin: 15px auto;
    width: 280px;
    height: 220px;
    border-radius: 12px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,0.2);
}

#complete-image img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 10px;
}

.complete-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin-top: 20px;
}

.complete-buttons .btn {
    background: #e94560;
    border: none;
    color: #fff;
    padding: 12px 25px;
    border-radius: 10px;
    cursor: pointer;
    font-size: 1.1em;
    transition: all 0.2s ease;
}

.complete-buttons .btn:hover {
    background: #c93650;
    transform: translateY(-2px);
}

/* Confetti */
.confetti-piece {
    position: fixed;
    width: 10px;
    height: 10px;
    top: -20px;
    z-index: 10001;
    opacity: 1;
    pointer-events: none;
    animation: confetti-fall linear forwards;
}

@keyframes confetti-fall {
    0% {
        opacity: 1;
        transform: translateY(0) rotate(0deg) scale(1);
    }
    80% {
        opacity: 1;
    }
    100% {
        opacity: 0;
        transform: translateY(105vh) rotate(var(--confetti-spin)) scale(0.4);
    }
}

/* ============================================
   RESPONSIVE
   ============================================ */

@media (max-width: 768px) {
    #start-content h1 {
        font-size: 2em;
    }

    .mode-card {
        width: 160px;
        padding: 20px 15px;
    }

    .difficulty-card {
        width: 120px;
        padding: 14px 10px;
    }

    .mode-icon {
        font-size: 2em;
    }

    .pattern-item {
        width: 100px;
        height: 100px;
    }

    #placement-area {
        flex-direction: column;
    }

    .pieces-tray {
        width: 100%;
        height: 120px;
        min-width: unset;
        border-left: none;
        border-right: none;
        border-top: 1px solid rgba(255,255,255,0.1);
        grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
        grid-template-rows: 1fr;
        overflow-x: auto;
        overflow-y: hidden;
    }

    .tray-slot {
        min-height: unset;
        min-width: 80px;
    }
}

/* ============================================
   HINT OVERLAY
   ============================================ */

#hint-overlay {
    position: absolute;
    top: 0;
    left: 0;
    pointer-events: none;
    z-index: 50;
    opacity: 0.3;
    transition: opacity 0.5s ease;
}

/* ============================================
   SCROLLBAR
   ============================================ */

#pieces-tray::-webkit-scrollbar {
    width: 6px;
}

#pieces-tray::-webkit-scrollbar-track {
    background: transparent;
}

#pieces-tray::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.2);
    border-radius: 3px;
}

#pieces-tray::-webkit-scrollbar-thumb:hover {
    background: rgba(255,255,255,0.3);
}
