/* ===== 基础布局 ===== */
* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
    --green: #27ae60;
    --red: #e74c3c;
    --blue: #4169e1;
    --blue-2: #5c81f0;
}

html, body { height: 100%; overflow: hidden; }
body {
    font-family: "PingFang SC", "Microsoft YaHei", sans-serif;
    background: #16286b;
    color: #fff;
}

.scene {
    position: fixed; inset: 0;
    display: none;
    flex-direction: column;
    align-items: center; justify-content: center;
    text-align: center;
    /* 创建 stacking context，使子元素 z-index: -1 可正常工作 */
    isolation: isolate;
}
.scene.active { display: flex; }

.hidden { display: none !important; }

/* ===== 统一标题栏（与 vocab-map 同款蓝色渐变，固定吸顶） ===== */
.unified-bar {
    position: absolute !important; top: 0 !important; left: 0 !important; right: 0 !important;
    height: 56px; flex-shrink: 0;
    display: flex; align-items: center;
    padding: 0 14px;
    background: linear-gradient(135deg, #4169e1, #5c81f0);
    box-shadow: 0 2px 12px rgba(65, 105, 225, .35);
    gap: 12px;
    z-index: 6;
    width: 100%;
}
.home-btn {
    width: 38px; height: 38px; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    border: none; border-radius: 10px;
    background: rgba(255,255,255,.16);
    cursor: pointer; text-decoration: none;
    transition: background .15s;
}
.home-btn:hover { background: rgba(255,255,255,.3); }
.home-btn svg { width: 22px; height: 22px; display: block; }
.unified-bar .divider { width: 1px; height: 24px; background: rgba(255,255,255,.18); }
.unified-bar .module-name {
    flex: 0 1 auto; min-width: 0;
    font-size: .95rem; color: rgba(255,255,255,.92);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    text-align: left;
}
.unified-bar .divider.push-right { margin-left: auto; }

/* 教师统计入口：与主页图标同风格、略小一号，置于标题栏末端 */
.unified-bar .admin-btn {
    width: 30px; height: 30px; border-radius: 8px;
}
.unified-bar .admin-btn svg { width: 17px; height: 17px; }

.btn {
    border: none; border-radius: 12px;
    font-size: 1.4rem; font-weight: bold;
    padding: 14px 42px; cursor: pointer;
    color: #fff; transition: transform .1s;
    box-shadow: 0 4px 0 rgba(0,0,0,.3);
}
.btn:active { transform: translateY(3px); box-shadow: none; }
.btn-primary { background: linear-gradient(135deg, var(--blue), var(--blue-2)); }

/* ===== 开始页 ===== */
#scene-start { background: linear-gradient(160deg, #4169e1, #16286b); gap: 18px; }
#scene-start > *:not(#start-bg-items) {
    position: relative;
    z-index: 1;
}
#start-title { font-size: 3rem; letter-spacing: 2px; }
#start-subtitle { font-size: 1.4rem; opacity: .85; }

/* 开始页物品暗纹背景 */
#start-bg-items {
    position: absolute; inset: 0;
    overflow: hidden; pointer-events: none;
    z-index: -1;
}
#start-bg-items .bg-item {
    position: absolute;
    opacity: .12;
    color: #fff;
    animation: floatItem 12s ease-in-out infinite alternate;
}
#start-bg-items .bg-item:nth-child(odd) {
    animation-direction: alternate-reverse;
    animation-duration: 15s;
}
#start-bg-items .bg-item svg {
    width: 100%; height: 100%; display: block;
}
@keyframes floatItem {
    0%   { transform: translateY(0) rotate(0deg); }
    100% { transform: translateY(-12px) rotate(4deg); }
}

/* 雷达扫描动画（开始页） */
.radar-scan {
    width: 200px; height: 200px;
    border-radius: 50%;
    background:
        radial-gradient(circle, rgba(231,76,60,.9) 0 16px, transparent 17px),
        repeating-radial-gradient(circle, rgba(231,76,60,.25) 0 7px, transparent 7px 22px);
    animation: scan 1.6s ease-in-out infinite alternate;
}
@keyframes scan { to { transform: scale(1.15) rotate(8deg); } }

