/* 
 * Public Serpent v3 Canvas - Neon CRT Snake Game
 * CORNERSTONE Theme Integration
 */

/* Modal Overlay */
.serpent-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.92);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 999999;
    font-family: 'Source Code Pro', 'Courier New', monospace;
}

/* Container */
.serpent-container {
    width: 90%;
    max-width: 820px;
    max-height: 90vh;
    padding: 24px;
    border-radius: 12px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.02), rgba(255, 255, 255, 0.01));
    box-shadow:
        0 6px 30px rgba(0, 0, 0, 0.7),
        0 0 50px var(--crt-glow, #00ffd5) / 0.03;
    position: relative;
    overflow: auto;
}

/* CRT Scanlines Overlay */
.serpent-container::after {
    content: "";
    pointer-events: none;
    position: absolute;
    left: 0;
    right: 0;
    top: 0;
    bottom: 0;
    background: repeating-linear-gradient(transparent 0 1px,
            rgba(0, 0, 0, 0.06) 1px 2px);
    mix-blend-mode: overlay;
    opacity: 0.5;
    border-radius: 12px;
}

/* Header */
.serpent-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.serpent-title {
    font-size: 18px;
    margin: 0;
    letter-spacing: 0.6px;
    color: var(--crt-glow, #00ffd5);
    text-shadow: 0 0 10px var(--crt-glow, #00ffd5);
}

.serpent-mode-indicator {
    font-size: 13px;
    color: var(--secondary-color, #888888);
    background: rgba(136, 136, 136, 0.1);
    padding: 4px 12px;
    border-radius: 12px;
    border: 1px solid rgba(136, 136, 136, 0.3);
}

.serpent-close {
    background: none;
    border: none;
    color: var(--text-color, #fff);
    font-size: 32px;
    line-height: 1;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all 0.2s;
}

.serpent-close:hover {
    background: rgba(255, 61, 129, 0.2);
    color: var(--accent-color, #ff3d81);
}

/* Content */
.serpent-content {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* Score Display */
.serpent-info {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
}

.serpent-score {
    font-size: 16px;
    font-weight: 600;
    color: var(--crt-glow, #00ffd5);
    text-shadow: 0 0 10px var(--crt-glow, #00ffd5);
}

/* Canvas */
.serpent-canvas {
    display: block;
    width: 100% !important;
    height: auto !important;
    max-height: 70vh;
    /* Increased for mobile */
    border-radius: 8px;
    background: linear-gradient(180deg, rgba(0, 0, 0, 0.6), rgba(0, 0, 0, 0.35));
    box-shadow:
        0 0 24px var(--crt-glow, #00ffd5) / 0.09,
        inset 0 0 40px rgba(0, 0, 0, 0.6);
    image-rendering: pixelated;
    margin: 0 auto;
    cursor: crosshair;
}

/* Mobile Portrait Optimization */
@media (max-width: 768px) {
    .serpent-canvas {
        max-height: 75vh;
        /* Even more height on mobile */
        max-width: 100vw;
        /* Full width on mobile */
    }
}

/* Very small screens */
@media (max-width: 480px) {
    .serpent-canvas {
        max-height: 80vh;
        /* Maximum height on small phones */
    }
}

/* Controls Hint */
.serpent-hint {
    text-align: center;
    font-size: 13px;
    color: rgba(255, 255, 255, 0.5);
    margin: -8px 0 0 0;
}

/* Submit Form */
.serpent-submit-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 16px;
    background: rgba(0, 255, 213, 0.05);
    border-radius: 8px;
    border: 1px solid rgba(0, 255, 213, 0.2);
}

.serpent-input {
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(0, 255, 213, 0.3);
    color: var(--text-color, #fff);
    font-family: 'Source Code Pro', 'Courier New', monospace;
    font-size: 16px;
    padding: 8px 12px;
    border-radius: 4px;
    width: 80px;
    text-align: center;
    text-transform: uppercase;
}

.serpent-input:focus {
    outline: none;
    border-color: var(--crt-glow, #00ffd5);
    box-shadow: 0 0 10px var(--crt-glow, #00ffd5) / 0.3;
}

.serpent-btn {
    background: linear-gradient(180deg,
            var(--crt-glow, #00ffd5) / 0.2,
            var(--crt-glow, #00ffd5) / 0.1);
    border: 1px solid var(--crt-glow, #00ffd5) / 0.5;
    color: var(--crt-glow, #00ffd5);
    font-family: 'Source Code Pro', 'Courier New', monospace;
    font-size: 14px;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
    text-shadow: 0 0 5px var(--crt-glow, #00ffd5);
}

.serpent-btn:hover {
    background: var(--crt-glow, #00ffd5) / 0.3;
    box-shadow: 0 0 15px var(--crt-glow, #00ffd5) / 0.5;
}

.serpent-btn:active {
    transform: scale(0.98);
}

/* Success Message */
.serpent-success-msg {
    text-align: center;
    padding: 12px;
    background: rgba(0, 255, 100, 0.1);
    border-radius: 4px;
    color: #00ff64;
    font-size: 14px;
}

/* Leaderboard */
.serpent-leaderboard {
    margin-top: 8px;
}

.serpent-leaderboard h4 {
    margin: 0 0 12px 0;
    font-size: 16px;
    color: var(--secondary-color, #888888);
    text-align: center;
    letter-spacing: 1px;
}

.serpent-leaderboard-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 200px;
    overflow-y: auto;
    padding: 8px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 4px;
}

.serpent-leaderboard-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.02);
    border-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    font-size: 14px;
}

.serpent-rank {
    color: var(--secondary-color, #888888);
    font-weight: 600;
    min-width: 40px;
}

.serpent-initials {
    color: var(--crt-glow, #00ffd5);
    font-weight: 600;
    flex: 1;
    text-align: center;
}

.serpent-score {
    color: var(--text-color, #fff);
    font-weight: 600;
    min-width: 60px;
    text-align: right;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .serpent-container {
        width: 98%;
        /* Almost full width on mobile */
        padding: 12px;
        /* Less padding for more game space */
        max-height: 95vh;
        /* Use almost full screen height */
    }

    .serpent-title {
        font-size: 16px;
    }

    .serpent-mode-indicator {
        font-size: 11px;
        padding: 3px 8px;
    }

    .serpent-canvas {
        max-height: 75vh;
        /* More height for mobile */
        max-width: 100vw;
        /* Full width */
    }

    .serpent-header {
        flex-wrap: wrap;
        margin-bottom: 12px;
        /* Less space between header and game */
    }

    .serpent-submit-container {
        flex-direction: column;
    }

    .serpent-leaderboard {
        margin-top: 8px;
        /* Less space above leaderboard */
    }

    .serpent-leaderboard-list {
        max-height: 150px;
        /* Smaller leaderboard on mobile */
    }
}

/* Very small phones */
@media (max-width: 480px) {
    .serpent-container {
        width: 100%;
        padding: 8px;
        border-radius: 0;
        /* Full screen on very small phones */
    }

    .serpent-canvas {
        max-height: 80vh;
        /* Maximum height on small phones */
    }

    .serpent-leaderboard-list {
        max-height: 120px;
        /* Even smaller leaderboard */
    }
}

/* Screen Reader Only */
.serpent-live {
    position: absolute;
    left: -10000px;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

/* Accessibility - Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    * {
        animation: none !important;
        transition: none !important;
    }
}