:root {

    --background: #010812;

    --panel: #03111f;
    --panel-dark: #020c16;

    --blue: #078cff;
    --blue-light: #2aaaff;
    --cyan: #2ecbff;

    --green: #27d62d;
    --red: #ef4148;

    --text: #f3f8ff;
    --muted: #8fa9c2;

    --line: rgba(34, 151, 255, 0.25);
    --line-soft: rgba(111, 177, 232, 0.10);

    --radius: 7px;
}


* {

    box-sizing: border-box;

    margin: 0;
    padding: 0;
}


html,
body {

    width: 100%;

    min-height: 100%;
}


body {

    overflow-x: hidden;
    overflow-y: auto;

    color: var(--text);

    font-family:
        Inter,
        system-ui,
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        sans-serif;

    background: var(--background);
}


button,
input,
select {

    font: inherit;
}


button {

    color: inherit;

    cursor: pointer;
}


.hidden {

    display: none !important;
}


/* =========================================================
   LAYOUT
========================================================= */

.app-shell {

    display: grid;

    grid-template-columns:
        250px
        minmax(520px, 1fr)
        260px;

    align-items: start;

    gap: 8px;

    width: 100%;

    min-height: 100vh;

    padding: 8px;
}


.sidebar {

    display: flex;

    flex-direction: column;

    gap: 8px;
}


.left-sidebar {

    overflow: visible;
}


.world-column {

    position: sticky;

    top: 8px;

    min-width: 0;

    height:
        calc(100vh - 16px);
}


.right-sidebar {
   overflow: visible;
}


/* =========================================================
   LOGO
========================================================= */

.brand {
    height: 70px;
    display: flex;
    align-items: center;

    /* centra melhor logo + nome na coluna esquerda */
    justify-content: center;

    gap: 12px;
    padding: 0 12px;
}

.brand-logo {
    width: 58px;
    height: 58px;

    object-fit: contain;
    flex-shrink: 0;
}

.brand-title {
    display: flex;
    align-items: center;

    font-size: 29px;
    font-weight: 800;
    line-height: 1;

    letter-spacing: -1.2px;
    white-space: nowrap;
}

/* Blu azul */
.brand-blu {
    color: #20aaff;
}

/* Orbis branco */
.brand-orbis {
    color: #f5f9ff;
}


/* =========================================================
   PAINÉIS
========================================================= */

.panel {

    width: 100%;

    border:
        1px solid var(--line);

    border-radius: var(--radius);

    overflow: hidden;

    background:
        linear-gradient(
            180deg,
            #031321,
            #020d18
        );
}


.panel h2 {

    padding:
        11px 13px;

    border-bottom:
        1px solid var(--line-soft);

    color: var(--blue-light);

    font-size: 0.75rem;

    letter-spacing: 0.02em;
}


.left-sidebar .panel {

    padding-bottom: 11px;
}


.left-sidebar .panel h2 {

    margin-bottom: 9px;
}


.panel label {

    display: block;

    margin:
        0 13px 5px;

    color: #9eb6cd;

    font-size: 0.68rem;
}


/* =========================================================
   INPUT
========================================================= */

input,
select {

    border:
        1px solid var(--line);

    border-radius: 6px;

    outline: none;

    color: #e4f1ff;

    background: #020d18;
}


input:focus,
select:focus {

    border-color: var(--blue);
}


.left-sidebar > .panel > input,
.left-sidebar > .panel > select {

    width:
        calc(100% - 26px);

    height: 37px;

    margin:
        0 13px 11px;

    padding:
        0 10px;
}


/* =========================================================
   BOTÕES
========================================================= */

.button {

    min-height: 36px;

    padding:
        7px 10px;

    border:
        1px solid var(--line);

    border-radius: 6px;

    color: #edf7ff;

    background:
        linear-gradient(
            #061b2e,
            #03111f
        );
}


.button:hover {

    border-color: var(--blue);
}


.button-primary {

    border-color: #078cff;

    background:
        linear-gradient(
            #0d8cf0,
            #0757a6
        );
}


