:root {
    --primary-color: #00ff41;
    --secondary-color: #ff006e;
    --background-color: #0a0a0a;
    --card-bg-color: #1a1a1a;
    --text-color: #00ff41;
    --text-light-color: #ffffff;
    --eliminated-color: #4a4a4a;
    --danger-color: #ff006e;
    --font-family: 'Rajdhani', sans-serif;
    --font-heading: 'Orbitron', sans-serif;
}

body {
    font-family: var(--font-family);
    background-color: var(--background-color);
    color: var(--text-color);
    margin: 0;
    padding: 20px;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    min-height: 100vh;
    letter-spacing: 0.5px;
    position: relative;
}

body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: 
        repeating-linear-gradient(0deg, transparent, transparent 2px, rgba(0, 255, 65, 0.03) 2px, rgba(0, 255, 65, 0.03) 4px);
    pointer-events: none;
    z-index: 1;
}

body > * {
    position: relative;
    z-index: 2;
}

h1 {
    font-family: var(--font-heading);
    color: var(--primary-color);
    text-align: center;
    font-size: 2.5rem;
    font-weight: 900;
    margin-bottom: 20px;
    text-transform: uppercase;
    letter-spacing: 3px;
    text-shadow: 0 0 20px var(--primary-color);
}

h2 {
    font-family: var(--font-heading);
    color: var(--primary-color);
    text-transform: uppercase;
    letter-spacing: 2px;
    font-weight: 700;
    position: relative;
    padding: 15px 0;
}

h2::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, 
        var(--primary-color) 0%, 
        var(--primary-color) 10px, 
        transparent 10px, 
        transparent 15px, 
        var(--primary-color) 15px, 
        var(--primary-color) calc(100% - 15px), 
        transparent calc(100% - 15px), 
        transparent calc(100% - 10px), 
        var(--primary-color) calc(100% - 10px));
    opacity: 0.6;
}

h2::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, 
        var(--primary-color) 0%, 
        var(--primary-color) 10px, 
        transparent 10px, 
        transparent 15px, 
        var(--primary-color) 15px, 
        var(--primary-color) calc(100% - 15px), 
        transparent calc(100% - 15px), 
        transparent calc(100% - 10px), 
        var(--primary-color) calc(100% - 10px));
    opacity: 0.6;
}

h3 {
    font-family: var(--font-heading);
    text-transform: uppercase;
    letter-spacing: 2px;
    font-weight: 700;
}

.ascii-art {
    color: var(--primary-color);
    text-align: center;
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.9rem;
    font-weight: 700;
    margin: 20px auto;
    line-height: 1.2;
    white-space: pre;
    overflow-x: auto;
    text-shadow: 0 0 10px var(--primary-color), 0 0 20px var(--primary-color), 0 0 30px var(--primary-color), 0 0 40px var(--primary-color);
    animation: glitch 3s infinite;
    max-width: 100%;
}

/* Responsive ASCII art for mobile devices */
@media (max-width: 768px) {
    .ascii-art {
        font-size: 0.7rem;
        margin: 15px auto;
    }
}

@media (max-width: 480px) {
    .ascii-art {
        font-size: 0.55rem;
        margin: 10px auto;
    }
}

@media (max-width: 360px) {
    .ascii-art {
        font-size: 0.45rem;
        margin: 5px auto;
    }
}

@keyframes glitch {
    0%, 80%, 100% {
        text-shadow: 0 0 10px var(--primary-color), 0 0 20px var(--primary-color), 0 0 30px var(--primary-color);
        transform: translate(0, 0);
    }
    82% {
        text-shadow: 0 0 15px var(--secondary-color), 0 0 25px var(--secondary-color), 3px 3px var(--primary-color);
        transform: translate(-3px, 1px) skew(-2deg);
    }
    84% {
        text-shadow: 0 0 15px var(--primary-color), 0 0 25px var(--primary-color), -3px -3px var(--secondary-color);
        transform: translate(3px, -1px) skew(2deg);
    }
    86% {
        text-shadow: 0 0 20px var(--secondary-color), 0 0 30px var(--secondary-color), 2px -2px var(--primary-color);
        transform: translate(-2px, -1px) skew(1deg);
    }
    88% {
        text-shadow: 0 0 10px var(--primary-color), 0 0 20px var(--primary-color), -2px 2px var(--secondary-color);
        transform: translate(2px, 1px) skew(-1deg);
    }
}

#game-container {
    width: 100%;
    max-width: 900px;
    text-align: center;
}

