@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@400;700&display=swap&subset=latin-ext');

:root {
    --brand-primary: #ffce00; /* German Flag Yellow */
    --brand-accent: #dd0000;  /* German Flag Red */
    --brand-dark: #1a1a1a;    /* Deep Charcoal */
    --bg-color: #f7f9fc;
    --text-color: #2d3436;
    --card-bg: #ffffff;
    --success: #27ae60;
    --error: #c0392b;
    --filter-bg: #ffffff;
    --badge-bg: #f1f2f6;
    --input-border: #dfe6e9;
    --icon-hover: #f1f2f6;
    --stat-label: #636e72;
    --divider-color: #dfe6e9;
    
    /* Legacy alias mappings */
    --sv-blue: var(--brand-accent);
    --sv-yellow: var(--brand-primary);
    --falun-red: #c0392b;
}

* {
    box-sizing: border-box;
}

body.dark {
    --bg-color: #0f1011 !important;
    --text-color: #ecf0f1 !important;
    --card-bg: #1c1e21 !important;
    --filter-bg: #1c1e21 !important;
    --badge-bg: #2d3436 !important;
    --input-border: #2d3436 !important;
    --icon-hover: #2d3436 !important;
    --stat-label: #b2bec3 !important;
    --brand-primary: #ffce00 !important; 
    --brand-accent: #ff4d4d !important;  
    --divider-color: #2d3436 !important;
    --falun-red: #ff4d4d !important;
}

body {
    font-family: 'Nunito', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
    background-color: var(--bg-color);
    color: var(--text-color);
    margin: 0;
    padding: 0;
    display: flex;
    justify-content: center;
    min-height: 100vh;
    /* transition removed to prevent flickering */
}

.main-container {
    width: 100%;
    max-width: 500px;
    padding: 20px;
    padding-top: max(20px, env(safe-area-inset-top));
    padding-bottom: max(20px, env(safe-area-inset-bottom));
    padding-left: max(20px, env(safe-area-inset-left));
    padding-right: max(20px, env(safe-area-inset-right));
    display: flex;
    flex-direction: column;
    gap: 12px;
}

main {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
}

header {
    text-align: center;
    margin-bottom: 0;
    position: relative;
}

.version-tag {
    position: absolute;
    bottom: 5px;
    right: 0;
    font-size: 0.5rem;
    opacity: 0.3;
    pointer-events: none;
    user-select: none;
    font-weight: normal;
}

.header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 5px;
}

.streak-badge {
    font-size: 1.2rem;
    font-weight: bold;
    display: flex;
    align-items: center;
    gap: 5px;
    cursor: pointer;
}

.combo-badge {
    background: linear-gradient(45deg, #ff9a9e 0%, #fad0c4 99%, #fad0c4 100%);
    color: #fff;
    padding: 5px 10px;
    border-radius: 20px;
    font-weight: bold;
    font-size: 1rem;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes popIn {
    0% { transform: scale(0); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

/* Filter Bar */
.filter-group {
    display: flex;
    gap: 2px; /* Minimal gap */
    align-items: center;
    flex-wrap: nowrap; /* Force single line */
    justify-content: space-between; /* Distribute evenly */
    width: 100%;
}

.filter-label {
    font-weight: bold;
    color: var(--stat-label);
    font-size: 0.9rem;
}

.filter-option {
    display: flex;
    align-items: center;
    gap: 2px; /* Set gap to 2px as requested */
    cursor: pointer;
    /* Responsive font size: shrink on small screens */
    font-size: clamp(0.75rem, 3.5vw, 1rem); 
    background: none; /* Remove box bg */
    padding: 5px 2px; /* Minimal padding */
    border: none; /* Remove border */
    border-radius: 0;
    white-space: nowrap; /* Prevent wrapping inside item */
}

.filter-option input[type="checkbox"] {
    margin: 0; /* Remove any default margins */
}

header h1 {
    color: var(--brand-primary);
    margin: 15px 0 0 0;
    font-size: clamp(1.5rem, 6vw, 2rem); /* Dynamic sizing */
    white-space: nowrap;
}

/* Removed specific media query as clamp handles it smoothly */

/* Unified Stats Grid */
.stats-grid-box {
    display: grid;
    grid-template-columns: 1fr 1fr;
    background: var(--card-bg);
    border: 1px solid var(--input-border);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 6px rgba(0,0,0,0.05);
    position: relative; /* Base for pseudo-element lines */
}

/* Vertical Divider (always needed for 2 columns) */
.stats-grid-box::before {
    content: '';
    position: absolute;
    left: 50%;
    top: 10px;
    bottom: 10px;
    width: 1px;
    background-color: var(--divider-color);
    z-index: 1;
}

/* Horizontal Divider (only for DB grid with 2 rows) */
.stats-grid-box.db-grid::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 10px;
    right: 10px;
    height: 1px;
    background-color: var(--divider-color);
    z-index: 1;
}

.stats-grid-box .stat-item {
    padding: 12px 10px;
    text-align: center;
    display: flex;
    flex-direction: column;
    justify-content: center;
    position: relative;
    z-index: 2;
}

#rank-display {
    color: var(--brand-primary);
    font-weight: 800;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
}

#rank-display .rank-emoji {
    width: 1.4em;
    height: 1.4em;
    margin-left: 0; /* Gap handled by parent */
    flex-shrink: 0;
}

#elo-display {
    color: var(--sv-orange);
}

.stat-item .value {
    display: block;
    font-size: 1.4rem;
    font-weight: bold;
    line-height: 1.2;
}

.stat-item .label {
    font-size: 0.75rem;
    color: var(--stat-label);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 4px;
}

.stat-item.correct .value { color: var(--success); }
.stat-item.wrong .value { color: var(--error); }

#btn-general-feedback {
    margin-top: 0; /* Remove redundant margin */
}

/* Flashcard */
.card-container {
    perspective: 1000px;
}

