@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;600;800&display=swap');

:root {
    --bg-dark: #0f172a;
    --card-bg: rgba(30, 41, 59, 0.9);
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --primary: #6366f1;
    --accent: #f43f5e;
    --success: #10b981;
    --glass-border: rgba(255, 255, 255, 0.1);

    /* Tile Colors */
    --tile-red: #ef4444;
    --tile-blue: #3b82f6;
    --tile-yellow: #f59e0b;
    --tile-black: #1e293b;
    --tile-bg: #fffcf2;
    --tile-shadow: 0 4px 6px rgba(0, 0, 0, 0.3), 0 1px 3px rgba(0, 0, 0, 0.2);

    /* Responsive Dimensions - Desktop Default */
    --tile-width: 50px;
    --tile-height: 70px;
    --grid-gap: 8px;
    --font-size-num: 1.8rem;
}

/* Reset & Base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Outfit', sans-serif;
    user-select: none;
    -webkit-user-select: none;
}

body {
    background-color: #0f172a !important;
    color: var(--text-main);
    min-height: 100vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* Mobile Portrait */
@media (max-width: 600px) {
    :root {
        --tile-width: 36px;
        --tile-height: 50px;
        --grid-gap: 4px;
        --font-size-num: 1.3rem;
    }

    .game-title {
        font-size: 1rem;
    }

    .btn {
        padding: 0.5rem 1rem;
        font-size: 0.9rem;
    }
}

/* Landscape Mobile */
@media (max-height: 500px) and (orientation: landscape) {
    :root {
        --tile-width: 40px;
        --tile-height: 54px;
        --grid-gap: 5px;
        --font-size-num: 1.4rem;
    }

    header {
        padding: 0.2rem 1rem;
    }

    .rack {
        height: 100px;
    }
}

/* Layout */
.app-container {
    height: 100vh;
    display: flex;
    flex-direction: column;
    position: relative;
    z-index: 1;
}

.hidden {
    display: none !important;
}

/* Overlays */
.overlay {
    position: fixed;
    inset: 0;
    background: #0f172a;
    z-index: 100;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 2rem;
}

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    z-index: 200;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 2rem;
}

/* Cards */
.lobby-card {
    background: var(--card-bg);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    padding: 2.5rem;
    width: 100%;
    max-width: 400px;
    text-align: center;
    position: relative;
    z-index: 101;
}

.modal-content {
    background: var(--card-bg);
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(16px);
    border-radius: 24px;
    padding: 2rem;
    max-width: 500px;
    max-height: 80vh;
    overflow-y: auto;
    color: var(--text-main);
    position: relative;
    z-index: 201;
}

.modal-content h2 {
    margin-bottom: 1rem;
    color: var(--primary);
}

.modal-content p {
    margin-bottom: 0.8rem;
    line-height: 1.5;
    color: var(--text-muted);
}

.modal-content ul {
    padding-left: 1.5rem;
    margin-bottom: 1rem;
    color: var(--text-muted);
}

.modal-content li {
    margin-bottom: 0.5rem;
}

/* Header */
header {
    padding: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(0, 0, 0, 0.2);
    border-bottom: 1px solid var(--glass-border);
    z-index: 10;
}

.game-title {
    font-size: 1.2rem;
    font-weight: 800;
    background: linear-gradient(to right, #818cf8, #f472b6);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* Game Board */
#board {
    flex: 1;
    background: radial-gradient(circle at center, #1e293b 0%, #0f172a 100%);
    padding: 1rem;
    overflow: auto;
    display: grid;
    grid-template-columns: repeat(20, var(--tile-width));
    grid-template-rows: repeat(20, var(--tile-height));
    gap: var(--grid-gap);
    align-content: start;
}

/* Player Rack */
.rack {
    height: 160px;
    background: rgba(0, 0, 0, 0.4);
    border-top: 1px solid var(--glass-border);
    display: flex;
    flex-direction: column;
    padding: 0.5rem;
    z-index: 20;
}

.rack-scroll {
    overflow-x: auto;
    white-space: nowrap;
    display: flex;
    gap: 8px;
    padding: 10px;
    flex: 1;
}

.rack-controls {
    display: flex;
    justify-content: space-between;
    padding: 0.2rem 1rem;
}

/* Tiles */
.tile {
    width: var(--tile-width);
    height: var(--tile-height);
    background: var(--tile-bg);
    border-radius: 6px;
    box-shadow: var(--tile-shadow);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    cursor: grab;
    transition: transform 0.1s;
    position: relative;
    border-bottom: 3px solid #dcd7c9;
}

.tile-number {
    font-size: var(--font-size-num);
    font-weight: 800;
}

.tile:active {
    cursor: grabbing;
    scale: 1.05;
}

.tile-icon {
    font-size: 0.8rem;
    margin-top: -5px;
}

/* Tile Colors */
.tile-red .tile-number,
.tile-red .tile-icon {
    color: var(--tile-red);
}

.tile-blue .tile-number,
.tile-blue .tile-icon {
    color: var(--tile-blue);
}

.tile-yellow .tile-number,
.tile-yellow .tile-icon {
    color: var(--tile-yellow);
}

.tile-black .tile-number,
.tile-black .tile-icon {
    color: var(--tile-black);
}

.tile-joker .tile-number {
    color: transparent;
    background: linear-gradient(45deg, #ef4444, #3b82f6, #f59e0b, #1e293b);
    -webkit-background-clip: text;
}

.tile-joker::after {
    content: '🤡';
    font-size: 1.5rem;
}

/* Buttons */
.btn {
    padding: 0.8rem 1.5rem;
    border-radius: 12px;
    border: none;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
    z-index: 5;
}

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

.btn-secondary {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border: 1px solid var(--glass-border);
}

.btn-success {
    background: var(--success);
    color: white;
}

.btn:active {
    transform: scale(0.95);
}

/* Share Buttons */
.share-buttons {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 1rem;
}

.btn-icon {
    width: 40px;
    height: 40px;
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 50%;
    font-size: 1.2rem;
    padding: 0;
}

.btn-whatsapp {
    background: #25D366;
    color: white;
}

.btn-telegram {
    background: #0088cc;
    color: white;
}

.btn-copy {
    background: #718096;
    color: white;
}

/* Alerts */
#game-alerts {
    position: fixed;
    top: 15%;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999;
    pointer-events: none;
    width: 80%;
    text-align: center;
}

/* Animations */
@keyframes pop {
    0% {
        transform: scale(0.8);
        opacity: 0;
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}