@import url('https://fonts.googleapis.com/css2?family=Fredoka+One&family=Nunito:wght@400;700;800&display=swap');

:root {
    --lypm-bg:      #0f1535;
    --lypm-surface: #1a2555;
    --lypm-card:    #212e6a;
    --lypm-yellow:  #FFD93D;
    --lypm-teal:    #4ECDC4;
    --lypm-pink:    #FF6B9D;
    --lypm-green:   #2ECC71;
    --lypm-red:     #E74C3C;
    --lypm-text:    #F0F4FF;
    --lypm-muted:   #a8b4d8;
    --lypm-font-h:  'Fredoka One', cursive;
    --lypm-font-b:  'Nunito', sans-serif;
    --lypm-shadow:  0 8px 32px rgba(0,0,0,.5);
    --lypm-radius:  16px;
}

/* ── WRAPPER ─────────────────────────────────────────────── */
.lypm-wrapper {
    font-family: var(--lypm-font-b);
    background: var(--lypm-bg);
    border-radius: 24px;
    max-width: 680px;
    margin: 0 auto;
    overflow: hidden;
    box-shadow: var(--lypm-shadow);
    color: var(--lypm-text);
    position: relative;
}
.lypm-screen { display:none; padding:28px 24px 32px; animation:lypm-fadeIn .3s ease; min-height:500px; }
.lypm-screen.active { display:block; }
@keyframes lypm-fadeIn { from{opacity:0;transform:translateY(10px)} to{opacity:1;transform:translateY(0)} }

