/* Variabile CSS pentru o mai bună mentenanță */
:root {
    --color-primary-bg: #0f1419;
    --color-secondary-bg: #1a1a2e;
    --color-tertiary-bg: #16213e;
    --color-success: #00ff00;
    --color-warning: #ff4444;
    --color-info: #ffff00;
    --color-text-light: #ffaa00;
    --color-dark-bg: rgba(0, 50, 100, 0.3);
    --border-main: 2px solid var(--color-success);
    --shadow-success: 0 0 30px rgba(0, 255, 0, 0.3);
}

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

body {
    font-family: 'Courier New', monospace;
    background: linear-gradient(135deg, var(--color-primary-bg) 0%, var(--color-secondary-bg) 50%, var(--color-tertiary-bg) 100%);
    color: var(--color-success);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    font-size: 16px; /* Dimensiune font implicită pentru mobil */
}

.container {
    text-align: center;
    width: 100%;
    max-width: 800px;
    padding: 20px;
    margin: 0 auto; /* Centrează containerul */
}

.warning-banner {
    background: linear-gradient(45deg, var(--color-warning), #ff6666);
    color: white;
    padding: 15px;
    border-radius: 10px;
    margin-bottom: 20px;
    box-shadow: 0 0 20px rgba(255, 68, 68, 0.5);
    animation: pulse 2s infinite;
    font-size: 1em; /* Ajustare pentru mobil */
}

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

.control-panel {
    background: var(--color-dark-bg);
    border: var(--border-main);
    border-radius: 15px;
    padding: 20px; /* Redus padding-ul pentru mobil */
    box-shadow: var(--shadow-success);
    backdrop-filter: blur(10px);
}

.timer {
    font-size: 2em; /* Ajustare pentru mobil */
    color: var(--color-warning);
    margin-bottom: 15px;
    text-shadow: 0 0 10px var(--color-warning);
}

.timer.critical {
    animation: pulse 0.5s infinite; /* Aplica animația doar când e critic */
}

.level-info {
    font-size: 1.1em; /* Ajustare pentru mobil */
    margin-bottom: 15px;
    color: var(--color-info);
}

.cables-container,
.slots-container {
    display: grid;
    gap: 10px; /* Redus gap-ul pentru mobil */
    margin: 15px 0;
    justify-content: center;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); /* Adaptiv */
}

.cable {
    width: 100%; /* Ocupă lățimea disponibilă în grid */
    max-width: 150px; /* Lățime maximă pentru cablu */
    height: 40px;
    border-radius: 20px;
    border: 3px solid;
    cursor: grab;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
    margin: 0 auto; /* Centrează cablul în celulă */
    position: relative; /* Adăugat pentru poziționarea în slot */
    color: white; /* Culoare text implicită */
}

.cable:hover:not(.dragging) { /* Aplică hover doar dacă nu e dragat */
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(255,255,255,0.2);
}

.cable.dragging {
    cursor: grabbing;
    transform: rotate(5deg) scale(1.1);
    opacity: 0.8; /* Adaugă o mică opacitate când e dragat */
}

