/* -------------------------------------------------------------
   Shivtegs Snake - Theme & Styling
   Design System: Retro-Futuristic / Synthwave Neon Aesthetic
------------------------------------------------------------- */

:root {
    --bg-dark: #09070f;
    --bg-darker: #050409;
    --panel-bg: rgba(18, 14, 31, 0.7);
    --panel-border: rgba(0, 240, 255, 0.15);
    --panel-border-focus: rgba(0, 240, 255, 0.4);
    
    /* Neon Palettes */
    --neon-blue: #00f0ff;
    --neon-blue-glow: rgba(0, 240, 255, 0.35);
    --neon-pink: #ff007f;
    --neon-pink-glow: rgba(255, 0, 127, 0.35);
    --neon-green: #39ff14;
    --neon-green-glow: rgba(57, 255, 20, 0.35);
    --neon-purple: #9d4edd;
    --neon-purple-glow: rgba(157, 78, 221, 0.35);
    
    --text-primary: #ffffff;
    --text-muted: #8e8a9f;
    --danger: #ff3838;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    user-select: none;
    -webkit-user-drag: none;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-primary);
    font-family: 'Plus Jakarta Sans', sans-serif;
    min-height: 100vh;
    overflow-x: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Background Grid Lines */
.grid-background {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-size: 50px 50px;
    background-image: 
        linear-gradient(to right, rgba(255, 255, 255, 0.02) 1px, transparent 1px),
        linear-gradient(to bottom, rgba(255, 255, 255, 0.02) 1px, transparent 1px);
    z-index: -2;
    transform: perspective(500px) rotateX(25deg) translateY(-20%);
    transform-origin: top center;
    opacity: 0.8;
    animation: gridScroll 20s linear infinite;
}

@keyframes gridScroll {
    0% { background-position: 0 0; }
    100% { background-position: 0 1000px; }
}

/* Atmospheric Glow Background */
.glow-effect {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 800px;
    height: 800px;
    background: radial-gradient(circle, rgba(157, 78, 221, 0.12) 0%, rgba(9, 7, 15, 0) 70%);
    z-index: -1;
    pointer-events: none;
}

.app-container {
    width: 100%;
    max-width: 1100px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    height: 100vh;
    justify-content: space-between;
}

/* Header */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-icon {
    font-size: 24px;
    color: var(--neon-blue);
    text-shadow: 0 0 10px var(--neon-blue-glow);
    animation: pulse 2s infinite ease-in-out;
}

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

.logo h1 {
    font-family: 'Orbitron', sans-serif;
    font-weight: 900;
    font-size: 24px;
    letter-spacing: 2px;
}

.highlight {
    color: var(--neon-pink);
    text-shadow: 0 0 10px var(--neon-pink-glow);
}

.controls-top {
    display: flex;
    gap: 12px;
}

.icon-btn {
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    color: var(--text-primary);
    width: 44px;
    height: 44px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 18px;
    transition: all 0.3s cubic-bezier(0.165, 0.84, 0.44, 1);
}

.icon-btn:hover {
    border-color: var(--neon-blue);
    box-shadow: 0 0 12px var(--neon-blue-glow);
    transform: translateY(-2px);
}

/* Screens System */
.screen {
    display: none;
    flex-grow: 1;
    align-items: center;
    justify-content: center;
    padding: 20px 0;
}

.screen.active {
    display: flex;
    animation: fadeIn 0.4s ease-out;
}

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

/* Beautiful Cards */
.game-card {
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    border-radius: 20px;
    padding: 40px;
    width: 100%;
    max-width: 650px;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.4);
    position: relative;
}

.game-card h2 {
    font-family: 'Orbitron', sans-serif;
    font-size: 28px;
    margin-bottom: 8px;
    letter-spacing: 1px;
    text-align: center;
}

.subtitle {
    color: var(--text-muted);
    text-align: center;
    margin-bottom: 35px;
    font-size: 15px;
}

