:root {
    --primary: #536dfe;
    --primary-deep: #4054c8;
    --primary-soft: #eef1ff;
    --accent: #12a594;
    --accent-soft: #e8faf6;
    --violet: #6658d3;
    --amber: #f59e0b;
    --ink: #172033;
    --muted: #6f7890;
    --surface: #ffffff;
    --surface-soft: #f6f8fc;
    --line: #e4e8f1;
    --shadow: 0 18px 55px rgba(38, 51, 92, .10);
    --shadow-small: 0 8px 24px rgba(38, 51, 92, .09);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
    color: var(--ink);
    font-family: "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
    background:
        radial-gradient(circle at 8% 4%, rgba(83, 109, 254, .12), transparent 26rem),
        radial-gradient(circle at 94% 12%, rgba(18, 165, 148, .10), transparent 23rem),
        #f5f7fb;
}
a { color: var(--primary-deep); text-decoration-thickness: 1px; text-underline-offset: 3px; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
.muted, .subtitle { color: var(--muted); }
.shell { width: min(100%, 980px); margin: auto; padding: 24px; }
.hero { text-align: center; padding: 42px 16px 26px; }
.emblem {
    width: 68px; height: 68px; margin: auto; display: grid; place-items: center;
    border-radius: 22px; color: #fff; font-size: 29px; font-weight: 850;
    background: linear-gradient(145deg, #6c7dff, #4f63df);
    box-shadow: 0 14px 28px rgba(83, 109, 254, .25), inset 0 1px 0 #ffffff66;
    transform: rotate(-5deg);
}
.hero h1 { font-size: clamp(30px, 6vw, 46px); margin: 20px 0 8px; letter-spacing: -.04em; }
h1, h2, h3 { color: var(--ink); }
h2 { margin: 0 0 18px; }
h3 { margin: 10px 0; }
.subtitle { margin: 0; font-size: 15px; }
.card {
    margin-bottom: 18px; padding: 24px; border: 1px solid rgba(218, 224, 237, .9);
    border-radius: 22px; background: rgba(255, 255, 255, .94); box-shadow: var(--shadow);
}
.field { display: grid; gap: 8px; margin-bottom: 16px; }
.field label { font-weight: 700; font-size: 14px; }
.field input, .field select, .field textarea {
    width: 100%; padding: 13px 14px; border: 1px solid #d6dce8; border-radius: 12px;
    outline: none; color: var(--ink); background: #fff; transition: .18s ease;
}
.field input:focus, .field select:focus, .field textarea:focus {
    border-color: var(--primary); box-shadow: 0 0 0 4px rgba(83, 109, 254, .11);
}
.btn {
    display: inline-flex; align-items: center; justify-content: center; border: 0; border-radius: 12px;
    padding: 12px 20px; color: #394258; background: #edf0f6; font-weight: 750;
    text-decoration: none; transition: transform .16s ease, box-shadow .16s ease, background .16s ease;
}
.btn:hover:not(:disabled) { transform: translateY(-1px); }
.btn-primary { color: #fff; background: linear-gradient(135deg, #6278ff, #475ad6); box-shadow: 0 10px 22px rgba(83, 109, 254, .24); }
.btn-outline { color: var(--primary-deep); border: 1px solid #c8d0ff; background: #fff; }
.btn-small { padding: 8px 12px; border-radius: 9px; font-size: 13px; }
.btn:disabled { opacity: .42; cursor: not-allowed; box-shadow: none; transform: none; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.actions .btn-primary { flex: 1; }
.error { display: none; margin: 10px 0; padding: 11px 13px; border: 1px solid #f5d290; border-radius: 11px; color: #8a5800; background: #fff8e8; }
.error.show { display: block; }
.rules { line-height: 1.8; }
.rules li { margin: 7px 0; }
.rule-score { padding: 13px 15px; border-left: 4px solid var(--accent); border-radius: 9px; color: #12665d; background: var(--accent-soft); }
.footer { padding: 26px; text-align: center; color: var(--muted); font-size: 13px; }

/* 游戏页 */
.topbar { position: sticky; top: 0; z-index: 20; border-bottom: 1px solid rgba(220, 225, 237, .9); background: rgba(249, 251, 255, .92); backdrop-filter: blur(16px); }
.topbar-inner { width: min(100%, 1240px); margin: auto; padding: 11px 18px; display: flex; justify-content: space-between; align-items: center; gap: 16px; }
.brand { display: flex; align-items: center; gap: 9px; color: var(--ink); font-weight: 850; letter-spacing: -.02em; }
.brand-mark { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 10px; color: #fff; background: linear-gradient(145deg, #6579ff, #13a999); font-size: 14px; box-shadow: 0 6px 13px rgba(83, 109, 254, .18); }
.stats { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.pill { padding: 7px 11px; border: 1px solid var(--line); border-radius: 999px; color: #4f5870; background: #fff; box-shadow: 0 3px 10px rgba(42, 54, 94, .04); font-size: 13px; }
.pill b { color: var(--ink); }
.game-shell { width: min(100%, 1240px); margin: auto; padding: 16px; }
.game-grid { display: grid; grid-template-columns: minmax(0, 1fr) 286px; gap: 16px; align-items: start; }
.game-main { min-width: 0; }
.canvas-wrap { position: relative; height: min(78vh, 790px); min-height: 440px; overflow: hidden; border: 1px solid #20283b; border-radius: 20px; background: #111725; box-shadow: 0 22px 50px rgba(19, 27, 49, .18); touch-action: none; }
.game-canvas { display: block; width: 100%; height: 100%; touch-action: none; }
.game-sidebar { display: flex; flex-direction: column; min-width: 0; }
.progress-card { margin: 0 0 14px; box-shadow: var(--shadow-small); }
.eyebrow { color: var(--primary); font-size: 10px; font-weight: 850; letter-spacing: .14em; }
.progress-card h3 { margin: 5px 0 18px; font-size: 20px; }
.progress-track { height: 10px; margin: 13px 0; overflow: hidden; border-radius: 999px; background: #e8ebf3; }
.progress-bar { height: 100%; border-radius: inherit; background: linear-gradient(90deg, #6379ff, #18b9a7); transition: width .25s ease; }
.progress-count { margin: 0; font-size: 16px; }
.progress-count b { font-size: 22px; }
.progress-tip { margin: 12px 0 0; color: var(--muted); font-size: 12px; line-height: 1.6; }
.complete-mark { margin-top: 18px; padding: 15px 10px; border-radius: 16px; text-align: center; color: #08796c; background: var(--accent-soft); }
.complete-mark .check { width: 48px; height: 48px; margin: auto auto 7px; display: grid; place-items: center; border-radius: 50%; color: #fff; background: var(--accent); font-size: 28px; font-weight: 900; box-shadow: 0 9px 18px rgba(18, 165, 148, .20); }
.complete-mark strong, .complete-mark small { display: block; }
.complete-mark small { margin-top: 4px; color: #43847d; }
.view-toolbar {
    min-height: 54px; margin-top: 9px; padding: 6px 8px 6px 14px; display: flex; align-items: center; justify-content: space-between;
    border: 1px solid var(--line); border-radius: 15px; color: var(--muted); background: rgba(255, 255, 255, .94);
    box-shadow: var(--shadow-small); font-size: 13px;
}
.view-toolbar > div { display: flex; gap: 6px; }
.view-tool { min-width: 42px; height: 40px; padding: 0 11px; border: 1px solid #d8deeb; border-radius: 11px; color: #3f4a65; background: #f7f8fc; font-size: 20px; font-weight: 800; }
.view-tool:hover { color: var(--primary-deep); border-color: #c7d0ff; background: var(--primary-soft); }
.view-tool-reset { min-width: 62px; font-size: 13px; }
.image-toast {
    position: absolute; left: 50%; top: 18px; z-index: 8; width: min(760px, calc(100% - 96px)); min-height: 62px;
    display: flex; align-items: center; gap: 13px; padding: 10px 16px; border: 1px solid transparent; border-radius: 16px;
    background: rgba(255, 255, 255, .95); box-shadow: 0 16px 40px rgba(8, 16, 38, .24); transform: translateX(-50%);
    backdrop-filter: blur(14px); pointer-events: none; animation: toast-in .2s ease-out;
}
.image-toast-badge { flex: 0 0 auto; min-width: 40px; height: 40px; padding: 0 7px; display: grid; place-items: center; border-radius: 12px; color: #fff; font-weight: 850; }
.image-toast-copy { min-width: 0; display: flex; align-items: baseline; gap: 12px; }
.image-toast-copy strong { flex: 0 0 auto; font-size: 16px; white-space: nowrap; }
.image-toast-copy p { margin: 0; color: #515b72; line-height: 1.45; }
.image-toast.found { border-color: #d8d3ff; }
.image-toast.found .image-toast-badge { background: var(--violet); }
.image-toast.found strong { color: #5145b6; }
.image-toast.safe { border-color: #bcebe4; }
.image-toast.safe .image-toast-badge { background: var(--accent); }
.image-toast.safe strong { color: #08796c; }
.image-toast.repeat { border-color: #cfd6fb; }
.image-toast.repeat .image-toast-badge { background: #6f7890; }
.image-toast.repeat strong { color: #4f5870; }
.image-toast.miss { border-color: #f4d8a3; }
.image-toast.miss .image-toast-badge { background: var(--amber); }
.image-toast.miss strong { color: #8a5800; }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, -8px); } to { opacity: 1; transform: translate(-50%, 0); } }
.violation-feedback { margin-top: 12px; padding: 14px 16px; border: 1px solid #d8d3ff; border-left: 6px solid var(--violet); border-radius: 16px; background: #f7f6ff; box-shadow: var(--shadow-small); }
.feedback-heading { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.feedback-heading small { color: #6658d3; font-weight: 750; }
.feedback-heading h3 { margin: 1px 0 0; font-size: 18px; }
.feedback-symbol { width: 36px; height: 36px; display: grid; place-items: center; flex: 0 0 auto; border-radius: 11px; color: #fff; background: var(--violet); font-weight: 900; }
.violation-list { display: grid; gap: 9px; }
.violation-item { width: 100%; min-width: 0; display: grid; grid-template-columns: auto 1fr; align-items: start; gap: 11px; padding: 10px 12px; border: 1px solid #e3dfff; border-radius: 12px; background: #fff; }
.violation-item strong { color: #5145b6; white-space: nowrap; }
.violation-item p { margin: 0; color: #4f5870; line-height: 1.55; }
.decoy-feedback { margin: auto 0 14px; padding: 14px; border: 1px solid #bcebe4; border-radius: 15px; color: #12665d; background: var(--accent-soft); }
.decoy-title { display: flex; align-items: center; gap: 8px; margin-bottom: 7px; }
.decoy-title span { width: 27px; height: 27px; display: grid; place-items: center; border-radius: 9px; color: #fff; background: var(--accent); font-weight: 900; }
.decoy-list p { margin: 8px 0 0; padding-top: 8px; border-top: 1px solid #c7eee8; line-height: 1.55; }

/* 结算与排行榜 */
.metric-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.metric { padding: 20px 9px; border: 1px solid #e6eafa; border-radius: 16px; text-align: center; background: linear-gradient(145deg, #f8f9ff, #f1f4ff); }
.metric strong { display: block; color: var(--primary-deep); font-size: 30px; }
.result-hero { padding-bottom: 18px; }
.result-hero .emblem { width: 58px; height: 58px; border-radius: 50%; transform: none; background: linear-gradient(145deg, #20b9a7, #4e71ef); }
.result-hero h1 { font-size: clamp(28px, 5vw, 38px); }
.result-summary { display: flex; align-items: center; justify-content: center; gap: 10px; margin: 20px 0 4px; padding: 14px; border-radius: 13px; color: #4054a8; background: var(--primary-soft); }
.section-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 14px; }
.section-heading h2 { margin-bottom: 4px; }
.section-heading p { margin: 0; }
.segmented { display: inline-flex; padding: 4px; border-radius: 13px; background: #e9edf5; }
.segmented button { padding: 9px 15px; border: 0; border-radius: 10px; color: var(--muted); background: transparent; font-weight: 750; }
.segmented button.active { color: var(--primary-deep); background: #fff; box-shadow: 0 4px 12px rgba(38, 51, 92, .10); }
.table-wrap { overflow: auto; }
.data-table { width: 100%; min-width: 640px; border-collapse: collapse; }
.data-table th, .data-table td { padding: 12px 11px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
.data-table th { color: var(--muted); background: #fafbfe; font-size: 13px; }
.answers-grid { display: grid; gap: 20px; }
.answer-image { width: 100%; display: block; border-radius: 14px; background: #151b29; }
.legend { display: flex; gap: 16px; margin: 10px 0; font-size: 13px; }
.dot { display: inline-block; width: 11px; height: 11px; margin-right: 6px; border-radius: 50%; }
.dot.bad { background: var(--violet); }
.dot.good { background: var(--accent); }
.answer-list { padding-left: 22px; }
.answer-list li { margin: 8px 0; line-height: 1.6; }

/* 管理后台 */
.admin-layout { display: grid; grid-template-columns: 230px 1fr; min-height: 100vh; }
.admin-nav { position: sticky; top: 0; height: 100vh; padding: 24px 15px; color: #e8edff; background: linear-gradient(180deg, #202946, #172036); }
.admin-nav h2 { margin-left: 10px; color: #fff; }
.admin-nav button, .admin-nav a { width: 100%; display: block; margin: 5px 0; padding: 12px; border: 0; border-radius: 11px; color: #cbd3ea; background: transparent; text-align: left; text-decoration: none; }
.admin-nav button.active, .admin-nav button:hover, .admin-nav a:hover { color: #fff; background: #ffffff16; }
.admin-main { min-width: 0; padding: 26px; }
.admin-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 22px; }
.admin-section { display: none; }
.admin-section.active { display: block; }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.toolbar .active { color: #fff; background: var(--primary); }
.editor-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 15px; }
.editor-canvas-wrap { position: relative; height: 600px; overflow: hidden; border-radius: 17px; background: #151b29; box-shadow: var(--shadow-small); touch-action: none; }
.editor-canvas { width: 100%; height: 100%; display: block; touch-action: none; }
.region-item { margin: 9px 0; padding: 11px; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.region-item textarea { min-height: 62px; }
.admin-form-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; align-items: end; }
.thumb { width: 90px; height: 60px; object-fit: cover; border-radius: 9px; background: #151b29; }
.warning { margin: 9px 0; padding: 10px; border: 1px solid #f2d495; border-radius: 10px; color: #795000; background: #fff8e8; }
.empty { padding: 32px; color: var(--muted); text-align: center; }
.status { display: inline-block; padding: 3px 8px; border-radius: 999px; background: #edf0f6; font-size: 12px; }
.status.on { color: #08796c; background: var(--accent-soft); }
.question-toggle { display: inline-flex; align-items: center; gap: 7px; font-weight: 700; }
.question-toggle input, .filter-check input { width: 19px; height: 19px; accent-color: var(--primary); }
.filter-check { display: flex; align-items: center; gap: 7px; padding-bottom: 15px; white-space: nowrap; }
.rules-editor { min-height: 280px; line-height: 1.8; resize: vertical; }
.save-hint { display: inline-block; margin-left: 12px; color: #08796c; font-weight: 700; }
.record-actions .btn { flex: 0 0 auto; min-width: 120px; }

@media (max-width: 900px) {
    .admin-layout { grid-template-columns: 1fr; }
    .admin-nav { position: static; height: auto; display: flex; gap: 4px; overflow: auto; padding: 10px; }
    .admin-nav h2 { display: none; }
    .admin-nav button, .admin-nav a { width: auto; white-space: nowrap; }
    .admin-main { padding: 14px; }
    .editor-layout { grid-template-columns: 1fr; }
    .editor-canvas-wrap { height: 480px; }
    .admin-form-row { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 760px) {
    .shell { padding: 13px; }
    .hero { padding: 28px 12px 20px; }
    .card { padding: 18px; border-radius: 18px; }
    .topbar-inner { align-items: flex-start; padding: 9px 12px; }
    .brand { font-size: 14px; }
    .brand-mark { width: 27px; height: 27px; }
    .stats { gap: 5px; }
    .pill { padding: 5px 7px; font-size: 11px; }
    .game-shell { padding: 9px; }
    .game-grid { grid-template-columns: 1fr; gap: 10px; }
    .canvas-wrap { height: 64vh; min-height: 390px; border-radius: 16px; }
    .view-toolbar { min-height: 48px; margin-top: 7px; padding: 4px 5px 4px 11px; }
    .view-tool { min-width: 39px; height: 38px; }
    .game-sidebar { display: block; }
    .progress-card { margin: 0; padding: 14px; }
    .progress-card h3 { display: inline; margin: 0 8px 0 0; font-size: 16px; }
    .progress-track { margin: 9px 0; }
    .progress-count { display: inline; font-size: 13px; }
    .progress-count b { font-size: 16px; }
    .progress-tip, .eyebrow { display: none; }
    .complete-mark { margin-top: 10px; padding: 9px; }
    .complete-mark .check { display: inline-grid; width: 28px; height: 28px; margin: 0 6px 0 0; font-size: 17px; vertical-align: middle; }
    .complete-mark strong { display: inline; }
    .complete-mark small { display: none; }
    .violation-feedback { padding: 12px; }
    .violation-item { width: 100%; min-width: 0; }
    .decoy-feedback { margin: 9px 0; }
    #nextBtn { width: 100% !important; height: 50px; }
    body.stage-ready { padding-bottom: calc(76px + env(safe-area-inset-bottom)); }
    body.stage-ready #nextBtn {
        position: fixed; left: 12px; right: 12px; bottom: calc(10px + env(safe-area-inset-bottom)); z-index: 30;
        width: auto !important; height: 56px; border: 2px solid rgba(255,255,255,.88); border-radius: 16px;
        box-shadow: 0 16px 38px rgba(55, 72, 170, .35); animation: next-ready .24s ease-out;
    }
    .image-toast { top: 10px; width: calc(100% - 20px); min-height: 56px; padding: 8px 11px; border-radius: 14px; }
    .image-toast-badge { min-width: 36px; height: 36px; border-radius: 10px; }
    .image-toast-copy { display: block; }
    .image-toast-copy strong { display: block; font-size: 14px; }
    .image-toast-copy p { max-width: calc(100vw - 105px); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
    .metric-grid { gap: 7px; }
    .metric { padding: 14px 5px; }
    .metric strong { font-size: 23px; }
    .section-heading { display: block; }
    .segmented { width: 100%; margin-top: 12px; }
    .segmented button { flex: 1; }
    .leaderboard-home { width: 100%; flex: 1 0 100% !important; }
}

@keyframes next-ready { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: translateY(0); } }

.loading-notice { margin: 14px 0 0; padding: 12px 16px; border: 1px solid #f3cf87; border-radius: 10px; background: #fff7e6; line-height: 1.7; white-space: pre-wrap; overflow-wrap: anywhere; text-align: center; }
.notice-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 16px; }
.notice-toolbar label { display: inline-flex; align-items: center; gap: 8px; }
.notice-toolbar input[type="color"] { width: 48px; height: 36px; padding: 2px; }
.notice-toolbar select { padding: 7px; border: 1px solid #d6dce8; border-radius: 6px; }
.notice-divider { border: 0; border-top: 1px solid #d6dce8; margin: 26px 0; }

.image-loading { position:absolute; inset:0; z-index:5; display:grid; place-items:center; background:#111725; color:#fff; font-size:17px; pointer-events:all; }