/* ── HOME ────────────────────────────────────────────────── */
.lypm-stars-bg { position:absolute; inset:0; pointer-events:none; overflow:hidden; border-radius:24px; }
.lypm-stars-bg::before { content:''; position:absolute; width:2px; height:2px; border-radius:50%; background:white; box-shadow:40px 30px 0 white,120px 80px 0 white,220px 40px 0 white,320px 120px 0 white,80px 180px 0 white,400px 60px 0 white,500px 150px 0 white,60px 260px 0 white,180px 300px 0 white,280px 240px 0 white,450px 280px 0 white,350px 340px 0 white,150px 380px 0 white,520px 380px 0 white,240px 440px 0 white; opacity:.4; }
.lypm-home-content { position:relative; z-index:1; }
.lypm-logo { display:flex; align-items:center; gap:14px; justify-content:center; margin-bottom:6px; }
.lypm-logo-icon { font-size:50px; animation:lypm-bounce 2s infinite ease-in-out; }
@keyframes lypm-bounce { 0%,100%{transform:translateY(0)} 50%{transform:translateY(-7px)} }
.lypm-title { font-family:var(--lypm-font-h); font-size:34px; line-height:1.1; margin:0; color:#fff; }
.lypm-title span { color:var(--lypm-yellow); }
.lypm-subtitle { text-align:center; color:var(--lypm-muted); font-weight:600; margin:0 0 20px; }

/* Guest badge */
.lypm-guest-badge { background:rgba(255,217,61,.1); border:1px solid rgba(255,217,61,.3); border-radius:12px; padding:10px 16px; display:flex; align-items:center; justify-content:space-between; gap:12px; margin-bottom:16px; font-size:13px; flex-wrap:wrap; }

/* Level grid */
.lypm-level-grid { display:grid; grid-template-columns:1fr 1fr; gap:14px; }
.lypm-level-btn {
    background:var(--lypm-card); border:2px solid rgba(255,255,255,.08);
    border-left: 4px solid var(--lv-color, var(--lypm-teal));
    border-radius:var(--lypm-radius); color:var(--lypm-text);
    cursor:pointer; padding:14px 16px; text-align:left;
    display:flex; flex-direction:row; align-items:center; gap:14px;
    transition:transform .18s, border-color .18s, background .18s;
    font-family:var(--lypm-font-b);
}
.lypm-level-btn:hover { transform:scale(1.03); border-left-color:var(--lv-color,var(--lypm-teal)); background:#2a3880; }
.lypm-lv-text { display:flex; flex-direction:column; gap:2px; }
.lypm-lv-icon  { 
    display:inline-flex; align-items:center; justify-content:center;
    width:48px; height:48px; border-radius:50%;
    background:var(--lv-color);
    color:#fff;
    font-size:26px; font-weight:900; line-height:1;
    font-family:var(--lypm-font-b);
    box-shadow:0 4px 14px color-mix(in srgb, var(--lv-color) 60%, transparent);
    flex-shrink:0;
}
.lypm-lv-label { font-family:var(--lypm-font-h); font-size:18px; }
.lypm-lv-desc  { font-size:12px; color:var(--lypm-muted); }
.lypm-lv-record{ font-size:12px; color:var(--lypm-yellow); margin-top:4px; min-height:16px; }

.lypm-back-btn { background:rgba(255,255,255,.1); border:1px solid rgba(255,255,255,.15); color:var(--lypm-text); font-family:var(--lypm-font-b); font-weight:700; font-size:14px; padding:7px 14px; border-radius:30px; cursor:pointer; margin-bottom:18px; transition:background .2s; }
.lypm-back-btn:hover { background:rgba(255,255,255,.2); }

/* ── GAME HEADER ─────────────────────────────────────────── */
.lypm-game-header { display:flex; justify-content:space-around; align-items:center; background:var(--lypm-card); border-radius:var(--lypm-radius); padding:12px 16px; margin-bottom:20px; }
.lypm-info-chip { text-align:center; }
.lypm-info-label { display:block; font-size:11px; color:var(--lypm-muted); text-transform:uppercase; letter-spacing:.5px; margin-bottom:2px; }
.lypm-info-chip strong { font-family:var(--lypm-font-h); font-size:22px; color:var(--lypm-yellow); }
.lypm-info-center strong { color:var(--lypm-teal); }

/* ── BOARD ───────────────────────────────────────────────── */
.lypm-board { display:grid; gap:10px; }

/* Carta */
.lypm-card {
    aspect-ratio: 1;
    cursor:pointer;
    perspective:600px;
    position:relative;
}
.lypm-card-inner {
    width:100%; height:100%;
    position:relative;
    transform-style:preserve-3d;
    transition:transform .4s ease;
    border-radius:12px;
}
.lypm-card.lypm-flipped .lypm-card-inner { transform:rotateY(180deg); }
.lypm-card-front,
.lypm-card-back {
    position:absolute; inset:0;
    border-radius:12px;
    display:flex; align-items:center; justify-content:center;
    backface-visibility:hidden;
    font-family:var(--lypm-font-h);
    user-select:none;
}
.lypm-card-front {
    background:var(--lypm-card);
    border:2px solid rgba(255,255,255,.1);
    font-size:28px;
    transition:background .2s;
}
.lypm-card:hover:not(.lypm-flipped):not(.lypm-matched) .lypm-card-front {
    background:#2a3880; border-color:rgba(255,255,255,.25);
}
.lypm-card-back {
    transform:rotateY(180deg);
    font-size:20px;
    text-align:center;
    padding:6px;
    word-break:break-all;
}
.lypm-card-q {
    background:linear-gradient(135deg,#1a3a6a,#2a4a8a);
    border:2px solid rgba(78,205,196,.4);
    color:var(--lypm-teal);
}
.lypm-card-a {
    background:linear-gradient(135deg,#3a1a6a,#5a2a9a);
    border:2px solid rgba(255,107,157,.4);
    color:var(--lypm-pink);
    font-size:26px;
}
.lypm-card.lypm-matched .lypm-card-front,
.lypm-card.lypm-matched .lypm-card-back {
    opacity:.55;
}
.lypm-card.lypm-matched { cursor:default; }

/* Animazioni */
@keyframes lypm-match-pop { 0%{transform:rotateY(180deg) scale(1)} 50%{transform:rotateY(180deg) scale(1.12)} 100%{transform:rotateY(180deg) scale(1)} }
.lypm-card.lypm-match-anim .lypm-card-inner { animation:lypm-match-pop .5s ease; }

@keyframes lypm-wrong-shake { 0%,100%{transform:rotateY(180deg) translateX(0)} 25%{transform:rotateY(180deg) translateX(-6px)} 75%{transform:rotateY(180deg) translateX(6px)} }
.lypm-card.lypm-wrong-anim .lypm-card-inner { animation:lypm-wrong-shake .4s ease; }

/* ── RISULTATO ───────────────────────────────────────────── */
.lypm-result-content { text-align:center; padding-top:28px; position:relative; overflow:hidden; }
.lypm-result-trophy { font-size:76px; animation:lypm-bounce 1.5s infinite ease-in-out; }
.lypm-result-title { font-family:var(--lypm-font-h); font-size:36px; margin:10px 0 16px; color:var(--lypm-yellow); }
.lypm-result-stats { display:flex; justify-content:center; gap:24px; margin-bottom:14px; }
.lypm-stat { text-align:center; background:var(--lypm-card); border-radius:14px; padding:14px 20px; }
.lypm-stat-val { display:block; font-family:var(--lypm-font-h); font-size:28px; color:var(--lypm-teal); }
.lypm-stat-lbl { display:block; font-size:12px; color:var(--lypm-muted); margin-top:4px; }
.lypm-result-badge { background:linear-gradient(135deg,#FF6B35,#FFD93D); color:#fff; font-family:var(--lypm-font-h); font-size:18px; padding:10px 24px; border-radius:30px; display:inline-block; margin-bottom:16px; animation:lypm-bounce .8s infinite; }
.lypm-result-buttons { display:flex; gap:14px; justify-content:center; flex-wrap:wrap; margin-top:8px; }
.lypm-btn-primary { background:linear-gradient(135deg,#FF6B35,#FF6B9D); border:none; color:#fff; font-family:var(--lypm-font-h); font-size:18px; padding:13px 26px; border-radius:14px; cursor:pointer; transition:transform .15s; box-shadow:0 4px 16px rgba(255,107,53,.35); }
.lypm-btn-primary:hover { transform:scale(1.05); }
.lypm-btn-secondary { background:rgba(255,255,255,.1); border:1px solid rgba(255,255,255,.15); color:var(--lypm-text); font-family:var(--lypm-font-h); font-size:18px; padding:13px 26px; border-radius:14px; cursor:pointer; transition:background .2s; }
.lypm-btn-secondary:hover { background:rgba(255,255,255,.18); }
@keyframes lypm-confetti-fall { to{transform:translateY(600px) rotate(720deg);opacity:0} }
.lypm-confetti-piece { position:absolute; width:10px; height:10px; border-radius:2px; top:-20px; animation:lypm-confetti-fall linear forwards; }

/* ── RESPONSIVE ──────────────────────────────────────────── */
@media (max-width:600px) {
    .lypm-screen { padding:20px 14px 24px; }
    /* 1 colonna su mobile: i bottoni hanno spazio pieno */
    .lypm-level-grid { grid-template-columns:1fr; gap:10px; }
    /* Bottone: layout relativo, padding extra in alto a sinistra per l'icona */
    .lypm-level-btn { position:relative; padding:12px 14px 12px 52px; flex-direction:row; align-items:center; gap:0; }
    /* Icona piccola in angolo alto a sinistra */
    .lypm-lv-icon {
        position:absolute; top:10px; left:10px;
        width:32px; height:32px; font-size:17px;
        box-shadow:none;
    }
    .lypm-lv-text { width:100%; }
    .lypm-lv-label { font-size:15px; }
    .lypm-lv-desc  { font-size:12px; }
    .lypm-board { gap:7px; }
    .lypm-card-back { font-size:15px; }
    .lypm-card-a { font-size:20px; }
    .lypm-result-stats { gap:12px; }
    .lypm-stat { padding:10px 14px; }
    .lypm-stat-val { font-size:22px; }
}

/* ── SCORE BAR & RESET ───────────────────────────────────── */
.lypm-score-bar { display:flex; justify-content:space-between; align-items:center; background:rgba(255,255,255,.06); border-radius:12px; padding:10px 16px; font-size:15px; font-weight:700; }
.lypm-btn-small { background:rgba(255,255,255,.1); border:none; color:var(--lypm-text); font-family:var(--lypm-font-b); font-size:13px; font-weight:700; padding:5px 12px; border-radius:20px; cursor:pointer; transition:background .2s; }
.lypm-btn-small:hover { background:rgba(255,255,255,.2); }

/* ── PULSANTE MUTO ─────────────────────────────────────────── */
/* lyp-mute-btn moved to platform */
