:root {
    --color-bg: #0A1128; /* Deep Navy Blue */
    --color-bg-light: #162447;
    --color-gold: #D4AF37; /* Juridic Gold */
    --color-gold-hover: #b8962e;
    --color-text: #E0E0E0;
    --color-text-dark: #121212;
    --color-glass: rgba(22, 36, 71, 0.6);
    --color-glass-border: rgba(212, 175, 55, 0.2);
    --color-danger: #e74c3c;
    --color-success: #2ecc71;
    --color-pending: #f39c12;
    
    --font-heading: 'Cinzel', serif;
    --font-body: 'Inter', sans-serif;
}

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

body {
    background: radial-gradient(circle at top right, var(--color-bg-light), var(--color-bg));
    color: var(--color-text);
    font-family: var(--font-body);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow-x: hidden;
}

/* Typography */
h1, h2, h3, .gold {
    font-family: var(--font-heading);
    color: var(--color-gold);
}

h1 { font-size: 3rem; margin-bottom: 0.5rem; text-shadow: 0 4px 10px rgba(0,0,0,0.5); }
h2 { font-size: 2rem; margin-bottom: 1.5rem; }

/* Utilities */
.hidden { display: none !important; }
.text-center { text-align: center; }
.relative { position: relative; }
.border-gold { border: 2px solid var(--color-gold) !important; }

/* Glassmorphism Container */
.glass-container {
    background: var(--color-glass);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--color-glass-border);
    border-radius: 16px;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    padding: 2rem;
}

/* Screens */
.screen {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

#screen-start {
    max-width: 500px;
    text-align: center;
    animation: fadeIn 0.8s ease-in-out;
}

/* Forms and Inputs */
.input-group { margin-bottom: 1.5rem; }

input, select {
    width: 100%;
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--color-glass-border);
    border-radius: 8px;
    color: var(--color-text);
    font-size: 1rem;
    outline: none;
    transition: 0.3s border-color;
}

input:focus, select:focus {
    border-color: var(--color-gold);
    background: rgba(255, 255, 255, 0.1);
}

select option { background: var(--color-bg); }

/* Buttons */
.btn {
    display: inline-block;
    width: 100%;
    padding: 14px;
    font-size: 1.1rem;
    font-family: var(--font-heading);
    font-weight: bold;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.btn-gold {
    background: var(--color-gold);
    color: var(--color-text-dark);
    box-shadow: 0 4px 15px rgba(212, 175, 55, 0.4);
}

.btn-gold:hover {
    background: var(--color-gold-hover);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(212, 175, 55, 0.6);
}

.btn-ghost {
    background: transparent;
    color: var(--color-gold);
    border: 1px solid var(--color-gold);
}

.btn-ghost:hover {
    background: rgba(212, 175, 55, 0.1);
}

/* GAMEPLAY UI */
#screen-game {
    display: flex;
    flex-direction: column;
    gap: 20px;
    height: 95vh;
}

.game-header {
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding: 1rem 2rem;
}

.stat {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.stat .label { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 2px; color: #aaa; }
.stat .value { font-size: 1.5rem; font-weight: bold; font-family: var(--font-heading); }

.game-body {
    display: flex;
    gap: 20px;
    flex: 1;
    min-height: 0;
}

.sidebar-words {
    width: 250px;
    overflow-y: auto;
}

.sidebar-words h3 { font-size: 1.2rem; }
.sidebar-words p { font-size: 0.8rem; color: #aaa; margin-bottom: 1rem; }

#word-list { list-style: none; }
#word-list li {
    padding: 8px 12px;
    margin-bottom: 8px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
    font-weight: 600;
    transition: 0.3s;
}

#word-list li.found {
    text-decoration: line-through;
    color: var(--color-gold);
    background: rgba(212, 175, 55, 0.1);
    border-left: 3px solid var(--color-gold);
}

/* CAÇA PALAVRAS GRID */
.grid-container {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    user-select: none; /* Evita selecionar o texto no html */
}

/* Grade gerada pelo JS. Ajustaremos as colunas via JS dependendo do tamanho da grade */
#word-grid {
    display: grid;
    gap: 2px;
    padding: 6px;
    background: rgba(0,0,0,0.2);
    border-radius: 8px;
    width: 100%; /* Largura total permitida */
    max-width: 500px; /* Limite máximo no PC */
    height: auto;
    margin: 0 auto;
}

