/* ============================================
   L.I.F.E.AI - Styles
   Dark & Light (Paper) Themes
============================================ */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* Dark Theme - Photographic Gray + Pale Yellow (CLI Code inspired) */
    --bg-primary: #1e1e1e;
    --bg-secondary: #2d2d2d;
    --text-primary: #f4e8c1;
    --text-secondary: #a89968;
    --accent: #f4e8c1;
    --accent-hover: #fff5d6;
    --border: #3d3d3d;
    --shadow: rgba(0, 0, 0, 0.4);
    --btn-bg: transparent;
    --btn-hover: #3d3d3d;
}

.light-theme {
    /* Light Theme - Warm Paper Color */
    --bg-primary: #f9f3e3;
    --bg-secondary: #f4ecd8;
    --text-primary: #2b2419;
    --text-secondary: #6b5d4f;
    --accent: #8b6914;
    --accent-hover: #6b5210;
    --border: #d4c4a8;
    --shadow: rgba(107, 93, 79, 0.12);
    --btn-bg: transparent;
    --btn-hover: #ebe3d0;
}

.theme-dark-green {
    /* Dark Green Theme - Dark background with green text */
    --bg-primary: #0f1c14;
    --bg-secondary: #1a2d20;
    --text-primary: #50c878; /* Emerald green */
    --text-secondary: #3aa56a;
    --accent: #50c878;
    --accent-hover: #64e08c;
    --border: #2d4d33;
    --shadow: rgba(0, 0, 0, 0.4);
    --btn-bg: transparent;
    --btn-hover: #2d4d33;
}

.theme-purple-terminal {
    /* Purple Terminal Theme - Darker photographic gray background with brighter yellow text */
    --bg-primary: #1e1e1e; /* Darker photographic gray */
    --bg-secondary: #2d2d2d; /* Slightly lighter gray for secondary areas */
    --text-primary: #ffd700; /* Bright yellow text */
    --text-secondary: #daa520; /* Golden yellow for secondary text */
    --accent: #ffcc00; /* Brighter yellow accent */
    --accent-hover: #ffeb3b; /* Even brighter yellow for hover */
    --border: #444466; /* Pale purple border (narcissus-inspired) */
    --shadow: rgba(139, 0, 255, 0.2); /* Purple shadow */
    --btn-bg: transparent;
    --btn-hover: #3a3a4a;
}

/* Green theme - Light yellow background with dark green text */
.theme-green-terminal {
    /* Light yellow background with dark green text */
    --bg-primary: #f5f5dc; /* Light yellow background (like parchment) */
    --bg-secondary: #e5e5cc; /* Slightly darker yellow */
    --text-primary: #006400; /* Dark green text */
    --text-secondary: #2e8b57; /* Sea green for secondary text */
    --accent: #228b22; /* Forest green for accents */
    --accent-hover: #3cb371; /* Medium sea green for hover */
    --border: #d4d4a7; /* Yellowish border */
    --shadow: rgba(0, 100, 0, 0.1); /* Dark green shadow */
    --btn-bg: transparent;
    --btn-hover: #e0e0b8;
}

/* Additional styling for story text */
.light-theme .story-text {
    background: var(--bg-primary);
    border-radius: 0;
    padding: 1.5rem !important;
    line-height: 1.8;
    font-family: 'Ubuntu', 'Arial', sans-serif;
    box-shadow: none;
}

/* Green theme - Light yellow background with dark green text */
.theme-green-terminal {
    /* Light yellow background with dark green text */
    --bg-primary: #f5f5dc; /* Light yellow background (like parchment) */
    --bg-secondary: #e5e5cc; /* Slightly darker yellow */
    --text-primary: #006400; /* Dark green text */
    --text-secondary: #2e8b57; /* Sea green for secondary text */
    --accent: #228b22; /* Forest green for accents */
    --accent-hover: #3cb371; /* Medium sea green for hover */
    --border: #d4d4a7; /* Yellowish border */
    --shadow: rgba(0, 100, 0, 0.1); /* Dark green shadow */
    --btn-bg: transparent;
    --btn-hover: #e0e0b8;
}

/* Purple Terminal Theme - Darker photographic gray background with brighter yellow text */
.theme-purple-terminal {
    /* Darker photographic gray background with bright yellow text */
    --bg-primary: #1e1e1e; /* Darker photographic gray */
    --bg-secondary: #2d2d2d; /* Slightly lighter gray for secondary areas */
    --text-primary: #ffd700; /* Bright yellow text */
    --text-secondary: #daa520; /* Golden yellow for secondary text */
    --accent: #ffcc00; /* Brighter yellow accent */
    --accent-hover: #ffeb3b; /* Even brighter yellow for hover */
    --border: #444466; /* Pale purple border */
    --shadow: rgba(139, 0, 255, 0.2); /* Purple shadow */
    --btn-bg: transparent;
    --btn-hover: #3a3a4a;
}

.light-theme .setup-header h2 {
    color: var(--accent);
}

.light-theme .story-container {
    background-color: var(--bg-secondary);
    border: 1px solid #e0d8c0;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
}

