* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --primary-light: #818cf8;
    --success: #22c55e;
    --success-bg: rgba(34, 197, 94, 0.15);
    --danger: #ef4444;
    --danger-bg: rgba(239, 68, 68, 0.15);
    --bg-dark: #0f172a;
    --bg-card: #1e293b;
    --bg-card-hover: #334155;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --border: #334155;
    --card-red: #dc2626;
    --card-black: #1e293b;
    --felt-green: #166534;
    --gold: #fbbf24;
}

html, body {
    height: 100%;
    overflow-x: hidden;
    overflow-y: auto;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: linear-gradient(135deg, var(--bg-dark) 0%, #1a1a2e 100%);
    color: var(--text-primary);
    min-height: 100vh;
    min-height: 100dvh;
}

#app {
    max-width: 500px;
    margin: 0 auto;
    min-height: 100vh;
    min-height: 100dvh;
    position: relative;
}

/* Screens */
.screen {
    display: none;
    min-height: 100vh;
    min-height: 100dvh;
    padding: 1.5rem;
    padding-bottom: env(safe-area-inset-bottom, 1.5rem);
    flex-direction: column;
}

.screen.active {
    display: flex;
}

/* Start Screen */
#start-screen {
    justify-content: center;
    align-items: center;
    text-align: center;
    gap: 3rem;
}

.logo {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.logo-icon {
    font-size: 4rem;
    animation: float 3s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

.logo h1 {
    font-size: 2.5rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary-light), var(--primary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.tagline {
    color: var(--text-secondary);
    font-size: 1.1rem;
}

.start-content {
    width: 100%;
    max-width: 350px;
}

.rules {
    background: var(--bg-card);
    border-radius: 1rem;
    padding: 1.5rem;
    margin-bottom: 2rem;
    text-align: left;
}

.rules h3 {
    font-size: 1rem;
    color: var(--text-secondary);
    margin-bottom: 1rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.rules ul {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.rules li {
    font-size: 0.95rem;
    color: var(--text-primary);
    line-height: 1.4;
}

/* Buttons */
.btn {
    border: none;
    border-radius: 0.75rem;
    padding: 1rem 2rem;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    width: 100%;
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.4);
}

.btn-primary:active {
    transform: translateY(0);
}

/* Game Screen */
#game-screen {
    padding: 1rem;
    gap: 0.75rem;
}

.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    background: var(--bg-card);
    border-radius: 1rem;
}

.game-header .label {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    display: block;
}

.game-header .value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
}

.score .value {
    color: var(--gold);
}

.lives {
    font-size: 1.25rem;
    letter-spacing: 2px;
}

/* Boss Mode Indicator */
.boss-indicator {
    background: linear-gradient(135deg, #7c3aed, #db2777);
    border-radius: 1rem;
    padding: 0.75rem 1rem;
    text-align: center;
    animation: bossGlow 2s ease-in-out infinite;
    margin-bottom: 0.5rem;
}

.boss-indicator.hidden {
    display: none;
}

@keyframes bossGlow {
    0%, 100% { box-shadow: 0 0 20px rgba(219, 39, 119, 0.5); }
    50% { box-shadow: 0 0 30px rgba(124, 58, 237, 0.7); }
}

.boss-title {
    font-size: 1rem;
    font-weight: 700;
    color: white;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: 0.5rem;
}

.boss-progress {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
}

.boss-stage {
    font-size: 0.7rem;
    padding: 0.25rem 0.5rem;
    border-radius: 0.5rem;
    background: rgba(255, 255, 255, 0.2);
    color: rgba(255, 255, 255, 0.7);
    transition: all 0.3s ease;
}

.boss-stage.current {
    background: white;
    color: #7c3aed;
    font-weight: 600;
    transform: scale(1.1);
}

.boss-stage.completed {
    background: rgba(34, 197, 94, 0.8);
    color: white;
}

/* Boss mode choice buttons */
.choice-btn.boss-choice {
    border-color: #7c3aed;
    background: linear-gradient(135deg, rgba(124, 58, 237, 0.1), rgba(219, 39, 119, 0.1));
}

.choice-btn.boss-choice:hover {
    border-color: #db2777;
    background: linear-gradient(135deg, rgba(124, 58, 237, 0.2), rgba(219, 39, 119, 0.2));
}

/* Boss reward text */
.boss-reward {
    color: var(--gold) !important;
    font-weight: 600;
    animation: pulse 1s ease infinite;
}

/* Chance Mode */
.chance-indicator {
    background: linear-gradient(135deg, #10b981, #059669);
    border-radius: 1rem;
    padding: 0.6rem 1rem;
    text-align: center;
    animation: chanceGlow 1.5s ease-in-out infinite;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: white;
}

.chance-indicator.hidden {
    display: none;
}

@keyframes chanceGlow {
    0%, 100% { box-shadow: 0 0 15px rgba(16, 185, 129, 0.5); }
    50% { box-shadow: 0 0 25px rgba(5, 150, 105, 0.7); }
}

.chance-label {
    color: var(--gold);
    font-weight: 600;
    font-size: 0.95rem;
    margin-bottom: 0.75rem;
    animation: pulse 1.5s ease infinite;
}

.choice-btn.chance-choice {
    border-color: #10b981;
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.1), rgba(5, 150, 105, 0.1));
}

.choice-btn.chance-choice:hover {
    border-color: #059669;
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.2), rgba(5, 150, 105, 0.2));
}

