:root {
    --bg-color: #121212;
    --text-color: #ffffff;
    --card-bg: #1e1e1e;
    --primary: #00d2ff;
    --secondary: #ff007f;
    --border-radius: 16px;
    --transition: all 0.3s ease;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Outfit', sans-serif;
}

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.container {
    width: 100%;
    max-width: 600px;
    padding: 20px;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

.hub-container {
    max-width: 900px;
}

/* Header */
header {
    text-align: center;
    margin-bottom: 40px;
    margin-top: 20px;
}

h1 {
    font-size: 3rem;
    font-weight: 800;
    background: linear-gradient(45deg, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 5px;
}

header p {
    color: #aaaaaa;
    font-size: 1.1rem;
}

/* Hub Game Selection */
.game-selection {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    column-gap: 30px;
    row-gap: 60px;
}



.game-card {
    text-decoration: none;
    color: var(--text-color);
    text-align: center;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    gap: 10px; /* Tighten space so text sits right below its tile */
}

.card-icon {
    background-color: var(--card-bg);
    border-radius: var(--border-radius);
    width: 100%;
    aspect-ratio: 1;
    box-sizing: border-box;
    display: flex;
    justify-content: center;
    align-items: center;
    border: 2px solid transparent;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.card-icon::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: linear-gradient(45deg, rgba(0, 210, 255, 0.1), rgba(255, 0, 127, 0.1));
    opacity: 0;
    transition: var(--transition);
}

.game-card:hover .card-icon, .game-card:focus .card-icon {
    transform: translateY(-5px);
    border-color: rgba(255, 255, 255, 0.1);
    box-shadow: 0 10px 20px rgba(0,0,0,0.5);
}

.game-card:hover .card-icon::before, .game-card:focus .card-icon::before {
    opacity: 1;
}

.card-icon img {
    height: 75%;
    width: 75%;
    object-fit: contain;
    border-radius: 12px;
    filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.3));
    transition: var(--transition);
}

.game-card:hover .card-icon img {
    transform: scale(1.05); /* subtle pop effect on hover */
}

.game-card h2 {
    font-size: 1.5rem;
    margin: 0;
}

.game-card p {
    color: #bbbbbb;
    margin: 0;
}

/* Common Room UI */
.room-setup {
    background-color: var(--card-bg);
    padding: 20px;
    border-radius: var(--border-radius);
    text-align: center;
    margin-bottom: 20px;
}

.input-group {
    display: flex;
    gap: 10px;
    margin-top: 15px;
    justify-content: center;
}

input[type="text"] {
    padding: 12px 15px;
    border-radius: 8px;
    border: 1px solid #333;
    background-color: #222;
    color: white;
    font-size: 1rem;
    width: 60%;
}

button {
    background: linear-gradient(45deg, var(--primary), var(--secondary));
    border: none;
    padding: 12px 20px;
    border-radius: 8px;
    color: white;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

button:hover {
    opacity: 0.9;
    transform: scale(1.05);
}

.install-pwa-btn {
    background: linear-gradient(45deg, #11998e, #38ef7d);
    padding: 8px 16px;
    font-size: 0.9rem;
    margin-top: 10px;
    box-shadow: 0 4px 15px rgba(17, 153, 142, 0.4);
}

.status {
    margin-top: 15px;
    font-size: 1.2rem;
    font-weight: 600;
    height: 30px;
}

/* Tic Tac Toe Board */
.tictactoe-board {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin: 30px auto;
    max-width: 300px;
}

.cell {
    aspect-ratio: 1;
    background-color: var(--card-bg);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 4rem;
    cursor: pointer;
    transition: var(--transition);
    user-select: none;
}

.cell:hover {
    background-color: #2a2a2a;
}

.cell.x {
    color: var(--primary);
    animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.cell.o {
    color: var(--secondary);
    animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes popIn {
    0% { transform: scale(0.5); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

/* Dots and Boxes Board */
.dab-board {
    margin: 30px auto;
    position: relative;
}

.dab-row {
    display: flex;
    justify-content: center;
}

.dot {
    width: 15px;
    height: 15px;
    background-color: #555;
    border-radius: 50%;
    z-index: 2;
}

.line-h, .line-v {
    background-color: #222;
    cursor: pointer;
    transition: background-color 0.2s ease;
    z-index: 1;
}

.line-h {
    height: 15px;
    width: 60px;
    margin: 0 -5px; /* overlap dots slightly */
}

.line-v {
    width: 15px;
    height: 60px;
    margin: -5px 0; /* overlap dots slightly */
}

.line-h:hover, .line-v:hover {
    background-color: #444;
}

.line-active-p1 {
    background-color: var(--primary) !important;
}

.line-active-p2 {
    background-color: var(--secondary) !important;
}

.box {
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    font-weight: 800;
    transition: background-color 0.3s ease;
}

.box.p1 {
    background-color: rgba(0, 210, 255, 0.2);
    color: var(--primary);
    animation: popIn 0.3s ease;
}

.box.p2 {
    background-color: rgba(255, 0, 127, 0.2);
    color: var(--secondary);
    animation: popIn 0.3s ease;
}

.score-board {
    display: flex;
    justify-content: space-around;
    margin-bottom: 20px;
    font-size: 1.5rem;
}

.score-p1 { color: var(--primary); font-weight: bold; }
.score-p2 { color: var(--secondary); font-weight: bold; }

/* Utilities */
.hidden {
    display: none !important;
}
.back-btn {
    text-decoration: none;
    color: #aaa;
    display: inline-block;
    margin-bottom: 20px;
    font-size: 1.1rem;
}
.back-btn:hover { color: white; }

.tetris-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    flex-grow: 1;
}

.t-cell {
    position: absolute;
    width: 10%;
    height: 5%;
    box-sizing: border-box;
}

@media (max-width: 768px) {
    .game-selection {
        gap: 15px;
        row-gap: 25px;
    }
    .game-card {
        background-color: transparent !important;
        padding: 0 !important;
        border: none !important;
        border-radius: 0 !important;
        overflow: visible !important;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: flex-start;
        z-index: 1;
        box-shadow: none !important;
        min-width: 0;
    }
    .card-icon {
        width: 100%;
        aspect-ratio: 1;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 2.5rem;
        margin-bottom: 0;
    }
    .game-card h2 {
        font-size: 14px;
        margin-bottom: 0;
        line-height: 1.2;
        text-align: center;
        width: 100%;
        min-width: 0;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
        font-weight: 400;
        color: #f1f1f1;
        letter-spacing: 0.2px;
    }
    .game-card p {
        display: none !important;
    }
}

html[lang="ml"] { 
    font-size: 75%; 
    line-height: 1.65; 
}
