:root {
    --primary-color: #4f46e5;
    --primary-hover: #4338ca;
    --bg-light: #f8fafc;
    --bg-card: rgba(255, 255, 255, 0.7);
    --text-main: #0f172a;
    --text-muted: #64748b;
    --border-color: rgba(0, 0, 0, 0.05);

    --brand-font: 'Outfit', sans-serif;
    --board-size-real: 540px;
}

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

body {
    margin: 0;
    font-family: 'Inter', system-ui, sans-serif;
    background-color: var(--bg-light);
    background-image: 
        radial-gradient(at 0% 0%, hsla(253,16%,10%,1) 0, transparent 50%), 
        radial-gradient(at 50% 0%, hsla(225,39%,30%,1) 0, transparent 50%);
    /* We'll update the colors for a lighter look below */
    background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
    color: var(--text-main);
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
}

body::before, body::after {
    content: '';
    position: fixed;
    width: 600px;
    height: 600px;
    border-radius: 50%;
    z-index: -1;
    filter: blur(100px);
    opacity: 0.15;
}

body::before {
    background: var(--primary-color);
    top: -200px;
    left: -200px;
}

body::after {
    background: #ec4899;
    bottom: -200px;
    right: -200px;
}

.dashboard {
    display: flex;
    flex-direction: column;
    height: 100vh;
    padding: 20px;
    gap: 20px;
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
}

/* Navbar Style */
.navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-icon {
    font-size: 2rem;
}

.logo-text {
    font-family: var(--brand-font);
    font-size: 1.5rem;
    font-weight: 700;
}

.badge {
    font-size: 0.6rem;
    background: var(--primary-color);
    padding: 2px 6px;
    border-radius: 4px;
    vertical-align: middle;
    margin-left: 5px;
    color: white;
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 20px;
}

.conn-status {
    font-size: 0.75rem;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: 20px;
    background: rgba(0, 0, 0, 0.1);
    transition: all 0.3s;
}

.conn-status.connected { color: #22c55e; border: 1px solid rgba(34, 197, 94, 0.2); }
.conn-status.reconnecting { color: #eab308; border: 1px solid rgba(234, 179, 8, 0.2); animation: pulse 1s infinite alternate; }
.conn-status.disconnected { color: #ef4444; border: 1px solid rgba(239, 68, 68, 0.2); }

@keyframes pulse {
    from { opacity: 0.6; }
    to { opacity: 1; }
}

.back-link {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 600;
    padding: 8px 16px;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    transition: all 0.2s;
}

.back-link:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: var(--text-muted);
}

/* Main Layout */
.game-container {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 24px;
    flex: 1;
    min-height: 0;
    align-items: start;
    justify-content: center;
}

/* Panels */
.glass-panel {
    background: var(--bg-card);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.5); /* Changed border for light theme */
    border-radius: 24px; /* Slightly larger border-radius */
    padding: 24px; /* Slightly larger padding */
    box-shadow:
        0 4px 6px -1px rgba(0, 0, 0, 0.05),
        0 10px 15px -3px rgba(0, 0, 0, 0.05); /* Updated box-shadow for light theme */
    min-height: calc(var(--board-size-real) + 30px);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.secondary-panel {
    min-height: auto;
    height: auto;
    margin-top: 15px;
    background: rgba(255, 255, 255, 0.4); 
    padding: 20px;
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.secondary-panel h3 {
    font-size: 0.9rem;
    margin-bottom: 12px;
    color: var(--text-muted);
}

.secondary-btn {
    background: white;
    color: var(--primary-color);
    border: 1px solid var(--primary-color);
}

.secondary-btn:hover {
    background: var(--primary-color);
    color: white;
}

/* Custom scrollbar for panels */
.glass-panel::-webkit-scrollbar { width: 6px; }
.glass-panel::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.1); border-radius: 10px; }

.panel h2 {
    font-family: 'Outfit', sans-serif;
    font-size: 1.25rem;
    margin-bottom: 8px;
}

.subtitle {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 24px;
}

/* Stats Row */
.stats-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 24px;
}

.stat-badge {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-weight: 700;
    font-size: 0.9rem;
}

