* { box-sizing: border-box; }

html, body {
    height: 100%;
    margin: 0;
    padding: 0;
    overflow: hidden;
    background: #04121f;
    color: #cfe9ff;
    font-family: "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Helvetica, Arial, sans-serif;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    touch-action: none;
}

#app {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    position: relative;
}

#hud {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 7px 14px;
    background: linear-gradient(180deg, rgba(9, 36, 60, .97), rgba(5, 20, 35, .94));
    border-bottom: 1px solid rgba(90, 200, 255, .22);
    box-shadow: 0 3px 18px rgba(0, 0, 0, .55);
    z-index: 20;
    white-space: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}
#hud::-webkit-scrollbar { display: none; }

.hud-group { display: flex; align-items: center; gap: 7px; flex: 0 0 auto; }

.hud-item {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 11px;
    border-radius: 999px;
    background: rgba(255, 255, 255, .055);
    border: 1px solid rgba(120, 210, 255, .16);
    color: #a8d6f5;
    font-size: 13px;
    line-height: 1.45;
    letter-spacing: .2px;
    transition: background .2s, border-color .2s, transform .18s;
}
.hud-item .glyphicon { font-size: 12px; }
.hud-item b {
    color: #ffffff;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    font-feature-settings: "tnum";
}

.hud-item.hp     { color: #ff9aa6; border-color: rgba(255, 120, 140, .28); }
.hud-item.hp .glyphicon { color: #ff5d72; }
.hud-item.score  { color: #ffd98a; border-color: rgba(255, 200, 90, .28); }
.hud-item.score .glyphicon { color: #ffc53d; }
.hud-item.combo  { color: #ffb27a; border-color: rgba(255, 150, 90, .28); }
.hud-item.combo .glyphicon { color: #ff8a3d; }
.hud-item.wpm    { color: #8ff0d0; border-color: rgba(90, 230, 190, .28); }
.hud-item.wpm .glyphicon { color: #26e0b0; }
.hud-item.acc    { color: #9dd8ff; border-color: rgba(100, 190, 255, .28); }
.hud-item.acc .glyphicon { color: #4ad6ff; }
.hud-item.lvl    { color: #c8b6ff; border-color: rgba(160, 130, 255, .28); }
.hud-item.lvl .glyphicon { color: #9b7bff; }
.hud-item.size   { color: #ffc4a8; border-color: rgba(255, 170, 130, .28); }
.hud-item.size .glyphicon { color: #ff9b6a; }

.hud-item.combo.hot {
    background: rgba(255, 138, 61, .22);
    border-color: rgba(255, 160, 90, .7);
    transform: scale(1.06);
    animation: comboPulse .45s ease;
}
@keyframes comboPulse {
    0%   { box-shadow: 0 0 0 0 rgba(255, 160, 80, .65); }
    100% { box-shadow: 0 0 0 14px rgba(255, 160, 80, 0); }
}

.hud-progress {
    width: 82px;
    height: 7px;
    border-radius: 99px;
    background: rgba(255, 255, 255, .13);
    overflow: hidden;
    position: relative;
}
.hud-progress > i {
    display: block;
    height: 100%;
    width: 0%;
    border-radius: 99px;
    background: linear-gradient(90deg, #26e0b0, #4ad6ff);
    box-shadow: 0 0 10px rgba(74, 214, 255, .85);
    transition: width .25s ease;
}

#hud .btn-hud {
    display: inline-flex;
    align-items: center;
    padding: 4px 12px;
    font-size: 13px;
    line-height: 1.5;
    border-radius: 999px;
    background: rgba(255, 255, 255, .07);
    border: 1px solid rgba(120, 210, 255, .25);
    color: #bfe6ff;
    text-decoration: none;
    transition: all .18s ease;
    cursor: pointer;
}
#hud .btn-hud:hover,
#hud .btn-hud:focus {
    background: rgba(74, 214, 255, .2);
    border-color: rgba(74, 214, 255, .65);
    color: #ffffff;
    outline: none;
    text-decoration: none;
    box-shadow: 0 0 14px rgba(74, 214, 255, .35);
}
#hud .btn-hud .glyphicon { margin-right: 3px; }

/* 返回按钮高亮 */
#hud .btn-hud.back-btn {
    background: rgba(255, 180, 80, .12);
    border-color: rgba(255, 200, 100, .45);
    color: #ffd98a;
}
#hud .btn-hud.back-btn:hover,
#hud .btn-hud.back-btn:focus {
    background: rgba(255, 200, 100, .28);
    border-color: rgba(255, 220, 130, .9);
    box-shadow: 0 0 14px rgba(255, 200, 100, .5);
}

#stage {
    flex: 1 1 auto;
    position: relative;
    overflow: hidden;
    background: #04121f;
}
#gameCanvas { display: block; width: 100%; height: 100%; }

#banners {
    position: absolute;
    top: 12px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 10px;
    z-index: 15;
    pointer-events: none;
    flex-wrap: wrap;
    justify-content: center;
    max-width: 92%;
}
.status-banner {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 7px 16px;
    border-radius: 999px;
    background: rgba(4, 22, 38, .85);
    border: 1px solid rgba(74, 214, 255, .5);
    box-shadow: 0 6px 22px rgba(0, 0, 0, .5), 0 0 22px rgba(74, 214, 255, .25);
    color: #d6f0ff;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: .5px;
    animation: bannerIn .3s ease;
}
@keyframes bannerIn {
    from { transform: translateY(-10px); opacity: 0; }
    to   { transform: translateY(0); opacity: 1; }
}
.status-banner .banner-time {
    font-variant-numeric: tabular-nums;
    color: #4ad6ff;
    font-size: 13.5px;
}
.status-banner.freeze { border-color: rgba(140, 220, 255, .6); }
.status-banner.freeze .banner-time { color: #8ce0ff; }
.status-banner.boost  { border-color: rgba(255, 200, 90, .6); }
.status-banner.boost .banner-time { color: #ffc53d; }
.status-banner.shield { border-color: rgba(120, 255, 200, .6); }
.status-banner.shield .banner-time { color: #5ff0b6; }
.status-banner.wordlock {
    border-color: rgba(255, 220, 130, .85);
    background: rgba(40, 24, 4, .9);
    color: #ffe7a0;
    font-size: 14px;
    letter-spacing: 1px;
}
.status-banner.wordlock .word-progress {
    color: #7dffd1;
    font-weight: 800;
    font-size: 15px;
}

#powerbar {
    position: absolute;
    bottom: 14px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 10px;
    z-index: 12;
    padding: 8px 12px;
    border-radius: 16px;
    background: rgba(4, 20, 34, .78);
    border: 1px solid rgba(90, 200, 255, .25);
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
    box-shadow: 0 10px 32px rgba(0, 0, 0, .55);
}

.power-slot {
    position: relative;
    width: 68px;
    height: 68px;
    border-radius: 12px;
    background: rgba(255, 255, 255, .05);
    border: 1px solid rgba(120, 210, 255, .18);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    cursor: pointer;
    transition: all .2s ease;
    color: #a8d6f5;
    font-size: 11px;
}
.power-slot:hover {
    background: rgba(74, 214, 255, .16);
    border-color: rgba(74, 214, 255, .6);
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(74, 214, 255, .35);
}
.power-slot.empty { opacity: .4; cursor: not-allowed; filter: grayscale(1); }
.power-slot .power-icon { font-size: 20px; color: #4ad6ff; line-height: 1; }
.power-slot .power-name { font-size: 10px; color: #bfe6ff; white-space: nowrap; line-height: 1.2; }
.power-slot .power-count {
    position: absolute;
    top: -6px;
    right: -6px;
    min-width: 20px;
    height: 20px;
    padding: 0 5px;
    border-radius: 10px;
    background: linear-gradient(180deg, #ffd166, #ffb027);
    color: #06121e;
    font-size: 11px;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(255, 176, 39, .5);
    font-variant-numeric: tabular-nums;
}
.power-slot .power-key {
    position: absolute;
    bottom: 3px;
    right: 5px;
    font-size: 9px;
    color: #7fabc7;
    font-weight: 700;
    background: rgba(0, 0, 0, .3);
    padding: 0 4px;
    border-radius: 4px;
}

#fxCanvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1100;
}

.overlay {
    position: fixed;
    top: 0; right: 0; bottom: 0; left: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 18px;
    background: radial-gradient(ellipse at center, rgba(6, 32, 54, .82), rgba(1, 8, 15, .95));
    -webkit-backdrop-filter: blur(7px);
    backdrop-filter: blur(7px);
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: opacity .26s ease, visibility .26s ease;
}
.overlay.is-open { opacity: 1; visibility: visible; }

.panel-card {
    width: 100%;
    max-width: 600px;
    max-height: 88vh;
    overflow-y: auto;
    padding: 26px 28px 24px;
    border-radius: 18px;
    background: linear-gradient(180deg, #0f2f4c 0%, #0a1f34 55%, #071726 100%);
    border: 1px solid rgba(90, 200, 255, .28);
    box-shadow: 0 26px 70px rgba(0, 0, 0, .7), inset 0 1px 0 rgba(255, 255, 255, .07);
    color: #cfe9ff;
    text-align: center;
    transform: scale(.9) translateY(16px);
    opacity: 0;
    transition: transform .34s cubic-bezier(.18, .9, .32, 1.22), opacity .3s ease;
}
.overlay.is-open .panel-card { transform: scale(1) translateY(0); opacity: 1; }

.panel-card h1,panel-card h2 {
    margin: 0 0 8px;
    font-size: 26px;
    font-weight: 800;
    letter-spacing: 2px;
    color: #ffffff;
    text-shadow: 0 0 22px rgba(74, 214, 255, .55);
}
.panel-card h1 .glyphicon,.panel-card h2 .glyphicon { color: #4ad6ff; margin-right: 8px; }

.panel-card .lead-line {
    margin: 0 0 16px;
    font-size: 14px;
    color: #8fbcd9;
    line-height: 1.7;
}
.panel-card .divider {
    height: 1px;
    margin: 14px 0;
    background: linear-gradient(90deg, transparent, rgba(90, 200, 255, .35), transparent);
}

.choice-group { margin-bottom: 14px; text-align: left; }
.choice-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 700;
    color: #8fbcd9;
    letter-spacing: 1px;
    margin-bottom: 8px;
}
.choice-label .glyphicon { color: #4ad6ff; font-size: 12px; }

.choice-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.choice-btn {
    padding: 11px 6px;
    border-radius: 11px;
    background: rgba(255, 255, 255, .05);
    border: 1px solid rgba(120, 210, 255, .18);
    color: #a8d6f5;
    font-size: 13.5px;
    font-weight: 700;
    letter-spacing: .5px;
    cursor: pointer;
    transition: all .2s ease;
    text-align: center;
    line-height: 1.35;
}
.choice-btn small {
    display: block;
    font-size: 10.5px;
    font-weight: 400;
    color: #6f97b3;
    margin-top: 2px;
    letter-spacing: 0;
}
.choice-btn:hover {
    background: rgba(74, 214, 255, .14);
    border-color: rgba(74, 214, 255, .5);
    transform: translateY(-2px);
}
.choice-btn.active {
    background: linear-gradient(180deg, rgba(34, 167, 240, .35), rgba(18, 129, 196, .25));
    border-color: rgba(74, 214, 255, .85);
    color: #ffffff;
    box-shadow: 0 4px 18px rgba(74, 214, 255, .3), inset 0 1px 0 rgba(255, 255, 255, .15);
}
.choice-btn.active small { color: #a9dcff; }

.panel-card .btn {
    border-radius: 10px;
    font-weight: 600;
    letter-spacing: .5px;
    transition: all .2s ease;
}
.panel-card .btn-primary {
    background: linear-gradient(180deg, #22a7f0, #1281c4);
    border: 1px solid #37b6ff;
    box-shadow: 0 6px 22px rgba(34, 167, 240, .38);
}
.panel-card .btn-primary:hover,
.panel-card .btn-primary:focus {
    background: linear-gradient(180deg, #38b8ff, #1a92d8);
    box-shadow: 0 8px 28px rgba(56, 184, 255, .55);
}
.panel-card .btn-default {
    background: rgba(255, 255, 255, .07);
    border: 1px solid rgba(120, 210, 255, .3);
    color: #bfe6ff;
}
.panel-card .btn-default:hover,
.panel-card .btn-default:focus {
    background: rgba(74, 214, 255, .2);
    border-color: rgba(74, 214, 255, .7);
    color: #ffffff;
}

.panel-card .btn + .btn { margin-left: 8px; }
.btn-stack { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.btn-stack .btn { margin: 0 !important; }

.start-badges {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 16px;
}
.start-badges span {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 12px;
    border-radius: 999px;
    font-size: 12.5px;
    background: rgba(74, 214, 255, .1);
    border: 1px solid rgba(74, 214, 255, .28);
    color: #a9dcff;
}
.start-badges .glyphicon { color: #4ad6ff; }

.setting-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 12px 14px;
    margin-bottom: 10px;
    border-radius: 12px;
    background: rgba(255, 255, 255, .045);
    border: 1px solid rgba(120, 210, 255, .13);
    text-align: left;
    transition: background .2s, border-color .2s;
}
.setting-row:hover {
    background: rgba(74, 214, 255, .09);
    border-color: rgba(74, 214, 255, .3);
}
.setting-text { flex: 1 1 auto; min-width: 0; }
.setting-title {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 14.5px;
    font-weight: 700;
    color: #ffffff;
    margin-bottom: 3px;
}
.setting-title .glyphicon { color: #4ad6ff; font-size: 13px; }
.setting-desc { font-size: 12px; line-height: 1.6; color: #7fabc7; white-space: normal; }
.setting-switch {
    flex: 0 0 auto;
    width: 54px;
    height: 30px;
    border-radius: 999px;
    background: rgba(255, 255, 255, .14);
    border: 1px solid rgba(255, 255, 255, .18);
    position: relative;
    cursor: pointer;
    transition: background .22s, border-color .22s;
}
.setting-switch::after {
    content: "";
    position: absolute;
    top: 3px;
    left: 3px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #ffffff;
    box-shadow: 0 2px 7px rgba(0, 0, 0, .4);
    transition: transform .24s cubic-bezier(.3, .9, .4, 1.3);
}
.setting-switch.on {
    background: linear-gradient(90deg, #26e0b0, #4ad6ff);
    border-color: rgba(74, 214, 255, .8);
}
.setting-switch.on::after { transform: translateX(24px); }

.rule-list { text-align: left; margin: 0; padding: 0; list-style: none; }
.rule-list li {
    display: flex;
    gap: 11px;
    padding: 10px 12px;
    margin-bottom: 8px;
    border-radius: 11px;
    background: rgba(255, 255, 255, .04);
    border: 1px solid rgba(120, 210, 255, .12);
    font-size: 13.5px;
    line-height: 1.7;
    color: #b9d9ee;
}
.rule-list li .glyphicon { color: #4ad6ff; font-size: 14px; margin-top: 3px; flex: 0 0 auto; }
.rule-list li b { color: #ffffff; }

.result-head {
    margin-bottom: 6px;
    font-size: 34px;
    font-weight: 900;
    letter-spacing: 4px;
    text-align: center;
}
.result-head.win {
    color: #5ff0b6;
    text-shadow: 0 0 26px rgba(95, 240, 182, .75), 0 0 60px rgba(95, 240, 182, .35);
    animation: winGlow 1.6s ease-in-out infinite alternate;
}
.result-head.lose {
    color: #ff7a6e;
    text-shadow: 0 0 26px rgba(255, 122, 110, .7);
    animation: loseShake .55s ease 2;
}
@keyframes winGlow {
    from { transform: scale(1);    filter: brightness(1); }
    to   { transform: scale(1.06); filter: brightness(1.3); }
}
@keyframes loseShake {
    0%, 100% { transform: translateX(0); }
    20%      { transform: translateX(-8px) rotate(-1.5deg); }
    40%      { transform: translateX(7px)  rotate(1.5deg); }
    60%      { transform: translateX(-5px) rotate(-1deg); }
    80%      { transform: translateX(4px)  rotate(.6deg); }
}

.result-score {
    text-align: center;
    font-size: 44px;
    font-weight: 900;
    line-height: 1.15;
    color: #ffd98a;
    text-shadow: 0 0 26px rgba(255, 197, 61, .7);
    font-variant-numeric: tabular-nums;
    margin-bottom: 4px;
}
.result-score-label {
    text-align: center;
    font-size: 12.5px;
    letter-spacing: 3px;
    color: #7fabc7;
    margin-bottom: 18px;
}

.stat-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-bottom: 18px;
}
.stat-cell {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px 14px;
    border-radius: 12px;
    background: rgba(255, 255, 255, .05);
    border: 1px solid rgba(120, 210, 255, .15);
    text-align: left;
}
.stat-cell .glyphicon { font-size: 19px; flex: 0 0 auto; }
.stat-cell .stat-label { font-size: 11.5px; color: #7fabc7; line-height: 1.3; }
.stat-cell .stat-value {
    font-size: 17px;
    font-weight: 800;
    color: #ffffff;
    line-height: 1.25;
    font-variant-numeric: tabular-nums;
}
.stat-cell.c-wpm   .glyphicon { color: #26e0b0; }
.stat-cell.c-acc   .glyphicon { color: #4ad6ff; }
.stat-cell.c-combo .glyphicon { color: #ff8a3d; }
.stat-cell.c-fish  .glyphicon { color: #ffd166; }

.kbd-hint {
    display: inline-block;
    padding: 2px 8px;
    margin: 0 2px;
    border-radius: 6px;
    background: rgba(255, 255, 255, .12);
    border: 1px solid rgba(255, 255, 255, .22);
    border-bottom-width: 2px;
    font-family: Menlo, Consolas, monospace;
    font-size: 12px;
    color: #ffffff;
}
.hint-line {
    font-size: 12.5px;
    color: #7fabc7;
    margin-top: 14px;
    line-height: 1.9;
}

#toast {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(.86);
    padding: 13px 30px;
    border-radius: 12px;
    background: rgba(8, 34, 56, .96);
    border: 1px solid rgba(74, 214, 255, .45);
    box-shadow: 0 14px 44px rgba(0, 0, 0, .6), 0 0 30px rgba(74, 214, 255, .22);
    color: #d6f0ff;
    font-size: 15px;
    font-weight: 700;
    letter-spacing: .5px;
    z-index: 1200;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity .24s ease, transform .28s cubic-bezier(.2, .9, .3, 1.4), visibility .24s;
    white-space: nowrap;
    max-width: 90vw;
    text-align: center;
}
#toast.show {
    opacity: 1;
    visibility: visible;
    transform: translate(-50%, -50%) scale(1);
}
#toast .glyphicon { margin-right: 7px; color: #4ad6ff; }

@media (max-width: 992px) {
    #hud { padding: 6px 10px; gap: 8px; }
    .hud-item { font-size: 12px; padding: 3px 9px; }
    .hud-progress { width: 62px; }
    #hud .btn-hud { padding: 3px 9px; font-size: 12px; }
    .power-slot { width: 58px; height: 58px; }
    .power-slot .power-icon { font-size: 17px; }
    .power-slot .power-name { font-size: 9.5px; }
}
@media (max-width: 768px) {
    .hud-item span.label-txt { display: none; }
    .hud-item { padding: 4px 8px; }
    .hud-progress { display: none; }
    .hud-item.size { display: none; }
    .panel-card { padding: 20px 18px 18px; }
    .panel-card h2 { font-size: 21px; }
    .result-head { font-size: 26px; }
    .result-score { font-size: 34px; }
    .stat-grid { grid-template-columns: 1fr; }
    #hud .btn-hud .btn-txt { display: none; }
    #hud .btn-hud .glyphicon { margin-right: 0; }
    #powerbar { gap: 6px; padding: 6px 8px; bottom: 8px; }
    .power-slot { width: 52px; height: 52px; border-radius: 10px; }
    .power-slot .power-icon { font-size: 15px; }
    .power-slot .power-name { font-size: 9px; }
    .power-slot .power-count { min-width: 17px; height: 17px; font-size: 10px; }
    .status-banner { font-size: 11.5px; padding: 5px 12px; }
    .choice-row { grid-template-columns: repeat(3, 1fr); gap: 6px; }
    .choice-btn { padding: 9px 4px; font-size: 12px; }
    .choice-btn small { font-size: 9.5px; }
}
@media (max-width: 480px) {
    .hud-item.lvl { display: none; }
    .btn-stack { flex-direction: column; }
    .btn-stack .btn { width: 100%; }
    .power-slot { width: 46px; height: 46px; }
    .power-slot .power-icon { font-size: 13px; }
    .power-slot .power-name { display: none; }
}