@import url('https://fonts.googleapis.com/css2?family=Oxanium:wght@200..800&display=swap');

/* =========================================================================
   TEMA  (claro por padrão; body.dark-mode sobrescreve)
   Sistema de cores:
     verde  = ação principal / dificuldade FÁCIL
     âmbar  = destaque / dificuldade MÉDIO / placar
     coral  = dificuldade DIFÍCIL
   ========================================================================= */
:root {
    /* superfícies */
    --bg: #f3f5fb;
    --surface: #ffffff;
    --surface-2: #eaecf4;
    --text: #1a1c24;
    --text-dim: #6b6f80;
    --border: #e2e5ef;

    /* marca / ações */
    --accent: #3596C7;
    --accent-press: #2a7bb8;
    --accent-soft: #edf6e6;

    /* dificuldade */
    --easy: #5F9126;
    --easy-press: #4c7720;
    --medium: #e0971a;
    --medium-press: #c47f10;
    --hard: #e05656;
    --hard-press: #c63f3f;

    /* status */
    --gold: #f1b211;
    --correct: #2ecc71;
    --wrong: #e74c3c;

    --key-text: #ffffff;
    --disabled: #d8dbe6;
    --disabled-text: #9aa0b0;
}

body.dark-mode {
    --bg: #0b0c11;
    --surface: #15161e;
    --surface-2: #1f2129;
    --text: #f3f4fa;
    --text-dim: #969aab;
    --border: #282b37;

    --accent: #3596C7;
    --accent-press: #2a7bb8;
    --accent-soft: #1b2a13;

    --easy: #6aa12c;
    --easy-press: #588a25;
    --medium: #e3a52b;
    --medium-press: #c98a18;
    --hard: #ea6a6a;
    --hard-press: #d34f4f;

    --gold: #f1b211;
    --correct: #34d27f;
    --wrong: #ff5b4a;

    --disabled: #23252f;
    --disabled-text: #555a68;


}

/* ===== Reset / base ===== */
* {
    box-sizing: border-box;
}

.hidden {
    display: none !important;
}

::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border);

}

html,
body {
    height: 100%;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: "Oxanium", sans-serif;
    -webkit-user-select: none;
    -moz-user-select: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    transition: background .25s, color .25s;
    overflow-x: hidden;
}

/* ===== Topbar ===== */
#topbar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    height: 52px;
    border-top: 1px solid var(--border);
    z-index: 60;
}

.topbar-right {
    display: flex;
    width: 100%;
}

.icon-btn {
    flex: 1;
    height: 100%;
    background: var(--surface);
    color: var(--text);
    border: none;
    border-left: 1px solid var(--border);
    cursor: pointer;
    font-size: 19px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .2s;
}

.icon-btn:first-child {
    border-left: none;
}

.icon-btn:hover {
    background: var(--surface-2);
}

#leaderboard-button {
    color: var(--gold);
}

/* ===== Modal de configurações ===== */
.config-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 8px;
}

.config-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    padding: 14px 16px;
}

.config-label {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    font-size: 16px;
}

.config-label i {
    color: var(--accent);
    width: 20px;
    text-align: center;
}

.theme-btn {
    width: 46px;
    height: 46px;
    background: var(--surface-2);
    color: var(--text);
    border: 1px solid var(--border);
    cursor: pointer;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .2s, transform .12s;
}

.theme-btn:hover {
    transform: scale(1.06);
}

.config-credit {
    color: var(--accent);
    text-decoration: none;
    font-size: 16px;
}

.config-select {
    background: var(--surface-2);
    color: var(--text);
    border: 1px solid var(--border);
    padding: 8px 12px;
    font-family: inherit;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    outline: none;
}

.config-version {
    text-align: center;
    color: var(--text-dim);
    font-size: 13px;
    margin: 18px 0 0;
}

