:root {
    --primary-color: #2563eb;
    --secondary-color: #7c3aed;
    --success-color: #059669;
    --danger-color: #dc2626;
    --warning-color: #d97706;
    --dark-bg: #0f172a;
    --card-bg: #1e293b;
    --text-primary: #f8fafc;
    --text-secondary: #cbd5e1;
    --border-color: #334155;
    --accent-gold: #fbbf24;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', sans-serif;
    background: linear-gradient(135deg, var(--dark-bg) 0%, #1e293b 100%);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
}

/* Screen Management */
.screen {
    display: none;
    min-height: 100vh;
    animation: fadeIn 0.5s ease-in-out;
}

.screen.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Main Menu */
.game-title {
    font-family: 'Orbitron', monospace;
    font-size: 4rem;
    font-weight: 900;
    text-align: center;
    background: linear-gradient(45deg, var(--accent-gold), var(--primary-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 0.5rem;
    text-shadow: 0 0 30px rgba(251, 191, 36, 0.3);
}

.subtitle {
    text-align: center;
    font-size: 1.2rem;
    color: var(--text-secondary);
    margin-bottom: 3rem;
    font-style: italic;
}

.menu-options {
    max-width: 400px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.player-input input {
    width: 100%;
    padding: 1rem;
    border: 2px solid var(--border-color);
    border-radius: 12px;
    background: var(--card-bg);
    color: var(--text-primary);
    font-size: 1.1rem;
    transition: all 0.3s ease;
}

.player-input input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* Buttons */
.btn {
    padding: 1rem 2rem;
    border: none;
    border-radius: 12px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 25px rgba(37, 99, 235, 0.3);
}

.btn-secondary {
    background: var(--card-bg);
    color: var(--text-primary);
    border: 2px solid var(--border-color);
}

.btn-secondary:hover {
    border-color: var(--primary-color);
    transform: translateY(-2px);
}

.btn-danger {
    background: var(--danger-color);
    color: white;
}

.btn-small {
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
}

.join-input {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.join-input input {
    flex: 1;
    padding: 0.75rem;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    background: var(--card-bg);
    color: var(--text-primary);
    text-transform: uppercase;
}

.hidden {
    display: none !important;
}

/* Game Lobby */
.lobby-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid var(--border-color);
}

.lobby-header h2 {
    font-family: 'Orbitron', monospace;
    color: var(--accent-gold);
}

.players-list {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 2rem;
    margin-bottom: 2rem;
    border: 1px solid var(--border-color);
}

.players-list h3 {
    margin-bottom: 1rem;
    color: var(--text-secondary);
}

.player-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    margin: 0.5rem 0;
    background: var(--dark-bg);
    border-radius: 8px;
    border-left: 4px solid var(--primary-color);
}

.player-item.host {
    border-left-color: var(--accent-gold);
}

.player-badge {
    background: var(--accent-gold);
    color: var(--dark-bg);
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 600;
}

/* Game Screen */
.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding: 1.5rem;
    background: var(--card-bg);
    border-radius: 12px;
    border: 1px solid var(--border-color);
}

.round-info {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.round-info span:first-child {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--accent-gold);
}

.round-info span:last-child {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
}

.timer {
    font-family: 'Orbitron', monospace;
    font-size: 3rem;
    font-weight: 900;
    color: var(--accent-gold);
    text-align: center;
    padding: 1rem;
    border: 3px solid var(--accent-gold);
    border-radius: 50%;
    width: 100px;
    height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(251, 191, 36, 0.4); }
    70% { box-shadow: 0 0 0 10px rgba(251, 191, 36, 0); }
    100% { box-shadow: 0 0 0 0 rgba(251, 191, 36, 0); }
}

/* Numbers Round */
.round-content {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 2rem;
    margin-bottom: 2rem;
    border: 1px solid var(--border-color);
}

.target {
    text-align: center;
    margin-bottom: 2rem;
}

.target h3 {
    font-size: 2rem;
    color: var(--text-primary);
}

.target span {
    font-family: 'Orbitron', monospace;
    font-size: 3rem;
    color: var(--accent-gold);
    font-weight: 900;
}

.numbers-grid, .letters-grid, #availableNumbers, #availableLetters {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 2rem;
    flex-wrap: wrap;
}

.number-tile, .letter-tile {
    width: 80px;
    height: 80px;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 2px solid transparent;
}

