/* =====================================================
   TERMOO V2 — VISUAL RESPONSIVO
===================================================== */

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

:root {
    --bg-top: #2c374c;
    --bg-bottom: #0d121b;
    --surface: #222a38;
    --surface-2: #343d4e;
    --surface-3: #465064;
    --border: #596377;
    --text: #ffffff;
    --muted: #b3bac8;
    --correct: #45c795;
    --present: #d7b25c;
    --absent: #342e33;
    --danger: #ef6262;
    --tile-size: 46px;
    --tile-gap: 6px;
}

html,
body {
    width: 100%;
    min-height: 100%;
}

body {
    min-height: 100vh;
    min-height: 100dvh;
    overflow: hidden;
    background:
        radial-gradient(circle at top, var(--bg-top), var(--bg-bottom) 78%);
    color: var(--text);
    font-family: Arial, Helvetica, sans-serif;
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
}

button,
select {
    font: inherit;
}

button {
    color: inherit;
}

.app-shell {
    width: 100%;
    max-width: 1200px;
    height: 100vh;
    height: 100dvh;
    margin: 0 auto;
    padding:
        max(10px, env(safe-area-inset-top))
        16px
        max(8px, env(safe-area-inset-bottom));
    display: grid;
    grid-template-rows: auto 30px minmax(0, 1fr) auto auto;
    align-items: center;
}

.topbar {
    min-height: 58px;
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
}

.brand {
    grid-column: 2;
    font-size: clamp(30px, 4vw, 44px);
    font-weight: 900;
    letter-spacing: clamp(4px, .7vw, 8px);
    line-height: 1;
    white-space: nowrap;
}

.brand span {
    color: var(--correct);
}

.topbar-actions {
    grid-column: 3;
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

.icon-button {
    width: 48px;
    height: 48px;
    border: 1px solid rgba(255,255,255,.16);
    border-radius: 14px;
    background: rgba(255,255,255,.07);
    display: grid;
    place-items: center;
    font-size: 22px;
    cursor: pointer;
    transition: .16s ease;
}

.topbar > .icon-button {
    grid-column: 1;
    justify-self: start;
}

.icon-button:hover {
    background: rgba(255,255,255,.13);
}

.icon-button:active {
    transform: scale(.95);
}

.message {
    height: 30px;
    display: grid;
    place-items: center;
    font-size: 15px;
    font-weight: 700;
    text-align: center;
}

.message.error {
    color: #ffb1b1;
}

.boards {
    width: 100%;
    height: 100%;
    min-height: 0;
    display: grid;
    place-content: center;
    overflow: auto;
    scrollbar-width: thin;
    padding: 8px 0;
}

.boards.mode-1 {
    grid-template-columns: max-content;
}

.boards.mode-2 {
    grid-template-columns: repeat(2, max-content);
    column-gap: clamp(28px, 7vw, 100px);
}

.boards.mode-4 {
    grid-template-columns: repeat(2, max-content);
    grid-template-rows: repeat(2, max-content);
    column-gap: clamp(48px, 8vw, 120px);
    row-gap: clamp(18px, 3vh, 36px);
}

.board {
    width: max-content;
    display: flex;
    flex-direction: column;
    gap: var(--tile-gap);
}

.board.solved {
    opacity: .9;
}

.board-row {
    display: flex;
    justify-content: center;
    gap: var(--tile-gap);
}

.tile {
    width: var(--tile-size);
    height: var(--tile-size);
    flex: 0 0 var(--tile-size);
    display: grid;
    place-items: center;
    border: 2px solid var(--border);
    border-radius: 7px;
    background: rgba(34,42,56,.82);
    font-size: calc(var(--tile-size) * .53);
    font-weight: 900;
    text-transform: uppercase;
    transition: background-color .22s ease, border-color .22s ease, transform .15s ease;
}

.tile.filled {
    border-color: #8f98aa;
    animation: pop .12s ease;
}

.tile.correct {
    background: var(--correct);
    border-color: var(--correct);
}

.tile.present {
    background: var(--present);
    border-color: var(--present);
}

.tile.absent {
    background: var(--absent);
    border-color: var(--absent);
}

@keyframes pop {
    50% { transform: scale(1.08); }
}

.board-row.shake {
    animation: shake .35s ease;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    50% { transform: translateX(5px); }
    75% { transform: translateX(-3px); }
}

.new-game-button,
.primary-button {
    border: 0;
    border-radius: 28px;
    background: var(--correct);
    color: var(--text);
    font-weight: 800;
    cursor: pointer;
    transition: .16s ease;
}

.new-game-button {
    justify-self: center;
    min-width: 185px;
    height: 48px;
    margin: 5px 0 12px;
    padding: 0 34px;
    font-size: 16px;
}

.new-game-button:hover,
.primary-button:hover {
    filter: brightness(1.06);
}

.new-game-button:active,
.primary-button:active {
    transform: scale(.97);
}

.keyboard {
    width: min(700px, 100%);
    justify-self: center;
}

.keyboard-row {
    display: flex;
    justify-content: center;
    gap: 5px;
    margin-bottom: 6px;
}

.keyboard-row:last-child {
    margin-bottom: 0;
}

.keyboard-row button {
    position: relative;
    isolation: isolate;
    overflow: hidden;
    flex: 1 1 0;
    min-width: 0;
    max-width: 50px;
    height: 48px;
    padding: 0;
    border: 0;
    border-radius: 7px;
    background: var(--surface-2);
    font-size: 15px;
    font-weight: 800;
    cursor: pointer;
    user-select: none;
    touch-action: manipulation;
}

.keyboard-row button:hover {
    filter: brightness(1.08);
}

.keyboard-row button:active {
    transform: scale(.96);
}

.key-letter {
    position: relative;
    z-index: 3;
    width: 100%;
    height: 100%;
    display: grid;
    place-items: center;
    pointer-events: none;
}

.key-zones {
    position: absolute;
    inset: 0;
    z-index: 1;
    display: grid;
    pointer-events: none;
}

.key-zones.mode-1 {
    grid-template-columns: 1fr;
}

.key-zones.mode-2 {
    grid-template-columns: repeat(2, 1fr);
}

.key-zones.mode-4 {
    grid-template-columns: repeat(2, 1fr);
    grid-template-rows: repeat(2, 1fr);
}

.key-zone.unknown { background: var(--surface-2); }
.key-zone.correct { background: var(--correct); }
.key-zone.present { background: var(--present); }
.key-zone.absent { background: var(--absent); }

.keyboard-action {
    max-width: 58px !important;
    flex-grow: 1.25 !important;
}

.keyboard-action--enter {
    max-width: 102px !important;
    flex-grow: 1.75 !important;
    font-size: 13px !important;
}

.modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    padding: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    visibility: hidden;
    opacity: 0;
    pointer-events: none;
    background: rgba(0,0,0,.72);
    backdrop-filter: blur(4px);
    transition: opacity .22s ease, visibility .22s ease;
}

.modal.open {
    visibility: visible;
    opacity: 1;
    pointer-events: auto;
}

.modal-card {
    position: relative;
    width: min(420px, 100%);
    max-height: calc(100dvh - 36px);
    overflow-y: auto;
    padding: 25px;
    border: 1px solid rgba(255,255,255,.06);
    border-radius: 22px;
    background: #202735;
    box-shadow: 0 24px 70px rgba(0,0,0,.5);
    opacity: 0;
    transform: scale(.9) translateY(12px);
    transition: opacity .22s ease, transform .22s ease;
}

.modal.open .modal-card {
    opacity: 1;
    transform: scale(1) translateY(0);
}

.modal-card--help {
    max-width: 520px;
}

.modal-card h2 {
    margin-bottom: 22px;
    font-size: 24px;
    text-align: center;
}

.modal-card p {
    margin: 12px 0;
    color: #edf0f5;
    line-height: 1.45;
}

.modal-card label {
    display: block;
    margin: 15px 0 7px;
    font-size: 15px;
    font-weight: 600;
}

