/* ========================================
   QPong - Quantum Pong Game Styles
   Modern sci-fi theme with quantum effects
   ======================================== */

:root {
    /* Color Palette */
    --bg-primary: #0a0a1a;
    --bg-secondary: #12122a;
    --bg-tertiary: #1a1a3a;
    --accent-cyan: #00f0ff;
    --accent-magenta: #ff00ff;
    --accent-purple: #8b5cf6;
    --accent-green: #00ff88;
    --text-primary: #ffffff;
    --text-secondary: #a0a0c0;
    --glow-cyan: 0 0 20px rgba(0, 240, 255, 0.5);
    --glow-magenta: 0 0 20px rgba(255, 0, 255, 0.5);
    --glow-purple: 0 0 20px rgba(139, 92, 246, 0.5);

    /* Typography */
    --font-display: 'Orbitron', sans-serif;
    --font-body: 'Rajdhani', sans-serif;

    /* Sizing */
    --game-width: 900px;
    --game-height: 500px;
}

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

body {
    font-family: var(--font-body);
    background: var(--bg-primary);
    background-image:
        radial-gradient(ellipse at top, rgba(139, 92, 246, 0.15) 0%, transparent 50%),
        radial-gradient(ellipse at bottom, rgba(0, 240, 255, 0.1) 0%, transparent 50%);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    overflow-x: hidden;
    overflow-y: auto;
    padding: 10px;
}

/* ========================================
   Game Container
   ======================================== */

.game-container {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 10px;
    max-width: 1000px;
    width: 100%;
    min-width: 320px;
    transform-origin: top center;
}

/* ========================================
   Header & Score
   ======================================== */

.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px;
}

.title {
    font-family: var(--font-display);
    font-size: 2.5rem;
    font-weight: 900;
    letter-spacing: 4px;
    text-transform: uppercase;
    color: var(--text-primary);
    text-shadow: var(--glow-cyan);
}

.title .highlight {
    color: var(--accent-cyan);
}

.score-display {
    display: flex;
    align-items: center;
    gap: 20px;
    font-family: var(--font-display);
}

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

.score .label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: var(--text-secondary);
}

.score .value {
    font-size: 2.5rem;
    font-weight: 700;
}

.player-score .value {
    color: var(--accent-cyan);
    text-shadow: var(--glow-cyan);
}

.opponent-score .value {
    color: var(--accent-magenta);
    text-shadow: var(--glow-magenta);
}

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

/* ========================================
   Game Area
   ======================================== */

.game-area {
    display: flex;
    gap: 20px;
    justify-content: center;
}

#game-canvas {
    background: var(--bg-secondary);
    border: 2px solid var(--accent-purple);
    border-radius: 8px;
    box-shadow:
        var(--glow-purple),
        inset 0 0 50px rgba(139, 92, 246, 0.1);
}

/* ========================================
   Quantum State Display
   ======================================== */

.quantum-state-display {
    width: 180px;
    background: var(--bg-secondary);
    border: 1px solid var(--accent-purple);
    border-radius: 8px;
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.quantum-state-display h3 {
    font-family: var(--font-display);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--accent-purple);
    text-align: center;
}

.state-vector {
    font-family: 'Courier New', monospace;
    font-size: 0.7rem;
    color: var(--accent-cyan);
    background: var(--bg-primary);
    padding: 10px;
    border-radius: 4px;
    max-height: 120px;
    overflow-y: auto;
    line-height: 1.4;
}

.probability-bars {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex-grow: 1;
}

.prob-bar-container {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.7rem;
}

.prob-bar-label {
    width: 30px;
    font-family: 'Courier New', monospace;
    color: var(--text-secondary);
}

.prob-bar {
    flex-grow: 1;
    height: 14px;
    background: var(--bg-primary);
    border-radius: 3px;
    overflow: hidden;
    position: relative;
}

.prob-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-cyan), var(--accent-purple));
    border-radius: 3px;
    transition: width 0.3s ease;
    box-shadow: var(--glow-cyan);
}

.prob-bar-value {
    width: 35px;
    text-align: right;
    font-family: 'Courier New', monospace;
    color: var(--text-secondary);
}

/* ========================================
   Gate Panel
   ======================================== */

