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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #0ea5e9 0%, #06b6d4 100%);
    min-height: 100vh;
    padding-bottom: 20px;
}

/* Navbar */
.navbar {
    background: rgba(255, 255, 255, 0.95);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    padding: 15px 0;
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(10px);
}

.nav-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.navbar h1 {
    font-size: 1.5em;
    color: #0ea5e9;
    margin: 0;
}

.nav-actions {
    display: flex;
    gap: 10px;
    align-items: center;
}

/* History button - make it prominent */
#historyBtn {
    animation: gentle-pulse 3s infinite;
}

@keyframes gentle-pulse {
    0%, 100% {
        box-shadow: 0 4px 15px rgba(14, 165, 233, 0.4);
    }
    50% {
        box-shadow: 0 4px 20px rgba(14, 165, 233, 0.6);
    }
}

@media (prefers-reduced-motion: reduce) {
    #historyBtn {
        animation: none;
        box-shadow: 0 4px 15px rgba(14, 165, 233, 0.4);
    }
}

/* Buttons */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 0.95em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    outline: none;
}

.btn-primary {
    background: linear-gradient(135deg, #0ea5e9 0%, #06b6d4 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(14, 165, 233, 0.4);
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(14, 165, 233, 0.6);
}

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-secondary {
    background: #f8f9fa;
    color: #333;
    border: 1px solid #dee2e6;
}

.btn-secondary:hover {
    background: #e9ecef;
}

.btn-icon {
    font-size: 1.2em;
    padding: 8px 12px;
    background: transparent;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-icon:hover {
    transform: scale(1.1);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.85em;
}

/* Container */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 15px;
}

.freewrite-container {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-top: 15px;
    max-width: 1200px;
}

/* Main Freewrite Card */
.freewrite-card {
    background: white;
    border-radius: 16px;
    padding: 20px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
}

.game-header {
    text-align: center;
    margin-bottom: 15px;
}

.game-header h2 {
    color: #333;
    font-size: 1.8em;
    margin-bottom: 10px;
}

.game-instructions {
    color: #666;
    font-size: 0.95em;
}

/* Prompt Section */
.prompt-section {
    margin-bottom: 30px;
}

.prompt-card {
    background: linear-gradient(135deg, #f5f7fa 0%, #e4e8ec 100%);
    border-radius: 12px;
    padding: 25px;
    text-align: center;
    border: 2px solid #e0e5eb;
}

.prompt-icon {
    font-size: 3em;
    margin-bottom: 15px;
}

.prompt-text {
    font-size: 1.3em;
    color: #333;
    font-weight: 500;
    line-height: 1.6;
    margin-bottom: 20px;
    min-height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Timer Section */
.timer-section {
    margin-bottom: 30px;
    text-align: center;
}

.timer-display {
    background: linear-gradient(135deg, #0ea5e9 0%, #06b6d4 100%);
    color: white;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
    display: inline-block;
    min-width: 200px;
}

.timer-icon {
    font-size: 1.5em;
    margin-right: 10px;
}

.timer-text {
    font-size: 2em;
    font-weight: 700;
    font-family: 'Courier New', monospace;
}

.timer-controls {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
}

/* Writing Section */
.writing-section {
    margin-bottom: 20px;
}

.writing-area {
    width: 100%;
    min-height: 300px;
    padding: 20px;
    border: 2px solid #e0e5eb;
    border-radius: 12px;
    font-size: 1.1em;
    line-height: 1.8;
    resize: vertical;
    font-family: 'Georgia', serif;
    transition: all 0.3s ease;
}

.writing-area:focus {
    outline: none;
    border-color: #0ea5e9;
    box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.1);
}

.writing-area:disabled {
    background: #f8f9fa;
    cursor: not-allowed;
}

.word-count {
    text-align: right;
    color: #666;
    font-size: 0.9em;
    margin-top: 10px;
}

/* Action Buttons */
.action-buttons {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-bottom: 20px;
}

/* Save Message */
.save-message {
    text-align: center;
    padding: 15px;
    border-radius: 8px;
    font-weight: 500;
    animation: slideIn 0.3s ease;
}

.save-message.success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.save-message.error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

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

/* Stats Card */
.stats-card {
    background: white;
    border-radius: 16px;
    padding: 25px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
    height: fit-content;
}

.stats-card h3 {
    color: #333;
    font-size: 1.3em;
    margin-bottom: 20px;
    text-align: center;
}

.stats-grid {
    display: grid;
    gap: 20px;
}

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

.stat-value {
    font-size: 2em;
    font-weight: 700;
    color: #0ea5e9;
    margin-bottom: 5px;
}

.stat-label {
    font-size: 0.85em;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(5px);
}

.modal-content {
    background-color: white;
    margin: 50px auto;
    padding: 30px;
    border-radius: 16px;
    width: 90%;
    max-width: 600px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: modalSlideIn 0.3s ease;
}

.modal-large {
    max-width: 900px;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-50px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.close {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    transition: color 0.2s ease;
}

.close:hover,
.close:focus {
    color: #000;
}

.modal-content h2 {
    color: #333;
    margin-bottom: 20px;
}

/* History Actions Bar */
.history-actions-bar {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid #e9ecef;
}

.history-actions-bar .btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
}

/* History List */
.history-list {
    max-height: 500px;
    overflow-y: auto;
}

.history-item {
    background: #f8f9fa;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 15px;
    border-left: 4px solid #0ea5e9;
}

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.history-date {
    font-size: 0.9em;
    color: #666;
}

.history-actions {
    display: flex;
    gap: 8px;
}

.history-actions button {
    padding: 5px 10px;
    font-size: 0.85em;
}

.history-prompt {
    font-style: italic;
    color: #0ea5e9;
    margin-bottom: 10px;
    font-weight: 500;
}

.history-text {
    color: #333;
    line-height: 1.6;
    max-height: 100px;
    overflow: hidden;
    position: relative;
}

.history-text.expanded {
    max-height: none;
}

.history-meta {
    display: flex;
    gap: 15px;
    margin-top: 10px;
    font-size: 0.85em;
    color: #666;
}

.empty-history {
    text-align: center;
    padding: 40px;
    color: #666;
}

.empty-history-icon {
    font-size: 4em;
    margin-bottom: 20px;
}

/* Settings */
.settings-section {
    margin-bottom: 30px;
}

.setting-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 0;
    border-bottom: 1px solid #e0e5eb;
}

.setting-item:last-child {
    border-bottom: none;
}

.setting-info {
    flex: 1;
}

.setting-info label {
    display: block;
    font-weight: 600;
    color: #333;
    margin-bottom: 5px;
}

.setting-description {
    font-size: 0.85em;
    color: #666;
}

.setting-select {
    padding: 8px 12px;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    font-size: 0.95em;
    background: white;
    cursor: pointer;
}

.setting-value {
    padding: 8px 12px;
    display: flex;
    align-items: center;
}

.timer-duration-display {
    font-size: 1em;
    font-weight: 600;
    color: #0ea5e9;
}

/* Toggle Switch */
.toggle {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 26px;
}

.toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: 0.3s;
    border-radius: 26px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.3s;
    border-radius: 50%;
}

.toggle input:checked + .toggle-slider {
    background: linear-gradient(135deg, #0ea5e9 0%, #06b6d4 100%);
}

.toggle input:checked + .toggle-slider:before {
    transform: translateX(24px);
}

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

/* Footer */
.footer {
    background: rgba(255, 255, 255, 0.95);
    margin-top: 40px;
    padding: 20px 0;
}

.footer-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    text-align: center;
}

.footer-links {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    margin-bottom: 15px;
    flex-wrap: wrap;
}

.footer-links a {
    color: #0ea5e9;
    text-decoration: none;
    font-weight: 600;
    transition: color 0.3s ease;
}

.footer-links a:hover {
    color: #06b6d4;
    text-decoration: underline;
}

.footer-links .separator {
    color: #ccc;
}

.footer-social {
    margin: 15px 0;
}

.social-btn {
    background: linear-gradient(135deg, #0ea5e9 0%, #06b6d4 100%);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 0.95em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(14, 165, 233, 0.4);
    display: inline-block;
    text-decoration: none;
}

.social-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(14, 165, 233, 0.6);
}

.footer-copyright {
    color: #666;
    font-size: 0.9em;
    margin-top: 15px;
}

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

/* Responsive Design */
@media (max-width: 968px) {
    .freewrite-container {
        display: flex;
        flex-direction: column;
        max-width: 1200px;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .navbar h1 {
        font-size: 1.2em;
    }

    .freewrite-card {
        padding: 20px;
    }

    .game-header h2 {
        font-size: 1.4em;
    }

    .prompt-text {
        font-size: 1.1em;
    }

    .timer-text {
        font-size: 1.5em;
    }

    .writing-area {
        min-height: 200px;
        font-size: 1em;
    }

    .action-buttons {
        flex-direction: column;
    }

    .action-buttons .btn {
        width: 100%;
    }

    .modal-content {
        margin: 20px auto;
        padding: 20px;
    }
    
    .footer-links {
        flex-direction: column;
        gap: 8px;
    }
    
    .footer-links .separator {
        display: none;
    }
}

/* Dark Mode */
.dark-mode {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
}

.dark-mode .navbar,
.dark-mode .freewrite-card,
.dark-mode .stats-card,
.dark-mode .modal-content {
    background: #2d2d44;
    color: #e0e0e0;
}

.dark-mode .game-header h2,
.dark-mode .stats-card h3,
.dark-mode .modal-content h2 {
    color: #e0e0e0;
}

.dark-mode .game-instructions,
.dark-mode .stat-label,
.dark-mode .word-count,
.dark-mode .history-date,
.dark-mode .history-meta,
.dark-mode .setting-description {
    color: #b0b0b0;
}

.dark-mode .prompt-card {
    background: #3a3a52;
    border-color: #4a4a62;
}

.dark-mode .prompt-text {
    color: #e0e0e0;
}

.dark-mode .writing-area {
    background: #3a3a52;
    color: #e0e0e0;
    border-color: #4a4a62;
}

.dark-mode .writing-area:disabled {
    background: #2d2d44;
}

.dark-mode .history-item {
    background: #3a3a52;
}

.dark-mode .history-text {
    color: #e0e0e0;
}

.dark-mode .btn-secondary {
    background: #3a3a52;
    color: #e0e0e0;
    border-color: #4a4a62;
}

.dark-mode .btn-secondary:hover {
    background: #4a4a62;
}

.dark-mode .footer {
    background: rgba(26, 26, 46, 0.95);
}

.dark-mode .footer-links a {
    color: #8a9aef;
}

.dark-mode .footer-links a:hover {
    color: #a8b4f5;
}

.dark-mode .footer-links .separator {
    color: #555;
}

.dark-mode .footer-copyright {
    color: #b0b0b0;
}