body {
    font-family: 'Ubuntu', 'Arial', sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.7;
    transition: background-color 0.8s ease, color 0.3s ease;
    margin: 0;
    padding: 0;
    /* Subtle paper texture for dark theme */
    background-image:
        repeating-linear-gradient(0deg, rgba(255,255,255,0.02) 0px, transparent 1px, transparent 2px, rgba(255,255,255,0.02) 3px),
        repeating-linear-gradient(90deg, rgba(255,255,255,0.02) 0px, transparent 1px, transparent 2px, rgba(255,255,255,0.02) 3px);
}

/* Dynamic Scene Atmosphere - Mood-based colors (subtle transitions from gray) */
body.atmosphere-tense {
    background-color: #222222; /* Dark gray with subtle red tint for danger */
    transition: background-color 0.8s ease;
}

body.atmosphere-peaceful {
    background-color: #2a2a2a; /* Neutral dark gray */
    transition: background-color 0.8s ease;
}

body.atmosphere-mysterious {
    background-color: #25222a; /* Dark gray with subtle purple tint */
    transition: background-color 0.8s ease;
}

body.atmosphere-romantic {
    background-color: #2a2528; /* Dark gray with subtle pink tint */
    transition: background-color 0.8s ease;
}

body.atmosphere-triumphant {
    background-color: #2a2a25; /* Dark gray with subtle gold tint */
    transition: background-color 0.8s ease;
}

/* Light theme atmosphere adjustments (subtle transitions from light gray) */
body.light-theme.atmosphere-tense {
    background-color: #f8f0f0; /* Light gray with subtle red tint */
    transition: background-color 0.8s ease;
}

body.light-theme.atmosphere-peaceful {
    background-color: #f0f8f5; /* Light neutral gray-green */
    transition: background-color 0.8s ease;
}

body.light-theme.atmosphere-mysterious {
    background-color: #f5f0f8; /* Light gray with subtle purple tint */
    transition: background-color 0.8s ease;
}

body.light-theme.atmosphere-romantic {
    background-color: #f8f0f5; /* Light gray with subtle pink tint */
    transition: background-color 0.8s ease;
}

body.light-theme.atmosphere-triumphant {
    background-color: #f8f7f0; /* Light gray with subtle gold tint */
    transition: background-color 0.8s ease;
}

.light-theme body {
    font-family: 'Ubuntu', 'Arial', sans-serif;
    background-color: #f9f3e3;
    /* Paper texture for light theme (stronger than dark) */
    background-image:
        repeating-linear-gradient(0deg, rgba(0,0,0,0.03) 0px, transparent 1px, transparent 2px, rgba(0,0,0,0.03) 3px),
        repeating-linear-gradient(90deg, rgba(0,0,0,0.03) 0px, transparent 1px, transparent 2px, rgba(0,0,0,0.03) 3px);
    transition: background-color 0.8s ease, color 0.3s ease;
}

.app-container {
    max-width: 100%;
    width: 100%;
    min-height: 100vh;
    margin: 0;
    display: flex;
    flex-direction: column;
    box-shadow: none;
    border: none;
    background: transparent;
    padding: 0 0.5rem;  /* Minimal padding - 8px */
}

/* Responsive margin adjustments */
@media (max-width: 1200px) {
    .app-container {
        padding: 0 0.5rem;  /* 8px on tablets */
    }
}

@media (max-width: 768px) {
    .app-container {
        padding: 0 0.5rem;  /* 8px on mobile */
    }
}

@media (max-width: 480px) {
    .app-container {
        padding: 0 0.25rem;  /* 4px on small mobile */
    }
}

/* ============================================
   Header
============================================ */

.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem 2rem;
    border-bottom: 1px solid var(--border);
    background-color: var(--bg-secondary);
    border-radius: 0;  /* Remove header rounded corners for paper look */
    box-shadow: none;  /* Remove header shadow */
}

/* Reading Settings Panel */
.reading-settings-panel {
    background-color: var(--bg-secondary);
    padding: 1.5rem 2rem;
    border-bottom: 1px solid var(--border);
}

.reading-settings-panel h3 {
    margin: 0 0 1rem 0;
    color: var(--accent);
    font-size: 1.1rem;
}

.setting-group {
    margin-bottom: 1rem;
}

.setting-group label {
    display: block;
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
}

.font-options {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.font-option-btn {
    padding: 0.5rem 1rem;
    background-color: transparent;
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.9rem;
}

.font-option-btn:hover {
    border-color: var(--accent);
    background-color: rgba(244, 232, 193, 0.05);
}

.font-option-btn.active {
    border-color: var(--accent);
    background-color: var(--accent);
    color: var(--bg-primary);
}

.light-theme .font-option-btn.active {
    color: #ffffff;
}

.text-align-options {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.text-align-option-btn {
    padding: 0.5rem 1rem;
    background-color: transparent;
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.9rem;
}

.text-align-option-btn:hover {
    border-color: var(--accent);
    background-color: rgba(244, 232, 193, 0.05);
}

.text-align-option-btn.active {
    border-color: var(--accent);
    background-color: var(--accent);
    color: var(--bg-primary);
}

.light-theme .text-align-option-btn.active {
    color: #ffffff;
}

/* Text Alignment Options */
body.text-align-justify .story-text {
    text-align: justify;
}

body.text-align-left .story-text {
    text-align: left;
}

.setting-group input[type="checkbox"] {
    margin-right: 0.5rem;
    cursor: pointer;
    width: 18px;
    height: 18px;
    vertical-align: middle;
}

/* Reading Progress Bar */
.reading-progress-container {
    background-color: var(--bg-secondary);
    padding: 0.75rem 2rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 1rem;
}

.progress-bar-wrapper {
    flex: 1;
    height: 8px;
    background-color: var(--border);
    border-radius: 10px;
    overflow: hidden;
    position: relative;
}

.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), var(--accent-hover));
    border-radius: 10px;
    transition: width 0.5s ease;
    box-shadow: 0 0 10px rgba(244, 232, 193, 0.4);
}

