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

:root {
    --primary-color: #00d9ff;
    --secondary-color: #bd00ff;
    --accent-color: #ffd700;
    --success-color: #00ff88;
    --danger-color: #ff0055;
    --dark-bg: #0a0e27;
    --darker-bg: #050814;
    --card-bg: rgba(15, 23, 42, 0.8);
    --device-color: #ff0055;
    --beam-color: #00d9ff;
    --glow-color: rgba(0, 217, 255, 0.5);
}

@keyframes float {
    0%, 100% { transform: translateY(0px); }
    50% { transform: translateY(-20px); }
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

@keyframes glow {
    0%, 100% {
        box-shadow: 0 0 20px var(--glow-color),
                    0 0 40px var(--glow-color);
    }
    50% {
        box-shadow: 0 0 30px var(--glow-color),
                    0 0 60px var(--glow-color),
                    0 0 80px var(--glow-color);
    }
}

@keyframes scan-line {
    0% { transform: translateY(-100%); }
    100% { transform: translateY(100%); }
}

body {
    font-family: 'Segoe UI', 'Roboto', sans-serif;
    background: var(--darker-bg);
    background-image:
        radial-gradient(circle at 20% 50%, rgba(189, 0, 255, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 80% 80%, rgba(0, 217, 255, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 40% 20%, rgba(255, 215, 0, 0.05) 0%, transparent 40%);
    min-height: 100vh;
    padding: 20px;
    color: #fff;
    position: relative;
    overflow-x: hidden;
}

/* Animated background particles */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image:
        radial-gradient(2px 2px at 20% 30%, rgba(255, 255, 255, 0.3), transparent),
        radial-gradient(2px 2px at 60% 70%, rgba(0, 217, 255, 0.3), transparent),
        radial-gradient(1px 1px at 50% 50%, rgba(189, 0, 255, 0.3), transparent),
        radial-gradient(1px 1px at 80% 10%, rgba(255, 215, 0, 0.3), transparent);
    background-size: 200px 200px, 300px 300px, 250px 250px, 150px 150px;
    background-position: 0 0, 40px 60px, 130px 270px, 70px 100px;
    animation: float 20s ease-in-out infinite;
    pointer-events: none;
    z-index: 0;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    background: var(--card-bg);
    border-radius: 20px;
    backdrop-filter: blur(20px);
    border: 1px solid rgba(0, 217, 255, 0.2);
    box-shadow:
        0 0 60px rgba(0, 217, 255, 0.1),
        0 20px 60px rgba(0, 0, 0, 0.4);
    overflow: hidden;
    position: relative;
    z-index: 1;
}

/* Scan line effect */
.container::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 3px;
    background: linear-gradient(90deg,
        transparent,
        var(--beam-color),
        transparent);
    animation: scan-line 3s ease-in-out infinite;
    opacity: 0.3;
    pointer-events: none;
}

header {
    background: linear-gradient(135deg,
        rgba(0, 217, 255, 0.2) 0%,
        rgba(189, 0, 255, 0.2) 100%);
    padding: 40px 30px;
    text-align: center;
    border-bottom: 2px solid rgba(0, 217, 255, 0.3);
    position: relative;
    overflow: hidden;
}

header::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255,255,255,0.1) 0%, transparent 70%);
    animation: float 8s ease-in-out infinite;
}

