/* ===========================
   CSS Custom Properties
   =========================== */
:root {
    --bg-primary: #0a0e1a;
    --bg-secondary: #111827;
    --bg-card: rgba(255, 255, 255, 0.04);
    --bg-card-hover: rgba(255, 255, 255, 0.07);
    --border-glass: rgba(255, 255, 255, 0.08);
    --border-glass-strong: rgba(255, 255, 255, 0.15);

    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;

    --accent-blue: #6366f1;
    --accent-purple: #8b5cf6;
    --accent-pink: #ec4899;
    --accent-green: #10b981;
    --accent-red: #ef4444;
    --accent-amber: #f59e0b;

    --gradient-primary: linear-gradient(135deg, #6366f1, #8b5cf6, #a78bfa);
    --gradient-warm: linear-gradient(135deg, #f59e0b, #ec4899);
    --gradient-success: linear-gradient(135deg, #10b981, #34d399);
    --gradient-danger: linear-gradient(135deg, #ef4444, #f97316);

    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.5);
    --shadow-glow-blue: 0 0 30px rgba(99, 102, 241, 0.15);
    --shadow-glow-green: 0 0 30px rgba(16, 185, 129, 0.15);
    --shadow-glow-red: 0 0 30px rgba(239, 68, 68, 0.15);

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 20px;
    --radius-xl: 28px;

    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --transition-fast: 150ms ease;
    --transition-normal: 250ms ease;
    --transition-slow: 400ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* ===========================
   Reset & Base
   =========================== */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-family);
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    line-height: 1.6;
}

/* Animated background */
body::before {
    content: '';
    position: fixed;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(ellipse at 20% 50%, rgba(99, 102, 241, 0.08) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 20%, rgba(139, 92, 246, 0.06) 0%, transparent 50%),
        radial-gradient(ellipse at 50% 80%, rgba(236, 72, 153, 0.05) 0%, transparent 50%);
    animation: bgShift 20s ease-in-out infinite alternate;
    z-index: 0;
    pointer-events: none;
}

@keyframes bgShift {
    0% {
        transform: translate(0, 0) rotate(0deg);
    }

    100% {
        transform: translate(-3%, -3%) rotate(3deg);
    }
}

/* ===========================
   Layout
   =========================== */
.app-container {
    position: relative;
    z-index: 1;
    max-width: 700px;
    margin: 0 auto;
    padding: 2rem 1.25rem 4rem;
}

/* ===========================
   Header
   =========================== */
.app-header {
    text-align: center;
    margin-bottom: 2rem;
}

.logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}

.logo-icon {
    font-size: 2rem;
    filter: drop-shadow(0 2px 8px rgba(99, 102, 241, 0.3));
}

.logo h1 {
    font-size: 1.75rem;
    font-weight: 800;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.02em;
}

.tagline {
    color: var(--text-secondary);
    font-size: 0.95rem;
    font-weight: 400;
}

/* ===========================
   Domain Selector
   =========================== */
.domain-selector {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
    flex-wrap: wrap;
    margin-bottom: 2rem;
}

.domain-chip {
    padding: 0.5rem 1.25rem;
    border-radius: 100px;
    border: 1px solid var(--border-glass);
    background: var(--bg-card);
    color: var(--text-secondary);
    font-family: var(--font-family);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-normal);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.domain-chip:hover {
    border-color: var(--border-glass-strong);
    background: var(--bg-card-hover);
    color: var(--text-primary);
    transform: translateY(-1px);
}

.domain-chip.active {
    background: var(--gradient-primary);
    border-color: transparent;
    color: white;
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.3);
}

/* ===========================
   Glass Card
   =========================== */
.glass-card {
    background: var(--bg-card);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-lg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    padding: 2rem;
    transition: all var(--transition-slow);
}

/* ===========================
   Screens
   =========================== */
.screen {
    animation: fadeIn 0.4s ease;
}

