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

:root {
    --en-bg:      #0f1535;
    --en-surface: #1a2555;
    --en-card:    #1e2f45;
    --en-text:    #e8f0fe;
    --en-muted:   #7a90b0;
    --en-label:   #a8bdd8;
    --en-yellow:  #FFD93D;
    --en-green:   #26de81;
    --en-red:     #ff4757;
    --en-radius:  16px;
    --en-font-h:  'Fredoka One', cursive;
    --en-font-b:  'Nunito', sans-serif;
    --en-shadow:  0 20px 60px rgba(0,0,0,.5);
}

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

/* ── SFONDO STELLATO ─────────────────────────────────────── */
.lype-stars-bg { position:absolute; inset:0; pointer-events:none; overflow:hidden; border-radius:24px; }
.lype-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; }

/* ── HOME ────────────────────────────────────────────────── */
.lype-home-content { position:relative; z-index:1; }
.lype-logo { display:flex; align-items:center; gap:14px; margin-bottom:8px; justify-content:center; }
.lype-logo-flag { font-size:52px; animation:lype-bounce 2s infinite ease-in-out; }
@keyframes lype-bounce { 0%,100%{transform:translateY(0)} 50%{transform:translateY(-8px)} }
.lype-title { font-family:var(--en-font-h); font-size:36px; margin:0; line-height:1.1; color:#fff; }
.lype-title span { color:var(--en-yellow); }
.lype-subtitle { color:var(--en-muted); font-size:15px; margin:0 0 24px; text-align:center; }

/* Griglia temi */
.lype-tema-grid { display:grid; grid-template-columns:repeat(3,1fr); gap:12px; }
.lype-tema-card {
    background: var(--en-card);
    border: 2px solid rgba(255,255,255,.06);
    border-left: 4px solid var(--tc, #4ECDC4);
    border-radius: var(--en-radius);
    padding: 14px 14px 10px;
    display: flex; flex-direction: column; gap: 10px;
    transition: background .18s;
}
.lype-tema-card:hover { background: #2a3880; }
.lype-tema-top { display:flex; flex-direction:column; gap:3px; }
.lype-tema-icon   { font-size:26px; }
.lype-tema-label  { font-family:var(--en-font-h); font-size:16px; color:#fff; }
.lype-tema-record { font-size:11px; color:var(--en-yellow); min-height:16px; }
/* Pulsanti Impara / Gioca — stile coerente con gli altri giochi */
.lype-tema-actions { display:flex; gap:6px; }
.lype-tema-btn-learn,
.lype-tema-btn-play {
    flex:1; border:none; border-radius:10px;
    font-family:var(--en-font-b); font-size:12px; font-weight:700;
    padding:7px 4px; cursor:pointer; transition:transform .15s, opacity .15s;
    white-space:nowrap;
}
.lype-tema-btn-learn {
    background:rgba(255,255,255,.1); color:var(--en-text);
}
.lype-tema-btn-learn:hover { background:rgba(255,255,255,.2); }
.lype-tema-btn-play {
    background:linear-gradient(135deg, var(--tc,#4ECDC4), color-mix(in srgb, var(--tc,#4ECDC4) 70%, #fff));
    color:#1a2540;
    box-shadow:0 2px 8px color-mix(in srgb, var(--tc,#4ECDC4) 40%, transparent);
}
.lype-tema-btn-play:hover { transform:scale(1.05); }

/* ── GAME HEADER ─────────────────────────────────────────── */
.lype-game-content { display:flex; flex-direction:column; gap:16px; }
.lype-game-header {
    display: flex; align-items:center; justify-content:space-between;
    background: var(--en-card);
    border-radius: 12px;
    padding: 10px 16px;
    gap: 12px;
}
.lype-header-tema { font-family:var(--en-font-h); font-size:16px; color:#fff; flex:1; }
.lype-lives { font-size:18px; letter-spacing:1px; }
.lype-score-chip { display:flex; flex-direction:column; align-items:center; }
.lype-score-label { font-size:10px; color:var(--en-muted); text-transform:uppercase; letter-spacing:.05em; }
.lype-score-chip strong { font-family:var(--en-font-h); font-size:22px; color:var(--en-yellow); line-height:1; }

/* ── FLASHCARD ───────────────────────────────────────────── */
.lype-card-wrap { display:flex; flex-direction:column; align-items:center; gap:10px; }
.lype-card {
    background: linear-gradient(135deg, var(--en-card) 0%, #243652 100%);
    border: 2px solid rgba(255,255,255,.1);
    border-radius: 20px;
    padding: 28px 32px;
    text-align: center;
    width: 100%;
    box-shadow: 0 8px 32px rgba(0,0,0,.3);
    transition: transform .15s;
}
.lype-card-emoji { font-size:72px; line-height:1; margin-bottom:12px; }
.lype-card-word  { font-family:var(--en-font-h); font-size:28px; color:#fff; }

/* Animazioni carta */
.lype-card-pop     { animation: en-pop .35s cubic-bezier(.36,.07,.19,.97); }
.lype-card-correct { animation: en-correct .4s ease; }
.lype-card-wrong   { animation: en-shake .4s ease; }
/* Blocca tap-highlight mobile durante la transizione tra carte */
.lype-answer-input:disabled { opacity:.5; pointer-events:none; -webkit-tap-highlight-color:transparent; }
@keyframes en-pop     { 0%{transform:scale(.9);opacity:.5} 60%{transform:scale(1.05)} 100%{transform:scale(1);opacity:1} }
@keyframes en-correct { 0%{background:var(--en-card)} 50%{background:rgba(38,222,129,.25)} 100%{background:var(--en-card)} }
@keyframes en-shake   { 0%,100%{transform:translateX(0)} 20%{transform:translateX(-8px)} 60%{transform:translateX(8px)} 80%{transform:translateX(-4px)} }

/* Hint (lettera iniziale) */
.lype-card-hint { font-size:18px; color:var(--en-muted); letter-spacing:4px; font-family:monospace; min-height:24px; }
.lype-card-hint-visible { color:var(--en-yellow); }

/* ── INPUT ───────────────────────────────────────────────── */
.lype-input-row { display:flex; gap:10px; }
.lype-answer-input {
    flex:1;
    background: var(--en-card);
    border: 2px solid rgba(255,255,255,.12);
    border-radius: 12px;
    color: var(--en-text);
    font-family: var(--en-font-b);
    font-size: 20px;
    font-weight: 700;
    padding: 12px 16px;
    outline: none;
    transition: border-color .2s;
}
.lype-answer-input:focus { border-color:var(--en-yellow); }
.lype-answer-input::placeholder { color:var(--en-muted); font-weight:400; }
/* .lype-answer-input:disabled gestito sopra */
.lype-ok-btn {
    background: linear-gradient(135deg, #26de81, #20bf6b);
    border: none; border-radius: 12px;
    color: #fff; font-family:var(--en-font-h); font-size:16px;
    padding: 12px 18px; cursor:pointer;
    transition: transform .15s, opacity .15s;
    box-shadow: 0 4px 16px rgba(38,222,129,.35);
    white-space:nowrap;
}
.lype-ok-btn:hover { transform:scale(1.05); }

/* ── FEEDBACK ────────────────────────────────────────────── */
.lype-feedback { font-size:15px; font-weight:700; min-height:22px; text-align:center; }
.lype-feedback-ok  { color:var(--en-green); }
.lype-feedback-err { color:var(--en-red); }

/* ── PROGRESS BAR ────────────────────────────────────────── */
.lype-progress-bar-wrap {
    background: rgba(255,255,255,.07);
    border-radius: 99px; height:8px; overflow:hidden;
}
.lype-progress-bar {
    height:100%; border-radius:99px; width:0%;
    background: linear-gradient(90deg, #4ECDC4, var(--en-yellow));
    transition: width .4s ease;
}
.lype-progress-label { font-size:11px; color:var(--en-muted); text-align:right; margin-top:2px; }

/* ── BACK BTN ────────────────────────────────────────────── */
.lype-back-btn {
    background:rgba(255,255,255,.1); border:1px solid rgba(255,255,255,.15);
    color:var(--en-text); font-family:var(--en-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;
}
.lype-back-btn:hover { background:rgba(255,255,255,.2); }

/* ── RISULTATO / GAME OVER ───────────────────────────────── */
.lype-result-content { text-align:center; padding-top:16px; }
.lype-result-trophy  { font-size:72px; margin-bottom:12px; }
.lype-result-title   { font-family:var(--en-font-h); font-size:28px; color:#fff; margin:0 0 10px; }
.lype-result-msg     { color:var(--en-label); font-size:15px; margin:0 0 16px; }
.lype-result-record-badge {
    display:inline-block; background:rgba(255,217,61,.15);
    border:1px solid rgba(255,217,61,.4); border-radius:12px;
    padding:6px 16px; font-size:14px; font-weight:700;
    color:var(--en-yellow); margin-bottom:16px;
}
.lype-result-buttons { display:flex; gap:12px; justify-content:center; flex-wrap:wrap; margin-top:8px; }
.lype-btn-primary {
    background:linear-gradient(135deg,#4ECDC4,#26de81);
    border:none; border-radius:14px; color:#1a2540;
    font-family:var(--en-font-h); font-size:18px;
    padding:12px 24px; cursor:pointer; transition:transform .15s;
    box-shadow:0 4px 16px rgba(78,205,196,.4);
}
.lype-btn-primary:hover { transform:scale(1.04); }
.lype-btn-secondary {
    background:rgba(255,255,255,.1); border:1px solid rgba(255,255,255,.15);
    color:var(--en-text); font-family:var(--en-font-h); font-size:18px;
    padding:12px 24px; border-radius:14px; cursor:pointer; transition:background .2s;
}
.lype-btn-secondary:hover { background:rgba(255,255,255,.2); }

/* Coriandoli */
.lype-confetti { position:relative; height:0; overflow:visible; }
.lype-confetti-piece {
    position:absolute; top:0; border-radius:3px;
    animation:lype-confetti-fall 1.8s ease-in forwards;
}
@keyframes lype-confetti-fall {
    0%   { transform:translateY(0) rotate(0deg); opacity:1; }
    100% { transform:translateY(180px) rotate(720deg); opacity:0; }
}

/* ── RESPONSIVE ──────────────────────────────────────────── */
@media (max-width:600px) {
    .lype-screen { padding:18px 14px 24px; }
    .lype-logo-flag { font-size:38px; }
    .lype-title { font-size:28px; }
    .lype-tema-grid { grid-template-columns:repeat(2,1fr); gap:10px; }
    .lype-tema-card { padding:14px 10px; }
    .lype-tema-icon { font-size:26px; }
    .lype-card-emoji { font-size:54px; }
    .lype-card-word  { font-size:22px; }
    .lype-card { padding:20px 18px; }
    .lype-answer-input { font-size:18px; }
    .lype-lives { font-size:15px; }
}

/* ── SCHERMATA IMPARA ─────────────────────────────────────── */
.lype-learn-content {
    display: flex;
    flex-direction: column;
    gap: 14px;
}
.lype-learn-heading {
    font-family: var(--en-font-h);
    font-size: 22px;
    color: #fff;
    margin: 0;
}
.lype-learn-intro {
    color: var(--en-label);
    font-size: 14px;
    margin: 0;
    line-height: 1.6;
}
/* Griglia vera di card — 3 colonne */
.lype-learn-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    padding-right: 2px;
}
.lype-learn-card {
    background: rgba(255,255,255,.07);
    border: 1px solid rgba(255,255,255,.1);
    border-radius: 12px;
    padding: 12px 8px 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    text-align: center;
    transition: background .15s, transform .15s;
    cursor: default;
}
.lype-learn-card:hover {
    background: rgba(255,255,255,.13);
    transform: translateY(-2px);
}
.lype-learn-card-emoji { font-size: 30px; line-height: 1; }
.lype-learn-card-it {
    font-family: var(--en-font-h);
    font-size: 13px;
    color: #fff;
    line-height: 1.2;
}
.lype-learn-card-en {
    font-size: 16px;
    color: var(--en-yellow);
    font-family: var(--en-font-h);
    font-weight: 700;
}

/* Barra score + reset — stile coerente con gli altri giochi */
.lype-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; margin-top:16px;
}
.lype-btn-small {
    background:rgba(255,255,255,.1); border:none; color:var(--en-text);
    font-family:var(--en-font-b); font-size:13px; font-weight:700;
    padding:5px 12px; border-radius:20px; cursor:pointer; transition:background .2s;
}
.lype-btn-small:hover { background:rgba(255,255,255,.2); }

@media (max-width:600px) {
    .lype-learn-grid { grid-template-columns: repeat(2,1fr); gap:8px; }
    .lype-learn-card-emoji { font-size:22px; }
}

/* ── TASTIERA CUSTOM ────────────────────────────────────────── */
.lype-answer-display {
    flex: 1;
    background: var(--en-card);
    border: 2px solid rgba(255,255,255,.12);
    border-radius: 12px;
    color: var(--en-text);
    font-family: var(--en-font-b);
    font-size: 20px;
    font-weight: 700;
    padding: 12px 16px;
    min-height: 48px;
    display: flex;
    align-items: center;
    letter-spacing: 2px;
    transition: border-color .2s;
}
.lype-answer-display.active { border-color: var(--en-yellow); }
.lype-answer-text { min-width: 4px; }
.lype-cursor {
    display: inline-block;
    color: var(--en-yellow);
    font-weight: 300;
    animation: lype-blink 1s step-end infinite;
    margin-left: 1px;
}
@keyframes lype-blink { 0%,100%{opacity:1} 50%{opacity:0} }

.lype-keyboard {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 10px;
    user-select: none;
    -webkit-user-select: none;
}
.lype-kb-row {
    display: flex;
    justify-content: center;
    gap: 5px;
}
.lype-kb-key {
    background: var(--en-card);
    border: 1px solid rgba(255,255,255,.15);
    border-radius: 8px;
    color: var(--en-text);
    font-family: var(--en-font-b);
    font-size: 15px;
    font-weight: 700;
    padding: 0;
    width: 32px;
    height: 40px;
    cursor: pointer;
    transition: background .1s, transform .08s;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}
.lype-kb-key:active { background: var(--en-yellow); color: #1a1a2e; transform: scale(.94); }
.lype-kb-space { width: 120px; font-size: 12px; letter-spacing: 1px; }
.lype-kb-dash  { width: 44px; }
.lype-kb-back  { width: 52px; font-size: 18px; }
.lype-kb-disabled .lype-kb-key { opacity: .4; pointer-events: none; }

/* ── PULSANTE PRONUNCIA ──────────────────────────────────── */
.lype-card-word-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}
.lype-speak-btn {
    background: none;
    border: none;
    font-size: 22px;
    cursor: pointer;
    opacity: .65;
    transition: opacity .15s, transform .15s;
    padding: 4px 2px;
    line-height: 1;
    flex-shrink: 0;
}
.lype-speak-btn:hover { opacity: 1; transform: scale(1.2); }

/* ── NASCONDI TASTIERA SU DESKTOP (puntatore preciso = mouse) */
@media (pointer: fine) {
    #lype-keyboard { display: none; }
}

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