/* ===== Telas (largura base mobile; cada tela expande no PC) ===== */
.screen {
    width: 100%;
  
    margin: 0 auto;
    padding: 32px 16px 84px;
    min-height: 100vh;
}

/* =========================================================================
   TELA 1: OPERAÇÕES
   ========================================================================= */
.logo-img {
    display: block;
    width: 100%;
    height: auto;
    margin: 4px auto 8px;
    margin-bottom: 20px;
}

.logo-dark {
    display: none;
}

.logo-light {
    display: block;
}

body.dark-mode .logo-dark {
    display: block;
}

body.dark-mode .logo-light {
    display: none;
}



.screen-sub {
    text-align: center;
    color: var(--text-dim);
    font-size: 15px;
    margin: 0 0 24px;
}

.cat-label {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--text-dim);
    font-weight: 700;
    margin: 0 0 10px 2px;
}

.op-sections {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* cada dificuldade vira um card */
.op-section {}

.op-section .cat-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text);
    margin: 0 0 12px;
}

/* bolinha colorida = sinaliza o nível num olhar */
.op-section .cat-label::before {
    content: '';
    width: 10px;
    height: 10px;
    flex: none;
}

.lvl-easy .cat-label::before {
    background: var(--easy);
}

.lvl-medium .cat-label::before {
    background: var(--medium);
}

.lvl-hard .cat-label::before {
    background: var(--hard);
}

.op-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.op-btn {
    display: flex;
    align-items: center;
    gap: 11px;
    min-height: 56px;
    padding: 10px 14px;
    border: none;
    background: var(--easy);
    color: #fff;
    font-family: inherit;
    font-size: 15px;
    font-weight: 700;
    line-height: 1.15;
    text-align: left;
    cursor: pointer;
    transition: transform .12s ease, background .15s;
}

/* ícone num "chip" translúcido — dá hierarquia e fica fácil de escanear */
.op-btn i {
    flex: none;
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    background: rgba(255, 255, 255, .22);
    font-size: 15px;
    clip-path: polygon(0 0, calc(100% - 10px) 0, 100% 10px, 100% 100%, 0 100%);
}


.op-btn span {
    flex: 1;
}

.op-btn.wide {
    grid-column: 1 / -1;
}

.op-btn:hover {
        clip-path: polygon(0 0, calc(100% - 10px) 0, 100% 10px, 100% 100%, 0 100%);

}

.op-btn:active {
    transform: translateY(0) scale(.98);
}

.op-btn:focus-visible {
    outline: 3px solid var(--text);
    outline-offset: 2px;
}

/* cores por dificuldade */
.lvl-easy .op-btn {
    background: var(--easy);
}

.lvl-easy .op-btn:hover {
    background: var(--easy-press);
}

.lvl-medium .op-btn {
    background: var(--medium);
}

.lvl-medium .op-btn:hover {
    background: var(--medium-press);
}


.lvl-hard .op-btn {
    background: var(--hard);
}

.lvl-hard .op-btn:hover {
    background: var(--hard-press);
}

/* =========================================================================
   TELA 2: TEMPO
   ========================================================================= */
.time-title {
    text-align: center;
    font-size: 24px;
    font-weight: 800;
    margin: 8px 0 26px;
    color: var(--text);
}

.time-title>span:first-child {
    color: var(--text);
}

#time-op-name {
    color: var(--accent);
}

#time-op-name.lvl-easy {
    color: var(--easy);
}

#time-op-name.lvl-medium {
    color: var(--medium);
}

#time-op-name.lvl-hard {
    color: var(--hard);
}

.time-layout {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.time-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 10px;
}

.time-btn {
    padding: 18px 6px;
    border: none;
    background: var(--accent);
    color: #fff;
    font-family: inherit;
    font-size: 17px;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    transition: transform .1s, background .15s;
}

.time-btn i {
    opacity: .8;
}

