/* Midnight Lotto — State Lottery Formal Style */

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

:root {
    --emerald:        #2e7d57;
    --emerald-dark:   #1f5a3e;
    --emerald-deep:   #143821;
    --gold:           #daa520;
    --gold-dark:      #b8860b;
    --gold-soft:      #f0c75e;
    --cream:          #fdfaf2;
    --cream-shadow:   #efe7d2;
    --ink:            #143821;
    --ink-muted:      #6b8074;
    --paper-line:     #d8cdb0;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    font-family: 'Georgia', 'Times New Roman', serif;
}

body {
    display: flex;
    justify-content: center;
    align-items: center;
    background:
        radial-gradient(ellipse at 50% 0%, var(--emerald) 0%, var(--emerald-dark) 55%, var(--emerald-deep) 100%);
    min-height: calc(100dvh - 3.5rem);
    color: var(--ink);
}

/* ============ SCREENS ============ */
.screen {
    position: fixed;
    inset: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background: var(--emerald-deep);
    color: var(--cream);
    z-index: 1000;
}

.screen.hidden { display: none; }

.loading-spinner {
    width: 3.25rem;
    height: 3.25rem;
    border: 0.1875rem solid rgba(218, 165, 32, 0.18);
    border-top-color: var(--gold);
    border-radius: 50%;
    animation: spinAnim 1s linear infinite;
}

@keyframes spinAnim { to { transform: rotate(360deg); } }

#loading-screen p {
    margin-top: 1rem;
    color: var(--gold-soft);
    font-size: 0.9375rem;
    letter-spacing: 0.0625rem;
}

.login-content { text-align: center; }
.login-icon { font-size: 3.5rem; margin-bottom: 1rem; }
.login-content h2 { color: var(--gold-soft); margin-bottom: 0.5rem; }
.login-content p  { color: rgba(253, 250, 242, 0.7); }

/* ============ GAME CONTAINER ============ */
#game-container {
    width: 100%;
    max-width: 28.75rem;
    height: 100%;
    max-height: 51.25rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0.5rem 0.75rem;
    position: relative;
    z-index: 1;
}

#game-container.hidden { display: none; }

/* ============ HEADER ============ */
#game-header {
    width: 100%;
    padding: 0.375rem 0;
    display: flex;
    justify-content: center;
}

.balance-display {
    background: linear-gradient(180deg, rgba(253, 250, 242, 0.96) 0%, rgba(239, 231, 210, 0.95) 100%);
    border: 0.0625rem solid var(--gold);
    border-radius: 1.25rem;
    padding: 0.4375rem 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.4375rem;
    box-shadow: 0 0.125rem 0.625rem rgba(0, 0, 0, 0.25);
}

.balance-label {
    color: var(--ink-muted);
    font-size: 0.75rem;
    letter-spacing: 0.03125rem;
    text-transform: uppercase;
}

#balance-value {
    color: var(--emerald-dark);
    font-size: 1.25rem;
    font-weight: 700;
    min-width: 4.375rem;
    text-align: right;
}

.balance-currency { color: var(--gold-dark); font-size: 0.6875rem; font-weight: 700; }

/* ============ PAYTABLE STRIP ============ */
.paytable-strip {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    padding: 0.4375rem 0.75rem;
    background: linear-gradient(180deg, var(--cream) 0%, var(--cream-shadow) 100%);
    border: 0.0625rem solid var(--gold);
    border-radius: 0.5rem;
    margin-bottom: 0.25rem;
    box-shadow: 0 0.125rem 0.625rem rgba(0, 0, 0, 0.2);
}

.pay-item {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0 0.5rem;
}

.pay-match {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.125rem;
    height: 1.125rem;
    background: var(--gold);
    color: var(--ink);
    border-radius: 50%;
    font-size: 0.75rem;
    font-weight: 700;
    font-family: 'Georgia', serif;
}

.pay-mult {
    color: var(--emerald-dark);
    font-size: 0.8125rem;
    font-weight: 700;
    letter-spacing: 0.03125rem;
}

