:root {
    --bg-dark: #0f111a;
    --card-bg: rgba(25, 28, 41, 0.65);
    --card-border: rgba(255, 255, 255, 0.1);
    --text-main: #f8f9fa;
    --text-muted: #a0a4b8;
    --primary: #6b4cff;
    --primary-hover: #8367ff;
    --success: #20c997;
    --warning: #ffb800;
    --error: #ff4b72;
    --font-main: 'Outfit', sans-serif;
    --aurora-1: #6b4cff;
    --aurora-2: #00d2ff;
    --aurora-3: #ff4b72;
}

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

body {
    font-family: var(--font-main);
    background-color: var(--bg-dark);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    overflow-x: hidden;
    overflow-y: auto;
    position: relative;
}

.background-aurora {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    overflow: hidden;

}

.background-aurora::before,
.background-aurora::after {
    content: '';
    position: absolute;
    width: 800px;
    height: 800px;
    border-radius: 50%;
    opacity: 0.6;
}

.background-aurora::before {
    background: radial-gradient(circle, var(--aurora-1) 0%, transparent 70%);
    top: -200px;
    left: -200px;
}

.background-aurora::after {
    background: radial-gradient(circle, var(--aurora-2) 0%, transparent 70%);
    bottom: -200px;
    right: -200px;
}

.app-container {
    width: 90%;
    max-width: 500px;
    display: flex;
    flex-direction: column;
    gap: 0;
    z-index: 10;
    margin-top: 60px; /* Exact height of the fixed header */
}

.hidden {
    display: none !important;
}

header.sticky-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 15px;
    height: 60px;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    background: rgba(10, 14, 39, 0.95);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    margin-bottom: 0;
}

.header-left, .header-actions {
    flex: 1;
}

.header-center {
    flex: 2;
    display: flex;
    justify-content: center;
    align-items: center;
}

.header-actions {
    justify-content: flex-end;
}

.header-left, .header-actions {
    flex: 1;
}

.header-center {
    flex: 2; /* More space for stats */
    display: flex;
    justify-content: center;
    align-items: center;
}

.header-actions {
    justify-content: flex-end;
}

.header-stats {
    display: flex;
    gap: 15px;
    align-items: center;
    font-weight: 800;
    font-size: 1.1rem;
}

.stat-mini {
    display: flex;
    align-items: center;
    gap: 4px;
}
.stat-mini.success { color: var(--success); }
.stat-mini.error { color: var(--error); }

.header-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 15px;
}

.header-left {
    display: flex;
    justify-content: flex-start;
}

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

.icon-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    transition: color 0.3s ease, transform 0.3s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    padding: 0;
}

.icon-btn:active {
    color: var(--text-main);
    transform: rotate(15deg) scale(1.1);
}

h1 {
    font-size: 1.6rem;
    font-weight: 800;
    background: linear-gradient(135deg, #fff, #a0a4b8);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -0.5px;
}

.card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 20px;
    padding: 25px 30px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    display: flex;
    flex-direction: column;
    align-items: center;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.stats-panel {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    padding: 15px 25px;
    gap: 15px;
}

.stat-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.stat-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    font-weight: 600;
}

.stat-value {
    font-size: 1.4rem;
    font-weight: 800;
    color: var(--text-main);
}

.stat-value.success {
    color: var(--success);
}

.stat-value.error {
    color: var(--error);
}

.global-stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-top: 10px;
}

.global-stats-grid .stat-box {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 12px;
    padding: 20px;
    border: 1px solid var(--card-border);
}

.challenge-info {
    display: flex;
    gap: 12px;
    width: 100%;
    justify-content: center;
    margin-bottom: 15px;
    flex-wrap: wrap;
    align-items: center;
}

.pronoun-badge {
    padding: 6px 16px;
    border-radius: 30px;
    font-size: 0.9rem;
    font-weight: 800;
    color: #fff;
    background: rgba(107, 76, 255, 0.3);
    border: 2px solid var(--primary);
    box-shadow: 0 4px 15px rgba(107, 76, 255, 0.4);
    text-transform: lowercase;
}

.tense-badge {
    padding: 6px 16px;
    border-radius: 30px;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-muted);
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--card-border);
}