.modal-card select {
    width: 100%;
    height: 46px;
    padding: 0 13px;
    border: 1px solid transparent;
    border-radius: 12px;
    outline: none;
    background: var(--surface-2);
    color: var(--text);
}

.modal-card select:focus {
    border-color: var(--correct);
}

.modal-close {
    position: absolute;
    top: 10px;
    right: 14px;
    width: 34px;
    height: 34px;
    border: 0;
    background: transparent;
    font-size: 27px;
    font-weight: 700;
    cursor: pointer;
}

.primary-button {
    width: 100%;
    height: 46px;
    margin-top: 22px;
}

.help-divider {
    height: 1px;
    margin: 18px 0;
    background: rgba(255,255,255,.22);
}

.help-example {
    margin-bottom: 20px;
}

.help-word {
    display: flex;
    gap: 4px;
}

.help-tile {
    width: 40px;
    height: 40px;
    display: grid;
    place-items: center;
    border: 2px solid #788195;
    border-radius: 4px;
    background: #171d27;
    font-size: 24px;
    font-weight: 900;
}

.help-tile.correct {
    background: var(--correct);
    border-color: var(--correct);
}

.help-tile.present {
    background: var(--present);
    border-color: var(--present);
}

.help-tile.absent {
    background: var(--absent);
    border-color: var(--absent);
}