.gate-panel {
    background: var(--bg-secondary);
    border: 1px solid var(--accent-purple);
    border-radius: 8px;
    padding: 15px 20px;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.panel-header h2 {
    font-family: var(--font-display);
    font-size: 1rem;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: var(--accent-purple);
}

.qubit-selector {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.qubit-btn {
    background: var(--bg-tertiary);
    border: 1px solid var(--accent-purple);
    color: var(--text-secondary);
    font-family: var(--font-display);
    font-size: 0.8rem;
    padding: 5px 12px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.qubit-btn:hover {
    background: rgba(139, 92, 246, 0.2);
    color: var(--text-primary);
}

.qubit-btn.active {
    background: var(--accent-purple);
    color: var(--bg-primary);
    box-shadow: var(--glow-purple);
}

/* ========================================
   Gate Buttons
   ======================================== */

.gates-container {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
}

.gate-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 80px;
    height: 70px;
    background: linear-gradient(145deg, var(--bg-tertiary), var(--bg-primary));
    border: 2px solid var(--accent-cyan);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    overflow: hidden;
}

.gate-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(0, 240, 255, 0.2), transparent);
    transition: left 0.5s ease;
}

.gate-btn:hover::before {
    left: 100%;
}

.gate-btn:hover {
    transform: translateY(-3px);
    box-shadow: var(--glow-cyan);
    border-color: var(--accent-cyan);
}

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

.gate-symbol {
    font-family: var(--font-display);
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--accent-cyan);
}

.gate-name {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* Special gate colors */
#gate-h {
    border-color: var(--accent-green);
}

#gate-h .gate-symbol {
    color: var(--accent-green);
}

#gate-h:hover {
    box-shadow: 0 0 20px rgba(0, 255, 136, 0.5);
}

#gate-cnot {
    border-color: var(--accent-magenta);
}

#gate-cnot .gate-symbol {
    color: var(--accent-magenta);
}

#gate-cnot:hover {
    box-shadow: var(--glow-magenta);
}

#gate-measure {
    border-color: var(--accent-purple);
}

#gate-measure .gate-symbol {
    color: var(--accent-purple);
}

#gate-measure:hover {
    box-shadow: var(--glow-purple);
}

/* ========================================
   Circuit Display
   ======================================== */

.circuit-display {
    display: flex;
    align-items: center;
    gap: 15px;
    padding-top: 10px;
    border-top: 1px solid rgba(139, 92, 246, 0.3);
}

.circuit-display h3 {
    font-family: var(--font-display);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-secondary);
    white-space: nowrap;
}

.circuit-lines {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex-grow: 1;
    background: var(--bg-primary);
    padding: 10px 15px;
    border-radius: 4px;
    overflow-x: auto;
}

.circuit-line {
    display: flex;
    align-items: center;
    gap: 10px;
    height: 24px;
}

.qubit-label {
    font-family: 'Courier New', monospace;
    font-size: 0.75rem;
    color: var(--accent-cyan);
    width: 20px;
}

.wire {
    flex-grow: 1;
    height: 2px;
    background: var(--text-secondary);
    position: relative;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 5px;
}

.circuit-gate {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    background: var(--bg-tertiary);
    border: 1px solid var(--accent-cyan);
    border-radius: 4px;
    font-family: var(--font-display);
    font-size: 0.7rem;
    color: var(--accent-cyan);
    flex-shrink: 0;
}

.circuit-gate.hadamard {
    border-color: var(--accent-green);
    color: var(--accent-green);
}

.circuit-gate.cnot {
    border-color: var(--accent-magenta);
    color: var(--accent-magenta);
}

.circuit-gate.measure {
    border-color: var(--accent-purple);
    color: var(--accent-purple);
    border-radius: 50%;
}

.circuit-gate.pauli-y {
    border-color: #ff8800;
    color: #ff8800;
}

.circuit-gate.rotation {
    border-color: #ffcc00;
    color: #ffcc00;
    font-size: 0.6rem;
}

/* Circuit cells for keyboard navigation */
.circuit-cell {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border: 1px dashed transparent;
    border-radius: 4px;
    transition: all 0.15s ease;
    flex-shrink: 0;
}

.circuit-cell.cursor {
    border-color: var(--accent-cyan);
    background: rgba(0, 240, 255, 0.15);
    box-shadow: 0 0 10px rgba(0, 240, 255, 0.3);
    animation: cursorPulse 1s infinite;
}

@keyframes cursorPulse {

    0%,
    100% {
        box-shadow: 0 0 10px rgba(0, 240, 255, 0.3);
    }

    50% {
        box-shadow: 0 0 20px rgba(0, 240, 255, 0.6);
    }
}

.wire {
    flex-grow: 1;
    height: 28px;
    background: transparent;
    position: relative;
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 0;
}

.wire::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--text-secondary);
    z-index: 0;
}