.time-btn:hover {
    background: var(--accent-press);
    clip-path: polygon(0 0, calc(100% - 10px) 0, 100% 10px, 100% 100%, 0 100%);

    
}

.time-btn.selected {
    transform: translateY(0) scale(.98);
    background: var(--correct);
    clip-path: polygon(0 0, calc(100% - 20px) 0, 100% 20px, 100% 100%, 0 100%);
}

.time-btn.selected:hover {
    background: var(--correct);
}

/* barra "Voltar + Jogar" no rodapé da tela de tempo */
.time-actions {
    display: flex;
    gap: 10px;
    margin-top: 22px;
    align-items: stretch;
}

.time-actions .ghost-btn {
    margin: 0;
    flex: 0 0 auto;
}

.play-btn {
    flex: 1;
    padding: 14px;
    border: none;
    background: var(--correct);
    color: #fff;
    font-family: inherit;
    font-size: 17px;
    font-weight: 700;
    cursor: pointer;
    transition: filter .15s;
}

.play-btn:hover:not(:disabled) {
    filter: brightness(1.08);
}

.play-btn:disabled {
    background: var(--disabled);
    color: var(--disabled-text);
    cursor: default;
}

/* tempo personalizado (accordion) */
.custom-time {
    margin-top: 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    overflow: hidden;
}

.ct-toggle {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    background: transparent;
    border: none;
    cursor: pointer;
    font-family: inherit;
    font-weight: 700;
    font-size: 16px;
    color: var(--text);
}

.ct-toggle span i {
    color: var(--accent);
    margin-right: 6px;
}

.ct-chevron {
    color: var(--text-dim);
    transition: transform .3s;
}

#custom-time.open .ct-chevron {
    transform: rotate(180deg);
}

.ct-body {
    max-height: 0;
    overflow: hidden;
    padding: 0 16px;
    transition: max-height .32s ease;
}

#custom-time.open .ct-body {
    max-height: 220px;
    padding-bottom: 16px;
}

.stepper {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.step-btn {
    width: 48px;
    height: 48px;
    border: none;
    background: var(--accent);
    color: #fff;
    font-size: 26px;
    font-weight: 700;
    cursor: pointer;
    line-height: 1;
}

.step-btn:active {
    background: var(--accent-press);
}

#ct-value {
    width: 90px;
    height: 48px;
    text-align: center;
    font-size: 26px;
    font-weight: 700;
    font-family: inherit;
    background: var(--bg);
    color: var(--text);
    border: 2px solid var(--border);

    outline: none;
}

.ct-unit {
    font-size: 20px;
    color: var(--text-dim);
    font-weight: 700;
}

.time-start {
    width: 100%;
    margin-top: 14px;
    padding: 14px;
    border: none;

    background: var(--correct);
    color: #fff;
    font-family: inherit;
    font-size: 18px;
    font-weight: 700;
    cursor: pointer;
}

.time-start:active {
    filter: brightness(.92);
}

/* bônus = ajustes (cartão neutro, não botão de ação) */
.bonus-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.bonus-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text);

    padding: 12px 14px;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    line-height: 1.2;
    transition: border-color .2s, background .2s;
}

.bonus-row:has(.switch:checked) {
    border-color: var(--accent);
    background: var(--accent-soft);
}

.bonus-info {
    display: flex;
    align-items: center;
    gap: 9px;
}

.bonus-info i {
    color: var(--accent);
    width: 18px;
    text-align: center;
    flex: none;
}

.switch {
    appearance: none;
    -webkit-appearance: none;
    width: 44px;
    height: 24px;

    background: var(--surface-2);
    border: 1px solid var(--border);
    position: relative;
    cursor: pointer;
    flex-shrink: 0;
    transition: background .2s, border-color .2s;
}

.switch::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 18px;
    height: 18px;

    background: #fff;
    transition: left .2s;
}

.switch:checked {
    background: var(--correct);
    border-color: var(--correct);
}

.switch:checked::after {
    left: 22px;
}