.number-tile:hover, .letter-tile:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 25px rgba(37, 99, 235, 0.3);
}

.number-tile.used, .letter-tile.used {
    opacity: 0.5;
    transform: scale(0.9);
}

.letter-tile.vowel-chosen {
    border-color: var(--accent-gold);
    box-shadow: 0 0 10px rgba(251, 191, 36, 0.5);
}

.letter-tile.consonant-chosen {
    border-color: var(--primary-color);
    box-shadow: 0 0 10px rgba(37, 99, 235, 0.5);
}

.calculation, .word-input {
    margin-bottom: 2rem;
}

.calculation input, .word-input input {
    width: 100%;
    padding: 1rem;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    background: var(--dark-bg);
    color: var(--text-primary);
    font-size: 1.1rem;
    margin-bottom: 1rem;
}

.result, .word-length {
    text-align: center;
    font-size: 1.2rem;
    color: var(--text-secondary);
}

.result span, .word-length span {
    color: var(--accent-gold);
    font-weight: 700;
    font-family: 'Orbitron', monospace;
}

/* Scoreboard */
.scoreboard {
    background: var(--dark-bg);
    border-radius: 12px;
    padding: 1.5rem;
    border: 1px solid var(--border-color);
}

.scoreboard h4 {
    margin-bottom: 1rem;
    color: var(--text-secondary);
    text-align: center;
}

.score-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border-color);
}

.score-item:last-child {
    border-bottom: none;
}

.score-value {
    font-weight: 700;
    color: var(--accent-gold);
    font-family: 'Orbitron', monospace;
}

/* Results Screen */
.round-results {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 2rem;
    margin-bottom: 2rem;
    border: 1px solid var(--border-color);
}

.result-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    margin: 0.5rem 0;
    background: var(--dark-bg);
    border-radius: 8px;
    border-left: 4px solid var(--primary-color);
}

.result-item.winner {
    border-left-color: var(--accent-gold);
    background: rgba(251, 191, 36, 0.1);
}

.points-earned {
    font-weight: 700;
    color: var(--success-color);
    font-family: 'Orbitron', monospace;
}

/* Final Results */
.final-scoreboard {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 2rem;
    margin-bottom: 2rem;
    border: 1px solid var(--border-color);
}

.final-score-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    margin: 1rem 0;
    background: var(--dark-bg);
    border-radius: 12px;
    border-left: 4px solid var(--border-color);
    position: relative;
}

.final-score-item:first-child {
    border-left-color: var(--accent-gold);
    background: rgba(251, 191, 36, 0.1);
}

.final-score-item:first-child::before {
    content: "🏆";
    position: absolute;
    left: -10px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 2rem;
}

.position {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-secondary);
    margin-right: 1rem;
}

.final-controls {
    display: flex;
    gap: 1rem;
    justify-content: center;
}

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        padding: 1rem;
    }
    
    .game-title {
        font-size: 2.5rem;
    }
    
    .game-header {
        flex-direction: column;
        gap: 1rem;
    }
    
    .timer {
        font-size: 2rem;
        width: 80px;
        height: 80px;
    }
    
    .numbers-grid, .letters-grid {
        gap: 0.5rem;
    }
    
    .number-tile, .letter-tile {
        width: 60px;
        height: 60px;
        font-size: 1.2rem;
    }
    
    .final-controls {
        flex-direction: column;
    }
    
    /* Intermediate screen responsive */
    .letter-choice-buttons {
        flex-direction: column;
        gap: 1rem;
    }
    
    .choice-btn {
        padding: 1.5rem 3rem;
        font-size: 1.2rem;
        min-width: 180px;
    }
    
    .sequence-grid {
        gap: 0.5rem;
        max-width: 300px;
    }
    
    .sequence-square {
        width: 60px;
        height: 60px;
        font-size: 1.5rem;
    }
    
    .letter-choice-buttons {
        flex-direction: column;
        gap: 1rem;
    }
    
    .choice-btn {
        padding: 1.5rem 3rem;
        font-size: 1.2rem;
        min-width: 180px;
    }
    
    .sequence-grid {
        gap: 0.5rem;
        max-width: 300px;
    }
    
    .sequence-square {
        width: 60px;
        height: 60px;
        font-size: 1.5rem;
    }
    
    .vowel-buttons, .consonant-buttons {
        max-width: 100%;
        gap: 0.3rem;
    }
    
    .letter-btn {
        width: 45px;
        height: 45px;
        font-size: 1rem;
    }
    
    .selection-display {
        gap: 1rem;
    }
    
    .selected-vowel, .selected-consonant {
        width: 50px;
        height: 50px;
        font-size: 1.5rem;
    }
}

