/**
 * Slam.io Styles
 * Modern, clean design with Figtree and Inter fonts
 */

/* ============ CSS VARIABLES ============ */
:root {
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --primary-glow: rgba(99, 102, 241, 0.4);
    --accent: #22c55e;
    --accent-hover: #16a34a;
    --danger: #ef4444;
    --warning: #f59e0b;
    
    --bg: #0a0a0f;
    --bg-light: #12121a;
    --bg-lighter: #1a1a25;
    --bg-card: #15151f;
    
    --text: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-dim: #64748b;
    
    --border: #2a2a3a;
    --border-light: #3a3a4a;
    
    --radius: 12px;
    --radius-sm: 8px;
    --radius-xs: 6px;
    
    --shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.6);
    
    --transition: 0.2s ease;
    
    --font-display: 'Figtree', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-body: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

/* ============ RESET & BASE ============ */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    overflow: hidden;
}

body {
    font-family: var(--font-body);
    font-size: 14px;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-display);
    font-weight: 700;
}

button {
    font-family: var(--font-body);
    cursor: pointer;
}

input, select {
    font-family: var(--font-body);
}

/* ============ APP CONTAINER ============ */
#app {
    position: relative;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

/* Background Canvas */
#bgCanvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
}

/* ============ SCREENS ============ */
.screen {
    display: none;
    width: 100%;
    height: 100%;
}

.screen.active {
    display: flex;
}

/* ============ MENU SCREEN ============ */
#menuScreen {
    position: relative;
    z-index: 1;
    justify-content: center;
    align-items: center;
    background: rgba(10, 10, 15, 0.7);
    backdrop-filter: blur(8px);
}

.menu-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 28px;
    padding: 40px;
    max-width: 420px;
    width: 100%;
}

/* Logo */
.logo-section {
    text-align: center;
}

.game-logo {
    font-family: var(--font-display);
    font-size: 72px;
    font-weight: 900;
    letter-spacing: -3px;
    line-height: 1;
    text-shadow: 0 4px 30px var(--primary-glow);
}

.logo-slam {
    color: var(--primary);
}

.logo-io {
    color: var(--text);
}

.tagline {
    color: var(--text-dim);
    font-size: 14px;
    font-weight: 500;
    margin-top: 8px;
    letter-spacing: 0.5px;
}

/* Main Buttons */
.main-buttons {
    display: flex;
    flex-direction: column;
    gap: 14px;
    width: 100%;
}

.big-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 18px 40px;
    font-family: var(--font-display);
    font-size: 22px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 1px;
    border: none;
    border-radius: var(--radius);
    transition: all var(--transition);
}

.big-btn.primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-hover));
    color: white;
    box-shadow: 0 4px 20px var(--primary-glow);
}

.big-btn.primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 30px var(--primary-glow);
}

.big-btn.primary:active {
    transform: translateY(0);
}

.big-btn i {
    font-size: 20px;
}

.secondary-buttons {
    display: flex;
    gap: 12px;
}

.med-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px 20px;
    font-size: 14px;
    font-weight: 600;
    background: var(--bg-lighter);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    transition: all var(--transition);
}

.med-btn:hover {
    background: var(--bg-card);
    border-color: var(--primary);
    color: var(--primary);
}

.med-btn i {
    font-size: 14px;
}

/* Rooms Section */
.rooms-section {
    width: 100%;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.rooms-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: var(--bg-lighter);
    border-bottom: 1px solid var(--border);
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
}

.rooms-header i {
    margin-right: 6px;
    color: var(--primary);
}

.icon-btn {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    color: var(--text-dim);
    font-size: 12px;
    transition: all var(--transition);
}

.icon-btn:hover {
    background: var(--bg-lighter);
    border-color: var(--primary);
    color: var(--primary);
}

.room-list {
    max-height: 180px;
    overflow-y: auto;
    padding: 8px;
}

.room-list::-webkit-scrollbar {
    width: 6px;
}

