@font-face {
    font-family: 'OpenDyslexic';
    src: url('../fonts/OpenDyslexic-Regular.woff2') format('woff2');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

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

:root {
    --primary: #4361ee;
    --primary-dark: #3451d1;
    --text: #212529;
    --text-muted: #6c757d;
    --bg: #f0f4ff;
    --card-bg: #ffffff;
    --border: #dee2e6;
    --word-color: #1a1a2e;
}

body {
    font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
}

#app {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ── Screens ── */

.screen {
    flex: 1;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem 1rem;
}

.screen-session {
    background: #fff;
    padding: 0;
    justify-content: stretch;
    align-items: stretch;
}

/* ── Card ── */

.card {
    background: var(--card-bg);
    border-radius: 1rem;
    padding: 2rem;
    box-shadow: 0 2px 16px rgba(0, 0, 0, 0.08);
    width: 100%;
    max-width: 560px;
}

/* ── Buttons ── */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.875rem 2rem;
    border: none;
    border-radius: 0.75rem;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, transform 0.1s;
    user-select: none;
    -webkit-user-select: none;
}

.btn:active {
    transform: scale(0.97);
}

.btn-primary {
    background: var(--primary);
    color: #fff;
}

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-secondary {
    background: #e9ecef;
    color: var(--text);
}

.btn-secondary:hover {
    background: #dee2e6;
}

.btn-block {
    width: 100%;
}

.btn-xl {
    font-size: 1.4rem;
    padding: 1.25rem 2rem;
    border-radius: 1rem;
}

.btn-sm {
    font-size: 0.875rem;
    padding: 0.5rem 1rem;
}

.btn-row {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-top: 1.5rem;
}

/* ── Typography ── */

.app-title {
    font-size: 1.75rem;
    font-weight: 800;
    color: var(--primary);
    margin-bottom: 0.25rem;
}

.app-subtitle {
    color: var(--text-muted);
    margin-bottom: 1.5rem;
}

.section-title {
    font-size: 1.15rem;
    font-weight: 700;
    margin-bottom: 1.25rem;
}

/* ── Last session summary ── */

.last-session {
    background: var(--bg);
    border-radius: 0.75rem;
    padding: 0.875rem 1rem;
    margin-bottom: 1.5rem;
}

.last-session-label {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 0.4rem;
}

.last-session-stats {
    display: flex;
    gap: 1.25rem;
    flex-wrap: wrap;
    font-size: 0.9rem;
}

.last-session-stats span strong {
    color: var(--primary);
}

/* ── Config form ── */

.form-group {
    margin-bottom: 1.25rem;
}

.form-label {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    font-weight: 600;
    margin-bottom: 0.4rem;
}

.form-label-value {
    font-weight: 700;
    color: var(--primary);
    font-size: 1rem;
}

input[type="range"] {
    width: 100%;
    accent-color: var(--primary);
    height: 6px;
    cursor: pointer;
}

input[type="range"]:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.dist-auto-hint {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

.config-divider {
    border: none;
    border-top: 1px solid var(--border);
    margin: 1.25rem 0;
}

/* ── Session: header ── */

.session-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.875rem 1.5rem;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.session-progress-text {
    font-size: 0.9rem;
    color: var(--text-muted);
}

.session-timer {
    font-size: 0.9rem;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
    min-width: 52px;
    text-align: right;
}

/* ── Session: progress bar ── */

.progress-bar {
    height: 5px;
    background: #e9ecef;
    flex-shrink: 0;
}

.progress-bar-fill {
    height: 100%;
    background: var(--primary);
    transition: width 0.25s ease;
}

/* ── Session: word area ── */

.word-area {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.pseudo-word {
    font-size: clamp(3.5rem, 14vw, 7.5rem);
    font-weight: 700;
    color: var(--word-color);
    letter-spacing: 0.06em;
    text-align: center;
    user-select: none;
    -webkit-user-select: none;
}

/* ── Session: footer ── */

.session-footer {
    padding: 1.25rem 1.5rem 2rem;
    flex-shrink: 0;
}

/* ── Ready screen ── */

.ready-icon {
    font-size: 3.5rem;
    margin-bottom: 0.75rem;
    text-align: center;
}

.ready-title {
    font-size: 1.75rem;
    font-weight: 800;
    text-align: center;
    margin-bottom: 0.4rem;
}

.ready-subtitle {
    color: var(--text-muted);
    text-align: center;
    margin-bottom: 1.75rem;
    font-size: 1rem;
    line-height: 1.5;
}

/* ── Results ── */

.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.875rem;
    margin: 1.25rem 0;
}

.stat-box {
    background: var(--bg);
    border-radius: 0.75rem;
    padding: 1rem;
    text-align: center;
}

.stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--primary);
    font-variant-numeric: tabular-nums;
}