.progress-info {
    min-width: 200px;
    text-align: right;
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 500;
}

/* Trait Display */
.trait-display-container {
    display: flex;
    justify-content: space-around;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem 1rem;
    background-color: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
}

.trait-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 40px;
}

.trait-icon {
    font-size: 1.2rem;
    margin-bottom: 0.25rem;
}

.trait-value {
    font-size: 0.9rem;
    font-weight: bold;
    color: var(--accent);
}

/* Responsive trait display */
@media (max-width: 768px) {
    .trait-display-container {
        gap: 0.75rem;
        padding: 0.5rem 1rem;
    }
    
    .trait-icon {
        font-size: 1rem;
    }
    
    .trait-value {
        font-size: 0.8rem;
    }
}

/* Responsive progress bar */
@media (max-width: 768px) {
    .reading-progress-container {
        flex-direction: column;
        gap: 0.5rem;
        padding: 0.5rem 1rem;
    }

    .progress-info {
        min-width: auto;
        text-align: center;
        width: 100%;
    }
}

.logo {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--accent);
}

.header-controls {
    display: flex;
    gap: 0.5rem;
}

.icon-btn {
    background: transparent;
    border: none;
    font-size: 1.4rem;
    cursor: pointer;
    padding: 0.6rem;
    transition: all 0.2s ease;
    min-height: 40px;
    min-width: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    border-radius: 6px;
}

.icon-btn:hover {
    background-color: var(--btn-hover);
    color: var(--accent);
}

.icon-btn:active {
    transform: scale(0.92);
}

/* Icon styling - Default white icons for dark theme */
.font-size-icon,
.save-icon,
.theme-icon,
.settings-icon,
.focus-icon,
.tracker-icon {
    font-size: 1.2rem;
    line-height: 1;
    display: block;
    color: #ffffff !important;
    font-style: normal;
}

/* Plus icon - custom styled */
#fontIncrease .font-size-icon {
    font-weight: 300;
    font-size: 1.6rem;
    color: #ffffff !important;
}

/* Minus icon - custom styled */
#fontDecrease .font-size-icon {
    font-weight: 300;
    font-size: 1.6rem;
    color: #ffffff !important;
}

/* Save icon */
.save-icon {
    font-weight: 600;
    font-size: 1.3rem;
    color: #ffffff !important;
}

/* Theme icon */
.theme-icon {
    font-size: 1.4rem;
    font-weight: normal;
    color: #ffffff !important;
}

/* Settings icon */
.settings-icon,
.focus-icon,
.tracker-icon {
    color: #ffffff !important;
}

/* Light theme icon visibility */
.light-theme .icon-btn,
.light-theme #fontIncrease,
.light-theme #fontDecrease,
.light-theme #themeToggle,
.light-theme #saveBtn,
.light-theme #readingSettingsToggle,
.light-theme #focusModeToggle,
.light-theme #characterTrackerToggle {
    color: #000000 !important;
}

.light-theme .font-size-icon,
.light-theme .save-icon,
.light-theme .theme-icon,
.light-theme .settings-icon,
.light-theme .focus-icon,
.light-theme .tracker-icon {
    color: #000000 !important;
}

/* Dark green theme icon visibility */
.theme-dark-green .icon-btn,
.theme-dark-green #fontIncrease,
.theme-dark-green #fontDecrease,
.theme-dark-green #themeToggle,
.theme-dark-green #saveBtn,
.theme-dark-green #readingSettingsToggle,
.theme-dark-green #focusModeToggle,
.theme-dark-green #characterTrackerToggle {
    color: #ffffff !important;
}

.theme-dark-green .font-size-icon,
.theme-dark-green .save-icon,
.theme-dark-green .theme-icon,
.theme-dark-green .settings-icon,
.theme-dark-green .focus-icon,
.theme-dark-green .tracker-icon {
    color: #ffffff !important;
}

/* Purple terminal theme icon visibility */
.theme-purple-terminal .icon-btn,
.theme-purple-terminal #fontIncrease,
.theme-purple-terminal #fontDecrease,
.theme-purple-terminal #themeToggle,
.theme-purple-terminal #saveBtn,
.theme-purple-terminal #readingSettingsToggle,
.theme-purple-terminal #focusModeToggle,
.theme-purple-terminal #characterTrackerToggle {
    color: #ffffff !important;
}

.theme-purple-terminal .font-size-icon,
.theme-purple-terminal .save-icon,
.theme-purple-terminal .theme-icon,
.theme-purple-terminal .settings-icon,
.theme-purple-terminal .focus-icon,
.theme-purple-terminal .tracker-icon {
    color: #ffffff !important;
}

