* { box-sizing: border-box; }
html, body {
    margin: 0; padding: 0;
    background: #000;
    width: 100vw; height: 100vh;
    overflow: hidden;
    font-family: system-ui, sans-serif;
    color: #ccc;
}
#stage {
    position: relative;
    width: 100vw; height: 100vh;
    background: #000;
    overflow: hidden;
}
canvas {
    display: block;
    /* width/height setados via JS pra match com pixels físicos (DPR-aware).
     * Letterbox 4:3 é desenhado DENTRO do canvas (barras pretas integradas). */
    image-rendering: -webkit-optimize-contrast;  /* Chrome/Edge — melhor pra HD */
    image-rendering: crisp-edges;                 /* Firefox */
}

/* HUD debug (#info / #controls / Tab toggle) foi removido — o jogo agora
 * tem painel inferior dedicado (#bottom-bar) e os textos do EXE no canvas
 * (Insira Créditos, Aperte JOGAR, etc) são suficientes pro UX. */

/* ============================================================
 * Overlay "vire o celular" — mostra em mobile portrait
 * ============================================================ */
#rotate-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: #000;
    z-index: 99999;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    color: #FFD700;
    font-family: Arial, sans-serif;
    text-align: center;
}
#rotate-overlay .icon {
    font-size: 80px;
    margin-bottom: 20px;
    animation: rotatePhone 2s ease-in-out infinite;
}
#rotate-overlay .text {
    font-size: 22px;
    font-weight: bold;
}
@keyframes rotatePhone {
    0%, 100% { transform: rotate(0deg); }
    50% { transform: rotate(90deg); }
}
@media screen and (orientation: portrait) and (max-width: 1024px) {
    #rotate-overlay { display: flex; }
    #stage, #btn-fullscreen, #btn-home, .side-rail { display: none !important; }
}

/* ============================================================
 * Overlays HOME + FULLSCREEN (mesmo padrao do SB3)
 * Botoes fixed no topo. Dourados, com filter drop-shadow.
 * Em fullscreen mode, fullscreen btn esconde. Side-rails ativos:
 * empurrar pra dentro pra nao sobrepor.
 * ============================================================ */
/* Botoes posicionados via JS (mesmo padrao SB3 — mede canvas real). */
#btn-home, #btn-fullscreen {
    position: fixed;
    z-index: 9999;
    width: 44px;
    height: 44px;
    background: transparent;
    border: none;
    padding: 4px;
    cursor: pointer;
    filter: drop-shadow(0 0 3px rgba(0,0,0,0.95));
    display: none;
    align-items: center;
    justify-content: center;
}
#btn-home.game-ready,
#btn-fullscreen.game-ready { display: flex; }
#btn-home svg, #btn-fullscreen svg { width: 100%; height: 100%; }

/* Em fullscreen, esconde o botao de tela cheia (ja esta em tela cheia) */
:fullscreen #btn-fullscreen { display: none; }
:-webkit-full-screen #btn-fullscreen { display: none; }
:-moz-full-screen #btn-fullscreen { display: none; }

/* ============================================================
 * BOTÕES SLOT-MACHINE — visual compartilhado entre side-rails (mobile)
 * e bottom-bar (desktop). Estilos aqui aplicam SEMPRE; só layout
 * (position fixed, larguras) fica nas media queries específicas.
 * ============================================================ */
:root {
    --rail-left-width: 0px;
    --rail-right-width: 0px;
}

.side-rail { display: none; }

/* Botao slot-machine — moldura cromo + bevel (vale pra rails E bottom-bar) */
.rail-btn {
    --btn-tint: rgba(0,0,0,0);
    --btn-base: #353535;
    flex: 1;
    position: relative;
    border: 1px solid #000;
    border-radius: 6px;
    cursor: pointer;
    font-family: 'Arial Black', Arial, sans-serif;
    font-weight: 900;
    font-size: clamp(10px, 0.7em + 0.4vh, 13px);
    line-height: 1.05;
    letter-spacing: 0;
    word-break: keep-all;
    overflow: hidden;
    color: #f0f0f0;
    text-shadow: 0 1px 0 #000, 0 0 4px rgba(0,0,0,0.9);
    text-align: center;
    padding: 4px 2px;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    transition: filter 0.12s, transform 0.08s, box-shadow 0.12s;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background:
        linear-gradient(180deg,
            rgba(255,255,255,0.10) 0%,
            rgba(255,255,255,0.02) 45%,
            rgba(0,0,0,0.20) 100%),
        var(--btn-tint),
        var(--btn-base);
    box-shadow:
        0 0 0 2px #6e6e6e,
        0 0 0 3px #1a1a1a,
        0 3px 5px rgba(0,0,0,0.85),
        inset 0 1px 0 rgba(255,255,255,0.30),
        inset 0 -2px 3px rgba(0,0,0,0.55);
}
.rail-btn .lbl { display: block; pointer-events: none; }
/* Tecla atalho do teclado em parênteses, fonte menor cinza */
.rail-btn .kbd {
    display: block;
    pointer-events: none;
    font-size: 0.72em;
    font-weight: 400;
    color: rgba(255,255,255,0.55);
    margin-top: 3px;
    letter-spacing: 0.5px;
    text-shadow: 0 1px 0 rgba(0,0,0,0.6);
}
.rail-btn:active {
    transform: translateY(1px) scale(0.97);
    filter: brightness(0.82);
    box-shadow:
        0 0 0 2px #555,
        0 0 0 3px #1a1a1a,
        0 1px 2px rgba(0,0,0,0.9),
        inset 0 2px 3px rgba(0,0,0,0.5),
        inset 0 -1px 0 rgba(255,255,255,0.1);
}