.button-danger {

    color: #ff5661;

    border-color:
        rgba(239, 65, 72, 0.55);
}


.two-buttons {

    display: grid;

    grid-template-columns:
        1fr 0.8fr;

    gap: 7px;

    padding:
        0 13px;
}


/* =========================================================
   CONTROLOS
========================================================= */

.control-grid {

    display: grid;

    grid-template-columns:
        1fr 1fr;

    gap: 7px;

    padding:
        0 13px;
}


/* =========================================================
   DIMENSÕES
========================================================= */

.dimension-row {

    display: grid;

    grid-template-columns:
        1fr auto 1fr;

    align-items: center;

    gap: 6px;

    margin:
        0 13px 11px;
}


.dimension-row input {

    width: 100%;

    min-width: 0;

    height: 37px;

    padding:
        0 9px;
}


.dimension-row span {

    color: var(--muted);
}


/* =========================================================
   RANGE
========================================================= */

.range-row {

    display: grid;

    grid-template-columns:
        1fr auto;

    align-items: center;

    gap: 8px;

    padding:
        0 13px;
}


.range-row input {

    width: 100%;

    accent-color: var(--blue);
}


.range-row strong {

    color: #a9bfd2;

    font-size: 0.68rem;
}


/* =========================================================
   ESPÉCIES

   Cresce livremente.
========================================================= */

.species-panel {

    display: block;

    height: auto;

    max-height: none;

    overflow: visible;
}


.species-add {

    display: block;

    width:
        calc(100% - 26px);

    margin:
        0 13px 7px;
}


#speciesList {

    height: auto;

    max-height: none;

    overflow: visible;
}


.species-item {

    display: grid;

    grid-template-columns:
        auto
        minmax(0, 1fr)
        auto
        auto;

    align-items: center;

    min-height: 38px;

    gap: 8px;

    padding:
        0 13px;

    border-top:
        1px solid var(--line-soft);

    cursor: pointer;
}


.species-item:hover {

    background:
        rgba(7, 140, 255, 0.05);
}


.species-dot {

    width: 10px;
    height: 10px;

    border-radius: 50%;

    background: currentColor;

    box-shadow:
        0 0 7px currentColor;
}


.species-name {

    min-width: 0;

    overflow: hidden;

    color: #bdd1e2;

    font-size: 0.72rem;

    text-overflow: ellipsis;

    white-space: nowrap;
}


.species-count {

    color: #88a4ba;

    font-size: 0.69rem;
}


.species-more {

    display: flex;

    width: 28px;
    height: 28px;

    padding: 0;

    align-items: center;
    justify-content: center;

    border:
        1px solid var(--line);

    border-radius: 5px;

    color: #a5bed2;

    background: #031421;
}


/* =========================================================
   MUNDO
========================================================= */

.world-panel {

    display: flex;

    width: 100%;
    height: 100%;

    flex-direction: column;

    border:
        1px solid rgba(33, 147, 245, 0.4);

    border-radius: 5px;

    overflow: hidden;

    background: #010813;
}


.world-header {

    display: flex;

    flex:
        0 0 50px;

    align-items: center;

    justify-content: space-between;

    padding:
        0 14px;

    border-bottom:
        1px solid rgba(7, 140, 255, 0.6);

    background: #031120;
}


.world-header h1 {

    color: var(--blue-light);

    font-size: 0.9rem;
}


.world-tools {

    display: flex;

    gap: 7px;
}


.world-tools button {

    display: flex;

    width: 34px;
    height: 34px;

    align-items: center;
    justify-content: center;

    border:
        1px solid var(--line);

    border-radius: 6px;

    color: #9bbbd4;

    background: #031221;
}


.world-stage {

    position: relative;

    flex: 1;

    min-height: 0;

    overflow: hidden;

    background: #010914;
}


#worldCanvas {

    display: block;

    width: 100%;
    height: 100%;
}