.help-signature {
    text-align: center;
    font-weight: 800;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.stat-card {
    min-height: 96px;
    padding: 16px;
    border-radius: 16px;
    background: var(--surface);
    display: grid;
    place-items: center;
    text-align: center;
}

.stat-card strong {
    font-size: 30px;
}

.stat-card span {
    color: var(--muted);
    font-size: 13px;
}

/* Desktop */
@media (min-width: 901px) {
    .boards.mode-4 {
        --tile-size: clamp(34px, 2.7vw, 46px);
        --tile-gap: 5px;
        grid-template-columns: repeat(2, max-content);
        grid-template-rows: repeat(2, max-content);
        column-gap: clamp(80px, 10vw, 160px);
        row-gap: clamp(24px, 4vh, 46px);
    }

    .keyboard {
        width: min(700px, 70vw);
    }

    .keyboard-row button {
        height: 44px;
        max-width: 61px;
    }

    .keyboard-action {
        max-width: 65px !important;
    }

    .keyboard-action--enter {
        max-width: 170px !important;
    }
}

/* Tablet */
@media (max-width: 900px) {
    :root {
        --tile-size: 40px;
        --tile-gap: 5px;
    }

    .boards.mode-2 {
        column-gap: 28px;
    }

    .boards.mode-4 {
        column-gap: 28px;
        row-gap: 18px;
    }
}

/* Celular */
@media (max-width: 600px) {
    .app-shell {
        padding:
            max(8px, env(safe-area-inset-top))
            10px
            max(5px, env(safe-area-inset-bottom));
        grid-template-rows: auto 24px minmax(0,1fr) auto auto;
    }

    .topbar {
        min-height: 57px;
    }

    .brand {
        font-size: clamp(29px, 9vw, 40px);
        letter-spacing: clamp(4px, 1.5vw, 7px);
    }

    .icon-button {
        width: 44px;
        height: 44px;
        border-radius: 13px;
        font-size: 21px;
    }

    .message {
        height: 24px;
        font-size: 14px;
    }

    .boards {
        padding: 3px 0;
    }

    .boards.mode-1 {
        --tile-size: clamp(42px, 11.5vw, 52px);
        --tile-gap: 5px;
    }

    .boards.mode-2 {
        --tile-size: clamp(27px, 7.2vw, 36px);
        --tile-gap: 3px;
        grid-template-columns: repeat(2, max-content);
        column-gap: clamp(10px, 3vw, 18px);
    }

    .boards.mode-4 {
        --tile-size: clamp(22px, 5.8vw, 30px);
        --tile-gap: 2px;
        grid-template-columns: repeat(2, max-content);
        grid-template-rows: repeat(2, max-content);
        column-gap: clamp(7px, 2.5vw, 14px);
        row-gap: clamp(6px, 1.4vh, 12px);
    }

    .tile {
        border-radius: 5px;
    }

    .new-game-button {
        min-width: 175px;
        height: 46px;
        margin: 4px 0 10px;
    }

    .keyboard {
        width: 100%;
    }

    .keyboard-row {
        gap: 4px;
        margin-bottom: 5px;
    }

    .keyboard-row button {
        max-width: none;
        height: 49px;
        border-radius: 7px;
        font-size: clamp(12px, 3.5vw, 16px);
    }

    .keyboard-action {
        max-width: none !important;
    }

    .keyboard-action--enter {
        max-width: none !important;
        font-size: 12px !important;
    }

    .modal-card--help {
        width: 94%;
        padding: 22px 16px;
    }

    .help-tile {
        width: 36px;
        height: 36px;
        font-size: 21px;
    }
}

/* Celulares baixos */
@media (max-width: 600px) and (max-height: 780px) {
    .app-shell {
        grid-template-rows: auto 20px minmax(0,1fr) auto auto;
    }

    .topbar {
        min-height: 50px;
    }

    .icon-button {
        width: 40px;
        height: 40px;
    }

    .boards.mode-1 {
        --tile-size: clamp(37px, 10vw, 46px);
        --tile-gap: 4px;
    }

    .boards.mode-2 {
        --tile-size: clamp(25px, 6.6vw, 33px);
        --tile-gap: 2px;
    }

    .boards.mode-4 {
        --tile-size: clamp(20px, 5.2vw, 27px);
        --tile-gap: 2px;
        row-gap: 5px;
    }

    .new-game-button {
        height: 42px;
        margin-bottom: 7px;
    }

    .keyboard-row button {
        height: 43px;
    }
}

/* Telas estreitas */
@media (max-width: 380px) {
    .app-shell {
        padding-left: 6px;
        padding-right: 6px;
    }

    .brand {
        font-size: 27px;
    }

    .icon-button {
        width: 38px;
        height: 38px;
    }

    .boards.mode-2 {
        --tile-size: 25px;
        column-gap: 7px;
    }

    .boards.mode-4 {
        --tile-size: 20px;
        column-gap: 5px;
        row-gap: 5px;
    }

    .keyboard-row {
        gap: 3px;
    }

    .keyboard-row button {
        height: 42px;
        font-size: 12px;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: .01ms !important;
        transition-duration: .01ms !important;
    }
}


/* =====================================================
   AJUSTE FINO — DUETO COM 7 E 8 LETRAS NO CELULAR
===================================================== */

@media (max-width: 600px) {
    .boards.mode-2 {
        width: 100%;
        max-width: 100%;
        overflow-x: hidden;
        justify-content: center;
        align-content: center;
    }

    .boards.mode-2[data-length="7"] {
        --tile-size: clamp(21px, 5.65vw, 29px);
        --tile-gap: 2px;
        grid-template-columns: repeat(2, max-content);
        column-gap: clamp(6px, 1.8vw, 10px);
    }

    .boards.mode-2[data-length="8"] {
        --tile-size: clamp(18px, 4.85vw, 25px);
        --tile-gap: 2px;
        grid-template-columns: repeat(2, max-content);
        column-gap: clamp(4px, 1.2vw, 7px);
    }

    .boards.mode-2[data-length="7"] .tile,
    .boards.mode-2[data-length="8"] .tile {
        border-width: 2px;
        border-radius: 4px;
    }
}

@media (max-width: 380px) {
    .boards.mode-2[data-length="7"] {
        --tile-size: 20px;
        --tile-gap: 2px;
        column-gap: 5px;
    }

    .boards.mode-2[data-length="8"] {
        --tile-size: 17px;
        --tile-gap: 1px;
        column-gap: 4px;
    }
}

@media (max-width: 600px) and (max-height: 780px) {
    .boards.mode-2[data-length="7"] {
        --tile-size: clamp(20px, 5.3vw, 27px);
    }

    .boards.mode-2[data-length="8"] {
        --tile-size: clamp(17px, 4.55vw, 23px);
    }
}

/* =====================================================
   TERMOO V2.1 — DUETO 7/8 LETRAS EMPILHADO NO CELULAR
===================================================== */

@media (max-width: 600px) {
    .boards.mode-2[data-length="7"],
    .boards.mode-2[data-length="8"] {
        width: 100%;
        max-width: 100%;

        grid-template-columns: max-content;
        grid-template-rows: repeat(2, max-content);

        justify-content: center;
        align-content: start;

        column-gap: 0;
        row-gap: 14px;

        overflow-x: hidden;
        overflow-y: auto;
        overscroll-behavior: contain;

        padding: 8px 0 14px;
    }

    .boards.mode-2[data-length="7"] {
        --tile-size: clamp(32px, 8.6vw, 40px);
        --tile-gap: 3px;
    }

    .boards.mode-2[data-length="8"] {
        --tile-size: clamp(29px, 7.75vw, 36px);
        --tile-gap: 3px;
    }

    .boards.mode-2[data-length="7"] .tile,
    .boards.mode-2[data-length="8"] .tile {
        border-width: 2px;
        border-radius: 5px;
    }
}

@media (max-width: 600px) and (max-height: 780px) {
    .boards.mode-2[data-length="7"],
    .boards.mode-2[data-length="8"] {
        row-gap: 10px;
        padding-top: 5px;
        padding-bottom: 10px;
    }

    .boards.mode-2[data-length="7"] {
        --tile-size: clamp(28px, 7.5vw, 34px);
        --tile-gap: 2px;
    }

    .boards.mode-2[data-length="8"] {
        --tile-size: clamp(25px, 6.75vw, 31px);
        --tile-gap: 2px;
    }
}

@media (max-width: 380px) {
    .boards.mode-2[data-length="7"] {
        --tile-size: 27px;
        --tile-gap: 2px;
    }

    .boards.mode-2[data-length="8"] {
        --tile-size: 24px;
        --tile-gap: 2px;
    }
}


/* =====================================================
   TERMOO V2.1 — QUARTETO DESKTOP SEM BARRA LATERAL
   Compacta os 4 tabuleiros para que as 9 tentativas
   caibam integralmente na área disponível.
===================================================== */

@media (min-width: 901px) {
    .boards.mode-4 {
        /*
         * O tamanho acompanha a altura da janela.
         * Em telas mais baixas, os quadrados diminuem
         * automaticamente para evitar rolagem.
         */
        --tile-size: clamp(24px, 3.25vh, 33px);
        --tile-gap: clamp(2px, 0.35vh, 4px);

        grid-template-columns: repeat(2, max-content);
        grid-template-rows: repeat(2, max-content);

        column-gap: clamp(55px, 8vw, 125px);
        row-gap: clamp(12px, 2vh, 24px);

        place-content: center;

        overflow: hidden;
        scrollbar-width: none;

        padding-top: 2px;
        padding-bottom: 2px;
    }

    .boards.mode-4::-webkit-scrollbar {
        display: none;
    }

    .boards.mode-4 .tile {
        border-radius: 5px;
        border-width: 2px;
    }
}

/* Monitores/notebooks com pouca altura */
@media (min-width: 901px) and (max-height: 800px) {
    .boards.mode-4 {
        --tile-size: clamp(22px, 3vh, 29px);
        --tile-gap: 2px;

        row-gap: 10px;
        column-gap: clamp(42px, 6vw, 90px);
    }
}

/* Telas muito baixas: preserva todos os 9 campos visíveis */
@media (min-width: 901px) and (max-height: 680px) {
    .boards.mode-4 {
        --tile-size: clamp(19px, 2.7vh, 25px);
        --tile-gap: 2px;

        row-gap: 7px;
        column-gap: clamp(32px, 5vw, 70px);
    }
}

/* =====================================================
   TERMOO V2.2 — QUARTETO ADAPTATIVO POR ORIENTAÇÃO
   Horizontal largo: 4 tabuleiros lado a lado.
   Vertical/estreito: 2 tabuleiros em cima e 2 embaixo.
===================================================== */

/* Menus superiores mais próximos e compactos no computador */
@media (min-width: 901px) {
    .app-shell {
        max-width: 1500px;
        padding-left: 18px;
        padding-right: 18px;
    }

    .topbar {
        width: min(920px, 100%);
        min-height: 52px;
        justify-self: center;
    }

    .brand {
        font-size: clamp(30px, 3vw, 42px);
        letter-spacing: clamp(4px, .55vw, 7px);
    }

    .icon-button {
        width: 42px;
        height: 42px;
        border-radius: 12px;
        font-size: 19px;
    }

    .topbar-actions {
        gap: 6px;
    }
}

/* Base para telas verticais ou janelas que não sejam largas: 2 x 2 */
@media (min-width: 901px) {
    .boards.mode-4 {
        --tile-size: clamp(24px, 3.1vh, 36px);
        --tile-gap: clamp(2px, .35vh, 4px);

        grid-template-columns: repeat(2, max-content);
        grid-template-rows: repeat(2, max-content);

        column-gap: clamp(55px, 8vw, 120px);
        row-gap: clamp(12px, 2vh, 24px);

        place-content: center;
        overflow: hidden;
        scrollbar-width: none;
    }

    .boards.mode-4::-webkit-scrollbar {
        display: none;
    }
}

/* Monitor horizontal/largo: 4 tabuleiros na mesma linha */
@media (min-width: 1200px) and (orientation: landscape) {
    .boards.mode-4 {
        --tile-size: clamp(23px, 2.15vw, 36px);
        --tile-gap: clamp(2px, .25vw, 4px);

        grid-template-columns: repeat(4, max-content);
        grid-template-rows: max-content;

        column-gap: clamp(24px, 2.8vw, 52px);
        row-gap: 0;

        place-content: center;
        overflow: hidden;
        padding-top: 4px;
        padding-bottom: 4px;
    }

    .boards.mode-4 .tile {
        border-radius: 5px;
    }
}

/* Monitor horizontal com pouca altura */
@media (min-width: 1200px) and (orientation: landscape) and (max-height: 760px) {
    .boards.mode-4 {
        --tile-size: clamp(20px, 2.65vh, 28px);
        --tile-gap: 2px;
        column-gap: clamp(18px, 2.2vw, 38px);
    }

    .new-game-button {
        height: 42px;
        margin-top: 2px;
        margin-bottom: 8px;
    }

    .keyboard-row button {
        height: 40px;
    }
}


/* =====================================================
   TERMOO V2.3 — MENU MOBILE E CONFIRMAÇÃO DE NOVO JOGO
===================================================== */

body.modal-open {
    overflow: hidden;
}

.mobile-game-actions {
    display: none;
}

.mobile-action-button {
    min-width: 0;
    height: 46px;
    padding: 0 16px;
    border: 1px solid rgba(255,255,255,.08);
    border-radius: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    color: var(--text);
    font-size: 14px;
    font-weight: 800;
    cursor: pointer;
    transition: transform .15s ease, filter .15s ease, background-color .15s ease;
}

.mobile-action-button:active {
    transform: scale(.97);
}

.mobile-action-button--menu {
    background: var(--surface-2);
}

.mobile-action-button--new {
    background: var(--correct);
    border-color: transparent;
}

.modal-card {
    transform-origin: center;
}

.confirm-card {
    width: min(390px, 100%);
    padding: 30px 26px 24px;
    text-align: center;
}

.confirm-icon {
    width: 62px;
    height: 62px;
    margin: 0 auto 16px;
    border-radius: 20px;
    display: grid;
    place-items: center;
    background: rgba(69,199,149,.14);
    color: var(--correct);
    font-size: 34px;
    font-weight: 900;
    box-shadow: inset 0 0 0 1px rgba(69,199,149,.2);
}

.confirm-card h2 {
    margin-bottom: 10px;
}

.confirm-card p {
    margin: 0 auto;
    max-width: 315px;
    color: var(--muted);
    font-size: 14px;
}

.confirm-actions {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-top: 24px;
}

.confirm-button {
    height: 46px;
    border: 0;
    border-radius: 14px;
    font-weight: 800;
    cursor: pointer;
    transition: transform .15s ease, filter .15s ease;
}

.confirm-button:active {
    transform: scale(.97);
}

.confirm-button--cancel {
    background: var(--surface-2);
    color: var(--text);
}

.confirm-button--confirm {
    background: var(--correct);
    color: var(--text);
}

.mobile-menu-card {
    width: min(430px, 100%);
}

.mobile-menu-handle {
    display: none;
}

.mobile-menu-options {
    display: grid;
    gap: 10px;
}

.menu-option {
    width: 100%;
    min-height: 72px;
    padding: 12px 14px;
    border: 1px solid rgba(255,255,255,.07);
    border-radius: 16px;
    background: var(--surface);
    display: grid;
    grid-template-columns: 46px 1fr;
    align-items: center;
    gap: 12px;
    text-align: left;
    cursor: pointer;
    transition: transform .15s ease, background-color .15s ease;
}

.menu-option:hover {
    background: var(--surface-2);
}

.menu-option:active {
    transform: scale(.985);
}

.menu-option-icon {
    width: 44px;
    height: 44px;
    border-radius: 13px;
    display: grid;
    place-items: center;
    background: var(--surface-2);
    font-size: 20px;
    font-weight: 900;
}

.menu-option strong,
.menu-option small {
    display: block;
}

.menu-option strong {
    margin-bottom: 4px;
    font-size: 15px;
}

.menu-option small {
    color: var(--muted);
    font-size: 12px;
    font-weight: 500;
}

@media (max-width: 1024px) {
    .desktop-new-game {
        display: none;
    }

    .mobile-game-actions {
        width: min(470px, 100%);
        justify-self: center;
        display: grid;
        grid-template-columns: .85fr 1.35fr;
        gap: 8px;
        margin: 4px 0 10px;
    }
}

@media (max-width: 600px) {
    .mobile-game-actions {
        width: 100%;
        padding: 0 1px;
    }

    .mobile-action-button {
        height: 44px;
        border-radius: 14px;
        font-size: 13px;
    }

    .modal--sheet {
        align-items: flex-end;
        padding: 12px 10px max(10px, env(safe-area-inset-bottom));
    }

    .modal--sheet .modal-card {
        width: 100%;
        max-height: min(72dvh, 590px);
        border-radius: 24px 24px 18px 18px;
        transform: translateY(34px) scale(.98);
        transform-origin: bottom center;
    }

    .modal--sheet.open .modal-card {
        transform: translateY(0) scale(1);
    }

    .mobile-menu-handle {
        display: block;
        width: 42px;
        height: 5px;
        margin: -8px auto 18px;
        border-radius: 999px;
        background: rgba(255,255,255,.22);
    }

    .confirm-card {
        padding: 28px 20px 20px;
        border-radius: 22px;
    }

    .confirm-actions {
        gap: 8px;
    }
}


/* =====================================================
   TERMOO V2.4 — MENU UNIFICADO E CONFIRMAÇÃO EM TODOS
===================================================== */

/*
 * O cabeçalho agora possui apenas o Menu no canto esquerdo.
 * Ajuda, estatísticas e configurações ficam dentro do modal Menu.
 */
.topbar {
    position: relative;
}

.desktop-menu-button {
    grid-column: 1;
    justify-self: start;
}

.topbar-actions {
    display: none !important;
}

/*
 * Desktop/notebook com mouse:
 * Menu no topo esquerdo e Novo jogo acima do teclado.
 */
@media (hover: hover) and (pointer: fine) {
    .desktop-menu-button {
        display: grid;
    }

    .desktop-new-game {
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    .mobile-game-actions {
        display: none !important;
    }
}

/*
 * Celular/tablet por toque:
 * mantém somente Menu + Novo jogo na barra inferior.
 * Os controles do topo desaparecem para liberar espaço.
 */
@media (hover: none) and (pointer: coarse),
       (max-width: 768px) {
    .desktop-menu-button {
        display: none !important;
    }

    .desktop-new-game {
        display: none !important;
    }

    .mobile-game-actions {
        width: min(470px, 100%);
        justify-self: center;
        display: grid !important;
        grid-template-columns: .85fr 1.35fr;
        gap: 8px;
        margin: 4px 0 10px;
    }
}

/*
 * Garante que uma janela desktop estreita ou com zoom não exiba
 * os botões mobile soltos e sem estilo.
 */
@media (hover: hover) and (pointer: fine) and (max-width: 1024px) {
    .mobile-game-actions {
        display: none !important;
    }

    .desktop-new-game {
        display: inline-flex !important;
    }

    .desktop-menu-button {
        display: grid !important;
    }
}

@media (max-width: 600px) {
    .topbar {
        grid-template-columns: 1fr auto 1fr;
    }

    .mobile-game-actions {
        width: 100%;
        padding: 0 1px;
    }
}

/* =====================================================
   TERMOO V2.5 — CORREÇÃO DEFINITIVA DO MENU RESPONSIVO
===================================================== */

/* Desktop por largura: nunca renderiza a barra mobile. */
@media (min-width: 769px) {
    .mobile-game-actions {
        display: none !important;
        visibility: hidden !important;
        pointer-events: none !important;
        position: absolute !important;
        width: 0 !important;
        height: 0 !important;
        overflow: hidden !important;
    }

    .desktop-menu-button {
        display: grid !important;
        visibility: visible !important;
        pointer-events: auto !important;
    }

    .desktop-new-game {
        display: inline-flex !important;
        align-items: center;
        justify-content: center;
    }
}

/* Mobile/tablet: barra inferior; botão superior escondido. */
@media (max-width: 768px) {
    .desktop-menu-button,
    .desktop-new-game {
        display: none !important;
    }

    .mobile-game-actions {
        display: grid !important;
        visibility: visible !important;
        pointer-events: auto !important;
        position: static !important;
        width: min(470px, 100%) !important;
        height: auto !important;
        overflow: visible !important;
        grid-template-columns: .85fr 1.35fr;
        gap: 8px;
        justify-self: center;
        margin: 4px 0 10px;
    }
}

/* Menu de desktop sempre centralizado e acima da interface. */
@media (min-width: 769px) {
    #gameMenuModal {
        z-index: 1200;
    }

    #gameMenuModal .modal-card {
        width: min(430px, calc(100vw - 36px));
        max-height: calc(100dvh - 36px);
    }
}


