:root {
    --bg-color: #2c1e4a;
    --accent: #ffc107; /* Gold */
    --danger: #ff3d00; /* Red */
    --success: #00e676; /* Green */
    --card-bg: #452c78;
    --text-color: #ffffff;
}

* { box-sizing: border-box; margin: 0; padding: 0; user-select: none; -webkit-tap-highlight-color: transparent; }

body {
    font-family: 'Roboto', sans-serif;
    background: radial-gradient(circle at top, #3b2a60 0%, #1a102e 100%);
    color: var(--text-color);
    height: 100vh;
    overflow: auto;
    display: flex;
    justify-content: center;
}

.app-container {
    width: 100%;
    max-width: 450px;
    height: 100%;
    display: flex;
    flex-direction: column;
    padding: 15px;
    position: relative;
    transition: background 0.3s;
}

/* Header */
.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    margin-bottom: 10px;
}
.logo-area { font-family: 'Titan One', cursive; font-size: 1.2rem; color: var(--accent); }
.wallet-badge {
    background: rgba(0,0,0,0.4);
    border: 1px solid rgba(255,255,255,0.1);
    padding: 8px 15px;
    border-radius: 20px;
    font-weight: 900;
    display: flex; gap: 5px;
}
#prize-money { color: var(--success); font-size: 1.1rem; }

/* Instructions */
.instruction-box { text-align: center; margin-bottom: 20px; }
#status-text { font-family: 'Titan One', cursive; font-size: 1.8rem; color: #fff; text-shadow: 0 3px 0 #000; transition: color 0.3s; }

/* Grid */
.grid-container {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    padding: 5px;
}

.tile { aspect-ratio: 1; position: relative; perspective: 1000px; cursor: pointer; }
.tile-inner { position: relative; width: 100%; height: 100%; text-align: center; transition: transform 0.4s; transform-style: preserve-3d; }
.tile.flipped .tile-inner { transform: rotateY(180deg); }

.tile-front, .tile-back {
    position: absolute; width: 100%; height: 100%;
    backface-visibility: hidden; border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
}
.tile-front {
    background: linear-gradient(145deg, #5e3c9e, #452c78);
    border-bottom: 5px solid #2a1b4a;
    box-shadow: 0 4px 10px rgba(0,0,0,0.3);
}
.tile-front img { width: 55%; opacity: 0.9; }

.tile-back { background: #fff; transform: rotateY(180deg); border-bottom: 5px solid #ccc; }
.tile-back img { width: 75%; }

/* --- STICKY CASHOUT BUTTON --- */
.hidden { display: none !important; }
.cashout-wrapper {
    margin-top: auto;
    text-align: center;
    padding-bottom: 20px;
    animation: slideUp 0.5s ease;
}
.cashout-btn {
    display: block;
    width: 100%;
    background: linear-gradient(180deg, #00e676 0%, #00c853 100%);
    color: #fff;
    text-decoration: none;
    font-family: 'Titan One', cursive;
    font-size: 1.5rem;
    padding: 15px;
    border-radius: 15px;
    border-bottom: 6px solid #009624;
    text-shadow: 0 1px 2px rgba(0,0,0,0.3);
    box-shadow: 0 10px 20px rgba(0,230,118,0.3);
}
.cashout-sub { margin-top: 8px; font-size: 0.8rem; color: #aaa; }
.pulse-green { animation: pulse 1.5s infinite; }

/* --- RECOVERY MODAL --- */
#modal-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.9); z-index: 100;
    display: flex; justify-content: center; align-items: center;
    backdrop-filter: blur(5px);
    animation: fadeIn 0.3s;
}
.modal-card {
    background: #fff; width: 90%; max-width: 400px;
    border-radius: 20px; overflow: hidden; text-align: center;
    box-shadow: 0 20px 50px rgba(0,0,0,0.7);
    animation: popUp 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.header-red { background: var(--danger); padding: 15px; color: #fff; }
.header-red h2 { font-family: 'Titan One'; margin: 0; }
.modal-body { padding: 25px 20px; color: #333; }
.big-prize { font-family: 'Titan One'; font-size: 1.8rem; color: var(--danger); margin: 10px 0 5px; line-height: 1; }
.prize-details { font-size: 1.5rem; font-weight: bold; color: #333; margin-bottom: 20px; }
.cta-button {
    display: block; background: var(--accent); color: #452c78;
    text-decoration: none; padding: 15px; border-radius: 50px;
    border-bottom: 4px solid #b88a00; font-weight: 900; font-size: 1.3rem;
    animation: wiggle 3s infinite;
}

/* Animations */
@keyframes slideUp { from { transform: translateY(50px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
@keyframes pulse { 0% { transform: scale(1); } 50% { transform: scale(1.02); } 100% { transform: scale(1); } }
@keyframes popUp { from { transform: scale(0.7); } to { transform: scale(1); } }
@keyframes wiggle { 0%, 90% { transform: rotate(0deg); } 92% { transform: rotate(-3deg); } 94% { transform: rotate(3deg); } 96% { transform: rotate(-3deg); } 98% { transform: rotate(3deg); } 100% { transform: rotate(0deg); } }
.red-flash-anim { animation: redFlash 0.5s ease; }
@keyframes redFlash { 0% { background-color: transparent; } 50% { background-color: rgba(255, 0, 0, 0.6); } 100% { background-color: transparent; } }