.hidden {
    display: none !important;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(12px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ===========================
   Start Screen
   =========================== */
.start-card {
    text-align: center;
    padding: 3rem 2rem;
}

.start-icon {
    font-size: 3.5rem;
    margin-bottom: 1.25rem;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.08);
    }
}

.start-card h2 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.75rem;
    letter-spacing: -0.01em;
}

.start-card>p {
    color: var(--text-secondary);
    font-size: 0.95rem;
    max-width: 450px;
    margin: 0 auto 1.75rem;
    line-height: 1.6;
}

.rule-summary {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 2rem;
    text-align: left;
}

.rule {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.88rem;
    color: var(--text-secondary);
    padding: 0.75rem 1rem;
    background: rgba(255, 255, 255, 0.02);
    border-radius: var(--radius-md);
    border: 1px solid rgba(255, 255, 255, 0.04);
}

.rule strong {
    color: var(--text-primary);
}

.rule-badge {
    flex-shrink: 0;
    padding: 0.25rem 0.6rem;
    border-radius: 6px;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.rule-badge.silent {
    background: rgba(99, 102, 241, 0.15);
    color: #a5b4fc;
}

.rule-badge.pronounced {
    background: rgba(236, 72, 153, 0.15);
    color: #f9a8d4;
}

/* ===========================
   Primary Button
   =========================== */
.btn-primary {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.9rem 2rem;
    background: var(--gradient-primary);
    border: none;
    border-radius: 100px;
    color: white;
    font-family: var(--font-family);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-normal);
    box-shadow: 0 4px 20px rgba(99, 102, 241, 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 25px rgba(99, 102, 241, 0.4);
}

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

.btn-arrow {
    transition: transform var(--transition-fast);
}

.btn-primary:hover .btn-arrow {
    transform: translateX(3px);
}

/* ===========================
   Progress Bar
   =========================== */
.progress-container {
    margin-bottom: 1.5rem;
}

.progress-bar {
    width: 100%;
    height: 6px;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 100px;
    overflow: hidden;
    margin-bottom: 0.6rem;
}

.progress-fill {
    height: 100%;
    background: var(--gradient-primary);
    border-radius: 100px;
    transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    width: 0%;
    position: relative;
}

.progress-fill::after {
    content: '';
    position: absolute;
    right: 0;
    top: 0;
    width: 20px;
    height: 100%;
    background: rgba(255, 255, 255, 0.3);
    filter: blur(4px);
}

.progress-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.streak-badge {
    font-weight: 600;
    color: var(--accent-amber);
    opacity: 0;
    transition: opacity var(--transition-normal);
}

.streak-badge.visible {
    opacity: 1;
}

/* ===========================
   Sentence Card
   =========================== */
.sentence-card {
    text-align: center;
    margin-bottom: 1.5rem;
    min-height: 160px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.sentence-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 600;
    margin-bottom: 1.25rem;
}

.sentence-text {
    font-size: 1.35rem;
    font-weight: 500;
    line-height: 1.7;
    color: var(--text-primary);
    letter-spacing: 0.01em;
}

.sentence-text .highlight {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.2), rgba(139, 92, 246, 0.2));
    color: #c4b5fd;
    padding: 0.15em 0.45em;
    border-radius: 6px;
    font-weight: 700;
    border: 1px solid rgba(139, 92, 246, 0.25);
}

/* Card animations */
.sentence-card.correct-anim {
    animation: correctPulse 0.5s ease;
    border-color: rgba(16, 185, 129, 0.3);
    box-shadow: var(--shadow-glow-green);
}

.sentence-card.wrong-anim {
    animation: wrongShake 0.5s ease;
    border-color: rgba(239, 68, 68, 0.3);
    box-shadow: var(--shadow-glow-red);
}