/* =====================================================
   TERMOO V2.6 — AÇÕES DESKTOP UNIFICADAS
===================================================== */

/* O cabeçalho fica limpo, somente com o título centralizado. */
.topbar {
    grid-template-columns: 1fr auto 1fr;
}

.topbar .brand {
    grid-column: 2;
}

/* Menu e Novo jogo ficam juntos, acima do teclado. */
.desktop-game-actions {
    justify-self: center;
    width: min(390px, 100%);
    display: grid;
    grid-template-columns: .82fr 1.18fr;
    gap: 9px;
    margin: 5px 0 12px;
}

.desktop-action-button {
    height: 48px;
    min-width: 0;
    padding: 0 20px;
    border: 1px solid rgba(255,255,255,.09);
    border-radius: 24px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    color: var(--text);
    font-size: 15px;
    font-weight: 800;
    cursor: pointer;
    transition:
        transform .15s ease,
        filter .15s ease,
        background-color .15s ease;
}

.desktop-action-button:active {
    transform: scale(.97);
}

.desktop-action-button--menu {
    background: var(--surface-2);
}

.desktop-action-button--menu:hover {
    background: var(--surface-3);
}

.desktop-action-button--new {
    background: var(--correct);
    border-color: transparent;
}

.desktop-action-button--new:hover {
    filter: brightness(1.06);
}

/* Remove regras antigas do botão desktop isolado. */
.desktop-new-game {
    display: none !important;
}

/* Computador: exibe a barra desktop e esconde a barra mobile. */
@media (hover: hover) and (pointer: fine) {
    .desktop-game-actions {
        display: grid !important;
    }

    .mobile-game-actions {
        display: none !important;
    }
}

