html, body {
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
    overflow: hidden;
    background: #0d2a42;
    font-family: "Microsoft YaHei", "PingFang SC", "Helvetica Neue", Arial, sans-serif;
    -webkit-tap-highlight-color: transparent;
}

/* 整体纵向弹性布局：头部固定 + 主区域占满剩余空间 */
.apps {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    width: 100%;
}

/* ------------------------- 顶部 HUD ------------------------- */
.hud {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px 10px;
    padding: 7px 14px;
    background: linear-gradient(90deg, rgba(9, 38, 62, .94) 0%, rgba(16, 62, 96, .90) 55%, rgba(11, 44, 70, .94) 100%);
    border-bottom: 1px solid rgba(120, 210, 255, .32);
    box-shadow: 0 2px 20px rgba(0, 20, 40, .5);
    color: #d8eefb;
    font-size: 13px;
    line-height: 1;
    z-index: 10;
    backdrop-filter: blur(6px);
}

/* 游戏标题（H1 保留，利于 SEO 与语义结构），整体作为返回游戏列表的链接 */
.hud-title {
    margin: 0;
    padding: 0 8px 0 0;
    flex: 0 0 auto;
    line-height: 1;
    font-size: 1.2em;
}
.hud-title a {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-family: 'Coda', "Microsoft YaHei", sans-serif;
    font-size: 15px;
    font-weight: 800;
    color: #a8e4ff;
    letter-spacing: 1px;
    text-shadow: 0 0 14px rgba(120, 210, 255, .55);
    text-decoration: none;
    white-space: nowrap;
    transition: color .2s, text-shadow .2s, transform .2s;
}
.hud-title a:hover,
.hud-title a:focus {
    color: #ffffff;
    text-decoration: none;
    outline: none;
    text-shadow: 0 0 22px rgba(120, 210, 255, .9);
    transform: translateY(-1px);
}
.hud-title a .glyphicon {
    color: #ffd166;
    text-shadow: 0 0 12px rgba(255, 209, 102, .7);
}

/* 指标容器 */
.hud-stats {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    flex: 1 1 auto;
    min-width: 0;
}

