/* ============================================================
   街机游戏网络对战平台 — 全局样式 (Arcade Battle Theme)
   ============================================================ */

/* --- CSS Variables --- */
:root {
    --bg-primary: #0a0a0f;
    --bg-secondary: #111122;
    --bg-card: #1a1a2e;
    --bg-card-hover: #222240;
    --text-primary: #e0e0f0;
    --text-secondary: #8888aa;
    --accent: #ff6b9d;
    --accent-glow: #ff2d75;
    --neon-blue: #00d4ff;
    --neon-green: #00ff88;
    --neon-yellow: #ffd700;
    --neon-purple: #b347ea;
    --border: #2a2a4a;
    --border-glow: #3a3a5a;
    --radius: 12px;
    --radius-sm: 8px;
    --transition: 0.2s ease;
    --font-mono: 'Courier New', monospace;
    --font-main: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* --- Reset & Base --- */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-main);
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
    overflow-x: hidden;
}

/* --- Animated Background --- */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    background:
        radial-gradient(ellipse at 20% 50%, rgba(255, 107, 157, 0.08) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 20%, rgba(0, 212, 255, 0.06) 0%, transparent 50%),
        radial-gradient(ellipse at 50% 80%, rgba(179, 71, 234, 0.05) 0%, transparent 50%);
    pointer-events: none;
    z-index: 0;
}

/* Scanline overlay for retro feel */
body::after {
    content: '';
    position: fixed;
    inset: 0;
    background: repeating-linear-gradient(
        0deg,
        transparent,
        transparent 2px,
        rgba(0, 0, 0, 0.03) 2px,
        rgba(0, 0, 0, 0.03) 4px
    );
    pointer-events: none;
    z-index: 9999;
    opacity: 0.5;
}

/* --- Typography --- */
h1, h2, h3, h4 {
    font-weight: 700;
    line-height: 1.2;
}

a {
    color: var(--neon-blue);
    text-decoration: none;
    transition: color var(--transition);
}
a:hover {
    color: var(--accent);
    text-shadow: 0 0 10px var(--accent-glow);
}

/* --- Container --- */
.container {
    position: relative;
    z-index: 1;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* ============================================================
   Header
   ============================================================ */
.site-header {
    position: relative;
    z-index: 1;
    text-align: center;
    padding: 40px 20px 20px;
}

.site-header .logo {
    font-size: 3rem;
    font-family: var(--font-mono);
    font-weight: 900;
    letter-spacing: 4px;
    text-transform: uppercase;
    background: linear-gradient(135deg, var(--neon-blue), var(--accent), var(--neon-purple));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: none;
    filter: drop-shadow(0 0 20px rgba(0, 212, 255, 0.3));
    margin-bottom: 8px;
}

.site-header .subtitle {
    font-size: 0.95rem;
    color: var(--text-secondary);
    letter-spacing: 2px;
    font-family: var(--font-mono);
}

/* --- Neon Divider --- */
.neon-divider {
    position: relative;
    z-index: 1;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--neon-blue), var(--accent), var(--neon-purple), transparent);
    margin: 10px auto 30px;
    max-width: 800px;
    opacity: 0.6;
}

/* ============================================================
   Lobby — Game Grid
   ============================================================ */
.game-grid {
    position: relative;
    z-index: 1;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 24px;
    padding: 20px 0;
}

/* --- Game Card --- */
.game-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    transition: all 0.3s ease;
    cursor: pointer;
    display: flex;
    flex-direction: column;
}

.game-card:hover {
    transform: translateY(-4px);
    border-color: var(--accent);
    box-shadow:
        0 8px 32px rgba(255, 107, 157, 0.15),
        0 0 60px rgba(0, 212, 255, 0.05);
}

.game-card:hover .card-cover {
    filter: brightness(1.1);
}

.card-cover {
    width: 100%;
    aspect-ratio: 16/10;
    object-fit: cover;
    background: var(--bg-secondary);
    transition: filter 0.3s ease;
}

.card-cover-placeholder {
    width: 100%;
    aspect-ratio: 16/10;
    background: linear-gradient(135deg, var(--bg-secondary), var(--bg-card));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3rem;
}

.card-body {
    padding: 16px;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.card-title {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 4px;
    color: var(--text-primary);
}

.card-meta {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 12px;
    font-family: var(--font-mono);
    display: flex;
    gap: 12px;
    align-items: center;
}

.card-meta .players-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: var(--neon-green);
    font-size: 0.75rem;
}

.card-actions {
    margin-top: auto;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* ============================================================
   Buttons
   ============================================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 20px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    font-family: inherit;
    white-space: nowrap;
}

.btn:active {
    transform: scale(0.97);
}

