/**
 * Lightning Casino - Scratchcard Game Styles
 * Daily scratchcard with premium casino feel
 * Requires casino.css for shared variables and layout
 */

/* ========================================
   LAYOUT OVERRIDE
   Scratchcard uses narrower main column
   ======================================== */
.scratchcard-main {
    max-width: 1200px;
}

/* ========================================
   GAME CONTAINER
   Matches roulette/slots container style
   ======================================== */
.scratch-container {
    background: var(--bg-card);
    border-radius: 24px;
    padding: 2rem;
    border: 1px solid var(--border);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    position: relative;
}

/* Entrance animation */
.scratch-container.animate-in {
    animation: scratchFadeIn 0.5s ease-out;
}

@keyframes scratchFadeIn {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ========================================
   DEMO MODE BANNER
   ======================================== */
.demo-mode-banner {
    background: linear-gradient(135deg, rgba(247, 147, 26, 0.08), rgba(247, 147, 26, 0.03));
    border: 1px solid rgba(247, 147, 26, 0.2);
    border-radius: 12px;
    padding: 10px 16px;
    text-align: center;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.demo-mode-banner .demo-badge {
    display: inline-block;
    background: rgba(247, 147, 26, 0.15);
    color: #f7931a;
    font-size: 0.7rem;
    font-weight: 800;
    letter-spacing: 0.1em;
    padding: 2px 8px;
    border-radius: 4px;
    vertical-align: middle;
}

.demo-mode-banner a {
    color: #f7931a;
    text-decoration: underline;
    font-weight: 600;
}

.demo-mode-banner a:hover {
    color: #ffaa33;
}

/* ========================================
   HEADER
   ======================================== */
.scratch-header {
    text-align: center;
}

.scratch-title-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-bottom: 4px;
}

.scratch-header h1 {
    font-size: 1.5rem;
    font-weight: 800;
    background: linear-gradient(135deg, #ffd700 0%, #f7931a 100%);
    -webkit-background-clip: text;
    background-clip: text;
    color: #ffd700; /* Fallback for browsers that don't support background-clip: text */
    -webkit-text-fill-color: transparent;
    margin: 0;
    line-height: 1.2;
}

.scratch-subtitle {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin: 0;
}

.daily-badge {
    display: inline-block;
    background: linear-gradient(135deg, #22c55e 0%, #16a34a 100%);
    color: #fff;
    font-size: 0.65rem;
    font-weight: 800;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    padding: 3px 10px;
    border-radius: 20px;
    flex-shrink: 0;
}

.daily-badge.used {
    background: linear-gradient(135deg, #6b7280 0%, #4b5563 100%);
}

/* ========================================
   SCRATCH CARD
   The physical card with its golden border
   ======================================== */
.scratch-card {
    position: relative;
}

.scratch-card-inner {
    background: linear-gradient(180deg, #1c2128 0%, #161b22 100%);
    border-radius: 20px;
    padding: 1.5rem;
    border: 2px solid rgba(247, 147, 26, 0.15);
    box-shadow:
        0 0 0 1px rgba(255, 215, 0, 0.05),
        inset 0 1px 0 rgba(255, 255, 255, 0.03),
        0 8px 32px rgba(0, 0, 0, 0.3);
    position: relative;
    overflow: hidden;
}

/* Subtle texture overlay — uses CSS gradient instead of SVG feTurbulence
   (feTurbulence crashes/glitches on many Android Chrome versions) */
.scratch-card-inner::before {
    content: '';
    position: absolute;
    inset: 0;
    background:
        radial-gradient(circle at 20% 30%, rgba(255, 215, 0, 0.02) 0%, transparent 50%),
        radial-gradient(circle at 80% 70%, rgba(247, 147, 26, 0.02) 0%, transparent 50%);
    border-radius: 20px;
    pointer-events: none;
}

/* ========================================
   SCRATCH GRID
   ======================================== */
.scratch-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(2, 1fr);
    gap: 10px;
    max-width: 380px;
    margin: 0 auto;
    position: relative;
    z-index: 1;
}

/* ========================================
   INDIVIDUAL PANEL
   ======================================== */
.scratch-panel {
    position: relative;
    border-radius: 14px;
    overflow: hidden;
    cursor: pointer;
    aspect-ratio: 1;
    /* Fallback for older Android Chrome that doesn't support aspect-ratio */
    min-height: 0;
    transition: transform 0.15s ease;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

/* JS-free aspect-ratio fallback using padding trick for older browsers */
@supports not (aspect-ratio: 1) {
    .scratch-panel {
        padding-bottom: 100%;
    }
    .scratch-panel > .scratch-symbol,
    .scratch-panel > .scratch-cover {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
    }
}

.scratch-panel:hover:not(.scratched) {
    transform: scale(1.03);
}

.scratch-panel:active:not(.scratched) {
    transform: scale(0.95);
}

/* Symbol underneath */
.scratch-symbol {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    background: linear-gradient(145deg, #1a1a2e 0%, #0f0f1a 100%);
    border: 2px solid rgba(255, 215, 0, 0.12);
    border-radius: 14px;
}

.scratch-symbol svg {
    width: 40px;
    height: 40px;
    margin-bottom: 4px;
}

/* Bitcoin ₿ character - matches slots btc-symbol styling */
.scratch-btc-symbol {
    font-size: 2.5rem;
    font-weight: 700;
    color: #f7931a;
    line-height: 1;
    margin-bottom: 4px;
    display: inline-block;
    text-shadow: 0 0 12px rgba(247, 147, 26, 0.3);
}

.scratch-symbol .symbol-name {
    font-size: 0.7rem;
    color: var(--text-secondary);
    font-weight: 600;
}

/* Cover layer */
.scratch-cover {
    position: absolute;
    inset: 0;
    background: linear-gradient(145deg, #3a3f4b 0%, #2d333b 40%, #252a31 100%);
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.4s ease, transform 0.4s ease;
    z-index: 2;
    border: 2px solid rgba(255, 255, 255, 0.08);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.scratch-cover::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 50%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.04), transparent);
    animation: shimmer 3s ease-in-out infinite;
}

@keyframes shimmer {
    0% { left: -100%; }
    100% { left: 200%; }
}

.scratch-cover .scratch-icon {
    opacity: 0.4;
}

.scratch-cover .scratch-icon svg {
    width: 28px;
    height: 28px;
    color: var(--text-secondary);
}

/* Scratched state */
.scratch-panel.scratched .scratch-cover {
    opacity: 0;
    transform: scale(1.15) rotate(3deg);
    pointer-events: none;
}

/* Matching symbol highlight */
.scratch-panel.matched .scratch-symbol {
    border-color: rgba(255, 215, 0, 0.6);
    background: linear-gradient(145deg, rgba(255, 215, 0, 0.15) 0%, rgba(247, 147, 26, 0.08) 100%);
    box-shadow: 0 0 24px rgba(255, 215, 0, 0.2), 0 0 48px rgba(255, 215, 0, 0.1);
    animation: matchPulse 1.5s ease-in-out infinite;
}

@keyframes matchPulse {
    0%, 100% { box-shadow: 0 0 24px rgba(255, 215, 0, 0.2); }
    50% { box-shadow: 0 0 32px rgba(255, 215, 0, 0.35), 0 0 60px rgba(255, 215, 0, 0.15); }
}

.scratch-panel.matched .scratch-symbol svg {
    filter: drop-shadow(0 0 8px rgba(255, 215, 0, 0.5));
}

.scratch-panel.matched .scratch-btc-symbol {
    text-shadow: 0 0 12px rgba(255, 215, 0, 0.5), 0 0 24px rgba(255, 215, 0, 0.3);
}

.scratch-panel.matched .scratch-symbol .symbol-name {
    color: #ffd700;
}

/* Scratch-all stagger delays */
.scratch-panel.scratched:nth-child(1) .scratch-cover { transition-delay: 0s; }
.scratch-panel.scratched:nth-child(2) .scratch-cover { transition-delay: 0.1s; }
.scratch-panel.scratched:nth-child(3) .scratch-cover { transition-delay: 0.2s; }
.scratch-panel.scratched:nth-child(4) .scratch-cover { transition-delay: 0.3s; }
.scratch-panel.scratched:nth-child(5) .scratch-cover { transition-delay: 0.4s; }
.scratch-panel.scratched:nth-child(6) .scratch-cover { transition-delay: 0.5s; }

/* ========================================
   RESULT
   ======================================== */
.scratch-result {
    text-align: center;
    padding: 20px;
    border-radius: 16px;
    margin-top: 16px;
    opacity: 0;
    transform: translateY(10px);
    transition: all 0.5s ease;
}

.scratch-result.visible {
    opacity: 1;
    transform: translateY(0);
}

.scratch-result.win {
    background: linear-gradient(145deg, rgba(255, 215, 0, 0.1) 0%, rgba(247, 147, 26, 0.05) 100%);
    border: 1px solid rgba(255, 215, 0, 0.3);
}

.scratch-result.lose {
    background: linear-gradient(145deg, rgba(107, 114, 128, 0.08) 0%, rgba(75, 85, 99, 0.04) 100%);
    border: 1px solid rgba(107, 114, 128, 0.15);
}

.scratch-result h3 {
    margin: 0 0 4px;
    font-size: 1.2rem;
    font-weight: 800;
}

.scratch-result.win h3 {
    color: #ffd700;
}

.scratch-result.lose h3 {
    color: var(--text-secondary);
}

.scratch-result .prize-amount {
    font-size: 2rem;
    font-weight: 900;
    color: #f7931a;
    margin: 4px 0;
    text-shadow: 0 0 20px rgba(247, 147, 26, 0.3);
}

.scratch-result .prize-unit {
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.scratch-result .prize-balance-info {
    color: var(--text-secondary);
    font-size: 0.8rem;
    margin-top: 6px;
    opacity: 0.8;
}

/* ========================================
   ACTION BUTTONS
   ======================================== */
.scratch-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: center;
}

.btn-scratch-all {
    width: 100%;
    max-width: 380px;
    padding: 14px 24px;
    border: none;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-family: inherit;
}

.btn-scratch-all.free {
    background: linear-gradient(135deg, #22c55e 0%, #16a34a 100%);
    color: #fff;
    box-shadow: 0 4px 15px rgba(34, 197, 94, 0.3);
}

.btn-scratch-all.free:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(34, 197, 94, 0.4);
}

.btn-scratch-all.buy {
    background: linear-gradient(135deg, #f7931a 0%, #e67e00 100%);
    color: #fff;
    box-shadow: 0 4px 15px rgba(247, 147, 26, 0.3);
}

.btn-scratch-all.buy:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(247, 147, 26, 0.4);
}

.btn-scratch-all:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
}

.btn-scratch-all svg {
    width: 20px;
    height: 20px;
}

/* ========================================
   COOLDOWN TIMER
   ======================================== */
.scratch-cooldown {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.06);
}

.scratch-cooldown .timer-icon {
    color: var(--text-secondary);
    opacity: 0.6;
    display: inline-flex;
    flex-shrink: 0;
}

.scratch-cooldown .timer-label {
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.scratch-cooldown .timer-value {
    color: #f7931a;
    font-size: 0.95rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    font-family: var(--font-mono);
}

/* ========================================
   PRIZE TABLE
   ======================================== */
.scratch-prize-table {
    border-radius: 14px;
    overflow: hidden;
    border: 1px solid var(--border-subtle);
    background: rgba(255, 255, 255, 0.01);
}

.scratch-prize-table .table-header {
    background: rgba(255, 215, 0, 0.06);
    padding: 10px 16px;
    font-weight: 700;
    font-size: 0.85rem;
    color: #ffd700;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    border-bottom: 1px solid rgba(255, 215, 0, 0.08);
}

.scratch-prize-table .table-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    font-size: 0.85rem;
    transition: background 0.15s;
}

.scratch-prize-table .table-row:last-child {
    border-bottom: none;
}

.scratch-prize-table .table-row:hover {
    background: rgba(255, 255, 255, 0.02);
}

.scratch-prize-table .table-row.prize-hit {
    background: rgba(255, 215, 0, 0.1);
    border-left: 3px solid #ffd700;
    animation: prizeRowFlash 2s ease-out;
}

.scratch-prize-table .table-row.prize-hit .match-count {
    color: #ffd700;
}

.scratch-prize-table .table-row.prize-hit .prize-range {
    color: #ffd700;
    text-shadow: 0 0 8px rgba(255, 215, 0, 0.3);
}

@keyframes prizeRowFlash {
    0% { background: rgba(255, 215, 0, 0.3); }
    30% { background: rgba(255, 215, 0, 0.15); }
    100% { background: rgba(255, 215, 0, 0.1); }
}

.scratch-prize-table .miss-row .match-count,
.scratch-prize-table .miss-row .prize-range,
.scratch-prize-table .miss-row .probability {
    color: var(--text-muted);
    opacity: 0.6;
}

.scratch-prize-table .miss-row.prize-hit {
    background: rgba(107, 114, 128, 0.08);
    border-left: 3px solid #6b7280;
    animation: missRowFlash 2s ease-out;
}

.scratch-prize-table .miss-row.prize-hit .match-count,
.scratch-prize-table .miss-row.prize-hit .probability {
    opacity: 1;
    color: var(--text-secondary);
}

@keyframes missRowFlash {
    0% { background: rgba(107, 114, 128, 0.2); }
    30% { background: rgba(107, 114, 128, 0.12); }
    100% { background: rgba(107, 114, 128, 0.08); }
}

.scratch-prize-table .match-count {
    color: var(--text-primary);
    font-weight: 600;
    flex: 1;
    text-align: left;
}

.scratch-prize-table .prize-range {
    color: #f7931a;
    font-weight: 700;
    font-family: var(--font-mono);
    flex: 1;
    text-align: center;
}

.scratch-prize-table .probability {
    color: var(--text-muted);
    font-size: 0.8rem;
    font-style: italic;
    flex: 1;
    text-align: right;
}

/* ========================================
   GAME FOOTER
   ======================================== */
.scratch-game-footer {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    flex-wrap: wrap;
    font-size: 0.75rem;
    color: var(--text-muted);
    padding-top: 4px;
}

.scratch-game-footer .footer-item {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.scratch-game-footer .footer-sep {
    color: var(--text-muted);
    opacity: 0.4;
}

/* ========================================
   SIDEBAR: HOW IT WORKS
   ======================================== */
.how-it-works {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 4px 8px;
}

.how-it-works .step {
    display: flex;
    align-items: center;
    gap: 12px;
}

.how-it-works .step-num {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: linear-gradient(135deg, rgba(247, 147, 26, 0.15), rgba(247, 147, 26, 0.05));
    border: 1px solid rgba(247, 147, 26, 0.2);
    color: #f7931a;
    font-size: 0.75rem;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.how-it-works .step-text {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* ========================================
   RESPONSIVE
   ======================================== */
@media (max-width: 1024px) {
    .scratchcard-main {
        grid-template-columns: 1fr;
        padding: 1rem;
    }
}

@media (max-width: 500px) {
    .scratch-container {
        padding: 1.25rem;
        border-radius: 16px;
    }

    .scratch-card-inner {
        padding: 1rem;
        border-radius: 14px;
    }

    .scratch-grid {
        gap: 8px;
    }

    .scratch-symbol svg {
        width: 32px;
        height: 32px;
    }

    .scratch-btc-symbol {
        font-size: 2rem;
    }

    .scratch-header h1 {
        font-size: 1.25rem;
    }

    .scratch-title-row {
        flex-direction: column;
        gap: 4px;
    }

    .scratch-prize-table .table-row {
        padding: 8px 12px;
        font-size: 0.8rem;
    }
}

@media (max-width: 360px) {
    .scratch-grid {
        gap: 6px;
    }

    .scratch-symbol svg {
        width: 26px;
        height: 26px;
    }

    .scratch-btc-symbol {
        font-size: 1.6rem;
    }

    .scratch-symbol .symbol-name {
        font-size: 0.6rem;
    }
}