.reset-btn {
    background: transparent;
    border: 1px solid var(--text-secondary);
    color: var(--text-secondary);
    font-family: var(--font-body);
    font-size: 0.8rem;
    padding: 8px 15px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.reset-btn:hover {
    border-color: var(--accent-magenta);
    color: var(--accent-magenta);
}

/* ========================================
   Instructions Overlay
   ======================================== */

.instructions-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(10, 10, 26, 0.95);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    backdrop-filter: blur(10px);
}

.instructions-overlay.hidden {
    display: none;
}

.instructions-content {
    background: var(--bg-secondary);
    border: 2px solid var(--accent-purple);
    border-radius: 16px;
    padding: 40px 50px;
    max-width: 500px;
    text-align: center;
    box-shadow: var(--glow-purple);
    animation: fadeIn 0.5s ease;
}

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

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.instructions-content h2 {
    font-family: var(--font-display);
    font-size: 1.8rem;
    color: var(--accent-cyan);
    margin-bottom: 20px;
    text-shadow: var(--glow-cyan);
}

.instructions-content p {
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: 15px;
}

.instructions-content ul {
    text-align: left;
    list-style: none;
    margin: 20px 0;
}

.instructions-content li {
    padding: 8px 0;
    color: var(--text-secondary);
    border-bottom: 1px solid rgba(139, 92, 246, 0.2);
}

.instructions-content li strong {
    color: var(--accent-cyan);
}

.instructions-content em {
    color: var(--accent-magenta);
    font-style: normal;
}

.start-btn {
    background: linear-gradient(135deg, var(--accent-cyan), var(--accent-purple));
    border: none;
    color: var(--bg-primary);
    font-family: var(--font-display);
    font-size: 1.1rem;
    font-weight: 700;
    padding: 15px 40px;
    border-radius: 8px;
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 2px;
    margin-top: 20px;
    transition: all 0.3s ease;
    box-shadow: var(--glow-cyan);
}

.start-btn:hover {
    transform: scale(1.05);
    box-shadow:
        var(--glow-cyan),
        var(--glow-purple);
}

/* ========================================
   Animations
   ======================================== */

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

@keyframes quantumFlicker {

    0%,
    100% {
        opacity: 1;
    }

    25% {
        opacity: 0.8;
    }

    50% {
        opacity: 0.6;
    }

    75% {
        opacity: 0.9;
    }
}

.superposition {
    animation: quantumFlicker 0.5s infinite;
}

/* ========================================
   Responsive
   ======================================== */

@media (max-width: 1100px) {
    .game-area {
        flex-direction: column;
        align-items: center;
    }

    .quantum-state-display {
        width: 100%;
        max-width: 500px;
        flex-direction: row;
        flex-wrap: wrap;
    }

    .quantum-state-display h3 {
        width: 100%;
    }

    .state-vector {
        flex: 1;
        max-height: 80px;
    }

    .probability-bars {
        flex: 1;
    }
}

@media (max-width: 700px) {
    .game-header {
        flex-direction: column;
        gap: 10px;
    }

    .title {
        font-size: 1.8rem;
    }

    .score .value {
        font-size: 1.8rem;
    }

    #game-canvas {
        max-width: 100%;
        height: auto;
    }

    .quantum-state-display {
        width: 100%;
        padding: 10px;
    }

    .gates-container {
        gap: 6px;
    }

    .gate-btn {
        width: 50px;
        height: 45px;
    }

    .gate-symbol {
        font-size: 1rem;
    }

    .gate-name {
        font-size: 0.5rem;
    }

    .gate-panel {
        padding: 10px;
    }

    .circuit-display {
        flex-wrap: wrap;
        gap: 8px;
    }

    .circuit-lines {
        padding: 8px;
    }

    .circuit-cell {
        width: 22px;
        height: 22px;
    }

    .circuit-gate {
        width: 20px;
        height: 20px;
        font-size: 0.6rem;
    }

    .prob-bar-container {
        font-size: 0.6rem;
    }

    .panel-header {
        flex-direction: column;
        gap: 8px;
        align-items: flex-start;
    }

    .qubit-selector {
        font-size: 0.75rem;
    }

    .qubit-btn {
        padding: 4px 8px;
        font-size: 0.7rem;
    }
}

@media (max-width: 500px) {
    .game-container {
        gap: 8px;
        padding: 5px;
    }

    .gate-btn {
        width: 42px;
        height: 38px;
    }

    .gate-symbol {
        font-size: 0.9rem;
    }

    .gate-name {
        display: none;
    }

    .circuit-display h3 {
        display: none;
    }

    .state-vector {
        font-size: 0.6rem;
    }
}