:root {
    /* Color Palette - Premium Casino Green Theme */
    --color-bg-primary: #0a2f1c;
    --color-bg-secondary: #0f3d24;
    --color-bg-card: #14452b;

    --color-accent-primary: #ebb305;
    --color-accent-secondary: #f59e0b;
    --color-success: #10b981;
    --color-error: #ef4444;
    --color-text-primary: #ffffff;
    --color-text-secondary: #a7f3d0;

    /* Spacing */
    --spacing-xs: 4px;
    --spacing-sm: 8px;
    --spacing-md: 16px;
    --spacing-lg: 24px;
    --spacing-xl: 32px;

    /* Border Radius */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 20px;
    --radius-full: 9999px;

    /* Typography */
    --font-heading: 'Outfit', sans-serif;
    --font-body: 'Inter', sans-serif;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    background-color: var(--color-bg-primary);
    color: var(--color-text-primary);
    font-family: var(--font-body);
    font-size: 16px;
    line-height: 1.5;
    height: 100vh;
    overflow: hidden;
}

#app {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    position: relative;
}

h1,
h2,
h3,
h4,
h5,
h6 {
    font-family: var(--font-heading);
    font-weight: 700;
}

button {
    cursor: pointer;
    border: none;
    outline: none;
    font-family: var(--font-heading);
    transition: all 0.2s ease;
}

/* Utilities */
.hidden {
    display: none !important;
}

.flex-center {
    display: flex;
    justify-content: center;
    align-items: center;
}

.w-full {
    width: 100%;
}

/* Home Screen */
.home-screen {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: var(--spacing-lg);
    background: radial-gradient(circle at top right, #1a4d2e, #0a2f1c);
}

.hero-section {
    margin-top: var(--spacing-xl);
    margin-bottom: var(--spacing-xl);
    text-align: center;
}

.hero-section h1 {
    font-size: 2.5rem;
    margin-bottom: var(--spacing-sm);
    letter-spacing: -0.02em;
}

.hero-section p {
    color: var(--color-text-secondary);
    font-size: 1.1rem;
}

.main-menu {
    display: grid;
    gap: var(--spacing-md);
    margin-top: auto;
    margin-bottom: auto;
}

.menu-btn {
    display: flex;
    align-items: center;
    padding: var(--spacing-lg);
    border-radius: var(--radius-lg);
    background: var(--color-bg-card);
    color: var(--color-text-primary);
    text-align: left;
    border: 1px solid rgba(255, 255, 255, 0.05);
    position: relative;
    overflow: hidden;
}

.menu-btn:active {
    transform: scale(0.98);
    background: var(--color-bg-secondary);
}

.menu-btn.primary {
    background: var(--color-bg-card);
    color: var(--color-text-primary);
}

.home-footer {
    text-align: center;
    padding-top: var(--spacing-lg);
    color: var(--color-text-secondary);
    font-size: 0.8rem;
    opacity: 0.5;
}

/* Card Styling */
.card-scene {
    width: 180px;
    height: 252px;
    margin: 6px;
    perspective: 800px;
    display: inline-block;
}

.card-object {
    position: relative;
    width: 100%;
    height: 100%;
    transition: transform 0.8s;
    transform-style: preserve-3d;
    transform: rotateY(180deg);
    animation: deal-slide 0.5s ease-out forwards;
}

.card-object.reveal {
    transform: rotateY(0deg);
}

@keyframes deal-slide {
    from {
        opacity: 0;
        margin-top: -50px;
    }

    to {
        opacity: 1;
        margin-top: 0;
    }
}

.card-face {
    position: absolute;
    width: 100%;
    height: 100%;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    border-radius: var(--radius-sm);
}

.card-face-front {
    background-color: white;
    display: flex;
    align-items: center;
    justify-content: center;
}

.card-face-front img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.card-face-back {
    background-color: white;
    background-image: url('../assets/card-back.jpg');
    background-size: cover;
    background-position: center;
    border: 1px solid #ddd;
    transform: rotateY(180deg) rotate(180deg);
}

/* Drill Screen */
.drill-screen {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--color-bg-primary);
}

.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--spacing-md);
    background: var(--color-bg-secondary);
}