header h1 {
    font-size: 2.8rem;
    margin-bottom: 10px;
    background: linear-gradient(135deg, var(--beam-color), var(--secondary-color), var(--accent-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-weight: 700;
    text-shadow: 0 0 30px rgba(0, 217, 255, 0.5);
    position: relative;
    z-index: 1;
}

.subtitle {
    opacity: 0.9;
    font-size: 1.1rem;
    color: var(--beam-color);
    position: relative;
    z-index: 1;
}

main {
    padding: 30px;
}

.controls {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.control-group {
    background: rgba(10, 14, 39, 0.6);
    padding: 20px;
    border-radius: 15px;
    border: 1px solid rgba(0, 217, 255, 0.2);
    backdrop-filter: blur(10px);
    transition: all 0.3s ease;
}

.control-group:hover {
    border-color: var(--beam-color);
    box-shadow: 0 0 20px rgba(0, 217, 255, 0.2);
    transform: translateY(-2px);
}

.control-group h3 {
    margin-bottom: 15px;
    color: var(--beam-color);
    font-size: 1.1rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.input-row, .button-row {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.9);
}

input[type="number"] {
    width: 70px;
    padding: 10px;
    background: rgba(0, 0, 0, 0.4);
    border: 2px solid rgba(0, 217, 255, 0.3);
    border-radius: 8px;
    color: var(--beam-color);
    font-size: 1rem;
    font-weight: 600;
    transition: all 0.3s ease;
}

input[type="number"]:focus {
    outline: none;
    border-color: var(--beam-color);
    box-shadow: 0 0 15px rgba(0, 217, 255, 0.3);
}

.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 1px;
    position: relative;
    overflow: hidden;
}

.btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.btn:hover::before {
    width: 300px;
    height: 300px;
}

.btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 5px 25px rgba(0, 217, 255, 0.4);
}

.btn:active {
    transform: translateY(-1px);
}

.btn-primary {
    background: linear-gradient(135deg, var(--beam-color), var(--secondary-color));
    color: white;
    box-shadow: 0 5px 15px rgba(0, 217, 255, 0.3);
}

.btn-success {
    background: linear-gradient(135deg, var(--success-color), var(--beam-color));
    color: var(--dark-bg);
    box-shadow: 0 5px 15px rgba(0, 255, 136, 0.3);
}

.btn-danger {
    background: linear-gradient(135deg, var(--danger-color), #ff3366);
    color: white;
    box-shadow: 0 5px 15px rgba(255, 0, 85, 0.3);
}

.btn-secondary {
    background: rgba(100, 100, 120, 0.4);
    color: white;
    border: 2px solid rgba(255, 255, 255, 0.3);
}

.btn-info {
    background: linear-gradient(135deg, var(--accent-color), #ffed4e);
    color: var(--dark-bg);
    box-shadow: 0 5px 15px rgba(255, 215, 0, 0.3);
}

.preset-select {
    width: 100%;
    padding: 12px;
    background: rgba(0, 0, 0, 0.4);
    border: 2px solid rgba(0, 217, 255, 0.3);
    border-radius: 10px;
    color: var(--beam-color);
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.preset-select:focus {
    outline: none;
    border-color: var(--beam-color);
    box-shadow: 0 0 15px rgba(0, 217, 255, 0.3);
}

.visualization {
    display: grid;
    grid-template-columns: 1fr 350px;
    gap: 30px;
    margin-bottom: 30px;
}

@media (max-width: 1024px) {
    .visualization {
        grid-template-columns: 1fr;
    }
}

.grid-container {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background: rgba(5, 8, 20, 0.8);
    border-radius: 15px;
    padding: 30px;
    border: 2px solid rgba(0, 217, 255, 0.3);
    position: relative;
    min-height: 500px;
}

.grid-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background:
        linear-gradient(90deg, rgba(0, 217, 255, 0.03) 1px, transparent 1px),
        linear-gradient(rgba(0, 217, 255, 0.03) 1px, transparent 1px);
    background-size: 20px 20px;
    border-radius: 15px;
    pointer-events: none;
}

#gridCanvas {
    border: 3px solid rgba(0, 217, 255, 0.4);
    border-radius: 10px;
    cursor: pointer;
    box-shadow:
        0 0 30px rgba(0, 217, 255, 0.2),
        inset 0 0 30px rgba(0, 217, 255, 0.1);
    position: relative;
    z-index: 1;
    transition: all 0.3s ease;
}

#gridCanvas:hover {
    border-color: var(--beam-color);
    box-shadow:
        0 0 40px rgba(0, 217, 255, 0.4),
        inset 0 0 40px rgba(0, 217, 255, 0.2);
}

.stats {
    background: linear-gradient(135deg,
        rgba(0, 217, 255, 0.15) 0%,
        rgba(189, 0, 255, 0.15) 100%);
    padding: 25px;
    border-radius: 15px;
    border: 2px solid rgba(0, 217, 255, 0.3);
    backdrop-filter: blur(10px);
}

.stats h3 {
    margin-bottom: 25px;
    font-size: 1.4rem;
    color: var(--beam-color);
    text-transform: uppercase;
    letter-spacing: 2px;
}

.stat-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 20px;
    border-bottom: 1px solid rgba(0, 217, 255, 0.2);
}