.card {
    background: var(--card-bg);
    border-radius: 16px;
    padding: 20px 30px; /* Reduced vertical padding */
    box-shadow: 0 8px 20px rgba(0,0,0,0.1);
    text-align: center;
    transition: transform 0.3s ease, background-color 0.3s;
    will-change: transform;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px; /* Reduced margin */
    color: var(--stat-label);
    font-size: 0.9rem;
}

.card-search-btn {
    font-size: 1.3rem !important;
    width: 44px !important;
    height: 44px !important;
    background: var(--sv-blue) !important;
    color: white !important;
    border: none !important;
    display: flex !important;
    align-items: center;
    justify-content: center;
    border-radius: 50% !important;
    box-shadow: 0 4px 10px rgba(0,0,0,0.15) !important;
    padding: 0 !important;
    margin: 0 !important;
}

.badges {
    display: flex;
    gap: 10px;
}

.badge {
    background: var(--badge-bg);
    padding: 4px 8px;
    border-radius: 4px;
    font-weight: bold;
    color: var(--text-color);
    font-size: 0.8rem;
}

.level-badge {
    background-color: var(--brand-primary);
    color: white;
}

.category-badge {
    background-color: var(--brand-accent);
    color: var(--brand-primary);
}

/* Category Filter Layout */
.filters {
    background: var(--card-bg);
    padding: 10px 15px; /* Reduced vertical padding */
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.05);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px; /* Reduced gap from 10px */
}

.category-filter-container {
    width: 100%;
}

.category-filter-container .btn {
    margin-top: 0px; /* Removed extra margin */
}

.category-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 15px;
    justify-content: center;
}

.category-chip {
    background: var(--badge-bg);
    border: 1px solid var(--input-border);
    padding: 6px 12px;
    border-radius: 15px;
    font-size: 0.85rem;
    cursor: pointer;
    text-align: center;
    transition: background-color 0.2s, transform 0.2s, border-color 0.2s;
    color: var(--text-color);
    user-select: none;
    line-height: 1.2;
    white-space: nowrap;
}

.category-chip.active {
    background-color: var(--brand-primary);
    color: white;
    border-color: var(--brand-primary);
}

.category-chip:hover {
    transform: translateY(-2px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.modal-actions {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
}

.modal-actions .btn {
    margin-top: 0;
}

.question-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    margin-bottom: 15px;
}

#question-text {
    font-size: clamp(1.5rem, 6vw, 2rem); /* Responsive sizing like title */
    margin: 0;
    color: var(--brand-primary);
    word-break: break-word;
    hyphens: auto;
    overflow-wrap: break-word;
    line-height: 1.2;
}

.q-note {
    font-size: 0.65em;
    color: var(--success);
    margin-left: 0.2em;
    font-weight: normal;
    display: inline;
    white-space: normal;
    font-style: italic;
    word-break: break-word;
}

.error-text {
    color: var(--error) !important;
}

.icon-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    margin: 0;
    border-radius: 50%;
    transition: background-color 0.2s, transform 0.1s;
    will-change: transform;
    line-height: 1;
    color: var(--text-color);
}

.icon-btn:hover {
    background: var(--icon-hover);
    transform: scale(1.1);
}

.icon-btn:active {
    transform: scale(0.95);
}

.hint-text {
    font-size: 0.8rem;
    color: #e67e22; /* Orange for warning/hint */
    margin-bottom: 3px;
    font-weight: bold;
    min-height: 0.8rem;
    line-height: 1;
    visibility: hidden;
}

.hint-text.visible {
    visibility: visible;
}

/* Input Area */
.input-wrapper {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 0px;
}

.inline-btn {
    width: 48px;
    height: 48px;
    min-width: 48px;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    transition: background-color 0.2s, color 0.2s, transform 0.1s ease;
    will-change: transform; /* Hint for composited animation */
    padding: 0;
}

.inline-btn.check-state {
    background-color: var(--brand-primary);
    color: white;
}

.inline-btn.next-state {
    background-color: var(--brand-accent);
    color: var(--brand-primary);
}

.inline-btn:active {
    transform: scale(0.95);
}

.input-flag {
    font-size: 1.2rem;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
}

body.dark .input-flag,
body.dark .flag-icon {
    filter: drop-shadow(0px 0px 0px rgba(0,0,0,0));
}
body.dark .input-flag {
    background-color: rgba(255, 255, 255, 0.35);
    text-shadow: 0 0 5px rgba(255, 255, 255, 0.8);
    border-radius: 6px;
    padding: 4px;
    width: 36px;
    height: 36px;
}
body.dark .flag-icon {
    box-shadow: 0 0 0 1.5px rgba(255, 255, 255, 0.5) !important;
}

body.dark .header-flag {
    box-shadow: none !important;
    border: 1.5px solid rgba(255, 255, 255, 0.5);
    vertical-align: -3px !important;
    width: 42px !important;
    height: 28px !important;
    margin: 0 10px !important;
    border-radius: 3px;
}

/* Make the black stripe of the German SVG flag visible in dark mode */
body.dark .flag-icon rect[fill="#000"],
body.dark .flag-icon rect[fill="black"] {
    fill: #333 !important;
}

input[type="text"] {
    width: 100%;
    padding: 12px;
    border: 2px solid var(--input-border);
    border-radius: 8px;
    font-size: 1.1rem;
    outline: none;
    transition: border-color 0.2s, background-color 0.3s, color 0.3s;
    background-color: var(--card-bg);
    color: var(--text-color);
}

input[type="text"]:disabled {
    background-color: var(--card-bg);
    color: var(--text-color);
    opacity: 0.8;
    cursor: not-allowed;
    -webkit-text-fill-color: var(--text-color); /* Fix for iOS Safari */
}

input[type="text"]:focus {
    border-color: var(--brand-primary);
}

textarea {
    background-color: var(--card-bg);
    color: var(--text-color);
    border: 1px solid var(--input-border);
    border-radius: 8px;
    padding: 10px;
    font-family: inherit;
    font-size: 1rem;
    outline: none;
    transition: border-color 0.2s;
}

textarea:focus {
    border-color: var(--brand-primary);
}

.char-buttons {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
}

