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

::selection {
    background: rgba(56, 139, 253, 0.3);
}

:root {
    --bg-primary: #ffffff;
    --bg-secondary: #f6f8fa;
    --bg-tertiary: #f3f4f6;
    --bg-card: #ffffff;
    --border-color: #d0d7de;
    --border-color-hover: #bbc0c5;
    --text-primary: #1f2328;
    --text-secondary: #656d76;
    --text-tertiary: #8c959f;
    --accent-green: #1a7f37;
    --accent-green-hover: #156b2d;
    --accent-blue: #0969da;
    --accent-purple: #8250df;
    --accent-red: #cf222e;
    --radius-sm: 6px;
    --radius-md: 8px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.5;
    font-size: 14px;
}

.app {
    max-width: 1012px;
    margin: 0 auto;
    padding: 32px 16px;
}

#page-home, #page-scenes, #page-level, #page-world, #page-project-detail, #page-achievements {
    animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ===== Nav ===== */
.nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 32px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-color);
}

.logo {
    font-size: 16px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-primary);
}

.logo svg {
    fill: var(--text-primary);
}

.nav-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    font-size: 13px;
}

.avatar {
    width: 20px;
    height: 20px;
    border-radius: 50%;
}

.demo-badge {
    font-size: 11px;
    padding: 1px 6px;
    background: rgba(130, 80, 223, 0.1);
    color: var(--accent-purple);
    border-radius: 10px;
    font-weight: 500;
}

/* ===== Buttons ===== */
.btn {
    padding: 5px 16px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    border: 1px solid;
    cursor: pointer;
    transition: all 0.15s ease;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: none;
    line-height: 20px;
    user-select: none;
}

.btn:active {
    transform: scale(0.97);
}

.btn-primary {
    background: var(--accent-green);
    color: #ffffff;
    border-color: var(--accent-green);
}

.btn-primary:hover {
    background: var(--accent-green-hover);
    border-color: var(--accent-green-hover);
}

.btn-primary:active {
    background: var(--accent-green);
}

.btn-primary:disabled {
    background: #94d3a2;
    border-color: #94d3a2;
    color: #ffffff;
    cursor: not-allowed;
}

.btn-outline {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border-color: var(--border-color);
}

.btn-outline:hover {
    background: var(--bg-tertiary);
    border-color: var(--border-color-hover);
}

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

.btn-ghost:hover {
    background: var(--bg-secondary);
}

.fav-btn {
    padding: 4px 8px;
    color: var(--text-tertiary);
    transition: color 0.15s;
}

.fav-btn:hover {
    color: #f59e0b;
    background: transparent;
}

.fav-btn.favorited {
    color: #f59e0b;
}

.fav-btn:active {
    transform: scale(1.1);
}

.btn-demo {
    background: rgba(130, 80, 223, 0.08);
    color: var(--accent-purple);
    border-color: rgba(130, 80, 223, 0.3);
}

.btn-demo:hover {
    background: rgba(130, 80, 223, 0.15);
    border-color: rgba(130, 80, 223, 0.5);
}

.btn-sm {
    padding: 3px 12px;
    font-size: 12px;
}

.btn-loading {
    opacity: 0.6;
    pointer-events: none;
}

.link-btn {
    background: none;
    border: none;
    color: var(--accent-blue);
    cursor: pointer;
    font-size: 14px;
    text-decoration: none;
    padding: 4px 0;
}

.link-btn:hover {
    text-decoration: underline;
}

/* ===== Hero ===== */
.hero {
    text-align: center;
    margin-bottom: 32px;
    padding: 24px 0;
}

.hero h1 {
    font-size: 32px;
    font-weight: 600;
    margin-bottom: 8px;
    letter-spacing: -0.5px;
    line-height: 1.3;
}

.hero p {
    font-size: 16px;
    color: var(--text-secondary);
}

/* ===== Stats Bar ===== */
.stats-bar {
    display: flex;
    justify-content: center;
    gap: 48px;
    margin-bottom: 32px;
    padding: 20px 32px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
}

.stat-item {
    text-align: center;
}

.stat-number {
    display: block;
    font-size: 24px;
    font-weight: 600;
    color: var(--accent-green);
    margin-bottom: 4px;
}

.stat-label {
    font-size: 13px;
    color: var(--text-secondary);
}

/* ===== Entry Cards ===== */
.entry-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.entry-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 24px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.entry-card:hover {
    border-color: var(--border-color-hover);
    transform: translateY(-3px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
}

.entry-card:active {
    transform: translateY(-1px);
}

.card-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.card-header .icon {
    font-size: 32px;
    width: 40px;
    text-align: center;
}

.card-header h3 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 4px;
}

