/* ===== CSS Variables & Design System ===== */
:root {
    --bg-primary: #0a1628;
    --bg-secondary: #0f1f3a;
    --bg-card: rgba(15, 31, 58, 0.85);
    --text-primary: #f0f4ff;
    --text-secondary: #8899bb;
    --accent-glow: rgba(100, 180, 255, 0.3);
    --color-red: #e53935;
    --color-blue: #1e88e5;
    --color-orange: #fb8c00;
    --color-purple: #8e24aa;
    --color-yellow: #fdd835;
    --font-main: 'Outfit', sans-serif;
    --radius-sm: 8px;
    --radius-md: 16px;
    --radius-lg: 24px;
}

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

html, body {
    width: 100%; height: 100%;
    overflow: hidden;
    font-family: var(--font-main);
    background: var(--bg-primary);
    color: var(--text-primary);
    -webkit-user-select: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

/* ===== Screen System ===== */
.screen {
    position: fixed; top: 0; left: 0;
    width: 100%; height: 100%;
    display: none; flex-direction: column;
    align-items: center; justify-content: center;
    z-index: 1;
}
.screen.active { display: flex; }

/* ===== Start Screen ===== */
#start-screen {
    background: linear-gradient(135deg, #0a1628 0%, #1a2744 40%, #0f1f3a 100%);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    justify-content: flex-start;
    padding-top: 5vh;
    padding-bottom: 5vh;
}

.start-bg-particles {
    position: absolute; top: 0; left: 0;
    width: 100%; height: 100%;
    pointer-events: none; z-index: 0;
}

.start-bg-particles .particle {
    position: absolute; border-radius: 50%;
    opacity: 0.15;
    animation: floatParticle 8s infinite ease-in-out;
}

@keyframes floatParticle {
    0%, 100% { transform: translateY(0) scale(1); opacity: 0.1; }
    50% { transform: translateY(-30px) scale(1.2); opacity: 0.25; }
}

.start-content {
    position: relative; z-index: 1;
    display: flex; flex-direction: column; align-items: center;
    gap: 24px; padding: 20px; width: 100%; max-width: 450px;
}

.logo-container { position: relative; text-align: center; margin-bottom: 10px; }

.logo-glow {
    position: absolute; top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    width: 200px; height: 200px;
    background: radial-gradient(circle, rgba(100, 180, 255, 0.2) 0%, transparent 70%);
    border-radius: 50%;
    animation: pulseGlow 3s infinite ease-in-out;
}

@keyframes pulseGlow {
    0%, 100% { transform: translate(-50%, -50%) scale(1); opacity: 0.5; }
    50% { transform: translate(-50%, -50%) scale(1.3); opacity: 1; }
}

.game-title {
    font-size: 3.5rem; font-weight: 900; letter-spacing: 4px;
    background: linear-gradient(180deg, #ffffff 0%, #88bbff 100%);
    -webkit-background-clip: text; -webkit-text-fill-color: transparent;
    background-clip: text;
    filter: drop-shadow(0 0 20px rgba(100, 180, 255, 0.3));
}

.title-accent {
    display: block; font-size: 1.8rem; letter-spacing: 12px;
    background: linear-gradient(180deg, #ffcc00 0%, #ff8800 100%);
    -webkit-background-clip: text; -webkit-text-fill-color: transparent;
    background-clip: text;
}

.game-subtitle {
    color: var(--text-secondary); font-size: 0.9rem;
    letter-spacing: 3px; text-transform: uppercase; margin-top: 4px;
}

.mode-selection {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    width: 100%;
}

.mode-btn {
    flex: 1; position: relative;
    display: flex; flex-direction: column; align-items: center; gap: 6px;
    padding: 18px 12px;
    background: var(--bg-card);
    border: 2px solid rgba(100, 180, 255, 0.1);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-family: var(--font-main); font-size: 0.95rem; font-weight: 600;
    cursor: pointer; transition: all 0.3s ease;
    backdrop-filter: blur(10px);
}

.mode-btn:hover { border-color: rgba(100, 180, 255, 0.3); }

.mode-btn.active-mode {
    border-color: var(--color-blue); color: var(--text-primary);
    box-shadow: 0 0 20px rgba(30, 136, 229, 0.2), inset 0 0 20px rgba(30, 136, 229, 0.05);
}

.mode-icon { font-size: 2rem; }
.mode-label { font-weight: 700; }

.coming-soon {
    position: absolute; top: -8px; right: -8px;
    background: linear-gradient(135deg, #ff6b6b, #ff3366);
    color: white; font-size: 0.55rem; font-weight: 700;
    padding: 3px 8px; border-radius: 20px;
    text-transform: uppercase; letter-spacing: 1px;
}

.player-names-section {
    width: 100%; background: var(--bg-card);
    border-radius: var(--radius-md); padding: 18px;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(100, 180, 255, 0.08);
}

.player-names-section h3 {
    font-size: 0.85rem; color: var(--text-secondary);
    text-transform: uppercase; letter-spacing: 2px;
    margin-bottom: 14px; text-align: center;
}

.name-input-row { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.name-input-row:last-child { margin-bottom: 0; }

.color-select {
    width: 85px;
    height: 34px;
    border-radius: var(--radius-sm);
    border: 1px solid rgba(255,255,255,0.15);
    color: var(--text-primary);
    font-family: var(--font-main);
    font-size: 0.8rem;
    font-weight: 700;
    padding: 0 6px;
    outline: none;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0,0,0,0.3);
    transition: all 0.3s ease;
}
.color-select:hover {
    border-color: rgba(100, 180, 255, 0.3);
}

.bot-checkbox-label {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    user-select: none;
    flex-shrink: 0;
    background: rgba(255,255,255,0.05);
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    border: 1px solid rgba(255,255,255,0.08);
    transition: all 0.3s ease;
}
.bot-checkbox-label:hover {
    background: rgba(255,255,255,0.1);
    border-color: rgba(100, 180, 255, 0.2);
}

.bot-checkbox {
    width: 16px;
    height: 16px;
    accent-color: var(--color-blue);
    cursor: pointer;
}

.name-input-row input {
    flex: 1;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-sm); padding: 10px 14px;
    color: var(--text-primary); font-family: var(--font-main);
    font-size: 0.9rem; font-weight: 600; outline: none;
    transition: border-color 0.3s ease;
}

.name-input-row input:focus { border-color: rgba(100, 180, 255, 0.4); }
.name-input-row input::placeholder { color: var(--text-secondary); opacity: 0.5; }

.play-btn {
    display: flex; align-items: center; justify-content: center; gap: 12px;
    width: 100%; max-width: 280px; padding: 16px 32px;
    background: linear-gradient(135deg, #1e88e5, #1565c0);
    border: none; border-radius: 50px;
    color: white; font-family: var(--font-main);
    font-size: 1.1rem; font-weight: 800; letter-spacing: 3px;
    cursor: pointer; transition: all 0.3s ease;
    box-shadow: 0 4px 20px rgba(30, 136, 229, 0.4);
    position: relative; overflow: hidden;
}

.play-btn::before {
    content: ''; position: absolute; top: 0; left: -100%;
    width: 100%; height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
    animation: btnShimmer 3s infinite;
}

@keyframes btnShimmer { 0% { left: -100%; } 100% { left: 100%; } }

.play-btn:hover { transform: translateY(-2px); box-shadow: 0 6px 30px rgba(30, 136, 229, 0.5); }
.play-btn:active { transform: translateY(0); }
.play-btn-icon { font-size: 1.2rem; }

/* ===== Power-Ups Toggle ===== */
.powerups-toggle-section {
    width: 100%;
    display: flex; flex-direction: column; align-items: center; gap: 6px;
}

.toggle-label {
    display: flex; align-items: center; gap: 14px;
    cursor: pointer; padding: 10px 20px;
    background: var(--bg-card);
    border: 1px solid rgba(100, 180, 255, 0.1);
    border-radius: 50px;
    backdrop-filter: blur(10px);
    transition: all 0.3s ease;
}
.toggle-label:hover { border-color: rgba(100, 180, 255, 0.3); }

.toggle-text {
    font-size: 0.95rem; font-weight: 700;
    color: var(--text-primary); letter-spacing: 1px;
}

.toggle-switch {
    position: relative; width: 48px; height: 26px;
}
.toggle-switch input { opacity: 0; width: 0; height: 0; }

.toggle-slider {
    position: absolute; inset: 0;
    background: rgba(255,255,255,0.1);
    border-radius: 26px; cursor: pointer;
    transition: all 0.3s ease;
}
.toggle-slider::before {
    content: '';
    position: absolute; left: 3px; top: 3px;
    width: 20px; height: 20px;
    background: #fff; border-radius: 50%;
    transition: all 0.3s ease;
    box-shadow: 0 2px 6px rgba(0,0,0,0.3);
}
.toggle-switch input:checked + .toggle-slider {
    background: linear-gradient(135deg, #1e88e5, #1565c0);
}
.toggle-switch input:checked + .toggle-slider::before {
    transform: translateX(22px);
}

.toggle-hint {
    font-size: 0.7rem; color: var(--text-secondary);
    letter-spacing: 1px; opacity: 0.7;
}

/* ===== Game Screen - Full Canvas ===== */
#game-screen {
    background: #0a1628;
    padding: 0;
}

#board-canvas {
    width: 100%;
    height: 100%;
    display: block;
    cursor: pointer;
}

/* ===== Win Screen ===== */
#win-screen {
    background: rgba(10, 22, 40, 0.95);
    backdrop-filter: blur(20px); z-index: 100;
}

.win-content {
    display: flex; flex-direction: column; align-items: center;
    gap: 20px; padding: 30px; position: relative;
}

.confetti-container {
    position: fixed; top: 0; left: 0;
    width: 100%; height: 100%; pointer-events: none; z-index: 0;
}

.trophy {
    font-size: 5rem;
    animation: trophyBounce 1s ease-in-out infinite alternate;
    filter: drop-shadow(0 0 20px rgba(255, 215, 0, 0.5));
}

@keyframes trophyBounce { from { transform: translateY(0); } to { transform: translateY(-15px); } }

.winner-text {
    font-size: 2rem; font-weight: 900; letter-spacing: 2px; text-align: center;
    background: linear-gradient(180deg, #ffd700, #ff8c00);
    -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}

.rankings { display: flex; flex-direction: column; gap: 10px; width: 100%; max-width: 300px; }

.rank-row {
    display: flex; align-items: center; gap: 12px; padding: 10px 16px;
    background: var(--bg-card); border-radius: var(--radius-sm);
    border: 1px solid rgba(255,255,255,0.05);
}

.rank-number { font-weight: 800; font-size: 1.1rem; width: 30px; text-align: center; }
.rank-name { flex: 1; font-weight: 600; }
.rank-score {
    font-weight: 800; font-size: 0.95rem;
    background: linear-gradient(135deg, #ffd700, #ff8c00);
    -webkit-background-clip: text; -webkit-text-fill-color: transparent;
    background-clip: text;
}
.rank-medal { font-size: 1.3rem; }

/* ===== Menu Overlay ===== */
.menu-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.6); display: none;
    align-items: center; justify-content: center;
    z-index: 200; backdrop-filter: blur(5px);
}
.menu-overlay.show { display: flex; }

.menu-panel {
    background: var(--bg-secondary);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: var(--radius-lg); padding: 30px;
    display: flex; flex-direction: column; gap: 14px;
    min-width: 250px; text-align: center;
}

.menu-panel h3 { font-size: 1.2rem; font-weight: 800; letter-spacing: 2px; margin-bottom: 6px; }

.menu-option {
    padding: 12px 24px;
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: var(--radius-sm);
    color: var(--text-primary); font-family: var(--font-main);
    font-size: 0.95rem; font-weight: 600;
    cursor: pointer; transition: all 0.3s ease;
}

.menu-option:hover { background: rgba(255,255,255,0.1); border-color: rgba(100, 180, 255, 0.3); }

/* ===== Mid-Game Players Control ===== */
.menu-players-section {
    margin: 10px 0;
    text-align: left;
    background: rgba(0, 0, 0, 0.15);
    border-radius: var(--radius-sm);
    padding: 12px;
    border: 1px solid rgba(255,255,255,0.05);
}
.menu-players-section h4 {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 2px;
    margin-bottom: 10px;
    margin-top: 0;
}
.menu-player-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 0;
    border-bottom: 1px dashed rgba(255, 255, 255, 0.06);
}
.menu-player-row:last-child {
    border-bottom: none;
}
.menu-player-name {
    font-size: 0.9rem;
    font-weight: 700;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.autoplay-checkbox-label {
    display: flex;
    align-items: center;
    gap: 5px;
    cursor: pointer;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-secondary);
    user-select: none;
}
.autoplay-checkbox {
    cursor: pointer;
    width: 14px;
    height: 14px;
    accent-color: var(--color-blue);
}
.menu-leave-btn {
    background: rgba(229, 57, 53, 0.15);
    border: 1px solid rgba(229, 57, 53, 0.3);
    border-radius: 4px;
    color: #ff5252;
    padding: 4px 8px;
    font-size: 0.75rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
}
.menu-leave-btn:hover {
    background: rgba(229, 57, 53, 0.3);
    border-color: #ff5252;
}
.menu-option.danger {
    background: rgba(229, 57, 53, 0.08);
    border-color: rgba(229, 57, 53, 0.2);
}
.menu-option.danger:hover {
    background: rgba(229, 57, 53, 0.2);
    border-color: rgba(229, 57, 53, 0.5);
}