.grid-cell {
    width: 100%; /* Preenche todo seu 1fr na grid */
    aspect-ratio: 1 / 1; /* Mantém um quadrado perfeito sempre */
    background: rgba(255,255,255,0.05);
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: clamp(0.6rem, 3.5vw, 1.2rem); /* Escala dinâmica da fonte */
    font-weight: bold;
    color: #fff;
    cursor: pointer;
    border-radius: 4px;
    transition: 0.1s background-color;
}

/* Seleções no Grid */
.grid-cell.selected { background: var(--color-glass-border); color: var(--color-gold); }
.grid-cell.found { background: rgba(212, 175, 55, 0.4); font-weight: bold; }
.grid-cell.pending { background: var(--color-pending); animation: pulse 1s infinite alternate; }
.grid-cell.error-shake { animation: shake 0.4s ease-in-out; background: var(--color-danger); }

/* Modals */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; width: 100vw; height: 100vh;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-content {
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    animation: scaleIn 0.3s ease-out;
}

/* Quiz Specifics */
.options-container { 
     margin: 1.5rem 0; 
     display: flex; 
     flex-direction: column; 
     gap: 10px; 
     max-height: 50vh; 
     overflow-y: auto; 
     padding-right: 5px;
}
.quiz-option {
    padding: 15px;
    background: rgba(255,255,255,0.05);
    border: 1px solid var(--color-glass-border);
    border-radius: 8px;
    cursor: pointer;
    transition: 0.2s;
    font-size: 1rem;
    color: #fff;
    text-align: left;
}

/* Estilo Premium de Scrollbar Global */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: rgba(255, 255, 255, 0.05); border-radius: 4px; }
::-webkit-scrollbar-thumb { background: var(--color-gold); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--color-gold-hover); }

.quiz-option:hover { background: rgba(212, 175, 55, 0.15); border-color: var(--color-gold); }
.quiz-option.correct { background: var(--color-success) !important; border-color: var(--color-success); }
.quiz-option.incorrect { background: var(--color-danger) !important; border-color: var(--color-danger); }

/* Ranking Table */
.table-container { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; margin-top: 1rem; }
th, td { padding: 12px; text-align: left; border-bottom: 1px solid rgba(255,255,255,0.1); }
th { color: var(--color-gold); font-family: var(--font-heading); }
tr:hover { background: rgba(255,255,255,0.05); }

.close-btn {
    position: absolute; top: 15px; right: 20px;
    background: none; border: none; color: #fff; font-size: 1.5rem; cursor: pointer;
}

/* Notificações */
.notification {
    position: fixed; top: 20px; right: 20px;
    background: var(--color-glass); border: 1px solid var(--color-gold);
    padding: 15px 25px; border-radius: 8px; z-index: 2000;
    box-shadow: 0 4px 15px rgba(0,0,0,0.5);
    transition: 0.3s; transform: translateX(120%);
}
.notification.show { transform: translateX(0); }
.notification.error { border-color: var(--color-danger); }
.notification.success { border-color: var(--color-success); border-left: 5px solid var(--color-gold); }


/* Animations */
@keyframes fadeIn { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
@keyframes scaleIn { from { opacity: 0; transform: scale(0.9); } to { opacity: 1; transform: scale(1); } }
@keyframes pulse { from { background: rgba(243, 156, 18, 0.5); } to { background: rgba(243, 156, 18, 0.9); } }
@keyframes shake {
    0% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    50% { transform: translateX(5px); }
    75% { transform: translateX(-5px); }
    100% { transform: translateX(0); }
}

@media (max-width: 768px) {
    .game-body { flex-direction: column; }
    .sidebar-words { width: 100%; height: auto; max-height: 160px; }
    
    /* Remover tamanhos fixos da grid cell pois agora usa aspect-ratio: 1/1 */
    #word-grid { gap: 1px; padding: 4px; }
    
    /* Header ajustes */
    .game-header { padding: 0.5rem 1rem; }
    h1 { font-size: 2rem; }
}

@media (max-width: 480px) {
    /* Tela de celular pequeno/médio (ex: iPhone, Androids menores) */
    #word-grid { gap: 1px; padding: 2px; border-radius: 4px; }
    .stat .value { font-size: 1.1rem; }
    .stat .label { font-size: 0.6rem; }
    
    /* Quiz Ajustes Mobile */
    .quiz-option { padding: 10px; font-size: 0.9rem; }
    .options-container { margin: 1rem 0; gap: 8px; }
    .glass-container { padding: 1rem; }
}

@media (max-width: 360px) {
    /* Telas ultra estreitas - Apenas borda no grid cell se necessário */
    .grid-cell { border-radius: 2px; }
}
