/* ===== Modern Go Online UI ===== */
@import url('https://fonts.googleapis.com/css2?family=Heebo:wght@300;400;500;700;900&display=swap');

:root {
    --bg-primary: #0a0a1a;
    --bg-secondary: #13132b;
    --bg-card: rgba(255, 255, 255, 0.03);
    --border-color: rgba(255, 255, 255, 0.08);
    --border-hover: rgba(255, 255, 255, 0.15);
    --text-primary: #ffffff;
    --text-secondary: #94a3b8;
    --accent-gold: #f59e0b;
    --accent-amber: #fbbf24;
    --accent-yellow: #facc15;
    --accent-green: #10b981;
    --accent-red: #ef4444;
    --accent-blue: #3b82f6;
    --shadow-lg: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    --shadow-md: 0 10px 15px -3px rgba(0, 0, 0, 0.4);
    --shadow-sm: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
    --radius-xl: 20px;
    --radius-lg: 16px;
    --radius-md: 12px;
    --radius-sm: 8px;
}

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

body {
    font-family: 'Heebo', 'Arial', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    text-align: center;
    min-height: 100vh;
    position: relative;
    overflow-x: hidden;
}

/* ===== Animated Background ===== */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    background: 
        radial-gradient(ellipse at 20% 50%, rgba(245, 158, 11, 0.08) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 20%, rgba(59, 130, 246, 0.06) 0%, transparent 50%),
        radial-gradient(ellipse at 50% 80%, rgba(16, 185, 129, 0.06) 0%, transparent 50%),
        linear-gradient(180deg, var(--bg-primary) 0%, var(--bg-secondary) 100%);
    z-index: -1;
    animation: bgShift 20s ease-in-out infinite;
}

@keyframes bgShift {
    0%, 100% { opacity: 0.8; }
    50% { opacity: 1; }
}

/* ===== Floating Particles ===== */
body::after {
    content: '';
    position: fixed;
    inset: 0;
    background-image: 
        radial-gradient(2px 2px at 20px 30px, rgba(255,255,255,0.3), transparent),
        radial-gradient(2px 2px at 40px 70px, rgba(255,255,255,0.2), transparent),
        radial-gradient(1px 1px at 90px 40px, rgba(255,255,255,0.3), transparent),
        radial-gradient(1px 1px at 130px 80px, rgba(255,255,255,0.2), transparent),
        radial-gradient(2px 2px at 160px 30px, rgba(255,255,255,0.25), transparent);
    background-size: 200px 100px;
    z-index: -1;
    animation: particlesFloat 15s linear infinite;
    opacity: 0.5;
}

@keyframes particlesFloat {
    0% { transform: translateY(0); }
    100% { transform: translateY(-100px); }
}

/* ===== App Container ===== */
.app {
    max-width: 1200px;
    margin: 0 auto;
    padding: 24px 20px;
    animation: fadeInUp 0.6s ease-out;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ===== Screen Transitions ===== */
.screen {
    margin-top: 20px;
    animation: screenFadeIn 0.5s ease-out;
}

@keyframes screenFadeIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* ===== Cards ===== */
.card, .topbar, .gameTopbar, .gameInfo, .modalBox {
    background: rgba(255, 255, 255, 0.03);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    padding: 28px 24px;
    box-shadow: var(--shadow-lg);
    transition: all 0.3s ease;
}

.card:hover {
    border-color: var(--border-hover);
    box-shadow: var(--shadow-lg), 0 0 30px rgba(245, 158, 11, 0.1);
    transform: translateY(-2px);
}

/* ===== Input Fields ===== */
input {
    padding: 14px 18px;
    border-radius: var(--radius-md);
    border: 2px solid var(--border-color);
    margin: 8px;
    font-size: 16px;
    background: rgba(255, 255, 255, 0.05);
    color: white;
    font-family: 'Heebo', sans-serif;
    transition: all 0.3s ease;
    outline: none;
}

input:focus {
    border-color: var(--accent-gold);
    box-shadow: 0 0 20px rgba(245, 158, 11, 0.2);
    background: rgba(255, 255, 255, 0.08);
}

input::placeholder {
    color: rgba(255, 255, 255, 0.4);
}

#inviteInput {
    width: 100%;
    direction: ltr;
    text-align: left;
    font-family: 'Courier New', monospace;
    font-size: 14px;
    background: rgba(0, 0, 0, 0.3);
    border-color: rgba(255, 255, 255, 0.1);
}

