:root {
    /* Görselden alınan renk paleti */
    --bg-color: #EEDC9A;
    --active-color: #FFB74D; /* Turuncu - ziyaret edilmiş hücreler */
    --dark-color: #1A1812;
    --path-color: #FFB74D; /* Turuncu - connector'lar */
    --text-color: #1A1812;
}

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    margin: 0;
    padding: 0;
    height: 100vh;
    overflow: hidden;
}

.main-container {
    width: 100%;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    box-sizing: border-box;
}

.game-container {
    display: flex;
    flex-direction: column;
    gap: 20px;
    padding: 20px;
    max-width: 1400px;
    width: 100%;
    height: auto;
    min-height: calc(100vh - 140px);
    box-sizing: border-box;
}

/* Oyun Alanı */
.board-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding-top: 90px; /* Header için alan (24px top + 16px bottom + 50px content) */
}

.header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    width: 100%;
    background: var(--bg-color);
    z-index: 1000;
    border: none;
    padding-top: 24px;
    padding-bottom: 16px;
}

.header-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.header-center {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
}

.header-title {
    font-size: 22px;
    font-weight: 600;
    color: var(--dark-color);
    margin: 0;
    font-family: 'Poppins', sans-serif;
    letter-spacing: -0.2px;
}

.header-subtitle {
    font-size: 14px;
    font-weight: 400;
    color: var(--dark-color);
    margin-top: 4px;
    opacity: 0.8;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.header-icon {
    cursor: pointer;
    font-size: 20px;
    color: var(--dark-color);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    transition: opacity 0.2s;
}

.header-icon:hover {
    opacity: 0.7;
}

.header-nav-icon {
    cursor: pointer;
    font-size: 18px;
    color: var(--dark-color);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    transition: opacity 0.2s;
}

.header-nav-icon:hover {
    opacity: 0.7;
}


/* Modal Overlay */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: 1000;
    justify-content: center;
    align-items: center;
    animation: fadeIn 0.2s ease;
}

.modal-overlay.active {
    display: flex;
}

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

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
    transform: translateY(0);
}
}

@keyframes resetPulse {
    0% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.3;
        transform: scale(0.95);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

.grid-resetting {
    animation: resetPulse 0.6s ease;
}

/* Ayarlar Modal */
.settings-modal {
    background: white;
    border-radius: 16px;
    padding: 0;
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow: hidden;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
    animation: slideUp 0.3s ease;
    display: flex;
    flex-direction: column;
}

.settings-modal::-webkit-scrollbar {
    width: 6px;
}

.settings-modal::-webkit-scrollbar-track {
    background: transparent;
}

.settings-modal::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 3px;
}

