#pnr-reading-app {
    max-width: 800px;
    margin: 0 auto;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #f9f9f9;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
}

.pnr-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 2px solid #eee;
}

/* Section Selector Styling */
.pnr-sections {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    margin-bottom: 25px;
    background: #fff;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    border: 1px solid #eee;
}

.pnr-sections label {
    font-weight: 700;
    color: #555;
    font-size: 0.95em;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 5px;
}

#pnr-section-selector {
    flex-grow: 1;
    padding: 12px 15px;
    font-size: 1em;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    background-color: #f8f9fa;
    color: #333;
    cursor: pointer;
    transition: all 0.3s ease;
    outline: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22292.4%22%20height%3D%22292.4%22%3E%3Cpath%20fill%3D%22%230073aa%22%20d%3D%22M287%2069.4a17.6%2017.6%200%200%200-13-5.4H18.4c-5%200-9.3%201.8-12.9%205.4A17.6%2017.6%200%200%200%200%2082.2c0%205%201.8%209.3%205.4%2012.9l128%20127.9c3.6%203.6%207.8%205.4%2012.8%205.4s9.2-1.8%2012.8-5.4L287%2095c3.5-3.5%205.4-7.8%205.4-12.8%200-5-1.9-9.2-5.5-12.8z%22%2F%3E%3C%2Fsvg%3E");
    background-repeat: no-repeat;
    background-position: right 15px top 50%;
    background-size: 12px auto;
}

#pnr-section-selector:hover {
    border-color: #b0b0b0;
    background-color: #fff;
}

#pnr-section-selector:focus {
    border-color: #0073aa;
    background-color: #fff;
    box-shadow: 0 0 0 3px rgba(0, 115, 170, 0.1);
}

.pnr-card {
    background: white;
    padding: 40px;
    text-align: center;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}

#pnr-content-text {
    font-size: 2em;
    color: #333;
    margin-bottom: 30px;
    line-height: 1.5; /* Added for better readability of wrapped words */
}

/* Word Highlighting Styles */
.pnr-word {
    padding: 2px 5px;
    border-radius: 4px;
    transition: background-color 0.2s;
}

.pnr-word-correct {
    background-color: #d4edda;
    color: #155724;
}

.pnr-word-wrong {
    background-color: #f8d7da;
    color: #721c24;
}

.pnr-controls {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-bottom: 20px;
}

.pnr-btn {
    padding: 12px 24px;
    border: none;
    border-radius: 5px;
    font-size: 16px;
    cursor: pointer;
    transition: background 0.3s;
}

.pnr-btn.primary {
    background: #d63638;
    color: white;
}

.pnr-btn.secondary {
    background: #2271b1;
    color: white;
}

.pnr-btn.success {
    background: #00a32a;
    color: white;
}

.pnr-btn.recording {
    background: #ff0000;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

.pnr-status {
    margin-top: 10px;
    color: #666;
    font-style: italic;
}

.pnr-result-box {
    margin-top: 30px;
    border-top: 1px solid #eee;
    padding-top: 20px;
    text-align: left;
}

.pnr-loading {
    text-align: center;
    padding: 40px;
    color: #666;
}

.pnr-error {
    color: red;
    text-align: center;
    padding: 20px;
}

/* Badge System Styles */
.pnr-badge-popup {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    animation: fadeIn 0.3s;
}

.pnr-badge-content {
    background: white;
    padding: 30px;
    border-radius: 15px;
    text-align: center;
    max-width: 400px;
    width: 90%;
    animation: bounceIn 0.6s;
    position: relative;
}

.pnr-badge-close {
    position: absolute;
    top: 10px;
    right: 15px;
    font-size: 24px;
    cursor: pointer;
    color: #999;
}

.pnr-badge-title {
    font-size: 24px;
    margin: 10px 0;
    color: #333;
}

.pnr-badge-icon {
    font-size: 60px;
    margin: 15px 0;
    display: block;
}

.pnr-badge-message {
    font-size: 16px;
    color: #666;
    margin-bottom: 20px;
}

/* Badge Colors */
.badge-beginner { color: #2ecc71; border: 2px solid #2ecc71; }
.badge-improving { color: #3498db; border: 2px solid #3498db; }
.badge-confident { color: #f1c40f; border: 2px solid #f1c40f; }
.badge-advanced { color: #e74c3c; border: 2px solid #e74c3c; }
.badge-master { color: #9b59b6; border: 2px solid #9b59b6; }
.badge-story { color: #e67e22; border: 2px solid #e67e22; }
.badge-resilience { color: #ff69b4; border: 2px solid #ff69b4; }
.badge-streak { color: #ff4500; border: 2px solid #ff4500; }

.pnr-badge-card {
    display: inline-block;
    padding: 10px;
    border-radius: 10px;
    margin: 5px;
    background: #fff;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes bounceIn {
    0% { transform: scale(0.3); opacity: 0; }
    50% { transform: scale(1.05); opacity: 1; }
    70% { transform: scale(0.9); }
    100% { transform: scale(1); }
}

/* --- Responsive / Mobile Optimizations --- */
@media only screen and (max-width: 768px) {
    #pnr-reading-app {
        padding: 10px;
        border-radius: 5px;
    }

    .pnr-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .pnr-sections {
        padding: 15px;
    }
    
    .pnr-card {
        padding: 20px 15px; /* Reduced padding for mobile */
    }

    #pnr-content-text {
        font-size: 1.3em; /* Significantly reduced from 2em */
        line-height: 1.6;
        margin-bottom: 20px;
    }

    .pnr-word {
        padding: 1px 3px; /* Slightly tighter highlighting */
    }

    .pnr-controls {
        flex-direction: column; /* Stack buttons on very small screens if needed, but row is usually better if they fit. Let's keep row but smaller gap. */
        flex-direction: row; 
        gap: 10px;
    }

    .pnr-btn {
        padding: 10px 16px; /* Smaller buttons */
        font-size: 14px;
        flex: 1; /* Make buttons equal width */
        display: flex;
        justify-content: center;
        align-items: center;
    }
}

/* Extra small devices (phones, 480px and down) */
@media only screen and (max-width: 480px) {
    #pnr-content-text {
        font-size: 1.2em; /* Even smaller for portrait phones */
    }

    .pnr-card {
        padding: 15px 10px;
    }
    
    .pnr-controls {
        flex-direction: row; /* Keep side by side unless labels are very long */
        flex-wrap: wrap;
    }
    
    .pnr-btn {
        width: 100%; /* If wrapping, take full width */
        margin-bottom: 5px;
    }
    
    /* Force row layout for top controls if they exist to save vertical space */
    .pnr-top-controls .pnr-btn {
        width: auto;
        flex: 1;
        margin-bottom: 0;
    }
}