:root {
    --primary-color: #6366f1;
    --primary-gradient: linear-gradient(135deg, #6366f1 0%, #a855f7 100%);
    --bg-color: #f8fafc;
    --card-bg: rgba(255, 255, 255, 0.7);
    --glass-border: rgba(255, 255, 255, 0.4);
    --text-main: #0f172a;
    --text-muted: #64748b;
    --border-color: rgba(226, 232, 240, 0.5);
    --success-color: #10b981;
    --shadow-soft: 0 8px 32px 0 rgba(31, 38, 135, 0.07);
    --glass-blur: blur(12px);
    --transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    --radius-lg: 24px;
    --radius-md: 16px;
    --radius-sm: 12px;
    /* Vibrant Gradient */
    --vibrant-gradient: linear-gradient(135deg, #6366f1 0%, #a855f7 100%);
    color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg-color: #0f172a;
        --card-bg: rgba(30, 41, 59, 0.7);
        --glass-border: rgba(255, 255, 255, 0.1);
        --text-main: #f1f5f9;
        --text-muted: #94a3b8;
        --border-color: rgba(51, 65, 85, 0.5);
        --shadow-soft: 0 8px 32px 0 rgba(0, 0, 0, 0.3);
    }
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background-color: var(--bg-color);
    background-image:
        radial-gradient(at 0% 0%, hsla(253, 16%, 7%, 1) 0, transparent 50%),
        radial-gradient(at 50% 0%, hsla(225, 39%, 30%, 1) 0, transparent 50%),
        radial-gradient(at 100% 0%, hsla(339, 49%, 30%, 1) 0, transparent 50%);
    background-attachment: fixed;
    color: var(--text-main);
    line-height: 1.6;
    min-height: 100vh;
    padding: 20px;
    overflow-x: hidden;
}

/* Background Animation */
.bg-blobs {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    overflow: hidden;
}

.blob {
    position: absolute;
    width: 400px;
    height: 400px;
    background: var(--primary-color);
    filter: blur(80px);
    opacity: 0.15;
    border-radius: 50%;
    animation: move 25s infinite alternate;
}

.blob-1 {
    top: -100px;
    left: -100px;
    background: #6366f1;
    animation-delay: 0s;
}

.blob-2 {
    bottom: -100px;
    right: -100px;
    background: #a855f7;
    animation-delay: -5s;
}

.blob-3 {
    top: 40%;
    left: 30%;
    background: #ec4899;
    animation-delay: -10s;
}

@keyframes move {
    from {
        transform: translate(0, 0) scale(1);
    }

    to {
        transform: translate(100px, 100px) scale(1.2);
    }
}

.container {
    max-width: 800px;
    margin: 0 auto;
    width: 100%;
    flex: 1;
    z-index: 1;
    display: flex;
    flex-direction: column;
}

.app-container {
    background-color: transparent;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    position: relative;
    box-shadow: none;
}

/* Fixed Header */
.app-header {
    position: sticky;
    top: 20px;
    background: var(--card-bg);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    padding: 20px 30px;
    margin-bottom: 20px;
    box-shadow: var(--shadow-soft);
    z-index: 100;
}

.header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    margin-bottom: 0.5rem;
}

.copyright {
    font-size: 0.7rem;
    color: var(--text-muted);
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.version {
    font-size: 0.6rem;
    opacity: 0.8;
}

.language-toggle {
    display: flex;
    gap: 0.5rem;
}

.lang-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid var(--glass-border);
    padding: 8px 12px;
    border-radius: 10px;
    cursor: pointer;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-main);
    backdrop-filter: var(--glass-blur);
    transition: var(--transition);
}

.lang-btn.active {
    background: var(--primary-color);
    color: white;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.app-header h1 {
    font-size: 1.75rem;
    font-weight: 800;
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -0.02em;
    text-align: center;
    margin-bottom: 0.75rem;
}

.score-display {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 0.75rem;
}

.score-box {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    padding: 0.5rem;
    border-radius: var(--radius-sm);
    text-align: center;
    backdrop-filter: var(--glass-blur);
    transition: var(--transition);
}

.score-box.total {
    background: var(--primary-gradient);
    color: white;
    border: none;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.score-box.total .score-label,
.score-box.total .score-value {
    color: white;
}

.score-label {
    display: block;
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 700;
    color: var(--text-muted);
}

.score-value {
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--text-main);
}

/* Main Content (Scrolling) */
main {
    flex: 1;
    padding: 1.5rem;
}

.fim-item {
    background: var(--card-bg);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    padding: 30px;
    border-radius: 20px;
    box-shadow: var(--shadow-soft);
    margin-bottom: 20px;
    transition: var(--transition);
    border: 1px solid var(--glass-border);
    animation: slideUp 0.6s ease-out;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

.item-title-container {
    display: flex;
    align-items: center;
    gap: 10px;
}

.item-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-main);
    letter-spacing: -0.01em;
}

.help-btn {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: 1px solid var(--primary-color);
    background: transparent;
    color: var(--primary-color);
    font-size: 13px;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.help-btn:hover {
    background: var(--primary-color);
    color: white;
}

.help-info {
    font-size: 0.85rem;
    background: var(--primary-light);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 12px;
    margin-bottom: 15px;
    color: var(--text-main);
    line-height: 1.5;
    animation: slideDown 0.3s ease-out;
}

.help-info-section {
    margin-bottom: 6px;
}

.help-info-section:last-child {
    margin-bottom: 0;
}

.help-label {
    font-weight: 700;
    color: var(--primary-dark);
    margin-inline-end: 6px;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.score-select {
    width: 100%;
    padding: 14px 18px;
    border: 2px solid var(--border-color);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.05);
    cursor: pointer;
    font-family: inherit;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-main);
    appearance: none;
    transition: var(--transition);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%236366f1'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    background-size: 1rem;
}

