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

:root {
    --bg: #fff0f5;
    --surface: #ffffff;
    --border: #f0c0d0;
    --text: #4a2040;
    --text-muted: #9a6080;
    --accent: #e84393;
    --accent-hover: #fd79a8;
    --green: #00b894;
    --red: #d63031;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
}

header {
    border-bottom: 1px solid var(--border);
    padding: 1rem 2rem;
    position: sticky;
    top: 0;
    background: var(--bg);
    z-index: 100;
}

nav {
    max-width: 1000px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--accent);
}

nav ul {
    list-style: none;
    display: flex;
    gap: 1.5rem;
}

nav a {
    color: var(--text-muted);
    text-decoration: none;
    transition: color 0.2s;
}

nav a:hover {
    color: var(--text);
}

main {
    max-width: 1000px;
    margin: 0 auto;
    padding: 2rem;
}

#hero {
    text-align: center;
    padding: 3rem 0;
}

#hero h1 {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
}

#hero p {
    color: var(--text-muted);
    font-size: 1.2rem;
}

h2 {
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border);
}

/* Editor */
#editor-container {
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
}

.CodeMirror {
    height: auto;
    min-height: 120px;
    max-height: 400px;
    font-size: 15px;
    line-height: 1.5;
}

#controls {
    display: flex;
    gap: 0.5rem;
    margin: 0.75rem 0;
}

button {
    padding: 0.5rem 1.25rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface);
    color: var(--text);
    cursor: pointer;
    font-size: 0.9rem;
    transition: background 0.2s, border-color 0.2s;
}

button:hover:not(:disabled) {
    background: var(--border);
}

#run-btn {
    background: #e84393;
    border-color: #d63384;
    color: #fff;
}

#run-btn:hover:not(:disabled) {
    background: #fd79a8;
}

#run-btn:disabled {
    opacity: 0.6;
    cursor: wait;
}

/* Output */
#output-container {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1rem;
    min-height: 60px;
    max-height: 300px;
    overflow-y: auto;
    margin-bottom: 3rem;
}

#output {
    font-family: 'SF Mono', 'Fira Code', 'Fira Mono', Menlo, Consolas, monospace;
    font-size: 14px;
    white-space: pre-wrap;
    word-break: break-word;
    color: var(--text);
}

.output-error {
    color: var(--red) !important;
}

.output-success {
    color: var(--green) !important;
}

.output-wrong {
    color: #b45309 !important;
}

/* Problems */
#problems {
    margin-top: 2rem;
}

#selector-row {
    display: flex;
    gap: 1rem;
    align-items: end;
    flex-wrap: wrap;
    margin-bottom: 1.5rem;
}

#selector-row label {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-muted);
}

#selector-row select {
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface);
    color: var(--text);
    font-size: 0.9rem;
    min-width: 200px;
}

#generate-btn {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
    font-weight: 600;
    padding: 0.5rem 1.5rem;
}

#generate-btn:hover {
    background: var(--accent-hover);
}

#problem-display {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1.25rem;
}

#problem-display h3 {
    margin-bottom: 0.5rem;
    color: var(--accent);
}

#problem-display p {
    color: var(--text);
    font-size: 0.95rem;
    line-height: 1.6;
}

#problem-display code {
    background: var(--bg);
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    font-size: 0.9em;
}

footer {
    text-align: center;
    padding: 2rem;
    color: var(--text-muted);
    border-top: 1px solid var(--border);
    margin-top: 2rem;
}

/* Sparkles */
.sparkle {
    position: fixed;
    pointer-events: none;
    font-size: 32px;
    z-index: 9999;
    animation: sparkle-fall linear forwards;
}

@keyframes sparkle-fall {
    0% {
        opacity: 1;
        transform: translateY(0) rotate(0deg) scale(1);
    }
    100% {
        opacity: 0;
        transform: translateY(120px) rotate(360deg) scale(0);
    }
}