/* Tints de cada categoria de botão */
.btn-blue   { --btn-tint: linear-gradient(180deg, rgba( 60,140,210,0.55) 0%, rgba( 30, 80,150,0.55) 100%); }
.btn-cyan   { --btn-tint: linear-gradient(180deg, rgba( 90,180,190,0.55) 0%, rgba( 30,110,130,0.55) 100%); }
.btn-orange { --btn-tint: linear-gradient(180deg, rgba(220,150, 60,0.55) 0%, rgba(150, 80, 20,0.55) 100%); }
.btn-red    { --btn-tint: linear-gradient(180deg, rgba(210, 50, 50,0.60) 0%, rgba(130, 20, 20,0.60) 100%); }
.btn-gunmetal {
    --btn-base: #3a3a3a;
    font-size: clamp(13px, 0.95em + 0.5vh, 16px);
    letter-spacing: 0.5px;
}

/* === ESTADOS === */
.rail-btn.disabled-no-credit { filter: grayscale(1) brightness(0.55); pointer-events: none; }
.rail-btn.disabled-playing   { filter: brightness(0.4) saturate(0.3); pointer-events: none; }
.rail-btn.blink              { animation: rail-pulse 0.8s ease-in-out infinite; }
@keyframes rail-pulse {
    0%, 100% { filter: brightness(1);    box-shadow:
        0 0 0 2px #6e6e6e,
        0 0 0 3px #1a1a1a,
        0 3px 5px rgba(0,0,0,0.85),
        inset 0 1px 0 rgba(255,255,255,0.30),
        inset 0 -2px 3px rgba(0,0,0,0.55); }
    50%      { filter: brightness(1.55); box-shadow:
        0 0 0 2px #c8c8c8,
        0 0 0 3px #1a1a1a,
        0 0 12px rgba(255,220,140,0.55),
        inset 0 1px 0 rgba(255,255,255,0.45),
        inset 0 -2px 3px rgba(0,0,0,0.55); }
}

/* ============================================================
 * SIDE RAILS — layout específico mobile landscape touch
 * ============================================================ */
@media screen and (orientation: landscape) and (pointer: coarse) {
    :root {
        --rail-left-width: 104px;
        --rail-right-width: 116px;
    }

    #stage {
        position: fixed;
        top: 0; bottom: 0;
        left: var(--rail-left-width);
        right: var(--rail-right-width);
        width: auto;
        height: 100vh;
    }

    .side-rail {
        position: fixed;
        top: env(safe-area-inset-top, 0);
        bottom: env(safe-area-inset-bottom, 0);
        z-index: 10;
        display: flex;
        flex-direction: column;
        justify-content: space-around;
        align-items: stretch;
        gap: 7px;
        padding: 10px 7px;
        background: linear-gradient(180deg,
            #1a1a1a 0%, #2c2c2c 4%, #3a3a3a 50%, #2c2c2c 96%, #1a1a1a 100%);
        box-shadow:
            inset 1px 0 0 rgba(255,255,255,0.07),
            inset -1px 0 0 rgba(0,0,0,0.6),
            0 0 10px rgba(0,0,0,0.85);
    }
    #left-rail  { left:  env(safe-area-inset-left, 0);  width: var(--rail-left-width);  border-right: 2px solid #000; }
    #right-rail { right: env(safe-area-inset-right, 0); width: var(--rail-right-width); border-left:  2px solid #000; }
}

/* Esconde rails em portrait mobile (mesmo padrao do canvas) */
@media screen and (orientation: portrait) and (max-width: 1024px) {
    .side-rail { display: none !important; }
}

/* ============================================================
 * BARRA INFERIOR (desktop / portrait)
 * Mostra POR DEFAULT. Escondida só quando trilhos laterais aparecem
 * (mobile landscape touch). 6 botões: AJUDA · ABRIR CARTELAS · APOSTA
 * · NÚMEROS · TURBO · JOGAR — mesmo visual slot-machine dos rails.
 * ============================================================ */
:root { --bottom-bar-height: 78px; }

#bottom-bar {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    height: var(--bottom-bar-height);
    z-index: 10;
    display: flex;
    flex-direction: row;
    gap: 6px;
    padding: 6px 8px;
    background: linear-gradient(180deg,
        #1a1a1a 0%, #2c2c2c 4%, #3a3a3a 50%, #2c2c2c 96%, #1a1a1a 100%);
    box-shadow:
        inset 0 1px 0 rgba(255,255,255,0.07),
        inset 0 -1px 0 rgba(0,0,0,0.6),
        0 0 10px rgba(0,0,0,0.85);
    border-top: 2px solid #000;
}
#bottom-bar .rail-btn {
    flex: 1;
    min-width: 0;
    font-size: clamp(11px, 1vw + 2px, 14px);
    line-height: 1.05;
}
/* Stage encolhe verticalmente pra deixar espaço pra bottom-bar (modo padrão) */
#stage { height: calc(100vh - var(--bottom-bar-height)); }

/* Quando trilhos laterais ESTÃO visíveis (mobile landscape touch),
 * esconde a bottom-bar e devolve a altura toda do stage pros rails. */
@media screen and (orientation: landscape) and (pointer: coarse) {
    :root { --bottom-bar-height: 0px; }
    #bottom-bar { display: none; }
    #stage { height: 100vh; }
}