.ghost-btn {
    display: block;
    margin: 22px auto 0;
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-dim);
    padding: 12px 28px;

    cursor: pointer;
    font-family: inherit;
    font-size: 16px;
    font-weight: 700;
}

.ghost-btn:hover {
    background: var(--surface);
    color: var(--text);
}

/* =========================================================================
   TELA 3: JOGO
   ========================================================================= */
#screen-game {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    /* altura travada: o rascunho cresce/encolhe sem empurrar o resto */
    overflow: hidden;
    padding-bottom: 64px;
}

#hud {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-bottom: 10px;
}

.hud-item {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    min-width: 72px;
    background: var(--surface);
    border: 1px solid var(--border);

    padding: 7px 14px;
    font-size: 18px;
    font-weight: 700;
}

.hud-item i {
    font-size: 15px;
}

.hud-correct {
    color: var(--correct);
}

.hud-wrong {
    color: var(--wrong);
}

#time-bar-wrap {
    width: 100%;
    height: 10px;
    background: var(--surface-2);

    overflow: hidden;
    margin-bottom: 18px;
}

#time-bar {
    height: 100%;
    width: 100%;
    background: var(--accent);

    transition: width .2s linear, background .25s;
}

#problem-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 14px;
}

#problem-text {
    font-size: clamp(24px, 7vw, 34px);
    font-weight: 800;
    white-space: nowrap;
}

#answer-input {
    flex: 1;
    min-width: 0;
    font-size: 26px;
    font-weight: 700;
    text-align: center;
    padding: 12px;
    border: 2px solid var(--border);

    background: var(--surface);
    color: var(--text);
    font-family: inherit;
    outline: none;
    transition: border-color .2s, background .2s;
}

#answer-input:focus {
    border-color: var(--accent);
}

#problem-row.correct #answer-input {
    border-color: var(--correct);
    background: var(--accent-soft);
}

#problem-row.wrong #answer-input {
    border-color: var(--wrong);
    animation: shake .3s;
}

@keyframes shake {

    0%,
    100% {
        transform: translateX(0)
    }

    25% {
        transform: translateX(-7px)
    }

    75% {
        transform: translateX(7px)
    }
}

#backspace-btn {
    width: 54px;
    height: 54px;
    flex: none;
    border: none;

    background: var(--surface-2);
    color: var(--text);
    font-size: 20px;
    cursor: pointer;
}

#backspace-btn:active {
    background: var(--border);
}

#game-actions {
    display: flex;
    gap: 10px;
    margin-bottom: 12px;
}

#finish-btn {
    flex: 1;
    padding: 13px;
    border: none;

    background: var(--accent);
    color: #fff;
    font-family: inherit;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
}

#finish-btn:hover {
    background: var(--accent-press);
}

#toggle-keypad {
    width: 56px;
    border: none;

    background: var(--accent);
    color: #fff;
    font-size: 18px;
    cursor: pointer;
}

#toggle-keypad.off {
    background: var(--surface-2);
    color: var(--text-dim);
}

#scratch-wrap {
    position: relative;
    /* base 0 + min-height 0: a altura vem só do espaço livre do flex,
       não do tamanho do canvas (senão não encolhia ao mostrar o teclado) */
    flex: 1 1 0;
    min-height: 0;
    background: var(--surface);
    border: 1px solid var(--border);

    overflow: hidden;
    margin-bottom: 12px;
}

#scratch-pad {
    /* fora do fluxo: nunca influencia a altura do wrap */
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    touch-action: none;
    cursor: crosshair;
}

#clear-scratch {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 40px;
    height: 40px;
    border: none;

    background: var(--accent);
    color: #fff;
    font-size: 16px;
    cursor: pointer;
}

#clear-scratch:active {
    background: var(--accent-press);
}