.pay-sep {
    width: 0.0625rem;
    height: 1.125rem;
    background: var(--paper-line);
}

/* ============ LOTTERY TICKET ============ */
#lottery-ticket {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: stretch;
    width: 100%;
    padding: 0.75rem 0;
}

/* Ticket — cream paper with gold border */
.ticket-frame {
    position: relative;
    width: 100%;
    background:
        linear-gradient(180deg, var(--cream) 0%, var(--cream-shadow) 100%);
    border: 0.1875rem solid var(--gold);
    border-radius: 0.75rem;
    padding: 0.875rem 0.875rem 0.75rem;
    box-shadow:
        0 0 0 0.0625rem var(--gold-dark) inset,
        0 0.5rem 1.5rem rgba(0, 0, 0, 0.35),
        0 0 1.25rem rgba(218, 165, 32, 0.15);
    display: flex;
    flex-direction: column;
    gap: 0.625rem;
}

/* Paper guilloché lines */
.ticket-frame::before {
    content: '';
    position: absolute;
    inset: 0.3125rem;
    border: 0.0625rem dashed rgba(184, 134, 11, 0.35);
    border-radius: 0.5rem;
    pointer-events: none;
}

.ticket-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.125rem;
    padding-bottom: 0.375rem;
    border-bottom: 0.0625rem dashed var(--paper-line);
}

.ticket-title {
    color: var(--emerald-deep);
    font-size: 1.125rem;
    font-weight: 700;
    letter-spacing: 0.15rem;
    text-transform: uppercase;
}

.ticket-instruction {
    color: var(--ink-muted);
    font-size: 0.75rem;
    letter-spacing: 0.0625rem;
    font-style: italic;
}

/* Numbers Grid 5×10 */
.numbers-grid {
    display: grid;
    grid-template-columns: repeat(10, 1fr);
    gap: 0.25rem;
    padding: 0.125rem;
}

.numbers-grid.locked .num-cell {
    cursor: default;
}

.num-cell {
    position: relative;
    aspect-ratio: 1 / 1;
    background: var(--cream);
    border: 0.0625rem solid var(--paper-line);
    border-radius: 0.25rem;
    color: var(--ink);
    font-family: 'Georgia', serif;
    font-size: 0.8125rem;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.15s ease, background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
    user-select: none;
}

.num-cell:hover:not(.selected):not(.drawn-mark) {
    border-color: var(--gold);
    background: #fff8e1;
}

.num-cell.selected {
    background: linear-gradient(180deg, var(--gold-soft) 0%, var(--gold) 100%);
    border: 0.125rem solid var(--gold-dark);
    color: var(--ink);
    box-shadow: 0 0.0625rem 0.375rem rgba(184, 134, 11, 0.55), inset 0 0.0625rem 0 rgba(255, 255, 255, 0.4);
    transform: scale(1.04);
}

.cell-check {
    position: absolute;
    top: -0.1875rem;
    right: -0.1875rem;
    width: 0.6875rem;
    height: 0.6875rem;
    background: var(--emerald-dark);
    color: var(--cream);
    border-radius: 50%;
    font-size: 0.5rem;
    line-height: 0.6875rem;
    text-align: center;
    opacity: 0;
    transform: scale(0);
    transition: opacity 0.15s ease, transform 0.15s ease;
}

.num-cell.selected .cell-check {
    opacity: 1;
    transform: scale(1);
}

.num-cell.drawn-mark {
    border-color: var(--gold);
    background: #fff8e1;
}

.num-cell.match {
    background: linear-gradient(180deg, #ffd86b 0%, var(--gold) 100%);
    border: 0.125rem solid var(--gold-dark);
    color: var(--ink);
    box-shadow: 0 0 0.75rem rgba(218, 165, 32, 0.7), inset 0 0.0625rem 0 rgba(255, 255, 255, 0.5);
    animation: matchPulse 0.6s ease;
}

@keyframes matchPulse {
    0%   { transform: scale(1); }
    50%  { transform: scale(1.18); }
    100% { transform: scale(1.04); }
}

/* ============ DRUM ============ */
.drum-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.375rem;
    padding: 0.5rem;
    background: linear-gradient(180deg, var(--emerald-dark) 0%, var(--emerald-deep) 100%);
    border: 0.125rem solid var(--gold);
    border-radius: 0.5rem;
    box-shadow: inset 0 0.125rem 0.5rem rgba(0, 0, 0, 0.45);
}