.entry-card > p {
    color: var(--text-secondary);
    font-size: 14px;
    line-height: 1.6;
    margin-bottom: 16px;
}

.badge {
    display: inline-block;
    padding: 2px 8px;
    background: var(--bg-secondary);
    color: var(--text-secondary);
    border-radius: 10px;
    font-size: 12px;
    font-weight: 500;
    border: 1px solid var(--border-color);
}

.card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    color: var(--text-tertiary);
    border-top: 1px solid var(--border-color);
    padding-top: 12px;
    margin-top: 4px;
}

.continue-hint {
    color: var(--accent-blue);
    font-weight: 500;
}

.locked-hint {
    color: var(--text-tertiary);
}

/* ===== Page Header ===== */
.page-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 16px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-color);
}

.page-header h2 {
    font-size: 20px;
    font-weight: 600;
    flex: 1;
}

.hint {
    color: var(--text-secondary);
    margin-bottom: 16px;
    font-size: 14px;
}

/* ===== Scene Grid ===== */
.progress-hint {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 12px 16px;
    margin-bottom: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.progress-hint .text {
    font-size: 14px;
}

.scene-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
}

.scene-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 16px;
    cursor: pointer;
    transition: border-color 0.15s;
}

.scene-card:hover {
    border-color: var(--border-color-hover);
}

.scene-card .icon {
    font-size: 28px;
    margin-bottom: 8px;
}

.scene-card h4 {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 4px;
}

.scene-card p {
    color: var(--text-secondary);
    font-size: 12px;
    margin-bottom: 8px;
}

.scene-card .progress {
    font-size: 12px;
    color: var(--text-tertiary);
}

.scene-card .progress.completed {
    color: var(--accent-green);
}

/* ===== Step Page ===== */
.step-breadcrumb {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 16px;
    font-size: 14px;
    color: var(--text-secondary);
}

.step-title {
    font-size: 24px;
    font-weight: 600;
    margin-bottom: 4px;
}

.step-desc {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 24px;
}

.step-section {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 20px;
    margin-bottom: 16px;
}

.step-section .label {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-tertiary);
    margin-bottom: 8px;
    letter-spacing: 0.5px;
}

.step-section .content {
    color: var(--text-secondary);
    font-size: 14px;
    line-height: 1.6;
}

.step-action {
    display: flex;
    gap: 8px;
    margin-top: 16px;
}

.step-action .btn {
    flex: 1;
    justify-content: center;
}

.verify-box {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 16px;
    margin-bottom: 16px;
}

.verify-box .status {
    font-size: 14px;
}

.verify-box .wait { color: var(--text-secondary); }
.verify-box .success { color: var(--accent-green); }
.verify-box .error { color: var(--accent-red); }

/* ===== AI Chat ===== */
.ai-chat-box {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    overflow: hidden;
    margin-top: 24px;
}

.ai-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-secondary);
}

.ai-avatar { font-size: 20px; }
.ai-name { font-weight: 600; font-size: 14px; }
.ai-status { font-size: 12px; color: var(--accent-green); }

.ai-messages {
    padding: 16px;
    max-height: 300px;
    overflow-y: auto;
}

.ai-message { margin-bottom: 12px; }
.ai-message.user .content {
    background: rgba(9, 105, 218, 0.05);
    border-left: 3px solid var(--accent-blue);
}
.ai-message.assistant .content {
    background: var(--bg-secondary);
    border-left: 3px solid var(--accent-green);
}
.ai-message .content {
    padding: 10px 14px;
    border-radius: 0 6px 6px 6px;
    font-size: 14px;
    line-height: 1.6;
}

.ai-input {
    display: flex;
    gap: 8px;
    padding: 12px 16px;
    border-top: 1px solid var(--border-color);
    background: var(--bg-secondary);
}

.ai-input input {
    flex: 1;
    padding: 6px 12px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 14px;
    outline: none;
}

.ai-input input:focus {
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 3px rgba(9, 105, 218, 0.1);
}

/* ===== World ===== */
.world-locked {
    text-align: center;
    padding: 64px 20px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
}

.world-locked .locked-icon {
    font-size: 48px;
    margin-bottom: 12px;
    opacity: 0.5;
}

.world-locked h2 {
    font-size: 20px;
    margin-bottom: 4px;
}