.char-btn {
    background: var(--badge-bg);
    border: 1px solid var(--input-border);
    border-radius: 4px;
    padding: 5px 10px;
    font-size: 1.1rem;
    cursor: pointer;
    color: var(--brand-primary);
    transition: background 0.2s;
}

.char-btn:hover {
    background: var(--icon-hover);
}

.congrats-img {
    display: block;
    width: 120px;
    height: 120px;
    margin: 0 auto 20px auto;
}

.modal-onboarding .congrats-img {
    width: 150px;
    height: 150px;
}

.btn {
    display: block;
    width: 100%;
    padding: 10px 15px; /* Reduced from 15px to be closer to 'small' btn */
    margin-top: 20px;
    border: none;
    border-radius: 8px;
    font-size: 1.1rem;
    font-weight: bold;
    cursor: pointer;
    transition: background 0.2s;
}

.btn.primary {
    background-color: var(--sv-blue);
    color: white;
}

.btn.primary:hover {
    filter: brightness(1.1);
}

.choice-btn {
    display: flex !important;
    align-items: center;
    justify-content: center;
    margin-top: 0 !important;
    padding: 12px 8px !important;
    white-space: normal !important;
    overflow-wrap: break-word !important;
    word-break: break-word !important; 
    hyphens: auto;
    line-height: 1.2 !important;
    min-height: 4em;
    text-align: center;
}

.btn.secondary {
    background-color: var(--brand-accent);
    color: var(--brand-primary);
}

#hint-btn {
    background-color: var(--brand-primary) !important;
    color: var(--brand-accent) !important;
    font-weight: 700 !important;
    border: 2px solid var(--brand-accent) !important;
    box-shadow: 0 4px 0 rgba(0,0,0,0.1);
    transition: transform 0.1s;
}

#hint-btn:active {
    transform: translateY(2px);
    box-shadow: 0 2px 0 rgba(0,0,0,0.1);
}

.btn#risk-mode-btn, #risk-mode-btn.secondary {
    background-color: var(--falun-red) !important;
    color: white !important;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    height: 48px;
}

.risk-slot {
    font-size: 0.7rem;
    font-weight: bold;
    opacity: 0.6;
    animation: riskSlotAnim 4s infinite linear;
    width: 25px;
    text-align: center;
}

.risk-slot:nth-child(1) { animation-delay: 0s; }
.risk-slot:nth-child(2) { animation-delay: 2s; }
.risk-slot:nth-child(4) { animation-delay: 1s; }
.risk-slot:nth-child(5) { animation-delay: 3s; }

.risk-label {
    font-size: 1.1rem;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 1px;
}

@keyframes riskSlotAnim {
    0% { transform: translateY(20px); opacity: 0; }
    5%, 45% { transform: translateY(0); opacity: 1; }
    50%, 100% { transform: translateY(-20px); opacity: 0; }
}

.btn.danger {
    background-color: var(--error);
    color: white;
}

.btn.small {
    padding: 10px 15px; /* Matched with regular btn padding */
    font-size: 0.9rem;
    margin-top: 5px;
}

.hidden {
    display: none !important;
}

.rank-emoji-center {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 10;
    pointer-events: auto; /* Enabled for hover/tooltip */
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: help;
}

.rank-emoji-center .rank-emoji {
    margin: 0;
    width: 3em;
    height: 3em;
    font-size: 2em; /* Even larger central icon */
    box-shadow: 0 4px 15px rgba(0,0,0,0.4);
    transition: transform 0.2s ease;
}

/* Responsive Scaling for Narrow Devices */
@media (max-width: 400px) {
    .rank-emoji-center .rank-emoji {
        width: 2.5em;
        height: 2.5em;
        font-size: 1.6em;
    }
}

.rank-emoji-center:hover .rank-emoji {
    transform: scale(1.1);
}

.rank-emoji {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    /* Stronger 3D Coin/Badge Effect */
    background: radial-gradient(circle at 35% 35%, #fff5a3 0%, var(--brand-accent) 60%, #cc9900 100%) !important;
    color: #000000;
    border: 1px solid #b8960a; /* Metallic gold border */
    border-radius: 50%;
    width: 1.7em;
    height: 1.7em;
    font-size: 1.35em; /* Maximized emoji size */
    margin-left: 8px;
    /* Double shadow: Outer drop shadow + Inset rim shadows */
    box-shadow: 
        0 2px 4px rgba(0,0,0,0.25),
        inset 1px 1px 2px rgba(255,255,255,0.8),
        inset -1px -1px 2px rgba(0,0,0,0.3);
    vertical-align: middle;
    line-height: 1;
    /* Emoji depth */
    text-shadow: 0 1px 1px rgba(0,0,0,0.15);
    font-weight: 900; /* Extra bold for thin characters */
}

/* Slightly smaller rank icons in the help table */
.about-section table .rank-emoji {
    width: 1.8em;
    height: 1.8em;
    font-size: 1.4em;
    margin-left: 4px;
}

/* Feedback Area Refined */
#feedback-area, .feedback-area {
    margin-top: 20px;
    padding: 10px 15px; /* Reduced vertical padding */
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

#feedback-text, .feedback-area #feedback-text {
    font-weight: bold;
    font-size: 1.1rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.solution-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.solution {
    font-size: 1.2rem;
    font-weight: bold;
    color: var(--text-color);
    word-break: break-word;
    hyphens: auto;
    overflow-wrap: break-word;
    line-height: 1.3;
}

.solution .solution-text {
    color: var(--brand-primary);
    font-weight: bold;
    text-decoration: none !important;
}

.solution s {
    color: #e74c3c; /* Red for extra/wrong characters */
    text-decoration: line-through;
    text-decoration-thickness: 2px;
    opacity: 0.8;
}

.primary-synonym {
    text-decoration: underline;
    text-decoration-color: var(--brand-accent);
    text-decoration-thickness: 1px;
    text-underline-offset: 3px;
}

body.dark .solution .solution-text {
    color: var(--sv-yellow);
    text-decoration: none !important;
}

body.dark .solution s {
    color: #ff6b6b; /* Lighter red for dark mode */
}

.feedback-actions {
    display: flex;
    justify-content: center;
    gap: 15px;
}

.action-icon {
    font-size: 1.3rem !important;
    width: 40px !important;
    height: 40px !important;
    background: rgba(255,255,255,0.8) !important; /* Default Light Mode */
    border: 1px solid rgba(0,0,0,0.15) !important;
    display: flex !important;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    color: #333 !important; /* Force dark icon color in light mode */
}

body.dark .action-icon {
    background: rgba(0,0,0,0.3) !important; /* Darker background for dark mode */
    border: 1px solid rgba(255,255,255,0.1) !important;
    color: #e0e0e0 !important; /* Light icon color */
}

#report-btn {
    color: #e74c3c !important; /* Keep red flag */
}

