* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #1775F8 0%, #0d4fa3 100%);
    min-height: 100vh;
    padding: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
}

/* STILE PULSANTE HOME */
.home-btn {
    position: absolute;
    top: 20px;
    left: 20px;
    padding: 10px 20px;
    background: rgba(255, 255, 255, 0.9);
    color: #1775F8;
    border: 2px solid #1775F8;
    border-radius: 12px;
    font-weight: bold;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.3s;
    z-index: 1000;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.home-btn:hover {
    background: #1775F8;
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.2);
}

.container {
    width: 100%;
    max-width: 800px;
}

.login-section {
    background: white;
    padding: 40px;
    border-radius: 25px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    text-align: center;
}

.login-section h1 {
    color: #667eea;
    margin-bottom: 30px;
    font-size: 2.5em;
}

.login-section input[type="password"] {
    width: 100%;
    padding: 15px 20px;
    border: 2px solid #e0e0e0;
    border-radius: 15px;
    font-size: 1.1em;
    margin-bottom: 20px;
    transition: border-color 0.3s;
}

.login-section input[type="password"]:focus {
    outline: none;
    border-color: #1775F8;
}

.login-section .btn-login {
    width: 100%;
    padding: 15px;
    background: linear-gradient(135deg, #1775F8 0%, #0d4fa3 100%);
    color: white;
    border: none;
    border-radius: 15px;
    font-size: 1.1em;
    font-weight: bold;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.login-section .btn-login:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(23, 117, 248, 0.4);
}

.error-message {
    color: #ee0979;
    margin-top: 15px;
    font-weight: 500;
    display: none;
}

.error-message.show {
    display: block;
}

.main-content {
    display: none;
}

.main-content.active {
    display: block;
}

.header {
    background: white;
    padding: 30px;
    border-radius: 25px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    text-align: center;
    margin-bottom: 30px;
}

h1 {
    color: #1775F8;
    margin-bottom: 15px;
    font-size: 2.5em;
}

.logout-btn {
    position: absolute;
    top: 20px;
    right: 20px;
    padding: 10px 20px;
    background: rgba(255, 255, 255, 0.9);
    color: #1775F8;
    border: 2px solid #1775F8;
    border-radius: 12px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    z-index: 1000;
}

.logout-btn:hover {
    background: #1775F8;
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.2);
}

.upload-section {
    background: white;
    padding: 30px;
    border-radius: 25px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    margin-bottom: 30px;
}

.file-input-wrapper {
    position: relative;
    overflow: hidden;
    display: inline-block;
    width: 100%;
}

.file-input-wrapper input[type=file] {
    position: absolute;
    left: -9999px;
}

.file-input-label {
    display: block;
    padding: 15px 30px;
    background: linear-gradient(135deg, #1775F8 0%, #0d4fa3 100%);
    color: white;
    border-radius: 15px;
    cursor: pointer;
    text-align: center;
    font-size: 1.1em;
    font-weight: bold;
    transition: transform 0.2s, box-shadow 0.2s;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.file-input-label:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 20px rgba(23, 117, 248, 0.4);
}

.instructions {
    margin-top: 20px;
    padding: 20px;
    background: #f8f9ff;
    border-radius: 15px;
    border-left: 4px solid #1775F8;
}

.instructions h3 {
    color: #1775F8;
    margin-bottom: 10px;
}

.instructions p {
    color: #666;
    line-height: 1.6;
    margin-bottom: 10px;
}

.card-container {
    display: none;
    background: white;
    padding: 40px;
    border-radius: 25px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    margin-bottom: 30px;
}

.card-container.active {
    display: block;
}

.progress {
    text-align: center;
    margin-bottom: 30px;
    color: #1775F8;
    font-weight: bold;
    font-size: 1.1em;
}

.flashcard {
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    padding: 50px 40px;
    border-radius: 20px;
    min-height: 300px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    margin-bottom: 30px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.1);
}

.question {
    font-size: 1.5em;
    color: #333;
    font-weight: 600;
    margin-bottom: 30px;
}

