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

:root {
    --bg-color: #f4f7f6;
    --card-bg: #ffffff;
    --text-main: #2d3748;
    --text-muted: #718096;
    --border-main: #cbd5e0;
    
    --primary: #4299e1;
    --primary-dark: #3182ce;
    --secondary: #ed8936;
    --secondary-dark: #dd6b20;
    
    --p1: #f56565; /* Red */
    --p2: #ecc94b; /* Yellow */
    --p3: #48bb78; /* Green */
    --p4: #9f7aea; /* Purple */
}

body {
    font-family: 'Nunito', sans-serif;
    background-color: var(--bg-color);
    background-image: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23cbd5e0' fill-opacity='0.2'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
    color: var(--text-main);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    margin: 0;
}

h1, h2, h3 {
    font-weight: 900;
    margin-top: 0;
}

h1 {
    text-align: center;
    font-size: 2.2rem;
    margin-bottom: 30px;
    color: var(--text-main);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.container {
    width: 100%;
    max-width: 550px;
    padding: 20px;
    box-sizing: border-box;
}

.card {
    background: var(--card-bg);
    padding: 30px;
    border-radius: 20px;
    border: 4px solid var(--border-main);
    box-shadow: 0 10px 0 var(--border-main);
    box-sizing: border-box;
    margin-bottom: 20px;
}

.form-group {
    margin-bottom: 20px;
}

label {
    display: block;
    font-weight: 700;
    margin-bottom: 8px;
    color: var(--text-muted);
}

input[type="text"], select {
    width: 100%;
    padding: 12px 16px;
    background: #f7fafc;
    border: 3px solid var(--border-main);
    border-radius: 12px;
    font-size: 1rem;
    font-family: 'Nunito', sans-serif;
    font-weight: 700;
    color: var(--text-main);
    outline: none;
    transition: border-color 0.2s;
    box-sizing: border-box;
}

input[type="text"]:focus, select:focus {
    border-color: var(--primary);
}

.btn {
    display: inline-block;
    width: 100%;
    padding: 14px;
    font-size: 1.1rem;
    font-weight: 900;
    color: white;
    background-color: var(--primary);
    border: none;
    border-radius: 12px;
    cursor: pointer;
    box-shadow: 0 6px 0 var(--primary-dark);
    transition: transform 0.1s, box-shadow 0.1s;
    text-transform: uppercase;
}

.btn:active {
    transform: translateY(6px);
    box-shadow: 0 0 0 var(--primary-dark);
}

.btn-secondary {
    background-color: var(--secondary);
    box-shadow: 0 6px 0 var(--secondary-dark);
}
.btn-secondary:active {
    transform: translateY(6px);
    box-shadow: 0 0 0 var(--secondary-dark);
}

.btn-small {
    width: auto;
    padding: 8px 16px;
    font-size: 0.9rem;
    box-shadow: 0 4px 0 var(--primary-dark);
}
.btn-small:active {
    transform: translateY(4px);
    box-shadow: 0 0 0 var(--primary-dark);
}

/* Game Selector */
.game-selector {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin-bottom: 25px;
}

.game-card {
    border: 3px solid var(--border-main);
    background: white;
    border-radius: 15px;
    padding: 15px;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
    box-shadow: 0 4px 0 var(--border-main);
}

.game-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 0 var(--border-main);
}
.game-card:active {
    transform: translateY(4px);
    box-shadow: 0 0 0 var(--border-main);
}

.game-card.selected {
    border-color: var(--primary);
    background: #ebf8ff;
    box-shadow: 0 4px 0 var(--primary);
}
.game-card.selected:active {
    box-shadow: 0 0 0 var(--primary);
}

.game-card h3 {
    margin: 0 0 5px 0;
    font-size: 1.1rem;
    color: var(--text-main);
}

.game-card p {
    margin: 0;
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 700;
}

/* UI Elements */
.status-banner {
    background: var(--text-main);
    color: white;
    font-weight: 900;
    padding: 12px;
    border-radius: 12px;
    margin-bottom: 20px;
    text-align: center;
    font-size: 1.2rem;
    transition: background-color 0.3s;
    text-transform: uppercase;
}

.invite-section {
    background-color: #fffff0;
    padding: 15px;
    border-radius: 12px;
    border: 3px dashed #d69e2e;
    margin-bottom: 20px;
}
.invite-section p {
    margin: 0 0 10px 0;
    font-size: 0.95rem;
    font-weight: 700;
    color: #b7791f;
}

.invite-link-wrapper {
    display: flex;
    gap: 10px;
}

.players-info {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
    margin-bottom: 25px;
}

.player-badge {
    padding: 8px 16px;
    border-radius: 20px;
    font-weight: 900;
    font-size: 0.9rem;
    background: white;
    border: 3px solid var(--border-main);
    box-shadow: 0 3px 0 var(--border-main);
}
.player-badge.p0 { border-color: var(--p1); color: var(--p1); box-shadow: 0 3px 0 var(--p1); }
.player-badge.p1 { border-color: var(--secondary); color: var(--secondary); box-shadow: 0 3px 0 var(--secondary); }
.player-badge.p2 { border-color: var(--p3); color: var(--p3); box-shadow: 0 3px 0 var(--p3); }
.player-badge.p3 { border-color: var(--p4); color: var(--p4); box-shadow: 0 3px 0 var(--p4); }