.room-list::-webkit-scrollbar-track {
    background: transparent;
}

.room-list::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

.room-list::-webkit-scrollbar-thumb:hover {
    background: var(--border-light);
}

.empty-rooms {
    padding: 24px;
    text-align: center;
    color: var(--text-dim);
    font-size: 13px;
}

.room-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 14px;
    background: var(--bg-lighter);
    border-radius: var(--radius-xs);
    cursor: pointer;
    transition: all var(--transition);
    margin-bottom: 6px;
}

.room-item:last-child {
    margin-bottom: 0;
}

.room-item:hover {
    background: var(--bg);
    border-color: var(--primary);
    transform: translateX(4px);
}

.room-name {
    font-weight: 600;
    font-size: 13px;
    margin-bottom: 2px;
}

.room-meta {
    font-size: 11px;
    color: var(--text-dim);
}

.room-players {
    font-weight: 700;
    color: var(--primary);
    font-size: 14px;
}

/* Controls Hint */
.controls-hint {
    display: flex;
    gap: 20px;
    color: var(--text-dim);
    font-size: 12px;
}

.controls-hint kbd {
    display: inline-block;
    padding: 3px 8px;
    background: var(--bg-lighter);
    border: 1px solid var(--border);
    border-radius: 4px;
    font-family: var(--font-body);
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-right: 4px;
}

/* User Section */
.user-section {
    display: flex;
    align-items: center;
    gap: 12px;
}

.text-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    transition: all var(--transition);
}

.text-btn:hover {
    background: var(--bg-lighter);
    border-color: var(--primary);
    color: var(--text);
}

/* ============ GAME SCREEN ============ */
#gameScreen {
    flex-direction: column;
    background: var(--bg);
}

.back-btn {
    position: fixed;
    top: 12px;
    left: 12px;
    z-index: 100;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 13px;
    font-weight: 500;
    transition: all var(--transition);
}

.back-btn:hover {
    background: var(--bg-lighter);
    border-color: var(--primary);
}

.game-layout {
    display: flex;
    height: 100%;
    gap: 0;
}

/* Side Panels */
.side-panel {
    width: 240px;
    min-width: 240px;
    background: var(--bg-light);
    display: flex;
    flex-direction: column;
    border: 1px solid var(--border);
}

.left-panel {
    border-left: none;
    border-top: none;
    border-bottom: none;
}

.right-panel {
    border-right: none;
    border-top: none;
    border-bottom: none;
}

.panel-section {
    padding: 14px;
    border-bottom: 1px solid var(--border);
}

.panel-section:last-child {
    border-bottom: none;
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 11px;
    font-weight: 700;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 10px;
}

.section-header i {
    margin-right: 6px;
    color: var(--primary);
}

.badge {
    background: var(--primary);
    color: white;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
}

/* Player List */
.player-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 180px;
    overflow-y: auto;
}

.player-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    background: var(--bg-lighter);
    border-radius: var(--radius-xs);
    font-size: 13px;
}

.player-item.dead {
    opacity: 0.4;
}

.player-color {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    flex-shrink: 0;
}

.player-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 500;
}

.player-score {
    font-weight: 700;
    color: var(--primary);
}

/* Chat */
.chat-section {
    flex: 1;
    overflow: hidden;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 4px 0;
    font-size: 12px;
    min-height: 120px;
}

.chat-msg {
    padding: 4px 0;
    word-break: break-word;
}

.chat-msg .name {
    font-weight: 600;
    color: var(--primary);
}

.chat-msg.system {
    color: var(--text-dim);
    font-style: italic;
}

.chat-input-wrap {
    display: flex;
    gap: 8px;
    margin-top: 10px;
}

.chat-input-wrap input {
    flex: 1;
    padding: 10px 12px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    color: var(--text);
    font-size: 12px;
    outline: none;
    transition: border-color var(--transition);
}

.chat-input-wrap input:focus {
    border-color: var(--primary);
}

.chat-input-wrap button {
    padding: 10px 14px;
    background: var(--primary);
    border: none;
    border-radius: var(--radius-xs);
    color: white;
    font-size: 12px;
    transition: background var(--transition);
}

.chat-input-wrap button:hover {
    background: var(--primary-hover);
}

/* Room Info */
.room-info {
    font-size: 12px;
}

.room-info > div {
    display: flex;
    justify-content: space-between;
    padding: 6px 0;
    border-bottom: 1px solid var(--border);
}

.room-info > div:last-child {
    border-bottom: none;
}

.room-info span:first-child {
    color: var(--text-dim);
}

.leave-btn {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 5px 12px;
    background: var(--danger);
    border: none;
    border-radius: var(--radius-xs);
    color: white;
    font-size: 11px;
    font-weight: 600;
    transition: background var(--transition);
}

.leave-btn:hover {
    background: #dc2626;
}

/* Scoreboard */
.scoreboard {
    display: flex;
    flex-direction: column;
    gap: 6px;
    overflow-y: auto;
    flex: 1;
}

.score-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 10px;
    background: var(--bg-lighter);
    border-radius: var(--radius-xs);
    font-size: 12px;
}

.score-name {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Host Panel */
.host-start-btn {
    width: 100%;
    padding: 12px;
    background: var(--accent);
    border: none;
    border-radius: var(--radius-xs);
    color: white;
    font-weight: 700;
    font-size: 13px;
    transition: background var(--transition);
    margin-bottom: 10px;
}

.host-start-btn:hover {
    background: var(--accent-hover);
}

.host-settings {
    display: flex;
    gap: 8px;
}

.host-settings select {
    flex: 1;
    padding: 8px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    color: var(--text);
    font-size: 11px;
}

/* Game Area */
#gameArea {
    flex: 1;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg);
    overflow: hidden;
    min-width: 0;
}

#gameCanvas {
    display: block;
    background: #0c0c10;
}

/* Game Overlays */
.game-overlay-box {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    z-index: 10;
}

.lobby-content {
    background: rgba(10, 10, 15, 0.95);
    padding: 36px 52px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    backdrop-filter: blur(10px);
}

.lobby-icon {
    font-size: 32px;
    color: var(--primary);
    margin-bottom: 12px;
    animation: pulse 2s ease-in-out infinite;
}

.lobby-title {
    font-family: var(--font-display);
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 8px;
}

.lobby-count {
    font-family: var(--font-display);
    font-size: 36px;
    font-weight: 800;
    color: var(--primary);
    margin-bottom: 8px;
}

.lobby-hint {
    color: var(--text-dim);
    font-size: 13px;
    margin-bottom: 16px;
}

.start-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 14px 36px;
    background: var(--accent);
    border: none;
    border-radius: var(--radius-sm);
    color: white;
    font-size: 15px;
    font-weight: 700;
    transition: all var(--transition);
}

.start-btn:hover {
    background: var(--accent-hover);
    transform: translateY(-2px);
}

/* Countdown */
.countdown {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-family: var(--font-display);
    font-size: 120px;
    font-weight: 900;
    color: var(--primary);
    text-shadow: 0 0 60px var(--primary-glow);
    z-index: 20;
    animation: countPulse 0.5s ease-out;
}

@keyframes countPulse {
    0% { transform: translate(-50%, -50%) scale(1.5); opacity: 0; }
    100% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}

/* HUD */
.game-hud {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 20px;
    background: linear-gradient(to bottom, rgba(0, 0, 0, 0.6), transparent);
    z-index: 5;
}

.hud-left, .hud-center, .hud-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.game-hud span {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
}

.game-hud i {
    margin-right: 4px;
    color: var(--primary);
}

.slam-ready {
    color: var(--warning) !important;
    animation: glow 1s ease-in-out infinite alternate;
}