.stat-item:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

.stat-label {
    font-weight: 500;
    opacity: 0.9;
    color: rgba(255, 255, 255, 0.8);
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--beam-color);
    text-shadow: 0 0 20px rgba(0, 217, 255, 0.5);
    animation: pulse 2s ease-in-out infinite;
}

.stat-value.highlight {
    color: var(--accent-color);
    text-shadow: 0 0 20px rgba(255, 215, 0, 0.5);
}

.info-section {
    background: rgba(10, 14, 39, 0.6);
    padding: 30px;
    border-radius: 15px;
    border: 1px solid rgba(0, 217, 255, 0.2);
    backdrop-filter: blur(10px);
}

.info-section h3 {
    margin-bottom: 25px;
    color: var(--beam-color);
    font-size: 1.5rem;
    text-transform: uppercase;
    letter-spacing: 2px;
}

.info-content {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 30px;
}

@media (max-width: 768px) {
    .info-content {
        grid-template-columns: 1fr;
    }
}

.legend h4, .instructions h4 {
    margin-bottom: 15px;
    color: var(--success-color);
    font-size: 1.1rem;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 15px;
    color: rgba(255, 255, 255, 0.9);
}

.device-indicator, .beam-indicator, .empty-indicator {
    width: 35px;
    height: 35px;
    border-radius: 8px;
    border: 2px solid rgba(0, 217, 255, 0.3);
}

.device-indicator {
    background: var(--danger-color);
    box-shadow: 0 0 20px rgba(255, 0, 85, 0.5);
    animation: glow 2s ease-in-out infinite;
}

.beam-indicator {
    background: var(--beam-color);
    box-shadow: 0 0 20px rgba(0, 217, 255, 0.5);
}

.empty-indicator {
    background: rgba(100, 100, 120, 0.2);
    opacity: 0.5;
}

.instructions ul {
    list-style-position: inside;
    line-height: 2;
    color: rgba(255, 255, 255, 0.8);
}

.instructions li {
    margin-bottom: 10px;
    padding-left: 10px;
}

.instructions li::marker {
    color: var(--beam-color);
}

footer {
    background: var(--darker-bg);
    color: rgba(255, 255, 255, 0.7);
    text-align: center;
    padding: 25px;
    font-size: 0.9rem;
    border-top: 1px solid rgba(0, 217, 255, 0.2);
}

footer a {
    color: var(--beam-color);
    text-decoration: none;
    transition: all 0.3s ease;
}

footer a:hover {
    color: var(--accent-color);
    text-shadow: 0 0 10px rgba(255, 215, 0, 0.5);
}

/* Animation panel */
.animation-info {
    background: rgba(0, 0, 0, 0.8);
    border: 2px solid var(--beam-color);
    border-radius: 10px;
    padding: 20px;
    margin-top: 20px;
    backdrop-filter: blur(10px);
}

.animation-info h4 {
    color: var(--accent-color);
    margin-bottom: 10px;
    font-size: 1.2rem;
}

.animation-step {
    color: rgba(255, 255, 255, 0.9);
    font-size: 1rem;
    line-height: 1.6;
    margin-bottom: 10px;
}

.progress-bar {
    width: 100%;
    height: 6px;
    background: rgba(0, 217, 255, 0.2);
    border-radius: 3px;
    overflow: hidden;
    margin-top: 15px;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--beam-color), var(--accent-color));
    width: 0%;
    transition: width 0.3s ease;
    box-shadow: 0 0 10px var(--beam-color);
}