/* Buttons Styling */
.btn {
    width: 100%;
    padding: 16px 24px;
    margin-bottom: 16px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
    cursor: pointer;
    font-size: 16px;
    font-weight: 700;
    font-family: 'Plus Jakarta Sans', sans-serif;
    display: flex;
    align-items: center;
    gap: 18px;
    transition: all 0.3s cubic-bezier(0.165, 0.84, 0.44, 1);
    position: relative;
    overflow: hidden;
}

.btn-icon {
    font-size: 20px;
    width: 36px;
    height: 36px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
}

.btn-text {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    text-align: left;
}

.btn-text .desc {
    font-size: 12px;
    font-weight: 400;
    color: var(--text-muted);
    margin-top: 2px;
}

.btn-primary {
    background: linear-gradient(135deg, rgba(0, 240, 255, 0.1), rgba(0, 240, 255, 0.02));
    border-color: rgba(0, 240, 255, 0.3);
}

.btn-primary:hover {
    border-color: var(--neon-blue);
    box-shadow: 0 0 20px rgba(0, 240, 255, 0.25);
    background: linear-gradient(135deg, rgba(0, 240, 255, 0.2), rgba(0, 240, 255, 0.05));
    transform: translateY(-2px);
}

.btn-primary:hover .btn-icon {
    background: var(--neon-blue);
    color: var(--bg-dark);
    box-shadow: 0 0 10px var(--neon-blue);
}

.btn-secondary {
    background: linear-gradient(135deg, rgba(157, 78, 221, 0.15), rgba(157, 78, 221, 0.02));
    border-color: rgba(157, 78, 221, 0.3);
}

.btn-secondary:hover {
    border-color: var(--neon-purple);
    box-shadow: 0 0 20px rgba(157, 78, 221, 0.25);
    background: linear-gradient(135deg, rgba(157, 78, 221, 0.25), rgba(157, 78, 221, 0.05));
    transform: translateY(-2px);
}

.btn-secondary:hover .btn-icon {
    background: var(--neon-purple);
    color: var(--bg-dark);
    box-shadow: 0 0 10px var(--neon-purple);
}

.btn-accent {
    background: linear-gradient(135deg, rgba(255, 0, 127, 0.1), rgba(255, 0, 127, 0.02));
    border-color: rgba(255, 0, 127, 0.3);
}

.btn-accent:hover {
    border-color: var(--neon-pink);
    box-shadow: 0 0 20px rgba(255, 0, 127, 0.25);
    background: linear-gradient(135deg, rgba(255, 0, 127, 0.2), rgba(255, 0, 127, 0.05));
    transform: translateY(-2px);
}

.btn-accent:hover .btn-icon {
    background: var(--neon-pink);
    color: var(--bg-dark);
    box-shadow: 0 0 10px var(--neon-pink);
}

/* Back Button */
.back-btn {
    position: absolute;
    top: 25px;
    left: 25px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: color 0.2s;
}

.back-btn:hover {
    color: var(--text-primary);
}

/* Lobby Screen & Connection Layout */
.lobby-grid {
    display: flex;
    flex-direction: column;
    gap: 25px;
}

.lobby-option {
    padding: 20px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.lobby-option h3 {
    font-size: 18px;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.lobby-option p {
    color: var(--text-muted);
    font-size: 14px;
    margin-bottom: 20px;
}

.divider {
    text-align: center;
    position: relative;
}

.divider::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    width: 100%;
    height: 1px;
    background: rgba(255, 255, 255, 0.08);
    z-index: 1;
}

.divider span {
    background: #110d1e;
    padding: 0 15px;
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 700;
    position: relative;
    z-index: 2;
}

/* Share link and Inputs */
.link-share-box {
    margin-top: 15px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    animation: slideDown 0.3s ease-out;
}

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

.link-share-box .label {
    font-size: 12px;
    color: var(--text-muted);
}

.copy-input-group, .join-input-group {
    display: flex;
    gap: 10px;
}

.copy-input-group input, .join-input-group input {
    flex-grow: 1;
    background: var(--bg-darker);
    border: 1px solid var(--panel-border);
    border-radius: 8px;
    padding: 12px 16px;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 14px;
    outline: none;
    transition: all 0.3s;
}

.copy-input-group input:focus, .join-input-group input:focus {
    border-color: var(--neon-blue);
    box-shadow: 0 0 10px var(--neon-blue-glow);
}

.btn-copy {
    background: var(--neon-blue);
    color: var(--bg-dark);
    border: none;
    border-radius: 8px;
    width: 46px;
    cursor: pointer;
    font-size: 16px;
    transition: all 0.2s;
    display: flex;
    justify-content: center;
    align-items: center;
}

.btn-copy:hover {
    box-shadow: 0 0 12px var(--neon-blue);
    transform: scale(1.05);
}

.btn-copy.copied {
    background: var(--neon-green);
    box-shadow: 0 0 12px var(--neon-green);
}

.connection-status {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 12px;
    font-size: 13px;
    color: var(--text-muted);
}

.status-indicator {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--danger);
    display: inline-block;
}