.choice-btn.skip-chance {
    background: transparent;
    border-color: var(--text-muted);
    color: var(--text-secondary);
    font-size: 0.9rem;
    padding: 0.75rem;
}

.choice-btn.skip-chance:hover {
    border-color: var(--text-secondary);
    color: var(--text-primary);
}

.chance-reward {
    color: #10b981 !important;
    font-weight: 600;
    animation: pulse 1s ease infinite;
}

/* Loading indicator */
.loading {
    color: var(--text-secondary);
    text-align: center;
    padding: 1.5rem;
    font-size: 0.95rem;
}

.loading::after {
    content: '';
    animation: loadingDots 1.5s infinite;
}

@keyframes loadingDots {
    0%, 20% { content: '.'; }
    40% { content: '..'; }
    60%, 100% { content: '...'; }
}

/* Game Area */
.game-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    overflow-y: auto;
}

.section-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: 0.5rem;
    text-align: center;
}

/* Opponents */
.opponents-section {
    text-align: center;
}

.opponents {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.opponent {
    background: var(--bg-card);
    border-radius: 0.75rem;
    padding: 0.5rem 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.85rem;
}

.opponent-icon {
    font-size: 1.1rem;
}

.opponent-cards {
    display: flex;
    gap: 2px;
}

.mini-card {
    width: 18px;
    height: 24px;
    background: linear-gradient(135deg, #475569, #334155);
    border-radius: 3px;
    border: 1px solid var(--border);
}

/* Cards */
.cards {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
}

.card {
    width: 55px;
    height: 77px;
    background: white;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    position: relative;
    transition: transform 0.2s ease;
}

.card.red {
    color: var(--card-red);
}

.card.black {
    color: var(--card-black);
}

/* Card dealing animation */
.card.dealing {
    animation: dealCard 0.4s cubic-bezier(0.22, 1, 0.36, 1) backwards;
}

.card.dealing-player {
    animation: dealPlayerCard 0.5s cubic-bezier(0.22, 1, 0.36, 1) backwards;
}

@keyframes dealCard {
    0% {
        transform: translateY(-80px) translateX(100px) rotate(15deg) scale(0.5);
        opacity: 0;
    }
    100% {
        transform: translateY(0) translateX(0) rotate(0deg) scale(1);
        opacity: 1;
    }
}

@keyframes dealPlayerCard {
    0% {
        transform: translateY(-120px) rotate(-10deg) scale(0.3);
        opacity: 0;
    }
    60% {
        transform: translateY(5px) rotate(2deg) scale(1.05);
    }
    100% {
        transform: translateY(0) rotate(0deg) scale(1);
        opacity: 1;
    }
}

/* Opponent dealing animation */
.opponent.dealing {
    animation: dealOpponent 0.3s cubic-bezier(0.22, 1, 0.36, 1) backwards;
}

@keyframes dealOpponent {
    0% {
        transform: translateY(-30px) scale(0.8);
        opacity: 0;
    }
    100% {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
}

/* Empty card placeholder animation */
.card.empty.dealing {
    animation: fadeInEmpty 0.3s ease backwards;
}

@keyframes fadeInEmpty {
    0% {
        opacity: 0;
        transform: scale(0.9);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

/* Card reveal animation (for continuing hands) */
.card.dealing-reveal {
    animation: revealCard 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes revealCard {
    0% {
        transform: rotateY(180deg) scale(0.8);
        opacity: 0;
        filter: brightness(2);
    }
    50% {
        transform: rotateY(90deg) scale(1.1);
        filter: brightness(1.5);
    }
    100% {
        transform: rotateY(0deg) scale(1);
        opacity: 1;
        filter: brightness(1);
    }
}

.card .rank {
    font-size: 1.3rem;
    line-height: 1;
}

.card .suit {
    font-size: 1.4rem;
    line-height: 1;
}

.card.empty {
    background: rgba(255, 255, 255, 0.1);
    border: 2px dashed var(--border);
    box-shadow: none;
}

.card.empty::after {
    content: '?';
    font-size: 1.5rem;
    color: var(--text-muted);
}

/* Community Cards */
.community-section {
    background: linear-gradient(135deg, var(--felt-green), #15803d);
    border-radius: 1rem;
    padding: 1rem;
    box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.3);
}

.community-section .section-label {
    color: rgba(255, 255, 255, 0.7);
}

.community-cards {
    min-height: 77px;
}

/* Player Cards */
.player-section {
    text-align: center;
}

.player-cards .card {
    width: 65px;
    height: 91px;
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.3);
    border: 2px solid var(--primary);
}

.player-cards .card .rank {
    font-size: 1.5rem;
}

.player-cards .card .suit {
    font-size: 1.6rem;
}

/* Question Section */
.question-section {
    text-align: center;
    margin-top: auto;
}

.question {
    font-size: 1.1rem;
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

.choices {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.choice-btn {
    background: var(--bg-card);
    border: 2px solid var(--border);
    border-radius: 0.75rem;
    padding: 1rem;
    color: var(--text-primary);
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
}

.choice-btn:hover {
    background: var(--bg-card-hover);
    border-color: var(--primary);
}

.choice-btn:active {
    transform: scale(0.98);
}

.choice-btn.correct {
    background: var(--success-bg);
    border-color: var(--success);
    color: var(--success);
}

.choice-btn.incorrect {
    background: var(--danger-bg);
    border-color: var(--danger);
    color: var(--danger);
}

.choice-btn.actual {
    border-color: var(--success);
    box-shadow: 0 0 0 2px var(--success);
}

/* Result Popup */
.result-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.3);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    z-index: 100;
    padding: 1.5rem;
    padding-bottom: 2rem;
    opacity: 1;
    transition: opacity 0.2s ease;
}

.result-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.result-content {
    text-align: center;
    max-width: 350px;
    width: 100%;
    background: var(--bg-card);
    border-radius: 1.25rem;
    padding: 1.5rem;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(255, 255, 255, 0.1);
    transform: translateY(0);
    animation: slideUp 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.result-overlay.hidden .result-content {
    transform: translateY(100%);
}

@keyframes slideUp {
    0% { 
        transform: translateY(100%);
        opacity: 0;
    }
    100% { 
        transform: translateY(0);
        opacity: 1;
    }
}

.result-header {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.result-icon {
    font-size: 2rem;
    animation: pop 0.3s ease 0.1s both;
}

@keyframes pop {
    0% { transform: scale(0); }
    50% { transform: scale(1.3); }
    100% { transform: scale(1); }
}

.result-text {
    font-size: 1.25rem;
    font-weight: 700;
}

.result-text.correct {
    color: var(--success);
}

.result-text.incorrect {
    color: var(--danger);
}

.actual-probability {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 1.25rem;
    line-height: 1.5;
}

.actual-probability strong {
    color: var(--text-primary);
    font-size: 1.1rem;
}

.result-content .btn {
    padding: 0.875rem 1.5rem;
    font-size: 1rem;
}

/* Game Over Screen */
#gameover-screen {
    justify-content: center;
    align-items: center;
    text-align: center;
}

.gameover-content {
    width: 100%;
    max-width: 350px;
}

.gameover-content h2 {
    font-size: 2.5rem;
    margin-bottom: 2rem;
    color: var(--danger);
}

.final-score {
    background: var(--bg-card);
    border-radius: 1rem;
    padding: 1.5rem;
    margin-bottom: 1rem;
}

.final-score .label {
    display: block;
    font-size: 0.85rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.5rem;
}

.final-score .value {
    font-size: 3rem;
    font-weight: 700;
    color: var(--gold);
}

.high-score {
    background: var(--bg-card);
    border-radius: 1rem;
    padding: 1rem;
    margin-bottom: 1rem;
}

.high-score .label {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.25rem;
}

.high-score .value {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.new-record {
    font-size: 1.25rem;
    color: var(--gold);
    margin-bottom: 1rem;
    animation: pulse 1s ease infinite;
}

.new-record.hidden {
    display: none;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

#gameover-screen .btn {
    margin-top: 1rem;
}

/* Loading animation for calculation */
.calculating {
    pointer-events: none;
    opacity: 0.7;
}

.calculating .choice-btn {
    position: relative;
}

/* Responsive adjustments */
@media (max-height: 700px) {
    .card {
        width: 48px;
        height: 67px;
    }
    
    .card .rank {
        font-size: 1.1rem;
    }
    
    .card .suit {
        font-size: 1.2rem;
    }
    
    .player-cards .card {
        width: 55px;
        height: 77px;
    }
    
    .community-section {
        padding: 0.75rem;
    }
}

@media (max-height: 600px) {
    #game-screen {
        padding: 0.5rem;
        gap: 0.5rem;
    }
    
    .game-header {
        padding: 0.5rem 0.75rem;
    }
    
    .section-label {
        margin-bottom: 0.25rem;
    }
}

/* Dark mode card styling enhancement */
.card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(255,255,255,0.1) 0%, transparent 50%);
    border-radius: 6px;
    pointer-events: none;
}
