* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: hsl(222, 47%, 55%);
    --primary-foreground: hsl(0, 0%, 100%);
    --secondary: hsl(220, 13%, 91%);
    --secondary-foreground: hsl(220, 9%, 13%);
    --muted: hsl(220, 13%, 91%);
    --muted-foreground: hsl(220, 9%, 46%);
    --destructive: hsl(0, 72%, 55%);
    --destructive-foreground: hsl(0, 0%, 100%);
    --border: hsl(220, 13%, 91%);
    --card: hsl(0, 0%, 100%);
    --card-foreground: hsl(220, 9%, 13%);
    --warning: hsl(35, 90%, 55%);
    --success: hsl(152, 60%, 42%);
    --background: hsl(0, 0%, 100%);
    --foreground: hsl(220, 9%, 13%);
    --radius: 0.5rem;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
    'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    background-color: var(--background);
    color: var(--foreground);
    line-height: 1.5;
}

.container {
    max-width: 42rem;
    margin: 0 auto;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    gap: 2rem;
    padding: 2rem 1rem;
}

@media (min-width: 768px) {
    .container {
    padding: 3rem 1.5rem;
    }
}

/* Buttons */
button {
    font-family: inherit;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
}

button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-weight: 500;
    padding: 0.5rem 1rem;
}

.btn-primary {
    background-color: var(--primary);
    color: var(--primary-foreground);
}

.btn-primary:hover:not(:disabled) {
    background-color: hsl(222, 47%, 50%);
}

.btn-outline {
    border: 1px solid var(--border);
    background-color: transparent;
    color: var(--foreground);
}

.btn-outline:hover:not(:disabled) {
    background-color: var(--secondary);
}

.btn-destructive {
    background-color: var(--destructive);
    color: var(--destructive-foreground);
}

.btn-lg {
    padding: 0.625rem 2rem;
    font-size: 1rem;
}

.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.875rem;
}

/* Cards */
.card {
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background-color: var(--card);
    box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05);
}

.card-content {
    padding: 1.5rem;
}

/* Start Screen */
.start-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2rem;
}

.hero {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    text-align: center;
}

.icon-box {
    display: flex;
    height: 4rem;
    width: 4rem;
    align-items: center;
    justify-content: center;
    border-radius: 1rem;
    background-color: var(--primary);
    color: var(--primary-foreground);
    font-size: 2rem;
}

.hero h1 {
    font-size: 1.875rem;
    font-weight: 700;
    letter-spacing: -0.025em;
}

@media (min-width: 768px) {
    .hero h1 {
    font-size: 2.25rem;
    }
}

.hero p {
    max-width: 28rem;
    color: var(--muted-foreground);
    line-height: 1.625;
}

.hero .highlight {
    font-weight: 600;
    color: var(--foreground);
}

/* Operators Grid */
.operators-card {
    width: 100%;
    max-width: 28rem;
}

.section-title {
    margin-bottom: 0.75rem;
    font-size: 0.875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.025em;
    color: var(--muted-foreground);
}

.operators-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 0.5rem;
}

.operator-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    border-radius: var(--radius);
    background-color: var(--secondary);
    padding: 0.75rem;
}

.operator-symbol {
    font-size: 1.25rem;
    font-weight: 700;
    font-family: 'Courier New', monospace;
}

.operator-label {
    font-size: 0.625rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--muted-foreground);
}

/* Difficulty Selector */
.difficulty-card {
    width: 100%;
    max-width: 28rem;
}