.world-footer {

    display: flex;

    flex:
        0 0 34px;

    align-items: center;

    justify-content: space-between;

    padding:
        0 12px;

    border-top:
        1px solid var(--line);

    background: #02101d;
}


#worldLegend {

    display: flex;

    gap: 15px;
}


.legend-item {

    display: flex;

    align-items: center;

    gap: 5px;

    color: #a9bfd3;

    font-size: 0.64rem;
}


.world-help {

    color: #526f88;

    font-size: 0.62rem;
}


/* =========================================================
   TELEMETRIA
========================================================= */

.stat-row {

    display: flex;

    min-height: 42px;

    align-items: center;

    justify-content: space-between;

    gap: 10px;

    padding:
        0 13px;

    border-top:
        1px solid var(--line-soft);

    color: #a7bed3;

    font-size: 0.7rem;
}


.stat-row strong {

    color: white;
}


.running {

    color:
        var(--green) !important;
}


/* =========================================================
   POPULAÇÃO
========================================================= */

.population-item {

    padding:
        10px 13px;

    border-top:
        1px solid var(--line-soft);
}


.population-line {

    display: grid;

    grid-template-columns:
        auto 1fr auto;

    align-items: center;

    gap: 7px;
}


.population-label {

    color: #bdcfdf;

    font-size: 0.7rem;
}


.population-count {

    font-size: 0.7rem;
}


.population-bar {

    height: 5px;

    margin-top: 8px;

    overflow: hidden;

    border-radius: 20px;

    background: #061b2d;
}


.population-bar span {

    display: block;

    height: 100%;
}


/* =========================================================
   MODAL
========================================================= */

.modal-overlay {

    position: fixed;

    inset: 0;

    z-index: 5000;

    display: flex;

    align-items: center;
    justify-content: center;

    padding: 20px;

    background:
        rgba(0, 5, 11, 0.84);

    backdrop-filter:
        blur(8px);
}


.modal {

    display: flex;

    width:
        min(900px, 100%);

    max-height: 92vh;

    flex-direction: column;

    border:
        1px solid rgba(35, 157, 255, 0.4);

    border-radius: 12px;

    overflow: hidden;

    background:
        linear-gradient(
            #061a2d,
            #020c16
        );

    box-shadow:
        0 30px 100px black;
}


.small-modal {

    width:
        min(440px, 100%);
}


.modal-header {

    display: flex;

    align-items: center;

    justify-content: space-between;

    padding:
        16px 20px;

    border-bottom:
        1px solid var(--line);
}


.modal-header small {

    color: var(--cyan);

    font-size: 0.6rem;
}


.modal-header h2 {

    margin-top: 3px;

    font-size: 1.2rem;
}


.modal-close {

    border: 0;

    color: #a8bfd2;

    font-size: 1.7rem;

    background: transparent;
}


.modal-content {

    padding: 20px;

    overflow-y: auto;
}


.modal-section {

    padding:
        16px 0;

    border-bottom:
        1px solid var(--line-soft);
}


.modal-section:first-child {

    padding-top: 0;
}


.modal-section h3 {

    margin-bottom: 12px;

    color: var(--blue-light);

    font-size: 0.72rem;
}


.form-grid {

    display: grid;

    grid-template-columns:
        1fr 1fr;

    gap: 11px;
}


.form-field {

    display: flex;

    flex-direction: column;

    gap: 5px;
}


.form-field.wide {

    grid-column:
        1 / -1;
}


.form-field span {

    color: #9eb4c8;

    font-size: 0.69rem;
}


.form-field input,
.form-field select {

    width: 100%;

    height: 38px;

    padding:
        0 9px;
}


input[type="color"] {

    padding: 4px;
}


.form-note {

    margin-top: 10px;

    color: #647f96;

    font-size: 0.65rem;
}


/* =========================================================
   SEXOS
========================================================= */

.sex-grid {

    display: grid;

    grid-template-columns:
        1fr 1fr;

    gap: 11px;
}


