@font-face {
    font-family: 'Fuzzy Bubbles';
    src: url('fonts/FuzzyBubbles-Regular.ttf') format('truetype');
    font-weight: 400;
    font-style: normal;
}
@font-face {
    font-family: 'Fuzzy Bubbles';
    src: url('fonts/FuzzyBubbles-Bold.ttf') format('truetype');
    font-weight: 700;
    font-style: normal;
}

:root {
    --bg: #f4f6f8;
    --card-bg: #ffffff;
    --text: #2c3e50;
    --accent: #5a7d9a;
    --good: #2e7d32;
    --hard: #ef6c00;
    --again: #c62828;
    --perfect: #1976d2;
    --border: #dce1e6;
    --shadow: 0 4px 12px rgba(0,0,0,0.05);
    --radius: 12px;
    --theme-color: GhostWhite;
    --button-color: SlateBlue;
}

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

body {
    font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    font-weight: 400;
    background: var(--theme-color);
    color: var(--text);
}

.page-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    flex-direction: column;
    padding: 1rem;
    background: transparent;
}

.app-shell {
    width: 100%;
    max-width: 680px;
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 2.8rem 1.5rem 1.5rem 1.5rem;
    position: relative;
}

button {
    background: var(--button-color);
    color: white;
    border: none;
    padding: 0.6rem 1.3rem;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 500;
    font-size: 0.9rem;
    transition: background 0.2s, opacity 0.2s;
    outline: none;
}
button:hover { opacity: 0.9; }
button:disabled { opacity: 0.5; cursor: default; }
button.secondary { background: #757575; }
button.danger { background: var(--again); }
button.small { padding: 0.3rem 0.9rem; font-size: 0.8rem; }

input, textarea {
    width: 100%;
    padding: 0.8rem;
    margin: 0.4rem 0 0.8rem;
    border: 1px solid var(--border);
    border-radius: 10px;
    font-size: 0.95rem;
    background: #fafafa;
}

.hidden { display: none !important; }

/* Pestañas */
.tab-nav {
    display: flex;
    gap: 0.3rem;
    margin-bottom: 1.5rem;
    justify-content: center;
}
.tab-btn {
    padding: 0.4rem 0.8rem;
    background: transparent;
    color: #555;
    border-radius: 0;
    border-bottom: 2px solid transparent;
    font-weight: 500;
    cursor: pointer;
    transition: 0.2s;
    font-size: 1rem;
    text-decoration: none;
}
.tab-btn.active {
    background: transparent;
    color: var(--accent);
    border-bottom-color: var(--accent);
}
a.tab-btn { text-decoration: none !important; }

/* Nombre de categoría (enlace) */
.category-name {
    font-family: 'Fuzzy Bubbles', 'Comic Sans MS', cursive;
    color: var(--button-color);
    text-align: center;
    font-size: 1.1rem;
    margin-top: 0.2rem;
    margin-bottom: 1rem;
    text-decoration: none;
    display: block;
}
.category-name:hover {
    opacity: 0.8;
    text-decoration: underline;
}

/* Icono de ayuda */
.help-link {
    position: absolute;
    top: 0.8rem;
    right: 0.8rem;
    font-size: 1rem;
    text-decoration: none;
    color: #aaa;
    transition: color 0.2s;
    z-index: 10;
}
.help-link:hover { color: var(--accent); }

/* Cabecera principal */
.app-header {
    position: absolute;
    top: 0.8rem;
    left: 50%;
    transform: translateX(-50%);
    font-family: 'Courier', monospace;
    font-size: 1rem;
    color: var(--text);
    font-weight: 700;
    white-space: nowrap;
    z-index: 9;
    margin: 0;
    line-height: 1.2;
}
.app-header a { text-decoration: none; color: inherit; }
.app-header a:hover { opacity: 0.8; }

.version-badge {
    position: absolute;
    top: 0.8rem;
    right: 3.2rem;
    font-size: 0.7rem;
    color: #999;
    z-index: 11;
    font-weight: 400;
    letter-spacing: 0.5px;
    line-height: 1.2;
}

.status-bar {
    display: flex;
    justify-content: space-between;
    margin-bottom: 1.2rem;
    font-size: 0.85rem;
    color: #777;
}

.card-face {
    background: #fdfdfd;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.3rem;
    margin-bottom: 1rem;
    position: relative;
}

.question-text { font-size: 1.1rem; margin-bottom: 1rem; line-height: 1.5; }
.answer-area { margin: 1rem 0; }
#user-answer { height: auto; min-height: 2.5rem; }

.feedback-box {
    padding: 1rem;
    border-radius: 10px;
    margin: 1rem 0;
    font-weight: 500;
}
.feedback-box.again { background: #ffebee; border-left: 4px solid var(--again); }
.feedback-box.hard  { background: #fff3e0; border-left: 4px solid var(--hard); }
.feedback-box.good  { background: #e8f5e9; border-left: 4px solid var(--good); }
.feedback-box.perfect { background: #e3f2fd; border-left: 4px solid var(--perfect); }

.extra-info {
    background: #f3f5fd;
    padding: 1rem;
    border-radius: 10px;
    margin: 1rem 0;
    line-height: 1.5;
}

.discard-btn {
    position: absolute;
    top: 0.4rem;
    right: 0.6rem;
    background: none;
    border: none;
    color: #aaa;
    font-size: 1rem;
    cursor: pointer;
    padding: 0.2rem 0.4rem;
}
.discard-btn:hover { color: var(--again); }

.settings-block {
    background: #f8f8f8;
    border-radius: 12px;
    padding: 1.2rem;
    margin-bottom: 1.2rem;
}
.settings-block h3 { margin-bottom: 0.8rem; }

/* Rejilla colapsable */
details.card-grid-details {
    margin: 1rem 0;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.8rem 1rem;
    background: #fafbfc;
    transition: background 0.2s;
}
details.card-grid-details[open] {
    background: #f0f2f5;
}
details.card-grid-details summary {
    cursor: pointer;
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text);
    list-style: none;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
details.card-grid-details summary::-webkit-details-marker {
    display: none;
}
details.card-grid-details summary::before {
    content: '▶';
    display: inline-block;
    font-size: 0.8rem;
    transition: transform 0.2s;
    margin-right: 0.3rem;
}
details.card-grid-details[open] summary::before {
    transform: rotate(90deg);
}

.card-grid {
    margin-top: 1.5rem;
    margin-bottom: 0.5rem;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    justify-content: center;
}

.card-dot {
    width: 22px;
    height: 22px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.65rem;
    font-weight: 700;
    color: white;
    cursor: default;
    transition: background 0.2s;
}

.dot-pending  { background: #9e9e9e; }
.dot-new      { background: #fdd835; color: #333; }
.dot-again    { background: #c62828; }
.dot-hard     { background: #ef6c00; }
.dot-good     { background: #2e7d32; }
.dot-perfect  { background: #1976d2; }
.dot-mastered { background: #7b1fa2; }
.dot-discarded{ background: #e53935; }
.dot-obsolete { background: #a1887f; }

.card-grid a.card-dot {
    text-decoration: none !important;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    border-bottom: none !important;
    box-shadow: none !important;
}
.card-grid a.card-dot:hover {
    text-decoration: none !important;
    opacity: 0.8;
    transform: scale(1.1);
    transition: 0.2s;
}
/* Especificidad aumentada para no depender del orden en el archivo */
.card-grid a.card-dot.dot-new { color: #333; }

#level-indicator {
    font-size: 1rem;
    color: var(--accent);
    margin: 0.8rem 0;
    text-align: center;
    font-weight: 500;
}

.progress-link {
    display: block;
    margin: 1.5rem auto 0 auto;
    text-align: center;
    text-decoration: none !important;
}

.breadcrumb { margin-bottom: 1.5rem; font-size: 0.9rem; color: #777; }
.breadcrumb a { color: var(--accent); text-decoration: none; }
.breadcrumb a:hover { text-decoration: underline; }

.summary-title { font-size: 1.4rem; margin-bottom: 1.5rem; font-weight: 600; color: var(--text); }

.stats-cards {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: center;
    margin-top: 0.6rem;
    margin-bottom: 1.5rem;
}
.stat-item {
    background: #f0f3f6;
    border-radius: 6px;
    padding: 0.4rem 0.8rem;
    font-size: 0.8rem;
    font-weight: 500;
    color: #555;
    display: flex;
    align-items: center;
    gap: 0.3rem;
}
.stat-item strong { color: var(--text); margin-right: 0.1rem; }

.level-section h3 {
    font-size: 1rem;
    font-weight: 500;
    color: var(--accent);
    background: #edf1f4;
    padding: 0.5rem 0.8rem;
    border-radius: 6px;
    margin: 1rem 0 0.5rem;
}

.card-detail-title { font-size: 1.3rem; margin-bottom: 0.5rem; font-weight: 600; }
.card-detail-subtitle { font-size: 0.9rem; color: #777; margin-bottom: 1.2rem; }
.detail-section { margin-bottom: 1.2rem; }
.detail-section h3 { font-size: 1rem; font-weight: 500; margin-bottom: 0.5rem; color: var(--accent); }

.detail-table { width: 100%; border-collapse: collapse; }
.detail-table td { padding: 0.3rem 0; font-size: 0.9rem; border-bottom: 1px solid #f0f0f0; }
.detail-table td:first-child { font-weight: 500; color: #555; width: 40%; }

.meta-block, .progress-block { background: #f8f8f8; border-radius: 12px; padding: 1rem; margin: 1rem 0; }
.progress-block ul { list-style: none; padding-left: 0; }
.progress-block li { margin: 0.2rem 0; }

/* Footer blanco */
.app-footer {
    text-align: center;
    margin-top: 1.5rem;
    font-size: 0.75rem;
    color: #ffffff;
    background: transparent;
    padding: 0.5rem;
}
.app-footer a { color: #ffffff; text-decoration: none; }
.app-footer a:hover { text-decoration: underline; }

/* Píldoras de tags (botones pequeños) */
.tag-pill {
    display: inline-block;
    padding: 0.3rem 0.7rem;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    color: white !important;
    text-decoration: none !important;
    margin: 0.15rem 0.2rem;
    transition: opacity 0.2s, transform 0.1s;
}
.tag-pill:hover,
.tag-pill:focus {
    opacity: 0.85;
    transform: scale(1.05);
    text-decoration: none !important;
}
.tag-pill:active {
    transform: scale(0.97);
}

.card-face p, .extra-info p, .detail-section p { margin-bottom: 0.8rem; }

@media (max-width: 480px) {
    .stats-cards { flex-direction: column; align-items: flex-start; gap: 0.3rem; }
    .stat-item { width: 100%; }
}

.start-session-wrapper { display: flex; justify-content: flex-end; margin-top: 1rem; }

/* Modal de cambios */
#change-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.4);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}
.change-modal-content {
    background: white;
    padding: 2rem;
    border-radius: 12px;
    max-width: 700px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 8px 30px rgba(0,0,0,0.2);
}
.change-modal-content h2 {
    margin-bottom: 1rem;
    color: var(--text);
}
.change-modal-content h3 {
    margin: 1rem 0 0.5rem;
    color: var(--accent);
}
.change-modal-content ul {
    list-style: none;
    padding-left: 0;
    margin: 0.5rem 0;
}
.change-modal-content li {
    margin-bottom: 0.3rem;
}
.change-modal-content a {
    color: var(--accent);
    text-decoration: none;
}
.change-modal-content a:hover {
    text-decoration: underline;
}
#change-modal-close {
    margin-top: 1.5rem;
    width: 100%;
}

/* Banner de tarjeta archivada */
.obsolete-banner {
    background: #fff3e0;
    color: #e65100;
    padding: 0.8rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    font-weight: 500;
}