:root {
    /* Paleta Dark Nature "Premium" */
    --bg-gradient: linear-gradient(135deg, #0d1b14 0%, #173627 50%, #0c1821 100%);
    --glass-bg: rgba(20, 35, 25, 0.55);
    --glass-border: rgba(255, 255, 255, 0.08);
    --text-main: #f0f4f2;
    --text-muted: #95a5a6;
    --accent: #27ae60; 
    --accent-hover: #2ecc71;
    --card-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
    --radius-lg: 24px;
    --radius-md: 16px;
    --error: #e74c3c;
    --success: #2ecc71;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
}

body {
    background: var(--bg-gradient);
    color: var(--text-main);
    min-height: 100vh;
    overflow-x: hidden;
}

/* Background fixo escuro com textura sutil */
.app-background {
    position: fixed;
    top: 0; left: 0; width: 100vw; height: 100vh;
    background: radial-gradient(circle at top right, rgba(39, 174, 96, 0.1), transparent 40%),
                radial-gradient(circle at bottom left, rgba(41, 128, 185, 0.1), transparent 40%),
                var(--bg-gradient);
    z-index: -1;
}

.app-layout {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    max-width: 800px;
    margin: 0 auto;
    background: transparent;
}

/* Glassmorphism Dark Mode */
.glass-effect {
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    box-shadow: var(--card-shadow);
}

.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--card-shadow);
    margin-bottom: 20px;
    transition: transform 0.2s ease;
}

/* Sistema de Tooltips (Informativos ao passar o mouse) */
.has-tooltip {
    position: relative;
    cursor: help;
}

.has-tooltip::after {
    content: attr(data-tooltip);
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(10px);
    background: rgba(10, 15, 12, 0.95);
    color: #fff;
    padding: 8px 14px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
    z-index: 1000;
    border: 1px solid rgba(255,255,255,0.1);
    box-shadow: 0 4px 15px rgba(0,0,0,0.5);
    pointer-events: none;
}

.has-tooltip:hover::after {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(5px);
}

/* Ajuste do Tooltip para o menu inferior (balão sobe ao invés de descer) */
.ios-bottom-nav .has-tooltip::after {
    top: auto;
    bottom: 100%;
    transform: translateX(-50%) translateY(-10px);
}
.ios-bottom-nav .has-tooltip:hover::after {
    transform: translateX(-50%) translateY(-5px);
}

/* Header */
.ios-header {
    position: sticky;
    top: 0;
    z-index: 100;
    padding: 15px 20px 10px;
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
    border-top: none;
    margin-bottom: 20px;
}

.header-top-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    font-size: 14px;
    font-weight: 600;
}

.time-weather {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--text-muted);
}

.sim-icon {
    font-size: 16px;
    transition: all 0.4s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.app-title {
    font-size: 18px;
    font-weight: 800;
    letter-spacing: -0.5px;
    color: var(--text-main);
}

.header-pop {
    background: rgba(0, 0, 0, 0.4);
    padding: 6px 12px;
    border-radius: 20px;
    border: 1px solid var(--glass-border);
}

.resource-bar {
    display: flex;
    justify-content: space-between;
    background: rgba(0, 0, 0, 0.3);
    padding: 12px 15px;
    border-radius: var(--radius-md);
    border: 1px solid var(--glass-border);
}

.res-item {
    font-size: 14px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}
.res-item i { color: var(--accent); } /* Ícones dos recursos verdes */

/* Área Principal */
.main-content {
    flex-grow: 1;
    padding: 0 15px 100px;
}

.page-title {
    font-size: 28px;
    font-weight: 700;
    letter-spacing: -1px;
    margin-bottom: 24px;
    padding-left: 5px;
}

/* Grid de Cards */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 16px;
}

.stat-card h3 {
    font-size: 12px;
    text-transform: uppercase;
    color: var(--text-muted);
    letter-spacing: 1px;
    margin-bottom: 8px;
}