.status-indicator.waiting {
    background: var(--neon-purple);
    box-shadow: 0 0 8px var(--neon-purple);
    animation: blink 1.5s infinite;
}

.status-indicator.connected {
    background: var(--neon-green);
    box-shadow: 0 0 8px var(--neon-green);
}

@keyframes blink {
    0%, 100% { opacity: 0.4; }
    50% { opacity: 1; }
}

.hidden {
    display: none !important;
}

/* Game Layout & Sidebar */
.game-layout {
    display: flex;
    gap: 25px;
    align-items: stretch;
    width: 100%;
}

.game-sidebar {
    width: 250px;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

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

.mode-panel {
    text-align: center;
    font-family: 'Orbitron', sans-serif;
    font-size: 14px;
    font-weight: 700;
    letter-spacing: 1px;
    color: var(--neon-blue);
    text-shadow: 0 0 6px var(--neon-blue-glow);
}

.score-panel {
    display: flex;
    flex-direction: column;
    gap: 12px;
    flex-grow: 1;
}

.score-card {
    padding: 15px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.02);
    border-left: 4px solid #fff;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.score-card.p1-color {
    border-left-color: var(--neon-blue);
}
.score-card.p1-color .indicator {
    background-color: var(--neon-blue);
    box-shadow: 0 0 8px var(--neon-blue);
}

.score-card.p2-color {
    border-left-color: var(--neon-pink);
}
.score-card.p2-color .indicator {
    background-color: var(--neon-pink);
    box-shadow: 0 0 8px var(--neon-pink);
}

.player-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 700;
}

.player-label .indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.score-value {
    font-family: 'Orbitron', sans-serif;
    font-size: 32px;
    font-weight: 900;
}

.controls-info h3 {
    font-family: 'Orbitron', sans-serif;
    font-size: 13px;
    margin-bottom: 10px;
    color: var(--text-muted);
}

.control-row {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    margin-bottom: 8px;
}

.key-p1, .key-p2 {
    background: var(--bg-darker);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: monospace;
    font-weight: bold;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.key-p1 { color: var(--neon-blue); }
.key-p2 { color: var(--neon-pink); }

.sidebar-actions {
    display: flex;
    gap: 10px;
}

.btn-small {
    flex-grow: 1;
    padding: 10px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: var(--panel-bg);
    color: var(--text-primary);
    font-size: 12px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.btn-small:hover {
    border-color: var(--neon-blue);
    background: rgba(0, 240, 255, 0.05);
}

.btn-danger:hover {
    border-color: var(--danger);
    background: rgba(255, 56, 56, 0.1);
    color: var(--danger);
}

/* Game Canvas Container */
.canvas-container {
    position: relative;
    background: var(--bg-darker);
    border: 2px solid var(--panel-border);
    border-radius: 16px;
    overflow: hidden;
    aspect-ratio: 1/1;
    flex-grow: 1;
    max-width: 600px;
    box-shadow: 0 0 30px rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
}

#gameCanvas {
    display: block;
    width: 100%;
    height: 100%;
}

/* Canvas overlay for gameover/pause */
.canvas-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(5, 4, 9, 0.85);
    backdrop-filter: blur(8px);
    z-index: 50;
    display: flex;
    justify-content: center;
    align-items: center;
    text-align: center;
    animation: fadeIn 0.3s;
}