.feedback-correct {
    background-color: rgba(46, 204, 113, 0.15);
    color: #27ae60;
    border: 1px solid rgba(46, 204, 113, 0.3);
}

.feedback-wrong {
    background-color: rgba(231, 76, 60, 0.1);
    color: #c0392b;
    border: 1px solid rgba(231, 76, 60, 0.2);
}

.feedback-hint {
    background-color: rgba(243, 156, 18, 0.1);
    color: #d35400;
    border: 1px solid rgba(243, 156, 18, 0.2);
}

/* Example Sentence - Integrated Look */
.example-box {
    margin-top: 5px;
    padding: 0;
    background-color: transparent;
    border: none;
    border-radius: 0;
    text-align: center;
}

.example-label {
    font-size: 0.75rem;
    font-weight: bold;
    color: var(--stat-label);
    text-transform: uppercase;
    display: block;
    margin-bottom: 4px;
    opacity: 0.8;
}

.example-content {
    display: flex;
    align-items: center;
    gap: 10px;
    justify-content: center;
}

.example-actions {
    margin-top: 8px;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
}

.speed-selector {
    display: flex;
    background-color: var(--badge-bg);
    border-radius: 20px;
    padding: 2px;
    border: 1px solid var(--input-border);
}

.speed-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.1rem;
    font-weight: bold;
    padding: 2px 10px;
    border-radius: 15px;
    transition: background-color 0.2s, transform 0.1s;
    opacity: 0.6;
    display: flex;
    align-items: center;
    justify-content: center;
}

.speed-btn.active {
    background-color: var(--brand-primary);
    opacity: 1;
    color: white;
}

.speed-btn:hover:not(.active) {
    background-color: var(--icon-hover);
    opacity: 0.8;
}

#example-text {
    font-style: italic;
    color: var(--text-color);
    margin: 0;
    font-size: 1.05rem;
    line-height: 1.4;
}

.footer-links {
    text-align: center;
}

.footer-links a {
    color: var(--stat-label);
    font-size: 0.8rem;
    text-decoration: none;
    opacity: 0.7;
}

.footer-links a:hover {
    opacity: 1;
    text-decoration: underline;
}

.small-btn {
    font-size: 1.2rem;
    padding: 2px;
}

/* DB Stats */
.db-stats-container {
    background: var(--card-bg);
    padding: 12px 20px; /* Matched vertical padding to main gap */
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.05);
}

.db-stats-container h3 {
    margin-top: 0;
    font-size: 1rem;
    color: var(--stat-label);
}

.box-row {
    display: flex;
    align-items: center;
    margin-bottom: 8px;
    font-size: 0.9rem;
}

.box-label {
    width: 60px;
    font-weight: bold;
}

.progress-track {
    flex-grow: 1;
    background: var(--badge-bg);
    height: 10px;
    border-radius: 5px;
    overflow: hidden;
    margin: 0 10px;
}

.progress-fill {
    height: 100%;
    width: 100%; /* Ensure full width for scaling */
    background: var(--brand-primary);
    transform-origin: left;
    transition: transform 0.5s ease-out;
    will-change: transform;
}

.box-count {
    width: 40px;
    text-align: right;
    color: var(--stat-label);
}

/* Category Stats */
.category-stats-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
}

@media (min-width: 400px) {
    .category-stats-grid {
        grid-template-columns: 1fr 1fr;
    }
}

