:root {
    --stage-w: 1024;
    --stage-h: 768;
    --gold: #ffd700;
    --msg-green: #7cfc00;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: 'Arial Black', Impact, Arial, sans-serif;
    background: #0a1a10;
    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: #1a5c2e url('../assets/sprites/bg2.png') center/cover;
}

.auth-box {
    width: 100%;
    max-width: 400px;
    background: rgba(0, 0, 0, 0.82);
    border: 2px solid var(--gold);
    border-radius: 16px;
    padding: 24px;
    text-align: center;
}

.auth-logo { max-width: 200px; width: 100%; margin-bottom: 10px; }
.auth-box h1 { color: var(--gold); margin: 0 0 8px; }
.auth-tabs { display: flex; gap: 8px; margin: 14px 0; }
.auth-tab {
    flex: 1; padding: 10px; border: 1px solid #555;
    background: #222; color: #ccc; cursor: pointer; border-radius: 8px; font-weight: 700;
}
.auth-tab.active { background: var(--gold); color: #000; border-color: var(--gold); }
.auth-form input {
    width: 100%; margin: 8px 0; padding: 12px; border-radius: 8px;
    border: 1px solid #444; background: #111; color: #fff;
}
.btn-primary {
    width: 100%; margin-top: 8px; padding: 12px; border: none; border-radius: 8px;
    background: var(--gold); color: #000; font-weight: 800; cursor: pointer;
}
.msg { color: #ffb347; min-height: 18px; margin-top: 8px; font-size: 0.85rem; }

/* ===== GAME STAGE 1024x768 ===== */
.game-panel {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 6px;
    background: #051408;
}

.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/sprites/bg2.png') center / 100% 100% no-repeat;
    overflow: hidden;
    box-shadow: 0 10px 36px rgba(0, 0, 0, 0.55);
    user-select: none;
    container-type: size;
    container-name: stage;
}

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

/* HUD — valores sobre os campos do bg2.png */
.hud-values { position: absolute; inset: 0; z-index: 12; pointer-events: none; }

.hud-val {
    position: absolute;
    font-family: 'Courier New', Courier, monospace;
    font-weight: 700;
    font-size: clamp(14px, 2.2vw, 24px);
    font-size: calc(22 / var(--stage-w) * 100cqw);
    color: #fff;
    text-shadow: 0 0 6px rgba(255, 255, 255, 0.35);
    line-height: 1.1;
    text-align: center;
    min-width: calc(72 / var(--stage-w) * 100%);
}

.hud-credits   { top: calc(56 / var(--stage-h) * 100%); left: calc(328 / var(--stage-w) * 100%); }
.hud-total-bet { top: calc(56 / var(--stage-h) * 100%); left: calc(438 / var(--stage-w) * 100%); }
.hud-line-bet  { top: calc(56 / var(--stage-h) * 100%); left: calc(548 / var(--stage-w) * 100%); }
.hud-paid      { top: calc(56 / var(--stage-h) * 100%); left: calc(658 / var(--stage-w) * 100%); }

/* Rolos */
.slot-machine {
    position: absolute;
    left: calc(38 / var(--stage-w) * 100%);
    top: calc(102 / var(--stage-h) * 100%);
    width: calc(642 / var(--stage-w) * 100%);
    height: calc(452 / var(--stage-h) * 100%);
    z-index: 8;
}

.paylines-draw {
    position: absolute;
    left: calc(2 / 642 * 100%);
    top: 0;
    width: calc(638 / 642 * 100%);
    height: calc(446 / 452 * 100%);
    z-index: 11;
    pointer-events: none;
    overflow: visible;
}

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

.reels-viewport {
    position: absolute;
    left: calc(2 / 642 * 100%);
    top: 0;
    width: calc(638 / 642 * 100%);
    height: calc(446 / 452 * 100%);
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    overflow: hidden;
    z-index: 9;
    background: #fff;
    border: 1px solid rgba(0, 0, 0, 0.12);
}

.balls-tray {
    position: absolute;
    left: 0;
    bottom: 0;
    width: 100%;
    height: calc(48 / 452 * 100%);
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: calc(4 / var(--stage-w) * 100%);
    padding: 0 calc(8 / var(--stage-w) * 100%);
    z-index: 12;
    pointer-events: none;
}

.ball-chip {
    width: calc(34 / var(--stage-w) * 100cqw);
    height: calc(34 / var(--stage-w) * 100cqw);
    min-width: 22px;
    min-height: 22px;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 30%, #fff 0%, #ddd 45%, #aaa 100%);
    border: 2px solid #333;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Arial Black', Arial, sans-serif;
    font-size: clamp(9px, 1.1cqw, 13px);
    font-size: calc(11 / var(--stage-w) * 100cqw);
    color: #111;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
    animation: ballPop 0.35s ease-out;
}

@keyframes ballPop {
    from { transform: scale(0); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.reel-col {
    position: relative;
    overflow: hidden;
    background: #fff;
    border-right: 1px solid rgba(0, 0, 0, 0.18);
    height: 100%;
}
.reel-col: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%;
}

.reel-strip.spin-mode .symbol-cell {
    flex: 0 0 auto;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

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

.symbol-cell .sym {
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
    background-repeat: no-repeat;
    flex-shrink: 0;
    overflow: hidden;
}

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

@keyframes winPulse {
    from { transform: scale(1); }
    to { transform: scale(1.06); }
}

.reel-col.spinning {
    background: #f5f5f5;
}

.reel-col.spinning .sym {
    animation: symbolBlur 0.1s steps(2) infinite;
}

@keyframes symbolBlur {
    50% { opacity: 0.75; }
}

/* Linhas de pagamento */
.paylines-layer {
    position: absolute;
    top: calc(102 / var(--stage-h) * 100%);
    height: calc(446 / var(--stage-h) * 100%);
    width: calc(38 / var(--stage-w) * 100%);
    z-index: 10;
    pointer-events: none;
}

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

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

.paylines-right .line-badge { transform: translate(50%, -50%); }
.line-badge.active {
    opacity: 1;
    filter: drop-shadow(0 0 4px #fff);
    transform: translate(-50%, -50%) scale(1.12);
}
.paylines-right .line-badge.active { transform: translate(50%, -50%) scale(1.12); }

/* Painel central direito (jackpot, cartela, you win) */
.sidebar-layer {
    position: absolute;
    left: calc(718 / var(--stage-w) * 100%);
    top: calc(72 / var(--stage-h) * 100%);
    width: calc(186 / var(--stage-w) * 100%);
    height: calc(680 / var(--stage-h) * 100%);
    z-index: 14;
    pointer-events: none;
}

.side-menu-icon {
    position: absolute;
    top: 0;
    left: 0;
    width: calc(32 / var(--stage-w) * 100cqw);
    height: auto;
    pointer-events: auto;
}

.btn-hamburger {
    position: absolute;
    top: 0;
    right: 0;
    background: none;
    border: none;
    color: #fff;
    font-size: clamp(14px, 1.8cqw, 20px);
    font-size: calc(18 / var(--stage-w) * 100cqw);
    cursor: pointer;
    pointer-events: auto;
}

.jackpot-value {
    position: absolute;
    top: calc(48 / 680 * 100%);
    left: 50%;
    transform: translateX(-50%);
    width: 88%;
    text-align: center;
    font-family: 'Courier New', monospace;
    font-size: clamp(16px, 2.8cqw, 30px);
    font-size: calc(28 / var(--stage-w) * 100cqw);
    color: var(--gold);
    text-shadow: 0 0 10px rgba(255, 215, 0, 0.55);
    letter-spacing: 1px;
}

.mini-paytable {
    position: absolute;
    top: calc(112 / 680 * 100%);
    left: 2%;
    width: 96%;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1px;
}
.mini-paytable img { width: 100%; height: auto; display: block; }

.bonus-card {
    position: absolute;
    top: calc(220 / 680 * 100%);
    left: 6%;
    width: 88%;
    height: calc(118 / 680 * 100%);
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    grid-template-rows: repeat(3, 1fr);
    gap: 2px;
    padding: 2px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 2px;
}

.bonus-cell {
    background: rgba(255, 255, 255, 0.95);
    color: #1a3a5c;
    font-size: clamp(8px, 1cqw, 12px);
    font-size: calc(10 / var(--stage-w) * 100cqw);
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 1px;
    font-family: 'Courier New', monospace;
    position: relative;
}

.bonus-cell.hit { color: transparent; }

.bonus-cell.hit::after {
    content: 'X';
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #c0392b;
    font-size: calc(14 / var(--stage-w) * 100cqw);
    font-weight: 900;
}

.bonus-ganho {
    position: absolute;
    top: calc(342 / 680 * 100%);
    left: 6%;
    width: 88%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 4px;
    pointer-events: none;
}

.bonus-ganho-label {
    font-size: calc(9 / var(--stage-w) * 100cqw);
    color: var(--msg-green);
    font-weight: 800;
}

#bonus-ganho-val {
    font-family: 'Courier New', monospace;
    font-size: calc(14 / var(--stage-w) * 100cqw);
    color: var(--gold);
}

.msg-banner {
    position: absolute;
    top: calc(368 / 680 * 100%);
    left: 4%;
    width: 92%;
    height: calc(48 / 680 * 100%);
    background: rgba(0, 0, 0, 0.72);
    border: 1px solid rgba(124, 252, 0, 0.35);
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    pointer-events: none;
}

.msg-text {
    margin: 0;
    font-size: clamp(9px, 1.1cqw, 14px);
    font-size: calc(11 / var(--stage-w) * 100cqw);
    font-weight: 900;
    color: var(--msg-green);
    text-align: center;
    letter-spacing: 0.4px;
    text-shadow: 0 0 8px rgba(124, 252, 0, 0.4);
    padding: 0 6px;
    line-height: 1.15;
}

.msg-text.boa-sorte { font-size: calc(14 / var(--stage-w) * 100cqw); }
.msg-text.bolas {
    font-size: calc(18 / var(--stage-w) * 100cqw);
    color: var(--gold);
    letter-spacing: 1px;
}
.msg-text.ganhou { color: var(--gold); }
.msg-text.bonus { color: #ff9800; }

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

.you-win {
    position: absolute;
    top: calc(422 / 680 * 100%);
    left: 2%;
    width: 96%;
    height: calc(72 / 680 * 100%);
    background: url('../assets/sprites/win3.png') center / contain no-repeat;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--gold);
    pointer-events: none;
    padding-top: 8%;
}

.you-win .win-label {
    font-size: calc(10 / var(--stage-w) * 100cqw);
    opacity: 0.95;
    letter-spacing: 1px;
}
.you-win .win-amount {
    font-size: calc(22 / var(--stage-w) * 100cqw);
    line-height: 1;
    font-weight: 900;
    text-shadow: 0 0 8px rgba(255, 215, 0, 0.5);
}

/* Coluna de botoes — direita (como no original) */
.controls {
    position: absolute;
    left: calc(906 / var(--stage-w) * 100%);
    top: calc(132 / var(--stage-h) * 100%);
    width: calc(108 / var(--stage-w) * 100cqw);
    min-width: 72px;
    max-width: 120px;
    bottom: calc(28 / var(--stage-h) * 100%);
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    gap: calc(5 / var(--stage-h) * 100%);
    z-index: 16;
    pointer-events: auto;
}

.btn-game {
    position: relative;
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    width: 100%;
    flex: 0 0 auto;
    transition: transform 0.1s;
}
.btn-game img {
    width: 100%;
    height: auto;
    display: block;
    pointer-events: none;
}
.btn-game span {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: clamp(8px, 1.05cqw, 13px);
    font-size: calc(10 / var(--stage-w) * 100cqw);
    font-weight: 900;
    color: #fff;
    text-shadow: 1px 1px 0 #000, -1px -1px 0 #000;
    letter-spacing: 0.2px;
    pointer-events: none;
    z-index: 2;
    text-align: center;
    line-height: 1.05;
    padding: 0 4px;
}
.btn-game:active { transform: scale(0.96); }
.btn-game:disabled { opacity: 0.55; cursor: not-allowed; }

.btn-play { margin-top: auto; }
.btn-play span { font-size: calc(11 / var(--stage-w) * 100cqw); }
.btn-play.spinning span { animation: spinBtnPulse 0.4s ease-in-out infinite alternate; }

@keyframes spinBtnPulse {
    from { text-shadow: 0 0 4px rgba(255, 100, 100, 0.6); }
    to { text-shadow: 0 0 10px rgba(255, 50, 50, 1); }
}

@media (max-width: 768px) {
    .game-panel { padding: 0; }
    .game-stage { width: 100vw; border-radius: 0; }
}
