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

:root {
    --sn-bg:      #0f1535;
    --sn-surface: #1a2555;
    --sn-card:    #212e6a;
    --sn-yellow:  #FFD93D;
    --sn-orange:  #FF6B35;
    --sn-pink:    #FF6B9D;
    --sn-teal:    #4ECDC4;
    --sn-blue:    #3b82f6;
    --sn-red:     #ef4444;
    --sn-green:   #2ECC71;
    --sn-text:    #F0F4FF;
    --sn-muted:   #a8b4d8;
    --sn-radius:  18px;
    --sn-shadow:  0 8px 32px rgba(0,0,0,.45);
    --sn-font-h:  'Fredoka One', cursive;
    --sn-font-b:  'Nunito', sans-serif;
}

/* ── WRAPPER ─────────────────────────────────────────────── */
.lypsn-wrapper {
    font-family: var(--sn-font-b);
    background:  var(--sn-bg);
    border-radius: 24px;
    overflow: hidden;
    position: relative;
    min-height: 520px;
    max-width: 680px;
    margin: 0 auto;
    box-shadow: var(--sn-shadow);
    color: var(--sn-text);
}
/* Stelle su tutto il wrapper */
.lypsn-wrapper::before {
    content: '';
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    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;
}
.lypsn-wrapper-stars { display:none; }

.lypsn-screen { display:none; padding:28px 24px 32px; animation:sn-fadeIn .35s ease; position:relative; z-index:1; min-height:520px; }
.lypsn-screen.active { display:block; }
@keyframes sn-fadeIn { from{opacity:0;transform:translateY(12px)} to{opacity:1;transform:translateY(0)} }

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

/* ── HOME ────────────────────────────────────────────────── */
.lypsn-home-content { text-align: center; }
.lypsn-logo { display:flex; align-items:center; gap:14px; margin-bottom:8px; justify-content:center; }
.lypsn-logo-icon {
    font-size: 52px;
    animation: sn-bounce 2s infinite ease-in-out;
}
@keyframes sn-bounce { 0%,100%{transform:translateY(0)} 50%{transform:translateY(-8px)} }

.lypsn-title {
    font-family: var(--sn-font-h);
    font-size: 38px;
    margin: 0;
    line-height: 1.1;
    color: #fff !important;
}
.lypsn-title span { color: var(--sn-yellow); }
.lypsn-subtitle { color:var(--sn-muted); font-size:15px; margin:0 0 24px; text-align:center; }