.timer-display,
.score-display {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.timer-display .label,
.score-display .label {
    font-size: 10px;
    color: var(--color-text-secondary);
    letter-spacing: 1px;
}

.timer-display .value,
.score-display .value {
    font-family: var(--font-heading);
    font-size: 1.2rem;
    font-weight: 700;
}

.timer-display .value.warning {
    color: var(--color-error);
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }

    100% {
        opacity: 1;
    }
}

.running-count-display {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: rgba(0, 0, 0, 0.2);
    padding: var(--spacing-sm);
    margin: 0 var(--spacing-md);
    border-radius: var(--radius-md);
}

.running-count-display .label {
    font-size: 10px;
    color: var(--color-text-secondary);
    letter-spacing: 1px;
}

.running-count-display .value {
    font-family: var(--font-heading);
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--color-accent-primary);
}

.exit-btn {
    background: none;
    color: var(--color-text-secondary);
    font-size: 1.5rem;
    padding: var(--spacing-sm);
}

/* Game Stage */
.game-stage {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 8vh;
    width: 100%;
    padding: var(--spacing-md);
    min-height: 0;
}

.game-board {
    flex: 0 1 auto;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    align-content: center;
    perspective: 1000px;
    width: 100%;
}

.controls-area {
    padding: 0;
    margin: 0;
    border: none;
    background: transparent;
    display: flex;
    justify-content: center;
    width: 100%;
}

.numpad-grid {
    display: flex;
    justify-content: center;
    gap: var(--spacing-sm);
    flex-wrap: wrap;
    width: 100%;
    max-width: 800px;
}

.num-btn {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--color-bg-card);
    color: var(--color-text-primary);
    font-size: 1.2rem;
    font-weight: bold;
    border: 2px solid rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
}

.num-btn:active {
    background: var(--color-accent-primary);
    transform: translateY(2px) scale(0.95);
    border-color: var(--color-accent-primary);
}

.feedback-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 5rem;
    font-weight: bold;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s;
    z-index: 10;
}

.feedback-overlay.correct {
    color: var(--color-success);
    opacity: 1;
    animation: pop 0.2s ease-out;
}

.feedback-overlay.wrong {
    color: var(--color-error);
    opacity: 1;
    animation: shake 0.3s;
}

@keyframes pop {
    0% {
        transform: translate(-50%, -50%) scale(0.5);
    }

    100% {
        transform: translate(-50%, -50%) scale(1.2);
    }
}

.modal-screen {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-lg);
    padding: var(--spacing-xl);
}

.final-score {
    text-align: center;
    margin-bottom: var(--spacing-lg);
}

.final-score .big-number {
    display: block;
    font-size: 4rem;
    font-weight: 900;
    color: var(--color-accent-primary);
    line-height: 1;
}

@keyframes glow-pulse {
    0% {
        text-shadow: 0 0 5px rgba(235, 179, 5, 0.5), 0 0 10px rgba(235, 179, 5, 0.3);
    }

    50% {
        text-shadow: 0 0 20px rgba(235, 179, 5, 0.8), 0 0 30px rgba(235, 179, 5, 0.5);
    }

    100% {
        text-shadow: 0 0 5px rgba(235, 179, 5, 0.5), 0 0 10px rgba(235, 179, 5, 0.3);
    }
}

.glow-text {
    animation: glow-pulse 2s infinite ease-in-out;
}

/* =========================================
   REWARD ANIMATIONS
   ========================================= */

/* 1. Fire Reward (Streak > 5) */
.fire-overlay {
    position: absolute;
    top: 85%;
    /* Just below controls */
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 10rem;
    pointer-events: none;
    z-index: 2000;
    opacity: 0;
    filter: drop-shadow(0 0 20px orange) drop-shadow(0 0 40px red) brightness(1.5);
}

.fire-overlay.purple {
    filter: hue-rotate(270deg) drop-shadow(0 0 20px #d8b4fe) drop-shadow(0 0 40px #a855f7) brightness(2.0);
}

.fire-overlay.animate-fire {
    animation: fire-pop 3s ease-out forwards;
}

@keyframes fire-pop {
    0% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.2) rotate(-10deg);
    }

    10% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1.2) rotate(10deg);
    }

    20% {
        transform: translate(-50%, -50%) scale(1.0) rotate(-5deg);
    }

    30% {
        transform: translate(-50%, -50%) scale(1.1) rotate(5deg);
    }

    40% {
        transform: translate(-50%, -50%) scale(1.0) rotate(-5deg);
    }

    50% {
        transform: translate(-50%, -50%) scale(1.1) rotate(5deg);
    }

    60% {
        transform: translate(-50%, -50%) scale(1.0) rotate(-5deg);
    }

    70% {
        transform: translate(-50%, -50%) scale(1.1) rotate(5deg);
    }

    100% {
        opacity: 0;
        transform: translate(-50%, -150%) scale(2) rotate(0deg);
    }
}