/* Ensure consistent styling */
#fontDecrease,
#fontIncrease,
#themeToggle,
#saveBtn {
    /* All use default .icon-btn styling */
}

/* ============================================
   Screens
============================================ */

.screen {
    display: none;
    flex: 1;
    padding: 2rem;
    width: 100%;
}

.screen.active {
    display: block;
    width: 100%;
}

/* ============================================
   Setup Screen
============================================ */

.light-theme .setup-container {
    width: 100%;
    margin: 0 auto;
    background-color: var(--bg-primary);
    padding: 2.5rem;
    border: 1px solid var(--border);
    border-radius: 0;
    box-shadow: none;
}

/* Ensure dark theme still has proper styling */
.dark-theme .setup-container {
    width: 100%;
    margin: 0 auto;
    padding: 2rem;
}

.setup-header {
    text-align: center;
    margin-bottom: 3rem;
}

.setup-header h2 {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
    color: var(--accent);
}

.subtitle {
    color: var(--text-secondary);
    font-size: 1.1rem;
    font-style: italic;
}

.description {
    color: var(--text-secondary);
    font-size: 0.95rem;
    font-style: normal;
    line-height: 1.6;
}

.description-detailed {
    color: var(--text-secondary);
    font-size: 0.95rem;
    line-height: 1.8;
    margin-top: 1.5rem;
    padding: 1.5rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 2px 8px var(--shadow);
}

.description-detailed p {
    margin-bottom: 0.75rem;
}

.description-detailed strong {
    color: var(--accent);
    font-weight: 600;
}

.description-detailed ol {
    margin: 1rem 0;
}

.description-detailed ol li {
    margin-bottom: 0.75rem;
    color: var(--text-primary);
}

.description-detailed ol li strong {
    color: var(--accent);
}

.setup-section {
    margin-bottom: 2.5rem;
}

.setup-section h3 {
    font-size: 1.3rem;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.button-group {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.genre-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr); /* Dve kolone za 16 žanrova */
    gap: 1rem;  /* Veći razmak između dugmića */
}

/* Na većim ekranima može biti više kolona */
@media (min-width: 769px) {
    .genre-grid {
        grid-template-columns: repeat(4, 1fr); /* 4 kolone za veće ekrane */
    }
}

/* Mobilni uređaji */
@media (max-width: 768px) {
    .genre-grid {
        grid-template-columns: 1fr;  /* Vertikalni raspored na mobilnim uređajima za bolji dodir */
        gap: 1.2rem;
    }
}

/* Tablet uređaji */
@media (min-width: 481px) and (max-width: 768px) {
    .genre-grid {
        grid-template-columns: repeat(2, 1fr); /* 2 kolone za tablete */
    }
}

.choice-btn {
    padding: 1.25rem 1.5rem;
    background-color: transparent;
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
    font-family: inherit;
    min-height: 80px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: 100%;
    line-height: 1.5;
}

.choice-btn:hover {
    background-color: var(--btn-hover);
    border-color: var(--accent);
    color: var(--accent);
}

.choice-btn:active {
    transform: scale(0.98);
    background-color: var(--accent);
    border-color: var(--accent);
    color: var(--bg-primary);
}

.choice-btn.selected {
    transform: scale(0.98);
    background-color: var(--accent);
    border-color: var(--accent);
    color: var(--bg-primary);
    box-shadow: 0 0 15px rgba(244, 232, 193, 0.6);
    animation: pulseGlow 1s infinite alternate;
}

@keyframes pulseGlow {
    from {
        box-shadow: 0 0 10px rgba(244, 232, 193, 0.4);
    }
    to {
        box-shadow: 0 0 20px rgba(244, 232, 193, 0.8);
    }
}

.light-theme .choice-btn:active {
    background-color: var(--accent);
    border-color: var(--accent);
    color: #ffffff;
}

/* Touch feedback */
.active-touch {
    transform: scale(0.98);
    opacity: 0.8;
}

.choice-btn.active {
    border-color: var(--accent);
    background-color: var(--accent);
    color: var(--bg-primary);
}

/* Enhanced Genre Button Styles for better contrast */
.genre-btn {
    /* Inherits from choice-btn but with enhanced visual feedback */
    position: relative;
    overflow: hidden;
}

.genre-btn:hover {
    /* Enhanced hover effect for better visibility */
    background-color: var(--btn-hover);
    border-color: var(--accent);
    color: var(--accent);
    /* Slightly brighter effect */
    box-shadow: 0 0 8px rgba(244, 232, 193, 0.3);
}

.genre-btn:active {
    transform: scale(0.98);
    background-color: var(--accent);
    border-color: var(--accent);
    color: var(--bg-primary);
}

.light-theme .genre-btn:hover {
    /* Better contrast in light theme */
    box-shadow: 0 0 8px rgba(139, 105, 20, 0.2);
}

.light-theme .genre-btn:active {
    color: #ffffff;
    background-color: var(--accent);
    border-color: var(--accent);
}