/* Boards */
.game-board-container {
    display: flex;
    justify-content: center;
}

/* Tic Tac Toe */
.board {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    background: var(--text-main);
    padding: 10px;
    border-radius: 15px;
    width: 100%;
    max-width: 350px;
    aspect-ratio: 1;
}
.cell {
    background: white;
    border-radius: 10px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 4rem;
    font-weight: 900;
    cursor: pointer;
    user-select: none;
    transition: background 0.2s;
}
.cell:hover { background: #f7fafc; }
.cell.x { color: var(--p1); }
.cell.o { color: var(--primary); }

/* Connect 4 */
.c4-board {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 8px;
    background: var(--primary);
    padding: 12px;
    border-radius: 15px;
    width: 100%;
    aspect-ratio: 7/6;
    border: 4px solid var(--primary-dark);
    box-shadow: inset 0 6px 0 rgba(0,0,0,0.1);
}
.c4-cell {
    background: var(--bg-color);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: inset 0 4px 0 rgba(0,0,0,0.1);
}
.c4-cell.p1 { background: var(--p1); box-shadow: inset 0 -4px 0 rgba(0,0,0,0.2); }
.c4-cell.p2 { background: var(--p2); box-shadow: inset 0 -4px 0 rgba(0,0,0,0.2); }

/* Dots & Boxes */
.dab-board {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    grid-template-rows: repeat(7, 1fr);
    gap: 0;
    background: white;
    padding: 20px;
    border-radius: 15px;
    aspect-ratio: 1;
    width: 100%;
    max-width: 400px;
    border: 3px solid var(--border-main);
}
.dab-dot {
    background: var(--text-main);
    border-radius: 50%;
    width: 14px;
    height: 14px;
    justify-self: center;
    align-self: center;
}
.dab-hline {
    background: #edf2f7;
    height: 14px;
    width: 100%;
    align-self: center;
    cursor: pointer;
    border-radius: 7px;
    transition: background 0.2s;
}
.dab-vline {
    background: #edf2f7;
    width: 14px;
    height: 100%;
    justify-self: center;
    cursor: pointer;
    border-radius: 7px;
    transition: background 0.2s;
}
.dab-hline:hover, .dab-vline:hover { background: #e2e8f0; }
.dab-hline.filled, .dab-vline.filled { background: var(--text-main); cursor: default; }

.dab-box {
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 2rem;
    font-weight: 900;
}
.dab-box.p0 { color: var(--p1); }
.dab-box.p1 { color: var(--secondary); }
.dab-box.p2 { color: var(--p3); }
.dab-box.p3 { color: var(--p4); }

/* Snakes and Ladders */
.snl-board {
    display: grid;
    grid-template-columns: repeat(10, 1fr);
    grid-template-rows: repeat(10, 1fr);
    background: var(--text-main);
    gap: 2px;
    width: 100%;
    aspect-ratio: 1;
    border: 4px solid var(--text-main);
    border-radius: 10px;
    overflow: hidden;
}
.snl-cell {
    background: white;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-muted);
    position: relative;
}
.snl-cell.alt { background: #f7fafc; }

.snl-player {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    margin: 1px;
    box-shadow: 0 2px 0 rgba(0,0,0,0.2);
}
.snl-player.p0 { background: var(--p1); }
.snl-player.p1 { background: var(--secondary); }
.snl-player.p2 { background: var(--p3); }
.snl-player.p3 { background: var(--p4); }

.snl-controls {
    margin-top: 20px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    width: 100%;
}
.snl-log {
    background: #f7fafc;
    padding: 12px;
    border-radius: 12px;
    border: 2px solid var(--border-main);
    width: 100%;
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text-main);
    height: 60px;
    overflow-y: auto;
    box-sizing: border-box;
}

/* Toast & Popups */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.toast {
    background-color: var(--text-main);
    border-left: 6px solid var(--p1);
    color: white;
    padding: 15px 20px;
    border-radius: 10px;
    box-shadow: 0 8px 15px rgba(0,0,0,0.2);
    font-size: 1rem;
    font-weight: 700;
    animation: slideInRight 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
    opacity: 0;
    transform: translateX(100%);
}
@keyframes slideInRight { to { transform: translateX(0); opacity: 1; } }
@keyframes fadeOut { to { opacity: 0; } }

.popup-overlay {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(45, 55, 72, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    backdrop-filter: blur(4px);
}
.popup-content {
    animation: popIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    width: 100%;
    max-width: 400px;
    text-align: center;
}
.popup-content h2 { margin-bottom: 25px; }
.popup-buttons { display: flex; flex-direction: column; gap: 15px; }
@keyframes popIn { 0% { transform: scale(0.8); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }
