:root {
    /* Warm Earthy Desert Twilight Dark Night Theme Variables */
    --bg-base: #151538; /* Deep Indigo Twilight Base */
    --bg-surface: #1e1e45; /* Soft Indigo Surface */
    --bg-surface-hover: #272757; /* Exact Indigo (#272757) on Card Hover */
    --border-color: #2f2f63;
    --border-hover: #424285;
    
    --text-primary: #f5ede4; /* Sandy Cream */
    --text-secondary: #c9c9f0; /* Muted Twilight */
    --text-muted: #8484ba;
    
    --accent-emerald: #e27e58; /* Warm Terracotta Accent */
    --accent-emerald-hover: #cd6740;
    --accent-emerald-light: rgba(226, 126, 88, 0.12);
    
    --accent-gold: #9bb297; /* Soft Sage Green Accent */
    --accent-gold-light: rgba(155, 178, 151, 0.12);
    
    --accent-red: #d65f41; /* Clay Rust */
    --accent-red-light: rgba(214, 95, 65, 0.12);
    
    --glow-orb-1: rgba(226, 126, 88, 0.1);
    --glow-orb-2: rgba(39, 39, 87, 0.25); /* Indigo Glow Orb */
    
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-full: 9999px;
    
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --transition-smooth: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Warm Sandy Desert Light Theme Variables */
body.light-theme {
    --bg-base: #f5f0e6; /* Sandy Beige */
    --bg-surface: #fbf9f4; /* Desert Gypsum Cream */
    --bg-surface-hover: rgba(39, 39, 87, 0.08); /* Soft Brand Indigo Tint (#272757) */
    --border-color: #e3dbcc;
    --border-hover: #cfc3b0;
    
    --text-primary: #272757; /* Deep Indigo (#272757) for Premium Legible Contrast */
    --text-secondary: #494980; /* Soft Indigo */
    --text-muted: #7474a6;
    
    --accent-emerald: #d96b43; /* Terracotta Accent */
    --accent-emerald-hover: #c2562f;
    --accent-emerald-light: rgba(217, 107, 67, 0.08);
    
    --accent-gold: #768c72; /* Green Sage Accent */
    --accent-gold-light: rgba(118, 140, 114, 0.08);
    
    --accent-red: #b85135;
    --accent-red-light: rgba(184, 81, 53, 0.08);
    
    --glow-orb-1: rgba(217, 107, 67, 0.06);
    --glow-orb-2: rgba(39, 39, 87, 0.08); /* Indigo Glow Orb */
}

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

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background-color: var(--bg-base);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow-x: hidden;
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* Background Glowing Orbs */
.bg-effects {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: -10;
    overflow: hidden;
    pointer-events: none;
}

.orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(120px);
    opacity: 0.8;
}

.orb-1 {
    width: 500px;
    height: 500px;
    background: var(--glow-orb-1);
    top: -150px;
    left: -150px;
}

.orb-2 {
    width: 600px;
    height: 600px;
    background: var(--glow-orb-2);
    bottom: -200px;
    right: -150px;
}

/* Typography & Layout */
.container {
    width: 92%;
    max-width: 1000px;
    margin: 0 auto;
}

main {
    padding-bottom: 3.5rem; /* 1.5 cm gap before footer using light background space */
}

/* Navbar styles */
.navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 0;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 1.5rem;
}

.brand {
    font-size: 1.875rem;
    font-weight: 800;
    text-decoration: none;
    color: var(--text-primary);
    letter-spacing: -0.5px;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.brand span {
    color: var(--accent-emerald);
}

.nav-actions {
    display: flex;
    align-items: center;
    gap: 1.25rem;
}

.theme-toggle, .menu-trigger {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem;
    border-radius: var(--radius-sm);
    transition: var(--transition-smooth);
}

.theme-toggle:hover, .menu-trigger:hover {
    color: #ffffff;
    background-color: #98A869;
}

.menu-text {
    font-size: 0.95rem;
    font-weight: 600;
    margin-right: 0.35rem;
}

/* Sidebar Menu */
.sidenav {
    position: fixed;
    top: 0;
    right: -320px;
    width: 300px;
    height: 100vh;
    background-color: var(--bg-surface);
    border-left: 1px solid var(--border-color);
    z-index: 1000;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    box-shadow: -10px 0 30px rgba(0,0,0,0.25);
    transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow-y: auto;
}

.sidenav.active {
    right: 0;
}

.sidenav-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.sidenav-header h3 {
    font-size: 1.1rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.sidenav-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 1.5rem;
}

.sidenav-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.sidenav-section-title {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--text-muted);
    margin-top: 1rem;
    margin-bottom: 0.25rem;
    padding-left: 1rem;
}

.sidenav-link {
    display: block;
    padding: 0.75rem 1rem;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
    transition: var(--transition-smooth);
}

.sidenav-link:hover, .sidenav-link.active {
    color: #ffffff;
    background-color: #98A869;
    padding-left: 1.25rem;
}

.overlay-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(4px);
    z-index: 999;
    display: none;
}

.overlay-backdrop.active {
    display: block;
}

/* Header Text */
.page-title-section {
    text-align: center;
    margin-bottom: 1.25rem;
}

.page-title-section h1 {
    font-size: 2.25rem;
    font-weight: 800;
    letter-spacing: -1px;
    margin-bottom: 0.5rem;
}

.page-title-section p {
    color: var(--text-secondary);
    font-size: 1rem;
}

/* Main Cards / Forms */
.panel {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow-lg);
    margin-bottom: 1.25rem;
    transition: border-color 0.3s ease;
}

.panel:hover {
    border-color: var(--border-hover);
}

.unscramble-form {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.input-container {
    display: flex;
    align-items: center;
    background-color: var(--bg-base);
    border: 2px solid var(--border-color);
    border-radius: 9999px; /* Pill capsule shape */
    padding: 0.35rem 0.35rem 0.35rem 1.5rem;
    transition: var(--transition-smooth);
    width: 100%;
    position: relative;
}

.input-container:focus-within {
    border-color: var(--accent-emerald);
    box-shadow: 0 0 0 4px var(--accent-emerald-light);
}

.main-input {
    flex: 1;
    background: none;
    border: none;
    padding: 0.6rem 0;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.main-input::placeholder {
    text-transform: none;
    font-weight: 400;
    color: var(--text-muted);
}

.main-input:focus {
    outline: none;
}

.clear-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1.3rem;
    padding: 0.5rem 0.75rem;
    display: none;
    transition: var(--transition-smooth);
    margin-right: 0.25rem;
}

.clear-btn:hover {
    color: var(--text-primary);
}

.clear-btn.active {
    display: block;
}

.submit-btn {
    background-color: var(--accent-emerald);
    color: white;
    border: none;
    border-radius: 9999px; /* Rounded pill button */
    padding: 0.65rem 1.75rem;
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition-smooth);
    height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.submit-btn:hover {
    background-color: var(--accent-emerald-hover);
    transform: translateY(-1px);
}

.options-toggle-btn {
    background: none;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 0.75rem 1.25rem;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: var(--transition-smooth);
    width: fit-content;
}

.options-toggle-btn:hover {
    color: var(--text-primary);
    border-color: var(--border-hover);
    background-color: var(--bg-surface-hover);
}

/* Light Theme outline button overrides to utilize #272757 */
body.light-theme .options-toggle-btn {
    border-color: rgba(39, 39, 87, 0.3);
    color: #272757;
}

body.light-theme .options-toggle-btn:hover {
    border-color: #272757;
    background-color: rgba(39, 39, 87, 0.08);
}

/* Expandable Drawer */
.expandable-panel {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s cubic-bezier(0, 1, 0, 1);
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    padding-top: 0;
}

.expandable-panel.active {
    max-height: 1000px;
    padding-top: 1rem;
    transition: max-height 0.45s cubic-bezier(1, 0, 1, 0);
}

.fields-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
}

@media (max-width: 500px) {
    .fields-grid {
        grid-template-columns: 1fr;
    }
}

.field-group {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.field-group label {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.field-input, .field-select {
    background-color: var(--bg-base);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 0.75rem 1rem;
    font-size: 0.95rem;
    color: var(--text-primary);
    transition: var(--transition-smooth);
    width: 100%;
}

.field-input {
    text-transform: uppercase;
}

.field-input::placeholder {
    text-transform: none;
    color: var(--text-muted);
}

.field-input:focus, .field-select:focus {
    outline: none;
    border-color: var(--accent-emerald);
}

/* Point Comparison Badges */
.points-bar {
    display: flex;
    gap: 1rem;
    padding: 1rem 0;
    border-top: 1px solid var(--border-color);
    margin-top: 0.5rem;
}

.pts-tile-preview {
    font-size: 0.85rem;
    background-color: var(--bg-base);
    border: 1px solid var(--border-color);
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
}

.pts-tile-preview strong {
    color: var(--accent-gold);
}

/* Skeleton Loading Loader */
.skeleton-loader {
    display: none;
    flex-direction: column;
    gap: 1rem;
    margin-top: 1.5rem;
}

.skeleton-loader.active {
    display: flex;
}

.skel-card {
    height: 120px;
    background: linear-gradient(90deg, var(--bg-surface) 25%, var(--bg-surface-hover) 50%, var(--bg-surface) 75%);
    background-size: 200% 100%;
    animation: loading-pulse 1.5s infinite;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}

@keyframes loading-pulse {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Word Results Grid */
.results-container {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.result-section {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
}

.result-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.75rem;
    margin-bottom: 1.25rem;
}

.result-section-header h3 {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-secondary);
}

.word-count-badge {
    font-size: 0.75rem;
    background-color: var(--bg-base);
    border: 1px solid var(--border-color);
    padding: 0.25rem 0.6rem;
    border-radius: var(--radius-full);
    color: var(--text-muted);
}

.words-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 0.75rem;
}

.word-card {
    background-color: var(--bg-base);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 0.6rem 0.85rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    transition: var(--transition-smooth);
    user-select: none;
    text-decoration: none;
    color: inherit;
}

.word-card:hover {
    border-color: var(--accent-emerald);
    background-color: var(--bg-surface-hover);
    transform: translateY(-1px);
}

.word-card-text {
    font-weight: 700;
    letter-spacing: 0.5px;
    font-size: 0.95rem;
    text-transform: uppercase;
}

.word-card-score {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--accent-gold);
    background-color: var(--accent-gold-light);
    border: 1px solid rgba(245, 158, 11, 0.2);
    padding: 0.15rem 0.4rem;
    border-radius: var(--radius-sm);
}

/* Info Description Text */
.about-section {
    margin-top: 2rem;
    border-top: 1px solid var(--border-color);
    padding-top: 1.5rem;
    font-size: 0.95rem;
    color: var(--text-secondary);
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.about-section h2, .about-section h3 {
    color: var(--text-primary);
    font-weight: 800;
    letter-spacing: -0.5px;
    margin-top: 0.5rem;
}

.about-section p {
    line-height: 1.8;
}

.about-section ul {
    padding-left: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.about-section a {
    color: var(--accent-emerald);
    text-decoration: none;
}

.about-section a:hover {
    text-decoration: underline;
}

/* Footer Section */
.footer {
    margin-top: auto;
    padding: 3rem 0 2rem 0;
    border-top: 1px solid var(--border-color);
    background-color: #272757;
    /* Force light colors inside footer regardless of active theme */
    --text-primary: #f5ede4;
    --text-secondary: #d1c4b6;
    --text-muted: #9e8e7f;
    --border-color: rgba(245, 237, 228, 0.15);
}

.footer-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 2rem;
    margin-bottom: 2rem;
}

@media (max-width: 580px) {
    .footer-grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
        text-align: center;
    }
}