/* 2. Chip Stack Reward (Streak > 8) */
.chip-overlay {
    position: absolute;
    top: 85%;
    /* Same pos as Fire */
    left: 50%;
    transform: translate(-50%, -50%);
    width: 300px;
    height: 300px;
    pointer-events: none;
    z-index: 2001;
    display: flex;
    justify-content: center;
    align-items: flex-end;
    opacity: 0;
}

.chip-overlay.animate-chips {
    animation: fade-in-out 3s ease-in-out forwards;
}

.chip {
    width: 100px;
    height: 28px;
    background: radial-gradient(circle at 30% 30%, #ffd700, #b8860b);
    border: 4px dashed #fff;
    border-radius: 50%;
    box-shadow: 0 4px 0 #8b6508, 0 5px 10px rgba(0, 0, 0, 0.5);
    position: absolute;
    bottom: 0;
    opacity: 0;
}

.chip:nth-child(1) {
    bottom: 0;
    animation: chip-drop 0.5s ease-out 0s forwards;
}

.chip:nth-child(2) {
    bottom: 15px;
    animation: chip-drop 0.5s ease-out 0.1s forwards;
}

.chip:nth-child(3) {
    bottom: 30px;
    animation: chip-drop 0.5s ease-out 0.2s forwards;
}

.chip:nth-child(4) {
    bottom: 45px;
    animation: chip-drop 0.5s ease-out 0.3s forwards;
}

.chip:nth-child(5) {
    bottom: 60px;
    animation: chip-drop 0.5s ease-out 0.4s forwards;
}

@keyframes chip-drop {
    0% {
        transform: translateY(-400px);
        opacity: 0;
    }

    70% {
        transform: translateY(0);
        opacity: 1;
    }

    85% {
        transform: translateY(-10px);
    }

    100% {
        transform: translateY(0);
        opacity: 1;
    }
}

@keyframes fade-in-out {
    0% {
        opacity: 1;
    }

    80% {
        opacity: 1;
    }

    100% {
        opacity: 0;
    }
}

/* Mega Chips (Streak 20) */
.chip-overlay.mega-chips .chip {
    animation-duration: 0.3s;
    /* Faster drop */
    box-shadow: 0 0 15px #ffd700;
    /* Glowing chips */
}

.chip-overlay.mega-chips .chip:nth-child(even) {
    background: radial-gradient(circle at 30% 30%, #fff, #bfbfbf);
    /* Silver chips mixed in */
    border-color: #ffd700;
}

/* 3. Streak Text Animation */
.streak-message,
.pit-boss-message {
    position: absolute;
    top: 30%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-family: var(--font-heading);
    font-size: 4rem;
    font-weight: 900;
    color: #fff;
    text-transform: uppercase;
    text-shadow: 0 0 10px #ebb305, 0 0 20px #ebb305, 0 0 40px #f59e0b;
    z-index: 2002;
    pointer-events: none;
    opacity: 0;
    white-space: nowrap;
}

.pit-boss-message {
    color: #ef4444;
    /* Red for ALARM */
    text-shadow: 0 0 10px #ef4444, 0 0 20px #b91c1c, 0 0 40px #7f1d1d;
    font-size: 5rem;
    z-index: 2005;
}

.streak-message.animate-text,
.pit-boss-message.animate-text {
    animation: text-zoom-shake 2s ease-out forwards;
}

/* Pit Boss Specific Animation (More aggressive shake) */
.pit-boss-message.animate-text {
    animation: pit-boss-alarm 3s ease-out forwards;
}

@keyframes pit-boss-alarm {
    0% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.5) rotate(0deg);
    }

    10% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1.5) rotate(-10deg);
    }

    15% {
        transform: translate(-52%, -50%) scale(1.3) rotate(10deg);
    }

    20% {
        transform: translate(-48%, -50%) scale(1.3) rotate(-10deg);
    }

    25% {
        transform: translate(-52%, -50%) scale(1.3) rotate(10deg);
    }

    30% {
        transform: translate(-48%, -50%) scale(1.3) rotate(-10deg);
    }

    40% {
        transform: translate(-50%, -50%) scale(1.3) rotate(0deg);
    }

    80% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1.3);
    }

    100% {
        opacity: 0;
        transform: translate(-50%, -150%) scale(2);
    }
}