.drum-container.shaking {
    animation: drumShake 0.12s ease-in-out infinite;
}

@keyframes drumShake {
    0%, 100% { transform: translateX(0); }
    25%      { transform: translateX(-0.125rem) rotate(-0.5deg); }
    75%      { transform: translateX(0.125rem) rotate(0.5deg); }
}

.drum-label {
    color: var(--gold-soft);
    font-size: 0.625rem;
    letter-spacing: 0.1875rem;
    font-weight: 700;
    text-transform: uppercase;
}

.drum-slots {
    display: flex;
    gap: 0.4375rem;
}

.ball-slot {
    width: 2.125rem;
    height: 2.125rem;
    border: 0.0625rem dashed rgba(218, 165, 32, 0.5);
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.25);
    box-shadow: inset 0 0.0625rem 0.25rem rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
}

.ball-slot.filled {
    border-style: solid;
    border-color: var(--gold);
}

.ball {
    width: 1.875rem;
    height: 1.875rem;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 30%, #fff8e1 0%, var(--gold-soft) 35%, var(--gold) 70%, var(--gold-dark) 100%);
    color: var(--ink);
    font-family: 'Georgia', serif;
    font-size: 0.875rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow:
        inset -0.125rem -0.1875rem 0.375rem rgba(0, 0, 0, 0.25),
        inset 0.125rem 0.125rem 0.25rem rgba(255, 255, 255, 0.55),
        0 0.125rem 0.375rem rgba(0, 0, 0, 0.4);
    animation: ballBounce 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes ballBounce {
    0%   { transform: translateY(-1.875rem) scale(0.4); opacity: 0; }
    60%  { transform: translateY(0.1875rem) scale(1.15); opacity: 1; }
    100% { transform: translateY(0) scale(1); opacity: 1; }
}

/* ============ TICKET FOOTER ============ */
.ticket-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 0.375rem;
    border-top: 0.0625rem dashed var(--paper-line);
}

.pick-status {
    color: var(--emerald-dark);
    font-size: 0.8125rem;
    font-weight: 700;
    letter-spacing: 0.03125rem;
    transition: color 0.18s ease;
}

.pick-status.flash {
    color: #c0392b;
    animation: statusFlash 0.3s ease;
}

@keyframes statusFlash {
    0%   { transform: scale(1); }
    50%  { transform: scale(1.08); }
    100% { transform: scale(1); }
}

.clear-btn {
    background: transparent;
    border: 0.0625rem solid var(--ink-muted);
    color: var(--ink-muted);
    padding: 0.25rem 0.75rem;
    border-radius: 0.25rem;
    font-family: 'Georgia', serif;
    font-size: 0.6875rem;
    font-weight: 700;
    letter-spacing: 0.0625rem;
    cursor: pointer;
    transition: all 0.15s ease;
}

.clear-btn:hover:not(:disabled) {
    border-color: var(--emerald-dark);
    color: var(--emerald-dark);
    background: rgba(46, 125, 87, 0.08);
}

.clear-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* ============ WIN DISPLAY ============ */
#win-display {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: linear-gradient(160deg, var(--cream) 0%, var(--cream-shadow) 100%);
    padding: 1.125rem 2.5rem;
    border-radius: 1rem;
    border: 0.1875rem solid var(--gold);
    box-shadow:
        0 0 0 0.0625rem var(--gold-dark) inset,
        0 0 2.5rem rgba(218, 165, 32, 0.55),
        0 0.75rem 2rem rgba(0, 0, 0, 0.45);
    z-index: 100;
    text-align: center;
    animation: winPopup 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