.cat-stat-item {
    font-size: 0.8rem;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.cat-stat-header {
    display: flex;
    justify-content: space-between;
    color: var(--stat-label);
}

.cat-stat-track {
    background: var(--badge-bg);
    height: 18px; /* Increased height */
    border-radius: 9px;
    overflow: hidden;
    position: relative;
    display: flex;
    align-items: center;
}

.cat-stat-fill {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    width: 100%; /* Ensure full width for scaling */
    background: var(--brand-primary);
    transform-origin: left;
    transition: transform 0.5s ease-out;
    will-change: transform;
    z-index: 1;
}

.cat-stat-label-inner {
    position: absolute;
    width: 100%;
    display: flex;
    justify-content: space-between;
    padding: 0 8px;
    font-size: 0.7rem;
    font-weight: 900;
    color: #2c3e50; /* Dark blue-gray for readability in light mode */
    text-shadow: 0 0 3px #fff, 0 0 3px #fff, 0 0 3px #fff; /* Strong white glow */
    z-index: 2;
    pointer-events: none;
    line-height: 1;
}

body.dark .cat-stat-label-inner {
    color: #fff;
    text-shadow: 0 0 3px #000, 0 0 3px #000;
}

/* Mastery color (Box 5) */
.cat-stat-fill.mastered {
    background: #2ecc71; /* Green */
}

.data-management {
    background: var(--card-bg);
    padding: 15px 20px; /* Reduced vertical padding */
    border-radius: 12px;
}

.data-management h3 {
    margin-top: 0;
    font-size: 1rem;
    color: var(--stat-label);
}

.data-buttons {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

/* Ko-Fi Button */
.support-section {
    margin-top: 0px;
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.kofi-btn {
    margin-top: 0 !important;
    background-color: #FF5E5B; /* Ko-Fi Red */
    color: white;
    text-decoration: none;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: transform 0.2s, background-color 0.2s;
}

.kofi-btn:hover {
    background-color: #ff403d;
    transform: translateY(-2px);
}

/* Dark Mode & Help Toggle Styling */
.header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-actions .icon-btn {
    font-size: 1.2rem;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--card-bg);
    border-radius: 50%;
    cursor: pointer;
    border: 1px solid rgba(0,0,0,0.08);
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
    transition: background-color 0.2s, transform 0.1s, border-color 0.2s, box-shadow 0.2s;
    color: var(--text-color);
    padding: 0;
    margin: 0;
}

body.dark .header-actions .icon-btn {
    background-color: var(--badge-bg);
    border-color: var(--input-border);
    box-shadow: none;
}

/* Mobile Tweaks for Header Buttons */
@media (max-width: 400px) {
    .header-actions {
        gap: 6px;
    }
    
    .header-actions .icon-btn {
        width: 32px;
        height: 32px;
        font-size: 1rem;
    }
    
    /* Ensure emoji flags/icons are centered perfectly */
    .header-actions .icon-btn {
        padding-top: 2px; 
    }
}

.header-actions .icon-btn:hover {
    background-color: var(--icon-hover);
    border-color: var(--brand-primary);
    transform: scale(1.05);
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

/* Notification Status Dot */
#enable-push-btn {
    position: relative;
}

#enable-push-btn.status-active::after {
    content: '';
    position: absolute;
    top: 4px;
    right: 4px;
    width: 8px;
    height: 8px;
    background-color: #2ecc71; /* Success Green */
    border-radius: 50%;
    border: 1.5px solid var(--card-bg);
    box-shadow: 0 0 4px rgba(46, 204, 113, 0.6);
}

/* --- LANGUAGE DROPDOWN --- */
.lang-dropdown {
    position: relative;
    display: inline-block;
}

.dropdown-content {
    display: none;
    position: absolute;
    right: 0;
    top: 110%;
    background-color: var(--card-bg);
    min-width: 140px;
    box-shadow: 0 8px 16px rgba(0,0,0,0.2);
    border-radius: 8px;
    z-index: 1000;
    border: 1px solid var(--input-border);
    padding: 5px;
}

#lang-menu {
    min-width: 220px;
}

.dropdown-content:not(.hidden) {
    display: block;
    animation: fadeIn 0.2s;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-5px); }
    to { opacity: 1; transform: translateY(0); }
}

.lang-option {
    width: 100%;
    text-align: left;
    padding: 10px;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    color: var(--text-color);
    border-radius: 4px;
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
}

.lang-option:hover {
    background-color: var(--icon-hover);
}

.lang-option.active {
    background-color: var(--sv-yellow) !important;
    color: #004b75 !important;
    font-weight: bold;
}

.lang-option.active .icon-btn {
    background-color: var(--sv-blue) !important;
    color: white !important;
}

.lang-group-label {
    padding: 10px 12px 6px 12px;
    font-size: 0.7rem;
    font-weight: 800;
    text-transform: uppercase;
    color: var(--stat-label);
    background-color: var(--icon-hover);
    border-bottom: 1px solid var(--input-border);
    margin-bottom: 4px;
    margin-top: 4px;
    letter-spacing: 1px;
    display: block;
    opacity: 0.9;
    white-space: nowrap;
}

.lang-group-label:first-child {
    margin-top: 0;
    border-top-left-radius: 4px;
    border-top-right-radius: 4px;
}

/* Modal Styles */
.modal {
    position: fixed;
    z-index: 20000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    display: flex;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(3px);
}

.modal-content {
    background-color: var(--card-bg);
    padding: 20px 30px; /* Reduced vertical padding */
    border-radius: 16px;
    width: 90%;
    max-width: 450px;
    position: relative;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 10px 25px rgba(0,0,0,0.2);
    color: var(--text-color);
}

.close-modal {
    position: absolute;
    right: 20px;
    top: 15px;
    font-size: 2rem;
    cursor: pointer;
    color: var(--stat-label);
}

.modal-content h2 {
    color: var(--sv-blue);
    margin-top: 0;
}

.modal-content h3 {
    margin-bottom: 5px;
    color: var(--sv-blue);
    font-size: 1.1rem;
    color: var(--sv-blue);
}

.modal-content ul {
    padding-left: 20px;
    margin-bottom: 15px;
}

.modal-content li {
    margin-bottom: 5px;
}

.modal-content p {
    line-height: 1.5;
    margin-bottom: 15px;
}

/* --- Onboarding Modal --- */
.modal-onboarding .modal-content {
    border: 2px solid var(--sv-blue);
    background-color: #f0f8ff; /* AliceBlue */
}
body.dark .modal-onboarding .modal-content {
    background-color: #1a2a3a;
    border-color: var(--sv-blue);
}
.modal-onboarding h2 {
    color: var(--sv-blue);
}
.modal-onboarding .btn.primary {
    background-color: var(--brand-primary);
}

/* Update Toast */
#update-toast {
    position: fixed;
    top: 40px;
    padding-top: env(safe-area-inset-top, 0px); /* iOS Notch support */
    left: 50%;
    transform: translateX(-50%) translateY(-150px);
    background-color: var(--card-bg);
    color: var(--text-color);
    padding: 15px 20px;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    display: flex;
    align-items: center;
    gap: 15px;
    z-index: 3000;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    will-change: transform;
    border: 1px solid var(--sv-blue);
    width: 90%;
    max-width: 400px;
    justify-content: space-between;
}

#update-toast.visible {
    transform: translateX(-50%) translateY(0);
}

#update-toast .message {
    font-weight: bold;
    font-size: 0.95rem;
}

#update-toast .btn {
    margin: 0;
    padding: 8px 16px;
    font-size: 0.9rem;
    width: auto;
    white-space: nowrap;
}

/* Offline / Disabled State */
.disabled {
    opacity: 0.3;
    pointer-events: none;
    cursor: not-allowed;
    filter: grayscale(100%);
}

/* Shake Animation for Errors */
@keyframes shake {
    0% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    50% { transform: translateX(5px); }
    75% { transform: translateX(-5px); }
    100% { transform: translateX(0); }
}

.shake {
    animation: shake 0.4s ease-in-out;
}

