@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;600;700;800&display=swap');

:root {
    /* LIGHT MODE (Default) */
    --bg-base: #f1f5f9;
    --bg-surface: rgba(255, 255, 255, 0.7);
    --bg-surface-hover: rgba(255, 255, 255, 0.95);
    
    --text-primary: #0f172a;
    --text-secondary: #475569;
    
    --accent-emerald: #059669;
    --accent-emerald-glow: rgba(5, 150, 105, 0.2);
    
    --accent-gold: #d97706;
    --accent-gold-glow: rgba(217, 119, 6, 0.2);
    
    --accent-rose: #e11d48;
    
    --border-glass: rgba(0, 0, 0, 0.1);
    --shadow-glass: 0 16px 40px -8px rgba(0, 0, 0, 0.1);
    
    --input-bg: rgba(255, 255, 255, 0.5);
    --btn-bg: rgba(255, 255, 255, 0.8);
    
    --radius-lg: 24px;
    --radius-md: 16px;
    --radius-sm: 10px;
    
    --font-main: 'Outfit', sans-serif;
}

[data-theme="dark"] {
    /* DARK MODE */
    --bg-base: #060814;
    --bg-surface: rgba(18, 22, 45, 0.7);
    --bg-surface-hover: rgba(28, 35, 65, 0.85);
    
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    
    --accent-emerald: #10b981;
    --accent-emerald-glow: rgba(16, 185, 129, 0.3);
    
    --accent-gold: #fbbf24;
    --accent-gold-glow: rgba(251, 191, 36, 0.3);
    
    --accent-rose: #f43f5e;
    
    --border-glass: rgba(255, 255, 255, 0.08);
    --shadow-glass: 0 16px 40px -8px rgba(0, 0, 0, 0.5);
    
    --input-bg: rgba(0, 0, 0, 0.2);
    --btn-bg: rgba(255, 255, 255, 0.05);
}

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

body {
    background-color: var(--bg-base);
    color: var(--text-primary);
    font-family: var(--font-main);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    position: relative;
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* Dynamic background blobs */
body::before, body::after {
    content: '';
    position: fixed;
    border-radius: 50%;
    filter: blur(120px);
    z-index: -1;
    opacity: 0.5;
    transition: background 0.3s ease;
}
body::before {
    top: -10%; right: -5%;
    width: 50vw; height: 50vw;
    background: radial-gradient(circle, var(--accent-emerald-glow), transparent 60%);
}
body::after {
    bottom: -10%; left: -10%;
    width: 60vw; height: 60vw;
    background: radial-gradient(circle, var(--accent-gold-glow), transparent 60%);
}

h1, h2, h3, h4 {
    font-weight: 700;
    letter-spacing: -0.03em;
}

h1 { font-size: 3.5rem; font-weight: 800; }
h2 { font-size: 2rem; }

.glass-panel {
    background: var(--bg-surface);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-glass);
    padding: 2.5rem;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.container {
    max-width: 1280px;
    margin: 0 auto;
    padding: 2rem;
    width: 100%;
}

/* Theme Toggle Button */
.theme-toggle {
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 1.5rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem;
    border-radius: 50%;
    transition: background 0.3s ease;
}
.theme-toggle:hover {
    background: var(--border-glass);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--btn-bg);
    color: var(--text-primary);
    border: 1px solid var(--border-glass);
    padding: 0.875rem 1.75rem;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-family: var(--font-main);
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    text-decoration: none;
    backdrop-filter: blur(10px);
}
.btn:hover {
    background: var(--border-glass);
    transform: translateY(-2px);
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent-emerald), #059669);
    color: #fff;
    border: none;
    box-shadow: 0 4px 15px var(--accent-emerald-glow);
}
.btn-primary:hover {
    background: linear-gradient(135deg, #059669, #047857);
    color: #fff;
    box-shadow: 0 6px 20px var(--accent-emerald-glow);
}

.btn-accent {
    background: linear-gradient(135deg, var(--accent-gold), #d97706);
    color: #fff;
    border: none;
    box-shadow: 0 4px 15px var(--accent-gold-glow);
}
.btn-accent:hover {
    background: linear-gradient(135deg, #d97706, #b45309);
    color: #fff;
    box-shadow: 0 6px 20px var(--accent-gold-glow);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Forms */
.form-group {
    margin-bottom: 1.5rem;
    text-align: left;
}
.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
    font-size: 0.95rem;
    font-weight: 600;
}
.form-group input, .form-group select {
    width: 100%;
    padding: 1rem 1.25rem;
    background: var(--input-bg);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: var(--font-main);
    font-size: 1rem;
    transition: all 0.3s ease;
}
.form-group input:focus, .form-group select:focus {
    outline: none;
    border-color: var(--accent-emerald);
    box-shadow: 0 0 0 3px var(--accent-emerald-glow);
    background: var(--bg-surface);
}

/* Landing Page (Index) */
.landing-hero {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    min-height: 80vh;
    text-align: center;
    padding: 2rem;
}
.landing-title {
    font-size: clamp(3rem, 8vw, 5rem);
    background: linear-gradient(to right, var(--accent-emerald), var(--accent-gold));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 1.5rem;
}
.landing-subtitle {
    font-size: 1.25rem;
    color: var(--text-secondary);
    max-width: 600px;
    margin-bottom: 3rem;
    line-height: 1.6;
}

/* Dashboard */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 3rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border-glass);
}
.header-brand {
    font-size: 1.75rem;
    font-weight: 800;
    color: var(--text-primary);
    text-decoration: none;
}
.header-brand span {
    color: var(--accent-emerald);
}

.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 2rem;
}
@media(min-width: 900px) {
    .dashboard-grid {
        grid-template-columns: 350px 1fr;
    }
}