.card {
    background: var(--card-bg-color);
    border-radius: 0;
    box-shadow: 0 0 20px rgba(0, 255, 65, 0.3), 0 4px 12px rgba(0,0,0,0.5);
    padding: 30px;
    margin-bottom: 20px;
    text-align: center;
    border: 2px solid var(--primary-color);
    position: relative;
}

.card::before,
.card::after {
    content: '';
    position: absolute;
    width: 10px;
    height: 10px;
    border: 2px solid var(--primary-color);
}

.card::before {
    top: -2px;
    left: -2px;
    border-right: none;
    border-bottom: none;
}

.card::after {
    bottom: -2px;
    right: -2px;
    border-left: none;
    border-top: none;
}

.hidden {
    display: none !important;
}

/* Setup & Name Entry Screens */
#setup-screen div, #name-entry-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
}

.game-description {
    font-family: var(--font-family);
    color: var(--text-color);
    background-color: rgba(0, 255, 65, 0.05);
    border: 2px solid var(--primary-color);
    padding: 20px;
    margin-bottom: 25px;
    text-align: left;
    font-size: 0.95rem;
    line-height: 1.6;
    box-shadow: 0 0 10px rgba(0, 255, 65, 0.2);
}

.game-description p {
    margin: 10px 0;
}

.game-description ul {
    list-style: none;
    padding-left: 0;
    margin: 15px 0;
}

.game-description li {
    padding: 8px 0;
    padding-left: 20px;
    position: relative;
}

.game-description li::before {
    content: '▸';
    position: absolute;
    left: 0;
    color: var(--secondary-color);
    font-weight: bold;
}

.game-description strong {
    color: var(--primary-color);
    text-shadow: 0 0 5px rgba(0, 255, 65, 0.5);
}

.single-device-note {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid rgba(0, 255, 65, 0.3);
    font-size: 0.9rem;
    color: var(--text-color);
    opacity: 0.9;
}

.single-device-note em {
    font-style: italic;
    color: var(--primary-color);
}

.game-instruction {
    font-family: 'Courier New', monospace;
    color: var(--secondary-color);
    background-color: rgba(255, 0, 110, 0.1);
    border: 2px solid var(--secondary-color);
    padding: 15px;
    margin: 15px 0;
    text-align: center;
    font-weight: 700;
    font-size: 1rem;
    letter-spacing: 0.5px;
    box-shadow: 0 0 15px rgba(255, 0, 110, 0.3);
}

input[type="number"], input[type="text"], button {
    font-family: var(--font-family);
    font-size: 1.1rem;
    font-weight: 600;
    padding: 12px 20px;
    border-radius: 0;
    border: 2px solid var(--primary-color);
    width: 80%;
    max-width: 300px;
    box-sizing: border-box;
    letter-spacing: 1px;
}

input[type="number"], input[type="text"] {
    background-color: #0f0f0f;
    color: var(--primary-color);
    box-shadow: inset 0 0 10px rgba(0, 255, 65, 0.1);
    position: relative;
}

label {
    font-family: 'Courier New', monospace;
    color: var(--primary-color);
    font-weight: 700;
}

label::before {
    content: '▸ ';
    color: var(--secondary-color);
}

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

/* Custom number input spinner styling */
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

input[type="number"] {
    -moz-appearance: textfield;
    appearance: textfield;
}

/* Custom checkbox styling */
input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    width: 20px;
    height: 20px;
    border: 2px solid var(--primary-color);
    background-color: #0f0f0f;
    cursor: pointer;
    position: relative;
    margin-right: 8px;
    vertical-align: middle;
    transition: all 0.3s;
}

input[type="checkbox"]:hover {
    border-color: var(--secondary-color);
    box-shadow: 0 0 10px rgba(255, 0, 110, 0.5);
}

input[type="checkbox"]:checked {
    background-color: var(--primary-color);
    box-shadow: 0 0 15px rgba(0, 255, 65, 0.6);
}

input[type="checkbox"]:checked::before {
    content: 'X';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #0a0a0a;
    font-family: 'Courier New', monospace;
    font-size: 16px;
    font-weight: 900;
    line-height: 1;
}

button {
    background-color: var(--primary-color);
    color: #0a0a0a;
    border: 2px solid var(--primary-color);
    cursor: pointer;
    font-weight: 700;
    transition: all 0.3s;
    width: auto;
    box-shadow: 0 0 15px rgba(0, 255, 65, 0.5);
    text-transform: uppercase;
    letter-spacing: 2px;
    position: relative;
    font-family: 'Courier New', monospace;
    padding: 12px 35px;
}

