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

:root {
    --bg: #0a0a0f;
    --surface: #13131a;
    --border: #23232f;
    --text: #e4e4e8;
    --text-dim: #8888a0;
    --accent: #6c63ff;
    --accent-glow: rgba(108, 99, 255, 0.25);
    --danger: #ff6b6b;
    --radius: 12px;
    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

/* Screens */
.screen {
    display: none;
    min-height: 100vh;
    padding: 3rem 1.5rem;
    align-items: center;
    justify-content: center;
}

.screen.active {
    display: flex;
}

.container {
    max-width: 640px;
    width: 100%;
    margin: 0 auto;
}

.container.center {
    text-align: center;
}

/* Typography */
h1 {
    font-size: 2.5rem;
    font-weight: 700;
    line-height: 1.2;
    margin-bottom: 1rem;
    letter-spacing: -0.02em;
}

h2 {
    font-size: 1.5rem;
    font-weight: 600;
    line-height: 1.3;
    margin-bottom: 1.5rem;
}

.accent {
    color: var(--accent);
}

.subtitle {
    color: var(--text-dim);
    font-size: 1.1rem;
    margin-bottom: 2.5rem;
    line-height: 1.6;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 1.75rem;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    border: none;
    transition: all 0.2s ease;
    font-family: var(--font);
}

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

.btn-primary:hover {
    background: #5b52e0;
    box-shadow: 0 0 20px var(--accent-glow);
}

.btn-primary:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    box-shadow: none;
}

.btn-secondary {
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    border-color: var(--accent);
}

.btn-ghost {
    background: transparent;
    color: var(--text-dim);
}

.btn-ghost:hover {
    color: var(--text);
}

/* Dropzone */
.dropzone {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 3rem 2rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
    background: var(--surface);
}

.dropzone:hover,
.dropzone.dragover {
    border-color: var(--accent);
    background: rgba(108, 99, 255, 0.05);
}

.dropzone-icon {
    width: 48px;
    height: 48px;
    color: var(--text-dim);
    margin-bottom: 1rem;
}

.dropzone p {
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
}

.dropzone-hint {
    display: block;
    color: var(--text-dim);
    font-size: 0.85rem;
    margin-bottom: 1.25rem;
}

/* Upload status */
.upload-status {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-top: 1.5rem;
    color: var(--text-dim);
}

.hidden {
    display: none !important;
}

.error-msg {
    margin-top: 1rem;
    color: var(--danger);
    font-size: 0.9rem;
}

.privacy-note {
    margin-top: 1.5rem;
    font-size: 0.8rem;
    color: var(--text-dim);
    text-align: center;
}

/* Spinner */
.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Progress bar */
.progress-bar {
    width: 100%;
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    margin-bottom: 1rem;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--accent);
    border-radius: 2px;
    transition: width 0.3s ease;
    width: 10%;
}

.question-counter {
    color: var(--text-dim);
    font-size: 0.85rem;
    margin-bottom: 2rem;
}

/* Answer inputs */
textarea.answer-input {
    width: 100%;
    min-height: 120px;
    padding: 1rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 1rem;
    font-family: var(--font);
    line-height: 1.5;
    resize: vertical;
    transition: border-color 0.2s;
}

textarea.answer-input:focus {
    outline: none;
    border-color: var(--accent);
}

textarea.answer-input::placeholder {
    color: var(--text-dim);
}

/* Choice options */
.choice-options {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.choice-option {
    display: flex;
    align-items: center;
    padding: 1rem 1.25rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.2s;
    font-size: 1rem;
    color: var(--text);
    text-align: left;
    font-family: var(--font);
}

.choice-option:hover {
    border-color: var(--accent);
}

.choice-option.selected {
    border-color: var(--accent);
    background: rgba(108, 99, 255, 0.1);
}

/* Rank question */
.rank-hint {
    color: var(--text-dim);
    font-size: 0.85rem;
    margin-bottom: 0.75rem;
}

.rank-option {
    position: relative;
    padding-left: 3.5rem;
    transition: opacity 0.2s;
}

.rank-option.unranked {
    opacity: 0.5;
}

.rank-badge {
    position: absolute;
    left: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    min-width: 28px;
    height: 24px;
    padding: 0 4px;
    border-radius: 12px;
    background: var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-dim);
    transition: all 0.2s;
}