/* Test Environment Ribbon */
#test-ribbon {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    background: #e74c3c;
    color: white;
    text-align: center;
    font-weight: bold;
    font-size: 0.7rem;
    z-index: 10000;
    padding: 2px 0;
    pointer-events: none;
    opacity: 0.9;
}

/* SVG Flags */
.flag-icon {
    width: 1.4em;
    height: 1em;
    vertical-align: middle;
    display: inline-block;
    border-radius: 2px;
    box-shadow: 0 0 1px rgba(0,0,0,0.2);
}
.lang-option .flag-icon {
    margin-right: 8px;
}

/* --- SEARCH OVERLAY --- */
#search-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--bg-color); /* Matches main page background */
    z-index: 2000;
    padding: 20px;
    display: flex;
    justify-content: center;
    backdrop-filter: blur(5px);
}

body.dark #search-overlay {
    background-color: var(--bg-color); /* Matches main page background in dark mode */
}

.search-container {
    width: 100%;
    max-width: 500px; /* Matches main-container max-width */
    display: flex;
    flex-direction: column;
    height: 100%;
    gap: 12px; /* Matches main layout gap */
}

.search-header {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-bottom: 0px; /* Tighter integration with filters below */
    padding-top: env(safe-area-inset-top, 10px);
}

#search-input {
    flex-grow: 1;
    font-size: 1.1rem; /* Matches main input feel */
    padding: 12px 15px;
    border-radius: 12px;
    border: 2px solid var(--input-border);
    background: var(--card-bg);
    color: var(--text-color);
    box-shadow: 0 4px 6px rgba(0,0,0,0.05); /* Soft shadow like stats boxes */
}

#search-input:focus {
    border-color: var(--sv-blue);
    outline: none;
}

#close-search-btn {
    font-size: 2rem;
    padding: 0 10px;
    color: var(--stat-label);
}

.search-results {
    flex-grow: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding-bottom: 20px;
}

.result-card {
    background: var(--card-bg);
    padding: 15px 20px; /* Roomier, consistent with main card */
    padding-bottom: 40px; /* Extra space for dual bottom-right badges */
    border-radius: 16px;
    border: 1px solid var(--input-border);
    text-align: left;
    display: flex;
    flex-direction: column;
    gap: 6px;
    transition: all 0.2s ease;
    cursor: pointer;
    box-shadow: 0 4px 6px rgba(0,0,0,0.05); /* Match stats box shadow */
    position: relative; /* Base for absolute box badge */
}

.result-card-box {
    position: absolute;
    bottom: 12px;
    right: 15px;
    opacity: 0.9;
}

.result-card:active {
    transform: scale(0.98);
}

.result-header {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 2px;
}

.result-content {
    display: flex;
    flex-direction: column;
    gap: 4px;
    width: 100%;
}

.result-main {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}

.result-main span {
    font-size: 1.2rem; /* Larger, bolder primary word */
    font-weight: 800;
    color: var(--sv-blue);
    line-height: 1.2;
}

.result-forms {
    font-size: 0.8rem;
    color: var(--sv-yellow);
    font-style: italic;
    margin-top: -4px;
    margin-bottom: 2px;
    font-weight: 700;
    text-shadow: 0 0 1px rgba(0,0,0,0.1);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

.result-synonyms {
    font-size: 0.8rem;
    color: var(--stat-label);
    margin-top: 0px;
    margin-bottom: 2px;
    opacity: 0.9;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.syn-label {
    font-weight: 800;
    text-transform: uppercase;
    font-size: 0.7rem;
    letter-spacing: 0.5px;
    margin-right: 4px;
}

.result-sub {
    font-size: 1rem; /* Match main page answer text size */
    color: var(--text-color);
    font-weight: 600;
}

.result-meta {
    margin-top: 6px;
    padding-top: 6px;
    border-top: 1px dashed var(--input-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    font-size: 0.9rem;
    color: var(--stat-label);
    font-style: italic;
    opacity: 0.9;
}

.result-badges {
    display: none; /* Replaced by result-header */
}

.result-badge {
    font-size: 0.65rem;
    padding: 3px 8px;
    border-radius: 6px;
    font-weight: 700;
    white-space: nowrap;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.result-badge.cat {
    background-color: rgba(255, 205, 0, 0.15);
    color: var(--sv-yellow-text, #854d0e);
    border: 1px solid rgba(255, 205, 0, 0.3);
}

body.dark .result-badge.cat {
    color: #fbbf24;
}

.result-badge.type {
    background-color: var(--badge-bg);
    color: var(--stat-label);
    border: 1px solid var(--input-border);
}

.result-badge.level {
    background-color: rgba(148, 163, 184, 0.1);
    color: #64748b;
    border: 1px solid rgba(148, 163, 184, 0.2);
}

body.dark .result-badge.level {
    color: #94a3b8;
}

.result-badge.box {
    background-color: transparent;
    color: white;
}

.speak-result-btn {
    flex-shrink: 0;
    background: var(--badge-bg);
    border: 1px solid var(--input-border);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.result-card.highlight-exact {
    border: 2px solid var(--sv-yellow) !important;
    background: rgba(255, 205, 0, 0.03);
}

.highlight-match {
    background-color: var(--sv-yellow);
    color: #000; /* Dark text for contrast on yellow */
    border-radius: 2px;
    padding: 0 2px;
}

/* Profile Management */
.profile-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 20px;
}

.profile-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 15px;
    background: var(--bg-color);
    border-radius: 12px;
    border: 2px solid transparent;
    cursor: pointer;
    transition: all 0.2s;
}

.profile-item:hover {
    border-color: var(--input-border);
}

.profile-item.active {
    border-color: var(--sv-blue);
    background: var(--card-bg);
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
}

.profile-info {
    flex-grow: 1;
}

.profile-name {
    font-weight: bold;
    color: var(--text-color);
}

.profile-status {
    font-size: 0.75rem;
    color: var(--stat-label);
    margin-top: 2px;
}

.delete-profile {
    opacity: 0.5;
    transition: opacity 0.2s;
}

.delete-profile:hover {
    opacity: 1;
    color: var(--error);
}

.no-results {
    text-align: center;
    color: var(--stat-label);
    margin-top: 30px;
    font-style: italic;
}

@keyframes spin { 100% { transform: rotate(360deg); } }
.spin { animation: spin 1s linear infinite; }

/* --- QR Scanner Modal --- */
#scanner-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.9);
    z-index: 3000;
    display: flex !important;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(5px);
}

#scanner-container.hidden {
    display: none !important;
}

#scanner-container #qr-reader {
    width: 100%;
    max-width: 400px;
    height: 400px;
    border: 2px solid #fff;
    border-radius: 12px;
    background-color: #000;
}

#scanner-container .scanner-header {
    color: white;
    text-align: center;
    margin-bottom: 20px;
    font-size: 1.2rem;
    font-weight: bold;
}