.genre-btn.active {
    /* More pronounced active state */
    border-color: var(--accent);
    background-color: var(--accent);
    color: var(--bg-primary);
    box-shadow: 0 0 12px rgba(244, 232, 193, 0.5);
    transform: scale(1.02);
}

.light-theme .genre-btn.active {
    box-shadow: 0 0 12px rgba(139, 105, 20, 0.4);
}

/* Choice Consequence Badges */
.choice-badges {
    display: flex;
    gap: 0.4rem;
    margin-top: 0.5rem;
    flex-wrap: wrap;
    justify-content: center;
}

.choice-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.2rem 0.5rem;
    border-radius: 10px;
    font-size: 0.7rem;
    font-weight: 600;
    background-color: rgba(0, 0, 0, 0.25);
    border: 1px solid rgba(255, 255, 255, 0.15);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.light-theme .choice-badge {
    background-color: rgba(255, 255, 255, 0.6);
    border: 1px solid rgba(0, 0, 0, 0.15);
}

/* Risk Level Badges */
.badge-safe {
    color: #4ade80;
    border-color: #4ade80;
}

.badge-risky {
    color: #fbbf24;
    border-color: #fbbf24;
}

.badge-dangerous {
    color: #f87171;
    border-color: #f87171;
}

/* Trait Badges */
.badge-courage {
    color: #ef4444;
    border-color: #ef4444;
}

.badge-wisdom {
    color: #3b82f6;
    border-color: #3b82f6;
}

.badge-love {
    color: #ec4899;
    border-color: #ec4899;
}

.badge-wit {
    color: #a855f7;
    border-color: #a855f7;
}

.badge-caution {
    color: #14b8a6;
    border-color: #14b8a6;
}

.badge-stealth {
    color: #6366f1;
    border-color: #6366f1;
}

/* Poboljšanje za mobilne uređaje */
@media (max-width: 768px) {
    .choice-btn {
        min-height: 90px;
        padding: 1.5rem 1.5rem;
        font-size: 1.1rem;
    }

    .genre-grid {
        gap: 1rem; /* Veći razmak za dodir */
    }

    .embedded-choices-container {
        gap: 1.25rem;
    }
}

.primary-btn {
    width: 100%;
    padding: 1.25rem 2rem;
    background: linear-gradient(135deg, var(--accent), var(--accent-hover));
    color: #2c2c2c;
    border: none;
    border-radius: 8px;
    font-size: 1.2rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: inherit;
    margin-top: 2rem;
}

.light-theme .primary-btn {
    color: #ffffff;
}

.primary-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px var(--shadow);
}

.primary-btn:active {
    transform: scale(0.98);
    background: linear-gradient(135deg, var(--accent-hover), var(--accent));
}

/* Translation Option */
.translation-option {
    margin: 1.5rem 0 1rem 0;
    padding: 1rem;
    background: var(--bg-secondary);
    border-radius: 8px;
    border: 1px solid var(--border);
}

.translate-checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
    font-size: 1.05rem;
    font-weight: 500;
    color: var(--text);
}

.translate-checkbox-label input[type="checkbox"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
    accent-color: var(--accent);
}

.translate-checkbox-label span {
    user-select: none;
}

.translate-note {
    margin: 0.5rem 0 0 2.5rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-style: italic;
}

/* ============================================
   Game Screen
============================================ */

.game-container {
    width: 100%;
    padding: 0;  /* Remove padding to make it look more like paper */
    background: transparent;  /* Make transparent for paper background */
    box-shadow: none;  /* Remove container shadow */
    border: none;  /* Remove container border */
}

.light-theme .stats-bar {
    display: flex;
    justify-content: space-between;
    padding: 1rem 1.5rem;
    background-color: var(--bg-primary);
    border-radius: 0;
    margin-bottom: 2rem;
    border: 1px solid var(--border);
}

/* Ensure dark theme still has proper styling */
.dark-theme .stats-bar {
    display: flex;
    justify-content: space-between;
    padding: 1rem 1.5rem;
    background-color: var(--bg-secondary);
    border-radius: 8px;
    margin-bottom: 2rem;
}

.stat-item {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.stat-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.stat-value {
    font-size: 1.2rem;
    font-weight: bold;
    color: var(--accent);
}

.light-theme .story-container {
    background-color: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 0;
    padding: 1rem;
    margin-bottom: 2rem;
    box-shadow: none;
    min-height: 400px;
}

/* Ensure dark theme still has proper styling */
.dark-theme .story-container {
    background-color: var(--bg-secondary);
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 2rem;
    box-shadow: 0 2px 10px var(--shadow);
    min-height: 400px;
}

.story-text {
    font-size: 1.1rem;
    line-height: 1.9;
    white-space: pre-wrap;
    color: var(--text-primary);
    font-family: 'Georgia', serif;
    padding: 2rem 1.5rem;
    text-align: justify;
    max-width: 100%;
    margin: 0;
    /* Scene transition animation */
    animation: fadeInScene 0.6s ease-in;
}

/* Font Style Options */
body.font-serif .story-text {
    font-family: 'Georgia', serif;
}

body.font-sans-serif .story-text {
    font-family: 'Ubuntu', 'Arial', sans-serif;
}

body.font-monospace .story-text {
    font-family: 'Courier New', 'Courier', monospace;
    letter-spacing: 0.02em;
}

body.font-dyslexia .story-text {
    font-family: 'Comic Sans MS', 'Arial', sans-serif;
    letter-spacing: 0.12em;
    word-spacing: 0.16em;
    line-height: 2.2;
}

body.font-calibri .story-text {
    font-family: 'Calibri', 'Arial', sans-serif;
}

body.font-georgia .story-text {
    font-family: 'Georgia', serif;
}

body.font-garamond .story-text {
    font-family: 'Garamond', 'Times New Roman', serif;
}

body.font-times .story-text {
    font-family: 'Times New Roman', 'Times', serif;
}

body.font-idla-sans .story-text {
    font-family: 'Inter', 'Source Sans Pro', 'Roboto', 'Open Sans', 'Arial', sans-serif;
}

body.font-ubuntu-sans .story-text {
    font-family: 'Ubuntu', 'Arial', sans-serif;
}

/* Text Alignment Options */
body.text-align-justify .story-text {
    text-align: justify;
}

body.text-align-left .story-text {
    text-align: left;
}
}

