/* Treasure Bingo — Pirate-Treasure Tropical Style */

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

:root {
    /* Sea / sky */
    --sea-deep:      #07323d;
    --sea-mid:       #0f5a6b;
    --sea-light:     #1d7c8e;
    --sky-warm:      #19708a;

    /* Parchment card */
    --parchment:     #f3e0b6;
    --parchment-dk:  #e6c98a;
    --parchment-sh:  #b8965a;

    /* Gold / wood accents */
    --gold:          #c9a44b;
    --gold-bright:   #f0c46b;
    --gold-dk:       #8a6a2c;
    --wood:          #4a2f1a;
    --wood-dk:       #2b1a0d;

    /* Functional */
    --win-green:     #22c55e;
    --loss-mute:     #6b6552;
    --danger:        #e3553e;
    --text-dark:     #2b1a0d;
    --text-light:    #f6e9c8;
    --text-muted:    #97836a;

    /* Sizing */
    --radius-md:     0.75rem;
    --radius-lg:     1rem;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

body {
    display: flex;
    justify-content: center;
    align-items: center;
    background:
        radial-gradient(ellipse at 50% 0%, var(--sky-warm) 0%, var(--sea-mid) 45%, var(--sea-deep) 100%);
    min-height: calc(100dvh - 3.5rem);
    color: var(--text-light);
}

/* ============ OCEAN BACKGROUND ============ */
#ocean-bg {
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    background:
        radial-gradient(2px 2px at 12% 18%, rgba(246,233,200,0.25), transparent),
        radial-gradient(1px 1px at 68% 32%, rgba(246,233,200,0.18), transparent),
        radial-gradient(2px 2px at 42% 76%, rgba(246,233,200,0.20), transparent),
        radial-gradient(1px 1px at 88% 62%, rgba(246,233,200,0.18), transparent),
        linear-gradient(180deg, transparent 0%, rgba(7,50,61,0.4) 100%);
    background-repeat: repeat;
    background-size: 360px 360px, 280px 280px, 320px 320px, 240px 240px, 100% 100%;
    animation: oceanShimmer 7s ease-in-out infinite alternate;
}

@keyframes oceanShimmer {
    0%   { opacity: 0.6; transform: translateY(0); }
    100% { opacity: 1;   transform: translateY(-4px); }
}

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

.screen.hidden { display: none; }

.loading-spinner {
    width: 3.25rem;
    height: 3.25rem;
    border: 0.2rem solid rgba(201,164,75,0.15);
    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);
    font-size: 0.95rem;
    letter-spacing: 0.06rem;
}

.login-content { text-align: center; }
.login-icon { font-size: 3.5rem; margin-bottom: 1rem; }
.login-content h2 { color: var(--gold); margin-bottom: 0.5rem; }
.login-content p { color: var(--text-muted); }

/* ============ 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.4rem 0;
    display: flex;
    justify-content: center;
}

.balance-display {
    background: linear-gradient(180deg, rgba(201,164,75,0.18) 0%, rgba(74,47,26,0.18) 100%);
    border: 1px solid rgba(201,164,75,0.45);
    border-radius: 1.25rem;
    padding: 0.4rem 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.45rem;
    box-shadow: 0 0 1.1rem rgba(201,164,75,0.18);
}

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

#balance-value {
    color: var(--gold-bright);
    font-size: 1.25rem;
    font-weight: 700;
    min-width: 4.4rem;
    text-align: right;
    text-shadow: 0 0 0.65rem rgba(240,196,107,0.5);
    transition: color 0.3s ease, transform 0.3s ease;
}

.balance-currency { color: var(--parchment-sh); font-size: 0.7rem; }

/* ============ TITLE ============ */
.game-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.35rem 0 0.4rem;
}

.title-flag { font-size: 1.3rem; filter: drop-shadow(0 1px 2px rgba(0,0,0,0.5)); }

.title-text {
    color: var(--gold-bright);
    font-size: 1.35rem;
    font-weight: 800;
    letter-spacing: 0.18rem;
    text-shadow: 0 2px 8px rgba(0,0,0,0.55), 0 0 0.6rem rgba(240,196,107,0.4);
    text-transform: uppercase;
}