button::before {
    content: '[ ';
    position: absolute;
    left: 10px;
    color: #0a0a0a;
}

button::after {
    content: ' ]';
    position: absolute;
    right: 10px;
    color: #0a0a0a;
}

button:hover {
    background-color: var(--secondary-color);
    color: #ffffff;
    border-color: var(--secondary-color);
    transform: translateY(-2px);
    box-shadow: 0 0 25px rgba(255, 0, 110, 0.8);
}

button:hover::before,
button:hover::after {
    color: #ffffff;
}

#new-game-btn {
    background-color: var(--secondary-color);
    color: #ffffff;
    box-shadow: 0 0 15px rgba(255, 0, 110, 0.5);
}

#new-game-btn:hover {
    background-color: var(--primary-color);
    color: #0a0a0a;
    box-shadow: 0 0 25px rgba(0, 255, 65, 0.8);
}

/* Main Game Screen */
#game-info h2 {
    margin-top: 0;
}

#players-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 15px;
    margin-top: 20px;
}

.player-card {
    background: var(--card-bg-color);
    padding: 20px 15px;
    border-radius: 0;
    text-align: center;
    border: 2px dashed var(--primary-color);
    transition: all 0.3s;
    box-shadow: 0 0 10px rgba(0, 255, 65, 0.2);
    cursor: pointer;
    min-height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    position: relative;
    pointer-events: auto; /* ensure card receives clicks across browsers */
}

.player-card::before {
    content: '┌─────────────┐';
    position: absolute;
    top: 2px;
    left: 50%;
    transform: translateX(-50%);
    font-family: 'Courier New', monospace;
    font-size: 0.5rem;
    color: var(--primary-color);
    opacity: 0.4;
    white-space: nowrap;
}

.player-card::after {
    content: '└─────────────┘';
    position: absolute;
    bottom: 2px;
    left: 50%;
    transform: translateX(-50%);
    font-family: 'Courier New', monospace;
    font-size: 0.5rem;
    color: var(--primary-color);
    opacity: 0.4;
    white-space: nowrap;
}

/* Ensure children don't steal the click target in Firefox */
.player-card * {
    pointer-events: none;
}

.player-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 0 20px rgba(255, 0, 110, 0.6);
    border-color: var(--secondary-color);
}

.player-card strong {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 1.1rem;
    letter-spacing: 1px;
    text-transform: uppercase;
}

.player-card small {
    font-size: 0.9rem;
    color: #888;
    letter-spacing: 0.5px;
}

.player-card.eliminated {
    background-color: #0f0f0f;
    color: var(--eliminated-color);
    text-decoration: line-through;
    opacity: 0.5;
    cursor: not-allowed;
    border-color: var(--eliminated-color);
}

.player-card.eliminated:hover {
    transform: none;
    box-shadow: 0 0 10px rgba(0, 255, 65, 0.2);
}

.player-card.active {
    border-color: var(--secondary-color);
    transform: scale(1.05);
    box-shadow: 0 0 30px rgba(255, 0, 110, 0.8);
}

.play-order {
    position: absolute;
    top: 8px;
    right: 8px;
    font-size: 0.8rem;
    font-weight: 700;
    color: #0a0a0a;
    background-color: var(--primary-color);
    border-radius: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    pointer-events: none; /* don't block clicks on the card (Firefox fix) */
    box-shadow: 0 0 10px rgba(0, 255, 65, 0.8);
    border: 2px solid #0a0a0a;
    font-family: 'Courier New', monospace;
}

/* Role Reveal Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    backdrop-filter: blur(5px);
}

.modal-content {
    width: 90%;
    max-width: 400px;
    text-align: center;
}

.modal-content h3 {
    margin-top: 0;
    color: var(--primary-color);
    text-shadow: 0 0 10px var(--primary-color);
}

.modal-content p {
    font-size: 1.2rem;
    margin: 15px 0;
    letter-spacing: 0.5px;
}

.modal-content strong {
    font-family: var(--font-heading);
    color: var(--secondary-color);
    font-size: 1.5rem;
    text-shadow: 0 0 10px var(--secondary-color);
    text-transform: uppercase;
    letter-spacing: 2px;
}

/* Responsive Design */
@media (max-width: 600px) {
    body {
        padding: 10px;
    }

    h1 {
        font-size: 2rem;
    }

    #players-container {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
        gap: 10px;
    }

    .card {
        padding: 20px;
    }
}
