/* ============================================
   KOD MACERASI - Kodlama Oyunu Stilleri
   ============================================ */

/* Grid Container */
.kod-grid-wrap {
    display: flex;
    justify-content: center;
    margin: 0.5rem 0;
}

.kod-grid {
    display: grid;
    gap: 3px;
    background: #C8E6C9;
    border: 4px solid #81C784;
    border-radius: var(--radius-md);
    padding: 4px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.kod-grid.grid-3x3 { grid-template-columns: repeat(3, 1fr); }
.kod-grid.grid-4x4 { grid-template-columns: repeat(4, 1fr); }
.kod-grid.grid-5x5 { grid-template-columns: repeat(5, 1fr); }
.kod-grid.grid-6x6 { grid-template-columns: repeat(6, 1fr); }
.kod-grid.grid-7x7 { grid-template-columns: repeat(7, 1fr); }

/* Grid Cells */
.kod-cell {
    width: clamp(36px, 12vw, 76px);
    height: clamp(36px, 12vw, 76px);
    background: #E8F5E9;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    position: relative;
    transition: background 0.3s;
}

.kod-cell.obstacle {
    background: #BCAAA4;
    border: 2px solid #8D6E63;
}

.kod-cell.target {
    background: #FFF9C4;
    border: 2px dashed #FFD700;
    animation: targetPulse 2s ease-in-out infinite;
}

.kod-cell.collectible {
    background: #E8F5E9;
}

.kod-cell.start {
    background: #E3F2FD;
}

.kod-cell.robot-here {
    background: #BBDEFB;
    z-index: 2;
}

/* Robot */
.kod-robot {
    position: absolute;
    width: 80%;
    height: 80%;
    transition: transform 0.4s ease;
    z-index: 10;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.2));
}

.kod-robot.dir-up { transform: rotate(0deg); }
.kod-robot.dir-right { transform: rotate(90deg); }
.kod-robot.dir-down { transform: rotate(180deg); }
.kod-robot.dir-left { transform: rotate(270deg); }

.kod-robot.moving {
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.kod-robot.crashed {
    animation: robotCrash 0.5s ease-in-out;
}

/* Program Area */
.kod-program-wrap {
    background: white;
    border-radius: var(--radius-lg);
    padding: 0.6rem;
    margin: 0.5rem auto;
    max-width: 480px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.kod-program-label {
    font-size: 0.7rem;
    color: #888;
    font-weight: 600;
    writing-mode: vertical-rl;
    transform: rotate(180deg);
    letter-spacing: 1px;
    text-transform: uppercase;
}

.kod-program-slots {
    display: flex;
    gap: 6px;
    flex: 1;
    min-height: 52px;
    align-items: center;
}

.kod-program-slot {
    width: 48px;
    height: 48px;
    border: 3px dashed #E0E0E0;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    cursor: pointer;
    flex-shrink: 0;
}

.kod-program-slot.filled {
    border-style: solid;
    border-color: transparent;
    animation: popIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.kod-program-slot.filled:active {
    transform: scale(0.9);
}

.kod-program-slot .slot-block {
    width: 100%;
    height: 100%;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.kod-program-slot .slot-block svg {
    width: 28px;
    height: 28px;
}

/* Play/Reset Buttons */
.kod-action-btns {
    display: flex;
    gap: 6px;
    margin-left: auto;
}

.kod-play-btn, .kod-reset-btn {
    width: 48px;
    height: 48px;
    border: none;
    border-radius: 50%;
    font-size: 1.2rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s, box-shadow 0.2s;
    flex-shrink: 0;
}

.kod-play-btn {
    background: linear-gradient(135deg, #4CAF50, #2E7D32);
    color: white;
    box-shadow: 0 3px 8px rgba(76, 175, 80, 0.4);
}

.kod-play-btn:active { transform: scale(0.92); }
.kod-play-btn:disabled {
    background: #CCC;
    box-shadow: none;
    cursor: not-allowed;
}

.kod-reset-btn {
    background: linear-gradient(135deg, #EF5350, #C62828);
    color: white;
    box-shadow: 0 3px 8px rgba(239, 83, 80, 0.3);
    width: 40px;
    height: 40px;
    font-size: 1rem;
}

.kod-reset-btn:active { transform: scale(0.92); }

/* Block Palette */
.kod-palette {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin: 0.5rem auto;
    padding: 0.6rem;
    background: rgba(255,255,255,0.7);
    border-radius: var(--radius-lg);
    max-width: 400px;
}

.kod-block-btn {
    width: 56px;
    height: 56px;
    border: 3px solid transparent;
    border-radius: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.15s, box-shadow 0.15s;
    box-shadow: 0 3px 6px rgba(0,0,0,0.15);
    position: relative;
}

.kod-block-btn:active {
    transform: scale(0.9);
}

.kod-block-btn svg {
    width: 32px;
    height: 32px;
}

.kod-block-btn.disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* Status Bar */
.kod-status {
    display: flex;
    justify-content: center;
    gap: 1.5rem;
    font-size: 0.85rem;
    color: #666;
    font-weight: 600;
    padding: 0.3rem;
}

.kod-status span {
    background: rgba(255,255,255,0.8);
    padding: 4px 12px;
    border-radius: 20px;
}

/* Animations */
@keyframes targetPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(255, 215, 0, 0.4); }
    50% { box-shadow: 0 0 0 8px rgba(255, 215, 0, 0); }
}

@keyframes robotCrash {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-5px) rotate(-5deg); }
    40% { transform: translateX(5px) rotate(5deg); }
    60% { transform: translateX(-3px) rotate(-3deg); }
    80% { transform: translateX(3px) rotate(3deg); }
}

@keyframes popIn {
    0% { transform: scale(0); }
    100% { transform: scale(1); }
}

/* Robot walking trail */
.kod-cell.trail {
    background: #C5E1A5 !important;
    transition: background 0.3s;
}

.kod-cell.trail::after {
    content: '';
    position: absolute;
    width: 8px;
    height: 8px;
    background: #8BC34A;
    border-radius: 50%;
    opacity: 0.5;
}

/* MP specific styles */
.kod-mp-header {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.8rem;
    padding: 0.4rem;
    font-size: 1rem;
}

.kod-mp-status {
    text-align: center;
    padding: 0.5rem;
    font-weight: 700;
    font-size: 1rem;
    border-radius: var(--radius-md);
    margin: 0.3rem auto;
    max-width: 300px;
    transition: all 0.3s;
}

.kod-mp-status.your-turn {
    background: #E8F5E9;
    color: #2E7D32;
    animation: pulse 1.5s ease-in-out infinite;
}

.kod-mp-status.opponent-turn {
    background: #FFF3E0;
    color: #E65100;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.03); }
}

/* Hamle geçmişi */
.kod-move-history {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 4px;
    padding: 0.4rem;
    margin: 0.3rem auto;
    max-width: 400px;
}

.kod-history-label {
    font-size: 0.75rem;
    color: #999;
    font-weight: 600;
}

.kod-history-chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    font-size: 0.85rem;
    border: 2px solid;
}

.kod-history-chip.blocked {
    opacity: 0.4;
    text-decoration: line-through;
}

.kod-mp-opponent-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font-size: 0.8rem;
    color: #888;
    padding: 0.3rem;
}

.kod-mp-opponent-bar .dot-loading::after {
    content: '...';
    animation: dotPulse 1.5s infinite;
}

@keyframes dotPulse {
    0% { content: '.'; }
    33% { content: '..'; }
    66% { content: '...'; }
}
