:root {
    --bg: #1a1a2e;
    --card-bg: #16213e;
    --accent: #e94560;
    --text: #ffffff;
    --text-muted: #a0a0b0;
    --highlight: #0f3460;
    --gold: #ffd700;
    --success: #4caf50;
    --danger: #f44336;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg);
    color: var(--text);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    overflow-x: hidden;
    transition: background-color 0.2s;
}

body.flash-correct {
    background-color: rgba(76, 175, 80, 0.2);
}

body.flash-wrong {
    background-color: rgba(233, 69, 96, 0.2);
}

header {
    text-align: center;
    padding: 1rem;
    position: relative;
}

.progress-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background-color: rgba(255, 255, 255, 0.1);
}

.progress-bar {
    height: 100%;
    background-color: var(--success);
    width: 0%;
    transition: width 0.3s ease;
}

h1 {
    font-size: 1.5rem;
    margin-top: 0.5rem;
    margin-bottom: 0.25rem;
}

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

main {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 1rem;
    max-width: 600px;
    margin: 0 auto;
    width: 100%;
}

#main-view {
    display: flex;
    flex-direction: column;
    flex: 1;
}

.hidden {
    display: none !important;
}

.controls-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    gap: 0.5rem;
}

button {
    font-family: inherit;
    border: none;
    outline: none;
    cursor: pointer;
    border-radius: 8px;
    min-height: 44px;
    min-width: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    transition: opacity 0.2s, transform 0.1s, background-color 0.2s;
}

button:active {
    transform: scale(0.96);
}

.controls-top button {
    flex: 1;
    padding: 0.5rem 0;
    font-size: 1.2rem;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.btn-text {
    font-size: 0.75rem;
}

@media (min-width: 400px) {
    .controls-top button {
        flex-direction: row;
        font-size: 1rem;
        gap: 0.5rem;
    }
    .btn-text {
        font-size: 0.9rem;
    }
}

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

.btn-smart-active {
    background-color: var(--success) !important;
}

.card-container {
    flex: 1;
    perspective: 1000px;
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 250px;
}

.card {
    width: 100%;
    height: 300px;
    cursor: pointer;
}

@media (min-height: 700px) {
    .card {
        height: 350px;
    }
}

@media (min-height: 800px) {
    .card {
        height: 400px;
    }
}

.card-inner {
    position: relative;
    width: 100%;
    height: 100%;
    text-align: center;
    transition: transform 0.6s cubic-bezier(0.4, 0.2, 0.2, 1);
    transform-style: preserve-3d;
}

.card.flipped .card-inner {
    transform: rotateY(180deg);
}

.card-front, .card-back {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    background-color: var(--card-bg);
    border-radius: 16px;
    padding: 2rem 1.5rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.card-back {
    transform: rotateY(180deg);
}

.word-container {
    margin-bottom: 1.5rem;
}

.word {
    font-size: 2rem;
    font-weight: bold;
    color: var(--gold);
    background-color: var(--highlight);
    padding: 0.2em 0.5em;
    border-radius: 8px;
    display: inline-block;
}

.sentence {
    font-size: 1rem;
    font-style: italic;
    line-height: 1.5;
    color: var(--text);
}

.english {
    font-size: 1.1rem;
    font-weight: normal;
    line-height: 1.5;
}

.tap-hint {
    position: absolute;
    bottom: 1rem;
    font-size: 0.8rem;
    color: var(--text-muted);
    opacity: 0.7;
}

.controls-bottom {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.btn-nav {
    background-color: transparent;
    color: var(--text);
    font-size: 1.5rem;
    padding: 0.5rem;
}

.counter {
    font-size: 1rem;
    font-weight: bold;
    color: var(--text-muted);
}

.action-buttons {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
}

.btn-action {
    flex: 1;
    padding: 1rem;
    font-weight: bold;
    color: white;
}

.btn-red {
    background-color: var(--accent);
}

.btn-green {
    background-color: var(--success);
}

/* Quiz View */
#quiz-view, #quiz-results {
    flex: 1;
    display: flex;
    flex-direction: column;
    width: 100%;
}

.quiz-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.quiz-question {
    text-align: center;
    margin-bottom: 2rem;
    background-color: var(--card-bg);
    padding: 2rem 1rem;
    border-radius: 16px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}

.quiz-options {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.btn-quiz-option {
    background-color: var(--card-bg);
    color: var(--text);
    width: 100%;
    height: 52px;
    border-radius: 8px;
    font-size: 1rem;
    transition: background-color 0.2s;
}

.btn-quiz-option.correct {
    background-color: var(--success) !important;
}

.btn-quiz-option.wrong {
    background-color: var(--accent) !important;
}

/* Quiz Results */
.score-display {
    text-align: center;
    margin: 2rem 0;
}

.score-number {
    font-size: 3rem;
    font-weight: bold;
    color: var(--gold);
}

.score-bar-container {
    width: 100%;
    height: 8px;
    background-color: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    margin-top: 1rem;
    overflow: hidden;
}

.score-bar {
    height: 100%;
    background-color: var(--success);
    width: 0%;
    transition: width 1s ease-out;
}

.mistakes-list {
    list-style: none;
    margin-bottom: 2rem;
}

.mistakes-list li {
    background-color: var(--card-bg);
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 0.5rem;
    border-left: 4px solid var(--accent);
}

.mistakes-list .correct-answer {
    color: var(--success);
    font-weight: bold;
    margin-top: 0.5rem;
    display: block;
}

/* Stats Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(26, 26, 46, 0.95);
    z-index: 1000;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 1rem;
}

.modal-content {
    background-color: var(--card-bg);
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.btn-close {
    background: transparent;
    color: var(--text);
    font-size: 1.5rem;
    min-width: 44px;
    min-height: 44px;
}

.stats-body {
    padding: 1.5rem;
    overflow-y: auto;
}

.stat-row {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 0;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}

.stats-body h3 {
    margin: 1.5rem 0 0.5rem 0;
    color: var(--gold);
    font-size: 1.1rem;
}

.stat-list {
    list-style: none;
}

.stat-list li {
    display: flex;
    justify-content: space-between;
    padding: 0.3rem 0;
    font-size: 0.9rem;
}

.mt-4 {
    margin-top: 1.5rem;
}