/* ===== 游戏场景 ===== */
#scene-game { justify-content: flex-start; }

/* 合并进标题栏的 HUD（乘客进度 + 分数），透明底、白字、右侧 */
#hud {
    display: flex;
    align-items: center;
    gap: 14px;
    font-size: .92rem; font-weight: bold;
    color: #fff;
    flex-shrink: 0;
    white-space: nowrap;
}
#hud-score {
    background: rgba(255,255,255,.18);
    padding: 3px 12px; border-radius: 8px;
}

#stage {
    position: relative;
    width: 100%; flex: 1;
    overflow: hidden;
    background: linear-gradient(180deg, #d7e4f7, #c3d6f2);
}
#scene3d { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }

/* ===== 物品弹窗 ===== */
#items-popup {
    position: absolute; top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(22, 40, 107, .78);
    backdrop-filter: blur(6px);
    border: 3px solid var(--red);
    border-radius: 16px;
    padding: 18px 40px;
    z-index: 20;
    animation: pop .35s ease;
}
@keyframes pop {
    from { transform: translate(-50%, -50%) scale(.4); opacity: 0; }
    to   { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}
#popup-title { color: var(--red); font-size: 1.5rem; animation: blink .6s infinite; }
#popup-hint { margin: 8px 0; opacity: .8; }
#popup-list { list-style: none; font-size: 1.8rem; font-weight: bold; letter-spacing: 1px; }
#popup-list li { padding: 4px 0; }

/* ===== 操作区（始终显示黑条，深蓝调） ===== */
#controls {
    width: 100%; padding: 16px;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    background: rgba(22, 40, 107, .72); z-index: 10;
    height: 120px;
    flex-shrink: 0;
}
#controls-hint {
    font-size: 1.1rem; opacity: .55; letter-spacing: 1px;
}
#controls-btns.hidden { display: none; }
#controls-btns {
    display: flex; justify-content: center; gap: 60px;
}
.btn-pass { background: var(--green); font-size: 1.8rem; padding: 16px 70px; }
.btn-inspect { background: var(--red); font-size: 1.8rem; padding: 16px 70px; }

/* ===== 即时反馈（含单词卡片，合并为一个弹窗） ===== */
#feedback {
    position: absolute; top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(22, 40, 107, .94);
    border: 3px solid #3a7bd5;
    border-radius: 24px;
    padding: 30px 60px 28px;
    min-width: 320px;
    z-index: 30;
    animation: pop2 .3s ease;
    text-align: center;
}
#feedback.hidden { display: none; }
#feedback p { margin: 0; opacity: .85; font-size: 1.3rem; }
#feedback.good {
    border-color: var(--green);
    background: linear-gradient(160deg, rgba(21,73,49,.72), rgba(22,40,107,.62));
    backdrop-filter: blur(6px);
    box-shadow: 0 0 0 6px rgba(39,174,96,.25), 0 0 60px rgba(39,174,96,.5);
    animation: pop2 .3s ease, goodPulse .6s ease .3s;
}
#feedback.bad {
    border-color: #f39c12;
    background: linear-gradient(160deg, rgba(94,57,11,.72), rgba(22,40,107,.62));
    backdrop-filter: blur(6px);
    box-shadow: 0 0 0 6px rgba(243,156,18,.25), 0 0 60px rgba(243,156,18,.5);
    animation: pop2 .3s ease, badShake .4s ease .3s;
}
@keyframes goodPulse {
    0%, 100% { transform: translate(-50%, -50%) scale(1); }
    50% { transform: translate(-50%, -50%) scale(1.05); }
}
@keyframes badShake {
    0%, 100% { transform: translate(-50%, -50%) translateX(0); }
    20% { transform: translate(-50%, -50%) translateX(-12px); }
    40% { transform: translate(-50%, -50%) translateX(10px); }
    60% { transform: translate(-50%, -50%) translateX(-6px); }
    80% { transform: translate(-50%, -50%) translateX(4px); }
}
#card-emoji { width: 100px; height: 100px; margin: 0 auto 8px; line-height: 100px; font-size: 4rem; }
#card-emoji svg { width: 100%; height: 100%; display: block; }
#card-en { font-size: 2.6rem; font-weight: bold; color: #fff; letter-spacing: 3px; }
#card-zh { font-size: 1.4rem; opacity: .85; margin-top: 4px; }
#card-type {
    margin: 12px 0 14px; font-size: 1.1rem; font-weight: bold;
    padding: 5px 22px; border-radius: 10px; display: inline-block;
}
#card-type.safe { background: #27ae60; color: #fff; }
#card-type.danger { background: #e74c3c; color: #fff; }
#feedback-en { font-size: 1.6rem; font-weight: bold; margin-top: 10px; }
#feedback-zh { font-size: 1.2rem; margin-top: 4px; }
#feedback.good #feedback-en { color: var(--green); }
#feedback.bad #feedback-en { color: #f39c12; }

