:root {
    --bg: #f8fafc;
    --card: #ffffff;
    --text: #0f172a;
    --muted: #475569;
    --yellow: #ffbe0b;
    --blue: #2563eb;
    --green: #16a34a;
    --orange: #ea580c;
    --red: #dc2626;
    --border: #dbe3ee;
    --shadow: 0 10px 24px rgba(15, 23, 42, 0.12);
}

* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: 'Lexend Deca', system-ui, sans-serif;
    color: var(--text);
    background: radial-gradient(circle at 12% 18%, #fff7cc 0%, #f8fafc 40%),
                radial-gradient(circle at 88% 6%, #dbeafe 0%, rgba(219, 234, 254, 0) 36%);
    min-height: 100vh;
}

.screen { display: none; padding: 22px 14px 40px; }
.screen.active { display: flex; flex-direction: column; align-items: center; animation: fade .2s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.ss-header { text-align: center; max-width: 720px; }
.ss-header h1 {
    margin: 10px 0 2px;
    font-family: 'Fredoka One', cursive;
    font-size: clamp(2rem, 6vw, 3rem);
    color: var(--blue);
}
.ss-sub { color: var(--muted); font-size: .95rem; margin-bottom: 10px; }
.ss-pill {
    display: inline-flex; gap: 8px; align-items: center;
    background: #fff8cc; border: 2px solid #ffbe0b; color: #7a5200;
    border-radius: 999px; padding: 6px 14px; font-size: .84rem; font-weight: 700;
}

.ss-mode-grid {
    margin-top: 16px;
    width: 100%;
    max-width: 760px;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 12px;
}
.ss-mode-card {
    border: 2px solid var(--border);
    border-radius: 16px;
    padding: 14px;
    background: var(--card);
    box-shadow: var(--shadow);
    cursor: pointer;
    text-align: left;
}
.ss-mode-card h3 {
    margin: 2px 0 4px;
    font-family: 'Fredoka One', cursive;
    font-size: 1.1rem;
}
.ss-mode-card p { margin: 0; font-size: .84rem; color: var(--muted); line-height: 1.4; }
.ss-mode-card[data-mode="continuous"] { border-color: #2563eb; }
.ss-mode-card[data-mode="successive"] { border-color: #e63946; }
.ss-mode-card[data-mode="boxes"] { border-color: #16a34a; }

.ss-game-wrap {
    width: 100%; max-width: 700px;
    background: var(--card);
    border: 2px solid var(--border);
    border-radius: 18px;
    box-shadow: var(--shadow);
    padding: 14px;
}
.ss-hud { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.ss-meter { width: 100%; height: 8px; border-radius: 999px; background: #e2e8f0; overflow: hidden; margin-bottom: 12px; }
.ss-meter-fill { height: 100%; width: 0; background: linear-gradient(90deg, #e63946, #2563eb, #16a34a); transition: width .3s; }

.ss-target {
    min-height: 130px;
    border: 2px dashed #cbd5e1;
    border-radius: 14px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px;
    margin-bottom: 12px;
    position: relative;
    overflow: hidden;
}
.ss-big {
    font-family: 'Fredoka One', cursive;
    font-size: clamp(2.2rem, 10vw, 4.2rem);
    letter-spacing: .08em;
}
.ss-hint { font-size: .86rem; color: var(--muted); }
.ss-row { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }

.ss-btn {
    border: 2px solid #cbd5e1;
    background: #fff;
    border-radius: 12px;
    padding: 10px 12px;
    font-size: .9rem;
    font-weight: 700;
    cursor: pointer;
}
.ss-btn.primary { background: #e63946; border-color: #c81d2a; color: #fff; }
.ss-btn.secondary { background: #2563eb; border-color: #1d4ed8; color: #fff; }
.ss-btn.correct { background: #dcfce7; border-color: #22c55e; color: #14532d; }
.ss-btn.wrong { background: #fee2e2; border-color: #ef4444; color: #7f1d1d; }

/* Keep action buttons visually distinct */
.ss-row .ss-btn:nth-child(1) { background: #e63946; border-color: #c81d2a; color: #fff; }
.ss-row .ss-btn:nth-child(2) { background: #2563eb; border-color: #1d4ed8; color: #fff; }
.ss-row .ss-btn:nth-child(3) { background: #16a34a; border-color: #15803d; color: #fff; }

.ss-phoneme {
    min-width: 52px;
    text-align: center;
    border-radius: 10px;
    border: 2px solid #bfdbfe;
    padding: 10px 8px;
    background: #eff6ff;
    font-family: 'Fredoka One', cursive;
    font-size: 1.3rem;
}
.ss-phoneme.active { transform: scale(1.1); background: #dbeafe; border-color: #2563eb; }

.ss-boxes { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.ss-box {
    width: 54px; height: 54px;
    border: 2px dashed #94a3b8;
    border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.2rem; font-weight: 800;
}
.ss-chip-row { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.ss-chip {
    border: 2px solid #fcd34d; background: #fef3c7; color: #92400e;
    border-radius: 999px; padding: 8px 12px; font-weight: 700; cursor: pointer;
}

.ss-feedback { min-height: 24px; font-weight: 700; color: #065f46; text-align: center; }
.ss-feedback.bad { color: #b91c1c; }

.ss-pop {
    position: absolute;
    inset: auto;
    left: 50%; top: 50%;
    transform: translate(-50%, -50%);
    font-size: 2rem;
    pointer-events: none;
    animation: pop .45s ease forwards;
}
@keyframes pop {
    0% { opacity: 0; transform: translate(-50%, -50%) scale(.2); }
    50% { opacity: 1; transform: translate(-50%, -60%) scale(1.2); }
    100% { opacity: 0; transform: translate(-50%, -85%) scale(.6); }
}

.ss-results {
    margin-top: 14px;
    width: 100%; max-width: 440px;
    background: #fff;
    border: 2px solid var(--border);
    border-radius: 16px;
    box-shadow: var(--shadow);
    padding: 18px;
    text-align: center;
}

@media (max-width: 520px) {
    .ss-game-wrap { padding: 10px; }
    .ss-target { min-height: 114px; }
    .ss-box { width: 46px; height: 46px; }
}
