/* ============================================================
   仕途模拟器 — Light UI
   低饱和浅色主题，覆盖开始页/游戏页/结局页
   ============================================================ */

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

:root {
    --bg-root: #f6f7f9;
    --bg-surface: #ffffff;
    --bg-soft: #f1f3f6;
    --bg-soft-hover: #e9edf3;

    --text-primary: #1f2937;
    --text-secondary: #4b5563;
    --text-muted: #6b7280;

    --border: #d7dde6;
    --border-strong: #c7d0dc;

    --accent: #2f6fdd;
    --accent-hover: #275fbe;
    --accent-ghost: rgba(47, 111, 221, 0.08);

    --good: #1f8f65;
    --mid: #b7791f;
    --bad: #c2413b;
    --warn: #b7791f;

    --radius-sm: 10px;
    --radius-md: 14px;
    --radius-lg: 18px;

    --shadow-soft: 0 8px 24px rgba(16, 24, 40, 0.05);
    --shadow-hover: 0 12px 28px rgba(16, 24, 40, 0.08);

    --gap-xs: 8px;
    --gap-sm: 12px;
    --gap-md: 18px;
    --gap-lg: 26px;
    --gap-xl: 36px;
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: 'Noto Sans SC', 'PingFang SC', 'Microsoft YaHei', sans-serif;
    color: var(--text-primary);
    line-height: 1.65;
    background: var(--bg-root);
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
}

.app-bg {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: -1;
    background:
        radial-gradient(circle at 12% 8%, rgba(47, 111, 221, 0.08), transparent 42%),
        radial-gradient(circle at 82% 14%, rgba(17, 24, 39, 0.05), transparent 38%),
        linear-gradient(180deg, #fcfdff 0%, #f3f6fb 100%);
}

.screen {
    display: none;
    min-height: 100vh;
}

.screen.active {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    width: 100%;
    animation: fadeUp 0.35s ease;
}

/* ---------- Start ---------- */
.start-container {
    width: 100%;
    min-height: 100vh;
    padding: 10vh var(--gap-lg) var(--gap-lg);
    display: flex;
    justify-content: center;
}

.start-panel {
    width: 100%;
    max-width: 520px;
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid var(--border);
    border-radius: 24px;
    box-shadow: var(--shadow-soft);
    backdrop-filter: blur(8px);
    padding: 32px;
}

.eyebrow {
    font-size: 0.74rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 14px;
}

.start-title {
    font-family: 'Noto Serif SC', 'Songti SC', serif;
    font-size: 2.15rem;
    line-height: 1.2;
    margin-bottom: 10px;
}

.start-subtitle {
    color: var(--text-secondary);
    margin-bottom: 24px;
    font-size: 0.97rem;
}

.start-form {
    width: 100%;
}

.form-group {
    margin-bottom: var(--gap-md);
}

.form-group label {
    display: block;
    margin-bottom: var(--gap-xs);
    font-size: 0.88rem;
    color: var(--text-secondary);
    font-weight: 600;
}

.form-group input[type="text"] {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: #fff;
    color: var(--text-primary);
    padding: 12px 14px;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-group input[type="text"]:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(47, 111, 221, 0.12);
}

.form-group input[type="text"]::placeholder {
    color: #98a2b3;
}

.edu-options {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: var(--gap-xs);
}

.edu-btn {
    border: 1px solid var(--border);
    background: var(--bg-soft);
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
    padding: 10px 0;
    font-family: inherit;
    font-size: 0.92rem;
    cursor: pointer;
    transition: all 0.2s;
}

.edu-btn:hover {
    background: var(--bg-soft-hover);
    border-color: var(--border-strong);
    color: var(--text-primary);
}

.edu-btn.selected {
    border-color: var(--accent);
    background: var(--accent-ghost);
    color: var(--accent);
    font-weight: 600;
}

.btn-primary {
    border: none;
    border-radius: var(--radius-sm);
    background: var(--accent);
    color: #fff;
    font-size: 0.96rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: transform 0.16s ease, background 0.2s ease, box-shadow 0.2s ease;
    box-shadow: 0 6px 16px rgba(47, 111, 221, 0.25);
}

.btn-primary:hover:not(:disabled) {
    background: var(--accent-hover);
    transform: translateY(-1px);
}

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

#btn-start {
    width: 100%;
    padding: 12px 18px;
    margin-top: 8px;
}

/* ---------- Game ---------- */
.game-container {
    width: 100%;
    max-width: 1100px;
    padding: 22px var(--gap-lg) 36px;
}