/* Primary — Solo Play */
.btn-primary {
    background: linear-gradient(135deg, var(--neon-blue), #0099cc);
    border-color: var(--neon-blue);
    color: #fff;
}
.btn-primary:hover {
    box-shadow: 0 0 20px rgba(0, 212, 255, 0.4);
    border-color: #66e0ff;
}

/* Accent — Create Room */
.btn-accent {
    background: linear-gradient(135deg, var(--accent), #cc3377);
    border-color: var(--accent);
    color: #fff;
}
.btn-accent:hover {
    box-shadow: 0 0 20px rgba(255, 107, 157, 0.4);
    border-color: #ff88b0;
}

/* Outline */
.btn-outline {
    background: transparent;
    border-color: var(--border-glow);
    color: var(--text-primary);
}
.btn-outline:hover {
    border-color: var(--neon-purple);
    color: var(--neon-purple);
    box-shadow: 0 0 12px rgba(179, 71, 234, 0.2);
}

/* Small */
.btn-sm {
    padding: 6px 14px;
    font-size: 0.8rem;
}

/* Block (full width) */
.btn-block {
    width: 100%;
}

/* ============================================================
   Join Room Section
   ============================================================ */
.join-section {
    position: relative;
    z-index: 1;
    text-align: center;
    padding: 30px 20px 50px;
}

.join-section h3 {
    font-size: 1.2rem;
    margin-bottom: 16px;
    color: var(--text-secondary);
    font-weight: 400;
}

.join-form {
    display: flex;
    gap: 10px;
    max-width: 440px;
    margin: 0 auto;
    flex-wrap: wrap;
    justify-content: center;
}

.join-input {
    flex: 1;
    min-width: 200px;
    padding: 12px 16px;
    background: var(--bg-card);
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 1rem;
    font-family: var(--font-mono);
    letter-spacing: 1px;
    transition: border-color 0.2s ease;
    text-transform: uppercase;
}

.join-input::placeholder {
    color: var(--text-secondary);
    letter-spacing: 0;
    text-transform: none;
    font-family: var(--font-main);
}

.join-input:focus {
    outline: none;
    border-color: var(--neon-blue);
    box-shadow: 0 0 16px rgba(0, 212, 255, 0.15);
}

/* ============================================================
   Game Page
   ============================================================ */
.game-wrapper {
    position: relative;
    z-index: 1;
    width: 100%;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

/* EmulatorJS container */
#game {
    flex: 1;
    width: 100%;
    height: 100%;
}

/* --- Back Button (on game page) --- */
.back-btn {
    position: fixed;
    top: 16px;
    left: 16px;
    z-index: 100;
    background: rgba(10, 10, 15, 0.9);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    padding: 8px 14px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 6px;
    font-family: inherit;
}
.back-btn:hover {
    color: var(--text-primary);
    border-color: var(--neon-blue);
    box-shadow: 0 0 12px rgba(0, 212, 255, 0.2);
}

/* --- Share Bar --- */
.share-bar {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 100;
    background: rgba(10, 10, 15, 0.95);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    backdrop-filter: blur(12px);
    transition: all 0.3s ease;
}

.share-bar.hidden {
    opacity: 0;
    pointer-events: none;
    transform: translateX(-50%) translateY(20px);
}

.share-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-family: var(--font-mono);
    white-space: nowrap;
}

.share-code {
    font-size: 1.1rem;
    font-weight: 700;
    font-family: var(--font-mono);
    color: var(--neon-green);
    letter-spacing: 2px;
    text-shadow: 0 0 10px rgba(0, 255, 136, 0.3);
}

.share-copy-btn {
    padding: 6px 14px;
    font-size: 0.8rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
}
.share-copy-btn:hover {
    border-color: var(--neon-green);
    color: var(--neon-green);
}

/* ============================================================
   Toast / Message
   ============================================================ */
.toast {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10000;
    background: var(--bg-card);
    border: 1px solid var(--neon-green);
    border-radius: var(--radius-sm);
    padding: 12px 24px;
    color: var(--neon-green);
    font-size: 0.9rem;
    font-weight: 600;
    animation: toastIn 0.3s ease, toastOut 0.3s ease 2s forwards;
    box-shadow: 0 4px 20px rgba(0, 255, 136, 0.2);
}

@keyframes toastIn {
    from { opacity: 0; transform: translateX(-50%) translateY(-10px); }
    to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}
@keyframes toastOut {
    from { opacity: 1; }
    to   { opacity: 0; }
}

/* ============================================================
   Netplay Guide Overlay (for host page)
   ============================================================ */
.netplay-guide {
    position: fixed;
    inset: 0;
    z-index: 500;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
}

.netplay-guide-content {
    background: var(--bg-card);
    border: 1px solid var(--border-glow);
    border-radius: var(--radius);
    padding: 30px 36px;
    max-width: 480px;
    text-align: center;
    animation: toastIn 0.3s ease;
}

.netplay-guide-content h2 {
    margin-bottom: 8px;
    color: var(--neon-blue);
}

.netplay-guide-content p {
    color: var(--text-secondary);
    margin-bottom: 20px;
    font-size: 0.9rem;
    line-height: 1.6;
}

.netplay-guide-content .step {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
    text-align: left;
    font-size: 0.9rem;
}
.netplay-guide-content .step:last-child { border-bottom: none; }

.netplay-guide-content .step-num {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    font-weight: 700;
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

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

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 768px) {
    .site-header .logo {
        font-size: 2rem;
        letter-spacing: 2px;
    }

    .game-grid {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
        gap: 12px;
    }

    .btn {
        padding: 8px 14px;
        font-size: 0.8rem;
    }

    .share-bar {
        flex-wrap: wrap;
        justify-content: center;
        gap: 8px;
        padding: 10px 16px;
        bottom: 10px;
    }

    .netplay-guide-content {
        margin: 20px;
        padding: 20px;
    }
}

@media (max-width: 480px) {
    .game-grid {
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }

    .card-actions {
        flex-direction: column;
    }

    .card-actions .btn {
        width: 100%;
    }

    .join-form {
        flex-direction: column;
    }
}
