
        /* Reset e variabili CSS */
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        :root {
            --primary-color: #ffffff;
            --primary-hover: #1d4ed8;
            --secondary-color: #64748b;
            --success-color: #10b981;
            --error-color: #ef4444;
            --warning-color: #f59e0b;
            --background: #f8fafc;
            --surface: #ffffff;
            --surface-hover: #f1f5f9;   
            --text-primary: #0f172a;
            --text-secondary: #475569;
            --border-color: #e2e8f0;
            --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
            --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
            --radius: 8px;
            --radius-lg: 12px;
            --radius-lg: 12px;--gradient-primary: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            --gradient-hero: linear-gradient(135deg, #965c66 0%, #E18997 30%, #e07688 70%, #e2556d 100%);
            --nav-bg: #ffffff;
            --nav-text: #1a365d;
            --nav-hover-bg: #f1f5f9;
            --nav-border: #e2e8f0;
            --text-secondary-header: #222f3f;
            --cards-bg: #f8fafc;
            --card-bg: #ffffff;
            --card-text: #0f172a;
            --card-text-secondary: #475569;
            --footer-bg: transparent;
            --footer-text: #475569;
        }

        /* Dark theme variables */
        [data-theme="dark"] {
            --nav-bg: #1e293b;
            --nav-text: #ffffff;
            --nav-hover-bg: #334155;
            --nav-border: #334155;
            
            --cards-bg: #0f172a;
            --card-bg: #1e293b;
            --card-text: #ffffff;
            --card-text-secondary: #cbd5e1;
            --footer-bg: #0f172a;
            --footer-text: #ffffff;
            
            /* Override delle variabili esistenti per dark mode */
            --background: #0f172a;
            --surface: #1e293b;
            --surface-hover: #334155;   
            --text-primary: #ffffff;
            --text-secondary: #cbd5e1;
            --border-color: #334155;
        }


        body {
            font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', sans-serif;
            background: var(--background);
            color: var(--text-primary);
            line-height: 1.6;
            min-height: 100vh;
            padding-bottom: 80px;
            transition: background-color 0.3s ease, color 0.3s ease;
        }

        /* Navigation */
        nav {
            background: var(--nav-bg);
            border-bottom: 1px solid var(--nav-border);
            transition: background-color 0.3s ease, border-color 0.3s ease;
            position: sticky;
            top: 0;
            z-index: 100;
            box-shadow: var(--shadow);
        }

        .nav-container {
            max-width: 1200px;
            margin: 0 auto;
            padding: 0 16px;
        }

        .nav-links {
            display: flex;
            justify-content: space-around;
            align-items: center;
            padding: 12px 0;
        }

        .nav-item {
            display: flex;
            flex-direction: column;
            align-items: center;
            text-decoration: none;
            color: var(--nav-text);
            transition: all 0.3s ease;
            padding: 8px 12px;
            border-radius: var(--radius);
            min-width: 60px;
        }

        .nav-item:hover {
            color: var(--primary-color);
            background: var(--nav-hover-bg);
        }

        .nav-item img {
            width: 24px;
            height: 24px;
            margin-bottom: 4px;
        }

        .nav-item span {
            font-size: 12px;
            font-weight: 500;
        }

        /* Container principale */
        .main-container {
            max-width: 1200px;
            margin: 0 auto;
            padding: 20px 16px;
            background-color: var(--surface);
            transition: background-color 0.3s ease;
        }

        /* Header Section */
        .page-header {
            background: var(--gradient-hero);
            border-radius: var(--radius-lg);
            box-shadow: var(--shadow-lg);
            padding: 24px;
            margin-bottom: 20px;
            text-align: center;
            z-index: 1;
            position: relative;
        }

        .game-header::before {
            content: '';
            position: absolute;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1000 1000"><defs><radialGradient id="a" cx="0.5" cy="0.5" r="0.8"><stop offset="0%" stop-color="rgba(255,255,255,0.35)"/><stop offset="100%" stop-color="rgba(255,255,255,0)"/></radialGradient></defs><circle cx="220" cy="220" r="200" fill="url(%23a)"/><circle cx="800" cy="300" r="150" fill="url(%23a)"/><circle cx="600" cy="700" r="250" fill="url(%23a)"/><circle cx="400" cy="500" r="120" fill="url(%23a)"/><circle cx="900" cy="800" r="100" fill="url(%23a)"/></svg>') no-repeat center center;
            background-size: cover;
            opacity: 0.5;
            pointer-events: none;
            z-index: 0;
        }

        .page-title {
            font-size: 3.5rem;
            font-weight: 800;
            margin-bottom: 1.5rem;
            background: linear-gradient(135deg, #ffffff 0%, #f5f7f9 100%);
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
            background-clip: text;
            line-height: 1.2;
            text-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
        }

        .page-subtitle {
            font-size: 16px;
            color: var(--text-secondary-header);
            margin-bottom: 24px;
        }

        .page-instructions {
            font-size: 14px;
            color: var(--text-secondary-header);
            background: rgb(37 99 235 / 0.1);
            padding: 12px;
            border-radius: var(--radius);
            margin-bottom: 16px;
        }

        /* ------- Scoped styles: only affect elements inside .lw-card ------- */
        .lw-card { 
            margin: 16px 0;
            background: var(--surface);
            border-radius: var(--radius-lg);
            box-shadow: var(--shadow);
            overflow: hidden;
        }
        .lw-card * { box-sizing: border-box; }

        .lw-card .card {
            background: white;
            border-radius: 20px;
            max-width: 100%;
            width: 100%;
            overflow: hidden;
            animation: lw-slideIn 0.6s ease-out;
            margin: 0 auto;
        }

        @keyframes lw-slideIn {
            from { opacity: 0; transform: translateY(30px); }
            to   { opacity: 1; transform: translateY(0); }
        }

        .lw-card .card-header {
            background: linear-gradient(135deg, #aeabad, #d4c4c4);
            color: white;
            padding: 2px;
            text-align: center;
        }

        .lw-card .card-header h1 {
            font-size: 2em;
            margin-top: 10px;
            margin-bottom: 10px;
            text-shadow: 0 2px 4px rgba(0,0,0,0.2);
        }

        .lw-card .card-body { 
            padding: 15px; 
            background: var(--cards-bg);
        }
                                       
        .lw-card .level-buttons {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
            gap: 15px;
            margin-bottom: 0px;
        }

        .lw-card .level-btn {
            background: linear-gradient(135deg, #f8f9fa, #e9ecef);
            border: 2px solid #dee2e6;
            border-radius: 12px;   /* più compatto */
            padding: 12px 16px;    /* ridotto (era 20px) */
            cursor: pointer;
            transition: all 0.3s ease;
            text-align: center;
            font-size: 0.9em;      /* testo meno grande */
        }
        
        .lw-card .level-icon {
            font-size: 1.5em;      /* ridotto (era 2em) */
            margin-bottom: 6px;
        }
        
        .lw-card .level-title {
            font-size: 1.1em;      /* più piccolo */
        }
           
        .lw-card .level-btn:hover {
            transform: translateY(-5px);
            box-shadow: 0 10px 25px rgba(0,0,0,0.15);
        }

        .lw-card .level-btn.active {
            background: linear-gradient(135deg, #74b9ff, #0984e3);
            color: white;
            border-color: #0984e3;
        }

        .lw-card .level-btn.facile { 
            border-color: #00b894; 
            background: var(--card-bg);
            color: var(--nav-text);
        }
        .lw-card .level-btn.facile:hover,
        .lw-card .level-btn.facile.active {
            background: linear-gradient(135deg, #00b894, #007b67);
            border-color: #00a085;
        }

        .lw-card .level-btn.medio { 
            border-color: #fdcb6e; 
            background: var(--card-bg);
            color: var(--nav-text);
        }
        .lw-card .level-btn.medio:hover,
        .lw-card .level-btn.medio.active {
            background: linear-gradient(135deg, #fdcb6e, #e17055);
            border-color: #e17055;
        }

        .lw-card .level-btn.difficile { 
            border-color: #cb1c1c; 
            background: var(--card-bg);
            color: var(--nav-text);
        }
        .lw-card .level-btn.difficile:hover,
        .lw-card .level-btn.difficile.active {
            background: linear-gradient(135deg, #d84141, #ab1515);
            border-color: #a41111;
        }

        .lw-card .story-container {
            background: var(--nav-bg);
            border-radius: 15px;
            padding: 30px;
            margin-top: 20px;
            min-height: 300px;
            display: none;
            animation: lw-fadeIn 0.5s ease-in;
        }

        .lw-card .story-container.show { 
            display: block; 
            background: var(--nav-bg);

        
        }

        @keyframes lw-fadeIn { from { opacity: 0; } to { opacity: 1; } }

        .lw-card .story-title {
            font-size: 1.5em;
            font-weight: bold;
            margin-bottom: 15px;
            color: var(--nav-text);
        }

        .lw-card .story-content {
            line-height: 1.8;
            font-size: 1.1em;
            color: #636e72;
            text-align: justify;
            margin-bottom: 25px;
        }

        .lw-card .story-level-badge {
            display: inline-block;
            background: linear-gradient(135deg, #74b9ff, #0984e3);
            color: white;
            padding: 5px 15px;
            border-radius: 20px;
            font-size: 0.9em;
            font-weight: bold;
            margin-bottom: 20px;
        }

        .lw-card .highlighted-word {
            background: linear-gradient(135deg, #fdcb6e, #e17055);
            color: white;
            padding: 2px 6px;
            border-radius: 4px;
            font-weight: bold;
        }

        .lw-card .difficult-words {
            background: #e8f4f8;
            border-left: 4px solid #74b9ff;
            padding: 20px;
            margin-top: 25px;
            border-radius: 8px;
        }

        .lw-card .difficult-words h3 {
            color: #2d3436;
            margin-bottom: 15px;
            font-size: 1.2em;
        }

        .lw-card .words-list { display: grid; gap: 10px; }

        .lw-card .word-item {
            background: var(--nav-bg);
            padding: 12px;
            border-radius: 6px;
            border: 1px solid #ddd;
            font-size: 0.95em;
        }

        .lw-card .word-item strong { color: #0984e3; }

        .lw-card .no-story {
            text-align: center;
            color: #74b9ff;
            font-style: italic;
            font-size: 1.2em;
            padding: 60px 20px;
        }

        /* Footer con supporto tema */
        footer {
            background: var(--footer-bg);
            color: var(--footer-text);
            transition: background-color 0.3s ease, color 0.3s ease;
        }

        footer a {
            color: var(--footer-text);
            transition: color 0.3s ease;
        }

        /* Theme Toggle Button */
        .theme-toggle {
            position: absolute;
            right: 8px;
            top: 50%;
            transform: translateY(-50%);
            background: var(--nav-hover-bg);
            border: 1px solid var(--nav-border);
            border-radius: var(--radius);
            width: 36px;
            height: 36px;
            display: flex;
            align-items: center;
            justify-content: center;
            cursor: pointer;
            transition: all 0.3s ease;
            color: var(--nav-text);
            font-size: 16px;
            z-index: 10;
        }

        .theme-toggle:hover {
            transform: translateY(-50%) scale(1.05);
            box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
        }

        .theme-toggle:active {
            transform: translateY(-50%) scale(0.95);
        }


        /* Responsive Design */
        @media (max-width: 768px) {
            .main-container {
                padding: 8px 6px;
            }

            .page-header {
                margin-bottom: 0px;
                padding: 16px;
            }

            .page-title {
                font-size: 2.25rem;
                margin: 0 0 12px;
            }

            .page-subtitle {
                font-size: 12px;
                margin-bottom: 6px;
            }

            .page-instructions {
                font-size: 13px;
                padding: 10px;
                margin-bottom: 12px;
            }

            .nav-item span {
                font-size: 11px;
            }
            
            .nav-links {
                padding-right: 50px;
                padding: 0px 0;
            }

            .theme-toggle {
            width: 32px;
            height: 32px;
            right: 8px;
            font-size: 14px;
            }

            .lw-card {
                margin: 8px 0;
            }

            .lw-card .card-header h1 {
                font-size: 1.5em;
            }

            .lw-card .level-buttons {
                grid-template-columns: 1fr;
                gap: 10px;
            }

            .lw-card .story-container {
                padding: 20px 15px;
            }
        }

        @media (max-width: 480px) {

            .lw-card .card-header h1 {
                font-size: 1.3em;
            }

            .lw-card .story-content {
                font-size: 1em;
            }

            .nav-links {
            padding-right: 45px;
            }
            
            .theme-toggle {
                width: 28px;
                height: 28px;
                right: 6px;
                font-size: 12px;
            }
        }

        /* Footer */
        footer {
            text-align: center;
            margin-top: 3rem;
            padding: 2rem 1rem;
            font-size: 0.9em;
            color: var(--text-secondary);
            border-top: 1px solid var(--border-color);
            background: var(--surface);
        }

        footer p {
            margin-bottom: 0.5rem;
        }

        footer a {
            color: var(--text-secondary);
            text-decoration: none;
        }

        footer a:hover {
            text-decoration: underline;
        }

        /* Utilities */
        .hidden {
            display: none !important;
        }

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

        .fade-in {
            animation: fadeIn 0.3s ease-in;
        }

        @keyframes fadeIn {
            from { opacity: 0; transform: translateY(10px); }
            to { opacity: 1; transform: translateY(0); }
        }