/* ===== Buttons ===== */
button {
    padding: 12px 24px;
    margin: 6px;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-weight: 600;
    font-size: 15px;
    font-family: 'Heebo', sans-serif;
    background: linear-gradient(135deg, var(--accent-gold), var(--accent-amber));
    color: #0f172a;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

button::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
    transition: left 0.5s;
}

button:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(245, 158, 11, 0.3);
    filter: brightness(1.1);
}

button:hover::before {
    left: 100%;
}

button:active {
    transform: translateY(0);
    box-shadow: 0 2px 10px rgba(245, 158, 11, 0.2);
}

/* ===== Secondary Buttons ===== */
button.secondary {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border: 1px solid var(--border-color);
}

button.secondary:hover {
    background: rgba(255, 255, 255, 0.15);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
}

/* ===== Top Bars ===== */
.topbar, .gameTopbar {
    display: flex;
    justify-content: center;
    gap: 12px;
    flex-wrap: wrap;
    align-items: center;
    padding: 20px;
    margin-bottom: 24px;
}

.topbar h2, .gameTopbar h2 {
    margin: 0;
    font-size: 24px;
    font-weight: 700;
    background: linear-gradient(135deg, var(--accent-gold), var(--accent-amber));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* ===== Rooms Grid ===== */
.rooms {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 16px;
    margin-top: 20px;
}

.roomCard {
    background: rgba(255, 255, 255, 0.04);
    backdrop-filter: blur(10px);
    padding: 20px;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    transition: all 0.3s ease;
    animation: cardFadeIn 0.5s ease-out backwards;
}

@keyframes cardFadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.roomCard:nth-child(even) {
    animation-delay: 0.1s;
}

.roomCard:hover {
    border-color: var(--accent-gold);
    box-shadow: var(--shadow-md), 0 0 20px rgba(245, 158, 11, 0.15);
    transform: translateY(-4px);
}

.roomCard h3 {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 8px;
    color: var(--accent-amber);
}

.roomCard p {
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.roomCard button {
    width: 100%;
    padding: 10px;
}

/* ===== Game Board ===== */
#board {
    margin-top: 20px;
    background: linear-gradient(145deg, #d4a44c, #c4943c);
    border-radius: var(--radius-lg);
    max-width: 95vw;
    max-height: 70vh;
    box-shadow: 
        var(--shadow-lg),
        inset 0 2px 10px rgba(255,255,255,0.2),
        inset 0 -2px 10px rgba(0,0,0,0.2);
    transition: all 0.3s ease;
    border: 4px solid #8b6914;
}

#board:hover {
    box-shadow: 
        var(--shadow-lg),
        0 0 40px rgba(245, 158, 11, 0.2),
        inset 0 2px 10px rgba(255,255,255,0.2),
        inset 0 -2px 10px rgba(0,0,0,0.2);
}

/* ===== Game Info ===== */
.gameInfo {
    margin-bottom: 20px;
}

#turnText {
    color: var(--accent-yellow);
    font-size: 18px;
    font-weight: 700;
    text-shadow: 0 0 20px rgba(250, 204, 21, 0.3);
}

#scoringText {
    color: var(--accent-green);
    font-weight: 600;
    animation: pulse 2s ease-in-out infinite;
}

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

/* ===== Modal ===== */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(8px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10;
    animation: modalFadeIn 0.3s ease-out;
}

@keyframes modalFadeIn {
    from {
        opacity: 0;
        backdrop-filter: blur(0);
    }
    to {
        opacity: 1;
        backdrop-filter: blur(8px);
    }
}