.verb-display {
    font-size: clamp(1.5rem, 8vw, 3rem);
    font-weight: 800;
    margin-bottom: 30px;
    color: #fff;
    text-shadow: 0 0 20px rgba(255, 255, 255, 0.2);
    text-align: center;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
}

.irregular-badge {
    font-size: 0.35em;
    color: var(--error);
    align-self: flex-start;
    margin-top: 0.2em;
}

.special-chars-keyboard {
    display: flex;
    justify-content: center;
    gap: 6px;
    margin-bottom: 12px;
}

.char-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--card-border);
    color: var(--text-color);
    font-size: 1.1rem;
    padding: 8px 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.char-btn:hover {
    background: rgba(255, 255, 255, 0.15);
}

.char-btn:active {
    transform: scale(0.95);
    background: rgba(255, 255, 255, 0.25);
}

.input-wrapper {
    width: 100%;
    position: relative;
    margin-bottom: 20px;
}

.inline-input {
    display: flex;
    align-items: stretch;
    gap: 10px;
}

.inline-input input[type="text"] {
    flex-grow: 1;
    width: 10px; /* Let flex-grow handle the width */
}

.submit-arrow {
    width: 60px !important;
    padding: 0;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

#answer-input {
    flex: 1;
    background: transparent;
    border: 1px solid var(--card-border);
    border-radius: 12px;
    padding: 12px 15px;
    color: var(--text-main);
    font-size: 1.1rem;
    outline: none;
    transition: all 0.3s ease;
    min-width: 0;
    scroll-margin-top: 70px; /* Aligns input perfectly below the 60px header */
}

input[type="text"]:focus {
    border-color: var(--primary);
    background: rgba(0, 0, 0, 0.4);
    box-shadow: 0 0 15px rgba(107, 76, 255, 0.3);
}

.feedback-icon {
    font-size: 1.5rem;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    margin-right: 8px;
    display: none; /* Hidden by default */
}

.feedback-container {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    min-height: 45px;
}

.feedback-icon.show {
    display: inline-block;
    transform: scale(1);
}

.feedback-message {
    text-align: center;
    min-height: 24px;
    font-weight: 600;
    font-size: 1rem;
    opacity: 0;
    transform: translateY(10px);
    transition: all 0.3s ease;
}

.feedback-message.show {
    opacity: 1;
    transform: translateY(0);
}

.feedback-message.success {
    color: var(--success);
}

.feedback-message.error {
    color: var(--error);
}
.feedback-message.warning {
    color: var(--warning);
}

.tilde-hint-btn {
    background: rgba(255, 184, 0, 0.1);
    border: 1px solid var(--warning);
    color: var(--warning);
    border-radius: 6px;
    padding: 2px 10px;
    font-size: 1.1rem;
    font-weight: 800;
    cursor: pointer;
    margin-left: 8px;
    transition: all 0.2s ease;
    box-shadow: 0 0 12px rgba(255, 184, 0, 0.5); /* Yellow glowing halo */
}
.tilde-hint-btn:hover {
    background: rgba(255, 184, 0, 0.2);
    transform: scale(1.05);
}

.btn {
    width: 100%;
    padding: 16px;
    border: none;
    border-radius: 16px;
    font-family: var(--font-main);
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
}

.primary-btn {
    background: linear-gradient(135deg, var(--primary), #5235cc);
    color: white;
    box-shadow: 0 8px 20px rgba(107, 76, 255, 0.3);
}

.primary-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 25px rgba(107, 76, 255, 0.4);
}

.primary-btn:active {
    transform: translateY(1px);
}

.danger-btn {
    background: rgba(255, 75, 114, 0.15);
    color: var(--error);
    border: 1px solid var(--error);
    box-shadow: 0 4px 10px rgba(255, 75, 114, 0.2);
}

.danger-btn:hover {
    background: var(--error);
    color: white;
}

.secondary-btn {
    background: rgba(255, 177, 0, 0.15);
    color: #ffb100;
    border: 1px dashed rgba(255, 177, 0, 0.5);
    box-shadow: 0 4px 10px rgba(255, 177, 0, 0.1);
}