.game-header {
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.82);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-soft);
    padding: 16px 18px;
    display: flex;
    justify-content: space-between;
    gap: var(--gap-md);
    align-items: flex-start;
    margin-bottom: 14px;
}

.game-title {
    font-size: 1.2rem;
    letter-spacing: 0.02em;
    margin-bottom: 2px;
}

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

.header-meta {
    font-size: 0.82rem;
    color: var(--text-secondary);
    padding: 4px 10px;
    border-radius: 999px;
    background: var(--bg-soft);
    border: 1px solid var(--border);
}

.identity-card,
.ending-identity {
    background: rgba(255, 255, 255, 0.84);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 10px;
    display: grid;
    gap: 10px;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    box-shadow: var(--shadow-soft);
    margin-bottom: 14px;
}

.identity-item {
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: #fff;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-height: 72px;
}

.identity-label {
    font-size: 0.78rem;
    color: var(--text-muted);
}

.identity-value {
    font-size: 0.96rem;
    color: var(--text-primary);
    font-weight: 600;
    word-break: break-word;
}

.status-bar {
    display: flex;
    flex-wrap: wrap;
    gap: var(--gap-xs);
    margin-bottom: var(--gap-md);
}

.stat-pill {
    display: flex;
    align-items: center;
    gap: 6px;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.9);
    border-radius: 999px;
    padding: 7px 12px;
    transition: border-color 0.2s ease, background 0.2s ease;
}

.stat-pill.changed {
    border-color: var(--accent);
    background: var(--accent-ghost);
    animation: pop 0.55s ease;
}

.stat-icon {
    font-size: 0.86rem;
}

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

.stat-value {
    min-width: 22px;
    text-align: right;
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--text-primary);
}

.stat-value.high {
    color: var(--good);
}

.stat-value.mid {
    color: var(--mid);
}

.stat-value.low {
    color: var(--bad);
}

.system-messages {
    margin-bottom: var(--gap-sm);
}

.sys-msg {
    border: 1px solid rgba(183, 121, 31, 0.3);
    border-left: 4px solid var(--warn);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    padding: 10px 12px;
    background: rgba(183, 121, 31, 0.07);
    color: #8a5d1f;
    font-size: 0.84rem;
    margin-bottom: 8px;
    animation: fadeUp 0.2s ease;
}

.narrative-card {
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: rgba(255, 255, 255, 0.92);
    box-shadow: var(--shadow-soft);
    padding: 22px;
    min-height: 300px;
    max-height: 56vh;
    overflow-y: auto;
    margin-bottom: var(--gap-md);
}

.narrative-card::-webkit-scrollbar {
    width: 7px;
}

.narrative-card::-webkit-scrollbar-thumb {
    background: #d3dae4;
    border-radius: 999px;
}

.narrative-text {
    color: var(--text-primary);
    font-size: 1.01rem;
    line-height: 1.92;
    white-space: pre-wrap;
}

.narrative-text .text-muted {
    color: var(--text-muted);
}

.choices-area {
    margin-bottom: var(--gap-md);
}

.choice-card {
    display: flex;
    flex-direction: column;
    gap: 4px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.94);
    padding: 14px 16px;
    margin-bottom: 10px;
    box-shadow: var(--shadow-soft);
    transition: transform 0.16s ease, border-color 0.2s ease, box-shadow 0.2s ease;
    animation: fadeUp 0.22s ease;
    cursor: pointer;
}

.choice-card:hover:not(.disabled):not(.choice-free) {
    border-color: var(--accent);
    box-shadow: var(--shadow-hover);
    transform: translateY(-1px);
}

.choice-card.disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.choice-header {
    display: flex;
    align-items: center;
    gap: var(--gap-sm);
}

.choice-id {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    color: var(--accent);
    border: 1px solid var(--accent);
    background: var(--accent-ghost);
    flex-shrink: 0;
}

.choice-label {
    font-size: 0.95rem;
    color: var(--text-primary);
}

.choice-req {
    padding-left: 36px;
    font-size: 0.8rem;
    color: var(--bad);
}

.choice-req.ok {
    color: var(--text-muted);
}

.choice-req.no {
    color: var(--bad);
}

.choice-free {
    cursor: default;
}

.choice-free:hover {
    border-color: var(--border);
    transform: none;
    box-shadow: var(--shadow-soft);
}

.free-input-wrap {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-top: 8px;
}

.free-input-wrap input {
    flex: 1;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: #fff;
    padding: 10px 12px;
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.free-input-wrap input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(47, 111, 221, 0.12);
}

.btn-send {
    width: 40px;
    height: 40px;
    border: none;
    border-radius: var(--radius-sm);
    background: var(--accent);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s ease;
    flex-shrink: 0;
}