#keypad {
    /* flutua por cima do rodapé do canvas: o rascunho não muda de tamanho */
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    padding: 10px;
    background: var(--bg);
    border-top: 1px solid var(--border);
    z-index: 2;
}

body.keypad-hidden #keypad {
    display: none;
}

/* teclado neutro tipo calculadora — menos "parede verde", mais legível */
.key {
    padding: 18px 0;
    border: 1px solid var(--border);

    background: var(--surface);
    color: var(--text);
    font-family: inherit;
    font-size: 24px;
    font-weight: 700;
    cursor: pointer;
    transition: transform .05s, background .15s;
}

.key:active {
    transform: scale(.95);
    background: var(--surface-2);
}

/* operadores em destaque (sinal e vírgula) */
.key-sign,
.key-dot {
    color: var(--accent);
}

.key.disabled {
    background: var(--disabled);
    color: var(--disabled-text);
    border-color: transparent;
    pointer-events: none;
}

/* =========================================================================
   TELA 4: RESUMO
   ========================================================================= */
.summary-title {
    text-align: center;
    font-size: 24px;
    font-weight: 800;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--border);
    margin: 8px 0 20px;
}

.summary-layout {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.summary-col-left,
.summary-col-right {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.summary-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

.stat-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    background: var(--surface);
    border: 1px solid var(--border);

    padding: 14px 8px;
}

.sc-icon {
    font-size: 17px;
    color: var(--text-dim);
}

.ic-correct {
    color: var(--correct);
}

.ic-wrong {
    color: var(--wrong);
}

.ss-label {
    font-size: 13px;
    color: var(--text-dim);
}

.ss-val {
    font-size: 30px;
    font-weight: 800;
    line-height: 1;
}

.correct-c {
    color: var(--correct);
}

.wrong-c {
    color: var(--wrong);
}

#save-area {
    background: var(--surface);
    border: 1px solid var(--border);

    padding: 16px;
    text-align: center;
}

#player-name-input {
    width: 100%;
    padding: 12px;
    font-size: 16px;
    text-align: center;
    border: 2px solid var(--border);

    background: var(--bg);
    color: var(--text);
    font-family: inherit;
    outline: none;
    margin-bottom: 10px;
}

#player-name-input:focus {
    border-color: var(--accent);
}

#save-score-btn {
    width: 100%;
    padding: 13px;
    border: none;

    background: var(--gold);
    color: #2a2200;
    font-family: inherit;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
}

#save-score-btn:active {
    filter: brightness(.95);
}

#save-score-btn:disabled {
    background: var(--disabled);
    color: var(--disabled-text);
    cursor: default;
}

#save-status {
    font-size: 14px;
    color: var(--text-dim);
    margin: 8px 0 0;
    min-height: 18px;
}

.history-label {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--text-dim);
    font-weight: 700;
    margin: 0 0 4px 2px;
}

#history-list {
    max-height: 42vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding-right: 2px;
}

.hist-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 9px 12px;

    background: var(--surface);
    border: 1px solid var(--border);
    font-size: 16px;
}

.hist-item .h-q {
    font-weight: 700;
}

.hist-item .h-a {
    color: var(--text-dim);
}

.hist-item.ok {
    border-left: 4px solid var(--correct);
}

.hist-item.no {
    border-left: 4px solid var(--wrong);
}

.hist-item.no .h-a b {
    color: var(--wrong);
    text-decoration: line-through;
}

.summary-buttons {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.summary-buttons button {
    padding: 14px;
    border: none;

    background: var(--accent);
    color: #fff;
    font-family: inherit;
    font-size: 17px;
    font-weight: 700;
    cursor: pointer;
}

.summary-buttons button:hover {
    filter: brightness(1.05);
}

.summary-buttons button.secondary {
    background: transparent;
    color: var(--text);
    border: 1px solid var(--border);
}

.summary-buttons button.secondary:hover {
    background: var(--surface);
    filter: none;
}

/* =========================================================================
   POPUP DO PLACAR
   ========================================================================= */
.popup {
    position: fixed;
    inset: 0;
    z-index: 100;
    background: rgba(0, 0, 0, .55);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 14px;
}

.popup-content {
    background: var(--bg);
    color: var(--text);
    border: 1px solid var(--border);

    padding: 22px;
    width: 100%;
    max-width: 1080px;
    animation: pop .22s ease;
}

#leaderboard-popup .popup-content{
    height:calc(100dvh - 40px);
}