/* 单个指标胶囊 */
.hud-item {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 10px;
    border-radius: 20px;
    background: rgba(255, 255, 255, .07);
    border: 1px solid rgba(255, 255, 255, .11);
    white-space: nowrap;
    transition: background .2s, border-color .2s, transform .2s;
}
.hud-item .glyphicon { color: #5fd0ff; font-size: 12px; }
.hud-item .val { font-weight: 700; color: #ffffff; font-family: 'Coda', monospace; }
.hud-item.warn { background: rgba(255, 82, 82, .18); border-color: rgba(255, 82, 82, .55); }
.hud-item.warn .glyphicon, .hud-item.warn .val { color: #ff8a8a; }
.hud-item.pop { transform: scale(1.14); }

/* 主题名胶囊 */
.hud-item.theme-item .glyphicon { color: #ffd166; }
.hud-item.theme-item .val { color: #ffe9a8; font-size: 12px; }

/* 星级 */
.hud-stars .glyphicon { color: #ffd166; font-size: 12px; }
.hud-stars .glyphicon-star-empty { color: rgba(255, 209, 102, .3); }

/* 操作按钮组 */
.hud-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 0 0 auto;
}
.hud-actions .btn {
    border-radius: 18px;
    border: 1px solid rgba(120, 210, 255, .38);
    background: rgba(120, 210, 255, .1);
    color: #bfe8ff;
    padding: 4px 11px;
    font-size: 12px;
    line-height: 1.4;
    transition: all .2s;
}
.hud-actions .btn:hover,
.hud-actions .btn:focus {
    background: rgba(120, 210, 255, .3);
    color: #ffffff;
    border-color: #5fd0ff;
    outline: none;
    box-shadow: 0 0 14px rgba(95, 208, 255, .55);
}
.hud-actions .btn .glyphicon { margin-right: 3px; }

/* ------------------------- 游戏主区域 ------------------------- */
.app-main {
    flex: 1 1 auto;
    position: relative;
    min-height: 0;
    overflow: hidden;
}
#gameCanvas {
    display: block;
    width: 100%;
    height: 100%;
}

/* ------------------------- 撒花 / 特效层 ------------------------- */
#fxCanvas {
    position: fixed;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 3000;   /* 高于弹窗，保证撒花显示在弹层之上 */
}

/* ------------------------- 弹窗居中与主题化 ------------------------- */
.modal {
    text-align: center;
    padding: 0 !important;
    overflow-y: auto;
}
.modal::before {
    content: "";
    display: inline-block;
    height: 100%;
    vertical-align: middle;
    margin-right: -4px;
}
.modal-dialog {
    display: inline-block;
    text-align: left;
    vertical-align: middle;
    margin: 12px auto;
    width: auto;
    max-width: 94vw;
}
.modal-backdrop.in { opacity: .74; }

.modal-content {
    border: 1px solid rgba(120, 210, 255, .3);
    border-radius: 18px;
    background: linear-gradient(165deg, #123a58 0%, #0d2a42 60%, #0a2236 100%);
    box-shadow: 0 24px 70px rgba(0, 10, 25, .78), 0 0 0 1px rgba(120, 210, 255, .1) inset;
    color: #d8eefb;
    overflow: hidden;
}
.modal-body { padding: 26px 28px 24px; }

.modal-title {
    font-family: 'Coda', "Microsoft YaHei", sans-serif;
    font-weight: 800;
    font-size: 19px;
    color: #a8e4ff;
    letter-spacing: 1px;
    margin: 0 0 6px;
    text-shadow: 0 0 18px rgba(120, 210, 255, .45);
}
.modal-sub {
    color: #8fb4cc;
    font-size: 13px;
    line-height: 1.75;
    margin: 0 0 18px;
}

/* 弹窗内小节标题（H3） */
.section-label {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 12.5px;
    font-weight: 700;
    color: #7fc9ee;
    letter-spacing: .5px;
    margin: 0 0 10px;
    padding: 0;
}
.section-label .glyphicon { color: #ffd166; font-size: 12px; }
.section-label::after {
    content: "";
    flex: 1 1 auto;
    height: 1px;
    background: linear-gradient(90deg, rgba(120, 210, 255, .28), rgba(120, 210, 255, 0));
}
.modal-section { margin: 0 0 20px; }
.modal-section:last-of-type { margin-bottom: 22px; }

/* 弹窗内按钮统一样式 */
.modal-content .btn {
    border-radius: 22px;
    padding: 7px 20px;
    font-size: 13px;
    font-weight: 600;
    transition: all .22s;
    border-width: 1px;
}
.modal-content .btn-default {
    background: rgba(255, 255, 255, .07);
    border-color: rgba(255, 255, 255, .2);
    color: #cfe3f2;
}
.modal-content .btn-default:hover,
.modal-content .btn-default:focus {
    background: rgba(255, 255, 255, .18);
    color: #fff;
    border-color: rgba(255, 255, 255, .4);
}
.modal-content .btn-success {
    background: linear-gradient(135deg, #38c6ff, #0f8ec4);
    border-color: #4fd2ff;
    color: #04222f;
    box-shadow: 0 6px 20px rgba(56, 198, 255, .38);
}
.modal-content .btn-success:hover,
.modal-content .btn-success:focus {
    background: linear-gradient(135deg, #6bd8ff, #1aa5dd);
    color: #04222f;
    box-shadow: 0 8px 26px rgba(56, 198, 255, .6);
    transform: translateY(-1px);
}
.modal-content .btn-warning {
    background: linear-gradient(135deg, #ffc371, #ff9f43);
    border-color: #ffb020;
    color: #3a2300;
    box-shadow: 0 6px 20px rgba(255, 159, 67, .35);
}
.modal-content .btn-warning:hover,
.modal-content .btn-warning:focus {
    background: linear-gradient(135deg, #ffd08a, #ffb020);
    color: #3a2300;
    transform: translateY(-1px);
}
.modal-content .btn-primary {
    background: linear-gradient(135deg, #ffb3c7, #ff6fa5);
    border-color: #ff8fb8;
    color: #3a0a1c;
    box-shadow: 0 6px 20px rgba(255, 111, 165, .35);
}
.modal-content .btn-primary:hover,
.modal-content .btn-primary:focus {
    background: linear-gradient(135deg, #ffd1de, #ff8fb8);
    color: #3a0a1c;
    transform: translateY(-1px);
}
.modal-content .btn-danger {
    background: rgba(255, 90, 90, .14);
    border-color: rgba(255, 90, 90, .42);
    color: #ff9a9a;
}
.modal-content .btn-danger:hover,
.modal-content .btn-danger:focus {
    background: rgba(255, 90, 90, .3);
    color: #fff;
    border-color: #ff6b6b;
}

/* 设置开关行 */
.setting-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 9px 12px;
    margin-bottom: 8px;
    border-radius: 11px;
    background: rgba(255, 255, 255, .04);
    border: 1px solid rgba(255, 255, 255, .08);
    font-size: 13px;
}
.setting-row:last-child { margin-bottom: 0; }
.setting-row > span:first-child {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}
.setting-row .glyphicon { color: #5fd0ff; font-size: 13px; }

/* 规则列表 */
.rule-list {
    list-style: none;
    padding: 0;
    margin: 0;
    text-align: left;
    font-size: 13px;
    line-height: 1.95;
    color: #b6d2e5;
}
.rule-list li { padding-left: 24px; position: relative; margin-bottom: 3px; }
.rule-list li .glyphicon {
    position: absolute;
    left: 0;
    top: 6px;
    color: #ffd166;
    font-size: 12px;
}
.rule-list kbd {
    background: rgba(120, 210, 255, .18);
    border: 1px solid rgba(120, 210, 255, .42);
    color: #a8e4ff;
    border-radius: 5px;
    padding: 1px 6px;
    font-size: 11.5px;
    font-family: 'Coda', monospace;
    box-shadow: none;
}

/* 弹窗底部按钮行：均匀分布，留呼吸感 */
.modal-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 10px;
    margin-top: 22px;
}

/* ------------------------- 结算弹窗 ------------------------- */
.result-icon {
    font-size: 52px;
    line-height: 1;
    margin-bottom: 8px;
}
.result-icon .glyphicon { display: inline-block; }
.result-icon.win .glyphicon {
    color: #ffd166;
    text-shadow: 0 0 28px rgba(255, 209, 102, .9);
    animation: winPop .8s cubic-bezier(.34, 1.56, .64, 1) both, winFloat 2.4s ease-in-out .8s infinite;
}
.result-icon.lose .glyphicon {
    color: #ff8a8a;
    text-shadow: 0 0 26px rgba(255, 107, 107, .8);
    animation: loseShake .7s cubic-bezier(.36, .07, .19, .97) both;
}
@keyframes winPop {
    0%   { transform: scale(.2) rotate(-25deg); opacity: 0; }
    60%  { transform: scale(1.25) rotate(8deg); opacity: 1; }
    100% { transform: scale(1) rotate(0deg); opacity: 1; }
}
@keyframes winFloat {
    0%, 100% { transform: translateY(0); }
    50%      { transform: translateY(-9px); }
}
@keyframes loseShake {
    0%, 100% { transform: translateX(0) rotate(0); }
    20%      { transform: translateX(-9px) rotate(-6deg); }
    40%      { transform: translateX(8px) rotate(6deg); }
    60%      { transform: translateX(-6px) rotate(-4deg); }
    80%      { transform: translateX(4px) rotate(3deg); }
}

.result-title {
    font-family: 'Coda', "Microsoft YaHei", sans-serif;
    font-size: 22px;
    font-weight: 800;
    letter-spacing: 2px;
    margin: 0 0 10px;
    text-align: center;
}
.result-title.win { color: #a8e4ff; text-shadow: 0 0 24px rgba(120, 210, 255, .7); }
.result-title.lose { color: #ff9a9a; text-shadow: 0 0 24px rgba(255, 107, 107, .6); }

.result-stars {
    text-align: center;
    font-size: 22px;
    margin-bottom: 18px;
    letter-spacing: 5px;
}
.result-stars .glyphicon { color: #ffd166; text-shadow: 0 0 16px rgba(255, 209, 102, .7); }
.result-stars .glyphicon-star-empty { color: rgba(255, 209, 102, .22); text-shadow: none; }

.result-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 9px;
    margin: 0 auto 14px;
    max-width: 342px;
}
.result-cell {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 9px 13px;
    border-radius: 11px;
    background: rgba(255, 255, 255, .05);
    border: 1px solid rgba(255, 255, 255, .09);
    font-size: 12.5px;
    white-space: nowrap;
}
.result-cell .lbl { color: #8fb4cc; display: inline-flex; align-items: center; gap: 5px; }
.result-cell .lbl .glyphicon { color: #5fd0ff; }
.result-cell .num { font-family: 'Coda', monospace; font-weight: 700; color: #ffffff; font-size: 14px; }
.result-cell.highlight {
    grid-column: 1 / -1;
    justify-content: center;
    gap: 12px;
    background: rgba(255, 209, 102, .1);
    border-color: rgba(255, 209, 102, .35);
}
.result-cell.highlight .lbl .glyphicon { color: #ffd166; }
.result-cell.highlight .num { color: #ffd166; font-size: 18px; }

.result-hint {
    text-align: center;
    color: #8fb4cc;
    font-size: 12.5px;
    line-height: 1.7;
    margin: 0 0 4px;
    min-height: 20px;
}

/* 排行榜激励提示 */
.rank-tip {
    text-align: center;
    font-size: 12.5px;
    font-weight: 700;
    margin: 6px 0 2px;
    padding: 7px 12px;
    border-radius: 9px;
    line-height: 1.55;
}
.rank-tip.good {
    color: #ffe9a8;
    background: rgba(255, 209, 102, .14);
    border: 1px dashed rgba(255, 209, 102, .5);
    animation: tipPulse 1.6s ease-in-out infinite;
}
.rank-tip.normal {
    color: #8fb4cc;
    background: rgba(255, 255, 255, .04);
    border: 1px dashed rgba(255, 255, 255, .12);
}
@keyframes tipPulse {
    0%, 100% { transform: scale(1); }
    50%      { transform: scale(1.025); }
}

/* 排行榜列表 */
.rank-section { margin: 12px auto 6px; max-width: 384px; }
.rank-list {
    border-radius: 11px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, .1);
    background: rgba(0, 0, 0, .18);
    font-size: 12px;
}
.rank-row {
    display: grid;
    grid-template-columns: 32px 1fr 1fr 1.5fr;
    gap: 6px;
    padding: 7px 11px;
    border-bottom: 1px solid rgba(255, 255, 255, .06);
    align-items: center;
}
.rank-row:last-child { border-bottom: none; }
.rank-row.head {
    background: rgba(120, 210, 255, .1);
    color: #8fb4cc;
    font-weight: 700;
    font-size: 11.5px;
    letter-spacing: .5px;
}
.rank-row.me {
    background: rgba(255, 209, 102, .14);
    box-shadow: inset 3px 0 0 #ffd166;
}
.rank-no {
    font-weight: 800;
    font-family: 'Coda', monospace;
    color: #a8e4ff;
    text-align: center;
}
.rank-row.me .rank-no { color: #ffd166; }
.rank-score {
    font-weight: 700;
    color: #ffd166;
    font-family: 'Coda', monospace;
    text-align: right;
}
.rank-time {
    color: #a8e4ff;
    font-family: 'Coda', monospace;
    text-align: right;
}
.rank-date {
    color: #8fb4cc;
    font-size: 11px;
    text-align: right;
}
.rank-empty {
    padding: 18px 10px;
    text-align: center;
    color: #8fb4cc;
    font-size: 12.5px;
}

/* 暂停弹窗按钮行 */
.pause-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 10px;
}

/* ------------------------- 响应式微调 ------------------------- */
@media (max-width: 900px) {
    .hud { font-size: 12px; padding: 6px 10px; gap: 5px 7px; }
    .hud-title a { font-size: 13px; }
    .hud-item { padding: 4px 8px; }
    .hud-actions .btn { padding: 3px 9px; font-size: 11px; }
    .hud-actions .btn .txt { display: none; }
}
@media (max-width: 560px) {
    .hud-item .lbl { display: none; }
    .modal-body { padding: 20px 17px 18px; }
    .result-grid { grid-template-columns: 1fr; max-width: 270px; }
    .modal-actions .btn { padding: 7px 16px; font-size: 12.5px; }
    .rank-row { grid-template-columns: 26px 1fr 1fr 1.3fr; padding: 6px 8px; font-size: 11px; }
}
@media (max-height: 620px) {
    .modal::before { display: none; }
    .modal-dialog { margin: 18px auto; }
}

/* 无障碍：键盘聚焦高亮 */
.modal-content .btn:focus-visible,
.hud-actions .btn:focus-visible,
.hud-title a:focus-visible {
    outline: 2px solid #5fd0ff;
    outline-offset: 2px;
}

/* 屏幕阅读器专用（用于语义化标题，不占视觉空间） */
.sr-only {
    position: absolute;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}
@media (min-width: 768px) {
    .modal-dialog {
        min-width: auto;
        width: auto;
    }
}