/* Celular/tablet: mantém exatamente a barra mobile já aprovada. */
@media (hover: none) and (pointer: coarse),
       (max-width: 768px) {
    .desktop-game-actions {
        display: none !important;
    }

    .mobile-game-actions {
        display: grid !important;
    }
}

/* Evita ações mobile soltas em desktop estreito ou com zoom. */
@media (hover: hover) and (pointer: fine) and (max-width: 1024px) {
    .desktop-game-actions {
        display: grid !important;
    }

    .mobile-game-actions {
        display: none !important;
    }
}


/* =====================================================
   TERMOO V2.8 — INTERFACE PREMIUM
===================================================== */

.brand-block {
    grid-column: 2;
    display: grid;
    justify-items: center;
    gap: 5px;
}

.brand-block .brand {
    grid-column: auto;
}

.game-meta {
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
}

.tile.reveal {
    animation:
        tile-reveal .48s cubic-bezier(.2,.72,.28,1)
        var(--reveal-delay, 0ms)
        both;
    transform-style: preserve-3d;
}

@keyframes tile-reveal {
    0% {
        transform: rotateX(0deg);
    }

    48% {
        transform: rotateX(90deg) scale(.96);
    }

    100% {
        transform: rotateX(0deg);
    }
}

.toast-viewport {
    position: fixed;
    z-index: 1600;
    top: max(14px, env(safe-area-inset-top));
    left: 50%;
    width: min(430px, calc(100% - 24px));
    transform: translateX(-50%);
    pointer-events: none;
}

.toast {
    min-height: 52px;
    padding: 10px 14px;
    border: 1px solid rgba(255,255,255,.1);
    border-radius: 16px;
    display: grid;
    grid-template-columns: 32px 1fr;
    align-items: center;
    gap: 10px;
    background: rgba(25,31,43,.94);
    box-shadow: 0 16px 45px rgba(0,0,0,.38);
    backdrop-filter: blur(14px);
    opacity: 0;
    transform: translateY(-14px) scale(.97);
    transition: opacity .2s ease, transform .2s ease;
}

.toast.show {
    opacity: 1;
    transform: translateY(0) scale(1);
}

.toast-icon {
    width: 30px;
    height: 30px;
    border-radius: 10px;
    display: grid;
    place-items: center;
    font-size: 16px;
    font-weight: 900;
}

.toast-text {
    font-size: 14px;
    font-weight: 700;
    line-height: 1.3;
}

.toast--success .toast-icon {
    color: #0f2b21;
    background: var(--correct);
}

.toast--error .toast-icon {
    color: #351313;
    background: #ff7777;
}

.toast--warning .toast-icon {
    color: #3a2a0d;
    background: var(--present);
}

.toast--info .toast-icon {
    color: #11233b;
    background: #7db5ff;
}

.modal-card,
.mobile-action-button,
.desktop-action-button,
.menu-option,
.stat-card,
.keyboard-row button,
.tile {
    box-shadow: inset 0 1px 0 rgba(255,255,255,.025);
}

.menu-option,
.stat-card {
    transition:
        transform .15s ease,
        background-color .15s ease,
        border-color .15s ease;
}

.stat-card:hover {
    transform: translateY(-2px);
    background: var(--surface-2);
}

@media (max-width: 600px) {
    .brand-block {
        gap: 3px;
    }

    .game-meta {
        max-width: 250px;
        overflow: hidden;
        font-size: 10px;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .toast-viewport {
        top: max(8px, env(safe-area-inset-top));
    }

    .toast {
        min-height: 48px;
        border-radius: 14px;
    }
}


/* =====================================================
   TERMOO V2.8.1 — TOAST CORRIGIDO SEM ALTERAR O LAYOUT
===================================================== */

/*
 * O aviso permanece fixo e fora do fluxo da página.
 * Dessa forma, não cria barra de rolagem nem desloca tabuleiro,
 * botões ou teclado.
 */
.toast-viewport {
    position: fixed;
    z-index: 1600;

    top: max(76px, calc(env(safe-area-inset-top) + 68px));
    left: 50%;

    width: min(430px, calc(100% - 24px));

    min-height: 0;
    margin: 0;

    display: block;
    transform: translateX(-50%);

    pointer-events: none;
}

/* Celular e tablet: fica abaixo do título e do resumo do jogo. */
@media (max-width: 1024px) {
    .toast-viewport {
        top: max(86px, calc(env(safe-area-inset-top) + 78px));
        width: min(430px, calc(100% - 20px));
    }
}

@media (max-width: 600px) {
    .toast-viewport {
        top: max(92px, calc(env(safe-area-inset-top) + 84px));
        width: calc(100% - 20px);
    }
}


/* =====================================================
   TERMOO V2.8.2 — AVISOS SOMENTE EM TOAST
===================================================== */

/*
 * A antiga área de mensagens permanece no HTML apenas para
 * compatibilidade, mas não ocupa espaço e nunca fica visível.
 */
.message.message--hidden {
    display: none !important;
    width: 0 !important;
    height: 0 !important;
    min-height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: hidden !important;
}

/*
 * Como a linha fixa de mensagem foi removida visualmente,
 * a aplicação ganha uma linha extra para os tabuleiros.
 */
.app-shell {
    grid-template-rows: auto minmax(0, 1fr) auto auto;
}

@media (max-width: 600px) {
    .app-shell {
        grid-template-rows: auto minmax(0, 1fr) auto auto;
    }
}

@media (max-width: 600px) and (max-height: 780px) {
    .app-shell {
        grid-template-rows: auto minmax(0, 1fr) auto auto;
    }
}


/* =====================================================
   TERMOO V2.8.3 — TOAST MAIS PRÓXIMO DO SUBTÍTULO
===================================================== */

/* Desktop: mantém praticamente a posição aprovada. */
.toast-viewport {
    top: max(74px, calc(env(safe-area-inset-top) + 66px));
    width: min(420px, calc(100% - 24px));
}

/* Tablet: aproxima um pouco do subtítulo. */
@media (max-width: 1024px) {
    .toast-viewport {
        top: max(76px, calc(env(safe-area-inset-top) + 68px));
        width: min(420px, calc(100% - 22px));
    }
}

/* Celular: fica logo abaixo de "Modo • Categoria • Letras". */
@media (max-width: 600px) {
    .toast-viewport {
        top: max(70px, calc(env(safe-area-inset-top) + 62px));
        width: calc(100% - 20px);
    }

    .toast {
        border-radius: 18px;
        box-shadow: 0 12px 34px rgba(0,0,0,.32);
    }
}

/* Celulares muito baixos: preserva a proximidade do cabeçalho. */
@media (max-width: 600px) and (max-height: 780px) {
    .toast-viewport {
        top: max(66px, calc(env(safe-area-inset-top) + 58px));
    }
}


/* =====================================================
   TERMOO V3.0 — PROFESSIONAL EDITION
===================================================== */

:root[data-theme="light"] {
    --bg-top: #e7edf7;
    --bg-bottom: #cbd5e5;
    --surface: #d9e1ee;
    --surface-2: #c5cfde;
    --surface-3: #aebacc;
    --border: #8997aa;
    --text: #182131;
    --muted: #526076;
    --absent: #837a80;
}

:root[data-theme="light"] body {
    background:
        radial-gradient(circle at top, var(--bg-top), var(--bg-bottom) 78%);
}

:root[data-theme="light"] .modal-card,
:root[data-theme="light"] .toast {
    background: rgba(239, 243, 249, .96);
}

:root[data-theme="light"] .modal {
    background: rgba(30, 40, 55, .48);
}

.settings-divider {
    height: 1px;
    margin: 20px 0 4px;
    background: rgba(255,255,255,.12);
}

.toggle-row {
    min-height: 58px;
    padding: 10px 0;
    display: flex !important;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
}

.toggle-row > span {
    min-width: 0;
}

.toggle-row strong,
.toggle-row small {
    display: block;
}

.toggle-row small {
    margin-top: 4px;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.3;
}

.toggle-row input {
    width: 21px;
    height: 21px;
    flex: 0 0 auto;
    accent-color: var(--correct);
}

.modal-card--wide {
    width: min(620px, 100%);
}

.history-list,
.achievements-list {
    display: grid;
    gap: 10px;
}

.history-item,
.achievement-card {
    padding: 14px;
    border: 1px solid rgba(255,255,255,.07);
    border-radius: 15px;
    background: var(--surface);
    display: grid;
    gap: 5px;
}

.history-item span,
.history-item time,
.achievement-card small {
    color: var(--muted);
    font-size: 12px;
}

.achievement-card {
    grid-template-columns: 44px 1fr;
    align-items: center;
    opacity: .62;
}

.achievement-card.unlocked {
    opacity: 1;
    border-color: rgba(69,199,149,.28);
}

.achievement-icon {
    width: 42px;
    height: 42px;
    border-radius: 13px;
    display: grid;
    place-items: center;
    background: var(--surface-2);
    font-size: 21px;
}

.achievement-card strong,
.achievement-card small {
    display: block;
}

.achievement-card small {
    margin-top: 4px;
}

.empty-state {
    padding: 24px 12px;
    color: var(--muted);
    text-align: center;
}

.backup-actions {
    display: grid;
    gap: 10px;
    margin-top: 18px;
}

.secondary-file-button {
    width: 100%;
    height: 46px;
    border: 1px solid rgba(255,255,255,.1);
    border-radius: 24px;
    background: var(--surface-2);
    display: grid !important;
    place-items: center;
    font-weight: 800;
    cursor: pointer;
}

.secondary-file-button input {
    display: none;
}

.reduced-motion *,
.reduced-motion *::before,
.reduced-motion *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
}