.stat-value {
    font-size: 36px;
    font-weight: 700;
    letter-spacing: -1px;
    margin-bottom: 4px;
}

.stat-desc {
    font-size: 13px;
    color: var(--text-muted);
}

/* Tabelas e Formulários Dark */
.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th, .data-table td {
    padding: 14px 10px;
    text-align: left;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}

.data-table th {
    color: var(--text-muted);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.simple-select {
    padding: 8px 12px;
    border-radius: 10px;
    border: 1px solid var(--glass-border);
    background: rgba(0, 0, 0, 0.4);
    color: var(--text-main);
    font-size: 14px;
    outline: none;
}
.simple-select option { background: #1a2520; color: #fff; }

/* Botões */
.btn {
    width: 100%;
    padding: 14px;
    border: none;
    border-radius: var(--radius-md);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn.primary {
    background-color: var(--accent);
    color: white;
    box-shadow: 0 4px 15px rgba(39, 174, 96, 0.3);
}

.btn.primary:hover {
    background-color: var(--accent-hover);
    transform: translateY(-2px);
}

/* Bottom Nav Bar */
.ios-bottom-nav {
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 800px;
    display: flex;
    justify-content: space-around;
    padding: 12px 10px 25px; 
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    z-index: 1000;
    border-top: 1px solid var(--glass-border);
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-decoration: none;
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 500;
    gap: 6px;
    transition: color 0.2s;
}

.nav-item i {
    font-size: 20px;
}

.nav-item:hover, .nav-item:active { color: var(--accent); }
.nav-item.logout:hover { color: var(--error); }

@media (min-width: 801px) {
    .app-layout { padding-top: 40px; }
    .ios-header { border-radius: var(--radius-lg); border: 1px solid var(--glass-border); }
    .ios-bottom-nav {
        bottom: 20px;
        width: calc(100% - 40px);
        border-radius: var(--radius-lg);
        border: 1px solid var(--glass-border);
        padding-bottom: 12px;
    }
}

/* --- ADIÇÕES PARA O HEADER E TICKER --- */

.time-weather {
    display: flex;
    align-items: center;
    gap: 14px;
    color: var(--text-muted);
}

.sim-group {
    display: flex;
    align-items: center;
    gap: 4px;
}

.sim-text {
    font-size: 12px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.user-profile {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(255, 255, 255, 0.05);
    padding: 4px 10px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

/* O novo painel de mensagens abaixo dos recursos */
.lore-ticker {
    margin-top: 10px;
    background: rgba(0, 0, 0, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.03);
    border-radius: 8px;
    padding: 6px 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    overflow: hidden;
}

#lore-message {
    font-size: 12px;
    font-style: italic;
    color: #aebfb5; /* Um verde bem suave e desbotado */
    font-weight: 400;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: opacity 0.5s ease-in-out;
}

/* --- AJUSTES DE RESPONSIVIDADE PARA CELULAR --- */
@media (max-width: 650px) {
    /* 1. Reorganiza a parte superior do header */
    .header-top-info {
        flex-wrap: wrap;
        gap: 12px;
        justify-content: center;
    }
    
    /* 2. Oculta os textos do clima no celular para ganhar espaço */
    .sim-text {
        display: none;
    }

    /* 3. Ajusta o tamanho da fonte do perfil e espaçamentos */
    .user-profile {
        font-size: 12px;
        padding: 4px 8px;
    }
    
    .time-weather {
        gap: 10px;
        width: 100%;
        justify-content: center;
        border-bottom: 1px solid rgba(255, 255, 255, 0.05);
        padding-bottom: 8px;
        margin-bottom: 4px;
    }

    /* 4. Transforma os recursos em um Grid 2x2 elegante */
    .resource-bar {
        flex-wrap: wrap;
        justify-content: center;
        gap: 8px;
        padding: 8px;
    }
    
    .res-item {
        flex: 1 1 45%; /* Força a ocupar quase metade da tela */
        justify-content: center;
        background: rgba(255, 255, 255, 0.05);
        padding: 6px 0;
        border-radius: 8px;
        font-size: 13px;
    }

    /* 5. Ajusta o texto do ticker de eventos */
    #lore-message {
        font-size: 11px;
    }
}

/* Ajustes para telas extra pequenas (iPhone SE, etc) */
@media (max-width: 380px) {
    .res-item {
        font-size: 12px;
    }
    .user-profile {
        font-size: 11px;
    }
}

/* --- RANKING E PÓDIO --- */
.podium-container {
    display: flex;
    justify-content: center;
    align-items: flex-end;
    gap: 15px;
    padding-top: 40px;
    margin-bottom: 30px;
    min-height: 250px;
}

.podium-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 30%;
    max-width: 150px;
    position: relative;
}

.podium-avatar {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 24px;
    margin-bottom: 10px;
    background: rgba(255,255,255,0.1);
    border: 2px solid;
}

.podium-name {
    font-size: 14px;
    font-weight: 700;
    text-align: center;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    width: 100%;
}

.podium-pop {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 15px;
}

.podium-bar {
    width: 100%;
    border-radius: 12px 12px 0 0;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding-top: 15px;
    box-shadow: inset 0 5px 15px rgba(255,255,255,0.2);
}

.podium-rank {
    font-size: 24px;
    font-weight: 800;
    color: rgba(0,0,0,0.5);
    text-shadow: 0 1px 0 rgba(255,255,255,0.3);
}

/* Alturas do Pódio */
.step-1 .podium-bar { height: 140px; }
.step-2 .podium-bar { height: 100px; }
.step-3 .podium-bar { height: 70px; }

/* Cores das Medalhas */
.gold { border-color: #ffd700; color: #ffd700; }
.gold-text { color: #ffd700; }
.gold-bg { background: linear-gradient(135deg, #f1c40f 0%, #d4af37 100%); }

.silver { border-color: #c0c0c0; color: #c0c0c0; }
.silver-bg { background: linear-gradient(135deg, #e0e0e0 0%, #a9a9a9 100%); }

.bronze { border-color: #cd7f32; color: #cd7f32; }
.bronze-bg { background: linear-gradient(135deg, #d2b48c 0%, #b87333 100%); }

.crown-icon {
    position: absolute;
    top: -30px;
    font-size: 28px;
    filter: drop-shadow(0 2px 5px rgba(241, 196, 15, 0.5));
}

.podium-empty {
    color: var(--text-muted);
    font-size: 12px;
    font-style: italic;
    margin-bottom: 20px;
}

/* Ajuste mobile para o pódio */
@media (max-width: 500px) {
    .podium-container { gap: 5px; }
    .podium-name { font-size: 12px; }
    .step-1 .podium-name { font-size: 14px !important; }
    .podium-avatar { width: 40px; height: 40px; font-size: 18px; }
    .podium-rank { font-size: 18px; }
}

#lore-message {
    transition: opacity 0.5s ease;
}

/* =========================
   STORAGE UI
========================= */

.storage-info {
    margin-bottom: 18px;
}

.storage-label {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 12px;
}

.resource-storage {
    margin-bottom: 14px;
}

.storage-resource-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
    margin-bottom: 6px;
    font-weight: 600;
}

.storage-bar {
    width: 100%;
    height: 10px;
    background: rgba(255,255,255,0.08);
    border-radius: 999px;
    overflow: hidden;
    border: 1px solid rgba(255,255,255,0.05);
}

.storage-fill {
    height: 100%;
    border-radius: 999px;
    transition: width 0.4s ease;
}

/* Madeira */
.storage-fill.wood {
    background: linear-gradient(
        90deg,
        #8e5a2b,
        #c68642
    );
}

/* Pedra */
.storage-fill.stone {
    background: linear-gradient(
        90deg,
        #7f8c8d,
        #bdc3c7
    );
}

/* Comida */
.storage-fill.food {
    background: linear-gradient(
        90deg,
        #27ae60,
        #f1c40f
    );
}

/* =========================
RANKINGS
========================= */

.ranking-grid {

    display: grid;

    grid-template-columns:
        repeat(auto-fit, minmax(340px, 1fr));

    gap: 25px;

    margin-top: 30px;
}

.ranking-panel {

    padding: 24px;
}

.ranking-title {

    display: flex;

    align-items: center;

    gap: 10px;

    margin-bottom: 20px;

    font-size: 20px;

    color: var(--accent);
}

.ranking-list {

    display: flex;

    flex-direction: column;

    gap: 12px;
}

.ranking-item {

    display: flex;

    justify-content: space-between;

    align-items: center;

    padding: 14px;

    border-radius: 14px;

    background:
        rgba(255,255,255,0.05);

    transition: 0.2s;
}

.ranking-item:hover {

    transform: translateY(-2px);

    background:
        rgba(255,255,255,0.08);
}

.ranking-left {

    display: flex;

    align-items: center;

    gap: 14px;
}

.ranking-position {

    font-size: 18px;

    font-weight: bold;

    width: 42px;
}

.ranking-name {

    font-weight: 600;
}

.ranking-value {

    font-weight: bold;

    color: var(--accent);
}

/* =========================
TOP 3
========================= */

.top3-wrapper {

    display: grid;

    grid-template-columns: repeat(3, 1fr);

    gap: 12px;

    margin-bottom: 20px;
}

.top3-card {

    background:
        rgba(255,255,255,0.06);

    border-radius: 16px;

    padding: 14px;

    text-align: center;
}

.top3-medal {

    font-size: 32px;

    margin-bottom: 8px;
}

.top3-name {

    font-weight: bold;

    margin-bottom: 6px;
}

.top3-value {

    color: var(--accent);

    font-weight: bold;
}

/* =========================
MINHA POSIÇÃO
========================= */

.my-rank-box {

    margin-top: 20px;

    padding: 12px;

    border-radius: 12px;

    background:
        rgba(255,255,255,0.05);

    text-align: center;

    font-size: 14px;
}

/* =========================
PROGRESSO DO TEMPO
========================= */

.year-progress-wrapper {

    width: 100%;

    margin-top: 14px;

    margin-bottom: 14px;
}

.year-progress-inline {

    display: flex;

    align-items: center;

    gap: 10px;

    width: 100%;
}

.year-progress-bar {

    flex: 1;

    height: 8px;

    background:
        rgba(255,255,255,0.08);

    border-radius: 999px;

    overflow: hidden;

    position: relative;
}

.year-progress-fill {

    height: 100%;

    border-radius: 999px;

    background:
        linear-gradient(
            90deg,
            #f1c40f,
            #ffd54a
        );

    box-shadow:
        0 0 10px rgba(255,212,74,0.4);

    transition: width 1s linear;
}

.year-day {

    font-size: 11px;

    color: rgba(255,255,255,0.8);

    white-space: nowrap;

    flex-shrink: 0;
}

/* =========================
POPUP OFFLINE
========================= */

.offline-popup-overlay {

    position: fixed;

    inset: 0;

    background:
        rgba(0,0,0,0.7);

    display: flex;

    align-items: center;

    justify-content: center;

    z-index: 99999;

    backdrop-filter: blur(6px);
}

.offline-popup {

    width: 90%;

    max-width: 520px;

    padding: 28px;
}

.offline-popup h2 {

    margin-top: 0;

    margin-bottom: 20px;

    font-size: 22px;
}

.offline-popup pre {

    white-space: pre-wrap;

    font-family: inherit;

    line-height: 1.8;

    color: var(--text-muted);

    margin-bottom: 24px;
}