@keyframes text-zoom-shake {
    0% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.5) rotate(-5deg);
    }

    10% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1.2) rotate(5deg);
    }

    20% {
        transform: translate(-50%, -50%) scale(1.0) rotate(-3deg);
    }

    30% {
        transform: translate(-50%, -50%) scale(1.1) rotate(3deg);
    }

    40% {
        transform: translate(-50%, -50%) scale(1.0) rotate(-2deg);
    }

    80% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1.0) rotate(0deg);
    }

    100% {
        opacity: 0;
        transform: translate(-50%, -80%) scale(1.5);
    }
}

/* =========================================
   MOBILE RESPONSIVENESS (iPhone 14 Pro Max & others)
   ========================================= */
@media (max-width: 768px) {

    /* Adjust Fire Size */
    .fire-overlay {
        font-size: 6rem;
        /* Smaller fire on phone */
        top: 85%;
        /* Adjusted to 85% */
    }

    /* Adjust Chip Size */
    .chip-overlay {
        width: 200px;
        height: 200px;
        top: 85%;
        /* Match fire position */
    }

    .chip {
        width: 70px;
        height: 20px;
        border-width: 3px;
    }

    /* Adjust Streak Text */
    .streak-message,
    .pit-boss-message {
        font-size: 2.5rem;
        /* Prevent wrapping/overflow */
        top: 25%;
        /* Move up slightly to avoid cards */
        width: 90%;
        /* Ensure it fits width */
        text-align: center;
        white-space: normal;
        /* Allow wrap if absolutely needed, but 2.5rem should fit "ON A STREAK!" */
    }

    .pit-boss-message {
        font-size: 3rem;
        /* Slightly larger than streak */
    }

    /* Adjust Numpad for easier tapping */
    .num-btn {
        width: 50px;
        height: 50px;
        font-size: 1rem;
    }
}

@keyframes float-up {
    0% {
        transform: translateY(0);
        opacity: 1;
    }

    100% {
        transform: translateY(-20px);
        opacity: 0;
    }
}

/* Flow State Text */
.flow-state-message {
    position: absolute;
    top: 30%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-family: var(--font-heading);
    font-size: 3.5rem;
    font-weight: 900;
    color: #22d3ee;
    /* Cyan */
    text-transform: uppercase;
    text-shadow: 0 0 10px #06b6d4, 0 0 20px #0891b2, 0 0 40px #0e7490;
    z-index: 2005;
    pointer-events: none;
    opacity: 0;
    white-space: nowrap;
    text-align: center;
}

.flow-state-message.animate-flow-text {
    animation: flow-state-zoom 4s ease-out forwards;
}

@keyframes flow-state-zoom {
    0% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.5);
    }

    10% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1.2);
    }

    80% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1.4) skewX(-10deg);
    }

    100% {
        opacity: 0;
        transform: translate(-50%, -150%) scale(2);
    }
}

/* Blackjack Rain */
.blackjack-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 2004;
}

.falling-symbol {
    position: absolute;
    top: -10%;
    color: #000;
    font-weight: bold;
    text-shadow: 0 0 5px rgba(255, 255, 255, 0.5);
    animation: symbol-fall 3s linear forwards;
}

@keyframes symbol-fall {
    to {
        transform: translateY(110vh) rotate(360deg);
    }
}

@media (max-width: 768px) {
    .flow-state-message {
        font-size: 2rem;
        width: 90%;
        white-space: normal;
    }
}

/* Continuous Rain Animation */
@keyframes rain-fall {
    0% {
        transform: translateY(-10vh) rotate(0deg);
        opacity: 1;
    }

    90% {
        opacity: 1;
    }

    100% {
        transform: translateY(110vh) rotate(720deg);
        opacity: 0;
    }
}