.score-select option {
    background-color: var(--bg-color);
    color: var(--text-main);
}

.score-select:focus {
    outline: none;
    border-color: var(--primary-color);
    background: rgba(99, 102, 241, 0.05);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.score-select:hover {
    border-color: var(--primary-color);
}

/* RTL Support */
html[dir="rtl"] .score-select {
    background-position: left 1rem center;
}

/* Buttons */
.primary-btn {
    width: 100%;
    padding: 1rem;
    background: var(--vibrant-gradient);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    font-size: 1.1rem;
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: 0 8px 16px rgba(99, 102, 241, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.primary-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.4);
}

.primary-btn:active {
    transform: translateY(0);
}

/* Footer */
.app-footer {
    padding: 1.5rem;
    background-color: white;
    border-top: 1px solid var(--border-color);
    text-align: center;
}

.app-footer p {
    margin-top: 1rem;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Mobile Tweak */
@media (min-width: 600px) {
    .app-container {
        margin: 2rem auto;
        border-radius: 20px;
        min-height: calc(100vh - 4rem);
    }

    .app-header {
        border-radius: 20px 20px 0 0;
    }

    main {
        padding: 2rem;
    }
}

/* Modal Styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    backdrop-filter: blur(4px);
    animation: fadeIn 0.3s ease-out;
}

.modal-content {
    background-color: white;
    padding: 2rem;
    border-radius: var(--radius-md);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
    width: 90%;
    max-width: 400px;
    position: relative;
    text-align: center;
    animation: scaleUp 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.close-btn {
    position: absolute;
    top: 10px;
    right: 15px;
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--text-secondary);
    cursor: pointer;
    transition: color 0.2s;
}

.close-btn:hover {
    color: var(--primary-color);
}

.modal-header {
    margin-bottom: 1rem;
}

.modal-score-value {
    font-size: 3rem;
    font-weight: 800;
    color: var(--primary-color);
    line-height: 1;
}

.modal-meaning {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-main);
    margin: 0;
}

@keyframes scaleUp {
    from {
        opacity: 0;
        transform: scale(0.8);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

.score-box.total {
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.score-box.total:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.score-box.total:active {
    transform: translateY(0);
}

/* README Modal Specifics */
.modal-content.readme-modal {
    max-width: 800px;
    width: 95%;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    padding: 1.5rem;
}

.readme-body {
    text-align: left;
    overflow-y: auto;
    padding: 1rem;
    background: #fdfdfd;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    font-size: 0.9rem;
    line-height: 1.6;
}

.readme-body h1,
.readme-body h2,
.readme-body h3 {
    color: var(--primary-dark);
    margin-top: 1.2rem;
    margin-bottom: 0.6rem;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.3rem;
}

.readme-body h1 {
    font-size: 1.4rem;
}

.readme-body h2 {
    font-size: 1.2rem;
}

.readme-body h3 {
    font-size: 1.1rem;
}

.readme-body p {
    margin-bottom: 1rem;
}

.readme-body ul,
.readme-body ol {
    margin-bottom: 1rem;
    padding-left: 1.5rem;
}

.readme-body li {
    margin-bottom: 0.4rem;
}

.readme-body code {
    background: #f3f4f6;
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    font-family: monospace;
    font-size: 0.85rem;
}

html[dir="rtl"] .readme-body {
    text-align: right;
}

/* FIM Progress Bar Styles */
.fim-progress-container {
    margin: 20px 0;
    position: relative;
    padding-bottom: 24px;
    /* Reduced to fit closer */
}

.range-labels {
    display: flex;
    justify-content: space-between;
    margin-top: 2px;
    /* Much closer to the bar */
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--text-secondary);
    padding: 0;
}

.range-labels span {
    position: relative;
}

.fim-progress-bar {
    display: flex;
    height: 12px;
    border-radius: 6px;
    overflow: hidden;
    background: #e5e7eb;
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.range-segment {
    height: 100%;
    transition: opacity 0.3s;
}

/* Segment Colors (Red to Green) */
.range-18-35 {
    background-color: #ef4444;
    flex: 18;
}

.range-36-53 {
    background-color: #f97316;
    flex: 18;
}

.range-54-71 {
    background-color: #facc15;
    flex: 18;
}

.range-72-89 {
    background-color: #a3e635;
    flex: 18;
}

.range-90-107 {
    background-color: #22c55e;
    flex: 18;
}

.range-108-126 {
    background-color: #15803d;
    flex: 19;
}

.score-marker-line {
    position: absolute;
    top: -4px;
    bottom: 25px;
    width: 3px;
    background-color: var(--text-main);
    z-index: 10;
    border-radius: 2px;
    inset-inline-start: 0;
    transition: inset-inline-start 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.score-marker-line::after {
    content: '';
    position: absolute;
    top: -8px;
    left: 50%;
    transform: translateX(-50%);
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-top: 8px solid var(--text-main);
}

.significance-text {
    font-size: 1rem;
    color: var(--text-secondary);
    margin-top: 8px;
    font-style: italic;
    line-height: 1.4;
}

.independence-label {
    margin-top: 15px;
    display: block;
}