@media (max-width: 600px) {
    .modal-card--wide {
        width: 100%;
    }
}


/* =====================================================
   TERMOO V3.0.2 — TEMA SEM REINÍCIO + DIÁRIO BLOQUEADO
===================================================== */

.desktop-action-button.is-disabled,
.mobile-action-button.is-disabled,
.desktop-action-button:disabled,
.mobile-action-button:disabled {
    cursor: not-allowed;
    opacity: .58;
    filter: grayscale(.18);
    transform: none !important;
}

.desktop-action-button.is-disabled:hover,
.mobile-action-button.is-disabled:hover {
    filter: grayscale(.18);
}


/* =====================================================
   TERMOO V3.0.3 — REVISÃO COMPLETA DO TEMA CLARO
===================================================== */

/*
 * Variáveis semânticas adicionais. Elas evitam textos brancos
 * sobre superfícies claras e centralizam todo o contraste do tema.
 */
:root {
    --surface-primary: #1c2331;
    --surface-secondary: #2a3344;
    --surface-tertiary: #374156;
    --surface-elevated: #202837;

    --text-primary: #ffffff;
    --text-secondary: #c5cedd;
    --text-muted: #8f9aae;

    --button-secondary-bg: #313b4f;
    --button-secondary-text: #ffffff;

    --input-bg: #313a4d;
    --input-text: #ffffff;
    --input-border: rgba(255,255,255,.10);

    --overlay-bg: rgba(4, 9, 17, .72);
    --toast-bg: rgba(25, 31, 43, .96);
    --toast-text: #ffffff;
}

:root[data-theme="light"] {
    --bg-top: #f4f7fb;
    --bg-bottom: #dce4ef;

    --surface: #ffffff;
    --surface-2: #edf2f8;
    --surface-3: #d7e0ec;

    --surface-primary: #ffffff;
    --surface-secondary: #eef3f9;
    --surface-tertiary: #dce5f0;
    --surface-elevated: #ffffff;

    --border: #b5c0cf;

    --text: #1c2637;
    --muted: #5f6b7c;
    --text-primary: #1c2637;
    --text-secondary: #4d596b;
    --text-muted: #758196;

    --button-secondary-bg: #d7e1ef;
    --button-secondary-text: #202a3a;

    --input-bg: #f7f9fc;
    --input-text: #1c2637;
    --input-border: #b9c5d4;

    --overlay-bg: rgba(85, 99, 119, .56);
    --toast-bg: rgba(255,255,255,.97);
    --toast-text: #1c2637;

    --absent: #9a9097;
}

/* Base */
:root[data-theme="light"] body {
    color: var(--text-primary);
    background:
        radial-gradient(circle at top, var(--bg-top), var(--bg-bottom) 78%);
}

:root[data-theme="light"] .brand,
:root[data-theme="light"] .game-meta,
:root[data-theme="light"] .message,
:root[data-theme="light"] .keyboard-row button,
:root[data-theme="light"] .tile,
:root[data-theme="light"] .desktop-action-button,
:root[data-theme="light"] .mobile-action-button {
    color: var(--text-primary);
}

/* Modais e backdrop */
.modal {
    background: var(--overlay-bg);
}

.modal-card {
    color: var(--text-primary);
    background: var(--surface-elevated);
    border-color: rgba(120, 136, 158, .28);
}

.modal-card h2,
.modal-card h3,
.modal-card p,
.modal-card label,
.modal-card strong,
.modal-card span,
.modal-card small {
    color: inherit;
}

:root[data-theme="light"] .modal-card p,
:root[data-theme="light"] .modal-card small,
:root[data-theme="light"] .modal-card .muted {
    color: var(--text-secondary);
}

.modal-close {
    color: var(--text-primary);
}

:root[data-theme="light"] .modal-close:hover {
    background: var(--surface-secondary);
}

/* Selects, inputs e controles */
.modal-card select,
.modal-card input[type="text"],
.modal-card input[type="number"],
.modal-card input[type="email"],
.modal-card textarea {
    color: var(--input-text);
    background: var(--input-bg);
    border-color: var(--input-border);
}

:root[data-theme="light"] .modal-card select option {
    color: #1c2637;
    background: #ffffff;
}

.toggle-row {
    color: var(--text-primary);
}

.toggle-row small {
    color: var(--text-secondary);
}

/* Menu */
.menu-option {
    color: var(--text-primary);
    background: var(--surface-primary);
    border-color: rgba(120, 136, 158, .22);
}

.menu-option:hover {
    background: var(--surface-secondary);
}

.menu-option-icon {
    color: var(--text-primary);
    background: var(--surface-secondary);
}

.menu-option small {
    color: var(--text-secondary);
}

/* Estatísticas, histórico e conquistas */
.stat-card,
.history-item,
.achievement-card {
    color: var(--text-primary);
    background: var(--surface-primary);
    border-color: rgba(120, 136, 158, .22);
}

.stat-card:hover {
    background: var(--surface-secondary);
}

.history-item span,
.history-item time,
.achievement-card small,
.empty-state {
    color: var(--text-secondary);
}

.achievement-icon {
    background: var(--surface-secondary);
}

/* Backup */
.backup-actions {
    color: var(--text-primary);
}

.secondary-file-button,
.confirm-button--cancel,
.mobile-action-button--menu,
.desktop-action-button--menu {
    color: var(--button-secondary-text);
    background: var(--button-secondary-bg);
    border-color: rgba(120, 136, 158, .24);
}

:root[data-theme="light"] .secondary-file-button:hover,
:root[data-theme="light"] .confirm-button--cancel:hover,
:root[data-theme="light"] .mobile-action-button--menu:hover,
:root[data-theme="light"] .desktop-action-button--menu:hover {
    background: #c8d4e4;
}

/* Toast */
.toast {
    color: var(--toast-text);
    background: var(--toast-bg);
    border-color: rgba(120, 136, 158, .28);
}

.toast-text {
    color: var(--toast-text);
}

:root[data-theme="light"] .toast {
    box-shadow: 0 14px 34px rgba(52, 64, 82, .22);
}

:root[data-theme="light"] .toast--error .toast-icon {
    color: #5a1212;
    background: #ff8c8c;
}

:root[data-theme="light"] .toast--success .toast-icon {
    color: #0f3829;
    background: #4ed2a2;
}

:root[data-theme="light"] .toast--warning .toast-icon {
    color: #4c360c;
    background: #e6bd58;
}