/* ============ PAYTABLE STRIP ============ */
.paytable-strip {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.4rem 0.4rem;
    background:
        linear-gradient(180deg, #0a3a47 0%, #0c4655 100%) padding-box,
        linear-gradient(180deg, var(--gold-bright), var(--gold-dk)) border-box;
    border: 1px solid transparent;
    border-radius: 0.6rem;
    margin-bottom: 0.25rem;
    gap: 0.1rem;
}

.pay-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.1rem;
    padding: 0 0.5rem;
    min-width: 0;
}

.pay-name {
    font-size: 0.65rem;
    color: var(--text-muted);
    letter-spacing: 0.04rem;
    text-transform: uppercase;
    white-space: nowrap;
}

.pay-mult {
    color: var(--gold-bright);
    font-size: 0.85rem;
    font-weight: 800;
}

.pay-sep {
    width: 1px;
    height: 1.5rem;
    background: linear-gradient(to bottom, transparent, rgba(240,196,107,0.5), transparent);
}

/* ============ STAGE ============ */
#game-stage {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    padding: 0.5rem 0.25rem;
    position: relative;
}

/* Status row */
.status-row {
    width: 100%;
    display: flex;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 0.4rem;
}

.status-cell {
    flex: 1;
    background: rgba(7,50,61,0.55);
    border: 1px solid rgba(201,164,75,0.3);
    border-radius: 0.5rem;
    padding: 0.3rem 0.55rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.1rem;
}

.status-label {
    color: var(--text-muted);
    font-size: 0.65rem;
    letter-spacing: 0.05rem;
    text-transform: uppercase;
}

.status-val {
    color: var(--gold-bright);
    font-size: 1rem;
    font-weight: 700;
}

.status-val.low {
    color: var(--danger);
    animation: timerBlink 0.8s ease-in-out infinite alternate;
}

@keyframes timerBlink {
    0%   { opacity: 1; }
    100% { opacity: 0.55; }
}

/* Called ball */
.called-wrap {
    display: flex;
    justify-content: center;
    margin: 0.4rem 0;
}

.called-ball {
    width: 4.2rem;
    height: 4.2rem;
    border-radius: 50%;
    background:
        radial-gradient(circle at 35% 30%, var(--gold-bright) 0%, var(--gold) 55%, var(--gold-dk) 100%);
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow:
        0 0.4rem 1.2rem rgba(0,0,0,0.45),
        inset 0 -0.15rem 0.4rem rgba(0,0,0,0.35),
        inset 0 0.15rem 0.3rem rgba(255,255,255,0.45);
    border: 0.18rem solid var(--wood);
}

#called-ball-value {
    color: var(--wood-dk);
    font-size: 1.7rem;
    font-weight: 800;
    text-shadow: 0 1px 0 rgba(255,255,255,0.35);
}

.called-ball.pop {
    animation: ballPop 0.3s ease;
}

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

/* ============ BINGO CARD ============ */
.card-wrap {
    margin-top: 0.3rem;
    padding: 0.55rem;
    background:
        linear-gradient(180deg, var(--parchment) 0%, var(--parchment-dk) 100%);
    border: 0.2rem solid var(--gold-dk);
    border-radius: var(--radius-md);
    box-shadow:
        0 0.8rem 1.5rem rgba(0,0,0,0.45),
        inset 0 0 0 1px rgba(255,255,255,0.25),
        inset 0 0 1.5rem rgba(184,150,90,0.35);
    position: relative;
}

.card-wrap::before {
    /* Subtle parchment grain corners */
    content: '';
    position: absolute;
    inset: 0.3rem;
    pointer-events: none;
    border: 1px dashed rgba(74,47,26,0.18);
    border-radius: 0.5rem;
}

.bingo-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 0.3rem;
    position: relative;
    z-index: 1;
}

.bingo-cell {
    aspect-ratio: 1 / 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(180deg, #fff5d8 0%, var(--parchment) 100%);
    border: 1px solid var(--parchment-sh);
    border-radius: 0.45rem;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-dark);
    position: relative;
    transition: background 0.25s ease, transform 0.25s ease, box-shadow 0.25s ease;
    overflow: hidden;
}

.cell-number {
    position: relative;
    z-index: 1;
}