.btn-send:hover {
    background: var(--accent-hover);
}

.action-area {
    margin-top: 8px;
}

#btn-next-turn {
    min-width: 200px;
    width: auto;
    padding: 11px 20px;
}

/* ---------- Ending ---------- */
.ending-container {
    width: 100%;
    max-width: 760px;
    min-height: 100vh;
    padding: 8vh var(--gap-lg) var(--gap-lg);
    margin: 0 auto;
}

.ending-label {
    font-family: 'Noto Serif SC', 'Songti SC', serif;
    font-size: 1.7rem;
    margin-bottom: var(--gap-md);
}

.ending-text {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: rgba(255, 255, 255, 0.94);
    padding: 22px;
    white-space: pre-wrap;
    line-height: 1.92;
    margin-bottom: var(--gap-md);
    box-shadow: var(--shadow-soft);
}

.ending-stats {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
    margin-bottom: var(--gap-lg);
}

.ending-stat-item {
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.92);
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.es-label {
    font-size: 0.78rem;
    color: var(--text-muted);
}

.es-value {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-primary);
}

.ending-container .btn-primary {
    width: 100%;
    padding: 12px 18px;
}

/* ---------- Promotion Assignment ---------- */
.promotion-modal {
    position: fixed;
    inset: 0;
    z-index: 1100;
    background: rgba(15, 23, 42, 0.38);
    backdrop-filter: blur(3px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 18px;
}

.promotion-modal-panel {
    width: min(680px, 100%);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: #fff;
    box-shadow: var(--shadow-hover);
    padding: 18px;
}

.promotion-modal-title {
    font-size: 1.08rem;
    margin-bottom: 4px;
}

.promotion-modal-subtitle {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 14px;
}

.promotion-options {
    display: grid;
    gap: 10px;
}

.promotion-option {
    border: 1px solid var(--border);
    background: var(--bg-soft);
    border-radius: var(--radius-md);
    padding: 12px;
    cursor: pointer;
    transition: border-color 0.2s ease, background 0.2s ease, transform 0.16s ease;
}

.promotion-option:hover {
    border-color: var(--accent);
    background: var(--accent-ghost);
    transform: translateY(-1px);
}

.promotion-option-id {
    display: inline-flex;
    width: 22px;
    height: 22px;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--accent);
    border-radius: 50%;
    color: var(--accent);
    font-size: 0.75rem;
    margin-right: 8px;
}

.promotion-option-title {
    font-size: 0.96rem;
    font-weight: 600;
}

.promotion-option-meta {
    margin-top: 6px;
    color: var(--text-secondary);
    font-size: 0.82rem;
}

/* ---------- Loading ---------- */
.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(246, 247, 249, 0.65);
    backdrop-filter: blur(3px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 999;
}

.loading-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    max-width: 520px;
    text-align: center;
    padding: 20px 26px;
    border-radius: 14px;
    border: 1px solid rgba(199, 208, 220, 0.75);
    background: rgba(255, 255, 255, 0.9);
    box-shadow: var(--shadow-soft);
}

.loading-spinner {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 3px solid #dbe3ef;
    border-top-color: var(--accent);
    animation: spin 0.8s linear infinite;
}

.loading-title {
    font-size: 0.98rem;
    color: var(--text-primary);
    font-weight: 600;
}

.loading-tip {
    font-size: 0.84rem;
    color: var(--text-secondary);
    line-height: 1.6;
}

/* ---------- Motion ---------- */
@keyframes fadeUp {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes pop {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.03);
    }

    100% {
        transform: scale(1);
    }
}

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

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
    .ending-stats {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 720px) {
    .start-container,
    .ending-container {
        padding-left: var(--gap-sm);
        padding-right: var(--gap-sm);
    }

    .start-panel {
        padding: 24px 20px;
    }

    .start-title {
        font-size: 1.85rem;
    }

    .game-container {
        padding: var(--gap-sm) var(--gap-sm) 20px;
    }

    .game-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .identity-card,
    .ending-identity {
        grid-template-columns: 1fr;
    }

    .identity-item {
        min-height: 0;
    }

    .narrative-card {
        padding: 16px;
        max-height: 50vh;
    }

    #btn-next-turn {
        width: 100%;
    }
}

@media (max-width: 430px) {
    .status-bar {
        gap: 6px;
    }

    .stat-pill {
        padding: 6px 10px;
    }

    .stat-label {
        display: none;
    }

    .choice-card {
        padding: 12px;
    }

    .ending-stats {
        grid-template-columns: 1fr;
    }
}