.secondary-btn:hover {
    background: #ffb100;
    color: #0f111a;
    border: 1px solid #ffb100;
}

.gold-btn {
    background: rgba(255, 177, 0, 0.2);
    color: #ffb100;
    border: 1px solid #ffb100;
    box-shadow: 0 4px 10px rgba(255, 177, 0, 0.15);
}

.gold-btn:hover {
    background: #ffb100;
    color: #0f111a;
}

.small-btn {
    padding: 6px 12px;
    font-size: 0.85rem;
    border-radius: 8px;
    width: auto;
}

/* Modals */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(5px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.modal.show {
    opacity: 1;
    pointer-events: all;
}

.modal-content {
    width: 90%;
    max-width: 600px;
    max-height: 85vh;
    padding: 30px;
    align-items: stretch;
    transform: translateY(20px);
}

.modal.show .modal-content {
    transform: translateY(0);
}

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

.modal-header h2 {
    font-size: 1.5rem;
    color: #fff;
}

.modal-header .icon-btn {
    font-size: 2rem;
    line-height: 1;
    margin: 0;
}

/* Scrollbars */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
}

/* Grid specific to Tenses/Modals */
.level-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-main);
    padding: 8px 16px;
    border-radius: 20px;
    cursor: pointer;
    font-family: 'Outfit', sans-serif;
    font-weight: 600;
    font-size: 0.9rem;
    transition: all 0.2s ease;
}

.level-btn:hover {
    background: var(--primary);
    border-color: var(--primary);
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(107, 76, 255, 0.3);
}

.level-btn.active {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

.tenses-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 12px;
    overflow-y: auto;
    padding-right: 10px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-size: 0.95rem;
    color: var(--text-muted);
    transition: color 0.2s;
    user-select: none;
}

.checkbox-label:hover {
    color: var(--text-main);
}

.checkbox-label input[type="checkbox"] {
    appearance: none;
    width: 20px;
    height: 20px;
    border: 2px solid var(--text-muted);
    border-radius: 6px;
    background: transparent;
    cursor: pointer;
    position: relative;
    transition: all 0.2s;
}

.checkbox-label input[type="checkbox"]:checked {
    background: var(--primary);
    border-color: var(--primary);
}

.checkbox-label input[type="checkbox"]:checked::after {
    content: '✓';
    position: absolute;
    color: white;
    font-size: 14px;
    left: 4px;
    top: -1px;
}

/* Summary Card */
.summary-card {
    align-items: stretch;
    max-height: 80vh;
    overflow: hidden;
}

.summary-title {
    font-size: 1.8rem;
    text-align: center;
    margin-bottom: 5px;
}

.text-muted {
    color: var(--text-muted);
    text-align: center;
    font-size: 0.95rem;
    margin-bottom: 20px;
}

.mistakes-list {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding-right: 5px;
}

.mistake-item {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--card-border);
    border-radius: 12px;
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.mistake-header {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.verb-name {
    color: var(--text-main);
    font-weight: 600;
    font-size: 1rem;
    text-transform: uppercase;
}

.mistake-body {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(25, 28, 41, 0.4);
    padding: 8px 12px;
    border-radius: 8px;
}

.user-typed {
    color: var(--error);
    text-decoration: line-through;
    font-weight: 600;
}

.correct-ans {
    color: var(--success);
    font-weight: 600;
}

/* Database Section */
.db-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    overflow-y: auto;
    padding-right: 10px;
    max-height: 50vh;
}

.db-item {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--card-border);
    border-radius: 12px;
    overflow: hidden;
}