.xp-badge { color: #bf5af2; border-color: rgba(191, 90, 242, 0.3); }
.coins-badge { color: #ffcc00; border-color: rgba(255, 204, 0, 0.3); }

.stat-icon { font-size: 1.1rem; }

.action-row {
    margin-top: 10px;
}

/* Welcome Back Card */
.welcome-card {
    text-align: center;
    animation: slideDown 0.4s ease-out;
}

.profile-preview {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    margin: 20px 0;
    padding: 20px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 16px;
    border: 1px solid var(--border-color);
}

.profile-preview .avatar {
    font-size: 3rem;
    background: var(--bg-dark);
    width: 80px;
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    border: 2px solid var(--primary-color);
}

.profile-preview .details {
    display: flex;
    flex-direction: column;
}

.profile-preview strong {
    font-size: 1.2rem;
    color: var(--text-main);
}

.profile-preview .username {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.link-btn {
    background: transparent;
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-top: 10px;
    text-decoration: underline;
}

.link-btn:hover {
    color: var(--text-main);
}

/* Form Styling */
.form-group {
    margin-bottom: 16px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

label {
    display: block;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 6px;
    text-transform: uppercase;
}

.form-divider {
    font-size: 0.7rem;
    font-weight: 800;
    text-transform: uppercase;
    color: var(--primary-color);
    margin: 15px 0 12px 0;
    display: flex;
    align-items: center;
    gap: 8px;
    opacity: 0.8;
}

.form-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: linear-gradient(to right, rgba(79, 70, 229, 0.2), transparent);
}

.form-input, .form-select {
    width: 100%;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 10px 12px;
    color: var(--text-main);
    font-family: inherit;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.form-input:focus, .form-select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px var(--primary-glow);
}

.btn {
    cursor: pointer;
    font-family: 'Outfit', sans-serif;
    font-weight: 600;
    border-radius: 12px;
    padding: 12px;
    transition: all 0.2s;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.primary-btn {
    background-color: var(--primary-color);
    color: white;
    border: none;
    padding: 0.8rem 2rem;
    border-radius: 12px;
    font-weight: 600;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
}

.primary-btn:hover {
    background-color: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 10px 20px -5px rgba(99, 102, 241, 0.4);
}

.w-full { width: 100%; }

/* Game Status Panel */
.status-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.game-id {
    font-size: 0.7rem;
    background: rgba(255, 255, 255, 0.1);
    padding: 4px 8px;
    border-radius: 6px;
    color: var(--text-muted);
}

.status-box {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 12px;
    padding: 16px;
    text-align: center;
    font-weight: 600;
    margin-bottom: 20px;
}

.dice-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    margin-bottom: 20px;
}

.dice-container {
    width: 80px;
    height: 80px;
    background: white;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 10px 20px rgba(0,0,0,0.4);
}

#diceValue {
    font-size: 2.5rem;
    font-weight: 800;
    color: #1a1a1a;
}

.roll-btn {
    background: var(--primary-color);
    color: white;
    width: 100%;
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3);
}

.roll-btn:hover:not(:disabled) {
    background: var(--primary-hover);
    transform: translateY(-2px);
}

.roll-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    background: #64748b;
}

.hint {
    text-align: center;
    font-size: 0.8rem;
    color: var(--text-muted);
    font-style: italic;
}

/* Turn Timer Bar */
.turn-timer-container {
    width: 100%;
    margin-top: 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
}

.timer-bar-bg {
    width: 100%;
    height: 6px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 3px;
    overflow: hidden;
}

.timer-bar-fill {
    width: 100%;
    height: 100%;
    background: var(--primary-color);
    border-radius: 3px;
    transition: width 0.1s linear, background-color 0.3s;
}

#turnTimerText {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-muted);
}

/* 🌟 BOARD STYLES MOVED TO shared-board.css 🌟 */

/* Logs */
.logs { min-height: 0; }
.logs .glass-panel {
    height: calc(var(--board-size-real) + 40px);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.log-box {
    flex: 1;
    overflow-y: auto;
    font-family: 'Inter', sans-serif;
    font-size: 0.85rem;
    line-height: 1.6;
    padding: 15px;
    display: block; /* Normal flow */
    gap: 8px;
}

.log-entry {
    padding: 6px 10px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.05);
    border-left: 3px solid transparent;
    margin-bottom: 8px; /* Added spacing for block flow */
}