@keyframes correctPulse {
    0% {
        transform: scale(1);
    }

    30% {
        transform: scale(1.02);
    }

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

@keyframes wrongShake {

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

    15% {
        transform: translateX(-6px);
    }

    30% {
        transform: translateX(6px);
    }

    45% {
        transform: translateX(-4px);
    }

    60% {
        transform: translateX(4px);
    }

    75% {
        transform: translateX(-2px);
    }

    90% {
        transform: translateX(2px);
    }
}

/* ===========================
   Answer Buttons
   =========================== */
.answer-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.btn-answer {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.4rem;
    padding: 1.5rem 1rem;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-glass);
    background: var(--bg-card);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    cursor: pointer;
    transition: all var(--transition-normal);
    font-family: var(--font-family);
}

.btn-answer:hover:not(:disabled) {
    transform: translateY(-3px);
    border-color: var(--border-glass-strong);
    box-shadow: var(--shadow-md);
}

.btn-answer:active:not(:disabled) {
    transform: translateY(-1px);
}

.btn-answer:disabled {
    cursor: not-allowed;
    opacity: 0.5;
}

.btn-answer-icon {
    font-size: 2rem;
    line-height: 1;
}

.btn-answer-label {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
}

.btn-answer-sub {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.btn-silent:hover:not(:disabled) {
    background: rgba(99, 102, 241, 0.1);
    border-color: rgba(99, 102, 241, 0.3);
}

.btn-pronounced:hover:not(:disabled) {
    background: rgba(236, 72, 153, 0.1);
    border-color: rgba(236, 72, 153, 0.3);
}

/* Selected states */
.btn-answer.selected-correct {
    background: rgba(16, 185, 129, 0.12);
    border-color: rgba(16, 185, 129, 0.4);
    box-shadow: var(--shadow-glow-green);
}

.btn-answer.selected-wrong {
    background: rgba(239, 68, 68, 0.12);
    border-color: rgba(239, 68, 68, 0.4);
    box-shadow: var(--shadow-glow-red);
}

.btn-answer.correct-highlight {
    background: rgba(16, 185, 129, 0.08);
    border-color: rgba(16, 185, 129, 0.3);
}

/* ===========================
   Feedback Card
   =========================== */
.feedback-card {
    animation: slideUp 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    padding: 1.5rem;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(15px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.feedback-header {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-bottom: 0.75rem;
}

.feedback-icon {
    font-size: 1.5rem;
}

.feedback-title {
    font-size: 1.1rem;
    font-weight: 700;
}

.feedback-card.correct .feedback-title {
    color: var(--accent-green);
}

.feedback-card.incorrect .feedback-title {
    color: var(--accent-red);
}

.feedback-explanation {
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.6;
    margin-bottom: 1.25rem;
}

.btn-next {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.65rem 1.5rem;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--border-glass);
    border-radius: 100px;
    color: var(--text-primary);
    font-family: var(--font-family);
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-normal);
}

.btn-next:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--border-glass-strong);
    transform: translateY(-1px);
}

/* ===========================
   Results Screen
   =========================== */
.results-card {
    text-align: center;
    padding: 3rem 2rem;
}

.results-icon {
    font-size: 3.5rem;
    margin-bottom: 1rem;
    animation: bounceIn 0.6s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

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

    60% {
        transform: scale(1.15);
    }

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

.results-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 1.75rem;
}

.score-display {
    margin-bottom: 2rem;
}

.score-circle {
    position: relative;
    width: 120px;
    height: 120px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
}

.score-circle svg {
    position: absolute;
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
}

.score-bg {
    fill: none;
    stroke: rgba(255, 255, 255, 0.06);
    stroke-width: 8;
}