.db-item summary {
    padding: 15px 20px;
    cursor: pointer;
    font-weight: 800;
    font-size: 1.2rem;
    color: var(--text-main);
    list-style: none;
    display: flex;
    justify-content: space-between;
    transition: background 0.2s;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.db-item summary::-webkit-details-marker {
    display: none;
}

.db-item summary:hover {
    background: rgba(255, 255, 255, 0.05);
}

.db-item summary::after {
    content: '+';
    color: var(--primary);
    font-size: 1.5rem;
}

.db-item[open] summary::after {
    content: '-';
}

.db-details-content {
    padding: 0 20px 20px 20px;
}

.db-tense-section {
    margin-top: 15px;
}

.db-tense-title {
    font-size: 0.85rem;
    color: var(--primary);
    border-bottom: 1px solid var(--card-border);
    padding-bottom: 5px;
    margin-bottom: 10px;
    text-transform: uppercase;
}

.db-pronoun-row {
    display: flex;
    justify-content: space-between;
    font-size: 0.95rem;
    padding: 4px 0;
    border-bottom: 1px dashed rgba(255, 255, 255, 0.05);
}

.db-pronoun {
    color: var(--text-muted);
}

.db-conjugation {
    color: var(--success);
    font-weight: 600;
}

.success-btn {
    background: rgba(32, 201, 151, 0.15);
    color: var(--success);
    border: 1px solid var(--success);
    box-shadow: 0 4px 10px rgba(32, 201, 151, 0.2);
}

.success-btn:hover {
    background: var(--success);
    color: white;
}

.chart-bar-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    align-items: center;
    height: 100%;
}

.chart-bar {
    width: 100%;
    max-width: 25px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px 4px 0 0;
    display: flex;
    flex-direction: column-reverse;
    /* Builds from bottom */
    overflow: hidden;
    position: relative;
    transition: height 0.3s ease;
}

.chart-bar .correct-segment {
    background: var(--success);
    width: 100%;
    transition: height 0.3s ease;
}

.chart-bar .incorrect-segment {
    background: var(--error);
    width: 100%;
    transition: height 0.3s ease;
}

.chart-time-label {
    font-size: 0.6rem;
    color: #ffb100;
    font-weight: 800;
    margin-bottom: 2px;
    text-align: center;
}

.chart-date-label {
    font-size: 0.65rem;
    color: var(--text-muted);
    margin-top: 6px;
    text-align: center;
}

/* Mobile & Short Screen Optimizations */
@media (max-width: 600px),
(max-height: 850px) {
    :root {
        --container-padding: 10px;
    }

    header h1 {
        display: none;
    }

    /* Hide big logo to save space */
    header {
        justify-content: flex-end;
        padding: 5px 0;
        margin-bottom: 5px;
    }

    .header-actions {
        width: 100%;
        justify-content: flex-end;
        gap: 8px;
    }

    .btn.small-btn {
        padding: 4px 10px;
        font-size: 0.75rem;
    }

    .question-card {
        padding: 15px;
        margin: 5px 0;
    }

    #verb-display {
        margin-bottom: 2px;
    }

    .badge-container {
        margin-bottom: 8px;
        gap: 5px;
    }

    .badge {
        padding: 3px 8px;
        font-size: 0.7rem;
    }

    #answer-input {
        padding: 10px;
        font-size: 1rem;
        margin-bottom: 10px;
    }

    /* Flatten stats bar on mobile */
    .stats-panel-grid {
        display: flex;
        justify-content: space-around;
        gap: 5px;
        margin-bottom: 5px;
        padding: 5px;
    }

    .stat-item {
        padding: 5px;
        background: none;
        box-shadow: none;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    }

    .stat-item .label {
        font-size: 0.6rem;
        opacity: 0.7;
    }

    .stat-item .value {
        font-size: 1rem;
    }

    #daily-chart {
        height: 80px !important;
    }
}

@media (max-height: 600px) {
    .stats-panel-grid {
        display: none;
    }
}

/* Animations */
@keyframes shake {

    0%,
    100% {
        transform: translateX(0);
    }

    10%,
    30%,
    50%,
    70%,
    90% {
        transform: translateX(-5px);
    }

    20%,
    40%,
    60%,
    80% {
        transform: translateX(5px);
    }
}

.shake {
    animation: shake 0.5s ease-in-out;
}

@keyframes popIn {
    0% {
        transform: scale(0.9);
        opacity: 0;
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.pop-in {
    animation: popIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* Hide the default "x" clear button on search inputs */
input[type="search"]::-webkit-search-decoration,
input[type="search"]::-webkit-search-cancel-button,
input[type="search"]::-webkit-search-results-button,
input[type="search"]::-webkit-search-results-decoration {
  display: none;
}