body.text-align-left .story-text {
    text-align: left;
}

/* OLED Night Mode - True Black */
body.oled-mode {
    background-color: #000000 !important;
    background-image: none !important;
}

body.oled-mode .app-header {
    background-color: #000000;
    border-bottom-color: #222222;
}

body.oled-mode .reading-progress-container {
    background-color: #000000;
    border-bottom-color: #222222;
}

body.oled-mode .reading-settings-panel {
    background-color: #000000;
    border-bottom-color: #222222;
}

body.oled-mode .story-container {
    background-color: #000000;
}

body.oled-mode .story-text {
    color: #e0e0e0;
}

body.oled-mode .choice-btn {
    border-color: #333333;
    background-color: #000000;
}

body.oled-mode .choice-btn:hover {
    background-color: #111111;
    border-color: var(--accent);
}

/* Fade-in animation for new scenes */
@keyframes fadeInScene {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Paragraphs in story text - proper book formatting */
.story-text p {
    margin-bottom: 1.5rem;
    text-indent: 1.5em;
    line-height: 1.9;
    hyphens: auto;
    -webkit-hyphens: auto;
    -moz-hyphens: auto;
}

/* First paragraph after header has no indent */
.scene-header + p,
.story-text p:first-of-type {
    text-indent: 0;
}

/* Book-style headers for scene titles */
.story-text h1,
.story-text h2,
.story-text h3 {
    text-align: center;
    font-family: 'Ubuntu', 'Georgia', serif;
    font-weight: 500;
    color: var(--text-primary);
    margin: 2rem 0 1.5rem 0;
    padding: 0;
    border: none;
    background: none;
    letter-spacing: 0.05em;
    text-transform: none;
    text-indent: 0;
}

.story-text h1 {
    font-size: 2rem;
    margin-top: 1rem;
    margin-bottom: 2rem;
}

.story-text h2 {
    font-size: 1.6rem;
    margin-top: 1.5rem;
}

.story-text h3 {
    font-size: 1.3rem;
    font-style: italic;
}

/* Scene Header Styling */
.scene-header {
    margin: 0 0 1rem 0; /* Reduced from 2rem */
    padding: 0.5rem 0 0.5rem 0; /* Reduced from 1rem 0 0.75rem */
    border-bottom: 2px solid var(--accent);
    text-align: left;
}

.scene-number {
    font-size: 0.85rem; /* Slightly smaller */
    color: var(--accent);
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    margin: 0 0 0.25rem 0; /* Reduced from 0.5rem */
}

.scene-title {
    font-size: 1.2rem; /* Slightly smaller */
    font-weight: 700;
    color: var(--text-primary);
    margin: 0 0 0.25rem 0; /* Added small bottom margin */
    font-family: 'Ubuntu', 'Georgia', serif;
    line-height: 1.2; /* Reduced line height */
}

.scene-location {
    font-size: 0.9rem; /* Slightly smaller */
    color: var(--text-secondary);
    font-style: italic;
    opacity: 0.85;
    margin: 0 0 0.25rem 0; /* Added small bottom margin */
}

.scene-metadata {
    font-size: 0.85rem; /* Slightly smaller */
    color: var(--text-secondary);
    font-style: italic;
    opacity: 0.90;
    margin: 0; /* Removed top margin */
    line-height: 1.3; /* Reduced line height */
}

/* Light theme adjustments for scene header */
.light-theme .scene-header {
    border-bottom-color: var(--accent);
}

.light-theme .scene-title {
    color: #1a0f05;
}

.light-theme .scene-location {
    color: #4a4a4a;
}

/* Light theme specific styling for headers - darker ink color */
.light-theme .story-text h1,
.light-theme .story-text h2,
.light-theme .story-text h3 {
    color: #1a0f05;
    font-weight: 600;
}

/* Decorative line under h1 (chapter titles) */
.story-text h1::after {
    content: '';
    display: block;
    width: 80px;
    height: 2px;
    background: var(--accent);
    margin: 1rem auto 0;
    opacity: 0.5;
}

.scene-image-container {
    text-align: center;
    margin-bottom: 2rem;
}

.scene-image {
    max-width: 100%;
    max-height: 400px;
    border-radius: 8px;
    box-shadow: 0 4px 12px var(--shadow);
    margin-bottom: 1.5rem;
}

.scene-midi-container {
    text-align: center;
    margin: 1.5rem 0;
    padding: 1rem;
    background-color: var(--bg-secondary);
    border-radius: 8px;
    border: 1px solid var(--border);
}

.scene-midi-player {
    width: 100%;
    max-width: 500px;
    margin: 0.5rem 0;
}

.midi-controls {
    margin-top: 0.5rem;
}

.midi-info {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin: 0;
}

.emoji-intro {
    text-align: center;
    font-size: 1.5rem;
    margin-bottom: 1.5rem;
    opacity: 0.8;
}

.story-text p {
    margin-bottom: 1.5rem;
}

.choices-container {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 2rem;
}

.embedded-choices-container {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-top: 2rem;
    padding-top: 2rem;
    border-top: 2px solid var(--border);
    margin-left: 0;
    padding-left: 0;
}

.choice-btn.game-choice {
    /* Inherits from .choice-btn */
}

.embedded-choice {
    /* Inherits from .choice-btn */
}

.choice-emoji-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 0.5rem;
}