@keyframes glow {
    from { text-shadow: 0 0 5px var(--warning); }
    to { text-shadow: 0 0 15px var(--warning), 0 0 25px var(--warning); }
}

/* ============ MODALS ============ */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

.modal.active {
    display: flex;
}

.modal-bg {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(4px);
}

.modal-box {
    position: relative;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 28px;
    width: 100%;
    max-width: 380px;
    box-shadow: var(--shadow-lg);
}

.modal-box.small {
    max-width: 300px;
    text-align: center;
}

.modal-close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    color: var(--text-dim);
    font-size: 14px;
    transition: all var(--transition);
}

.modal-close:hover {
    background: var(--danger);
    border-color: var(--danger);
    color: white;
}

.modal h2 {
    font-family: var(--font-display);
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 20px;
}

/* Auth Tabs */
.auth-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
}

.auth-tabs .tab {
    flex: 1;
    padding: 10px;
    background: var(--bg-lighter);
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    color: var(--text-dim);
    font-size: 13px;
    font-weight: 600;
    transition: all var(--transition);
}

.auth-tabs .tab:hover {
    border-color: var(--primary);
}

.auth-tabs .tab.active {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

/* Forms */
form {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

form input[type="text"],
form input[type="password"] {
    padding: 12px 14px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    color: var(--text);
    font-size: 14px;
    outline: none;
    transition: border-color var(--transition);
}

form input:focus {
    border-color: var(--primary);
}

form select {
    padding: 12px 14px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    color: var(--text);
    font-size: 14px;
    cursor: pointer;
}

.form-row {
    display: flex;
    gap: 12px;
}

.form-row > * {
    flex: 1;
}

.color-row {
    display: flex;
    justify-content: center;
    gap: 24px;
}

.color-row label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-secondary);
}

.color-row input[type="color"] {
    width: 36px;
    height: 36px;
    border: none;
    border-radius: var(--radius-xs);
    cursor: pointer;
    background: transparent;
}

.checkbox {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-secondary);
    cursor: pointer;
}

.checkbox input {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--primary);
}

.error {
    color: var(--danger);
    font-size: 12px;
    text-align: center;
}

.submit-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px 24px;
    background: var(--primary);
    border: none;
    border-radius: var(--radius-sm);
    color: white;
    font-size: 14px;
    font-weight: 600;
    transition: all var(--transition);
}

.submit-btn:hover {
    background: var(--primary-hover);
}

/* Color Preview */
#colorPreviewCanvas {
    display: block;
    margin: 0 auto 20px;
    background: var(--bg);
    border-radius: var(--radius-sm);
}

/* Round End Modal */
.winner {
    font-family: var(--font-display);
    font-size: 18px;
    font-weight: 700;
    color: var(--accent);
    margin-bottom: 16px;
}

.scores {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.score-item {
    display: flex;
    justify-content: space-between;
    padding: 8px 12px;
    background: var(--bg-lighter);
    border-radius: var(--radius-xs);
    font-size: 13px;
}

/* ============ UTILITIES ============ */
.hidden {
    display: none !important;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* ============ RESPONSIVE ============ */
@media (max-width: 900px) {
    .side-panel {
        width: 200px;
        min-width: 200px;
    }
}

@media (max-width: 768px) {
    .game-layout {
        flex-direction: column;
    }
    
    .side-panel {
        width: 100%;
        min-width: auto;
        height: auto;
        max-height: 150px;
    }
    
    .left-panel {
        order: 2;
        border: none;
        border-top: 1px solid var(--border);
    }
    
    .right-panel {
        order: 3;
        border: none;
        border-top: 1px solid var(--border);
    }
    
    #gameArea {
        order: 1;
        min-height: 300px;
    }
    
    .game-logo {
        font-size: 48px;
    }
    
    .menu-container {
        padding: 20px;
        gap: 20px;
    }
    
    .controls-hint {
        flex-wrap: wrap;
        justify-content: center;
    }
}