.world-locked p {
    color: var(--text-secondary);
    margin-bottom: 20px;
    font-size: 14px;
}

.progress-ring {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    border: 3px solid var(--border-color);
    border-top-color: var(--accent-green);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 20px;
}

.progress-text { font-size: 12px; font-weight: 600; }

.world-idea-input {
    max-width: 600px;
    margin: 0 auto;
    text-align: center;
}

.idea-prompt {
    margin-bottom: 24px;
}

.prompt-icon {
    font-size: 36px;
    display: block;
    margin-bottom: 12px;
}

.idea-prompt h3 {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.idea-prompt p {
    color: var(--text-secondary);
    font-size: 14px;
}

.idea-input-box {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 16px;
    margin-bottom: 20px;
    text-align: left;
}

.idea-input-box textarea {
    width: 100%;
    min-height: 100px;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-family: inherit;
    resize: vertical;
    outline: none;
    transition: border-color 0.2s;
    background: var(--bg-card);
}

.idea-input-box textarea:focus {
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 3px rgba(9, 105, 218, 0.1);
}

.idea-input-box textarea::placeholder {
    color: var(--text-tertiary);
}

.idea-input-box button {
    margin-top: 12px;
    float: right;
}

.idea-examples {
    text-align: left;
}

.idea-examples .label {
    font-size: 12px;
    color: var(--text-secondary);
    display: block;
    margin-bottom: 8px;
}

.example-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.example-tag {
    padding: 6px 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 12px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
}

.example-tag:hover {
    background: var(--bg-secondary);
    border-color: var(--accent-blue);
    color: var(--accent-blue);
}

.world-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 16px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0;
}

.tab-btn {
    padding: 8px 16px;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
    margin-bottom: -1px;
}

.tab-btn:hover {
    color: var(--text-primary);
    border-bottom-color: var(--border-color);
}

.tab-btn.active {
    color: var(--text-primary);
    border-bottom-color: #fd8c73;
    font-weight: 600;
}

/* ===== Project Filters ===== */
.project-filters {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    flex-wrap: wrap;
    gap: 12px;
}

.filter-group {
    display: flex;
    align-items: center;
    gap: 6px;
}

.filter-label {
    color: var(--text-secondary);
    font-size: 14px;
}

.filter-btn {
    padding: 4px 10px;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 12px;
    cursor: pointer;
    transition: all 0.15s;
}

.filter-btn:hover {
    background: var(--bg-secondary);
}

.filter-btn.active {
    background: var(--accent-blue);
    border-color: var(--accent-blue);
    color: #fff;
}

.search-box {
    position: relative;
}

.search-box input {
    padding: 5px 12px 5px 28px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 13px;
    width: 240px;
    outline: none;
}

.search-box input:focus {
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 3px rgba(9, 105, 218, 0.1);
}

.search-box::before {
    content: "🔍";
    position: absolute;
    left: 8px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 12px;
    opacity: 0.6;
}

/* ===== Project Grid ===== */
.project-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
}

.project-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 16px;
    transition: all 0.2s ease;
}