/* Culorile cablurilor - Rămân neschimbate */
.red { background: linear-gradient(45deg, #ff4444, #ff6666); border-color: #ff2222; }
.blue { background: linear-gradient(45deg, #4444ff, #6666ff); border-color: #2222ff; }
.green { background: linear-gradient(45deg, #44ff44, #66ff66); border-color: #22ff22; }
.yellow { background: linear-gradient(45deg, #ffff44, #ffff66); border-color: #ffff22; color: black; }
.purple { background: linear-gradient(45deg, #ff44ff, #ff66ff); border-color: #ff22ff; }
.orange { background: linear-gradient(45deg, #ff8844, #ffaa66); border-color: #ff6622; }
.cyan { background: linear-gradient(45deg, #44ffff, #66ffff); border-color: #22ffff; color: black; }
.pink { background: linear-gradient(45deg, #ff88cc, #ffaadd); border-color: #ff66bb; color: black; }
.lime { background: linear-gradient(45deg, #88ff44, #aaff66); border-color: #66ff22; color: black; }
.brown { background: linear-gradient(45deg, #aa6644, #cc8866); border-color: #884422; }


.slot {
    width: 100%; /* Ocupă lățimea disponibilă în grid */
    max-width: 160px; /* Lățime maximă pentru slot */
    height: 50px;
    border: 3px dashed #666;
    border-radius: 25px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,0.5);
    transition: all 0.3s ease;
    margin: 0 auto; /* Centrează slotul în celulă */
    position: relative; /* Pentru a poziționa cablul în el */
    overflow: hidden; /* Pentru a ascunde eventualele depășiri ale cablului */
}

.slot.drag-over {
    border-color: var(--color-success);
    background: rgba(0,255,0,0.1);
    transform: scale(1.05);
}

.slot.filled {
    border-style: solid;
    border-color: var(--color-success);
    background: rgba(0,255,0,0.2); /* O culoare de fundal care indică umplerea */
    color: transparent; /* Ascunde textul slotului când este umplut */
}

/* Stil pentru cablu când este plasat în slot */
.slot .cable {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%) !important; /* Anulează orice transformare de la dragging/hover */
    pointer-events: none; /* Nu mai este dragabil */
    box-shadow: none; /* Fără umbră după ce e conectat */
    width: 90%; /* Ajustează dimensiunea cablului în slot */
    height: 90%;
}


.btn {
    background: linear-gradient(45deg, #00aa00, var(--color-success));
    border: none;
    color: white;
    padding: 12px 25px; /* Redus padding-ul pentru mobil */
    font-size: 1em; /* Ajustare pentru mobil */
    border-radius: 25px;
    cursor: pointer;
    margin: 10px;
    transition: all 0.3s ease;
    font-family: inherit;
    text-transform: uppercase;
    font-weight: bold;
    box-shadow: 0 4px 10px rgba(0,255,0,0.2); /* Umbră subtilă */
}

.btn:hover {
    transform: scale(1.05); /* Scara mai mică pentru o tranziție mai lină */
    box-shadow: 0 6px 20px rgba(0,255,0,0.6);
}

.message {
    font-size: 1.1em; /* Ajustare pentru mobil */
    margin: 15px 0;
    padding: 10px;
    border-radius: 10px;
    animation: fadeIn 0.5s ease;
}

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

.success {
    background: rgba(0,255,0,0.2);
    border: 2px solid var(--color-success);
    color: var(--color-success);
}

.danger {
    background: rgba(255,0,0,0.2);
    border: 2px solid var(--color-warning);
    color: var(--color-warning);
}

.sparks {
    position: absolute;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: -1;
}

.spark {
    position: absolute;
    width: 4px;
    height: 4px;
    background: var(--color-info);
    border-radius: 50%;
    animation: sparkle 1s forwards ease-out; /* 'forwards' pentru a rămâne la starea finală */
    opacity: 0; /* Începe invizibil */
}

@keyframes sparkle {
    0% { opacity: 0; transform: scale(0) translate(0, 0); }
    20% { opacity: 1; transform: scale(1) translate(0, 0); }
    100% { opacity: 0; transform: scale(0) translate(var(--spark-dx, 0), var(--spark-dy, 0)); } /* Deplasare random */
}


.intro-screen {
    text-align: center;
}

.intro-title {
    font-size: 2.2em; /* Ajustare pentru mobil */
    margin-bottom: 15px;
    text-shadow: 0 0 20px var(--color-success);
    animation: glow 2s ease-in-out infinite alternate;
}

@keyframes glow {
    from { text-shadow: 0 0 20px var(--color-success); }
    to { text-shadow: 0 0 30px var(--color-success), 0 0 40px var(--color-success); }
}

.intro-text {
    font-size: 1em; /* Ajustare pentru mobil */
    line-height: 1.5;
    margin-bottom: 20px;
    color: var(--color-text-light);
}

/* --- Media Queries Optimizate --- */

/* Pentru tablete (și mai mari) */
@media (min-width: 768px) {
    body {
        font-size: 18px;
    }

    .warning-banner {
        font-size: 1.2em;
        padding: 20px;
    }

    .control-panel {
        padding: 30px;
    }

    .timer {
        font-size: 2.5em;
    }

    .level-info {
        font-size: 1.2em;
    }

    .cables-container,
    .slots-container {
        gap: 15px;
        margin: 20px 0;
        grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    }

    .cable {
        max-width: 150px;
    }

    .slot {
        max-width: 160px;
    }

    .btn {
        padding: 15px 30px;
        font-size: 1.1em;
    }

    .message {
        font-size: 1.3em;
        padding: 15px;
    }

    .intro-title {
        font-size: 3em;
    }

    .intro-text {
        font-size: 1.2em;
    }
}

/* Pentru desktopuri (și mai mari) */
@media (min-width: 1025px) {
    body {
        font-size: 20px;
    }

    .warning-banner {
        font-size: 1.5em;
    }

    .timer {
        font-size: 3em;
    }

    .level-info {
        font-size: 1.4em;
    }
}