#scanner-container .scanner-instructions {
    color: #ccc;
    text-align: center;
    margin-bottom: 20px;
    max-width: 300px;
    line-height: 1.4;
}

#scanner-container #btn-stop-scanner {
    background-color: #e74c3c;
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 1rem;
    cursor: pointer;
    margin-top: 20px;
}

#scanner-container #btn-stop-scanner:hover {
    background-color: #c0392b;
}

/* Beta Tester Call */
.beta-step {
    margin-bottom: 20px;
    padding: 15px;
    background: rgba(0, 106, 167, 0.05);
    border-radius: 10px;
    border: 1px solid var(--input-border);
}

.beta-step-title {
    font-weight: bold;
    color: var(--sv-blue);
    margin-bottom: 5px;
}

.beta-step-desc {
    font-size: 0.9rem;
    margin-bottom: 10px;
    opacity: 0.9;
}

.beta-link {
    width: 100%;
    display: inline-block;
    text-align: center;
    text-decoration: none;
}

.beta-link.clicked {
    background-color: var(--badge-bg) !important;
    color: var(--text-color) !important;
    border-color: var(--input-border) !important;
}

/* ==========================================
   BONUS / RISK MODE STYLES
   ========================================== */

/* Bonus Active Mode - Visual separation when in bonus phase */
.bonus-active-mode {
    background-color: rgba(255, 205, 0, 0.08) !important;
    border: 2px solid var(--sv-yellow) !important;
    border-radius: 18px !important;
}

body.dark .bonus-active-mode {
    background-color: rgba(255, 205, 0, 0.05) !important;
    border-color: var(--sv-yellow) !important;
}

/* Bonus Header */
.bonus-header {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    margin-bottom: 20px;
    padding: 15px;
    background: linear-gradient(135deg, var(--sv-yellow) 0%, #ffd700 100%);
    border-radius: 12px;
    color: #004b75;
}

body.dark .bonus-header {
    background: linear-gradient(135deg, #b8960a 0%, var(--sv-yellow) 100%);
    color: #fff;
}

.bonus-base-word {
    font-size: clamp(1.5rem, 6vw, 2rem);
    font-weight: 800;
    color: #004b75;
    text-transform: none;
}

body.dark .bonus-base-word {
    color: var(--sv-blue);
}

.bonus-sentence-area {
    font-size: 1.2rem;
    margin-bottom: 20px;
    padding: 15px;
    line-height: 2.2;
    color: var(--text-color);
}

/* Gap Input - Underline style within text flow */
.gap-input {
    display: inline-block;
    min-width: 100px;
    max-width: 200px;
    padding: 5px 10px;
    border: none;
    border-bottom: 3px solid var(--sv-yellow);
    background-color: transparent;
    font-size: 1.2rem;
    font-weight: bold;
    color: var(--sv-blue);
    text-align: center;
    outline: none;
    transition: border-color 0.2s, background-color 0.2s;
    border-radius: 0;
}

.gap-input:focus {
    border-bottom-color: var(--sv-blue);
    background-color: rgba(255, 205, 0, 0.1);
}

body.dark .gap-input {
    border-bottom-color: var(--sv-yellow);
    color: var(--sv-blue);
}

/* Alternative: Box style for gap input */
.bonus-input {
    display: inline-block;
    width: 150px;
    padding: 8px 12px;
    border: 2px solid var(--sv-yellow);
    border-radius: 8px;
    background-color: var(--card-bg);
    font-size: 1.1rem;
    font-weight: bold;
    color: var(--text-color);
    text-align: center;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.bonus-input:focus {
    border-color: var(--sv-blue);
    box-shadow: 0 0 0 3px rgba(0, 106, 167, 0.2);
}

.bonus-input::placeholder {
    font-style: italic;
    opacity: 0.5;
    font-weight: normal;
}

/* Bonus Input Wrapper */
.bonus-input-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    margin-bottom: 15px;
}

/* Bonus Feedback Container */
.bonus-feedback-container {
    margin-top: 20px;
    padding: 15px;
    border-radius: 12px;
    animation: bonusFadeIn 0.4s ease-out;
}

/* Feedback Box Bonus - Success */
.feedback-success,
.feedback-box-bonus.success {
    background-color: rgba(46, 204, 113, 0.15);
    color: #27ae60;
    border: 2px solid rgba(46, 204, 113, 0.4);
    border-radius: 12px;
    padding: 20px;
    text-align: center;
}

.feedback-success h3,
.feedback-box-bonus.success h3 {
    color: #27ae60;
    margin: 0 0 10px 0;
    font-size: 1.5rem;
}

.feedback-success p,
.feedback-box-bonus.success p {
    color: #1e8449;
    margin: 0;
    font-size: 1.1rem;
}

/* Feedback Box Bonus - Failure */
.feedback-error,
.feedback-box-bonus.error {
    background-color: rgba(231, 76, 60, 0.12);
    color: #c0392b;
    border: 2px solid rgba(231, 76, 60, 0.3);
    border-radius: 12px;
    padding: 20px;
    text-align: center;
}

.feedback-error h3,
.feedback-box-bonus.error h3 {
    color: #c0392b;
    margin: 0 0 10px 0;
    font-size: 1.5rem;
}

.feedback-error p,
.feedback-box-bonus.error p {
    color: #922b21;
    margin: 0 0 15px 0;
    font-size: 1.1rem;
}

/* Bonus Report Button - Distinct from normal report */
#bonus-report-btn {
    background-color: #e74c3c !important;
    color: white !important;
    border: none !important;
    padding: 10px 20px !important;
    border-radius: 8px !important;
    font-weight: bold !important;
    cursor: pointer !important;
    transition: background-color 0.2s, transform 0.1s !important;
    margin-top: 10px !important;
}

#bonus-report-btn:hover {
    background-color: #c0392b !important;
    transform: scale(1.02);
}