/* Hidden treasure layer (back of cell) */
.cell-treasure {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    opacity: 0;
    transform: scale(0.4);
    transition: opacity 0.3s ease, transform 0.4s cubic-bezier(.34,1.56,.64,1);
    pointer-events: none;
    z-index: 2;
}

.bingo-cell.marked {
    background: linear-gradient(180deg, var(--gold-bright) 0%, var(--gold) 100%);
    color: var(--wood-dk);
    box-shadow:
        inset 0 -2px 0 rgba(0,0,0,0.15),
        0 0 0.55rem rgba(240,196,107,0.5);
    animation: markPop 0.3s ease;
}

@keyframes markPop {
    0%, 100% { transform: scale(1); }
    50%       { transform: scale(1.13); }
}

.bingo-cell.treasure-revealed .cell-number {
    opacity: 0;
}

.bingo-cell.treasure-revealed .cell-treasure {
    opacity: 1;
    transform: scale(1);
}

.bingo-cell.treasure-revealed {
    background: linear-gradient(180deg, #ffe79a 0%, var(--gold-bright) 70%, var(--gold) 100%);
    box-shadow:
        0 0 0.9rem rgba(240,196,107,0.75),
        inset 0 0 0.4rem rgba(255,255,255,0.5);
}

.bingo-cell.winning {
    background: linear-gradient(180deg, #ffd86b 0%, #f0a23c 100%);
    color: var(--wood-dk);
    animation: winningPulse 0.6s ease-in-out infinite;
}

@keyframes winningPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(240,196,107,0.6); }
    50%       { box-shadow: 0 0 0 0.55rem rgba(240,196,107,0); }
}

/* Sparkle burst */
.sparkle-burst {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    pointer-events: none;
    z-index: 3;
    animation: sparkle 0.7s ease-out forwards;
}

@keyframes sparkle {
    0%   { opacity: 0;   transform: scale(0.4) rotate(0deg); }
    40%  { opacity: 1;   transform: scale(1.4) rotate(180deg); }
    100% { opacity: 0;   transform: scale(2.0) rotate(360deg); }
}

/* ============ RESULT DISPLAY ============ */
.result-display {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: linear-gradient(160deg, rgba(11,46,55,0.97) 0%, rgba(7,32,40,0.97) 100%);
    padding: 1.1rem 2rem;
    border: 1px solid var(--gold);
    border-radius: var(--radius-lg);
    text-align: center;
    z-index: 50;
    box-shadow:
        0 0 0 1px rgba(201,164,75,0.25),
        0 0 2.5rem rgba(240,196,107,0.35);
    animation: resultIn 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    min-width: 13rem;
}

.result-display.hidden { display: none; }

@keyframes resultIn {
    from { transform: translate(-50%, -50%) scale(0.5); opacity: 0; }
    to   { transform: translate(-50%, -50%) scale(1);   opacity: 1; }
}

.result-icon {
    font-size: 2.7rem;
    margin-bottom: 0.4rem;
}

.result-title {
    font-size: 1.4rem;
    font-weight: 800;
    letter-spacing: 0.12rem;
    margin-bottom: 0.3rem;
    text-transform: uppercase;
}

.result-title.win { color: var(--gold-bright); text-shadow: 0 0 0.8rem rgba(240,196,107,0.55); }
.result-title.lose { color: var(--loss-mute); }

.result-info {
    color: var(--text-muted);
    font-size: 0.8rem;
    margin-bottom: 0.4rem;
    letter-spacing: 0.03rem;
}

.result-info.hidden, .result-multiplier.hidden, .result-amount.hidden { display: none; }

.result-multiplier {
    font-size: 1.7rem;
    font-weight: 800;
    color: var(--gold-bright);
    margin-bottom: 0.2rem;
    text-shadow: 0 0 0.6rem rgba(240,196,107,0.5);
}

.result-amount {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--win-green);
}

/* ============ CONTROLS ============ */
.controls {
    width: 100%;
    padding: 0.7rem 0.3rem 0.4rem;
    background: rgba(7,32,40,0.55);
    border-radius: var(--radius-md);
    border: 1px solid rgba(201,164,75,0.25);
    margin-top: 0.4rem;
}