#win-display.hidden { display: none; }

#win-display.jackpot {
    animation: winPopup 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275), jackpotPulse 0.9s ease-in-out 0.4s infinite;
}

@keyframes winPopup {
    0%   { transform: translate(-50%, -50%) scale(0.5); opacity: 0; }
    100% { transform: translate(-50%, -50%) scale(1);   opacity: 1; }
}

@keyframes jackpotPulse {
    0%, 100% { box-shadow: 0 0 0 0.0625rem var(--gold-dark) inset, 0 0 2.5rem rgba(218, 165, 32, 0.55), 0 0.75rem 2rem rgba(0, 0, 0, 0.45); }
    50%      { box-shadow: 0 0 0 0.0625rem var(--gold-dark) inset, 0 0 4rem rgba(255, 215, 60, 0.85), 0 0.75rem 2rem rgba(0, 0, 0, 0.45); }
}

.win-label {
    display: block;
    color: var(--emerald-dark);
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.1875rem;
    text-transform: uppercase;
    margin-bottom: 0.25rem;
}

#win-amount {
    display: block;
    color: var(--gold-dark);
    font-size: 2.625rem;
    font-weight: 700;
    line-height: 1;
    text-shadow: 0 0.125rem 0.5rem rgba(184, 134, 11, 0.35);
    font-family: 'Georgia', serif;
}

.win-sub {
    display: block;
    margin-top: 0.375rem;
    color: var(--ink-muted);
    font-size: 0.75rem;
    letter-spacing: 0.0625rem;
    text-transform: uppercase;
}

/* ============ MESSAGE DISPLAY ============ */
#message-display {
    position: absolute;
    bottom: 11.875rem;
    left: 50%;
    transform: translateX(-50%);
    background: var(--cream);
    padding: 0.5rem 1.375rem;
    border-radius: 0.5rem;
    border: 0.0625rem solid var(--gold);
    box-shadow: 0 0.25rem 0.75rem rgba(0, 0, 0, 0.3);
    z-index: 100;
    white-space: nowrap;
}

#message-display.hidden { display: none; }
#message-text { color: var(--ink); font-size: 0.8125rem; font-weight: 700; }

/* ============ BET CONTROLS ============ */
#bet-controls {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.5rem 0.25rem;
    flex-wrap: wrap;
}

.bet-label {
    color: var(--gold-soft);
    font-size: 0.6875rem;
    font-weight: 700;
    letter-spacing: 0.0625rem;
    text-transform: uppercase;
}

.bet-buttons { display: flex; gap: 0.375rem; }

.bet-btn {
    width: 3rem;
    height: 2rem;
    background: rgba(253, 250, 242, 0.1);
    border: 0.0625rem solid rgba(218, 165, 32, 0.5);
    border-radius: 0.375rem;
    color: rgba(253, 250, 242, 0.8);
    font-family: 'Georgia', serif;
    font-size: 0.8125rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.15s ease;
}

.bet-btn:hover {
    border-color: var(--gold);
    color: var(--cream);
    background: rgba(218, 165, 32, 0.18);
}

.bet-btn.active {
    background: linear-gradient(160deg, var(--gold-soft) 0%, var(--gold) 100%);
    color: var(--ink);
    border-color: var(--gold-dark);
    box-shadow: 0 0.125rem 0.5rem rgba(218, 165, 32, 0.45);
}

.bet-btn:disabled { opacity: 0.4; cursor: not-allowed; }

.current-bet {
    background: rgba(0, 0, 0, 0.25);
    padding: 0.25rem 0.875rem;
    border-radius: 0.375rem;
    border: 0.0625rem solid rgba(218, 165, 32, 0.4);
}

#current-bet-value {
    color: var(--gold-soft);
    font-size: 1rem;
    font-weight: 700;
}

