*, *::before, *::after { box-sizing: border-box; }
html, body {
    height: 100%; margin: 0; padding: 0; overflow: hidden;
    background: #050812; color: #dbe6ff;
    font-family: "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Helvetica, Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
}
button { font-family: inherit; }
#apps { display: flex; flex-direction: column; height: 100%; width: 100%; }

/* ============================================================
   顶部工具栏
   ============================================================ */
#topbar {
    flex: 0 0 auto;
    display: flex; align-items: center; justify-content: space-between;
    gap: 10px; height: 52px; padding: 0 12px;
    background: linear-gradient(180deg, #101a30 0%, #070d1c 100%);
    border-bottom: 1px solid rgba(120,170,255,.18);
    box-shadow: 0 2px 18px rgba(0,0,0,.6);
    z-index: 30; position: relative;
}
#topbar::after {
    content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 1px;
    background: linear-gradient(90deg, transparent, rgba(120,200,255,.55), transparent);
}
.tb-brand { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }
.tb-brand .brand-mark {
    width: 30px; height: 30px; border-radius: 9px;
    display: flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, #4ea8ff, #9b7bff);
    box-shadow: 0 0 14px rgba(90,160,255,.55);
    color: #fff; font-size: 15px;
}
#topbar h1 {
    margin: 0; font-size: 15px; font-weight: 700; letter-spacing: .5px;
    white-space: nowrap;
    background: linear-gradient(90deg, #86dcff, #b39cff);
    -webkit-background-clip: text; background-clip: text; color: transparent;
}
#topbar h1 small {
    display: block; font-size: 10px; letter-spacing: 2px; font-weight: 400;
    color: #5b6d92; -webkit-text-fill-color: #5b6d92;
}
.tb-stats {
    flex: 1 1 auto; display: flex; align-items: center; justify-content: center;
    gap: 6px; overflow: hidden; min-width: 0;
}
.stat-chip {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 4px 10px; border-radius: 20px;
    background: rgba(90,140,255,.10);
    border: 1px solid rgba(120,170,255,.16);
    font-size: 12px; color: #8fa4c9; white-space: nowrap;
    transition: background .2s, border-color .2s;
}
.stat-chip .glyphicon { font-size: 11px; opacity: .85; }
.stat-chip b {
    color: #8fe3ff; font-size: 13px; font-weight: 700;
    font-variant-numeric: tabular-nums; min-width: 16px; text-align: right;
}
.stat-chip.hot { background: rgba(255,140,60,.16); border-color: rgba(255,160,80,.4); }
.stat-chip.hot b { color: #ffb067; }
.stat-chip.hot .glyphicon { color: #ff8a3d; }
.tb-actions { display: flex; align-items: center; gap: 5px; flex: 0 0 auto; }
.tb-actions .btn {
    background: rgba(90,140,255,.10);
    border: 1px solid rgba(120,170,255,.20);
    color: #9fb6dd; padding: 5px 9px; font-size: 12px; border-radius: 8px;
    transition: all .18s ease;
}
.tb-actions .btn:hover, .tb-actions .btn:focus {
    background: rgba(110,170,255,.28); color: #e6f3ff;
    border-color: rgba(150,200,255,.5);
    box-shadow: 0 0 12px rgba(90,160,255,.35); outline: none;
}
.tb-actions .btn.active { background: rgba(110,170,255,.35); color: #fff; }

/* ============================================================
   游戏舞台
   ============================================================ */
#stage { position: relative; flex: 1 1 auto; overflow: hidden; background: #050812; }
#game { position: absolute; left: 0; top: 0; width: 100%; height: 100%; display: block; }

#fx-canvas {
    position: fixed; left: 0; top: 0; width: 100%; height: 100%;
    pointer-events: none; z-index: 1100; display: block;
}

/* ============================================================
   弹层：水平 + 垂直居中
   ============================================================ */
.modal { text-align: center; padding: 0 !important; }
.modal::before {
    content: ""; display: inline-block; height: 100%;
    vertical-align: middle; margin-right: -0.05em;
}
.modal-dialog {
    display: inline-block; vertical-align: middle; text-align: left;
    width: 520px; max-width: 94vw; margin: 14px auto;
}
.modal-backdrop.in { opacity: .74; }
.game-modal {
    background: linear-gradient(160deg, #14203c 0%, #0c1424 60%, #080e1c 100%);
    border: 1px solid rgba(120,170,255,.28);
    border-radius: 16px;
    box-shadow: 0 24px 70px rgba(0,0,0,.78), 0 0 0 1px rgba(255,255,255,.04) inset;
    overflow: hidden; color: #cfdcf5;
}
.game-modal .modal-body { padding: 28px 26px 22px; }
.game-modal .modal-footer {
    display: flex; flex-wrap: wrap; justify-content: center; align-items: center;
    gap: 10px; padding: 18px 22px 22px;
    border-top: 1px solid rgba(120,170,255,.14);
    background: rgba(0,0,0,.16);
}
.game-modal .modal-footer .btn-gm {
    margin: 0 !important; min-width: 138px;
    padding-left: 18px; padding-right: 18px;
}
.gm-icon {
    width: 64px; height: 64px; margin: 0 auto 14px;
    border-radius: 18px; display: flex; align-items: center; justify-content: center;
    font-size: 28px; color: #fff;
    background: linear-gradient(135deg, #4ea8ff, #9b7bff);
    box-shadow: 0 8px 26px rgba(90,150,255,.45);
    animation: gmPulse 2.6s ease-in-out infinite;
}
@keyframes gmPulse {
    0%,100% { transform: translateY(0) scale(1); }
    50%     { transform: translateY(-4px) scale(1.04); }
}
.gm-title {
    margin: 0 0 8px; font-size: 22px; font-weight: 700; color: #eaf3ff;
    text-align: center; letter-spacing: .5px;
}
.gm-desc {
    margin: 0 auto 16px; font-size: 13px; line-height: 1.75;
    color: #8ba0c6; text-align: center; max-width: 400px;
}
.key-hint {
    display: inline-block; padding: 1px 7px; margin: 0 2px;
    border-radius: 5px; font-size: 11px; font-weight: 700;
    background: rgba(120,180,255,.18); color: #9fdcff;
    border: 1px solid rgba(120,180,255,.35);
    border-bottom-width: 2px;
}
.btn-gm {
    border-radius: 10px; padding: 9px 22px; font-size: 14px; font-weight: 600;
    border: 1px solid transparent; transition: all .18s ease;
    white-space: nowrap;
}
.btn-primary-gm {
    background: linear-gradient(135deg, #3d8bff, #7a5cff); color: #fff;
    box-shadow: 0 6px 20px rgba(80,130,255,.42);
}
.btn-primary-gm:hover, .btn-primary-gm:focus {
    color: #fff; transform: translateY(-1px);
    box-shadow: 0 10px 26px rgba(80,130,255,.6); outline: none;
}
.btn-ghost-gm {
    background: rgba(120,170,255,.10); color: #a9c2e8;
    border-color: rgba(120,170,255,.26);
}
.btn-ghost-gm:hover, .btn-ghost-gm:focus {
    background: rgba(120,170,255,.24); color: #e3f0ff; outline: none;
}
.setting-row {
    display: flex; align-items: center; justify-content: space-between;
    gap: 14px; padding: 10px 0;
    border-bottom: 1px dashed rgba(120,170,255,.14);
}
.setting-row:last-child { border-bottom: none; }
.setting-label {
    font-size: 13px; color: #a9bcdd;
    display: flex; align-items: center; gap: 8px; flex: 0 0 auto;
}
.setting-label .glyphicon { color: #6fa4ff; }
.setting-ctrl {
    flex: 1 1 auto; display: flex; align-items: center; gap: 10px; justify-content: flex-end;
}
.setting-ctrl input[type="range"] {
    -webkit-appearance: none; appearance: none;
    width: 140px; height: 5px; border-radius: 3px; outline: none;
    background: linear-gradient(90deg, #3d8bff, #9b7bff);
    cursor: pointer;
}
.setting-ctrl input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none; appearance: none;
    width: 16px; height: 16px; border-radius: 50%;
    background: #fff; box-shadow: 0 0 10px rgba(110,160,255,.9); cursor: pointer;
}
.setting-ctrl input[type="range"]::-moz-range-thumb {
    width: 16px; height: 16px; border-radius: 50%; border: none;
    background: #fff; box-shadow: 0 0 10px rgba(110,160,255,.9); cursor: pointer;
}
.setting-val {
    width: 42px; text-align: right; font-size: 12px; color: #8fe3ff;
    font-variant-numeric: tabular-nums;
}
.seg-group {
    display: inline-flex; border-radius: 9px; overflow: hidden;
    border: 1px solid rgba(120,170,255,.26);
}
.seg-group button {
    background: transparent; border: none; color: #8ba0c6;
    padding: 6px 12px; font-size: 12px; transition: all .18s;
}
.seg-group button + button { border-left: 1px solid rgba(120,170,255,.2); }
.seg-group button.active {
    background: linear-gradient(135deg,#3d8bff,#7a5cff); color: #fff;
}
.rule-card {
    display: flex; gap: 12px; align-items: flex-start;
    padding: 11px 13px; margin-bottom: 9px;
    border-radius: 11px;
    background: rgba(90,140,255,.07);
    border: 1px solid rgba(120,170,255,.14);
}
.rule-card .rc-icon {
    flex: 0 0 auto; width: 30px; height: 30px; border-radius: 9px;
    display: flex; align-items: center; justify-content: center;
    font-size: 13px; color: #fff;
}
.rule-card .rc-body { flex: 1 1 auto; min-width: 0; }
.rule-card .rc-title { font-size: 13px; font-weight: 700; color: #d7e6ff; margin-bottom: 3px; }
.rule-card .rc-text { font-size: 12px; line-height: 1.65; color: #8ba0c6; }

.result-stats {
    display: grid; grid-template-columns: repeat(2, 1fr);
    gap: 12px; margin: 18px 0 8px;
}
.rs-item {
    background: rgba(90,140,255,.08);
    border: 1px solid rgba(120,170,255,.16);
    border-radius: 12px; padding: 14px 10px; text-align: center;
}
.rs-item .glyphicon { font-size: 15px; color: #6fa4ff; display: block; margin-bottom: 6px; }
.rs-item .rs-val {
    font-size: 22px; font-weight: 700; color: #8fe3ff;
    font-variant-numeric: tabular-nums; line-height: 1.15;
}
.rs-item .rs-label { font-size: 11px; color: #7c90b5; margin-top: 4px; letter-spacing: .5px; }
.result-badge {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 8px 20px; border-radius: 24px; font-size: 14px; font-weight: 700;
    margin-bottom: 6px;
}
.rb-win  { background: rgba(70,220,150,.16); color: #55e6a5; border: 1px solid rgba(70,220,150,.4); }
.rb-lose { background: rgba(255,90,90,.16);  color: #ff8080; border: 1px solid rgba(255,90,90,.4); }

/* ============================================================
   Toast —— 水平居中，纵向位于屏幕上方 18%（方块人上方，不遮挡目标台阶）
   ============================================================ */
#toast-wrap {
    position: fixed; left: 50%; top: 18%;
    transform: translate(-50%, -50%);
    z-index: 1200; pointer-events: none;
    display: flex; flex-direction: column; align-items: center; gap: 8px;
}
.gm-toast {
    display: flex; align-items: center; gap: 9px;
    padding: 10px 22px; border-radius: 30px;
    font-size: 14px; font-weight: 600; color: #eaf3ff;
    background: rgba(16,26,48,.96);
    border: 1px solid rgba(120,170,255,.4);
    box-shadow: 0 12px 40px rgba(0,0,0,.7), 0 0 22px rgba(80,150,255,.28);
    animation: toastIn .3s cubic-bezier(.2,1.3,.5,1);
    white-space: nowrap;
}
.gm-toast.out { animation: toastOut .3s ease forwards; }
.gm-toast .glyphicon { font-size: 15px; }
.gm-toast.ok   { border-color: rgba(70,220,150,.55); }
.gm-toast.ok   .glyphicon { color: #55e6a5; }
.gm-toast.err  { border-color: rgba(255,90,90,.55); }
.gm-toast.err  .glyphicon { color: #ff8080; }
.gm-toast.info .glyphicon { color: #6fa4ff; }
@keyframes toastIn  { from { opacity: 0; transform: translateY(14px) scale(.94); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to   { opacity: 0; transform: translateY(-12px) scale(.96); } }

@media (max-width: 900px) {
    #topbar h1 small { display: none; }
    .stat-chip { padding: 3px 8px; font-size: 11px; }
    .stat-chip b { font-size: 12px; }
}
@media (max-width: 700px) {
    #topbar { height: 46px; padding: 0 8px; gap: 6px; }
    #topbar h1 { font-size: 13px; }
    .tb-brand .brand-mark { width: 26px; height: 26px; font-size: 13px; }
    .stat-chip[data-opt] { display: none; }
    .tb-actions .btn { padding: 4px 7px; font-size: 11px; }
    .game-modal .modal-body { padding: 22px 16px 18px; }
    .gm-title { font-size: 18px; }
    .game-modal .modal-footer .btn-gm { min-width: 110px; font-size: 13px; padding: 8px 14px; }
}