/* 继续按钮（反馈弹窗内） */
#feedback-continue {
    margin-top: 16px;
    font-size: 1.2rem;
    padding: 10px 46px;
    animation: continuePulse 1.5s ease infinite;
}
@keyframes continuePulse {
    0%, 100% { box-shadow: 0 4px 0 rgba(0,0,0,.3); }
    50% { box-shadow: 0 4px 0 rgba(0,0,0,.3), 0 0 18px rgba(58,123,213,.8); }
}

#feedback #card-emoji { position: relative; z-index: 2; }
#feedback .fw-particle {
    position: absolute;
    border-radius: 50%;
    z-index: 1; /* 在物品图片后面 */
    pointer-events: none;
}

/* 对错大标志 */
#feedback-verdict {
    font-size: 2.4rem; font-weight: 900;
    letter-spacing: 4px;
    margin-bottom: 10px;
}
#feedback.good #feedback-verdict {
    color: var(--green);
    text-shadow: 0 0 24px rgba(39,174,96,.9);
}
#feedback.bad #feedback-verdict {
    color: #f39c12;
    text-shadow: 0 0 24px rgba(243,156,18,.9);
}

/* ===== 结算页 ===== */
#scene-result {
    background: linear-gradient(160deg, #4169e1, #16286b);
    gap: 12px;
    /* 顶栏 56px 高，给它留出空间，避免分数/评语被顶栏遮挡 */
    padding: 72px 16px 20px;
    overflow-y: auto;
    justify-content: flex-start;
}
#result-score-box {
    font-size: 2.8rem;
    font-weight: bold;
    color: #fff;
    text-shadow: 0 0 12px rgba(58,123,213,.5);
}
#result-bar {
    width: min(80%, 400px);
    height: 18px;
    background: rgba(255,255,255,.12);
    border-radius: 9px;
    overflow: hidden;
    margin-bottom: 4px;
}
.bar-fill {
    height: 100%;
    border-radius: 9px;
    transition: width .8s ease;
    width: 0;
}
.bar-fill.perfect { background: linear-gradient(90deg, #27ae60, #2ecc71); }
.bar-fill.good    { background: linear-gradient(90deg, #2980b9, #3498db); }
.bar-fill.ok      { background: linear-gradient(90deg, #f39c12, #f1c40f); }
.bar-fill.low     { background: linear-gradient(90deg, #e74c3c, #c0392b); }

#result-lines { font-size: 1.4rem; line-height: 1.8; }

/* 回答情况表 */
#result-table-wrap {
    width: min(96%, 640px);
    max-height: 40vh;
    overflow-y: auto;
    border-radius: 12px;
    border: 1px solid rgba(255,255,255,.15);
}
#result-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95rem;
}
#result-table thead { position: sticky; top: 0; z-index: 1; }
#result-table th {
    background: rgba(22,40,107,.98);
    padding: 10px 6px;
    font-weight: bold;
    font-size: 0.9rem;
    color: #64b5f6;
    border-bottom: 3px solid #3a7bd5;
    letter-spacing: 0.5px;
}
#result-table td {
    padding: 7px 6px;
    border-bottom: 1px solid rgba(255,255,255,.08);
    text-align: center;
    vertical-align: middle;
}
#result-table tr.row-ok { background: rgba(39,174,96,.12); }
#result-table tr.row-fail { background: rgba(231,76,60,.12); }
.td-idx { width: 24px; color: rgba(255,255,255,.5); }
.td-icon { width: 36px; }
.td-icon svg { width: 28px; height: 28px; }
.td-en { font-weight: bold; color: #fff; }
.td-zh { opacity: .8; }
.td-type.safe { color: #2ecc71; }
.td-type.danger { color: #e74c3c; }
/* 处置方式（真实安检规则） */
.td-disposal {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: bold;
    white-space: nowrap;
}
.td-disposal.tray { background: rgba(41,128,185,.25); color: #64b5f6; }
.td-disposal.pass { background: rgba(46,204,113,.2); color: #a5d6a7; }
.td-disposal.recheck { background: rgba(241,196,15,.2); color: #ffe082; }
.td-disposal.checked { background: rgba(243,156,18,.2); color: #ffcc80; }
.td-disposal.notAllowed { background: rgba(231,76,60,.22); color: #ef9a9a; }
.td-choice { font-weight: bold; }
.td-result { font-size: 1.1rem; }

@keyframes blink { 50% { opacity: .25; } }

/* ===== 报警红光氛围（仅在弹出的英文单词框 #items-popup 四周往外闪烁） ===== */
/* 通过 box-shadow 在弹窗外侧扩散，不进入弹窗内部，不影响整个画面 */
#items-popup {
    /* 默认无外扩红光；.on 时启用外扩闪烁 */
    box-shadow: 0 0 0 0 rgba(231,76,60,0);
    transition: box-shadow .2s;
}
#items-popup.on {
    animation: alarmGlow .5s ease-in-out infinite alternate;
}
@keyframes alarmGlow {
    from {
        box-shadow:
            0 0 0 0   rgba(231,76,60,0),
            0 0 30px  0   rgba(231,76,60,.35),
            0 0 80px  10px rgba(231,76,60,.25);
    }
    to {
        box-shadow:
            0 0 0 4px rgba(231,76,60,.25),
            0 0 60px  8px  rgba(231,76,60,.6),
            0 0 140px 30px rgba(231,76,60,.4);
    }
}

/* ===== 分数飘字 ===== */
#score-float {
    position: absolute; top: 40%; left: 50%;
    z-index: 40;
    font-size: 4rem; font-weight: bold;
    color: #2ecc71;
    text-shadow: 0 0 20px rgba(46,204,113,.8), 0 2px 0 rgba(0,0,0,.4);
    pointer-events: none;
    opacity: 0;
}
#score-float.show { animation: floatUp 1.4s ease forwards; }
@keyframes floatUp {
    0%   { opacity: 0; transform: translate(-50%, 0) scale(.4); }
    20%  { opacity: 1; transform: translate(-50%, -20px) scale(1.2); }
    100% { opacity: 0; transform: translate(-50%, -110px) scale(1); }
}

/* ===== 全屏按钮 ===== */
#btn-fullscreen {
    position: fixed; top: 64px; right: 10px;
    z-index: 999;
    width: 38px; height: 38px;
    border: none; border-radius: 10px;
    background: #FF9800;
    color: #fff; font-size: 1rem; font-weight: bold;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(255,152,0,.4);
    transition: filter .15s, transform .15s;
}
#btn-fullscreen:hover { filter: brightness(1.12); transform: translateY(-1px); }