.score-ring {
    fill: none;
    stroke: url(#scoreGradient);
    stroke-width: 8;
    stroke-linecap: round;
    stroke-dasharray: 326.73;
    stroke-dashoffset: 326.73;
    transition: stroke-dashoffset 1.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.score-number {
    font-size: 1.75rem;
    font-weight: 800;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    z-index: 1;
}

.results-stats {
    display: flex;
    justify-content: center;
    gap: 2.5rem;
    margin-bottom: 2rem;
}

.stat {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
}

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

/* ===========================
   Text Input Quiz (Numbers)
   =========================== */
.prompt-content {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.prompt-number {
    font-size: 2.5rem !important;
    font-weight: 800 !important;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.02em;
}

.btn-audio {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 1rem;
    border-radius: 100px;
    border: 1px solid var(--border-glass);
    background: var(--bg-card);
    color: var(--text-secondary);
    font-family: var(--font-family);
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-normal);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.btn-audio:hover {
    background: rgba(99, 102, 241, 0.1);
    border-color: rgba(99, 102, 241, 0.3);
    color: var(--text-primary);
    transform: translateY(-1px);
}

.btn-audio:active {
    transform: translateY(0);
}

.btn-audio.playing {
    background: rgba(99, 102, 241, 0.15);
    border-color: rgba(99, 102, 241, 0.4);
    color: #a5b4fc;
    animation: audioPulse 1s ease-in-out infinite;
}

@keyframes audioPulse {

    0%,
    100% {
        box-shadow: 0 0 0 0 rgba(99, 102, 241, 0.2);
    }

    50% {
        box-shadow: 0 0 12px 4px rgba(99, 102, 241, 0.15);
    }
}

.btn-audio svg {
    flex-shrink: 0;
}

.input-area {
    margin-bottom: 1.5rem;
}

.input-wrapper {
    display: flex;
    gap: 0.75rem;
    align-items: stretch;
}

.text-input {
    flex: 1;
    padding: 0.9rem 1.25rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-glass);
    background: var(--bg-card);
    color: var(--text-primary);
    font-family: var(--font-family);
    font-size: 1.05rem;
    font-weight: 500;
    outline: none;
    transition: all var(--transition-normal);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.text-input::placeholder {
    color: var(--text-muted);
    font-weight: 400;
}

.text-input:focus {
    border-color: rgba(99, 102, 241, 0.4);
    box-shadow: 0 0 20px rgba(99, 102, 241, 0.1);
}

.text-input:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.text-input.correct-input {
    border-color: rgba(16, 185, 129, 0.4);
    box-shadow: 0 0 20px rgba(16, 185, 129, 0.1);
}

.text-input.wrong-input {
    border-color: rgba(239, 68, 68, 0.4);
    box-shadow: 0 0 20px rgba(239, 68, 68, 0.1);
}

.btn-submit {
    padding: 0.9rem 1.75rem;
    border-radius: var(--radius-md);
    border: none;
    background: var(--gradient-primary);
    color: white;
    font-family: var(--font-family);
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all var(--transition-normal);
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.25);
    white-space: nowrap;
}

.btn-submit:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.35);
}

.btn-submit:active:not(:disabled) {
    transform: translateY(0);
}

.btn-submit:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.input-hint {
    margin-top: 0.5rem;
    font-size: 0.8rem;
    color: var(--text-muted);
    min-height: 1.2em;
}

/* Mode toggle chips for numbers domain */
.mode-toggle {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
    margin-bottom: 1.75rem;
}

.mode-chip {
    padding: 0.4rem 1rem;
    border-radius: 100px;
    border: 1px solid var(--border-glass);
    background: var(--bg-card);
    color: var(--text-secondary);
    font-family: var(--font-family);
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-normal);
}

.mode-chip:hover {
    border-color: var(--border-glass-strong);
    color: var(--text-primary);
}

.mode-chip.active {
    background: rgba(99, 102, 241, 0.15);
    border-color: rgba(99, 102, 241, 0.3);
    color: #a5b4fc;
}

/* ===========================
   Responsive
   =========================== */
@media (max-width: 500px) {
    .app-container {
        padding: 1.25rem 1rem 3rem;
    }

    .logo h1 {
        font-size: 1.4rem;
    }

    .start-card,
    .results-card {
        padding: 2rem 1.25rem;
    }

    .sentence-text {
        font-size: 1.15rem;
    }

    .answer-buttons {
        gap: 0.75rem;
    }

    .btn-answer {
        padding: 1.2rem 0.75rem;
    }

    .results-stats {
        gap: 1.5rem;
    }
}