@keyframes pop {
    from {
        transform: scale(.92);
        opacity: 0
    }

    to {
        transform: scale(1);
        opacity: 1
    }
}

.leaderboard-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.leaderboard-head h2 {
    margin: 0;
    font-size: 22px;
    color: var(--gold);
}

.close-x {
    background: transparent;
    border: none;
    color: var(--text-dim);
    font-size: 24px;
    cursor: pointer;
}

.lb-filter-row {
    display: flex;
    gap: 8px;
    margin-bottom: 14px;
    flex-wrap: wrap;
}

.lb-filter-row input,
.lb-filter-row select {
    flex: 1;
    min-width: 120px;
    padding: 10px;
    border: 1px solid var(--border);

    background: var(--surface);
    color: var(--text);
    font-family: inherit;
    font-size: 15px;
    outline: none;
}

.lb-filter-row input:focus,
.lb-filter-row select:focus {
    border-color: var(--accent);
}

.lb-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 22px;
    height: 22px;
    padding: 0 7px;
    margin-left: 8px;

    background: var(--surface-2);
    color: var(--text-dim);
    font-size: 13px;
    font-weight: 700;
    vertical-align: middle;
}

#leaderboard-list {
    max-height: 56vh;
    overflow-y: auto;
    overflow-x: auto;
}

.leaderboard-table {
    width: 100%;
    min-width: 540px;
    border-collapse: collapse;
}

.lb-correct b {
    color: var(--correct);
}

.lb-wrong {
    color: var(--wrong);
}

.lb-bonus {
    white-space: nowrap;
}

.lb-bonus-i {
    color: var(--accent);
    margin: 0 2px;
    font-size: 12px;
}

.lb-dash {
    color: var(--text-dim);
}

.leaderboard-table th,
.leaderboard-table td {
    padding: 9px 6px;
    text-align: center;
    font-size: 14px;
}

.leaderboard-table thead th {
    position: sticky;
    top: 0;
    background: var(--bg);
    border-bottom: 2px solid var(--border);
    color: var(--text-dim);
}

.lb-name {
    text-align: left !important;
    font-weight: 700;
}

.lb-row:nth-child(even) {
    background: var(--surface);
}

.lb-pos {
    font-weight: 900;
    width: 34px;
}

.lb-row.highlight-new {
    animation: flash 1.4s ease;
    font-weight: 700;
}

@keyframes flash {

    0%,
    100% {
        background: transparent
    }

    30% {
        background: var(--accent-soft)
    }
}

.no-scores {
    padding: 30px;
    text-align: center;
    color: var(--text-dim);
}

/* =========================================================================
   MENSAGENS DE CONEXÃO / ALERTAS / FOOTER
   ========================================================================= */
.connection-message {
    text-align: center;
    font-size: 13px;
    font-weight: 600;
    padding: 0 12px;

    background: var(--surface);
    border: 1px solid var(--border);

    margin: 0;
    opacity: 0;
    max-height: 0;
    overflow: hidden;
    transition: opacity .4s, max-height .4s, margin .4s, padding .4s;
}

.connection-message.show {
    opacity: 1;
    max-height: 60px;
    margin-top: 16px;
    margin-bottom: 20px;
    padding: 10px 12px;
}

.offline-msg {
    border-left: 4px solid var(--wrong);
    color: var(--wrong);
}

.online-msg {
    border-left: 4px solid var(--correct);
    color: var(--correct);
}