.choice-emoji {
    font-size: 2rem;
    line-height: 1;
    display: inline-block;
}

.choice-text {
    font-size: 0.95rem;
    line-height: 1.4;
    max-width: 90%;
}

/* ============================================
   Loading Screen
============================================ */

.loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--bg-primary);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

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

.loading-content h1 {
    font-size: 3rem;
    margin-bottom: 2rem;
    color: var(--accent);
}

.loading-spinner {
    width: 80px;
    height: 80px;
    margin: 0 auto 1rem;
    border: 5px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.countdown-number {
    position: absolute;
    font-size: 2rem;
    font-weight: bold;
    color: var(--accent);
    animation: pulse 0.5s ease-in-out infinite alternate;
}

@keyframes pulse {
    from {
        transform: scale(1);
        opacity: 0.8;
    }
    to {
        transform: scale(1.1);
        opacity: 1;
    }
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

#loadingText {
    font-size: 1.1rem;
    color: var(--text-secondary);
}

/* ============================================
   Character Relationship Tracker
============================================ */

.character-tracker {
    position: fixed;
    top: 80px;
    right: 0;
    width: 280px;
    max-height: calc(100vh - 100px);
    background-color: var(--bg-secondary);
    border-left: 2px solid var(--border);
    border-radius: 12px 0 0 12px;
    box-shadow: -4px 0 15px var(--shadow);
    z-index: 100;
    overflow-y: auto;
    transition: transform 0.3s ease;
}

.character-tracker.hidden {
    transform: translateX(100%);
}

.tracker-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    background-color: var(--bg-secondary);
    z-index: 10;
}

.tracker-header h3 {
    margin: 0;
    font-size: 1.1rem;
    color: var(--accent);
}

.tracker-close-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s ease;
}

.tracker-close-btn:hover {
    color: var(--accent);
}

.character-list {
    padding: 1rem;
}

.no-characters {
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-style: italic;
    padding: 2rem 1rem;
}

.character-card {
    background-color: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.75rem;
    margin-bottom: 0.75rem;
    transition: all 0.2s ease;
}

.light-theme .character-card {
    background-color: rgba(0, 0, 0, 0.03);
}

.character-card:hover {
    border-color: var(--accent);
    background-color: rgba(244, 232, 193, 0.05);
}

.character-name {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.character-attitude {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 10px;
    font-size: 0.7rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
}

.attitude-friendly {
    background-color: rgba(74, 222, 128, 0.2);
    color: #4ade80;
    border: 1px solid #4ade80;
}

.attitude-neutral {
    background-color: rgba(251, 191, 36, 0.2);
    color: #fbbf24;
    border: 1px solid #fbbf24;
}

.attitude-hostile {
    background-color: rgba(248, 113, 113, 0.2);
    color: #f87171;
    border: 1px solid #f87171;
}

.character-last-seen {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-style: italic;
}

/* Mobile responsive */
@media (max-width: 768px) {
    .character-tracker {
        width: 240px;
        top: 70px;
    }
}

/* ============================================
   Utilities
============================================ */

.hidden {
    display: none !important;
}

/* ============================================
   Focus Mode
============================================ */

/* When in focus mode, hide everything except story text and choices */
body.focus-mode .app-header {
    display: none;
}

body.focus-mode .reading-progress-container {
    display: none;
}

/* Show choices in focus mode but style them differently */
body.focus-mode .embedded-choices-container {
    display: flex !important;
    background-color: var(--bg-secondary);
    padding: 2rem 2rem 1rem 2rem;
    margin: 2rem -2rem 0 -2rem;
    border-top: 2px solid var(--border);
}

/* Style choices in focus mode */
body.focus-mode .embedded-choices-container .choice-btn {
    flex: 1;
    min-height: 70px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 1rem;
    margin-bottom: 0.5rem;
    text-align: center;
}

/* Hide emojis in focus mode choices */
body.focus-mode .embedded-choices-container .choice-emoji-wrapper,
body.focus-mode .embedded-choices-container .choice-emoji {
    display: none;
}

/* Ensure text is visible in focus mode */
body.focus-mode .embedded-choices-container .choice-text {
    font-size: 0.9rem;
    line-height: 1.3;
    width: 100%;
    text-align: center;
}

/* Make story text full screen in focus mode */
body.focus-mode .story-text {
    max-width: 900px;
    padding: 3rem 2rem;
    min-height: calc(100vh - 300px); /* Account for choices container */
}

/* Show a subtle exit hint */
body.focus-mode::before {
    content: 'Press ESC or click 👁️ to exit Focus Mode';
    position: fixed;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-secondary);
    color: var(--text-secondary);
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-size: 0.75rem;
    opacity: 0;
    pointer-events: none;
    animation: fadeInOut 3s ease-in-out;
    z-index: 1000;
}