.profile-card {
    text-align: center;
    padding: 2rem;
}
.profile-avatar {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent-emerald), var(--accent-gold));
    margin: 0 auto 1rem auto;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    font-weight: bold;
    color: #fff;
}
.profile-stats {
    display: flex;
    justify-content: center;
    gap: 2rem;
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-glass);
}
.stat-item h4 { color: var(--text-secondary); font-size: 0.85rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; }
.stat-item p { font-size: 1.5rem; font-weight: 800; color: var(--text-primary); margin-top: 0.25rem; }

.game-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1.5rem;
    margin-top: 1.5rem;
}
.game-card {
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    height: 100%;
}
.game-card:hover {
    background: var(--bg-surface-hover);
    transform: translateY(-5px);
}
.game-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1rem;
}
.game-card-title { font-size: 1.25rem; color: var(--text-primary); }
.game-card-host { font-size: 0.85rem; color: var(--accent-emerald); font-weight: 600; }
.game-card-target {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--accent-gold);
    margin: 1rem 0;
}
.game-card-meta {
    display: flex;
    justify-content: space-between;
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 1.5rem;
}

/* Game Interface */
.game-layout {
    display: grid;
    grid-template-columns: 280px 1fr 320px;
    gap: 1.5rem;
    height: calc(100vh - 120px);
}
@media (max-width: 1024px) {
    .game-layout {
        grid-template-columns: 1fr;
        height: auto;
    }
    .players-sidebar, .logs-sidebar {
        max-height: 300px;
    }
}

.players-sidebar, .logs-sidebar {
    padding: 1.5rem;
    overflow-y: auto;
}

.player-item {
    padding: 1rem;
    border-radius: var(--radius-sm);
    margin-bottom: 0.5rem;
    background: var(--border-glass);
    border: 1px solid transparent;
    transition: all 0.3s ease;
}
.player-item.active-turn {
    background: rgba(16, 185, 129, 0.1);
    border-color: var(--accent-emerald);
}
.player-name {
    font-weight: 700;
    margin-bottom: 0.25rem;
}
.player-credits {
    color: var(--accent-gold);
    font-weight: 600;
    font-size: 1.1rem;
}

.main-board {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    overflow-y: auto;
}

.my-stats {
    padding: 1.5rem;
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.15), rgba(16, 185, 129, 0.05));
    border: 1px solid rgba(16, 185, 129, 0.3);
    border-radius: var(--radius-lg);
    display: flex;
    justify-content: space-around;
    align-items: center;
}
.stat-box { text-align: center; }
.stat-box > div:first-child { color: var(--text-secondary); font-size: 0.9rem; font-weight: 600; text-transform: uppercase; margin-bottom: 0.25rem;}
.stat-val { font-size: 2rem; font-weight: 800; color: var(--text-primary); }
.stat-val.gold { color: var(--accent-gold); }

.market-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 1rem;
}
.investment-card {
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
}
.investment-card h4 {
    font-size: 1.2rem;
    margin-bottom: 0.25rem;
}
.investment-price {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--accent-emerald);
    margin-bottom: 1rem;
}
.investment-probs {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
    flex-grow: 1;
}

.log-item {
    font-size: 0.9rem;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border-glass);
    animation: fadeInRight 0.4s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}
.log-time { color: var(--text-secondary); font-size: 0.75rem; margin-right: 0.5rem; }
.log-user { font-weight: 700; color: var(--text-primary); }

/* Animations */
@keyframes fadeInRight {
    from { opacity: 0; transform: translateX(20px); }
    to { opacity: 1; transform: translateX(0); }
}
@keyframes pulse-glow {
    0% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.4); }
    70% { box-shadow: 0 0 20px 15px rgba(16, 185, 129, 0); }
    100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}
@keyframes coin-fly {
    0% { opacity: 1; transform: translateY(0) scale(1); }
    100% { opacity: 0; transform: translateY(-120px) scale(1.5); }
}
.floating-coin {
    position: absolute;
    font-weight: 800;
    font-size: 1.75rem;
    pointer-events: none;
    animation: coin-fly 1.5s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
    z-index: 1000;
    text-shadow: 0 2px 10px rgba(0,0,0,0.2);
}
[data-theme="dark"] .floating-coin {
    text-shadow: 0 2px 10px rgba(0,0,0,0.8);
}
.pulse { animation: pulse-glow 2s infinite; }

/* Toast Notification */
#toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
}
.toast {
    background: var(--bg-surface);
    border-left: 4px solid var(--accent-emerald);
    padding: 1rem 1.5rem;
    margin-top: 1rem;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-glass);
    animation: fadeInRight 0.3s cubic-bezier(0.4, 0, 0.2, 1) forwards;
    backdrop-filter: blur(10px);
    font-weight: 600;
}
.toast.error {
    border-left-color: var(--accent-rose);
}