:root[data-theme="light"] .toast--info .toast-icon {
    color: #17365c;
    background: #8bbcff;
}

/* Teclado */
:root[data-theme="light"] .keyboard-row button {
    color: #182233;
    background: #d8e1ed;
    border-color: rgba(105, 122, 146, .25);
}

:root[data-theme="light"] .keyboard-row button:hover {
    background: #cbd6e4;
}

:root[data-theme="light"] .keyboard-row button.correct {
    color: #0f3829;
}

:root[data-theme="light"] .keyboard-row button.present {
    color: #4a350b;
}

:root[data-theme="light"] .keyboard-row button.absent {
    color: #f8f9fb;
}

/* Tabuleiros */
:root[data-theme="light"] .tile {
    color: #192334;
    background: rgba(255,255,255,.34);
    border-color: #8f9caf;
}

:root[data-theme="light"] .tile.correct {
    color: #ffffff;
    background: var(--correct);
    border-color: var(--correct);
}

:root[data-theme="light"] .tile.present {
    color: #ffffff;
    background: var(--present);
    border-color: var(--present);
}

:root[data-theme="light"] .tile.absent {
    color: #ffffff;
    background: var(--absent);
    border-color: var(--absent);
}

/* Botões principais */
.primary-button,
.confirm-button--confirm,
.mobile-action-button--new,
.desktop-action-button--new {
    color: #ffffff;
}

:root[data-theme="light"] .primary-button,
:root[data-theme="light"] .confirm-button--confirm,
:root[data-theme="light"] .mobile-action-button--new,
:root[data-theme="light"] .desktop-action-button--new {
    color: #123126;
}

/* Divisores */
:root[data-theme="light"] .settings-divider {
    background: rgba(86, 103, 127, .20);
}

/* Seleção de texto */
:root[data-theme="light"] ::selection {
    color: #ffffff;
    background: #396fc5;
}


/* =====================================================
   TERMOO V3.0.4 — SELETORES PREMIUM SEM SETINHAS
===================================================== */

/*
 * O select nativo continua existindo para a lógica do jogo,
 * mas fica visualmente oculto. O componente premium espelha
 * e altera seu valor.
 */