.settings-modal-header {
    padding: 24px 24px 16px 24px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.settings-modal-header h3 {
    margin: 0;
    font-size: 20px;
    font-weight: 700;
    color: var(--dark-color);
}

.modal-close-btn {
    background: none;
    border: none;
    font-size: 24px;
    color: var(--dark-color);
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    transition: all 0.2s ease;
    opacity: 0.6;
}

.modal-close-btn:hover {
    background: rgba(0, 0, 0, 0.05);
    opacity: 1;
}

.settings-content {
    padding: 24px;
    overflow-y: auto;
    flex: 1;
}

.settings-content h3 {
    margin: 0 0 20px 0;
    font-size: 18px;
    font-weight: 600;
    color: var(--dark-color);
}

.settings-group {
    margin-bottom: 24px;
    padding: 20px;
    background: rgba(0, 0, 0, 0.02);
    border-radius: 12px;
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.settings-group:last-child {
    margin-bottom: 0;
}

.settings-group h4 {
    margin: 0 0 16px 0;
    font-size: 12px;
    font-weight: 700;
    color: var(--dark-color);
    text-transform: uppercase;
    letter-spacing: 1px;
    opacity: 0.8;
}

.setting-item {
    margin-bottom: 12px;
    padding: 12px;
    background: white;
    border-radius: 8px;
    border: 1px solid rgba(0, 0, 0, 0.08);
    transition: all 0.2s ease;
}

.setting-item:hover {
    border-color: rgba(0, 0, 0, 0.15);
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.setting-item:last-child {
    margin-bottom: 0;
}

.setting-item label {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    font-size: 14px;
    color: var(--dark-color);
    font-weight: 500;
    margin: 0;
}

.setting-item input[type="radio"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
    accent-color: var(--active-color);
}

.setting-item input[type="checkbox"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
    accent-color: var(--active-color);
}

.action-buttons {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.check-btn {
    width: 60px;
    height: 60px;
    padding: 0;
    background: var(--active-color);
    color: var(--dark-color);
    border: 2px solid var(--dark-color);
    border-radius: 8px;
    font-weight: 600;
    font-size: 20px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.check-btn.correct {
    background: #4caf50;
    color: white;
    border-color: #4caf50;
}

.check-btn.incorrect {
    background: #f44336;
    color: white;
    border-color: #f44336;
}

.check-btn:hover:not(.correct):not(.incorrect) {
    background: #FF8F00;
    transform: scale(1.05);
}

.check-btn:active {
    transform: scale(0.95);
}

.action-btn {
    width: 60px;
    height: 60px;
    padding: 0;
    background: rgba(255, 255, 255, 0.1);
    color: var(--dark-color);
    border: 2px solid var(--dark-color);
    border-radius: 8px;
    font-weight: 600;
    font-size: 18px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

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

.action-btn:active {
    transform: scale(0.95);
}

.grid {
    display: grid;
    /* Default 10x10; script.js overrides per-level via inline style */
    grid-template-columns: repeat(10, 1fr);
    gap: 6px;
    background-color: rgba(0,0,0,0.03);
    padding: 10px;
    border-radius: 12px;
    position: relative;
}

.cell {
    width: 35px;
    height: 35px;
    background-color: var(--dark-color);
    border-radius: 50%;
    cursor: pointer;
    position: relative;
    transition: transform 0.2s, background-color 0.3s;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2;
}

.cell:hover {
    transform: scale(1.08);
    opacity: 0.9;
}

/* Ziyaret Edilmiş Hücreler (Turuncu) */
.cell.visited {
    background-color: var(--active-color);
    z-index: 2;
}

/* Aktif (Son Seçilmiş) Hücre (Koyu Turuncu) */
/* Aktif hücre (renkli hücreler hariç) */
.cell.active:not(.colored-cell) {
    background-color: #FF8F00; /* Koyu turuncu - nerede kaldığımızı görmek için */
    z-index: 2;
}

/* Renkli hücre aktif olduğunda, rengini koru (inline style'dan gelir) */
.cell.active.colored-cell {
    z-index: 2;
    opacity: 1 !important;
    /* background-color inline style'dan gelir, override etmiyoruz */
}

/* Aktif hücre pulse animasyonu (bulunduğumuz konum) */
.cell.active {
    position: relative;
}

.cell.active::after {
    content: '';
    position: absolute;
    inset: -3px;
    border-radius: 50%;
    border: 3px solid rgba(255, 193, 7, 0.9);
    box-shadow: 0 0 0 0 rgba(255, 193, 7, 0.45);
    animation: activePulse 1.1s ease-in-out infinite;
    pointer-events: none;
    z-index: 3;
}

@keyframes activePulse {
    0% {
        transform: scale(0.92);
        opacity: 0.85;
        box-shadow: 0 0 0 0 rgba(255, 193, 7, 0.45);
    }
    50% {
        transform: scale(1.08);
        opacity: 0.35;
        box-shadow: 0 0 0 10px rgba(255, 193, 7, 0);
    }
    100% {
        transform: scale(0.92);
        opacity: 0.85;
        box-shadow: 0 0 0 0 rgba(255, 193, 7, 0.45);
    }
}

/* Başlangıç Noktası (Mor Nokta) */
.cell.start-point {
    position: relative;
}

.cell.start-point::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 12px;
    height: 12px;
    background: #ffffff; /* Badge ile aynı renk (mor) */
    border-radius: 50%;
    z-index: 6;
}

/* When start cell is also active, hide the inner dot (requested) */
.cell.start-point.active::after {
    display: none;
}

/* ===== Variables (chest) ===== */
.cell.has-var {
    position: relative;
}

.var-box {
    position: absolute;
    inset: 6px;
   
   
    color: #ffffff;
    font-size: 12px;
    font-weight: 900;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    letter-spacing: 0.2px;
    z-index: 4;
    pointer-events: none;
   
}

.var-box i {
     margin-top: -2px;
    font-size: 25px;
    line-height: 1;
}

.var-box span {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -58%);
    font-size: 12px;
    font-weight: 900;
    line-height: 1;
    color: #0c0c0c;
    margin-top: 2px;
   
}

/* HUD for current variable value */
#var-hud {
    position: fixed;
    right: 18px;
    top: 120px;
    display: none;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    border-radius: 16px;
    background: rgba(15, 23, 42, 0.78);
    color: #fff;
    z-index: 9999;
    box-shadow: 0 10px 24px rgba(0,0,0,0.18);
    backdrop-filter: blur(8px);
}

#var-hud .var-hud-icon {
    width: 38px;
    height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    background: rgba(255,255,255,0.10);
}

#var-hud .var-hud-value {
    font-weight: 900;
    font-size: 20px;
    letter-spacing: 0.2px;
}

#var-hud.is-inc { background: rgba(34, 197, 94, 0.78); }
#var-hud.is-dec { background: rgba(239, 68, 68, 0.78); }
#var-hud.is-set { background: rgba(59, 130, 246, 0.78); }

#var-hud.var-hud-pulse {
    animation: varHudPulse 650ms ease-out;
}