#customAlertNoScore {
    position: fixed;
    top: 70px;
    left: 50%;
    transform: translateX(-50%) translateY(-20px);
    background: var(--gold);
    color: #2a2200;
    padding: 14px 22px;

    font-weight: 700;
    z-index: 200;
    opacity: 0;
    pointer-events: none;
    transition: opacity .3s, transform .3s;
}

#customAlertNoScore.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

footer {
    text-align: center;
    margin-top: 28px;
    color: var(--text-dim);
    font-size: 13px;
}

/* dica de teclado físico: só no PC (ver media query abaixo) */
.pc-hint {
    display: none;
}

/* =========================================================================
   RESPONSIVO
   ========================================================================= */

/* ----- Telefones pequenos ----- */
@media (max-width: 380px) {
    .op-btn {
        font-size: 13px;
        gap: 9px;
        padding: 10px 11px;
    }

    .op-btn i {
        width: 30px;
        height: 30px;
    }

    .summary-stats {
        gap: 8px;
    }

    .ss-val {
        font-size: 26px;
    }

}

/* ----- Telefones pequenos ----- */
@media (max-width: 450px) {
    
    .bonus-row{
        flex-direction: column;
    }

    .switch{
        width: 100%;
    }

    /* como a largura agora é 100%, o "left: 22px" fixo deixa a bolinha no
       meio; usa calc no left (em vez de right) pra ir até o fim
       mantendo a transição deslizante */
    .switch:checked::after{
        left: calc(100% - 20px);
    }
}

/* ----- Tablet / Desktop: aproveita o espaço horizontal -----
   As telas deixam de ser uma coluna estreita e abrem em grade. */
@media (min-width: 760px) {

    /* Operações: 3 dificuldades lado a lado (Fácil | Médio | Difícil) */
    #screen-operations {
        max-width: 1080px;
    }

    .op-sections {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: 10px;
        align-items: start;
    }

    .op-section .op-grid {
        grid-template-columns: 1fr;
    }

    .op-section .op-btn.wide {
        grid-column: auto;
    }

    /* Tempo: presets à esquerda, bônus à direita */
    #screen-time {
        max-width: 1080px;
    }

    .time-layout {
        display: grid;
        grid-template-columns: 1.1fr .9fr;
        gap: 24px;
        align-items: start;
    }

    /* Resumo: estatísticas/ações à esquerda, histórico à direita */
    #screen-summary {
        max-width: 1080px;
    }
    
    .summary-layout {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 24px;
        align-items: start;
    }

    #history-list {
        max-height: 56vh;
    }
}

/* ----- No PC (mouse): sem teclado na tela e sem rascunho =====
   desenhar com mouse é ruim e o teclado físico já tem números, - e , */
@media (min-width: 769px) {

    #keypad,
    #scratch-wrap,
    #toggle-keypad,
    #backspace-btn {
        display: none !important;
    }

    /* a tela não precisa ocupar 100% da altura sem o rascunho */
    #screen-game {
        height: auto;
        min-height: 100vh;
        overflow: visible;
        justify-content: flex-start;
        padding-top: 32px;
        max-width: 620px;
    }

    /* conta vira um cartão grande e centrado: foco total no problema */
    #problem-row {
        
        gap: 18px;
        margin-top: 18px;
        padding: 30px;
        background: var(--surface);
        border: 1px solid var(--border);

    }

    #problem-text {
        font-size: 42px;
    }

    #answer-input {
        width: 100%;
        font-size: 32px;
        padding: 16px;
    }

    .pc-hint {
        display: block;
        text-align: center;
        color: var(--text-dim);
        font-size: 15px;
        margin-top: 16px;
    }

    .pc-hint kbd {
        background: var(--surface-2);
        border: 1px solid var(--border);

        padding: 2px 8px;
        font-family: inherit;
        font-weight: 700;
        color: var(--text);
    }
}