.stat-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 0.2rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.results-meta {
    text-align: center;
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

/* ── Keyboard hint ── */

.kbd-hint {
    text-align: center;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 0.75rem;
}

kbd {
    background: #e9ecef;
    border: 1px solid #ced4da;
    border-radius: 4px;
    padding: 1px 6px;
    font-size: 0.8rem;
    font-family: inherit;
}

/* ── Profiles ── */

.profile-badge {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-bottom: 1.5rem;
}

.profile-badge-name {
    font-weight: 600;
    color: var(--text);
}

.profile-badge-switch {
    background: none;
    border: none;
    color: var(--primary);
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    padding: 0;
    text-decoration: underline;
}

.profile-list {
    display: flex;
    flex-direction: column;
    gap: 0.625rem;
    margin-bottom: 1.25rem;
}

.profile-item {
    display: flex;
    align-items: center;
    padding: 0.875rem 1rem;
    background: var(--bg);
    border-radius: 0.75rem;
    border: 2px solid transparent;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
}

.profile-item:hover {
    background: #e4e9fb;
}

.profile-item.active {
    border-color: var(--primary);
    background: #eef1fd;
}

.profile-item-info {
    flex: 1;
}

.profile-item-name {
    font-weight: 700;
    font-size: 1rem;
}

.profile-item-meta {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 0.15rem;
}

.profile-item-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.btn-danger {
    background: #fee2e2;
    color: #dc2626;
}

.btn-danger:hover {
    background: #fecaca;
}

.new-profile-form {
    display: flex;
    gap: 0.5rem;
}

.new-profile-form input[type="text"] {
    flex: 1;
    padding: 0.75rem 1rem;
    border: 2px solid var(--border);
    border-radius: 0.75rem;
    font-size: 1rem;
    font-family: inherit;
    color: var(--text);
    outline: none;
    transition: border-color 0.15s;
}

.new-profile-form input[type="text"]:focus {
    border-color: var(--primary);
}

/* ── Dyslexia-friendly font ── */

body.font-dyslexic .pseudo-word {
    font-family: 'OpenDyslexic', sans-serif;
    letter-spacing: 0.08em;
}

.font-toggle {
    background: none;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    padding: 0.3rem 0.75rem;
    font-size: 0.8rem;
    color: var(--text-muted);
    cursor: pointer;
    line-height: 1.4;
    white-space: nowrap;
    transition: border-color 0.15s, color 0.15s;
}

.font-toggle:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.font-toggle.active {
    border-color: var(--primary);
    color: var(--primary);
    background: #eef1fd;
    font-weight: 600;
}

.toggle-short { display: none; }

.session-footer-buttons {
    display: flex;
    gap: 0.75rem;
    align-items: stretch;
}

.session-footer-buttons .btn-primary {
    flex: 1;
}

.btn-cancel {
    background: #fee2e2;
    color: #dc2626;
    font-size: 1rem;
    padding: 0.875rem 1.25rem;
    border-radius: 0.75rem;
    white-space: nowrap;
}

.btn-cancel:hover {
    background: #fecaca;
}

/* ── Responsive ── */

@media (max-width: 480px) {
    .card {
        padding: 1.5rem;
    }

    .last-session-stats {
        gap: 0.75rem;
    }

    .toggle-long { display: none; }
    .toggle-short { display: inline; }
}