@keyframes fadeInOut {
    0%, 100% { opacity: 0; }
    10%, 90% { opacity: 0.7; }
}

/* Keep focus mode toggle visible */
body.focus-mode .app-header {
    display: flex;
    position: fixed;
    top: 0;
    right: 0;
    width: auto;
    background: transparent;
    border: none;
    padding: 1rem;
    z-index: 999;
}

body.focus-mode .app-header .logo,
body.focus-mode .app-header .header-controls > *:not(#focusModeToggle) {
    display: none;
}

body.focus-mode .app-header .header-controls {
    margin: 0;
}

body.focus-mode #focusModeToggle {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 50%;
    padding: 0.75rem;
    box-shadow: 0 4px 12px var(--shadow);
}

/* Show a subtle exit hint */
body.focus-mode::before {
    content: 'Press ESC or click 👁️ to exit Focus Mode';
    position: fixed;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-secondary);
    color: var(--text-secondary);
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-size: 0.75rem;
    opacity: 0;
    pointer-events: none;
    animation: fadeInOut 3s ease-in-out;
    z-index: 1000;
}

@keyframes fadeInOut {
    0%, 100% { opacity: 0; }
    10%, 90% { opacity: 0.7; }
}

/* Keep focus mode toggle visible */
body.focus-mode .app-header {
    display: flex;
    position: fixed;
    top: 0;
    right: 0;
    width: auto;
    background: transparent;
    border: none;
    padding: 1rem;
    z-index: 999;
}

body.focus-mode .app-header .logo,
body.focus-mode .app-header .header-controls > *:not(#focusModeToggle) {
    display: none;
}

body.focus-mode .app-header .header-controls {
    margin: 0;
}

body.focus-mode #focusModeToggle {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 50%;
    padding: 0.75rem;
    box-shadow: 0 4px 12px var(--shadow);
}

/* ============================================
   Responsive
============================================ */

@media (max-width: 768px) {
    .app-header {
        padding: 1rem;
    }

    .screen {
        padding: 1rem;
    }

    .setup-header h2 {
        font-size: 2rem;
    }

    .story-container {
        padding: 1rem;
    }

    .story-text {
        font-size: 1rem;
        padding: 1.5rem 1rem;
        line-height: 1.8;
    }

    .story-text p {
        margin-bottom: 1.25rem;
        text-indent: 1.2em;
    }

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

/* ============================================
   Epilogue Styling
============================================ */

.epilogue-section {
    margin-top: 2rem;
    padding-top: 2rem;
    border-top: 2px solid var(--border);
}

.epilogue-section h3 {
    font-size: 1.5rem;
    color: var(--accent);
    margin-bottom: 1rem;
}

.cards-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    margin: 2rem 0;
}

.card-item {
    background-color: var(--bg-primary);
    padding: 1.5rem;
    border-radius: 8px;
    border: 1px solid var(--border);
    text-align: center;
}

.card-symbol {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.card-name {
    font-weight: bold;
    margin-bottom: 0.5rem;
    color: var(--accent);
}

.card-meaning {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

/* ============================================
   Genre Hidden & Additional Styles
============================================ */

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

.secondary-btn {
    background-color: transparent;
    border: 2px solid var(--accent);
    color: var(--accent);
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    font-weight: 500;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    margin: 0.5rem;
}

.secondary-btn:hover {
    background-color: var(--accent);
    color: var(--bg-primary);
}

.secondary-btn:active {
    transform: scale(0.98);
    background-color: var(--accent-hover);
    color: var(--bg-primary);
}

.epilogue-actions {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-top: 2rem;
    flex-wrap: wrap;
}

.epilogue-actions.hidden {
    display: none;
}

/* ============================================
   Scene Transitions - Cross-Fade
============================================ */

/* Scene fade-out animation (exit) */
@keyframes sceneFadeOut {
    from {
        opacity: 1;
        transform: scale(1);
    }
    to {
        opacity: 0;
        transform: scale(0.98);
    }
}

/* Scene fade-in animation (enter) */
@keyframes sceneFadeIn {
    from {
        opacity: 0;
        transform: scale(1.02);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Scene exit class - triggered when scene changes */
.scene-exit {
    animation: sceneFadeOut 400ms ease-out forwards;
}

/* Scene enter class - triggered when new scene appears */
.scene-enter {
    animation: sceneFadeIn 400ms ease-in forwards;
}

/* Story text container transition */
.story-text {
    transition: opacity 400ms ease;
}