.log-red { border-left-color: var(--color-red); color: #ef4444; background: rgba(239, 68, 68, 0.05); }
.log-green { border-left-color: var(--color-green); color: #22c55e; background: rgba(34, 197, 94, 0.05); }
.log-blue { border-left-color: var(--color-blue); color: #3b82f6; background: rgba(59, 130, 246, 0.05); }
.log-yellow { border-left-color: var(--color-yellow); color: #eab308; background: rgba(234, 179, 8, 0.05); }
.log-system { color: var(--text-muted); font-style: italic; }

.log-box::-webkit-scrollbar { width: 6px; }
.log-box::-webkit-scrollbar-thumb { background: rgba(0, 0, 0, 0.1); border-radius: 10px; }

.h-full { height: 100%; }

/* Chat Bubble Toast UI */
.player-marker { position: relative; } /* Ensure children can be positioned relative to marker */

.chat-bubble {
    position: absolute;
    bottom: 110%;
    left: 50%;
    transform: translateX(-50%) scale(0.8);
    background: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(10px);
    color: white;
    padding: 8px 14px;
    border-radius: 14px;
    font-size: 0.85rem;
    font-weight: 500;
    min-width: 60px;
    text-align: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    z-index: 1000;
    box-shadow: 0 4px 15px rgba(0,0,0,0.4);
    border: 1px solid rgba(255,255,255,0.15);
    pointer-events: none;
}

.chat-bubble::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border-width: 6px;
    border-style: solid;
    border-color: rgba(0,0,0,0.9) transparent transparent transparent;
}

.chat-bubble.show {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) scale(1) translateY(-5px);
}

.p-name {
    display: block;
}
.orb {
    position: fixed;
    border-radius: 50%;
    filter: blur(100px);
    z-index: -1;
    opacity: 0.1;
}

.orb-1 { width: 400px; height: 400px; background-color: var(--color-blue); top: -100px; left: -100px; }
.orb-2 { width: 500px; height: 500px; background-color: var(--color-red); bottom: -150px; right: -150px; }
.orb-3 {
    width: 300px; height: 300px; background-color: var(--color-green); top: 50%; right: 10%;
    animation: float 10s infinite alternate ease-in-out;
}

@keyframes float {
    from { transform: translateY(0); }
    to { transform: translateY(-40px); }
}

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* --- Lobby Styles --- */
.rooms-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding-top: 10px;
}

.room-card {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.room-card:hover {
    background: rgba(255, 255, 255, 0.08);
    transform: translateY(-2px);
    border-color: var(--primary-color);
}

.room-info {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.room-mode {
    font-size: 0.7rem;
    font-weight: 800;
    text-transform: uppercase;
    background: var(--primary-color);
    padding: 2px 8px;
    border-radius: 4px;
    color: white;
}

.room-format, .room-subtype {
    font-size: 0.7rem;
    font-weight: 600;
    background: rgba(255, 255, 255, 0.1);
    padding: 2px 8px;
    border-radius: 4px;
    color: var(--text-muted);
}

.room-players {
    display: flex;
    gap: 6px;
    align-items: center;
}

.player-slot {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 1.5px dashed rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
}

.player-slot.active {
    border-style: solid;
    border-color: var(--primary-color);
    background: rgba(79, 70, 229, 0.1);
}

.bot-tag {
    font-size: 1.2rem;
    filter: drop-shadow(0 0 5px var(--primary-color));
    animation: pulseBot 2s infinite ease-in-out;
}

@keyframes pulseBot {
    0% { transform: scale(1); opacity: 0.8; }
    50% { transform: scale(1.1); opacity: 1; }
    100% { transform: scale(1); opacity: 0.8; }
}

.join-btn {
    width: 100%;
    padding: 8px;
    font-size: 0.85rem;
    background: var(--primary-color);
    color: white;
}

.no-rooms {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
    font-style: italic;
    font-size: 0.9rem;
}

.loader-tiny {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    display: none;
}

.loader-tiny.loading {
    display: block;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* --- Quick Stats Enhancements --- */
#quickStats {
    background: linear-gradient(135deg, rgba(255,255,255,0.05) 0%, rgba(255,255,255,0.02) 100%) !important;
    backdrop-filter: blur(8px);
    box-shadow: inset 0 0 20px rgba(255,255,255,0.02);
}

#playerScores {
    display: flex !important;
    flex-direction: column;
    gap: 8px;
}

.score-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 10px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.03);
    transition: all 0.3s;
}

.score-row.active {
    background: rgba(79, 70, 229, 0.15);
    border: 1px solid rgba(79, 70, 229, 0.3);
    transform: scale(1.02);
}

/* --- Overlays --- */
.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.8);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(8px);
}

.overlay-content {
    max-width: 450px;
    width: 90%;
    text-align: center;
    padding: 40px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 20px 50px rgba(0,0,0,0.5);
}

.congrats { font-size: 2.5rem; margin-bottom: 10px; font-family: var(--brand-font); }
.rankings-list { text-align: left; margin: 25px 0; background: rgba(0,0,0,0.3); border-radius: 16px; padding: 20px; border: 1px solid rgba(255,255,255,0.05); }

/* --- Scrollbar Refinement --- */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.1); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.2); }