.native-select--enhanced {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    clip-path: inset(50%) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

.premium-select {
    position: relative;
    width: 100%;
    margin-bottom: 15px;
}

.premium-select-trigger {
    width: 100%;
    min-height: 50px;
    padding: 7px 12px;
    border: 1px solid var(--input-border);
    border-radius: 15px;

    display: grid;
    grid-template-columns: 34px minmax(0, 1fr) auto;
    align-items: center;
    gap: 10px;

    color: var(--input-text);
    background: var(--input-bg);
    text-align: left;
    cursor: pointer;

    box-shadow:
        inset 0 1px 0 rgba(255,255,255,.035),
        0 0 0 0 rgba(69,199,149,0);

    transition:
        border-color .16s ease,
        box-shadow .16s ease,
        transform .16s ease,
        background-color .16s ease;
}

.premium-select-trigger:hover {
    border-color: rgba(69,199,149,.55);
    background: var(--surface-secondary);
}

.premium-select-trigger:focus-visible,
.premium-select.open .premium-select-trigger {
    outline: none;
    border-color: var(--correct);
    box-shadow: 0 0 0 3px rgba(69,199,149,.14);
}

.premium-select-trigger:active {
    transform: scale(.992);
}

.premium-select-icon {
    width: 32px;
    height: 32px;
    border-radius: 10px;

    display: grid;
    place-items: center;

    color: var(--text-primary);
    background: var(--surface-secondary);
    font-size: 14px;
    font-weight: 900;
    letter-spacing: -.04em;
}

.premium-select-value {
    min-width: 0;
    overflow: hidden;
    color: var(--text-primary);
    font-size: 15px;
    font-weight: 750;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.premium-select-hint {
    padding: 5px 8px;
    border-radius: 999px;

    color: var(--text-secondary);
    background: var(--surface-secondary);
    font-size: 10px;
    font-weight: 800;
    letter-spacing: .04em;
    text-transform: uppercase;
}

.premium-select-panel {
    z-index: 2100;
    max-height: min(330px, 52vh);
    padding: 7px;
    overflow-y: auto;

    border: 1px solid rgba(120,136,158,.28);
    border-radius: 16px;

    color: var(--text-primary);
    background: var(--surface-elevated);

    box-shadow:
        0 22px 55px rgba(0,0,0,.34),
        inset 0 1px 0 rgba(255,255,255,.04);

    opacity: 0;
    transform: translateY(-5px) scale(.985);
    transform-origin: top center;

    transition:
        opacity .16s ease,
        transform .16s ease;
}

.premium-select-panel[data-position="above"] {
    transform: translateY(5px) scale(.985);
    transform-origin: bottom center;
}

.premium-select-panel.visible {
    opacity: 1;
    transform: translateY(0) scale(1);
}

.premium-select-option {
    width: 100%;
    min-height: 44px;
    padding: 7px 10px;
    border: 0;
    border-radius: 11px;

    display: grid;
    grid-template-columns: 29px minmax(0, 1fr);
    align-items: center;
    gap: 8px;

    color: var(--text-primary);
    background: transparent;
    text-align: left;
    cursor: pointer;

    transition:
        background-color .13s ease,
        transform .13s ease;
}

.premium-select-option:hover,
.premium-select-option:focus-visible {
    outline: none;
    background: var(--surface-secondary);
}

.premium-select-option:active {
    transform: scale(.988);
}

.premium-select-option.selected {
    color: var(--text-primary);
    background: rgba(69,199,149,.13);
}

.premium-select-option-marker {
    width: 27px;
    height: 27px;
    border-radius: 9px;

    display: grid;
    place-items: center;

    color: #123126;
    background: transparent;
    font-size: 14px;
    font-weight: 900;
}

.premium-select-option.selected .premium-select-option-marker {
    background: var(--correct);
}

.premium-select-option-label {
    overflow: hidden;
    font-size: 14px;
    font-weight: 720;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.premium-select-empty {
    margin: 0;
    padding: 16px 10px;
    color: var(--text-secondary);
    text-align: center;
    font-size: 13px;
}

.premium-select-panel::-webkit-scrollbar {
    width: 7px;
}

.premium-select-panel::-webkit-scrollbar-thumb {
    border-radius: 999px;
    background: var(--surface-tertiary);
}

/* Tema claro */
:root[data-theme="light"] .premium-select-trigger {
    box-shadow:
        inset 0 1px 0 rgba(255,255,255,.72),
        0 0 0 0 rgba(69,199,149,0);
}

:root[data-theme="light"] .premium-select-trigger:hover {
    background: #eef3f9;
}

:root[data-theme="light"] .premium-select-panel {
    border-color: #c2cddd;
    box-shadow:
        0 18px 45px rgba(53,65,84,.22),
        inset 0 1px 0 rgba(255,255,255,.9);
}

:root[data-theme="light"] .premium-select-option.selected {
    background: rgba(69,199,149,.18);
}

/* Ajustes mobile */
@media (max-width: 600px) {
    .premium-select {
        margin-bottom: 13px;
    }

    .premium-select-trigger {
        min-height: 48px;
        border-radius: 14px;
    }

    .premium-select-hint {
        display: none;
    }

    .premium-select-trigger {
        grid-template-columns: 34px minmax(0, 1fr);
    }

    .premium-select-panel {
        max-height: 44vh;
        border-radius: 15px;
    }

    .premium-select-option {
        min-height: 48px;
    }
}


/* =====================================================
   TERMOO V3.0.5 — AJUDA E SELETORES CORRIGIDOS
===================================================== */

/*
 * Como o painel premium agora fica diretamente no body,
 * ele não é cortado pelo modal e aparece acima do backdrop.
 */
.premium-select-panel {
    z-index: 5000 !important;
}

/* Texto do modal Como jogar com contraste reforçado. */
:root[data-theme="light"] .modal-card--help {
    color: #1b2638;
}

:root[data-theme="light"] .modal-card--help p {
    color: #4d5b70;
}

:root[data-theme="light"] .modal-card--help strong {
    color: #28364b;
}

:root[data-theme="light"] .help-divider {
    background: rgba(70, 88, 112, .20);
}

/*
 * As letras dos exemplos precisam continuar brancas sobre
 * os quadrados escuros, mesmo quando o tema geral é claro.
 */
:root[data-theme="light"] .help-tile {
    color: #ffffff;
    background: #202a3a;
    border-color: #6f7d92;
    text-shadow: 0 1px 1px rgba(0,0,0,.25);
}

:root[data-theme="light"] .help-tile.correct {
    color: #0f3829;
    background: var(--correct);
    border-color: var(--correct);
    text-shadow: none;
}

:root[data-theme="light"] .help-tile.present {
    color: #4a350b;
    background: var(--present);
    border-color: var(--present);
    text-shadow: none;
}

:root[data-theme="light"] .help-tile.absent {
    color: #ffffff;
    background: #827980;
    border-color: #827980;
}

:root[data-theme="light"] .help-signature {
    color: #435168;
}

/* Painel mais legível no tema claro. */
:root[data-theme="light"] .premium-select-panel {
    color: #1b2638;
    background: #ffffff;
    border-color: #b8c5d6;
}

:root[data-theme="light"] .premium-select-option {
    color: #1b2638;
}

:root[data-theme="light"] .premium-select-option:hover,
:root[data-theme="light"] .premium-select-option:focus-visible {
    background: #edf3f9;
}

:root[data-theme="light"] .premium-select-option.selected {
    background: rgba(69,199,149,.20);
}

/* Evita seleção acidental do texto dos gatilhos. */
.premium-select-trigger,
.premium-select-option {
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}


/* =====================================================
   TERMOO V3.0.6 — DESAFIO DIÁRIO PROTEGIDO
===================================================== */

.desktop-action-button.is-disabled,
.mobile-action-button.is-disabled {
    cursor: not-allowed;
}

.desktop-action-button.is-disabled span:first-child,
.mobile-action-button.is-disabled span:first-child {
    opacity: .65;
}


/* =====================================================
   TERMOO V3.1 — POLIMENTO PREMIUM
===================================================== */

.stats-modal-card {
    max-height: min(780px, calc(100dvh - 28px));
    overflow-y: auto;
}

.stats-intro {
    margin: -4px 0 18px;
    color: var(--text-secondary);
    line-height: 1.45;
}

.stats-modal-card .stats-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.stats-modal-card .stat-card {
    min-height: 84px;
    padding: 13px 8px;
    display: grid;
    place-items: center;
    align-content: center;
    text-align: center;
}

.stats-modal-card .stat-card strong {
    font-size: clamp(22px, 4vw, 30px);
    line-height: 1;
}

.stats-modal-card .stat-card span {
    margin-top: 7px;
    color: var(--text-secondary);
    font-size: 11px;
    line-height: 1.2;
}

.stats-section {
    margin-top: 20px;
    padding-top: 18px;
    border-top: 1px solid rgba(120,136,158,.20);
}

.stats-section h3 {
    margin-bottom: 12px;
    font-size: 15px;
}

.mode-stats-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
}

.mode-stats-grid > div {
    min-height: 66px;
    padding: 10px 6px;
    border-radius: 13px;
    display: grid;
    place-items: center;
    align-content: center;
    background: var(--surface-secondary);
}

.mode-stats-grid strong {
    font-size: 21px;
}

.mode-stats-grid span {
    margin-top: 4px;
    color: var(--text-secondary);
    font-size: 10px;
    text-align: center;
}

.stats-activity {
    height: 150px;
    padding: 10px 6px 0;
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    align-items: end;
    gap: 7px;
    border-radius: 14px;
    background: var(--surface-primary);
}

.activity-column {
    height: 100%;
    min-width: 0;
    display: grid;
    grid-template-rows: 18px minmax(60px, 1fr) 22px;
    align-items: end;
    text-align: center;
}

.activity-column strong {
    color: var(--text-secondary);
    font-size: 10px;
}

.activity-column small {
    align-self: center;
    color: var(--text-secondary);
    font-size: 9px;
    text-transform: capitalize;
}

.activity-track {
    width: min(24px, 72%);
    height: 100%;
    margin: 0 auto;
    border-radius: 8px 8px 3px 3px;
    display: flex;
    align-items: flex-end;
    overflow: hidden;
    background: var(--surface-secondary);
}

.activity-bar {
    width: 100%;
    min-height: 8px;
    border-radius: 7px 7px 2px 2px;
    background: linear-gradient(
        180deg,
        #62ddb0,
        var(--correct)
    );
    transition: height .35s ease;
}

.history-summary {
    margin-bottom: 12px;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.history-summary span {
    padding: 10px 6px;
    border-radius: 12px;
    display: grid;
    text-align: center;
    color: var(--text-secondary);
    background: var(--surface-secondary);
    font-size: 10px;
}

.history-summary strong {
    color: var(--text-primary);
    font-size: 19px;
}

.history-items {
    display: grid;
    gap: 9px;
}

.history-item {
    position: relative;
    overflow: hidden;
}

.history-item::before {
    content: "";
    position: absolute;
    inset: 0 auto 0 0;
    width: 4px;
    background: var(--danger);
}

.history-item--win::before {
    background: var(--correct);
}

.history-item-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.history-badge {
    padding: 4px 8px;
    border-radius: 999px;
    font-size: 9px;
    font-weight: 900;
    text-transform: uppercase;
}

.history-badge--win {
    color: #123126;
    background: var(--correct);
}

.history-badge--loss {
    color: #ffffff;
    background: var(--danger);
}

.achievement-progress {
    grid-column: 1 / -1;
    margin-bottom: 4px;
    padding: 14px;
    border-radius: 14px;
    display: flex;
    align-items: baseline;
    gap: 7px;
    background: var(--surface-secondary);
}

.achievement-progress strong {
    color: var(--correct);
    font-size: 24px;
}

.achievement-progress span {
    color: var(--text-secondary);
    font-size: 12px;
}

.celebration-layer {
    position: fixed;
    z-index: 8000;
    inset: 0;
    overflow: hidden;
    pointer-events: none;
    opacity: 0;
}

.celebration-layer.active {
    opacity: 1;
}

.confetti-piece {
    position: absolute;
    top: -24px;
    left: var(--confetti-x);
    width: 9px;
    height: 15px;
    border-radius: 2px;
    background: var(--correct);
    animation:
        confetti-fall
        var(--confetti-duration)
        cubic-bezier(.18,.78,.34,1)
        var(--confetti-delay)
        forwards;
}

.confetti-piece[data-variant="1"] {
    background: var(--present);
}

.confetti-piece[data-variant="2"] {
    background: #7aa7ff;
}

.confetti-piece[data-variant="3"] {
    background: #f0809a;
}

.confetti-piece[data-variant="4"] {
    background: #ffffff;
}

@keyframes confetti-fall {
    0% {
        transform:
            translate3d(0, -30px, 0)
            rotate(0);
        opacity: 0;
    }

    8% {
        opacity: 1;
    }

    100% {
        transform:
            translate3d(
                var(--confetti-drift),
                calc(100dvh + 60px),
                0
            )
            rotate(var(--confetti-rotate));
        opacity: .9;
    }
}

.victory-flash body {
    animation: victory-screen-flash .42s ease;
}

@keyframes victory-screen-flash {
    50% {
        filter: brightness(1.14);
    }
}

:root[data-theme="light"] .stats-activity,
:root[data-theme="light"] .history-item {
    border-color: rgba(90,108,132,.20);
}

@media (max-width: 600px) {
    .stats-modal-card .stats-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .mode-stats-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .stats-activity {
        height: 132px;
        gap: 4px;
    }

    .activity-track {
        width: min(20px, 78%);
    }

    .history-summary {
        gap: 5px;
    }

    .history-summary span {
        padding: 9px 3px;
    }
}