/* Intermediate Screen */
#intermediateScreen {
    display: none; /* Override with higher specificity */
    align-items: center;
    justify-content: center;
    text-align: center;
}

#intermediateScreen.active {
    display: flex; /* Only show when active */
}

#intermediateScreen h2 {
    font-family: 'Orbitron', monospace;
    font-size: 3rem;
    font-weight: 900;
    background: linear-gradient(45deg, var(--accent-gold), var(--primary-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 1rem;
    text-shadow: 0 0 30px rgba(251, 191, 36, 0.3);
}

#intermediateScreen p {
    font-size: 1.2rem;
    color: var(--text-secondary);
    margin-bottom: 2rem;
}

.turn-indicator {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 2rem;
    padding: 1rem 2rem;
    border-radius: 12px;
    text-align: center;
    transition: all 0.3s ease;
}

.turn-indicator.my-turn {
    background: var(--accent-gold);
    color: var(--dark-bg);
    box-shadow: 0 5px 15px rgba(251, 191, 36, 0.3);
    animation: pulse 2s infinite;
}

.turn-indicator.other-turn {
    background: var(--card-bg);
    color: var(--text-secondary);
    border: 2px solid var(--border-color);
}

.turn-indicator.complete {
    background: var(--success-color);
    color: white;
    box-shadow: 0 5px 15px rgba(5, 150, 105, 0.3);
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-20px); }
    to { opacity: 1; transform: translateY(0); }
}

.letter-choice-buttons {
    display: flex;
    gap: 2rem;
    margin-bottom: 3rem;
    justify-content: center;
}

.choice-btn {
    padding: 2rem 4rem;
    border: none;
    border-radius: 16px;
    font-size: 1.5rem;
    font-weight: 900;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 1px;
    min-width: 200px;
}

.vowel-choice {
    background: linear-gradient(135deg, var(--accent-gold), #f59e0b);
    color: var(--dark-bg);
    box-shadow: 0 8px 25px rgba(251, 191, 36, 0.3);
}

.vowel-choice:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 35px rgba(251, 191, 36, 0.4);
}

.consonant-choice {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    box-shadow: 0 8px 25px rgba(37, 99, 235, 0.3);
}

.consonant-choice:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 35px rgba(37, 99, 235, 0.4);
}

.letter-sequence {
    margin-bottom: 2rem;
}

.letter-sequence h3 {
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
    font-size: 1.5rem;
}

.sequence-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    max-width: 400px;
    margin: 0 auto;
}

.sequence-square {
    width: 80px;
    height: 80px;
    border: 3px solid var(--border-color);
    border-radius: 12px;
    background: var(--card-bg);
    color: var(--text-primary);
    font-size: 2rem;
    font-weight: 900;
    font-family: 'Orbitron', monospace;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.sequence-square::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s ease;
}

.sequence-square.filled::before {
    left: 100%;
}

.sequence-square.filled {
    border-color: var(--accent-gold);
    background: var(--accent-gold);
    color: var(--dark-bg);
    transform: scale(1.05);
    box-shadow: 0 5px 15px rgba(251, 191, 36, 0.3);
}

.sequence-square.vowel {
    border-color: var(--accent-gold);
    background: var(--accent-gold);
    color: var(--dark-bg);
}

.sequence-square.consonant {
    border-color: var(--primary-color);
    background: var(--primary-color);
    color: white;
}

.intermediate-controls {
    display: flex;
    justify-content: center;
    gap: 1rem;
}

.chosen-sequence-display {
    text-align: center;
    margin-bottom: 2rem;
    padding: 1rem;
    background: var(--card-bg);
    border-radius: 12px;
    border: 1px solid var(--border-color);
}

.chosen-sequence-display h4 {
    color: var(--accent-gold);
    margin-bottom: 0.5rem;
    font-family: 'Orbitron', monospace;
    font-size: 1.2rem;
}

.chosen-sequence-display p {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin: 0;
}
