:root {
    --primary: #6366f1;
    --secondary: #a855f7;
    --dark: #0f172a;
    --light: #f8fafc;
    --glass: rgba(15, 23, 42, 0.6);
    --glass-border: rgba(255, 255, 255, 0.1);
    --highlight: rgba(255, 255, 0, 0.5);
    --danger: #ef4444;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Cairo', 'Inter', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--dark);
    color: var(--light);
    height: 100vh;
    overflow: hidden;
    /* Prevent scrolling */
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Background Animations */
.background-blobs {
    position: absolute;
    inset: 0;
    z-index: -1;
    overflow: hidden;
}

.blob {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.5;
    animation: float 10s infinite alternate;
}

.blob-1 {
    width: 50vw;
    height: 50vw;
    background: var(--primary);
    top: -10%;
    left: -10%;
}

.blob-2 {
    width: 40vw;
    height: 40vw;
    background: var(--secondary);
    bottom: -10%;
    right: -10%;
    animation-delay: 2s;
}

.blob-3 {
    width: 30vw;
    height: 30vw;
    background: #ec4899;
    bottom: 20%;
    left: 20%;
    animation-delay: 4s;
}

@keyframes float {
    0% {
        transform: translate(0, 0);
    }

    100% {
        transform: translate(30px, 50px);
    }
}

/* App Structure */
.app-wrapper {
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.hidden {
    display: none !important;
}

/* --- HOME SCREEN (Small Card) --- */
#home-screen {
    width: 100%;
    max-width: 440px;
}

.glass-card {
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    padding: 2.5rem;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
    text-align: center;
}

h1 {
    font-size: 2.5rem;
    margin-bottom: 0.2rem;
    font-weight: 800;
}

header p {
    opacity: 0.7;
    margin-bottom: 2.5rem;
}

.menu-actions {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.join-container {
    display: flex;
    gap: 10px;
    margin-top: 0.5rem;
}

/* Buttons & Inputs */
button {
    width: 100%;
    padding: 16px;
    border-radius: 14px;
    border: none;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}

button:hover {
    transform: translateY(-2px);
    opacity: 0.9;
}

button:active {
    transform: scale(0.98);
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    box-shadow: 0 4px 20px rgba(99, 102, 241, 0.4);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--glass-border);
    color: white;
    width: auto;
    padding: 0 24px;
}

.btn-danger {
    background: rgba(239, 68, 68, 0.15);
    color: #fca5a5;
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.btn-danger:hover {
    background: rgba(239, 68, 68, 0.3);
}

input {
    flex: 1;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--glass-border);
    padding: 16px;
    border-radius: 14px;
    color: white;
    font-family: inherit;
    text-align: center;
    font-weight: bold;
    text-transform: uppercase;
}

input:focus {
    outline: none;
    border-color: var(--primary);
    background: rgba(0, 0, 0, 0.5);
}

.divider {
    display: flex;
    align-items: center;
    color: rgba(255, 255, 255, 0.3);
    font-size: 0.8rem;
    margin: 0.5rem 0;
}

.divider::before,
.divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: rgba(255, 255, 255, 0.1);
}

.divider span {
    padding: 0 10px;
}

footer {
    margin-top: 2rem;
    font-size: 0.8rem;
    opacity: 0.5;
}

/* --- GAME SCREEN (Wide Layout) --- */
.game-container {
    width: 100%;
    max-width: 1400px;
    height: 90vh;
    /* Takes up most of screen */
    animation: fadeIn 0.5s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

.game-layout {
    display: flex;
    gap: 30px;
    height: 100%;
    align-items: center;
}

/* 1. The Board (Flexible & Large) */
.board-wrapper {
    flex: 1;
    /* Takes remaining space */
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100%;
}

#myBoard {
    /* Magic to keep it square and big */
    width: 100%;
    max-width: 85vh;
    /* Don't exceed screen height */
    aspect-ratio: 1 / 1;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
    overflow: hidden;
}

/* 2. The Sidebar (Fixed Width) */
.game-sidebar {
    width: 350px;
    height: 100%;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 1rem;

    background: rgba(15, 23, 42, 0.4);
    /* Darker glass */
    backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
}

.sidebar-header h2 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

.code-badge {
    background: var(--primary);
    padding: 5px 10px;
    border-radius: 6px;
    font-family: monospace;
    font-size: 0.9rem;
}

/* Players Box */
.players-box {
    background: rgba(255, 255, 255, 0.03);
    border-radius: 16px;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    position: relative;
}

.player-badge {
    display: flex;
    align-items: center;
    gap: 12px;
    opacity: 0.4;
    transition: all 0.3s;
    padding: 10px;
    border-radius: 12px;
}

.player-badge.active {
    opacity: 1;
    background: rgba(255, 255, 255, 0.1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.2);
}

.avatar.w {
    background: #e2e8f0;
}

.avatar.b {
    background: #334155;
}

.p-info span {
    font-weight: 600;
    font-size: 1.1rem;
}

.vs-divider {
    text-align: center;
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.2);
    font-weight: bold;
}

/* Status Box */
.status-box {
    text-align: center;
    margin: 2rem 0;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

#turn-indicator {
    font-size: 1.8rem;
    font-weight: 800;
    text-transform: uppercase;
    margin-bottom: 0.5rem;
    color: white;
    text-shadow: 0 0 20px rgba(255, 255, 255, 0.2);
}

#game-status-text {
    color: #94a3b8;
    font-size: 1rem;
    line-height: 1.5;
}

/* Responsive: Mobile Stack */
@media (max-width: 900px) {
    body {
        height: auto;
        min-height: 100vh;
        overflow-y: auto;
    }

    .app-wrapper {
        align-items: flex-start;
        padding-top: 40px;
    }

    .game-layout {
        flex-direction: column-reverse;
        gap: 20px;
        height: auto;
    }

    .board-wrapper {
        width: 100%;
        height: auto;
    }

    #myBoard {
        max-width: 100%;
        aspect-ratio: 1/1;
    }

    .game-sidebar {
        width: 100%;
        height: auto;
        padding: 1.5rem;
    }

    .status-box {
        margin: 1rem 0;
    }
}

/* Toast Notification */
.toast {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(74, 222, 128, 0.9);
    /* Green */
    color: #064e3b;
    padding: 12px 24px;
    border-radius: 50px;
    font-weight: bold;
    font-size: 1rem;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(8px);
    z-index: 1000;
    transition: all 0.3s ease;
    opacity: 0;
    pointer-events: none;
}

.toast.show {
    top: 40px;
    /* Slide down effect */
    opacity: 1;
}

/* Add this to your style.css */

.name-input {
    width: 100%;
    margin-bottom: 1rem;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    font-size: 1.1rem;
    padding: 14px;
    border-radius: 12px;
    text-align: center;
    font-weight: bold;
    letter-spacing: 0.5px;
    text-transform: none;
    /* Allow normal casing for names */
}

.name-input::placeholder {
    color: rgba(255, 255, 255, 0.5);
    text-transform: none;
    letter-spacing: 0;
    font-weight: normal;
}

.name-input:focus {
    background: rgba(255, 255, 255, 0.15);
    border-color: var(--primary);
    outline: none;
}