/* ============ PLAY BUTTON ============ */
#play-button {
    width: 11.25rem;
    height: 3.25rem;
    background: linear-gradient(160deg, var(--gold-soft) 0%, var(--gold) 55%, var(--gold-dark) 100%);
    border: 0.0625rem solid var(--gold-dark);
    border-radius: 1.625rem;
    cursor: pointer;
    box-shadow:
        0 0.25rem 1rem rgba(218, 165, 32, 0.45),
        0 0.0625rem 0 rgba(255, 255, 255, 0.3) inset;
    transition: all 0.18s ease;
    margin: 0.5rem 0;
}

#play-button:hover:not(:disabled) {
    transform: translateY(-0.125rem);
    box-shadow: 0 0.5rem 1.5rem rgba(218, 165, 32, 0.6);
}

#play-button:active:not(:disabled) {
    transform: translateY(0);
    box-shadow: 0 0.125rem 0.5rem rgba(184, 134, 11, 0.45);
}

#play-button:disabled {
    background: linear-gradient(160deg, #4a5b50 0%, #2f3d34 100%);
    border-color: rgba(255, 255, 255, 0.1);
    box-shadow: none;
    cursor: not-allowed;
}

#play-button.pulse {
    animation: buttonPulse 2s ease-in-out infinite;
}

@keyframes buttonPulse {
    0%, 100% { box-shadow: 0 0.25rem 1rem rgba(218, 165, 32, 0.45); }
    50%      { box-shadow: 0 0.25rem 2rem rgba(240, 199, 94, 0.9); }
}

.play-text {
    color: var(--ink);
    font-family: 'Georgia', serif;
    font-size: 1.25rem;
    font-weight: 800;
    letter-spacing: 0.1875rem;
}

#play-button:disabled .play-text { color: #aaa; }

/* ============ GAME TITLE ============ */
.game-title {
    display: flex;
    align-items: baseline;
    gap: 0.375rem;
    padding: 0.25rem 0 0.375rem;
}

.title-mega {
    color: rgba(253, 250, 242, 0.5);
    font-size: 0.6875rem;
    letter-spacing: 0.125rem;
    text-transform: uppercase;
    font-family: 'Georgia', serif;
}

.title-50 {
    color: var(--gold-soft);
    font-size: 1.25rem;
    font-weight: 800;
    letter-spacing: 0.125rem;
    text-shadow: 0 0 0.875rem rgba(218, 165, 32, 0.55);
    font-family: 'Georgia', serif;
}

/* ============ PARTICLES ============ */
#particles-container {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 1000;
}

.particle {
    position: absolute;
    font-size: 1.25rem;
    animation: particleFall 2s ease-out forwards;
}

.particle.particle-jackpot {
    font-size: 1.75rem;
}

@keyframes particleFall {
    0%   { opacity: 1; transform: translateY(0) rotate(0deg) scale(1); }
    100% { opacity: 0; transform: translateY(80vh) rotate(540deg) scale(0.3); }
}

/* ============ RESPONSIVE ============ */
@media (max-width: 400px) {
    .num-cell { font-size: 0.6875rem; }
    .ball-slot { width: 1.75rem; height: 1.75rem; }
    .ball { width: 1.5rem; height: 1.5rem; font-size: 0.75rem; }
    .bet-btn { width: 2.625rem; height: 1.875rem; font-size: 0.75rem; }
    #play-button { width: 9.6875rem; height: 2.875rem; }
    .play-text { font-size: 1.0625rem; }
    .ticket-title { font-size: 1rem; letter-spacing: 0.125rem; }
}

@media (max-height: 700px) {
    .paytable-strip { padding: 0.3125rem 0.625rem; margin-bottom: 0; }
    #lottery-ticket { padding: 0.5rem 0; }
    .ticket-frame { padding: 0.625rem; gap: 0.5rem; }
    .num-cell { font-size: 0.75rem; }
    .drum-container { padding: 0.375rem; }
    .ball-slot { width: 1.75rem; height: 1.75rem; }
    .ball { width: 1.5rem; height: 1.5rem; font-size: 0.75rem; }
}

/* === clone palette override === */
body { filter: hue-rotate(220deg) saturate(110%); }