.footer-column {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.footer-column h4 {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 2px;
    margin-bottom: 0.5rem;
    transition: color 0.3s ease;
}

.footer-column:hover h4 {
    color: var(--text-primary);
}

.footer-column ul {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.footer-column a {
    font-size: 0.8rem;
    color: var(--text-secondary);
    text-decoration: none;
    transition: var(--transition-smooth);
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.footer-column a::before {
    content: '';
    display: inline-block;
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background-color: var(--accent-emerald);
    opacity: 0;
    transform: scale(0);
    transition: var(--transition-smooth);
}

.footer-column a:hover {
    color: #ffffff;
    padding-left: 0.25rem;
}

.footer-column a:hover::before {
    opacity: 1;
    transform: scale(1);
}

@media (max-width: 580px) {
    .footer-column a {
        justify-content: center;
    }
    .footer-column a:hover {
        padding-left: 0;
    }
}

.footer-bottom {
    text-align: center;
    font-size: 0.75rem;
    color: var(--text-muted);
    border-top: 1px solid var(--border-color);
    padding-top: 1.25rem;
    margin-top: 1.5rem;
    letter-spacing: 0.2px;
}

/* Slide-out Definition Drawer */
.def-drawer {
    position: fixed;
    bottom: -100%;
    left: 0;
    width: 100vw;
    max-height: 70vh;
    background-color: var(--bg-surface);
    border-top: 1px solid var(--border-color);
    z-index: 1010;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    box-shadow: 0 -10px 30px rgba(0,0,0,0.3);
    transition: bottom 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow-y: auto;
}

@media (min-width: 680px) {
    .def-drawer {
        top: 0;
        bottom: 0;
        right: -420px;
        left: auto;
        width: 400px;
        max-height: 100vh;
        border-top: none;
        border-left: 1px solid var(--border-color);
        border-radius: 0;
        transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }
    .def-drawer.active {
        right: 0;
        bottom: auto;
    }
}

.def-drawer.active {
    bottom: 0;
}

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

.def-word-title {
    font-size: 1.5rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.def-scores {
    display: flex;
    gap: 0.75rem;
    margin-top: 0.5rem;
}

.def-score-badge {
    font-size: 0.75rem;
    background-color: var(--bg-base);
    border: 1px solid var(--border-color);
    padding: 0.25rem 0.6rem;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
}

.def-close-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 1.25rem;
    padding: 0.5rem;
}

.def-drawer-content {
    padding: 1.5rem;
}

.def-loading {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    align-items: center;
    color: var(--text-muted);
    padding: 2rem 0;
}

.def-dict-badges {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.dict-badge {
    font-size: 0.75rem;
    font-weight: 700;
    padding: 0.35rem 0.75rem;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.dict-badge.valid {
    background-color: var(--accent-emerald-light);
    border: 1px solid rgba(16, 185, 129, 0.2);
    color: var(--accent-emerald);
}

.dict-badge.invalid {
    background-color: var(--accent-red-light);
    border: 1px solid rgba(239, 68, 68, 0.2);
    color: var(--accent-red);
}

.def-meaning-group {
    margin-bottom: 1.5rem;
}

.def-meaning-part {
    font-size: 0.85rem;
    font-weight: 800;
    text-transform: uppercase;
    color: var(--accent-emerald);
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.25rem;
    margin-bottom: 0.75rem;
}

.def-meaning-list {
    padding-left: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    color: var(--text-secondary);
}

.def-meaning-list li::marker {
    color: var(--text-muted);
}

.def-meaning-example {
    display: block;
    margin-top: 0.25rem;
    font-style: italic;
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* Wordle Input Grids */
.wordle-grid-container {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.wordle-row {
    display: flex;
    justify-content: space-between;
    gap: 0.75rem;
    max-width: 320px;
    margin: 0.5rem auto;
    width: 100%;
}

.wordle-box-input {
    flex: 1;
    height: 54px;
    background-color: var(--bg-base);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    text-align: center;
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--text-primary);
    text-transform: uppercase;
    transition: var(--transition-smooth);
}

.wordle-box-input:focus {
    outline: none;
    border-color: var(--accent-emerald);
    box-shadow: 0 0 0 3px var(--accent-emerald-light);
}

.wordle-box-input.filled {
    border-color: var(--accent-emerald);
    background-color: var(--accent-emerald-light);
}

/* Table Styles */
.seo-table-container {
    overflow-x: auto;
    margin: 1rem 0;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}

.seo-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
    background-color: var(--bg-surface);
}

.seo-table th, .seo-table td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.seo-table th {
    background-color: rgba(39, 39, 87, 0.05); /* Soft Brand Indigo Tint */
    color: var(--text-primary);
    font-weight: 700;
}

body.light-theme .seo-table th {
    background-color: #272757;
    color: #fbf9f4; /* Gypsum Cream text */
}

.seo-table tr:last-child td {
    border-bottom: none;
}

.seo-table td {
    color: var(--text-secondary);
}

.seo-table tr:hover td {
    background-color: var(--bg-surface-hover);
    color: var(--text-primary);
}

/* Custom Scrollbar Styles to integrate with brand colors */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: var(--bg-base);
}
::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: var(--radius-full);
}
::-webkit-scrollbar-thumb:hover {
    background: var(--border-hover);
}