@keyframes varHudPulse {
    0% { transform: scale(1); filter: brightness(1); }
    35% { transform: scale(1.10); filter: brightness(1.25); }
    100% { transform: scale(1); filter: brightness(1); }
}

/* === Level explanation modal (bolum-detay) === */
.level-expl-overlay{
    position: fixed;
    inset: 0;
    background: rgba(2, 6, 23, 0.82);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.level-expl-modal{
    width: min(1040px, calc(100vw - 28px));
    height: min(88vh, 760px);
    background: rgba(255,255,255,0.98);
    border-radius: 18px;
    box-shadow: 0 18px 80px rgba(0,0,0,0.35);
    position: relative;
    padding: 18px 18px 14px 18px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    font-family: "Poppins", "Inter", system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
}
.level-expl-close{
    position: absolute;
    top: 12px;
    right: 12px;
    width: 44px;
    height: 44px;
    border-radius: 12px;
    border: 0;
    background: rgba(15, 23, 42, 0.08);
    font-size: 28px;
    line-height: 1;
    cursor: pointer;
}
.level-expl-header{
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    padding-right: 54px;
}
.level-expl-title{
    font-weight: 900;
    color: #0f172a;
    font-size: 18px;
    margin-left: 8px;
}
.level-expl-counter{
    font-weight: 800;
    color: rgba(15, 23, 42, 0.55);
}
.level-expl-body{
    margin-top: 12px;
    flex: 1;
    overflow: hidden;
    padding: 6px 4px 6px 4px;
    display: flex;
    flex-direction: column;
    min-height: 0;
}
.level-expl-text-wrap{
    padding: 2px 4px 12px 4px;
    overflow: auto;
    max-height: 34%;
    min-height: 60px;
}
.level-expl-text-block{
    margin-bottom: 16px;
    padding-bottom: 14px;
    border-bottom: 1px solid rgba(15, 23, 42, 0.10);
}
.level-expl-text-block:last-child{
    border-bottom: 0;
    padding-bottom: 0;
    margin-bottom: 12px;
}
.level-expl-media-wrap{
    padding: 0 4px 6px 4px;
    flex: 1;
    min-height: 0;
}
.level-expl-text{
    font-size: 16px;
    line-height: 1.6;
    color: rgba(15, 23, 42, 0.9);
    font-weight: 400;
}
.level-expl-media{
    width: 100%;
    height: 100%;
    min-height: 260px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px;
    box-sizing: border-box;
}
.level-expl-media img,
.level-expl-media video,
.level-expl-media iframe{
    width: 100%;
    height: 100%;
    border-radius: 14px;
    background: rgba(2,6,23,0.08);
    object-fit: contain;
}
.level-expl-media video,
.level-expl-media iframe{
    aspect-ratio: 16 / 9;
}
.level-expl-caption{
    margin-top: 10px;
    color: rgba(15, 23, 42, 0.72);
    font-weight: 800;
    font-size: 13px;
}
.level-expl-nav{
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 48px;
    height: 56px;
    border-radius: 14px;
    border: 0;
    background: rgba(15, 23, 42, 0.12);
    font-size: 26px;
    cursor: pointer;
}
.level-expl-nav.prev{ left: 10px; }
.level-expl-nav.next{ right: 10px; }

/* Bağlantı Yolları (Görseldeki kalın çizgiler) */
.connector {
    position: absolute;
    background-color: var(--path-color);
    z-index: 1; /* Dairelerin arkasında (z-index: 2) */
    box-sizing: border-box;
    pointer-events: none;
    transition: transform 0.2s;
    /* transform-origin JavaScript'te ayarlanıyor */
}


/* Alt Taraf: Yönergeler */
.sidebar-wrapper {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    max-width: 100%;
    overflow: visible;
    position: relative;
    }

.sidebar {
    flex: 1;
    min-width: 0;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    padding: 20px 12px 12px 12px;
    display: flex;
    flex-direction: column;
    overflow: visible;
    position: relative;
}

.instruction-list {
    list-style: none;
    padding: 20px 6px 4px 6px;
    margin: 0;
    display: flex;
    flex-direction: row;
        gap: 8px;
    overflow-x: auto;
    overflow-y: visible;
    align-items: flex-start;
    scroll-behavior: smooth;
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE and Edge */
    min-width: 0;
    width: 100%;
    cursor: grab;
    user-select: none;
    -webkit-user-select: none;
}

.instruction-list::-webkit-scrollbar {
    display: none; /* Chrome, Safari, Opera */
}

.instruction-list.dragging {
    cursor: grabbing;
    scroll-behavior: auto;
}

.instruction-item {
    width: 60px;
    height: 60px;
    background: rgba(0, 0, 0, 0.05);
    color: var(--dark-color);
    border-radius: 8px;
    font-size: 10px;
    font-weight: 400;
    opacity: 0.4;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    border: 2px solid transparent;
    flex-shrink: 0;
    position: relative; /* allow badges (e.g. +1/-2) to anchor correctly */
}

.instruction-item.start {
    background: #4caf50;
    color: white;
    opacity: 1;
    font-weight: 600;
}

.instruction-item.end {
    background: #f44336;
    color: white;
    opacity: 1;
    font-weight: 600;
}

.instruction-item.loop-start {
    background: #FFA500;
    color: white;
    opacity: 1;
    font-weight: 600;
    position: relative;
    width: 40px;
    min-width: 40px;
}

.loop-repeat-badge {
    position: absolute;
    top: -18px;
    left: 50%;
    transform: translateX(-50%);
    background: #FFA500;
    color: white;
    width: 32px;
    height: 20px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 700;
    border: none;
    box-shadow: none;
    z-index: 10;
}

.ask-badge{
    position: absolute;
    top: -18px;
    left: 50%;
    transform: translateX(-50%);
    background: #9C27B0;
    color: white;
    width: 26px;
    height: 20px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 900;
    z-index: 10;
}

.ask-popover{
    position: absolute;
    left: 50%;
    bottom: 100%;
    transform: translateX(-50%);
    margin-bottom: 20px;
    z-index: 50;
    background: rgba(255, 255, 255, 0.96);
    border: 2px solid rgba(156, 39, 176, 0.35);
    border-radius: 12px;
    padding: 10px 10px;
    box-shadow: 0 12px 30px rgba(0,0,0,0.16);
    min-width: 120px;
    display: flex;
    gap: 6px;
    align-items: center;
}

.ask-popover.ask-popover-floating{
    position: fixed;
    left: 0;
    top: 0;
    bottom: auto;
    transform: none;
}
.ask-popover input{
    height: 32px;
    border-radius: 10px;
    border: 2px solid rgba(156, 39, 176, 0.28);
    padding: 0 10px;
    font-weight: 800;
    outline: none;
    width: 32px;
    background: rgba(156, 39, 176, 0.08);
    color: var(--dark-color);
}
.ask-popover input.is-wrong{
    border-color: rgba(244, 67, 54, 0.8);
}
.ask-popover button{
    height: 32px;
    border-radius: 10px;
    border: 0;
    
    color: #fff;
    font-weight: 900;
    padding: 0 10px;
    cursor: pointer;
}

.ask-stepper{
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.ask-stepper .ask-step{
    width: 30px;
    height: 20px;
    border-radius: 8px;
    padding: 0;
    background: #1A1812;
    color: #fff;
    border: 2px solid rgba(26, 24, 18, 0.10);
    display: flex;
    align-items: center;
    justify-content: center;
}
.ask-stepper .ask-step i{ font-size: 11px; }

.ask-clear{
    width: 34px;
    padding: 0;
    background: #db0707;
    color: var(--dark-color);
    border: 2px solid rgba(26, 24, 18, 0.10);
}
.ask-ok{
    width: 34px;
    padding: 0;
    background: #07db63;
}
.ask-popover button:active{
    transform: scale(0.98);
}

.instruction-item.loop-end {
    background: #FFA500;
    color: white;
    opacity: 1;
    font-weight: 600;
    width: 40px;
    min-width: 40px;
}

.instruction-item.outer-loop {
    height: 70px;
}

/* ========== IF-ELSE STYLES (BAŞLANGIÇ) ========== */
.instruction-item.if-start {
    background: #9C27B0;
    color: white;
    opacity: 1;
    font-weight: 600;
    width: 40px;
    min-width: 40px;
    position: relative;
}

.if-condition-badge {
    position: absolute;
    top: -18px;
    left: 50%;
    transform: translateX(-50%);
    color: white;
    width: 24px;
    min-width: 24px;
    height: 20px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
    border: 5px solid #9C27B0;
    box-shadow: none;
    z-index: 10;
    padding: 0;
}

.if-condition-badge.is-var {
    border: 0;
    width: auto;
    min-width: auto;
    padding: 0 5px 5px 5px;
    gap: 6px;
}

.instruction-item.if-end {
    background: #9C27B0;
    color: white;
    opacity: 1;
    font-weight: 600;
    width: 40px;
    min-width: 40px;
}

.if-content-container {
    height: 66px;
    min-height: 66px;
    width: auto !important;
    min-width: auto !important;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex-shrink: 0;
    overflow: visible;
    background: transparent !important;
    border: none !important;
    border-radius: 0 !important;
}

.if-true-container {
    height: 30px;
    min-height: 30px;
    max-height: 30px;
    width: 100%;
    display: flex;
    flex-direction: row;
    gap: 6px;
    align-items: center;
    justify-content: flex-start;
    overflow-x: visible;
    flex-shrink: 0;
}

.if-false-container {
    height: 30px;
    min-height: 30px;
    max-height: 30px;
    width: 100%;
    display: flex;
    flex-direction: row;
    gap: 6px;
    align-items: center;
    justify-content: flex-start;
    overflow-x: visible;
    flex-shrink: 0;
}

.instruction-item.if-content {
    height: 25px;
    min-height: 25px;
    width: 60px;
    min-width: 60px;
}

.instruction-item.if-content.if-true {
    background: rgba(76, 175, 80, 0.3) !important;
}

.instruction-item.if-content.if-false {
    background: rgba(244, 67, 54, 0.3) !important;
}

.instruction-item.if-content .icon {
    font-size: 14px;
}

.instruction-item.if-content .text {
    font-size: 8px;
}

/* "Sadece IF" (else yok) için normal boyutlu item */
.instruction-item.if-single {
    width: 60px;
    min-width: 60px;
    height: 60px;
    min-height: 60px;
}

.instruction-item.if-single.if-true {
    background: rgba(76, 175, 80, 0.3) !important;
}
/* ========== IF-ELSE STYLES (BİTİŞ) ========== */

.loop-connection-svg {
    position: absolute;
    pointer-events: none;
    z-index: 0;
}

.loop-connection-svg svg {
    display: block;
    width: 100%;
    height: 100%;
}

.loop-connection-svg path {
    fill: none;
    stroke: #FFA500;
    stroke-width: 3;
}

.loop-connection-svg.if-connection path {
    stroke: #9C27B0;
}

.instruction-item.current {
    background: repeating-linear-gradient(
        45deg,
        rgba(255, 193, 7, 0.15),
        rgba(255, 193, 7, 0.15) 10px,
        rgba(255, 193, 7, 0.25) 10px,
        rgba(255, 193, 7, 0.25) 20px
    );
    background-color: rgba(255, 193, 7, 0.1);
    color: var(--dark-color);
    opacity: 1;
    font-weight: 600;
    border: 2px dashed rgba(255, 193, 7, 0.8);
    transform: scale(1.05);
    box-shadow: 0 0 0 2px rgba(255, 193, 7, 0.3);
}

/* showCurrent false ise current class'ının görsel özelliklerini gizle */
body.hide-current .instruction-item.current {
    background: rgba(0, 0, 0, 0.05) !important;
    background-color: rgba(0, 0, 0, 0.05) !important;
    color: var(--dark-color) !important;
    opacity: 0.4 !important;
    font-weight: 400 !important;
    border: 2px solid transparent !important;
    transform: scale(1) !important;
    box-shadow: none !important;
}

.instruction-item.completed {
    opacity: 0.25;
}

/* Completed tick overlay (optional) */
body.show-ticks .instruction-item.completed:not(.start):not(.end)::after {
    content: '✓';
    position: absolute;
    top: -10px;
    right: -10px;
    width: 22px;
    height: 22px;
    border-radius: 999px;
    background: #4caf50;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 900;
    font-size: 14px;
    box-shadow: 0 10px 18px rgba(0,0,0,0.16);
    z-index: 20;
    opacity: 1;
}

/* İkonlar */
.icon {
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.instruction-item .text {
    font-size: 9px;
    text-align: center;
    line-height: 1.2;
}

/* Yazı olmadığında icon'ları büyüt */
.instruction-item.no-text .icon {
    font-size: 28px;
}

#status-msg {
    margin-top: 10px;
    padding: 8px 12px;
    background: rgba(0, 0, 0, 0.02);
    border-radius: 4px;
    font-weight: 600;
    font-size: 14px;
    min-height: 18px;
    text-align: center;
    color: var(--dark-color);
    opacity: 0.7;
}

/* Responsive Tasarım */
@media (max-width: 1024px) {
    .main-container {
        padding: 15px;
        padding-bottom: 0;
    }

    .game-container {
        height: auto;
        min-height: calc(100vh - 180px);
        padding: 15px;
        padding-bottom: 0;
        margin-bottom: 180px;
    }

    .grid {
        gap: 6px;
        padding: 10px;
    }

    .cell {
        width: 35px;
        height: 35px;
    }

    .sidebar-wrapper {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: var(--bg-color);
        padding: 12px;
        z-index: 100;
        box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
        max-height: 180px;
        border-top: 1px solid rgba(0, 0, 0, 0.1);
    }
}

@media (max-width: 768px) {
    .main-container {
        padding: 10px;
        padding-bottom: 0;
    }

    .game-container {
        padding: 12px;
        padding-bottom: 0;
        gap: 12px;
        height: auto;
        min-height: calc(100vh - 160px);
        margin-bottom: 160px;
    }

    .header {
        font-size: 18px;
        margin-bottom: 10px;
    }

    .grid {
        gap: 5px;
        padding: 8px;
        /* Prevent full-width stretching on mobile: keep grid compact so dots don't "spread apart" */
        display: inline-grid;
        width: fit-content;
        max-width: 100%;
        box-sizing: border-box;
    }

    .cell {
        width: calc((100vw - 80px) / 10 - 5px);
        height: calc((100vw - 80px) / 10 - 5px);
        max-width: 35px;
        max-height: 35px;
        min-width: 28px;
        min-height: 28px;
    }

    .connector {
        border-top-width: 2px;
        border-bottom-width: 2px;
        border-left-width: 2px;
        border-right-width: 2px;
    }

    .sidebar-wrapper {
        gap: 10px;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: var(--bg-color);
        padding: 12px;
        z-index: 100;
        box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
        max-height: 160px;
        overflow-y: auto;
        border-top: 1px solid rgba(0, 0, 0, 0.1);
    }

    .sidebar {
        padding: 12px;
        max-height: 100%;
        overflow-y: auto;
    }

    .instruction-list {
        gap: 6px;
    }

    .instruction-item {
        width: 55px;
        height: 55px;
        min-width: 55px;
    }

    .instruction-item.loop-start,
    .instruction-item.loop-end,
    .instruction-item.if-start,
    .instruction-item.if-end {
        width: 37px;
        min-width: 37px;
    }

    .icon {
        font-size: 20px;
    }

    .instruction-item .text {
        font-size: 9px;
    }

    .instruction-item.no-text .icon {
        font-size: 28px;
    }

    .check-btn {
        width: 55px;
        height: 55px;
        font-size: 22px;
        min-width: 55px;
    }

    #status-msg {
        font-size: 12px;
        font-weight: 600;
        padding: 6px 8px;
    }
}

@media (max-width: 480px) {
    .main-container {
        padding: 8px;
        padding-bottom: 0;
    }

    .game-container {
        padding: 10px;
        padding-bottom: 0;
        gap: 10px;
        margin-bottom: 150px;
    }

    .header {
        font-size: 16px;
        margin-bottom: 8px;
    }

    .grid {
        gap: 4px;
        padding: 6px;
        /* Keep compact on phones too */
        display: inline-grid;
        width: fit-content;
        max-width: 100%;
    }

    .cell {
        width: calc((100vw - 64px) / 10 - 4px);
        height: calc((100vw - 64px) / 10 - 4px);
        max-width: 30px;
        max-height: 30px;
        min-width: 24px;
        min-height: 24px;
    }

    .sidebar-wrapper {
        padding: 10px;
        max-height: 150px;
    }

    .sidebar {
        padding: 10px;
    }

    .instruction-list {
        gap: 5px;
    }

    .instruction-item {
        width: 50px;
        height: 50px;
        min-width: 50px;
    }

    .instruction-item.loop-start,
    .instruction-item.loop-end,
    .instruction-item.if-start,
    .instruction-item.if-end {
        width: 33px;
        min-width: 33px;
    }

    .icon {
        font-size: 18px;
    }

    .instruction-item.no-text .icon {
        font-size: 26px;
    }

    .check-btn {
        width: 50px;
        height: 50px;
        font-size: 20px;
        min-width: 50px;
    }

    .instruction-item .text {
        font-size: 8px;
    }
}

/* Completion Modal */
.completion-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(26, 24, 18, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10000;
    animation: fadeIn 0.2s ease-out;
}

.completion-modal {
    background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
    border-radius: 20px;
    padding: 40px 36px;
    max-width: 380px;
    width: calc(100% - 40px);
    text-align: center;
    box-shadow: 0 12px 48px rgba(26, 24, 18, 0.25), 0 0 0 1px rgba(26, 24, 18, 0.08);
    animation: slideUp 0.3s ease-out;
    position: relative;
    overflow: hidden;
}

.completion-modal::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, #4CAF50 0%, #81C784 100%);
}

.completion-icon {
    font-size: 72px;
    color: #4CAF50;
    margin-bottom: 20px;
    animation: scaleIn 0.4s ease-out;
    filter: drop-shadow(0 4px 8px rgba(76, 175, 80, 0.2));
}

.completion-icon i {
    display: inline-block;
}

.completion-title {
    font-size: 28px;
    font-weight: 700;
    color: var(--dark-color);
    margin: 0 0 12px 0;
    font-family: 'Inter', sans-serif;
    letter-spacing: -0.5px;
}

.completion-message {
    font-size: 15px;
    color: var(--dark-color);
    margin: 0 0 28px 0;
    opacity: 0.75;
    font-family: 'Inter', sans-serif;
    line-height: 1.5;
}

.completion-btn {
    background: linear-gradient(135deg, var(--dark-color) 0%, #2a2720 100%);
    color: var(--bg-color);
    border: none;
    border-radius: 10px;
    padding: 14px 28px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    transition: all 0.2s ease;
    font-family: 'Inter', sans-serif;
    box-shadow: 0 4px 12px rgba(26, 24, 18, 0.15);
}

.completion-btn:hover {
    background: #2a2720;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(26, 24, 18, 0.3);
}

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

.completion-btn i {
    font-size: 14px;
}

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

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

