:root {
    --bg-dark: #0f172a;
    --card-bg: #1e293b;
    --card-glass: rgba(30, 41, 59, 0.7); /* Engadido */
    --border-glow: rgba(255, 255, 255, 0.1); /* Engadido */
    --accent-blue: #38bdf8;
    --accent-green: #4ade80;
    --gal-blue: #00f5ff; /* Engadido */
    --gal-purple: #7c3aed; /* Engadido */
    --text-white: #f8fafc;
}

body {
  background: var(--bg-dark);
  color: #e0e8ff;
  font-family: 'Montserrat', sans-serif; /* Podes usar Montserrat tamén */
}

/* Efecto de Estrelas ao fondo */
body::before {
  content: '';
  position: fixed; inset: 0;
  background: 
    radial-gradient(circle at 20% 30%, rgba(0, 245, 255, 0.05) 0%, transparent 50%),
    radial-gradient(circle at 80% 70%, rgba(124, 58, 237, 0.05) 0%, transparent 50%);
  z-index: -1;
}

/* Navbar */
.navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 5%; /* Reducido de 10% a 5% */
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(10px);
    position: sticky;
    top: 0;
    z-index: 100;
    box-sizing: border-box; /* Crucial */
    width: 100%;
}

/* Para evitar que o menú desborde en móbiles */
@media (max-width: 768px) {
    .nav-menu {
        gap: 1rem;
    }
    .nav-menu a span {
        display: none; /* Agochamos o texto e deixamos só a icona se é preciso */
    }
    .hero h1 {
        font-size: 2rem; /* Título máis pequeno en móbil */
    }
}

.logo { font-weight: 900; font-size: 1.8rem; letter-spacing: -1px; }
.logo span { color: var(--accent-green); }

.nav-menu { display: flex; list-style: none; gap: 2rem; }
.nav-menu a { 
    text-decoration: none; 
    color: var(--text-white); 
    display: flex; 
    align-items: center; 
    gap: 8px;
    font-size: 0.9rem;
    transition: 0.3s;
}
.nav-menu a:hover { color: var(--accent-blue); }

/* Hero */
.hero {
    text-align: center;
    padding: 4rem 1rem;
    width: 100%;
    box-sizing: border-box;
    overflow: hidden; /* Evita que sombras do texto desborden */
}

.hero h1 {
    word-wrap: break-word; /* Rompe palabras se son moi longas */
    max-width: 100%;
}
.hero h1 span { color: var(--accent-blue); }

/* Grid de Xogos */
.games-container {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 20px;
    padding: 20px;
    box-sizing: border-box; /* Crucial para evitar o desbordamento */
}

/* Tarxetas de xogos estilo "Galactic" */
.game-card {
background: var(--card-glass);
    border: 1px solid var(--border-glow);
    border-radius: 20px;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px); /* Para Safari no iPhone */
    transition: all 0.4s ease;
    overflow: hidden;
    flex: 1 1 300px;
    max-width: 400px;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    height: auto; /* Deixa que o contido mande */
    min-height: 350px; /* Un mínimo para que todas as tarxetas se vexan iguais */
    opacity: 0; /* Comeza invisible */
    animation: fadeInUp 0.8s ease-out forwards;
}

.game-card:hover {
  transform: translateY(-10px) scale(1.02);
  border-color: var(--gal-blue);
  box-shadow: 0 0 30px rgba(0, 245, 255, 0.2);
}


.card-content { 
    padding: 1.5rem; /* Un pouco menos de padding en móbiles axuda moito */
    flex-grow: 1;    /* Fai que o contido ocupe todo o espazo da tarxeta */
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    box-sizing: border-box;
}
.card-content p {
    flex-grow: 1; /* Isto "empurra" o botón de xogar sempre cara ao fondo da tarxeta */
}
.badge_blue {
    background: var(--accent-blue);
    display: block;
    padding: 4px 12px;
    border-radius: 50px;
    font-size: 0.7rem;
    font-weight: bold;
    text-transform: uppercase;
    margin-bottom: 1rem;
    width: fit-content;
}
.badge_green {
    background: var(--accent-green);
    display: block;
    padding: 4px 12px;
    border-radius: 50px;
    font-size: 0.7rem;
    font-weight: bold;
    text-transform: uppercase;
    margin-bottom: 1rem;
    width: fit-content;
}


