:root {
    --stage-w: 1280;
    --stage-h: 720;
    --gold: #ffd54a;
    --hud-blue: #4db8ff;
    --cell-bg: #faf6ee;
    --wood: #6b4423;
    --btn-w: 128;
    --btn-h: 64;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: 'Arial Black', Impact, Arial, sans-serif;
    background: #0a1808;
    color: #fff;
    min-height: 100vh;
    overflow-x: hidden;
}

.hidden { display: none !important; }

/* ===== AUTH ===== */
.auth-panel {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: #1a3a1a url('../assets/bg.png') center/cover;
}

.auth-box {
    width: 100%;
    max-width: 400px;
    background: rgba(10, 30, 10, 0.95);
    border: 2px solid rgba(255, 213, 74, 0.45);
    border-radius: 18px;
    padding: 28px 24px;
    text-align: center;
}

.auth-logo { width: 120px; max-width: 100%; margin-bottom: 10px; border-radius: 12px; }
.auth-box h1 { margin: 0 0 6px; color: var(--gold); font-size: 1.5rem; }
.auth-box p { color: #b8d8a8; margin-bottom: 16px; font-size: 0.9rem; }

.auth-tabs { display: flex; gap: 8px; margin-bottom: 14px; }
.auth-tab {
    flex: 1; padding: 10px; border-radius: 10px;
    border: 1px solid rgba(255,255,255,0.15);
    background: rgba(0,0,0,0.25); color: #b8d8a8;
    cursor: pointer; font-weight: 700;
}
.auth-tab.active {
    border-color: var(--gold);
    color: #fff;
    background: rgba(255,213,74,0.18);
}

.auth-form input {
    display: block; width: 100%; margin: 8px 0;
    padding: 12px 14px; border-radius: 10px;
    border: 1px solid rgba(255,255,255,0.15);
    background: rgba(0,0,0,0.35); color: #fff;
}
.auth-form input:focus { outline: none; border-color: var(--gold); }
.btn-primary {
    width: 100%; margin-top: 8px; padding: 12px;
    border: none; border-radius: 10px; cursor: pointer;
    background: linear-gradient(180deg, #ffe082, #ffb300);
    color: #1a2800; font-weight: 800;
}
.msg { color: #ffb347; min-height: 20px; margin-top: 10px; font-size: 0.85rem; }

/* ===== GAME STAGE 1280x720 (original Unity) ===== */
.game-panel {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 6px;
    background: #051008;
}

.game-stage {
    position: relative;
    width: min(calc(100vw - 12px), calc((100vh - 12px) * var(--stage-w) / var(--stage-h)));
    aspect-ratio: var(--stage-w) / var(--stage-h);
    background: url('../assets/bg.png') center / 100% 100% no-repeat;
    overflow: hidden;
    box-shadow: 0 12px 40px rgba(0,0,0,0.55);
    border-radius: 4px;
    user-select: none;
    container-type: size;
    container-name: stage;
}

.btn-exit {
    position: absolute;
    top: calc(8 / var(--stage-h) * 100%);
    right: calc(10 / var(--stage-w) * 100%);
    z-index: 40;
    width: 28px; height: 28px; line-height: 26px; text-align: center;
    background: rgba(0,0,0,0.5); color: #fff; text-decoration: none;
    border-radius: 50%; font-size: 14px; border: 1px solid rgba(255,255,255,0.2);
}

/* Barra superior madeira (FUNDO_CONTADOR.png) */
.hud-bar {
    position: absolute;
    top: calc(8 / var(--stage-h) * 100%);
    left: 50%;
    transform: translateX(-50%);
    width: calc(1180 / var(--stage-w) * 100%);
    height: auto;
    z-index: 6;
    pointer-events: none;
}

.hud-values {
    position: absolute;
    inset: 0;
    z-index: 12;
    pointer-events: none;
}

.hud-val {
    position: absolute;
    font-family: 'Arial Black', Arial, sans-serif;
    font-weight: 900;
    font-size: clamp(12px, 2.4vw, 22px);
    font-size: calc(18 / var(--stage-w) * 100cqw);
    line-height: 1.1;
    text-align: left;
    text-shadow: 1px 1px 0 #000, -1px -1px 0 #000;
    white-space: nowrap;
}

/* Esquerda: Valor R$, Creditos, Pago (valores azuis como no original) */
.hud-valor-rs {
    top: calc(48 / var(--stage-h) * 100%);
    left: calc(248 / var(--stage-w) * 100%);
    color: var(--hud-blue);
    min-width: calc(100 / var(--stage-w) * 100%);
}

.hud-creditos {
    top: calc(68 / var(--stage-h) * 100%);
    left: calc(248 / var(--stage-w) * 100%);
    color: var(--hud-blue);
}

.hud-paid {
    top: calc(88 / var(--stage-h) * 100%);
    left: calc(248 / var(--stage-w) * 100%);
    color: var(--hud-blue);
}

/* Centro: JACKPOT */
.hud-jackpot {
    top: calc(52 / var(--stage-h) * 100%);
    left: 50%;
    transform: translateX(-50%);
    text-align: center;
    font-size: calc(32 / var(--stage-w) * 100cqw);
    color: #ffe566;
    text-shadow: 2px 2px 0 #1a3050, 0 0 10px rgba(100, 200, 255, 0.55);
    min-width: calc(160 / var(--stage-w) * 100%);
}

/* Direita: Aposta Total / Aposta Linha */
.hud-total-bet {
    top: calc(48 / var(--stage-h) * 100%);
    left: calc(968 / var(--stage-w) * 100%);
    color: var(--hud-blue);
    text-align: right;
    min-width: calc(60 / var(--stage-w) * 100%);
}

.hud-line-bet {
    top: calc(68 / var(--stage-h) * 100%);
    left: calc(968 / var(--stage-w) * 100%);
    color: var(--hud-blue);
    text-align: right;
}

/* Rolos + moldura img_rodilho */
.slot-machine {
    position: absolute;
    left: calc(168 / var(--stage-w) * 100%);
    top: calc(118 / var(--stage-h) * 100%);
    width: calc(944 / var(--stage-w) * 100%);
    height: calc(488 / var(--stage-h) * 100%);
    z-index: 8;
}

.reel-frame {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: fill;
    pointer-events: none;
    z-index: 12;
}

.paylines-draw {
    position: absolute;
    left: calc(58 / 944 * 100%);
    top: calc(36 / 488 * 100%);
    width: calc(828 / 944 * 100%);
    height: calc(416 / 488 * 100%);
    z-index: 14;
    pointer-events: none;
    overflow: visible;
}

.paylines-draw polyline {
    fill: none;
    stroke-linecap: round;
    stroke-linejoin: round;
    opacity: 0.95;
    filter: drop-shadow(0 0 3px rgba(100, 220, 255, 0.9));
}

.reels-viewport {
    position: absolute;
    left: calc(58 / 944 * 100%);
    top: calc(36 / 488 * 100%);
    width: calc(828 / 944 * 100%);
    height: calc(416 / 488 * 100%);
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    z-index: 10;
    overflow: hidden;
    background: transparent;
}

.reel {
    position: relative;
    height: 100%;
    overflow: hidden;
    background: var(--cell-bg);
    border-right: 2px solid rgba(92, 61, 46, 0.35);
}

.reel:last-child { border-right: none; }

.reel-strip {
    position: absolute;
    inset: 0;
    display: grid;
    grid-template-rows: repeat(3, 1fr);
    width: 100%;
    height: 100%;
    will-change: transform;
}

.reel-strip.spin-mode {
    display: flex;
    flex-direction: column;
    grid-template-rows: unset;
    height: auto;
    bottom: auto;
    top: 0;
    min-height: 100%;
}

.symbol {
    width: 100%;
    min-height: 0;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--cell-bg);
    border-bottom: 1px solid rgba(139, 90, 43, 0.2);
}

.reel-strip.spin-mode .symbol {
    flex: 0 0 auto;
    overflow: hidden;
}

.symbol:last-child { border-bottom: none; }

.sym-img {
    width: 92%;
    height: 92%;
    max-width: 100%;
    max-height: 100%;
    background-repeat: no-repeat;
    background-position: center center;
    background-size: contain;
    image-rendering: auto;
    flex-shrink: 0;
}

.symbol.win .sym-img {
    filter: drop-shadow(0 0 8px gold);
    animation: pulse-win 0.6s ease-in-out infinite alternate;
}

@keyframes pulse-win {
    from { filter: drop-shadow(0 0 4px gold); }
    to { filter: drop-shadow(0 0 12px #ffea00); }
}

.reel.spinning .sym-img {
    animation: symbol-blur 0.08s steps(2) infinite;
}

@keyframes symbol-blur {
    50% { opacity: 0.88; }
}

/* Indicadores de linha (esferas laterais) */
.paylines-layer {
    position: absolute;
    top: calc(118 / var(--stage-h) * 100%);
    height: calc(488 / var(--stage-h) * 100%);
    width: calc(56 / var(--stage-w) * 100%);
    z-index: 15;
    pointer-events: none;
}

.paylines-layer { left: calc(108 / var(--stage-w) * 100%); }

.paylines-layer.paylines-right {
    left: auto;
    right: calc(108 / var(--stage-w) * 100%);
}

.line-badge {
    position: absolute;
    width: calc(32 / var(--stage-w) * 100cqw);
    height: calc(32 / var(--stage-h) * 100cqh);
    min-width: 18px;
    min-height: 18px;
    transform: translate(-50%, -50%);
    background-repeat: no-repeat;
    background-size: contain;
    background-position: center;
    cursor: pointer;
    pointer-events: auto;
    opacity: 0.5;
    transition: opacity 0.2s, transform 0.2s;
    border: none;
    padding: 0;
    background-color: transparent;
}

.paylines-right .line-badge { transform: translate(50%, -50%); }

.line-badge.active {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.12);
    filter: drop-shadow(0 0 5px rgba(255,255,255,0.85));
}

.paylines-right .line-badge.active {
    transform: translate(50%, -50%) scale(1.12);
}

/* Mensagem central inferior (INSIRA CRÉDITOS / BOA SORTE) */
.msg-banner {
    position: absolute;
    left: 50%;
    top: calc(612 / var(--stage-h) * 100%);
    transform: translateX(-50%);
    width: calc(340 / var(--stage-w) * 100%);
    height: calc(42 / var(--stage-h) * 100%);
    min-height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    z-index: 19;
}

.msg-banner img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.msg-line-win {
    position: absolute;
    margin: 0;
    font-size: calc(14 / var(--stage-w) * 100cqw);
    color: #7ee8ff;
    text-shadow: 0 0 6px rgba(100, 220, 255, 0.8), 1px 1px 0 #000;
    text-align: center;
    white-space: nowrap;
}

.msg-line-win.visible { display: block !important; }
.msg-banner.show-text img { display: none; }

/* Controles inferiores — layout do original */
.controls-layer {
    position: absolute;
    inset: 0;
    z-index: 20;
    pointer-events: none;
}

.btn-sprite {
    position: absolute;
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    pointer-events: auto;
    transition: transform 0.12s;
    width: calc(var(--btn-w) / var(--stage-w) * 100cqw);
    height: calc(var(--btn-h) / var(--stage-h) * 100cqh);
    min-width: 72px;
    min-height: 36px;
}

.btn-icon {
    display: block;
    width: 100%;
    height: 100%;
    background-repeat: no-repeat;
    background-size: 200% 100%;
    background-position: 0 0;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.35));
}

.btn-sprite:active .btn-icon { background-position: 100% 0; }
.btn-sprite:active { transform: scale(0.94); }
.btn-sprite:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-sprite.spinning .btn-icon-spin { animation: spin-btn-pulse 0.4s ease-in-out infinite alternate; }

@keyframes spin-btn-pulse {
    from { filter: drop-shadow(0 0 4px rgba(255,213,74,0.5)); }
    to { filter: drop-shadow(0 0 10px rgba(255,213,74,1)); }
}

/* Crédito (verde) — canto inferior esquerdo */
.btn-cobrar {
    left: calc(48 / var(--stage-w) * 100%);
    top: calc(648 / var(--stage-h) * 100%);
    width: calc(112 / var(--stage-w) * 100cqw);
    min-width: 80px;
}

/* Linha de botões brancos */
.btn-bet {
    left: calc(228 / var(--stage-w) * 100%);
    top: calc(648 / var(--stage-h) * 100%);
}

.btn-ajuda {
    left: calc(368 / var(--stage-w) * 100%);
    top: calc(648 / var(--stage-h) * 100%);
}

.btn-lines {
    left: calc(508 / var(--stage-w) * 100%);
    top: calc(648 / var(--stage-h) * 100%);
}

.btn-auto {
    left: calc(768 / var(--stage-w) * 100%);
    top: calc(648 / var(--stage-h) * 100%);
}

/* Aposta Max — segunda linha, centro */
.btn-max {
    left: calc(438 / var(--stage-w) * 100%);
    top: calc(688 / var(--stage-h) * 100%);
}

/* JOGAR — botão amarelo grande à direita */
.btn-spin {
    left: calc(998 / var(--stage-w) * 100%);
    top: calc(636 / var(--stage-h) * 100%);
    width: calc(168 / var(--stage-w) * 100cqw);
    height: calc(72 / var(--stage-h) * 100cqh);
    min-width: 96px;
    min-height: 44px;
}

/* Dobrar / pular — só aparece após ganho */
.btn-dobrar {
    left: calc(648 / var(--stage-w) * 100%);
    top: calc(648 / var(--stage-h) * 100%);
    opacity: 0;
    pointer-events: none;
}

.btn-dobrar.visible {
    opacity: 1;
    pointer-events: auto;
}

.btn-dobrar.highlight {
    filter: drop-shadow(0 0 8px #ff4444);
}

.hidden-control {
    opacity: 0;
    pointer-events: none;
}

.paytable {
    position: absolute;
    bottom: 4px;
    right: 8px;
    font-size: 10px;
    color: #b8d8a8;
    z-index: 18;
    max-width: 45%;
    pointer-events: auto;
}

.paytable summary { cursor: pointer; color: #ffe082; }
.paytable table { width: 100%; border-collapse: collapse; font-size: 10px; background: rgba(0,0,0,0.8); }
.paytable th, .paytable td { border: 1px solid rgba(255,255,255,0.1); padding: 2px 4px; text-align: center; }

@media (max-width: 768px) {
    .game-panel { padding: 0; }
    .game-stage { width: 100vw; border-radius: 0; }
    .btn-sprite { min-width: 56px; min-height: 30px; }
}