#overlay-content {
    max-width: 80%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
}

#overlay-title {
    font-family: 'Orbitron', sans-serif;
    font-size: 36px;
    font-weight: 900;
    text-shadow: 0 0 15px var(--neon-pink-glow);
}

#overlay-subtitle {
    color: var(--text-muted);
    font-size: 15px;
    line-height: 1.5;
}

#overlay-content button {
    margin-top: 10px;
    max-width: 200px;
}

/* Help Modal Styling */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.8);
    backdrop-filter: blur(10px);
    justify-content: center;
    align-items: center;
}

.modal-content {
    background-color: #110d1e;
    border: 1px solid var(--neon-blue);
    box-shadow: 0 0 30px var(--neon-blue-glow);
    padding: 30px;
    border-radius: 16px;
    width: 90%;
    max-width: 550px;
    position: relative;
    animation: slideDown 0.3s ease-out;
}

.modal-content h2 {
    font-family: 'Orbitron', sans-serif;
    margin-bottom: 20px;
    color: var(--neon-blue);
}

.close-modal {
    color: var(--text-muted);
    position: absolute;
    right: 20px;
    top: 15px;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    transition: color 0.2s;
}

.close-modal:hover {
    color: var(--text-primary);
}

.help-grid {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.help-section h3 {
    font-size: 16px;
    margin-bottom: 8px;
    color: var(--neon-pink);
}

.help-section ul {
    list-style: none;
    font-size: 14px;
    color: var(--text-muted);
}

.help-section li {
    margin-bottom: 8px;
    line-height: 1.4;
    position: relative;
    padding-left: 15px;
}

.help-section li::before {
    content: '▪';
    color: var(--neon-blue);
    position: absolute;
    left: 0;
    font-size: 10px;
    top: 1px;
}

/* Mobile Controls */
.mobile-controls-container {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 100;
}

.mobile-dpad {
    display: grid;
    grid-template-rows: repeat(3, 60px);
    grid-template-columns: repeat(3, 60px);
    gap: 8px;
}

.dpad-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    color: var(--text-primary);
    font-size: 24px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: all 0.1s;
}

.dpad-btn:active {
    background: rgba(0, 240, 255, 0.2);
    border-color: var(--neon-blue);
    box-shadow: 0 0 10px var(--neon-blue-glow);
    transform: scale(0.95);
}

.dpad-btn.up { grid-row: 1; grid-column: 2; }
.dpad-btn.left { grid-row: 2; grid-column: 1; }
.dpad-btn.right { grid-row: 2; grid-column: 3; }
.dpad-btn.down { grid-row: 3; grid-column: 2; }
.dpad-center { grid-row: 2; grid-column: 2; background: transparent; pointer-events: none; }

/* Footer */
footer {
    text-align: center;
    padding-top: 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    color: var(--text-muted);
    font-size: 12px;
}

footer i {
    color: var(--neon-pink);
    animation: beat 1.5s infinite;
    display: inline-block;
}

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

/* Responsiveness adjustments */
@media (max-width: 900px) {
    .game-layout {
        flex-direction: column;
        align-items: center;
    }
    .game-sidebar {
        width: 100%;
        flex-direction: row;
        flex-wrap: wrap;
    }
    .score-panel {
        flex-direction: row;
        width: 100%;
    }
    .score-card {
        flex: 1;
    }
    .controls-info {
        display: none;
    }
    .sidebar-actions {
        width: 100%;
    }
    .app-container {
        height: auto;
        min-height: 100vh;
    }
}

@media (max-width: 600px) {
    .game-card {
        padding: 25px;
    }
    .game-card h2 {
        font-size: 22px;
    }
    .lobby-grid {
        gap: 15px;
    }
    .btn {
        padding: 12px 16px;
    }
}
