/* Global Styles - POLLY GLOP Theme */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Comic Sans MS', 'Arial Rounded MT Bold', 'Helvetica Rounded', sans-serif;
    background: linear-gradient(135deg, #87CEEB 0%, #98FB98 25%, #DDA0DD 50%, #F0E68C 75%, #FFB6C1 100%);
    min-height: 100vh;
    color: #2c3e50;
    line-height: 1.6;
    overflow-x: hidden;
}

.access-overlay {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 1200;
    padding: 20px;
}

.access-overlay.hidden {
    display: none;
}

.access-modal {
    background: #ffffff;
    border-radius: 18px;
    box-shadow: 0 18px 48px rgba(0, 0, 0, 0.25);
    max-width: 420px;
    width: 100%;
    padding: 32px 28px;
    text-align: center;
    position: relative;
}

.access-modal-header {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    margin-bottom: 16px;
}

.access-logo {
    width: 72px;
    height: auto;
}

.access-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 12px;
}

.access-form input[type="password"] {
    border: 2px solid #4ECDC4;
    border-radius: 12px;
    padding: 12px 16px;
    font-size: 1rem;
    text-align: center;
    outline: none;
    transition: box-shadow 0.2s ease, border-color 0.2s ease;
}

.access-form input[type="password"]:focus {
    border-color: #FF6B6B;
    box-shadow: 0 0 0 4px rgba(255, 107, 107, 0.25);
}

.access-help {
    font-size: 0.9rem;
    color: #546e7a;
}

.access-error {
    min-height: 1.4em;
    color: #c0392b;
    font-weight: bold;
}

.access-actions {
    display: flex;
    justify-content: center;
    margin-top: 8px;
}