.lypsn-cat-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-bottom: 20px;
}
.lypsn-cat-card {
    background: var(--sn-card);
    border: 2px solid rgba(255,255,255,.08);
    border-top: 3px solid var(--cc, #4ECDC4);
    border-radius: var(--sn-radius);
    padding: 16px 14px;
    cursor: pointer;
    transition: background .2s, transform .15s;
    text-align: left;
}
.lypsn-cat-card:hover { background: #2a3880; transform: translateY(-2px); }

.lypsn-cat-top { display:flex; align-items:center; gap:10px; margin-bottom:8px; }
.lypsn-cat-icon  { font-size:26px; }
.lypsn-cat-label { font-weight:800; font-size:15px; flex:1; }
.lypsn-cat-stars { font-size:11px; color:var(--sn-yellow); letter-spacing:-1px; }

.lypsn-cat-chips { display:flex; gap:6px; flex-wrap:wrap; }
.lypsn-cat-chip {
    font-size:10px; font-weight:700; padding:2px 8px; border-radius:10px;
}
.lypsn-cat-chip-sin { background:rgba(59,130,246,.25); color:#93c5fd; }
.lypsn-cat-chip-con { background:rgba(239,68,68,.25);  color:#fca5a5; }

.lypsn-score-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--sn-surface);
    border-radius: 12px;
    padding: 10px 16px;
    font-size: 14px;
    font-weight: 700;
}
.lypsn-btn-small {
    background: rgba(255,255,255,.1);
    border: 1px solid rgba(255,255,255,.2);
    color: var(--sn-text);
    font-family: var(--sn-font-b);
    font-size: 12px;
    padding: 5px 12px;
    border-radius: 20px;
    cursor: pointer;
    font-weight: 700;
}

/* ── SELEZIONE MODALITÀ ──────────────────────────────────── */
.lypsn-mode-content { }
.lypsn-mode-cat-header { display:flex; align-items:center; gap:12px; margin-bottom:6px; }
.lypsn-mode-icon  { font-size:36px; }
.lypsn-mode-title { font-family:var(--sn-font-h); font-size:26px; margin:0; color:#fff; }
.lypsn-mode-intro { color:var(--sn-muted); font-size:14px; margin:0 0 20px; }

.lypsn-mode-grid { display:grid; grid-template-columns:1fr 1fr; gap:10px; }
.lypsn-mode-btn {
    background: var(--sn-card);
    border: 2px solid rgba(255,255,255,.1);
    border-radius: var(--sn-radius);
    padding: 16px 14px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    color: var(--sn-text);
    font-family: var(--sn-font-b);
    transition: background .2s, transform .15s;
    text-align: left;
}
.lypsn-mode-btn:hover { background:#2a3880; transform:translateY(-2px); }
.lypsn-mode-btn:first-child { grid-column:1/-1; }
.lypsn-mode-btn-icon  { font-size:24px; }
.lypsn-mode-btn-label { font-weight:800; font-size:14px; }
.lypsn-mode-btn-desc  { font-size:11px; color:var(--sn-muted); }
.lypsn-mode-record    { font-size:11px; color:var(--sn-yellow); font-weight:700; margin-top:2px; }
.lypsn-mode-sin  { border-color:rgba(59,130,246,.4); }
.lypsn-mode-con  { border-color:rgba(239,68,68,.4); }
.lypsn-mode-quiz-sin { border-color:rgba(59,130,246,.25); }
.lypsn-mode-quiz-con { border-color:rgba(239,68,68,.25); }

/* ── IMPARA ──────────────────────────────────────────────── */
.lypsn-learn-heading { font-family:var(--sn-font-h); font-size:24px; margin:0 0 4px; color:#fff !important; }
.lypsn-learn-intro   { color:var(--sn-muted); font-size:14px; margin:0 0 16px; }

.lypsn-learn-tabs { display:flex; gap:8px; margin-bottom:14px; }
.lypsn-learn-tab {
    padding:6px 14px; border-radius:20px; border:1px solid rgba(255,255,255,.15);
    background:transparent; color:var(--sn-muted); font-family:var(--sn-font-b);
    font-size:13px; font-weight:700; cursor:pointer; transition:all .2s;
}
.lypsn-learn-tab.active { background:var(--sn-card); color:var(--sn-text); border-color:rgba(255,255,255,.3); }

.lypsn-learn-grid { display:flex; flex-direction:column; gap:8px; margin-bottom:20px; max-height:340px; overflow-y:auto; }
.lypsn-learn-card {
    background: var(--sn-card);
    border-radius: 12px;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-left: 4px solid var(--sn-blue);
    transition: opacity .2s;
}
.lypsn-learn-card[data-tipo="con"] { border-left-color:var(--sn-red); }
.lypsn-learn-card[data-tipo="sin"].hidden,
.lypsn-learn-card[data-tipo="con"].hidden { display:none; }

.lypsn-learn-emoji { font-size:22px; width:28px; text-align:center; flex-shrink:0; }
.lypsn-learn-words { flex:1; display:flex; align-items:flex-start; flex-direction:column; gap:2px; }
.lypsn-learn-word-a { font-weight:800; font-size:14px; }
.lypsn-learn-arrow { color:var(--sn-muted); font-size:11px; display:none; }
.lypsn-learn-word-b { font-weight:700; font-size:13px; color:var(--sn-yellow); }
.lypsn-learn-badge {
    font-size:10px; font-weight:700; padding:2px 8px; border-radius:10px; flex-shrink:0;
}
.lypsn-learn-badge-sin { background:rgba(59,130,246,.25); color:#93c5fd; }
.lypsn-learn-badge-con { background:rgba(239,68,68,.25);  color:#fca5a5; }

.lypsn-learn-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-top: 4px;
}
/* Colonna sinistra: Memory | Colonna destra: Quiz */
.lypsn-learn-actions .lypsn-btn-primary,
.lypsn-learn-actions .lypsn-btn-secondary {
    font-size: 13px;
    padding: 10px 8px;
    border-radius: 22px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ── MEMORY BOARD ────────────────────────────────────────── */
.lypsn-game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    gap: 8px;
}
.lypsn-mem-tipo-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    flex:1;
}
.lypsn-info-chip {
    background: var(--sn-card);
    border-radius: 12px;
    padding: 8px 14px;
    text-align: center;
    flex: 1;
}
.lypsn-tipo-badge {
    font-size:11px; font-weight:800; padding:3px 10px; border-radius:20px;
    background:rgba(255,255,255,.12); color:var(--sn-text); white-space:nowrap;
    letter-spacing:.3px; text-transform:uppercase;
}
.lypsn-info-chip strong { display:block; font-size:18px; color:var(--sn-yellow); }
.lypsn-info-label { font-size:11px; color:var(--sn-muted); font-weight:700; text-transform:uppercase; }
.lypsn-info-center { flex:1.4; }
#lypsn-mem-tipo-label { font-size:11px; font-weight:800; color:var(--sn-text); white-space:nowrap; }

.lypsn-board {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
}
.lypsn-card {
    aspect-ratio: 3/4;
    cursor: pointer;
    perspective: 600px;
    border-radius: 12px;
}
.lypsn-card-inner {
    width:100%; height:100%;
    position:relative;
    transform-style:preserve-3d;
    transition:transform .4s ease;
    border-radius:12px;
}
.lypsn-card.lypsn-flipped .lypsn-card-inner  { transform:rotateY(180deg); }
.lypsn-card.lypsn-matched .lypsn-card-inner  { transform:rotateY(180deg); }

.lypsn-card-front,
.lypsn-card-back {
    position:absolute; inset:0;
    border-radius:12px;
    display:flex; align-items:center; justify-content:center;
    backface-visibility:hidden;
    font-family:var(--sn-font-b);
    padding:6px;
    text-align:center;
}
.lypsn-card-front {
    background: var(--sn-card);
    border: 2px solid rgba(255,255,255,.1);
    font-size:22px;
}
.lypsn-card-back {
    transform:rotateY(180deg);
    font-size:13px;
    font-weight:800;
    line-height:1.2;
    word-break:break-word;
    overflow-wrap:break-word;
    hyphens:auto;
    padding:8px 4px;
}
.lypsn-card-sin { background:rgba(59,130,246,.35); border:2px solid rgba(59,130,246,.6); color:#dbeafe; }
.lypsn-card-con { background:rgba(239,68,68,.35);  border:2px solid rgba(239,68,68,.6);  color:#fee2e2; }
.lypsn-card.lypsn-matched .lypsn-card-back {
    background:rgba(46,204,113,.35);
    border-color:rgba(46,204,113,.7);
    color:#d1fae5;
}
@keyframes sn-match-pop { 0%{transform:rotateY(180deg) scale(1)} 50%{transform:rotateY(180deg) scale(1.12)} 100%{transform:rotateY(180deg) scale(1)} }
.lypsn-card.lypsn-match-anim .lypsn-card-inner { animation:sn-match-pop .5s ease; }
@keyframes sn-wrong-shake { 0%,100%{transform:translateX(0)} 25%{transform:translateX(-5px)} 75%{transform:translateX(5px)} }
.lypsn-card.lypsn-wrong-anim { animation:sn-wrong-shake .35s ease; }

/* ── QUIZ ────────────────────────────────────────────────── */
.lypsn-quiz-header {
    display:flex; align-items:center; justify-content:space-between;
    margin-bottom:16px; gap:10px; flex-wrap:wrap;
}
.lypsn-quiz-cat      { font-weight:800; font-size:14px; color:var(--sn-yellow); }
.lypsn-quiz-progress { font-size:13px; color:var(--sn-muted); font-weight:700; }
.lypsn-quiz-stars-row { display:flex; gap:3px; flex-wrap:wrap; }
.lypsn-star-dot { font-size:16px; transition:transform .2s; }
.lypsn-star-dot.earned { transform:scale(1.3); }

.lypsn-question-box {
    background: var(--sn-card);
    border-radius: 20px;
    padding: 28px 20px;
    text-align: center;
    margin-bottom: 18px;
    border: 2px solid rgba(255,255,255,.08);
}
.lypsn-question-label { font-size:13px; color:var(--sn-muted); font-weight:700; margin-bottom:10px; }
.lypsn-question-word  { font-family:var(--sn-font-h); font-size:38px; color:#fff; }

.lypsn-answers { display:grid; grid-template-columns:1fr 1fr; gap:10px; margin-bottom:12px; }
.lypsn-answer-btn {
    background: var(--sn-card);
    border: 2px solid rgba(255,255,255,.12);
    border-radius: 14px;
    color: var(--sn-text);
    font-family: var(--sn-font-b);
    font-size: 15px;
    font-weight: 700;
    padding: 16px 10px;
    cursor: pointer;
    transition: background .15s, transform .1s;
    touch-action: manipulation;
}
.lypsn-answer-btn:hover:not(:disabled) { background:#2a3880; transform:translateY(-2px); }
.lypsn-answer-btn.lypsn-answer-correct  { background:rgba(46,204,113,.35); border-color:#2ECC71; color:#d1fae5; }
.lypsn-answer-btn.lypsn-answer-wrong    { background:rgba(231,76,60,.35);  border-color:#E74C3C; color:#fee2e2; }

.lypsn-feedback {
    min-height:24px; font-size:14px; font-weight:700;
    text-align:center; border-radius:10px; padding:6px 0;
}
.lypsn-feedback-ok  { color:#2ECC71; }
.lypsn-feedback-err { color:#E74C3C; }

/* ── RISULTATO ───────────────────────────────────────────── */
.lypsn-result-content {
    text-align:center;
    padding-top: 20px;
}
.lypsn-result-trophy { font-size:72px; margin-bottom:8px; }
.lypsn-result-title  { font-family:var(--sn-font-h); font-size:32px; margin:0 0 8px; color:#fff; }
.lypsn-result-stars  { font-size:22px; letter-spacing:1px; margin-bottom:12px; }
.lypsn-result-msg    { color:var(--sn-muted); font-size:15px; margin:0 0 12px; }
.lypsn-result-record-badge {
    display:inline-block; background:var(--sn-yellow); color:#1a1a2e;
    font-weight:800; font-size:14px; padding:6px 20px; border-radius:30px; margin-bottom:16px;
}
.lypsn-result-buttons { display:flex; gap:10px; justify-content:center; flex-wrap:wrap; }

/* ── PULSANTI ────────────────────────────────────────────── */
.lypsn-btn-primary {
    background: linear-gradient(135deg, var(--sn-teal), #26a69a);
    color: #0f1535; border:none; border-radius:30px;
    font-family:var(--sn-font-b); font-weight:800; font-size:15px;
    padding:13px 26px; cursor:pointer; transition:transform .15s, box-shadow .15s;
    box-shadow:0 4px 15px rgba(78,205,196,.4);
}
.lypsn-btn-primary:hover { transform:translateY(-2px); box-shadow:0 6px 20px rgba(78,205,196,.5); }
.lypsn-btn-primary.lypsn-btn-red {
    background: linear-gradient(135deg, var(--sn-red), #dc2626);
    box-shadow: 0 4px 15px rgba(239,68,68,.4);
    color:#fff;
}
.lypsn-btn-secondary {
    background:rgba(255,255,255,.1); border:1px solid rgba(255,255,255,.2);
    color:var(--sn-text); font-family:var(--sn-font-b); font-weight:700;
    font-size:14px; padding:12px 22px; border-radius:30px; cursor:pointer; transition:background .2s;
}
.lypsn-btn-secondary:hover { background:rgba(255,255,255,.2); }
.lypsn-btn-fullwidth { width:100%; margin-top:10px; }

/* ── CONFETTI ────────────────────────────────────────────── */
.lypsn-confetti { position:relative; height:60px; overflow:hidden; margin-top:10px; }
.lypsn-confetti-piece {
    position:absolute; top:-10px; border-radius:3px;
    animation:sn-confetti-fall 1.8s ease-in forwards;
}
@keyframes sn-confetti-fall { to { transform:translateY(80px) rotate(720deg); opacity:0; } }

/* ── RESPONSIVE ──────────────────────────────────────────── */
@media (max-width:600px) {
    .lypsn-screen { padding:20px 14px 24px; }
    .lypsn-logo-icon { font-size:38px; }
    .lypsn-title { font-size:28px; }
    .lypsn-cat-grid { grid-template-columns:1fr 1fr; gap:8px; }
    .lypsn-mode-grid { grid-template-columns:1fr; }
    .lypsn-mode-btn:first-child { grid-column:auto; }
    .lypsn-board { grid-template-columns:repeat(4,1fr); gap:4px; }
    /* Card memory su mobile: font scalato per parole lunghe */
    .lypsn-card-back { font-size:10px; padding:6px 3px; }
    .lypsn-card-front { font-size:18px; }
    .lypsn-answers { grid-template-columns:1fr; }
    .lypsn-question-word { font-size:30px; }
    /* Learn actions su mobile resta griglia 2x2 ma padding ridotto */
    .lypsn-learn-actions .lypsn-btn-primary,
    .lypsn-learn-actions .lypsn-btn-secondary { font-size:12px; padding:9px 6px; }
}

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