.sex-card {

    padding: 14px;

    border:
        1px solid var(--line);

    border-radius: 8px;

    background: #031322;
}


.sex-card strong {

    display: block;

    margin-bottom: 11px;
}


.sex-card.female strong {

    color: #ff64b8;
}


.sex-card.male strong {

    color: #2ca9ff;
}


.sex-card label {

    display: grid;

    grid-template-columns:
        1fr 70px auto;

    align-items: center;

    gap: 6px;

    margin-top: 7px;

    color: #aec1d1;

    font-size: 0.7rem;
}


.sex-card input {

    height: 33px;

    padding:
        0 6px;
}


/* =========================================================
   MODAL FOOTER
========================================================= */

.modal-footer {

    display: flex;

    align-items: center;

    justify-content: space-between;

    padding:
        13px 20px;

    border-top:
        1px solid var(--line);

    background: #020c16;
}


.modal-footer > div {

    display: flex;

    gap: 8px;
}


/* =========================================================
   MOBILE
========================================================= */

.mobile-nav {
    display: none;
}


@media (max-width: 800px) {

    /* =====================================================
       BASE MOBILE
    ===================================================== */

    html,
    body {
        width: 100%;
        min-height: 100%;
    }

    body {
        overflow-x: hidden;
        overflow-y: auto;

        padding-bottom: 72px;
    }


    /* =====================================================
       CONTENTOR PRINCIPAL
    ===================================================== */

    .app-shell {
        display: block;

        width: 100%;

        min-height: calc(100dvh - 72px);
        height: auto;

        padding: 10px;
    }


    /* =====================================================
       ESCONDER AS 3 VISTAS POR DEFEITO
    ===================================================== */

    .left-sidebar,
    .right-sidebar,
    .world-column {
        display: none;

        position: static;

        width: 100%;

        max-width: none;
        max-height: none;

        margin: 0;
    }


    /* =====================================================
       CONFIGURAR
    ===================================================== */

    body[data-mobile-view="left"] .left-sidebar {
        display: flex;

        flex-direction: column;

        width: 100%;

        height: auto;

        overflow: visible;
    }


    /* Logo */

    .brand {
        height: 92px;

        justify-content: center;

        gap: 13px;

        margin-bottom: 8px;
    }


    .brand-logo {
        width: 70px;
        height: 70px;
    }


    .brand-title {
        font-size: 34px;
    }


    /* Painéis */

    .left-sidebar .panel {
        width: 100%;

        height: auto;

        max-height: none;

        overflow: visible;
    }


    .left-sidebar .panel h2 {
        padding: 14px 15px;

        font-size: 0.82rem;
    }


    .left-sidebar .panel label {
        margin-left: 15px;
        margin-right: 15px;

        font-size: 0.78rem;
    }


    /* Inputs maiores para toque */

    .left-sidebar > .panel > input,
    .left-sidebar > .panel > select {
        width: calc(100% - 30px);

        height: 48px;

        margin-left: 15px;
        margin-right: 15px;

        font-size: 1rem;
    }


    .dimension-row {
        margin-left: 15px;
        margin-right: 15px;
    }


    .dimension-row input {
        height: 48px;

        font-size: 1rem;
    }


    /* Botões */

    .button {
        min-height: 46px;
    }


    .two-buttons {
        padding-left: 15px;
        padding-right: 15px;
    }


    .control-grid {
        padding-left: 15px;
        padding-right: 15px;
    }


    /* =====================================================
       ESPÉCIES

       A lista cresce para baixo.
       Quem faz scroll é a página.
    ===================================================== */

    .species-panel {
        display: block;

        width: 100%;

        height: auto;
        max-height: none;

        overflow: visible;
    }


    .species-add {
        width: calc(100% - 30px);

        min-height: 48px;

        margin-left: 15px;
        margin-right: 15px;
    }


    #speciesList {
        display: block;

        width: 100%;

        height: auto;
        max-height: none;

        overflow: visible;
    }


    .species-item {
        min-height: 48px;

        padding-left: 15px;
        padding-right: 15px;
    }


    .species-more {
        width: 34px;
        height: 34px;
    }


    /* =====================================================
       MUNDO
    ===================================================== */

    body[data-mobile-view="world"] {
        overflow: hidden;
    }


    body[data-mobile-view="world"] .app-shell {
        height: calc(100dvh - 72px);

        min-height: 0;

        padding: 7px;
    }


    body[data-mobile-view="world"] .world-column {
        display: block;

        width: 100%;
        height: 100%;

        min-height: 0;
    }


    .world-panel {
        width: 100%;
        height: 100%;

        min-height: 0;
    }


    .world-header {
        flex: 0 0 48px;
    }


    .world-stage {
        flex: 1;

        width: 100%;

        min-height: 0;

        overflow: hidden;
    }


    #worldCanvas {
        display: block;

        width: 100%;
        height: 100%;
    }


    /* No telemóvel não precisamos da legenda inferior */

    .world-footer {
        display: none;
    }


    /* =====================================================
       DADOS
    ===================================================== */

    body[data-mobile-view="right"] .right-sidebar {
        display: flex;

        flex-direction: column;

        width: 100%;

        height: auto;

        max-height: none;

        overflow: visible;
    }


    .right-sidebar .panel {
        width: 100%;

        height: auto;

        max-height: none;
    }


    .right-sidebar .panel h2 {
        padding: 14px 15px;

        font-size: 0.82rem;
    }


    .stat-row {
        min-height: 52px;

        padding-left: 15px;
        padding-right: 15px;

        font-size: 0.8rem;
    }


    .population-item {
        padding: 13px 15px;
    }


    /* =====================================================
       NAVEGAÇÃO INFERIOR
    ===================================================== */

    .mobile-nav {
        position: fixed;

        left: 0;
        right: 0;
        bottom: 0;

        z-index: 3000;

        display: grid;

        grid-template-columns: repeat(3, 1fr);

        height: 72px;

        padding-bottom: env(safe-area-inset-bottom);

        border-top: 1px solid var(--line);

        background: rgba(1, 10, 18, 0.98);

        backdrop-filter: blur(10px);
    }


    .mobile-nav button {
        display: flex;

        flex-direction: column;

        align-items: center;
        justify-content: center;

        gap: 4px;

        border: 0;

        color: #68869f;

        background: transparent;

        font-size: 22px;
    }


    .mobile-nav button.active {
        color: var(--cyan);
    }


    .mobile-nav span {
        font-size: 0.72rem;
    }


    /* =====================================================
       MODAIS
    ===================================================== */

    .modal-overlay {
        align-items: flex-end;

        padding: 0;
    }


    .modal {
        width: 100%;

        max-height: 94dvh;

        border-radius: 17px 17px 0 0;
    }


    .modal-content {
        padding: 16px;

        overflow-y: auto;
    }


    .form-grid,
    .sex-grid {
        grid-template-columns: 1fr;
    }


    .form-field.wide {
        grid-column: auto;
    }


    .form-field input,
    .form-field select {
        height: 46px;
    }


    .modal-footer {
        padding-bottom:
            calc(13px + env(safe-area-inset-bottom));
    }
    
    .btn-treino {
    display: inline-block;
    padding: 14px 24px;
    background: #2563eb;
    color: white;
    text-decoration: none;
    font-size: 16px;
    font-weight: 600;
    border-radius: 10px;
    transition: 0.2s;
}

.btn-treino:hover {
    background: #1d4ed8;
    transform: translateY(-2px);
}

.treino-card {
    margin-top: 10px;
    padding: 16px 14px;

    display: flex;
    align-items: center;
    gap: 12px;

    background: #031525;
    border: 1px solid #075985;
    border-radius: 7px;

    text-decoration: none;
    color: white;

    cursor: pointer;
    transition: 0.2s;
}

.treino-card:hover {
    border-color: #00aaff;
    background: #06213a;
}

.treino-icon {
    font-size: 27px;
}

}