/* ============================================================
   Online Blackjack — Premium Game Table Styles
   ============================================================ */

/* ---------- Reset & Base ---------- */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --felt: #0b6623;
    --felt-dark: #064016;
    --gold: #d4af37;
    --gold-light: #f5d98e;
    --card-shadow: 0 4px 15px rgba(0, 0, 0, .45);
    --glass-bg: rgba(255, 255, 255, .08);
    --glass-border: rgba(255, 255, 255, .15);
    --text: #f0ead6;
    --text-dim: rgba(240, 234, 214, .6);
    --danger: #e74c3c;
    --success: #2ecc71;
    --push-color: #f39c12;
    --radius: 14px;
    --transition: .3s ease;
}

html,
body {
    height: 100%;
    height: 100vh;
    height: 100dvh;
    font-family: 'Outfit', sans-serif;
    color: var(--text);
    background: var(--tg-theme-bg-color, radial-gradient(ellipse at center, var(--felt) 0%, var(--felt-dark) 70%, #021a07 100%));
    background: radial-gradient(ellipse at center, var(--felt) 0%, var(--felt-dark) 70%, #021a07 100%);
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

/* ---------- Screens ---------- */
.screen {
    display: none;
    width: 100%;
    height: 100%;
}

.screen.active {
    display: flex;
}

/* ---------- Lobby ---------- */
#lobby {
    align-items: center;
    justify-content: center;
}

.lobby-container {
    text-align: center;
    animation: fadeUp .6s ease-out;
}

.logo-icon {
    font-size: 4.5rem;
    display: block;
    margin-bottom: .2rem;
    filter: drop-shadow(0 0 20px rgba(212, 175, 55, .5));
    animation: pulse 2s infinite;
}

.logo h1 {
    font-size: 3.2rem;
    font-weight: 700;
    letter-spacing: 2px;
    background: linear-gradient(135deg, var(--gold), var(--gold-light));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.tagline {
    font-weight: 300;
    font-size: 1.1rem;
    color: var(--text-dim);
    margin-bottom: 2.5rem;
    letter-spacing: 4px;
    text-transform: uppercase;
}

.status-text {
    margin-top: 1.2rem;
    font-size: .95rem;
    color: var(--gold-light);
    min-height: 1.4em;
    animation: blink 1.2s steps(2) infinite;
}

/* ---------- Buttons ---------- */
.btn {
    border: none;
    cursor: pointer;
    font-family: inherit;
    font-weight: 600;
    font-size: 1.05rem;
    border-radius: var(--radius);
    padding: .85rem 2.4rem;
    transition: transform var(--transition), box-shadow var(--transition), background var(--transition);
    letter-spacing: .5px;
}

.btn:active {
    transform: scale(.96);
}

.btn:disabled {
    opacity: .35;
    cursor: not-allowed;
    transform: none;
}

.btn-primary {
    background: linear-gradient(135deg, var(--gold), #c5972a);
    color: #1a1a1a;
    box-shadow: 0 4px 20px rgba(212, 175, 55, .35);
}

.btn-primary:hover:not(:disabled) {
    box-shadow: 0 6px 30px rgba(212, 175, 55, .55);
    transform: translateY(-2px);
}

.btn-hit {
    background: linear-gradient(135deg, var(--success), #27ae60);
    color: #fff;
    box-shadow: 0 4px 15px rgba(46, 204, 113, .3);
}

.btn-hit:hover:not(:disabled) {
    box-shadow: 0 6px 25px rgba(46, 204, 113, .5);
    transform: translateY(-2px);
}

.btn-stand {
    background: linear-gradient(135deg, var(--danger), #c0392b);
    color: #fff;
    box-shadow: 0 4px 15px rgba(231, 76, 60, .3);
}

.btn-stand:hover:not(:disabled) {
    box-shadow: 0 6px 25px rgba(231, 76, 60, .5);
    transform: translateY(-2px);
}

.btn-icon {
    margin-right: .4rem;
}

/* ---------- Table Layout ---------- */
.table {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 1.5rem 2rem;
    position: relative;
}

/* ---------- Zones ---------- */
.zone {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius);
    padding: 1.2rem 1.8rem;
    min-width: 280px;
    text-align: center;
    position: relative;
    transition: box-shadow var(--transition);
}

.zone-label {
    font-weight: 600;
    font-size: .85rem;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: var(--text-dim);
    margin-bottom: .6rem;
}

.dealer-zone {
    margin-top: .5rem;
    margin-bottom: auto;
}

.players-row {
    display: flex;
    gap: 3rem;
    justify-content: center;
    flex-wrap: wrap;
    margin-bottom: auto;
}

.player-zone.active-turn {
    box-shadow: 0 0 25px rgba(212, 175, 55, .5), inset 0 0 15px rgba(212, 175, 55, .1);
    border-color: var(--gold);
}

.player-zone .zone-label.is-you {
    color: var(--gold-light);
}

/* ---------- Cards ---------- */
.cards {
    display: flex;
    gap: -10px;
    justify-content: center;
    min-height: 120px;
    align-items: flex-end;
    padding: .3rem 0;
}

.card-img {
    width: 85px;
    height: auto;
    border-radius: 6px;
    box-shadow: var(--card-shadow);
    transition: transform var(--transition);
    animation: dealIn .4s ease-out backwards;
    margin-left: -12px;
}

.card-img:first-child {
    margin-left: 0;
}

.card-img:hover {
    transform: translateY(-8px) scale(1.05);
}

/* Stagger animation delay for each card */
.card-img:nth-child(1) {
    animation-delay: 0s;
}

.card-img:nth-child(2) {
    animation-delay: .1s;
}

.card-img:nth-child(3) {
    animation-delay: .2s;
}

.card-img:nth-child(4) {
    animation-delay: .3s;
}

.card-img:nth-child(5) {
    animation-delay: .4s;
}

.card-img:nth-child(6) {
    animation-delay: .5s;
}

.card-img:nth-child(7) {
    animation-delay: .6s;
}

/* ---------- Score Badge ---------- */
.score-badge {
    display: inline-block;
    background: rgba(0, 0, 0, .5);
    padding: .3rem .9rem;
    border-radius: 20px;
    font-size: .9rem;
    font-weight: 600;
    margin-top: .5rem;
    min-width: 40px;
}

/* ---------- Result Badge ---------- */
.result-badge {
    display: none;
    margin-top: .5rem;
    padding: .35rem 1rem;
    border-radius: 20px;
    font-weight: 700;
    font-size: .85rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.result-badge.show {
    display: inline-block;
}

.result-badge.win {
    background: var(--success);
    color: #fff;
}

.result-badge.lose {
    background: var(--danger);
    color: #fff;
}

.result-badge.push {
    background: var(--push-color);
    color: #1a1a1a;
}

.result-badge.blackjack {
    background: linear-gradient(135deg, var(--gold), var(--gold-light));
    color: #1a1a1a;
}

/* ---------- Controls ---------- */
.controls {
    display: flex;
    gap: 1.2rem;
    margin-top: .5rem;
    margin-bottom: 1rem;
}

/* ---------- Game Status ---------- */
.game-status {
    font-size: .95rem;
    color: var(--gold-light);
    min-height: 1.4em;
    text-align: center;
    margin-bottom: .5rem;
}

/* ---------- New Game Button ---------- */
.btn-new-game {
    margin-bottom: 1rem;
}

.hidden {
    display: none !important;
}

/* ---------- Result Overlay ---------- */
.result-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .7);
    backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    animation: fadeIn .3s ease;
}

.result-content {
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    padding: 2.5rem 3.5rem;
    text-align: center;
    animation: scaleUp .35s ease-out;
}

.result-content h2 {
    font-size: 2.2rem;
    margin-bottom: .5rem;
}

.result-content p {
    font-size: 1rem;
    color: var(--text-dim);
    margin-bottom: 1.5rem;
}

/* ---------- Toast ---------- */
.toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(231, 76, 60, .9);
    backdrop-filter: blur(8px);
    padding: .8rem 1.6rem;
    border-radius: 10px;
    font-size: .9rem;
    font-weight: 600;
    z-index: 200;
    animation: slideUp .3s ease-out;
}

/* ---------- Animations ---------- */
@keyframes fadeUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes scaleUp {
    from {
        opacity: 0;
        transform: scale(.85);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes dealIn {
    from {
        opacity: 0;
        transform: translateY(-40px) scale(.7);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translate(-50%, 20px);
    }

    to {
        opacity: 1;
        transform: translate(-50%, 0);
    }
}

@keyframes pulse {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.08);
    }
}

@keyframes blink {
    50% {
        opacity: .4;
    }
}

/* ---------- Responsive ---------- */
@media (max-width: 700px) {
    .players-row {
        gap: 1rem;
    }

    .zone {
        min-width: 200px;
        padding: .8rem 1rem;
    }

    .card-img {
        width: 65px;
        margin-left: -8px;
    }

    .logo h1 {
        font-size: 2.2rem;
    }

    .controls {
        gap: .6rem;
    }

    .btn {
        padding: .7rem 1.5rem;
        font-size: .95rem;
    }
}