.modalBox {
    width: min(650px, 92vw);
    background: rgba(19, 19, 43, 0.95);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-lg), 0 0 60px rgba(245, 158, 11, 0.1);
    animation: modalSlideUp 0.4s ease-out;
}

@keyframes modalSlideUp {
    from {
        opacity: 0;
        transform: translateY(30px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.modalBox h2 {
    font-size: 28px;
    font-weight: 900;
    margin-bottom: 16px;
    background: linear-gradient(135deg, var(--accent-gold), var(--accent-amber));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* ===== Toast Notification ===== */
#toast {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(135deg, var(--accent-green), #059669);
    color: white;
    padding: 14px 24px;
    border-radius: var(--radius-md);
    display: none;
    z-index: 20;
    font-weight: 600;
    box-shadow: var(--shadow-lg);
    animation: toastSlideDown 0.3s ease-out;
}

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

/* ===== Game Over Modal ===== */
#gameOverModal .modalBox h3 {
    font-size: 24px;
    color: var(--accent-gold);
    margin-bottom: 20px;
}

#finalScore {
    text-align: right;
    padding: 20px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: var(--radius-md);
    margin: 20px 0;
}

#finalScore p {
    margin: 8px 0;
    font-size: 16px;
}

#finalScore hr {
    border: none;
    border-top: 1px solid var(--border-color);
    margin: 16px 0;
}

/* ===== Login Screen ===== */
#login h1 {
    font-size: 48px;
    font-weight: 900;
    margin-bottom: 30px;
    background: linear-gradient(135deg, #ffffff, var(--accent-amber));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: none;
}

#login input {
    display: block;
    margin: 16px auto;
    width: min(300px, 80%);
}

/* ===== Responsive Design ===== */
@media (max-width: 768px) {
    .app {
        padding: 16px 12px;
    }
    
    .card, .topbar, .gameTopbar, .gameInfo {
        padding: 20px 16px;
    }
    
    #login h1 {
        font-size: 36px;
    }
    
    button {
        padding: 10px 18px;
        font-size: 14px;
    }
    
    .rooms {
        grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
        gap: 12px;
    }
    
    #board {
        max-width: 98vw;
        max-height: 60vh;
    }
}

/* ===== Scrollbar Styling ===== */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* ===== Selection Styling ===== */
::selection {
    background: var(--accent-gold);
    color: #0f172a;
}
html, body {
    width: 100%;
    min-height: 100%;
    overscroll-behavior: none;
}

#board {
    width: min(94vw, 620px);
    height: auto;
    aspect-ratio: 1 / 1;
    touch-action: manipulation;
}

@media (max-width: 600px) {
    .app {
        padding: 8px;
    }

    .screen {
        margin-top: 8px;
    }

    .gameTopbar {
        position: sticky;
        top: 0;
        z-index: 5;
        padding: 8px;
        gap: 6px;
        border-radius: 14px;
    }

    .gameTopbar button {
        flex: 1 1 42%;
        margin: 3px;
        padding: 9px 6px;
        font-size: 13px;
        white-space: nowrap;
    }

    .gameInfo {
        padding: 10px;
        margin-bottom: 8px;
    }

    #roomTitle {
        font-size: 18px;
    }

    #players {
        font-size: 14px;
        line-height: 1.4;
    }

    #turnText {
        font-size: 16px;
        margin-top: 4px;
    }


    .modalBox {
        width: 94vw;
        max-height: 88vh;
        overflow-y: auto;
        padding: 16px 12px;
    }

    .rooms {
        grid-template-columns: 1fr;
    }

    input {
        width: 92%;
        font-size: 16px;
    }
}
#board {
    width: 620px !important;
    height: 620px !important;
    max-width: 95vw !important;
    max-height: 95vw !important;
    aspect-ratio: 1 / 1 !important;
}

@media (max-width: 600px) {
    #board {
        width: 96vw !important;
        height: 96vw !important;
        max-width: 96vw !important;
        max-height: 96vw !important;
    }
}