.access-submit-btn {
    background: linear-gradient(135deg, #FF6B6B, #45B7D1);
    border: none;
    color: #fff;
    font-weight: bold;
    font-size: 1rem;
    padding: 12px 28px;
    border-radius: 999px;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.access-submit-btn:hover,
.access-submit-btn:focus-visible {
    transform: translateY(-2px);
    box-shadow: 0 12px 24px rgba(69, 183, 209, 0.35);
    outline: none;
}

.access-switch-btn {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 1100;
    background: rgba(255, 255, 255, 0.85);
    border: 2px solid #4ECDC4;
    color: #2c3e50;
    border-radius: 999px;
    padding: 10px 20px;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.access-switch-btn:hover,
.access-switch-btn:focus-visible {
    transform: translateY(-2px);
    box-shadow: 0 12px 24px rgba(78, 205, 196, 0.35);
    outline: none;
}

.access-switch-btn.hidden {
    display: none;
}

.restricted-control {
    opacity: 0.55 !important;
    pointer-events: none !important;
    filter: grayscale(40%);
}

.restricted-hidden {
    display: none !important;
}

.visually-hidden {
    position: absolute !important;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Animated background clouds */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle at 20% 80%, rgba(255,255,255,0.3) 20%, transparent 21%),
                radial-gradient(circle at 80% 20%, rgba(255,255,255,0.2) 15%, transparent 16%),
                radial-gradient(circle at 40% 40%, rgba(255,255,255,0.1) 25%, transparent 26%);
    z-index: -1;
}

/* Title Screen Styles */
.title-screen {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
    text-align: center;
}

.title-container {
    max-width: 600px;
    width: 100%;
}

.language-flags {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin-bottom: 20px;
}

.language-flag {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 24px;
    border-radius: 4px;
    border: 2px solid rgba(255, 255, 255, 0.7);
    background: rgba(255, 255, 255, 0.6);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease, background 0.2s ease;
    position: relative;
    overflow: hidden;
}

.flag-image {
    width: 28px;
    height: 20px;
    object-fit: cover;
    border-radius: 2px;
}

.flag-abbrev {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0,0,0,0.8);
    color: white;
    font-size: 0.6em;
    font-weight: bold;
    padding: 1px 2px;
    border-radius: 2px;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.language-flag:hover .flag-abbrev {
    opacity: 1;
}

.language-flag:hover,
.language-flag:focus-visible {
    transform: translateY(-3px);
    box-shadow: 0 8px 15px rgba(0, 0, 0, 0.25);
    outline: none;
}

.language-flag:active {
    transform: translateY(1px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.language-flag.active {
    background: #ffedc2;
    border-color: #FF6B6B;
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.25);
}

.site-footer {
    text-align: center;
    font-size: 0.65rem;
    color: rgba(44, 62, 80, 0.6);
    margin: 16px 0;
}

.logo-container {
    margin-bottom: 40px;
    animation: float 3s ease-in-out infinite;
}

.main-logo {
    max-width: 100%;
    width: 450px;
    height: auto;
    filter: drop-shadow(0 8px 16px rgba(0,0,0,0.2));
}

.title-actions {
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin-bottom: 24px;
}

.title-secondary-actions {
    display: flex;
    justify-content: center;
    margin-top: 8px;
}

.main-action-btn {
    background: linear-gradient(45deg, #FF6B6B, #4ECDC4, #45B7D1, #96CEB4, #FFEAA7);
    background-size: 300% 300%;
    color: white;
    border: none;
    padding: 20px 40px;
    font-size: 28px;
    font-weight: bold;
    border-radius: 50px;
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 2px;
    box-shadow: 0 8px 25px rgba(0,0,0,0.2);
    transition: all 0.3s ease;
    animation: rainbow-shift 3s ease-in-out infinite;
    width: 100%;
}

.main-action-btn:hover {
    transform: translateY(-5px) scale(1.05);
    box-shadow: 0 15px 35px rgba(0,0,0,0.3);
    animation-duration: 1s;
}

.main-action-btn[disabled],
.main-action-btn[aria-disabled="true"] {
    background: linear-gradient(135deg, #d7d7d7, #b5b5b5);
    color: rgba(44, 62, 80, 0.6);
    box-shadow: none;
    cursor: not-allowed;
    animation: none;
    transform: none;
}

.secondary-action-btn {
    background: rgba(255,255,255,0.9);
    color: #666;
    border: 3px solid #ddd;
    padding: 12px 30px;
    font-size: 18px;
    font-weight: bold;
    border-radius: 30px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.secondary-action-btn:hover {
    background: white;
    border-color: #FF6B6B;
    color: #FF6B6B;
    transform: translateY(-2px);
}

/* Story Creation Screen */
.story-creation-screen {
    min-height: 100vh;
    padding: 20px;
}

.story-creation-screen.hidden {
    display: none;
}

.story-results {
    max-width: 1100px;
    margin: 0 auto;
    padding: 20px;
}

.story-results.hidden {
    display: none;
}

.neverending-container .neverending-header {
    text-align: center;
    margin-bottom: 24px;
}

.neverending-container #neverendingTitle {
    font-size: 2.2rem;
    color: #ff6b6b;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 8px;
}

.neverending-container #neverendingSubtitle {
    font-size: 1.1rem;
    color: rgba(44, 62, 80, 0.85);
}

.neverending-controls {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 16px;
    margin-top: 10px;
}

.neverending-status {
    margin-top: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    text-align: center;
    font-weight: 600;
    min-height: 32px;
    color: #2c3e50;
}

.neverending-status.loading {
    color: #1b6ca8;
}

.neverending-status-text {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.neverending-spinner {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 3px solid rgba(30, 108, 168, 0.25);
    border-top-color: #1b6ca8;
    animation: neverending-spin 0.8s linear infinite;
}

@keyframes neverending-spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

.neverending-status.error {
    color: #c0392b;
}

.neverending-status.success {
    color: #1e8449;
}

.neverending-loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 32, 50, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    z-index: 2000;
    transition: opacity 0.2s ease;
}

.neverending-loading-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.neverending-loading-content {
    background: #ffffff;
    border-radius: 16px;
    padding: 28px 36px;
    box-shadow: 0 18px 40px rgba(10, 31, 68, 0.25);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 18px;
    min-width: 260px;
    max-width: min(90vw, 360px);
    text-align: center;
    color: #1b6ca8;
    font-weight: 600;
}

.neverending-loading-spinner {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: 5px solid rgba(27, 108, 168, 0.2);
    border-top-color: #1b6ca8;
    animation: neverending-spin 0.8s linear infinite;
}

.neverending-loading-message {
    font-size: 1.05rem;
    letter-spacing: 0.12em;
}

.neverending-loading-bar {
    position: relative;
    width: 220px;
    max-width: 100%;
    height: 6px;
    background: rgba(27, 108, 168, 0.15);
    border-radius: 999px;
    overflow: hidden;
}

.neverending-loading-bar-fill {
    position: absolute;
    inset: 0;
    width: 35%;
    background: linear-gradient(90deg, #1b6ca8, #3aaad6);
    border-radius: inherit;
    transform: translateX(-100%);
}

.neverending-loading-bar-fill.animate {
    animation: neverending-loading-progress 1.4s ease-in-out infinite;
}

@keyframes neverending-loading-progress {
    0% {
        transform: translateX(-100%);
    }
    50% {
        transform: translateX(40%);
    }
    100% {
        transform: translateX(220%);
    }
}

.neverending-output {
    margin-top: 24px;
    background: rgba(255, 255, 255, 0.92);
    border-radius: 24px;
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.12);
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.neverending-output.empty {
    display: block;
    padding: 24px;
}

.neverending-chapter {
    border-radius: 18px;
    padding: 20px;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.96), rgba(255, 255, 255, 0.86));
    box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.6);
}

.neverending-chapter-title {
    font-size: 1.4rem;
    color: #ff6b6b;
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.neverending-chapter-text {
    display: flex;
    flex-direction: column;
    gap: 12px;
    color: rgba(44, 62, 80, 0.92);
}

.neverending-chapter-text p {
    margin: 0;
}

/* Green selection state for clicked choice buttons */
.neverending-choice-btn.selected {
    background-color: #28a745 !important;
    color: white !important;
    border-color: #1e7e34 !important;
}

.neverending-choice-note {
    margin-top: 12px;
    text-align: center;
    font-weight: 600;
    color: #2c3e50;
}

.neverending-choices {
    margin-top: 24px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.neverending-choice-btn {
    background: linear-gradient(135deg, #45b7d1, #4ecdc4);
    color: #ffffff;
    border: none;
    border-radius: 14px;
    padding: 14px 22px;
    font-size: 1rem;
    font-weight: 700;
    text-align: left;
    cursor: pointer;
    box-shadow: 0 8px 18px rgba(0, 0, 0, 0.12);
    transition: transform 0.2s ease, box-shadow 0.2s ease, filter 0.2s ease;
    position: relative;
    width: 100%;
}

.neverending-choice-btn:hover:not([disabled]),
.neverending-choice-btn:focus-visible:not([disabled]) {
    transform: translateY(-3px);
    box-shadow: 0 14px 28px rgba(0, 0, 0, 0.18);
    outline: none;
}

.neverending-choice-btn[disabled] {
    cursor: wait;
    filter: grayscale(0.3);
    opacity: 0.7;
}

.neverending-choice-label {
    font-size: 1.05rem;
    margin-bottom: 8px;
}

.neverending-choice-summary {
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.85);
}


.neverending-empty-state {
    text-align: center;
    font-size: 1rem;
    color: rgba(44, 62, 80, 0.8);
    margin-top: 24px;
}

.container {
    max-width: 900px;
    margin: 0 auto;
    background: rgba(255,255,255,0.95);
    padding: 30px;
    border-radius: 25px;
    box-shadow: 0 15px 35px rgba(0,0,0,0.1);
    backdrop-filter: blur(10px);
}

.header-section {
    text-align: center;
    margin-bottom: 30px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    align-items: center;
}

.header-logo {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 10px 0;
}

.story-logo {
    width: 220px;
    max-width: 100%;
    height: auto;
    filter: drop-shadow(0 6px 12px rgba(0,0,0,0.15));
}

.header-row {
    width: 100%;
    display: flex;
    justify-content: flex-start;
}

.back-btn {
    position: static;
    background: #FF6B6B;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 16px;
    transition: all 0.3s ease;
}

.back-btn:hover {
    background: #FF5252;
    transform: translateX(-5px);
}

/* Typography */
h1 {
    font-size: 3em;
    background: linear-gradient(45deg, #FF6B6B, #4ECDC4, #45B7D1, #96CEB4);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.1);
}

.about-screen {
    min-height: 100vh;
    padding: 20px;
}

.about-screen.hidden {
    display: none;
}

.about-container {
    display: flex;
    flex-direction: column;
    gap: 30px;
}

.about-header {
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 15px;
    align-items: center;
}

.about-logo {
    width: 260px;
    max-width: 100%;
    height: auto;
    filter: drop-shadow(0 8px 18px rgba(0,0,0,0.2));
}

.about-title {
    font-size: 2.6em;
}

.about-subtitle {
    font-size: 1.2em;
    color: #555;
    max-width: 600px;
}

.about-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
}

.about-card {
    background: rgba(255,255,255,0.95);
    border-radius: 20px;
    padding: 25px;
    box-shadow: 0 12px 28px rgba(0,0,0,0.12);
    display: flex;
    flex-direction: column;
    gap: 12px;
    text-align: left;
}

.about-card h2 {
    margin-bottom: 10px;
}

.about-card p {
    color: #444;
    font-size: 1em;
}

.about-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 10px;
    color: #444;
    font-size: 1em;
}

.about-list li::before {
    content: '✨';
    margin-right: 8px;
}

.subtitle {
    color: #666;
    font-size: 1.2em;
    margin-bottom: 30px;
}

h2 {
    color: #4ECDC4;
    margin-bottom: 20px;
    font-size: 1.4em;
    text-align: center;
}

h3 {
    color: #FF6B6B;
    margin: 30px 0 20px 0;
    font-size: 1.2em;
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 1px;
    border-top: 2px solid #FF6B6B;
    padding-top: 15px;
}

/* Tabs */
.tabs {
    display: flex;
    margin-bottom: 30px;
    background: rgba(255,255,255,0.8);
    border-radius: 15px;
    padding: 5px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
}

.tab-button {
    flex: 1;
    background: transparent;
    border: none;
    padding: 15px 25px;
    cursor: pointer;
    font-size: 1em;
    color: #666;
    border-radius: 10px;
    transition: all 0.3s ease;
    font-weight: bold;
}

.tab-button:hover {
    background: rgba(78, 205, 196, 0.1);
    color: #4ECDC4;
}

.tab-button.active {
    background: linear-gradient(45deg, #4ECDC4, #45B7D1);
    color: white;
    box-shadow: 0 5px 15px rgba(0,0,0,0.2);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* Panel Layout */
.panel-grid {
    display: grid;
    gap: 25px;
    margin-bottom: 30px;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

.panel-card {
    background: rgba(255,255,255,0.85);
    border-radius: 22px;
    padding: 25px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.08);
    border: 3px solid rgba(255,255,255,0.5);
    backdrop-filter: blur(6px);
    transition: transform 0.35s ease, box-shadow 0.35s ease, border-color 0.35s ease;
}

.panel-card:hover,
.panel-card:focus-within {
    transform: translateY(-6px);
    box-shadow: 0 18px 36px rgba(0,0,0,0.16);
    border-color: rgba(255,255,255,0.85);
}

.panel-card h2 {
    margin-top: 0;
    margin-bottom: 18px;
}

.panel-card.action-card {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 180px;
    text-align: center;
}

.input-grid {
    display: grid;
    gap: 18px;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.teacher-grade-grid {
    margin-bottom: 10px;
}

.teacher-grade-grid .input-group {
    margin-bottom: 0;
}

.locked-grade-grid .input-group {
    position: relative;
}

.locked-value {
    display: inline-flex;
    align-items: center;
    min-height: 48px;
    padding: 12px 16px;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.85);
    border: 2px dashed rgba(69, 183, 209, 0.6);
    font-weight: bold;
    font-size: 1.05rem;
    color: #2c3e50;
}

/* Sections */
.section {
    margin-bottom: 25px;
    padding: 25px;
    background: rgba(255,255,255,0.7);
    border-radius: 20px;
    border: 3px solid transparent;
    background-clip: padding-box;
    box-shadow: 0 8px 25px rgba(0,0,0,0.08);
}

/* Input Groups */
.input-group {
    margin-bottom: 20px;
}

.input-group.disabled label,
.input-group.disabled small {
    color: #95a5a6;
}

.input-group.disabled select {
    background-color: #f5f7fa;
    border-color: #d5d8dc;
    color: #95a5a6;
}

.input-group.with-dice label {
    margin-bottom: 0;
}

.label-with-icons {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.icon-group {
    display: flex;
    gap: 8px;
    align-items: center;
}

.input-group.with-dice select {
    width: 100%;
    margin-bottom: 0;
}

.manual-entry-btn {
    background: #ffb703;
    border: none;
    color: #fff;
    font-size: 18px;
    line-height: 1;
    padding: 10px 12px;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0,0,0,0.12);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.manual-entry-btn:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 16px rgba(0,0,0,0.18);
}

.dice-btn {
    background: #4ECDC4;
    border: none;
    color: #fff;
    font-size: 22px;
    line-height: 1;
    padding: 10px 14px;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.dice-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 16px rgba(0,0,0,0.2);
}

label {
    display: block;
    margin-bottom: 8px;
    font-weight: bold;
    color: #2c3e50;
    font-size: 1.1em;
}

/* Input and Select Styling */
input[type="text"],
input[type="number"],
input[type="range"],
select,
textarea {
    width: 100%;
    padding: 15px;
    font-size: 16px;
    border: 3px solid #e0e0e0;
    border-radius: 15px;
    background: white;
    transition: all 0.3s ease;
    font-family: inherit;
    resize: vertical;
    outline: none;
}

.input-group.missing-field label {
    color: #e63946;
}

.input-group.missing-field input,
.input-group.missing-field select,
.input-group.missing-field textarea {
    border-color: #e63946;
    box-shadow: 0 0 0 3px rgba(230, 57, 70, 0.2);
}

.input-group.missing-flash input,
.input-group.missing-flash select,
.input-group.missing-flash textarea {
    animation: missingFieldPulse 0.9s ease-in-out;
}

@keyframes missingFieldPulse {
    0% {
        box-shadow: 0 0 0 0 rgba(230, 57, 70, 0.45);
    }
    60% {
        box-shadow: 0 0 0 6px rgba(230, 57, 70, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(230, 57, 70, 0);
    }
}

@media (prefers-reduced-motion: reduce) {
    .input-group.missing-flash input,
    .input-group.missing-flash select,
    .input-group.missing-flash textarea {
        animation: none;
    }
}

.missing-indicator {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: #e63946;
    font-weight: 600;
    font-size: 0.95em;
    margin-top: 8px;
}

.missing-indicator::before {
    content: '⚠️';
    font-size: 1.05em;
}

textarea {
    min-height: 80px;
    line-height: 1.4;
}

input[type="text"]:focus-visible,
input[type="number"]:focus-visible,
input[type="range"]:focus-visible,
select:focus-visible,
textarea:focus-visible {
    border-color: rgba(78, 205, 196, 0.75);
    box-shadow: 0 0 0 4px rgba(78, 205, 196, 0.18), 0 12px 25px rgba(69, 183, 209, 0.18);
    transform: translateY(-1px);
}

/* Checkbox Styling */
.checkbox-label {
    display: flex;
    align-items: center;
    cursor: pointer;
    margin-bottom: 8px;
}

.manual-entry-feedback {
    margin-top: 8px;
    font-size: 0.95rem;
    min-height: 1.2em;
    color: #2c3e50;
}

.manual-entry-feedback.success {
    color: #1b9c85;
}

.manual-entry-feedback.error {
    color: #c0392b;
}

.manual-entry-feedback.info {
    color: #2c3e50;
}

.restriction-message {
    margin-bottom: 16px;
    padding: 12px 16px;
    border-left: 4px solid #c0392b;
    border-radius: 12px;
    background: rgba(192, 57, 43, 0.1);
    color: #c0392b;
    font-weight: 600;
    box-shadow: 0 10px 22px rgba(192, 57, 43, 0.12);
}

.restriction-message.hidden {
    display: none;
}

.checkbox-label input[type="checkbox"] {
    width: auto;
    margin-right: 10px;
    transform: scale(1.2);
}

.checkbox-label span {
    font-weight: bold;
    color: #2c3e50;
    font-size: 1.1em;
}

/* Teacher Section Styling */
.teacher-section {
    margin-top: 30px;
    padding: 25px;
    background: linear-gradient(135deg, #fff9e6, #f0f7ff);
    border-radius: 20px;
    border: 3px solid #4ECDC4;
    box-shadow: 0 8px 25px rgba(0,0,0,0.1);
}

.teacher-section h3 {
    color: #4ECDC4;
    margin: 0 0 20px 0;
    font-size: 1.4em;
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.teacher-section h4 {
    color: #2c3e50;
    margin: 0 0 15px 0;
    font-size: 1.2em;
    border-bottom: 2px solid #4ECDC4;
    padding-bottom: 10px;
}

.questions-list {
    list-style: decimal;
    padding-left: 20px;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.question-item {
    background: rgba(255, 255, 255, 0.85);
    border-radius: 15px;
    border: 2px dashed #4ECDC4;
    padding: 15px;
}

.question-text {
    font-weight: bold;
    color: #2c3e50;
    margin-bottom: 6px;
}

.answer-text {
    color: #34495e;
    font-style: italic;
    margin-left: 5px;
    display: flex;
    gap: 6px;
    align-items: baseline;
}

.answer-label {
    font-weight: bold;
    font-style: normal;
}

.answer-value {
    flex: 1;
}

.comprehension-content {
    background: white;
    padding: 20px;
    border-radius: 15px;
    border: 2px solid #e0e0e0;
}

.questions-text {
    font-family: inherit;
    font-size: 1em;
    line-height: 1.6;
    white-space: pre-wrap;
    margin: 0;
    color: #2c3e50;
}

input[type="text"]:focus:not(:focus-visible),
input[type="number"]:focus:not(:focus-visible),
select:focus:not(:focus-visible),
textarea:focus:not(:focus-visible) {
    border-color: rgba(78, 205, 196, 0.6);
    box-shadow: 0 6px 18px rgba(78, 205, 196, 0.18);
    transform: translateY(-1px);
}

small {
    color: #666;
    font-size: 0.9em;
    display: block;
    margin-top: 5px;
}

.tooltip-help {
    background: linear-gradient(45deg, #FFE0B3, #FFF3CD);
    border: 2px solid #FFD93D;
    border-radius: 10px;
    padding: 8px 12px;
    margin-top: 8px;
    font-weight: 500;
    color: #856404;
}

/* Generate Buttons */
.generate-btn {
    width: 100%;
    padding: 20px;
    font-size: 20px;
    font-weight: bold;
    background: linear-gradient(45deg, #FF6B6B, #4ECDC4, #45B7D1, #96CEB4);
    background-size: 300% 300%;
    color: white;
    border: none;
    border-radius: 25px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 1px;
    box-shadow: 0 8px 25px rgba(0,0,0,0.2);
    animation: rainbow-shift 3s ease-in-out infinite;
    position: relative;
}

.generate-btn::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(120deg, rgba(255, 255, 255, 0.35), rgba(255, 255, 255, 0));
    opacity: 0;
    transition: opacity 0.4s ease;
    pointer-events: none;
}

.generate-btn:hover:not(:disabled) {
    transform: translateY(-3px) scale(1.02);
    box-shadow: 0 15px 35px rgba(0,0,0,0.3);
    animation-duration: 1s;
}

.generate-btn:hover:not(:disabled)::after,
.generate-btn:focus-visible::after {
    opacity: 1;
}

.generate-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
    animation: none;
}

.pressable-control {
    position: relative;
    overflow: hidden;
    transform: translateZ(0);
    transition: transform 0.2s ease, box-shadow 0.25s ease, filter 0.25s ease;
    outline: none;
}

.pressable-control:focus-visible {
    outline: 3px solid rgba(255, 255, 255, 0.85);
    outline-offset: 3px;
}

.pressable-control.is-pressed {
    transform: translateY(2px) scale(0.97);
    filter: brightness(0.97);
}

.pressable-ripple {
    position: absolute;
    border-radius: 50%;
    transform: scale(0);
    background: rgba(255, 255, 255, 0.5);
    opacity: 0.75;
    pointer-events: none;
    animation: pressable-ripple 620ms ease-out;
}

@keyframes pressable-ripple {
    to {
        transform: scale(1.6);
        opacity: 0;
    }
}

/* Story Output */
.story-output {
    margin-top: 30px;
    padding: 30px;
    border-radius: 20px;
    font-size: 18px;
    line-height: 1.8;
    white-space: normal;
    min-height: 60px;
    border: 3px solid transparent;
    font-family: 'Georgia', serif;
}

.story-output.loading {
    background: linear-gradient(45deg, #FFF3CD, #FFEAA7);
    border-color: #FFD93D;
    color: #856404;
    text-align: center;
    font-style: italic;
}

.story-output.success {
    background: linear-gradient(45deg, #D4EDDA, #98FB98);
    border-color: #4ECDC4;
    color: #155724;
}

.story-output .story-text {
    display: flex;
    flex-direction: column;
    gap: 1em;
}

.story-output .story-paragraph {
    margin: 0;
}

.glossary-section {
    margin-top: 28px;
    padding: 20px 24px;
    background: rgba(255, 255, 255, 0.78);
    border: 3px solid rgba(78, 205, 196, 0.5);
    border-radius: 18px;
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.08);
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.glossary-title {
    font-size: 1.4rem;
    color: #0b6b3c;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.glossary-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.glossary-list-item {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: baseline;
    background: rgba(78, 205, 196, 0.08);
    border: 1px dashed rgba(78, 205, 196, 0.4);
    border-radius: 14px;
    padding: 10px 14px;
}

.glossary-list-term {
    font-weight: 700;
    color: #0b6b3c;
    font-size: 1.05rem;
}

.glossary-list-translation {
    color: #155724;
    font-weight: 500;
    flex: 1 1 200px;
    position: relative;
    padding-left: 120px;
}

.glossary-list-translation::before {
    content: attr(data-label) ' : ';
    position: absolute;
    left: 0;
    top: 0;
    color: #e07a5f;
    font-weight: 700;
    white-space: nowrap;
    width: 110px;
}

.glossary-term {
    position: relative;
    cursor: help;
    border-bottom: 2px dotted rgba(21, 87, 36, 0.6);
    font-weight: 600;
    color: inherit;
    outline: none;
}

.glossary-term:hover,
.glossary-term:focus {
    color: #0b6b3c;
}

.glossary-term:focus-visible {
    outline: 2px solid #4ECDC4;
    outline-offset: 2px;
}

.glossary-tooltip {
    position: absolute;
    left: 50%;
    bottom: 100%;
    transform: translate(-50%, -0.25rem);
    background: #ffffff;
    color: #155724;
    padding: 6px 10px;
    border-radius: 10px;
    box-shadow: 0 8px 16px rgba(17, 138, 178, 0.25);
    border: 2px solid #4ECDC4;
    font-size: 0.85em;
    line-height: 1.25;
    white-space: normal;
    min-width: 140px;
    max-width: 260px;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s ease, transform 0.2s ease;
    z-index: 10;
}

.glossary-term:hover .glossary-tooltip,
.glossary-term:focus .glossary-tooltip {
    opacity: 1;
    transform: translate(-50%, -0.75rem);
}

.story-comprehension-block {
    margin-top: 30px;
    padding-top: 20px;
    border-top: 2px dashed rgba(21, 87, 36, 0.4);
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.story-questions-title {
    font-size: 1.1em;
    color: #0b6b3c;
    text-transform: uppercase;
    letter-spacing: 1px;
    text-align: center;
}

.story-questions-list,
.story-answers-list {
    padding-left: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.story-question-item,
.story-answer-item {
    margin-left: 0;
}

.story-spoiler-title {
    font-weight: bold;
    text-align: center;
    color: #c0392b;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.story-output.error {
    background: linear-gradient(45deg, #F8D7DA, #FFB6C1);
    border-color: #FF6B6B;
    color: #721c24;
    text-align: center;
}


/* Range Input Styling */
input[type="range"] {
    height: 8px;
    border-radius: 5px;
    background: linear-gradient(to right, #FF6B6B, #4ECDC4, #45B7D1);
    outline: none;
}

input[type="range"]::-webkit-slider-thumb {
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: white;
    cursor: pointer;
    border: 3px solid #4ECDC4;
    box-shadow: 0 2px 6px rgba(0,0,0,0.3);
}

input[type="range"]::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: white;
    cursor: pointer;
    border: 3px solid #4ECDC4;
    box-shadow: 0 2px 6px rgba(0,0,0,0.3);
}

/* Animations */
@keyframes float {
    0%, 100% { transform: translateY(0px); }
    50% { transform: translateY(-20px); }
}

@keyframes rainbow-shift {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

@keyframes bounce {
    0%, 20%, 50%, 80%, 100% { transform: translateY(0); }
    40% { transform: translateY(-10px); }
    60% { transform: translateY(-5px); }
}

.generate-btn:active {
    animation: bounce 0.6s;
}

@media (prefers-reduced-motion: reduce) {
    .panel-card,
    .pressable-control,
    .generate-btn,
    .language-flag {
        transition-duration: 0.01ms !important;
    }

    .pressable-ripple {
        animation-duration: 0.01ms !important;
    }
}

/* Responsive Design */
@media (max-width: 768px) {
    .main-logo {
        width: 300px;
    }
    
    .main-action-btn {
        font-size: 22px;
        padding: 18px 35px;
    }
    
    .container {
        padding: 20px;
        margin: 10px;
    }
    
    h1 {
        font-size: 2.2em;
    }
    
    .tabs {
        flex-direction: column;
    }
    
    .tab-button {
        margin-bottom: 5px;
    }
    
    .back-btn {
        position: static;
        margin-bottom: 20px;
    }
}

@media (max-width: 480px) {
    .main-logo {
        width: 250px;
    }
    
    .main-action-btn {
        font-size: 18px;
        padding: 15px 30px;
    }
    
    .generate-btn {
        font-size: 16px;
        padding: 15px;
    }
    
    input[type="text"],
    select {
        font-size: 16px;
    }

    .story-logo {
        width: 180px;
    }

    .about-logo {
        width: 200px;
    }

    .about-grid {
        grid-template-columns: 1fr;
    }
}

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

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

.manual-entry-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 200;
}

.manual-entry-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 210;
    background: #ffffff;
    border-radius: 22px;
    box-shadow: 0 18px 40px rgba(0, 0, 0, 0.2);
    width: min(420px, 90vw);
}

.manual-entry-content {
    padding: 28px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.manual-entry-content h3 {
    margin: 0;
    font-size: 1.4rem;
    color: #2c3e50;
}

.manual-entry-content p {
    margin: 0;
    font-size: 1rem;
    color: #4a4a4a;
}

.manual-entry-error {
    min-height: 1.2em;
    color: #c0392b;
    font-size: 0.95rem;
}

.manual-entry-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

.manual-entry-cancel,
.manual-entry-submit {
    border: none;
    border-radius: 14px;
    padding: 10px 18px;
    font-size: 1rem;
    cursor: pointer;
    font-weight: 600;
}

.manual-entry-cancel {
    background: #f1f1f1;
    color: #2c3e50;
}

.manual-entry-cancel:hover {
    background: #e2e2e2;
}

.manual-entry-submit {
    background: #4ECDC4;
    color: #ffffff;
    box-shadow: 0 6px 18px rgba(78, 205, 196, 0.4);
}

.manual-entry-submit:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.manual-entry-submit:hover:not(:disabled) {
    background: #3db5ac;
}

.teacher-access-card {
    margin-top: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.teacher-access-card h3 {
    margin: 0;
    font-size: 1.1rem;
    color: #1f2a44;
}

.teacher-access-card p {
    margin: 0;
    color: #4a4a4a;
    font-size: 0.95rem;
}

.access-code-status {
    min-height: 1.2em;
    font-size: 0.95rem;
    color: #1f2a44;
}

.access-code-status.error {
    color: #c0392b;
}

.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(17, 24, 39, 0.45);
    z-index: 420;
}

.access-code-modal {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 430;
}

.access-code-modal__content {
    background: #ffffff;
    border-radius: 24px;
    padding: 28px;
    width: min(420px, 90vw);
    box-shadow: 0 20px 45px rgba(17, 24, 39, 0.25);
    display: flex;
    flex-direction: column;
    gap: 18px;
    text-align: center;
}

.access-code-modal__content h2 {
    margin: 0;
    font-size: 1.5rem;
    color: #1f2a44;
}

.access-code-modal__content p {
    margin: 0;
    color: #4a4a4a;
}

.access-code-modal__value {
    font-size: 2.2rem;
    font-weight: 700;
    letter-spacing: 0.18em;
    color: #4ECDC4;
    font-family: 'Fira Mono', 'Courier New', monospace;
    word-break: break-word;
}

.access-code-modal__error {
    min-height: 1.2em;
    color: #c0392b;
    font-size: 0.95rem;
}

.access-code-modal__actions {
    display: flex;
    justify-content: center;
    gap: 12px;
}