#bonus-report-btn:active {
    transform: scale(0.98);
}

/* Fade-in Animation for Bonus Transition */
@keyframes bonusFadeIn {
    0% {
        opacity: 0;
        transform: translateY(-10px) scale(0.95);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.bonus-fade-in {
    animation: bonusFadeIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

/* Bonus Check Button */
#bonus-check-btn {
    background-color: var(--sv-blue);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    font-weight: bold;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.1s;
}

#bonus-check-btn:hover {
    filter: brightness(1.1);
}

#bonus-check-btn:active {
    transform: scale(0.98);
}

/* Bonus Speak Button */
#bonus-speak-btn {
    font-size: 1.3rem;
    background: rgba(255, 255, 255, 0.3);
    border: 1px solid rgba(0, 0, 0, 0.1);
}

body.dark #bonus-speak-btn {
    background: rgba(0, 0, 0, 0.2);
    border-color: rgba(255, 255, 255, 0.1);
}


/* Interactive Jingle Elements */
#header-title, .rank-emoji-center {
    cursor: pointer !important;
}

/* Search Filters */
.search-filters-box {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 12px;
    background: var(--card-bg);
    border-radius: 12px;
    margin-bottom: 12px;
    border: 2px solid var(--input-border);
    animation: fadeIn 0.2s ease-out;
}
.search-filter-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.search-filter-label {
    font-size: 0.65rem;
    font-weight: 900;
    text-transform: uppercase;
    color: var(--stat-label);
    letter-spacing: 0.8px;
    margin-bottom: 2px;
}
.search-filter-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    width: 100%;
}
.filter-pill {
    background: var(--bg-color);
    border: 1px solid var(--input-border);
    padding: 4px 8px;
    border-radius: 8px;
    font-size: 0.75rem;
    cursor: pointer;
    color: var(--text-color);
    transition: all 0.15s ease;
    user-select: none;
    font-weight: 700;
    flex-grow: 1;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
}
.filter-pill:hover {
    border-color: var(--sv-blue);
}
.filter-pill.active {
    background: var(--sv-blue) !important;
    color: #fff !important;
    border-color: var(--sv-blue) !important;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}
.filter-pill.box-error-pill.active {
    background: var(--error) !important;
    border-color: var(--error) !important;
}
.categories-scroll {
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 4px;
    -webkit-overflow-scrolling: touch;
}
#search-filter-toggle {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    min-width: 40px;
    border-radius: 50% !important;
    border: 2px solid transparent;
    transition: all 0.2s ease;
}

#search-filter-toggle.open, #search-filter-toggle.active-filters {
    border-color: var(--sv-blue);
    background: rgba(0, 106, 167, 0.05);
}

#search-filter-toggle.open {
    color: var(--sv-blue);
}

.filter-count-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    font-size: 0.65rem;
    background: var(--sv-blue);
    color: white;
    min-width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    font-weight: 800;
    border: 2px solid var(--card-bg);
}


/* Dual SRS Badges in Search Results */
.result-card-badges {
    position: absolute;
    bottom: 10px;
    right: 12px;
    display: flex;
    flex-direction: row;
    gap: 8px;
    align-items: center;
}

.dual-box-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--bg-color);
    padding: 2px 6px;
    border-radius: 6px;
    border: 1px solid var(--input-border);
}

.direction-flag {
    font-size: 0.7rem;
    font-weight: 800;
    opacity: 0.8;
    white-space: nowrap;
}

.box-badge-mini {
    width: 18px;
    height: 18px;
    font-size: 0.7rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    font-weight: 900;
    color: white;
    text-shadow: 0 1px 1px rgba(0,0,0,0.2);
}

.box-badge-mini.box-0 { background-color: #94a3b8; }
.box-badge-mini.box-1 { background-color: #3498db; }
.box-badge-mini.box-2 { background-color: #2ecc71; }
.box-badge-mini.box-3 { background-color: #f1c40f; }
.box-badge-mini.box-4 { background-color: #e67e22; }
.box-badge-mini.box-5 { background-color: #8e44ad; }
.box-badge-mini.box-error { background-color: var(--error); }

/* Risk Toggles Optimization */
.risk-toggles {
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding: 2px 0;
}

.risk-toggles::-webkit-scrollbar {
    display: none; /* Hide scrollbar for cleaner look */
}

/* Global Toast Popup */
.toast-popup {
    position: fixed;
    bottom: 25px;
    left: 50%;
    transform: translateX(-50%) translateY(120px);
    background: var(--card-bg);
    color: var(--text-color);
    padding: 12px 24px;
    border-radius: 50px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    z-index: 10000;
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    font-weight: bold;
    border: 2px solid var(--sv-blue);
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
}

.toast-popup.visible {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}


/* Input Error State - Enhanced Feedback */
.input-error {
    border-color: #e74c3c !important;
    background-color: rgba(231, 76, 60, 0.05) !important;
    color: #c0392b !important;
    box-shadow: 0 0 0 2px rgba(231, 76, 60, 0.2);
}

/* Multiple Choice Feedback Styles */
.choice-btn.choice-correct {
    background-color: #2ecc71 !important;
    color: white !important;
    border-color: #27ae60 !important;
}

.choice-btn.choice-wrong {
    background-color: #e74c3c !important;
    color: white !important;
    border-color: #c0392b !important;
}

/* Compound Word Hyphenation Support */
.compound-word {
    hyphens: manual;
    word-break: break-word;
    display: inline-block;
}