.bet-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
    margin-bottom: 0.6rem;
    flex-wrap: wrap;
}

.bet-controls.hidden { display: none; }

.bet-label {
    color: var(--text-muted);
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.08rem;
    text-transform: uppercase;
}

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

.bet-btn {
    width: 3rem;
    height: 2.1rem;
    background: rgba(246,233,200,0.06);
    border: 1px solid rgba(201,164,75,0.35);
    border-radius: 0.4rem;
    color: var(--text-light);
    font-size: 0.85rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.15s ease;
}

.bet-btn:hover:not(:disabled) {
    border-color: var(--gold);
    background: rgba(201,164,75,0.12);
}

.bet-btn.active {
    background: linear-gradient(160deg, var(--gold-bright) 0%, var(--gold-dk) 100%);
    color: var(--wood-dk);
    border-color: var(--gold-bright);
    box-shadow: 0 2px 0.7rem rgba(240,196,107,0.45);
}

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

/* Action button */
.action-button {
    width: 100%;
    padding: 0.85rem;
    border: 1px solid rgba(240,196,107,0.65);
    border-radius: 0.7rem;
    background: linear-gradient(160deg, var(--gold-bright) 0%, var(--gold) 55%, var(--gold-dk) 100%);
    color: var(--wood-dk);
    font-size: 1rem;
    font-weight: 800;
    letter-spacing: 0.15rem;
    cursor: pointer;
    transition: all 0.18s ease;
    text-transform: uppercase;
    box-shadow:
        0 0.3rem 1.2rem rgba(201,164,75,0.45),
        inset 0 1px 0 rgba(255,255,255,0.3);
}

.action-button:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 0.5rem 1.6rem rgba(240,196,107,0.55);
}

.action-button:active:not(:disabled) { transform: translateY(0); }

.action-button:disabled {
    background: linear-gradient(160deg, #2c2418 0%, #1c1610 100%);
    color: var(--text-muted);
    border-color: rgba(255,255,255,0.05);
    box-shadow: none;
    cursor: not-allowed;
}

.action-button.pulse {
    animation: btnPulse 2s ease-in-out infinite;
}

@keyframes btnPulse {
    0%, 100% { box-shadow: 0 0.3rem 1.2rem rgba(201,164,75,0.45); }
    50%       { box-shadow: 0 0.3rem 2rem rgba(240,196,107,0.85); }
}

/* ============ MESSAGE ============ */
.message-display {
    position: fixed;
    bottom: 6rem;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(7,32,40,0.93);
    border: 1px solid rgba(201,164,75,0.4);
    color: var(--text-light);
    padding: 0.55rem 1.2rem;
    border-radius: 0.5rem;
    font-size: 0.85rem;
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 200;
    pointer-events: none;
}

.message-display.hidden { display: none; }
.message-display.visible { opacity: 1; }

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

.particle {
    position: absolute;
    font-size: 1.3rem;
    animation: particleFall 2s ease-out forwards;
    filter: drop-shadow(0 1px 2px rgba(0,0,0,0.5));
}

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

/* ============ RESPONSIVE ============ */
@media (max-width: 25rem) {
    .title-text { font-size: 1.15rem; letter-spacing: 0.12rem; }
    .called-ball { width: 3.6rem; height: 3.6rem; }
    #called-ball-value { font-size: 1.4rem; }
    .bingo-cell { font-size: 0.95rem; }
    .cell-treasure { font-size: 1.15rem; }
    .pay-name { font-size: 0.6rem; }
    .pay-mult { font-size: 0.75rem; }
    .bet-btn { width: 2.7rem; height: 1.9rem; font-size: 0.78rem; }
}

@media (max-height: 44rem) {
    .paytable-strip { padding: 0.3rem; margin-bottom: 0.1rem; }
    .called-wrap { margin: 0.2rem 0; }
    .called-ball { width: 3.6rem; height: 3.6rem; }
    #called-ball-value { font-size: 1.4rem; }
    .card-wrap { padding: 0.4rem; }
    .bingo-grid { gap: 0.22rem; }
    .controls { padding: 0.5rem 0.3rem 0.3rem; margin-top: 0.25rem; }
    .action-button { padding: 0.65rem; }
}