.difficulty-options {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.difficulty-option {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background-color: var(--card);
    padding: 1rem;
    text-align: left;
    cursor: pointer;
    transition: all 0.2s;
}

.difficulty-option:hover {
    background-color: hsl(220, 13%, 95%);
}

.difficulty-option.selected {
    border-color: var(--primary);
    background-color: hsl(222, 47%, 55%, 0.05);
    box-shadow: 0 0 0 1px hsl(222, 47%, 55%, 0.2);
}

.radio {
    margin-top: 0.125rem;
    height: 1rem;
    width: 1rem;
    flex-shrink: 0;
    border-radius: 50%;
    border: 2px solid hsl(220, 9%, 46%, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.difficulty-option.selected .radio {
    border-color: var(--primary);
    background-color: var(--primary);
}

.radio-dot {
    height: 0.375rem;
    width: 0.375rem;
    border-radius: 50%;
    background-color: var(--primary-foreground);
}

.difficulty-title {
    font-weight: 600;
    text-transform: capitalize;
    margin-bottom: 0.25rem;
}

.difficulty-desc {
    font-size: 0.875rem;
    color: var(--muted-foreground);
}

/* Game Header */
.game-header {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.title-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.title-icon {
    display: flex;
    height: 2.5rem;
    width: 2.5rem;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius);
    background-color: var(--primary);
    color: var(--primary-foreground);
    font-size: 1.25rem;
}

.title-text h1 {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.025em;
}

@media (min-width: 768px) {
    .title-text h1 {
    font-size: 1.5rem;
    }
}

.title-text p {
    font-size: 0.875rem;
    color: var(--muted-foreground);
}

.stats-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem;
}

.difficulty-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 0.375rem;
}

.difficulty-pill {
    display: inline-flex;
    align-items: center;
    border-radius: 9999px;
    padding: 0.25rem 0.75rem;
    font-size: 0.75rem;
    font-weight: 600;
    background-color: var(--secondary);
    color: var(--secondary-foreground);
    border: none;
    cursor: pointer;
    transition: all 0.2s;
}

.difficulty-pill:hover:not(:disabled) {
    background-color: hsl(220, 13%, 85%);
}

.difficulty-pill:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.difficulty-pill.active-easy {
    background-color: var(--success);
    color: white;
}

.difficulty-pill.active-medium {
    background-color: var(--warning);
    color: white;
}

.difficulty-pill.active-hard {
    background-color: var(--destructive);
    color: white;
}

.difficulty-pill.active-extra-hard {
    background-color: hsl(270, 60%, 50%);
    color: white;
}

.divider {
    display: none;
    height: 1.25rem;
    width: 1px;
    background-color: var(--border);
}

@media (min-width: 768px) {
    .divider {
    display: block;
    }
}

.stat {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    font-size: 0.875rem;
}

.stat-icon {
    font-size: 1rem;
}

.stat-value {
    font-weight: 600;
}

.stat-muted {
    color: var(--muted-foreground);
    font-weight: 400;
}

/* Progress Bar */
.progress {
    position: relative;
    height: 0.5rem;
    width: 100%;
    overflow: hidden;
    border-radius: 9999px;
    background-color: var(--secondary);
}

.progress-bar {
    height: 100%;
    background-color: var(--primary);
    transition: width 0.3s;
}

/* Question Card */
.question-container {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.formula-card {
    border: 2px solid var(--border);
}

.formula-card .card-content {
    padding: 1.5rem;
}

@media (min-width: 768px) {
    .formula-card .card-content {
    padding: 2rem;
    }
}

.formula {
    text-align: center;
    font-family: 'Courier New', monospace;
    font-size: 1.5rem;
    line-height: 1.625;
    letter-spacing: 0.025em;
}

@media (min-width: 768px) {
    .formula {
    font-size: 1.875rem;
    }
}

.hint-card {
    background-color: hsl(220, 13%, 91%, 0.5);
}

.hint-text {
    font-size: 0.875rem;
    color: var(--muted-foreground);
    line-height: 1.625;
}

.hint-text .emphasis {
    font-weight: 600;
    color: var(--foreground);
}

/* Operator Buttons */
.operators-buttons {
    display: grid;
    gap: 0.5rem;
    grid-template-columns: repeat(5, 1fr);
}

.operators-buttons.extra-hard {
    grid-template-columns: repeat(3, 1fr);
}

@media (min-width: 640px) {
    .operators-buttons {
    gap: 0.75rem;
    }

    .operators-buttons.extra-hard {
    grid-template-columns: repeat(6, 1fr);
    }
}

.operator-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    padding: 1rem 0.25rem;
    background-color: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.2s;
}

.operator-btn:hover:not(:disabled) {
    background-color: var(--secondary);
}

.operator-btn:disabled {
    cursor: default;
}

.operator-btn.correct {
    background-color: var(--success);
    color: white;
    border-color: transparent;
    box-shadow: 0 0 0 2px hsl(152, 60%, 42%, 0.3);
}

.operator-btn.incorrect {
    background-color: var(--destructive);
    color: white;
    box-shadow: 0 0 0 2px hsl(0, 72%, 55%, 0.3);
}

.operator-btn-symbol {
    font-size: 1.5rem;
    font-weight: 700;
    font-family: 'Courier New', monospace;
}

.operator-btn-label {
    font-size: 0.563rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: -0.025em;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    width: 100%;
    text-align: center;
}

@media (min-width: 640px) {
    .operator-btn-label {
    font-size: 0.75rem;
    }
}

/* Feedback */
.feedback-card {
    border: 2px solid;
}

.feedback-card.correct {
    border-color: hsl(152, 60%, 42%, 0.4);
    background-color: hsl(152, 60%, 42%, 0.05);
}

.feedback-card.incorrect {
    border-color: hsl(0, 72%, 55%, 0.4);
    background-color: hsl(0, 72%, 55%, 0.05);
}

.feedback-content {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
}

.feedback-icon {
    margin-top: 0.125rem;
    font-size: 1.25rem;
    flex-shrink: 0;
}

.feedback-icon.correct {
    color: var(--success);
}

.feedback-icon.incorrect {
    color: var(--destructive);
}

.feedback-title {
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.feedback-title.correct {
    color: var(--success);
}

.feedback-title.incorrect {
    color: var(--destructive);
}

.feedback-text {
    font-size: 0.875rem;
    line-height: 1.625;
    color: var(--muted-foreground);
    margin-bottom: 0.5rem;
}

.feedback-answer {
    font-size: 0.875rem;
    color: var(--muted-foreground);
}

.feedback-answer .answer {
    font-weight: 700;
    font-family: 'Courier New', monospace;
    color: var(--foreground);
}

.feedback-actions {
    margin-top: 1rem;
    display: flex;
    justify-content: flex-end;
}

/* Results Screen */
.results-card {
    max-width: 32rem;
    margin: 0 auto;
    border: 2px solid var(--border);
}

.results-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
    padding: 2rem;
    text-align: center;
}

.trophy-icon {
    display: flex;
    height: 4rem;
    width: 4rem;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background-color: hsl(35, 90%, 55%, 0.1);
    color: var(--warning);
    font-size: 2rem;
}

.results-grade {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

@media (min-width: 768px) {
    .results-grade {
    font-size: 1.875rem;
    }
}

.results-message {
    color: var(--muted-foreground);
}

.score-display {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
}

.score-numbers {
    display: flex;
    align-items: baseline;
    gap: 0.25rem;
}

.score-main {
    font-size: 3rem;
    font-weight: 700;
    color: var(--primary);
}

.score-total {
    font-size: 1.25rem;
    color: var(--muted-foreground);
}

.score-percent {
    font-size: 0.875rem;
    color: var(--muted-foreground);
}

.results-actions {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    width: 100%;
}

@media (min-width: 640px) {
    .results-actions {
    flex-direction: row;
    justify-content: center;
    }
}

.hidden {
    display: none;
}