.answers {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.answer-btn {
    width: 100%;
    padding: 20px;
    background: white;
    border: 3px solid #e0e0e0;
    border-radius: 15px;
    font-size: 1.1em;
    cursor: pointer;
    transition: all 0.3s;
    color: #333;
    font-weight: 500;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.answer-btn:hover {
    border-color: #1775F8;
    transform: translateX(5px);
    box-shadow: 0 3px 15px rgba(23, 117, 248, 0.2);
}

.answer-btn.correct {
    background: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);
    color: white;
    border-color: #11998e;
}

.answer-btn.wrong {
    background: linear-gradient(135deg, #ee0979 0%, #ff6a00 100%);
    color: white;
    border-color: #ee0979;
}

.answer-btn.disabled {
    cursor: not-allowed;
    opacity: 0.6;
}

.answer {
    font-size: 1.3em;
    color: #667eea;
    font-weight: 500;
    display: none;
    margin-top: 20px;
    padding-top: 20px;
    border-top: 2px solid #667eea;
}

.answer.show {
    display: block;
}

.hint {
    color: #999;
    font-size: 0.9em;
    margin-top: 20px;
    font-style: italic;
}

.controls {
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
}

.btn {
    padding: 15px 30px;
    border: none;
    border-radius: 15px;
    font-size: 1em;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.btn-primary {
    background: linear-gradient(135deg, #1775F8 0%, #0d4fa3 100%);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(23, 117, 248, 0.4);
}

.btn-success {
    background: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);
    color: white;
}

.btn-success:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(56, 239, 125, 0.4);
}

.btn-danger {
    background: linear-gradient(135deg, #ee0979 0%, #ff6a00 100%);
    color: white;
}

.btn-danger:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(238, 9, 121, 0.4);
}

.btn-secondary {
    background: #e0e0e0;
    color: #666;
}

.btn-secondary:hover {
    background: #d0d0d0;
}

.stats {
    background: white;
    padding: 25px;
    border-radius: 20px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    display: none;
    text-align: center;
}

.stats.active {
    display: block;
}

.stats h2 {
    color: #1775F8;
    margin-bottom: 20px;
}

.stat-item {
    display: flex;
    justify-content: space-between;
    padding: 15px;
    margin: 10px 0;
    background: #f8f9ff;
    border-radius: 12px;
    font-size: 1.1em;
}

.stat-label {
    color: #666;
    font-weight: 600;
}

.stat-value {
    color: #1775F8;
    font-weight: bold;
}

.success-rate {
    font-size: 2em;
    color: #11998e;
    font-weight: bold;
    margin: 20px 0;
}

@media (max-width: 600px) {
    body {
        padding: 10px;
    }

    /* ADATTAMENTO MOBILE PULSANTI */
    .home-btn {
        top: 10px;
        left: 10px;
        padding: 8px 15px;
        font-size: 0.9em;
    }

    .logout-btn {
        top: 10px;
        right: 10px;
        padding: 8px 15px;
        font-size: 0.9em;
    }

    .container {
        max-width: 100%;
        margin-top: 50px;
        /* Spazio extra per i pulsanti */
    }

    h1 {
        font-size: 1.8em;
    }

    .header {
        padding: 20px;
        margin-bottom: 20px;
    }

    .login-section {
        padding: 25px;
        margin-top: 60px;
        /* Spazio per non coprire i pulsanti */
    }

    .login-section h1 {
        font-size: 2em;
    }

    .upload-section {
        padding: 20px;
    }

    .file-input-label {
        padding: 12px 20px;
        font-size: 1em;
    }

    .instructions {
        padding: 15px;
    }

    .instructions h3 {
        font-size: 1em;
    }

    .instructions p {
        font-size: 0.9em;
    }

    .card-container {
        padding: 20px;
    }

    .flashcard {
        padding: 30px 20px;
        min-height: 250px;
    }

    .question {
        font-size: 1.2em;
        margin-bottom: 25px;
    }

    .answer-btn {
        padding: 15px;
        font-size: 1em;
    }

    .progress {
        font-size: 1em;
        margin-bottom: 20px;
    }

    .controls {
        flex-direction: column;
        gap: 10px;
    }

    .btn {
        width: 100%;
        padding: 12px 20px;
        font-size: 0.95em;
    }

    .stats {
        padding: 20px;
    }

    .stats h2 {
        font-size: 1.5em;
    }

    .success-rate {
        font-size: 1.8em;
    }

    .stat-item {
        font-size: 1em;
        padding: 12px;
    }
}

@media (max-width: 400px) {
    h1 {
        font-size: 1.5em;
    }

    .login-section h1 {
        font-size: 1.7em;
    }

    .flashcard {
        padding: 20px 15px;
        min-height: 220px;
    }

    .question {
        font-size: 1.1em;
    }

    .answer-btn {
        padding: 12px;
        font-size: 0.95em;
    }
}

/* =========================
   PROMPT BOX + COPIA (FIX)
   ========================= */

.instructions .prompt-box {
    position: relative;
    margin-top: 18px;
    padding: 14px;
    border-radius: 14px;
    background: #0f0f10;
    color: #f3f3f3;
    border: 1px solid rgba(0, 0, 0, 0.08);
    overflow: hidden;
    /* evita robe strane */
}

.instructions .prompt-title {
    font-weight: 700;
    margin-bottom: 10px;
    color: #ffffff;
}

.instructions .prompt-text {
    margin: 0;
    white-space: pre-wrap;
    word-break: break-word;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
    font-size: 13px;
    line-height: 1.45;
    padding-right: 84px;
    /* spazio extra per bottone */
    color: #f3f3f3;
    background: transparent;
    border: 0;
}

.instructions .copy-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    font-size: 12px;
    padding: 6px 10px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, .18);
    background: rgba(255, 255, 255, .10);
    color: #fff;
    cursor: pointer;
    transition: transform .15s, background .15s;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    outline: none;
}

.instructions .copy-btn:hover {
    background: rgba(255, 255, 255, .14);
    transform: translateY(-1px);
}

.instructions .copy-btn:active {
    transform: translateY(0);
}

.instructions .copy-toast {
    position: absolute;
    top: 12px;
    right: 78px;
    font-size: 12px;
    opacity: 0;
    transform: translateY(-2px);
    transition: .2s;
    color: #b7ffb7;
    pointer-events: none;
}

.instructions .copy-toast.show {
    opacity: 1;
    transform: translateY(0);
}

@media (max-width: 600px) {
    .instructions .prompt-text {
        font-size: 12px;
    }
}
