/* ==================== CSS Custom Properties ==================== */
:root {
    --neon-cyan: #00ffff;
    --neon-magenta: #ff00ff;
    --neon-yellow: #ffff00;
    --neon-green: #00ff00;
    --dark-bg: #0a0a0a;
    --grid-bg: #1a1a1a;
    --panel-bg: rgba(20, 20, 30, 0.8);
    --border-color: rgba(0, 255, 255, 0.3);
    --text-primary: #00ffff;
    --text-secondary: #ff00ff;
    --shadow-glow: 0 0 10px currentColor, 0 0 20px currentColor, 0 0 30px currentColor;
}

/* ==================== Base Styles ==================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Courier New', monospace;
    background: var(--dark-bg);
    color: var(--text-primary);
    overflow: hidden;
    position: relative;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* ==================== Visual Effects ==================== */
.scanlines {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: repeating-linear-gradient(
        0deg,
        rgba(0, 255, 255, 0.03),
        rgba(0, 255, 255, 0.03) 1px,
        transparent 1px,
        transparent 2px
    );
    pointer-events: none;
    z-index: 999;
}

.glitch-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: transparent;
    pointer-events: none;
    z-index: 998;
    animation: glitchOverlay 8s infinite;
}

@keyframes glitchOverlay {
    0%, 90%, 100% { opacity: 0; }
    91%, 93% {
        opacity: 0.1;
        background: linear-gradient(90deg, #ff00ff 0%, transparent 50%, #00ffff 100%);
    }
}

/* ==================== Glitch Text Effect ==================== */
.glitch {
    position: relative;
    text-shadow: var(--shadow-glow);
    animation: glitch 1s infinite;
}

.glitch::before,
.glitch::after {
    content: attr(data-text);
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.glitch::before {
    left: 2px;
    text-shadow: -2px 0 var(--neon-magenta);
    clip: rect(24px, 550px, 90px, 0);
    animation: glitch-anim 3s infinite linear alternate-reverse;
}

.glitch::after {
    left: -2px;
    text-shadow: 2px 0 var(--neon-cyan);
    clip: rect(85px, 550px, 140px, 0);
    animation: glitch-anim 2s infinite linear alternate-reverse;
}

@keyframes glitch {
    0%, 90%, 100% { transform: translate(0); }
    91% { transform: translate(-2px, 2px); }
    93% { transform: translate(2px, -2px); }
}

@keyframes glitch-anim {
    0% { clip: rect(10px, 9999px, 30px, 0); }
    20% { clip: rect(60px, 9999px, 80px, 0); }
    40% { clip: rect(120px, 9999px, 140px, 0); }
    60% { clip: rect(30px, 9999px, 90px, 0); }
    80% { clip: rect(90px, 9999px, 110px, 0); }
    100% { clip: rect(50px, 9999px, 70px, 0); }
}

/* ==================== Layout ==================== */
.game-container {
    width: 100%;
    max-width: 1200px;
    padding: 20px;
    position: relative;
    z-index: 1;
}

.game-header {
    text-align: center;
    margin-bottom: 30px;
}

.game-title {
    font-size: clamp(2rem, 5vw, 4rem);
    letter-spacing: 0.5rem;
    color: var(--neon-cyan);
}

.game-main {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 20px;
    align-items: start;
}

/* ==================== Game Board ==================== */
.game-board {
    position: relative;
    background: var(--grid-bg);
    border: 2px solid var(--neon-cyan);
    box-shadow:
        0 0 20px rgba(0, 255, 255, 0.5),
        inset 0 0 20px rgba(0, 255, 255, 0.1);
    padding: 10px;
    border-radius: 4px;
}

#gameCanvas {
    display: block;
    background: #000;
    border: 1px solid var(--border-color);
}

/* ==================== Panels ==================== */
.game-sidebar {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.panel {
    background: var(--panel-bg);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 15px;
    backdrop-filter: blur(10px);
}

.panel-title {
    font-size: 1.2rem;
    color: var(--neon-magenta);
    text-shadow: var(--shadow-glow);
    margin-bottom: 15px;
    letter-spacing: 0.2rem;
}

/* ==================== Hold & Next ==================== */
.hold-container,
.next-container {
    display: flex;
    justify-content: center;
    align-items: center;
    background: #000;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 10px;
}

canvas {
    image-rendering: crisp-edges;
    image-rendering: pixelated;
}

/* ==================== Score Display ==================== */
.score-display {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.score-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 4px;
    border: 1px solid rgba(0, 255, 255, 0.2);
}

.score-label {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.score-value {
    font-size: 1.3rem;
    color: var(--neon-yellow);
    text-shadow: 0 0 10px var(--neon-yellow);
    font-weight: bold;
}

/* ==================== Controls Info ==================== */
.controls-info {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.control-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 4px;
}

.key {
    background: linear-gradient(145deg, #1a1a1a, #2a2a2a);
    color: var(--neon-cyan);
    padding: 4px 8px;
    border-radius: 3px;
    border: 1px solid var(--border-color);
    font-size: 0.85rem;
    font-weight: bold;
    min-width: 60px;
    text-align: center;
}

.action {
    font-size: 0.85rem;
    color: var(--text-primary);
}

/* ==================== Buttons ==================== */
.btn {
    width: 100%;
    padding: 12px 20px;
    font-family: 'Courier New', monospace;
    font-size: 1rem;
    font-weight: bold;
    letter-spacing: 0.1rem;
    border: 2px solid;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    background: transparent;
}

.btn--primary {
    color: var(--neon-cyan);
    border-color: var(--neon-cyan);
}

.btn--primary:hover {
    background: var(--neon-cyan);
    color: #000;
    box-shadow: 0 0 20px var(--neon-cyan);
    transform: translateY(-2px);
}

.btn--secondary {
    color: var(--neon-magenta);
    border-color: var(--neon-magenta);
    margin-bottom: 10px;
}

.btn--secondary:hover {
    background: var(--neon-magenta);
    color: #000;
    box-shadow: 0 0 20px var(--neon-magenta);
    transform: translateY(-2px);
}

.btn--secondary:last-child {
    margin-bottom: 0;
}

/* ==================== Game Over Screen ==================== */
.game-over {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.95);
    border: 2px solid var(--neon-magenta);
    border-radius: 8px;
    padding: 40px;
    text-align: center;
    box-shadow: 0 0 40px rgba(255, 0, 255, 0.6);
    z-index: 10;
}

.game-over.hidden {
    display: none;
}

.game-over-title {
    font-size: 3rem;
    color: var(--neon-magenta);
    margin-bottom: 20px;
}

.game-over-score {
    font-size: 1.5rem;
    color: var(--neon-yellow);
    margin-bottom: 30px;
}

/* ==================== Responsive Design ==================== */
@media (max-width: 1024px) {
    .game-main {
        grid-template-columns: 1fr;
        gap: 20px;
    }

    .game-sidebar--left,
    .game-sidebar--right {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
        gap: 15px;
    }

    .game-board {
        order: -1;
        margin: 0 auto;
    }
}

@media (max-width: 768px) {
    .game-title {
        font-size: 2rem;
        letter-spacing: 0.3rem;
    }

    .game-container {
        padding: 10px;
    }

    #gameCanvas {
        width: 100%;
        height: auto;
    }

    .panel {
        padding: 10px;
    }

    .panel-title {
        font-size: 1rem;
    }
}

@media (max-width: 480px) {
    .game-sidebar--left,
    .game-sidebar--right {
        grid-template-columns: 1fr;
    }

    .controls-info {
        font-size: 0.8rem;
    }

    .key {
        min-width: 50px;
        font-size: 0.75rem;
    }
}

/* ==================== Accessibility ==================== */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    :root {
        --neon-cyan: #00ffff;
        --neon-magenta: #ff00ff;
        --border-color: rgba(0, 255, 255, 0.6);
    }

    .panel {
        border-width: 2px;
    }
}

/* ==================== Utility Classes ==================== */
.hidden {
    display: none !important;
}
