:root {
    --bg-color: #0b0f19;
    --card-bg: rgba(19, 27, 46, 0.94);
    --card-unlocked-bg: rgba(24, 34, 58, 0.96);
    --border-color: rgba(255, 255, 255, 0.12);
    --accent: #f43f5e;
    --accent-hover: #e11d48;
    --gold: #fbbf24;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --radius: 20px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    -webkit-tap-highlight-color: transparent;
}

body {
    background-color: var(--bg-color);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
}

/* =========================================================
   OVERLAY SCHERMO NERO CON GLITCH ROSSO
   ========================================================= */
.jumpscare-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: #000000;
    z-index: 9999;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    transition: opacity 0.4s ease;
}

.jumpscare-overlay.hidden {
    opacity: 0;
    pointer-events: none;
    visibility: hidden;
}

.jumpscare-text {
    color: #ef4444;
    font-size: 2.2rem;
    font-weight: 900;
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 2px;
    text-shadow: 0 0 25px rgba(239, 68, 68, 0.9), 0 0 50px rgba(239, 68, 68, 0.5);
    animation: textFlicker 0.2s infinite alternate;
}

@keyframes textFlicker {
    0% { transform: scale(1) skewX(0deg); }
    100% { transform: scale(1.04) skewX(2deg); }
}

/* =========================================================
   LAYER FLUTTUANTE
   ========================================================= */
.floating-space {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
    z-index: 99;
    overflow: hidden;
}

/* VINILI FLUTTUANTI */
.floating-vinyl {
    position: absolute;
    bottom: -70px;
    font-size: 3rem;
    pointer-events: auto;
    cursor: pointer;
    user-select: none;
    animation: floatDrift linear forwards;
    filter: drop-shadow(0 0 16px rgba(251, 191, 36, 0.9));
    z-index: 200;
}

.floating-vinyl:hover {
    transform: scale(1.25) rotate(25deg);
}

.pop-collected {
    transform: scale(2.2) rotate(360deg) !important;
    opacity: 0 !important;
    transition: all 0.25s ease-out !important;
}

/* FOTO POLAROID INFERNALI */
.floating-photo {
    position: absolute;
    bottom: -220px;
    animation: floatDrift linear forwards;
    pointer-events: none;
    transition: opacity 0.8s ease;
}

.polaroid {
    background: #ffffff;
    padding: 5px 5px 16px 5px;
    border-radius: 6px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.7);
    width: 90px;
    height: 115px;
}

.polaroid img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 4px;
    display: block;
}

.fade-out {
    opacity: 0 !important;
    transition: opacity 0.8s ease !important;
}

@keyframes floatDrift {
    0% { transform: translateY(0) translateX(0) rotate(0deg); }
    33% { transform: translateY(-40vh) translateX(20px) rotate(15deg); }
    66% { transform: translateY(-80vh) translateX(-20px) rotate(-10deg); }
    100% { transform: translateY(-135vh) translateX(10px) rotate(25deg); }
}

/* =========================================================
   CONTENUTO PRINCIPALE
   ========================================================= */
.main-wrapper {
    position: relative;
    z-index: 10;
    padding-bottom: 70px;
}

.hero {
    text-align: center;
    padding: 30px 16px 15px 16px;
    max-width: 700px;
    margin: 0 auto;
}

.badge {
    display: inline-block;
    background: rgba(244, 63, 94, 0.2);
    color: var(--accent);
    padding: 6px 18px;
    border-radius: 99px;
    font-size: 0.85rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    margin-bottom: 12px;
}

.hero h1 {
    font-size: 1.8rem;
    margin-bottom: 10px;
    letter-spacing: -0.5px;
    text-shadow: 0 4px 15px rgba(0, 0, 0, 0.6);
}

.subtitle {
    color: var(--text-secondary);
    font-size: 0.95rem;
    line-height: 1.5;
}

.container {
    max-width: 1050px;
    margin: 20px auto 0 auto;
    padding: 0 12px;
}

.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
    align-items: start;
}

.card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 24px 18px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(12px);
}

.card.unlocked {
    background: var(--card-unlocked-bg);
    border-color: rgba(251, 191, 36, 0.4);
}

.card-header {
    text-align: center;
    margin-bottom: 18px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 12px;
}

.tag {
    font-size: 0.75rem;
    text-transform: uppercase;
    color: var(--text-secondary);
    letter-spacing: 1px;
    font-weight: 700;
}

.card-header h2 { font-size: 1.4rem; margin-top: 4px; }

/* MINI SFIDA */
.challenge-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--gold);
    margin-bottom: 6px;
    transition: color 0.3s;
}

.progress-box {
    margin-top: 18px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    padding: 12px;
    border-radius: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.progress-label {
    font-size: 0.9rem;
    font-weight: 600;
}

.counter-badge {
    background: var(--gold);
    color: #0b0f19;
    font-weight: 800;
    padding: 4px 14px;
    border-radius: 99px;
    font-size: 0.95rem;
    transition: background 0.3s;
}

/* CARD MELANIA */
.lock-wrapper { text-align: center; }
.lock-icon { font-size: 2.4rem; margin-bottom: 10px; }
.lock-hint { color: var(--text-secondary); font-size: 0.9rem; margin-bottom: 16px; }
.form-unlock { display: flex; flex-direction: column; gap: 10px; }

input[type="password"] {
    width: 100%;
    padding: 12px 14px;
    background: #090d16;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    color: var(--text-primary);
    font-size: 1rem;
    outline: none;
    text-align: center;
    transition: border-color 0.2s;
}

input[type="password"]:focus { border-color: var(--accent); }

.btn {
    background: var(--accent);
    color: #fff;
    padding: 12px;
    border: none;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.btn:hover { background: var(--accent-hover); }

.alert {
    background: rgba(239, 68, 68, 0.15);
    color: #f87171;
    padding: 8px;
    border-radius: 8px;
    font-size: 0.85rem;
    margin-bottom: 12px;
}

/* GRATTA E VINCI FINALE */
.success-banner {
    background: rgba(251, 191, 36, 0.15);
    color: var(--gold);
    text-align: center;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 700;
    margin-bottom: 16px;
}

.gift-title { font-size: 1.2rem; margin-bottom: 6px; text-align: center; }
.gift-desc { color: var(--text-secondary); font-size: 0.9rem; text-align: center; margin-bottom: 18px; }

.vinyl-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
    margin-bottom: 16px;
}

.vinyl-item { text-align: center; }

.scratch-container {
    position: relative;
    width: 100%;
    aspect-ratio: 1 / 1;
    border-radius: 10px;
    overflow: hidden;
    background: #090d16;
    border: 1px solid var(--border-color);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.6);
    margin-bottom: 8px;
    touch-action: none;
}

.under-cover {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.scratch-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 5;
    cursor: crosshair;
}

.anonymous-label {
    font-size: 0.9rem;
    color: var(--gold);
    font-weight: 700;
    letter-spacing: 0.5px;
}

.dedica { text-align: center; font-style: italic; color: var(--text-secondary); font-size: 0.85rem; margin-top: 12px; }

@media (min-width: 768px) {
    .hero h1 { font-size: 2.3rem; }
    .jumpscare-text { font-size: 3.2rem; }
    .container { padding: 0 20px; }
    .card { padding: 36px 28px; }
    .polaroid { width: 110px; height: 140px; }
}