.project-card:hover {
    border-color: var(--border-color-hover);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

.project-card:active {
    transform: translateY(0);
}

.project-card h4 {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 4px;
}

.project-card p {
    color: var(--text-secondary);
    font-size: 12px;
    margin-bottom: 12px;
    line-height: 1.5;
}

.project-card .meta {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 12px;
    color: var(--text-tertiary);
}

.project-card .meta span {
    display: flex;
    align-items: center;
    gap: 4px;
}

.project-card .fork-btn {
    margin-top: 12px;
    width: 100%;
    justify-content: center;
}

/* ===== Project Detail ===== */
.project-detail {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.project-detail-header {
    padding: 24px;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-secondary);
}

.project-detail-header h1 {
    font-size: 24px;
    font-weight: 600;
    margin-bottom: 8px;
}

.project-detail-header .project-desc {
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 16px;
}

.project-detail-meta {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    align-items: center;
}

.project-detail-meta .difficulty-tag {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}

.project-detail-meta .difficulty-tag.easy { background: #dafbe1; color: #1a7f37; }
.project-detail-meta .difficulty-tag.medium { background: #fff8c5; color: #9a6700; }
.project-detail-meta .difficulty-tag.hard { background: #ffebe9; color: #cf222e; }

.project-detail-meta .category-tag {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 12px;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
}

.project-detail-meta .project-repo-link {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 12px;
    background: rgba(3, 102, 214, 0.08);
    color: #0969da;
    cursor: pointer;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    transition: background 0.15s;
}
.project-detail-meta .project-repo-link:hover {
    background: rgba(3, 102, 214, 0.16);
}

/* 预览图占位 + fallback */
.detail-preview-wrap {
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-secondary);
    min-height: 220px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.detail-preview-img {
    width: 100%;
    max-height: 420px;
    object-fit: cover;
    display: block;
}

.detail-preview-fallback {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 48px 24px;
    width: 100%;
    background: linear-gradient(135deg, rgba(84, 60, 152, 0.08), rgba(3, 102, 214, 0.08));
}
.detail-fallback-emoji {
    font-size: 56px;
    line-height: 1;
}
.detail-fallback-name {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
}
.detail-fallback-desc {
    font-size: 13px;
    color: var(--text-secondary);
}

/* 技术栈 chips */
.detail-tech-stack {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.tech-chip {
    padding: 4px 12px;
    border-radius: 16px;
    font-size: 12px;
    background: rgba(132, 77, 230, 0.10);
    color: #6b3fb3;
    border: 1px solid rgba(132, 77, 230, 0.25);
    font-weight: 500;
}

/* 步骤条视觉升级 */
.detail-steps li {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px dashed var(--border-color);
    font-size: 14px;
    line-height: 1.6;
}
.detail-steps li:last-child {
    border-bottom: none;
}
.detail-steps li::before {
    display: none;
}
.detail-steps li .step-num {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    background: linear-gradient(135deg, var(--accent-blue), #5a36c9);
    color: white;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 600;
    box-shadow: 0 2px 6px rgba(3, 102, 214, 0.25);
    margin-top: -2px;
}
.detail-steps li .step-body {
    flex: 1;
    color: var(--text-primary);
}

.project-detail-body {
    padding: 24px;
}

.detail-section {
    margin-bottom: 24px;
}

.detail-section:last-child {
    margin-bottom: 0;
}

.detail-section h3 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-color);
}

.detail-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.detail-tags .tag {
    padding: 4px 10px;
    background: var(--bg-tertiary);
    border-radius: 12px;
    font-size: 12px;
    color: var(--text-secondary);
}

.detail-features {
    list-style: none;
    padding: 0;
}

.detail-features li {
    padding: 8px 0;
    padding-left: 24px;
    position: relative;
    font-size: 14px;
    color: var(--text-primary);
}

.detail-features li::before {
    content: "✓";
    position: absolute;
    left: 0;
    color: var(--accent-green);
    font-weight: 600;
}

.detail-steps {
    list-style: none;
    padding: 0;
    counter-reset: step-counter;
}

.detail-steps li {
    padding: 12px 0 12px 40px;
    position: relative;
    font-size: 14px;
    counter-increment: step-counter;
    border-bottom: 1px solid var(--border-color);
}

.detail-steps li:last-child {
    border-bottom: none;
}

.detail-steps li::before {
    content: counter(step-counter);
    position: absolute;
    left: 0;
    top: 10px;
    width: 24px;
    height: 24px;
    background: var(--accent-blue);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 600;
}

.project-detail-actions {
    display: flex;
    gap: 12px;
    margin-top: 24px;
    padding-top: 24px;
    border-top: 1px solid var(--border-color);
}

.project-detail-actions .btn {
    flex: 1;
    justify-content: center;
}

/* ===== Achievement ===== */
.achievement-stats {
    display: flex;
    justify-content: center;
    gap: 48px;
    margin-bottom: 32px;
    padding: 24px 32px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
}

.ach-stat-item {
    text-align: center;
}

.ach-stat-number {
    display: block;
    font-size: 28px;
    font-weight: 600;
    color: var(--accent-green);
    margin-bottom: 4px;
}

.ach-stat-label {
    font-size: 13px;
    color: var(--text-secondary);
}

.achievement-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 16px;
}

.achievement-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 20px 16px;
    text-align: center;
    transition: all 0.2s;
    position: relative;
    overflow: hidden;
}

.achievement-card:hover {
    border-color: var(--border-color-hover);
    transform: translateY(-2px);
}

.achievement-card.locked {
    opacity: 0.5;
    filter: grayscale(1);
}

.achievement-card.unlocked {
    border-color: var(--accent-green);
    box-shadow: 0 0 0 1px var(--accent-green);
}

.achievement-icon {
    font-size: 48px;
    margin-bottom: 12px;
    display: block;
}

.achievement-card h4 {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 6px;
}

.achievement-card p {
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.4;
}

.achievement-rarity {
    display: inline-block;
    margin-top: 10px;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 500;
}

.achievement-rarity.common { background: #eaeef2; color: #57606a; }
.achievement-rarity.rare { background: #ddf4ff; color: #0969da; }
.achievement-rarity.epic { background: #fbefff; color: #8250df; }
.achievement-rarity.legendary { background: #fff8c5; color: #9a6700; }

@media (max-width: 768px) {
    .achievement-stats { gap: 24px; padding: 16px; }
    .ach-stat-number { font-size: 22px; }
    .achievement-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
    .achievement-icon { font-size: 36px; }
}

/* ===== Guide ===== */
.guide-container {
    max-width: 720px;
    margin: 0 auto;
}

.guide-intro {
    text-align: center;
    margin-bottom: 32px;
    padding: 24px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
}

.guide-intro p {
    color: var(--text-secondary);
    font-size: 16px;
}

.guide-step {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    margin-bottom: 12px;
    overflow: hidden;
    transition: border-color 0.2s;
}

.guide-step:hover {
    border-color: var(--border-color-hover);
}

.guide-step-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    cursor: pointer;
    user-select: none;
}

.guide-step-header h3 {
    flex: 1;
    font-size: 16px;
    font-weight: 600;
}

.guide-step-num {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    background: var(--accent-blue);
    color: white;
    border-radius: 50%;
    font-size: 14px;
    font-weight: 600;
    flex-shrink: 0;
}

.guide-toggle {
    color: var(--text-tertiary);
    font-size: 12px;
    flex-shrink: 0;
}

.guide-step-body {
    padding: 0 20px 20px 20px;
}

.guide-step-body p {
    color: var(--text-primary);
    font-size: 14px;
    line-height: 1.7;
    margin-bottom: 12px;
}

.guide-step-body strong {
    color: var(--text-primary);
}

.guide-tip {
    background: rgba(9, 105, 218, 0.06);
    border-left: 3px solid var(--accent-blue);
    padding: 12px 16px;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    margin: 12px 0;
    font-size: 13px;
    color: var(--text-secondary);
}

.guide-list {
    padding-left: 20px;
    margin: 12px 0;
}

.guide-list li {
    padding: 4px 0;
    font-size: 14px;
    color: var(--text-primary);
    line-height: 1.6;
}

.guide-link {
    color: var(--accent-blue);
    text-decoration: none;
}

.guide-link:hover {
    text-decoration: underline;
}

.guide-action {
    text-align: center;
    margin-top: 16px;
}

.guide-cta {
    text-align: center;
    padding: 32px 20px;
    margin-top: 24px;
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}

.guide-cta p {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 8px;
}

.guide-cta-sub {
    font-size: 13px !important;
    font-weight: 400 !important;
    color: var(--text-secondary);
    margin-bottom: 20px !important;
    line-height: 1.6;
}

.btn-lg {
    padding: 12px 32px;
    font-size: 15px;
}

.guide-concept {
    padding: 12px 16px;
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
    margin-bottom: 12px;
}

.guide-concept strong {
    display: block;
    margin-bottom: 4px;
    font-size: 14px;
}

.guide-concept p {
    margin-bottom: 0;
    color: var(--text-secondary);
    font-size: 13px;
}

.guide-flow {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin: 20px 0;
    flex-wrap: wrap;
}

.guide-flow-step {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
}

.guide-flow-icon {
    font-size: 20px;
}

.guide-flow-arrow {
    color: var(--text-tertiary);
    font-size: 16px;
}

.guide-faq {
    margin-bottom: 16px;
    padding: 12px 16px;
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
}

.guide-faq-q {
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 4px;
}

.guide-faq-a {
    color: var(--text-secondary);
    font-size: 13px;
    line-height: 1.6;
}

@media (max-width: 768px) {
    .guide-flow { flex-direction: column; gap: 8px; }
    .guide-flow-arrow { transform: rotate(90deg); }
}

/* ===== World Chat ===== */
.world-chat {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.chat-messages {
    padding: 16px;
    max-height: 400px;
    overflow-y: auto;
}

.chat-message { margin-bottom: 12px; }
.chat-message.user .bubble {
    background: rgba(9, 105, 218, 0.08);
    border: 1px solid rgba(9, 105, 218, 0.2);
    margin-left: auto;
}
.chat-message.assistant .bubble {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
}
.chat-message .bubble {
    padding: 10px 14px;
    border-radius: 6px;
    max-width: 80%;
    font-size: 14px;
    line-height: 1.6;
}

.chat-input {
    display: flex;
    gap: 8px;
    padding: 12px 16px;
    border-top: 1px solid var(--border-color);
    background: var(--bg-secondary);
}

.chat-input input {
    flex: 1;
    padding: 8px 12px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 14px;
    outline: none;
}

.chat-input input:focus {
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 3px rgba(9, 105, 218, 0.1);
}

/* ===== Project Recommendations ===== */
.project-recommendations { margin-top: 20px; }
.project-recommendations h3 {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 12px;
}

.project-list {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.project-list-item {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 12px;
    cursor: pointer;
    transition: border-color 0.15s;
}

.project-list-item:hover {
    border-color: var(--border-color-hover);
}

.project-list-item h4 {
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 4px;
}

.project-list-item p {
    color: var(--text-secondary);
    font-size: 12px;
}

/* ===== Modal ===== */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(31, 35, 40, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.15s;
}

.modal-overlay.show {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 24px;
    max-width: 440px;
    width: 90%;
    text-align: center;
    transform: scale(0.95);
    transition: transform 0.15s;
}

.modal-overlay.show .modal {
    transform: scale(1);
}

.modal .big {
    font-size: 48px;
    margin-bottom: 12px;
}

.modal h2 {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 8px;
}

.modal p {
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 20px;
    line-height: 1.6;
}

.btn-group {
    display: flex;
    gap: 8px;
    justify-content: center;
}

.quiz-container {
    margin: 20px 0;
    text-align: left;
}

.quiz-item {
    margin-bottom: 20px;
}

.quiz-question {
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 10px;
    color: var(--text-primary);
}

.quiz-options {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.quiz-option {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.15s;
    border: 1px solid transparent;
}

.quiz-option:hover {
    background: var(--bg-tertiary);
}

.quiz-option input[type="radio"] {
    width: 18px;
    height: 18px;
    accent-color: var(--accent-green);
    cursor: pointer;
}

.quiz-option span {
    font-size: 14px;
    color: var(--text-primary);
}

.quiz-option:has(input:checked) {
    background: rgba(22, 163, 74, 0.1);
    border-color: var(--accent-green);
}

.graduation-badge {
    display: inline-block;
    padding: 4px 12px;
    background: rgba(26, 127, 55, 0.1);
    color: var(--accent-green);
    border-radius: 12px;
    font-weight: 600;
    margin-bottom: 20px;
    font-size: 12px;
    border: 1px solid rgba(26, 127, 55, 0.2);
}

/* ===== States ===== */
.loading-state {
    text-align: center;
    padding: 32px 20px;
}

.spinner {
    width: 24px;
    height: 24px;
    border: 2px solid var(--border-color);
    border-top-color: var(--accent-blue);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 8px;
}

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

.loading-state p {
    color: var(--text-secondary);
    font-size: 14px;
}

.empty-state {
    text-align: center;
    padding: 32px 20px;
    color: var(--text-secondary);
}

.empty-state .empty-icon {
    font-size: 40px;
    margin-bottom: 8px;
    opacity: 0.5;
}

.error-state {
    text-align: center;
    padding: 32px 20px;
    color: var(--accent-red);
}

.error-state .error-icon {
    font-size: 40px;
    margin-bottom: 8px;
}

/* ===== Toast ===== */
.toast {
    position: fixed;
    top: 16px;
    right: 16px;
    padding: 10px 16px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    z-index: 9999;
    transform: translateX(120%);
    transition: transform 0.2s;
    box-shadow: 0 4px 12px rgba(31, 35, 40, 0.15);
}

.toast.show { transform: translateX(0); }
.toast-info { background: var(--accent-blue); color: #fff; }
.toast-error { background: var(--accent-red); color: #fff; }
.toast-success { background: var(--accent-green); color: #fff; }

/* ===== Footer ===== */
.footer {
    text-align: center;
    padding: 32px 16px;
    margin-top: 48px;
    border-top: 1px solid var(--border-color);
    color: var(--text-tertiary);
    font-size: 13px;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .app { padding: 16px; }
    .hero h1 { font-size: 24px; }
    .hero p { font-size: 14px; }
    .stats-bar { gap: 24px; padding: 16px; }
    .stat-number { font-size: 20px; }
    .stat-label { font-size: 12px; }
    .entry-grid { grid-template-columns: 1fr; }
    .scene-grid { grid-template-columns: repeat(2, 1fr); }
    .project-grid { grid-template-columns: 1fr; }
    .project-list { grid-template-columns: 1fr; }
    .project-filters { flex-direction: column; align-items: stretch; }
    .search-box input { width: 100%; }
    .step-action { flex-direction: column; }
    .nav { flex-wrap: wrap; gap: 8px; }
    .nav-right { width: 100%; justify-content: flex-end; }
}

@media (max-width: 480px) {
    .scene-grid { grid-template-columns: 1fr; }
    .stats-bar { gap: 16px; padding: 12px; }
    .stat-number { font-size: 18px; }
    .stat-label { font-size: 11px; }
}

@media (max-width: 768px) {
    .world-tip {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
    .world-tip button {
        width: 100%;
        justify-content: center;
    }
    .idea-input-box button {
        float: none;
        width: 100%;
        justify-content: center;
    }
    .chat-message .bubble {
        max-width: 90%;
    }
    .chat-input {
        padding: 10px 12px;
    }
    .chat-input input {
        padding: 10px 12px;
        font-size: 15px;
    }
    .ai-input {
        padding: 10px 12px;
    }
    .ai-input input {
        padding: 10px 12px;
        font-size: 15px;
    }
    .btn {
        padding: 8px 16px;
        font-size: 15px;
        min-height: 44px;
    }
    .btn-sm {
        padding: 6px 12px;
        font-size: 13px;
        min-height: 36px;
    }
    .entry-card {
        padding: 20px 16px;
    }
    .entry-card:active {
        transform: scale(0.98);
    }
    .scene-card {
        padding: 20px 16px;
    }
    .project-card {
        padding: 16px;
    }
    .project-card:active {
        transform: scale(0.98);
    }
    .page-header {
        flex-wrap: wrap;
        gap: 8px;
    }
    .page-header h2 {
        font-size: 18px;
    }
    .step-section {
        padding: 16px;
    }
    .step-action .btn {
        padding: 10px 16px;
    }
    .hero {
        padding: 16px 0;
    }
    .hero h1 {
        font-size: 22px;
    }
    .hero p {
        font-size: 14px;
    }
    .idea-input-box textarea {
        min-height: 120px;
        padding: 14px;
        font-size: 15px;
    }
    .example-tag {
        padding: 8px 14px;
        font-size: 13px;
    }
    .project-detail-header {
        padding: 20px 16px;
    }
    .project-detail-body {
        padding: 20px 16px;
    }
    .project-detail-actions {
        flex-direction: column;
        gap: 10px;
    }
    .project-detail-actions .btn {
        padding: 12px 16px;
    }
    .modal {
        padding: 20px;
        max-width: 95%;
    }
    .btn-group {
        flex-direction: column;
        gap: 10px;
    }
    .btn-group .btn {
        width: 100%;
        justify-content: center;
        padding: 12px;
    }
    .modal-overlay {
        padding: 16px;
    }
    .modal h2 {
        font-size: 18px;
    }
    .modal p {
        font-size: 14px;
    }
    .guide-step-header {
        padding: 14px 16px;
    }
    .guide-step-body {
        padding: 0 16px 16px 16px;
    }
    .guide-step-body p {
        font-size: 15px;
        line-height: 1.7;
    }
    .guide-flow {
        flex-direction: column;
        gap: 8px;
    }
    .guide-flow-arrow {
        transform: rotate(90deg);
    }
    .achievement-stats {
        gap: 16px;
        padding: 16px;
    }
    .ach-stat-number {
        font-size: 22px;
    }
    .achievement-grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
        gap: 12px;
    }
    .achievement-card {
        padding: 16px;
    }
    .achievement-icon {
        font-size: 36px;
    }
    .toast {
        right: 8px;
        left: 8px;
        top: 8px;
        transform: translateY(-120%);
    }
    .toast.show {
        transform: translateY(0);
    }
    .stats-bar {
        gap: 16px;
        padding: 12px;
    }
    .stat-item {
        min-width: 70px;
    }
    .stat-number {
        font-size: 18px;
    }
    .stat-label {
        font-size: 11px;
    }
    .nav {
        margin-bottom: 20px;
        padding-bottom: 12px;
    }
    .logo {
        font-size: 15px;
    }
    .user-info {
        font-size: 12px;
        padding: 4px 8px;
    }
    .avatar {
        width: 18px;
        height: 18px;
    }
    .footer {
        padding: 20px 16px;
        margin-top: 32px;
    }
    .progress-hint {
        padding: 10px 12px;
    }
    .progress-hint .text {
        font-size: 13px;
    }
    .step-breadcrumb {
        font-size: 13px;
    }
    .step-title {
        font-size: 20px;
    }
    .step-desc {
        font-size: 14px;
        margin-bottom: 16px;
    }
    .verify-box {
        padding: 12px;
    }
    .verify-box .status {
        font-size: 13px;
    }
    .world-tabs {
        gap: 2px;
    }
    .tab-btn {
        padding: 8px 12px;
        font-size: 13px;
    }
    .filter-group {
        flex-wrap: wrap;
    }
    .filter-btn {
        padding: 6px 10px;
        font-size: 12px;
    }
    .search-box input {
        width: 100%;
        padding: 8px 12px 8px 28px;
        font-size: 14px;
    }
    .project-card h4 {
        font-size: 15px;
    }
    .project-card p {
        font-size: 13px;
    }
    .project-card .meta {
        font-size: 12px;
    }
    .project-card .fork-btn {
        padding: 10px 16px;
        font-size: 14px;
    }
    .project-detail-header h1 {
        font-size: 20px;
    }
    .project-detail-header .project-desc {
        font-size: 14px;
    }
    .detail-section h3 {
        font-size: 15px;
    }
    .detail-features li {
        font-size: 14px;
    }
    .detail-steps li {
        font-size: 14px;
        padding-left: 36px;
    }
    .detail-tags .tag {
        padding: 5px 10px;
        font-size: 12px;
    }
    .chat-messages {
        padding: 12px;
        max-height: 300px;
    }
    .chat-message .bubble {
        padding: 12px 14px;
        font-size: 15px;
        line-height: 1.7;
    }
    .ai-messages {
        padding: 12px;
        max-height: 250px;
    }
    .ai-message .content {
        padding: 12px 14px;
        font-size: 14px;
        line-height: 1.7;
    }
    .ai-header {
        padding: 10px 12px;
    }
    .project-list-item {
        padding: 14px;
    }
    .project-list-item h4 {
        font-size: 14px;
    }
    .project-list-item p {
        font-size: 13px;
    }
    .guide-intro {
        padding: 20px 16px;
    }
    .guide-intro p {
        font-size: 15px;
    }
    .guide-tip {
        padding: 10px 14px;
        font-size: 13px;
    }
    .guide-list li {
        font-size: 14px;
    }
    .guide-concept {
        padding: 10px 14px;
    }
    .guide-concept p {
        font-size: 13px;
    }
    .guide-faq {
        padding: 10px 14px;
    }
    .guide-faq-q {
        font-size: 14px;
    }
    .guide-faq-a {
        font-size: 13px;
    }
    .guide-action {
        margin-top: 12px;
    }
    .guide-action .btn {
        width: 100%;
        padding: 12px;
    }
}

/* ===== Chat Upload ===== */
.chat-input-wrapper {
    display: flex;
    flex-direction: column;
    border-top: 1px solid var(--border-color);
    background: var(--bg-secondary);
}

.chat-attachments {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 8px 16px;
    border-bottom: 1px solid var(--border-color);
    min-height: 48px;
}

.chat-attachment-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 12px;
    max-width: 200px;
}

.chat-attachment-item img {
    width: 32px;
    height: 32px;
    object-fit: cover;
    border-radius: 4px;
    flex-shrink: 0;
}

.chat-attachment-item .file-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chat-attachment-item .remove-btn {
    background: none;
    border: none;
    color: var(--text-tertiary);
    cursor: pointer;
    padding: 2px 4px;
    font-size: 12px;
    transition: color 0.15s;
}

.chat-attachment-item .remove-btn:hover {
    color: var(--accent-red);
}

.chat-upload-btn {
    flex-shrink: 0;
    padding: 6px 10px;
    font-size: 16px;
}

.chat-upload-btn:hover {
    background: rgba(9, 105, 218, 0.08);
}

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

.chat-message .message-content img {
    max-width: 100%;
    max-height: 200px;
    border-radius: 4px;
    margin: 4px 0;
}

.chat-message .message-content .file-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: rgba(9, 105, 218, 0.08);
    border-radius: 4px;
    color: var(--accent-blue);
    text-decoration: none;
    font-size: 13px;
    margin: 4px 0;
}

.chat-message .message-content .file-link:hover {
    background: rgba(9, 105, 218, 0.15);
}

.upload-progress {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--text-secondary);
}

.upload-progress-bar {
    flex: 1;
    height: 4px;
    background: var(--bg-tertiary);
    border-radius: 2px;
    overflow: hidden;
}

.upload-progress-fill {
    height: 100%;
    background: var(--accent-blue);
    border-radius: 2px;
    transition: width 0.2s;
}