.btn-play {
    display: inline-block;
    margin-top: 1rem;
    padding: 0.8rem 2rem;
    color: black;
    text-decoration: none;
    border-radius: 12px;
    transition: 0.3s;
    background: linear-gradient(135deg, var(--gal-purple), var(--gal-blue));
    border: none;
    box-shadow: 0 0 15px rgba(124, 58, 237, 0.4);
    color: white;
    text-transform: uppercase;
    font-weight: 700;
    letter-spacing: 1px;
}
*
.btn-play:hover { background: var(--accent-blue); color: white; }
 


.home-ranking {
    padding: 4rem 10%;
    max-width: 1200px;
    margin: 0 auto;
}

.section-title { text-align: center; margin-bottom: 2rem; }
.section-title h2 span { color: var(--accent-green); }

.ranking-card-main {
    background: var(--card-bg);
    border: 1px solid rgba(255,255,255,0.05);
    border-radius: 24px;
    padding: 1.5rem;
    box-shadow: 0 20px 40px rgba(0,0,0,0.4);
}

.home-table {
    width: 100%;
    border-collapse: collapse;
    color: white;
}

.home-table th {
    text-align: left;
    padding: 1rem;
    color: #94a3b8;
    font-size: 0.8rem;
    text-transform: uppercase;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.home-table td { padding: 1.2rem 1rem; }

/* Efecto Hover e Filas */
.home-table tr { transition: 0.3s; border-radius: 12px; }
.home-table tbody tr:hover { background: rgba(255,255,255,0.03); }

.pos-num { font-weight: 900; color: #475569; }
.player { font-weight: 600; }
.pts { font-family: 'monospace'; color: var(--accent-blue); font-weight: bold; }

/* Estilos das Medallas (Bbadges) */
.m-badge {
    padding: 4px 12px;
    border-radius: 50px;
    font-size: 0.75rem;
    font-weight: bold;
    border: 1px solid transparent;
}

.m-gold { background: rgba(251, 191, 36, 0.1); color: #fbbf24; border-color: #fbbf24; }
.m-silver { background: rgba(203, 213, 225, 0.1); color: #cbd5e1; border-color: #94a3b8; }
.m-bronze { background: rgba(217, 119, 6, 0.1); color: #d97706; border-color: #a16207; }
.m-iron { background: rgba(71, 85, 105, 0.1); color: #94a3b8; border-color: #475569; }

/* Resaltar usuario */
.current-user-row { background: rgba(56, 189, 248, 0.08) !important; border: 1px dashed var(--accent-blue); }

.table-footer { text-align: center; margin-top: 1.5rem; }
.btn-link { color: var(--accent-blue); text-decoration: none; font-weight: bold; font-size: 0.9rem; }
.btn-link:hover { text-decoration: underline; }

.logo img {
    width: 100%;
    max-width: 400px; /* Reducimos un pouco para que respire máis */
    height: auto;
    display: block;
}

@media (max-width: 600px) {
    .logo img {
        max-width: 250px; /* Máis axeitado para móbiles */
    }
}

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

/* A primeira tarxeta sae case de inmediato */
.game-card:nth-child(1) { animation-delay: 0.2s; }

/* A segunda un pouco despois */
.game-card:nth-child(2) { animation-delay: 0.4s; }

/* A terceira un pouco máis tarde */
.game-card:nth-child(3) { animation-delay: 0.6s; }

/* Estilos para a modal no Portal Principal */
.modal {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
}

.modal-content {
    background: white;
    padding: 30px;
    border-radius: 20px;
    width: 90%;
    max-width: 500px;
    position: relative;
    box-shadow: 0 10px 25px rgba(0,0,0,0.5);
}

.btn-play {
    transition: transform 0.2s;
}

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

#toast-container {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    background-color: #333;
    color: white;
    padding: 12px 25px;
    border-radius: 30px;
    z-index: 3000;
    font-family: 'Montserrat', sans-serif;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
    transition: opacity 0.5s, bottom 0.5s;
    pointer-events: none;
    opacity: 0;
}

#toast-container.show {
    opacity: 1;
    bottom: 50px;
}

.toast-success { background-color: #2ecc71 !important; }
.toast-error { background-color: #e74c3c !important; }