.rank-option.selected .rank-badge {
    background: var(--accent);
    color: #fff;
}

/* Question nav */
.question-nav {
    display: flex;
    justify-content: space-between;
    margin-top: 2rem;
}

/* Loader */
.loader {
    width: 48px;
    height: 48px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 1.5rem;
}

/* Story */
#screen-story {
    align-items: flex-start;
}

.story-container {
    max-width: 680px;
    padding-top: 2rem;
    padding-bottom: 4rem;
}

.story-intro {
    font-size: 1.05rem;
    line-height: 1.8;
    color: var(--text);
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border);
}

/* How to read */
.how-to-read {
    margin-bottom: 2rem;
    padding: 1.5rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.how-to-read h2 {
    font-size: 0.9rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.75rem;
    color: var(--text);
}

.how-to-read p {
    font-size: 0.9rem;
    line-height: 1.7;
    color: var(--text-dim);
    margin-bottom: 0.5rem;
}

.how-to-read p:last-child {
    margin-bottom: 0;
}

/* Scenarios */
.scenarios {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.scenario {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
}

.scenario-label {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-dim);
    margin-bottom: 0.25rem;
}

#scenario-0 .scenario-label { color: #4ade80; }
#scenario-1 .scenario-label { color: #facc15; }
#scenario-2 .scenario-label { color: #f87171; }

.scenario-desc {
    font-size: 0.85rem;
    color: var(--text-dim);
    margin-bottom: 1rem;
    line-height: 1.5;
}

.scenario-headline {
    font-size: 1.15rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
    line-height: 1.3;
}

.scenario-story {
    font-size: 0.95rem;
    line-height: 1.7;
    color: var(--text);
    margin-bottom: 1.25rem;
}

.scenario-paths h3 {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-dim);
    margin-bottom: 0.5rem;
}

.path-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.path-card {
    padding: 0.75rem 1rem;
    background: rgba(108, 99, 255, 0.05);
    border-radius: 8px;
    border-left: 3px solid var(--accent);
}

.path-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 0.25rem;
}

.path-desc {
    font-size: 0.9rem;
    line-height: 1.6;
    color: var(--text-dim);
}

/* Share link */
.share-link {
    margin-top: 2rem;
    padding: 1rem 1.25rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.share-link label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-dim);
    margin-bottom: 0.4rem;
}

.share-input-row {
    display: flex;
    gap: 0.5rem;
}

.share-input-row input {
    flex: 1;
    padding: 0.5rem 0.75rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-size: 0.85rem;
    font-family: var(--font);
}

.share-input-row .btn {
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
}

.story-actions {
    margin-top: 2rem;
    display: flex;
    gap: 1rem;
    justify-content: center;
}

/* Light mode */
@media (prefers-color-scheme: light) {
    :root {
        --bg: #f5f5f7;
        --surface: #ffffff;
        --border: #d8d8e0;
        --text: #1a1a2e;
        --text-dim: #6b6b80;
        --accent: #5b52e0;
        --accent-glow: rgba(91, 82, 224, 0.2);
    }

    .choice-option.selected {
        background: rgba(91, 82, 224, 0.08);
    }

    .path-card {
        background: rgba(91, 82, 224, 0.06);
    }

    .dropzone:hover,
    .dropzone.dragover {
        background: rgba(91, 82, 224, 0.04);
    }
}

/* Responsive */
@media (max-width: 600px) {
    h1 {
        font-size: 1.8rem;
    }
    h2 {
        font-size: 1.25rem;
    }
    .screen {
        padding: 2rem 1rem;
    }
    .dropzone {
        padding: 2rem 1rem;
    }
}
