*, *::before, *::after { box-sizing: border-box; }
html, body {
    height: 100%; margin: 0; padding: 0;
    background: radial-gradient(circle at 50% -10%, #123a5e 0%, #081a2e 55%, #040c18 100%);
    color: #e8eef7;
    font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
    overflow: hidden;
    -webkit-tap-highlight-color: transparent;
}
body { -webkit-font-smoothing: antialiased; }
.app { display: flex; flex-direction: column; height: 100vh; height: 100dvh; width: 100vw; }

.gbar {
    flex: 0 0 auto;
    display: flex; align-items: center; gap: 6px;
    height: 52px; padding: 0 10px;
    background: linear-gradient(180deg, rgba(18,38,64,.98), rgba(10,22,40,.98));
    border-bottom: 1px solid rgba(90,160,230,.18);
    box-shadow: 0 2px 14px rgba(0,0,0,.45);
    position: relative; z-index: 30;
    white-space: nowrap;
}
.gb-back {
    flex: 0 0 auto;
    display: inline-flex; align-items: center; justify-content: center;
    width: 32px; height: 32px; border-radius: 9px;
    color: #8fc0f0; text-decoration: none;
    background: rgba(255,255,255,.06);
    transition: background .18s, color .18s, transform .18s;
}
.gb-back:hover, .gb-back:focus { background: rgba(90,180,255,.24); color: #fff; transform: translateX(-2px); text-decoration: none; }
.gb-title {
    flex: 0 0 auto;
    font-size: 15px; font-weight: 800; letter-spacing: .5px;
    margin: 0 6px 0 2px; color: #fff; line-height: 1;
    text-shadow: 0 2px 10px rgba(90,200,255,.45);
}
.gb-title small { display: block; font-size: 10px; font-weight: 500; color: #6fa0d0; letter-spacing: 0; margin-top: 3px; }

.gb-stats { flex: 1 1 auto; display: flex; align-items: center; gap: 4px; overflow: hidden; }
.stat {
    display: inline-flex; align-items: center; gap: 4px;
    height: 26px; padding: 0 9px; border-radius: 13px;
    background: rgba(255,255,255,.055);
    border: 1px solid rgba(120,180,240,.12);
    font-size: 12px; color: #9db8d6; line-height: 1;
    transition: background .2s, border-color .2s;
}
.stat b { color: #fff; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat .glyphicon { font-size: 11px; color: #6fa8e8; }
.stat.hot { border-color: rgba(255,190,80,.55); background: rgba(255,190,80,.14); }
.stat.hot .glyphicon, .stat.hot b { color: #ffd166; }
.stat.good .glyphicon, .stat.good b { color: #5fe0a0; }
.stat.hearts { gap: 1px; padding: 0 8px; }
.stat.hearts .glyphicon { font-size: 12px; transition: transform .2s, color .2s; }
.stat.hearts .glyphicon.on { color: #ff4d6d; text-shadow: 0 0 8px rgba(255,77,109,.75); }
.stat.hearts .glyphicon.off { color: #2c4058; }
.stat.hearts.pulse .glyphicon.on { animation: heartBeat .5s ease; }
@keyframes heartBeat { 0%,100% { transform: scale(1); } 40% { transform: scale(1.5); } }

.gb-tools { flex: 0 0 auto; display: flex; align-items: center; gap: 4px; }
.gbtn {
    display: inline-flex; align-items: center; justify-content: center;
    width: 32px; height: 32px; padding: 0;
    border: 1px solid rgba(120,180,240,.16);
    border-radius: 9px;
    background: rgba(255,255,255,.055);
    color: #8fc0f0; font-size: 13px; cursor: pointer;
    transition: all .16s ease;
    outline: none !important;
}
.gbtn:hover { background: rgba(90,180,255,.26); color: #fff; transform: translateY(-1px); }
.gbtn:active { transform: translateY(0) scale(.94); }
.gbtn.off { color: #3d5470; }
.gbtn.off .glyphicon { opacity: .55; }

.gprog { flex: 0 0 auto; height: 3px; background: rgba(255,255,255,.07); position: relative; overflow: hidden; }
.gprog > i {
    display: block; height: 100%; width: 0%;
    background: linear-gradient(90deg, #47d7a0, #7de6c2 55%, #ffd166);
    box-shadow: 0 0 12px rgba(90,230,170,.85);
    transition: width .35s cubic-bezier(.22,1,.36,1);
    border-radius: 0 3px 3px 0;
}

.gwrap {
    flex: 1 1 auto; min-height: 0;
    display: flex; align-items: center; justify-content: center;
    position: relative; padding: 8px;
}
#cv {
    display: block; border-radius: 14px;
    box-shadow: 0 22px 60px rgba(0,0,0,.7), 0 0 0 1px rgba(90,160,230,.15);
    background: #0a2540;
    touch-action: none;
}

.ovl {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    display: none;
    background: rgba(4,12,24,.82);
    -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
    border-radius: 14px;
    z-index: 20;
    padding: 12px;
    overflow: auto;
    animation: ovlIn .26s ease both;
}
.ovl.show { display: flex; }
@keyframes ovlIn { from { opacity: 0; } to { opacity: 1; } }

.panel {
    margin: auto;
    width: min(560px, 100%);
    padding: 22px 24px;
    border-radius: 18px;
    background: linear-gradient(180deg, #142a48 0%, #0c1c33 100%);
    border: 1px solid rgba(110,170,240,.22);
    box-shadow: 0 26px 70px rgba(0,0,0,.72), inset 0 1px 0 rgba(255,255,255,.07);
    text-align: center;
    animation: panelIn .34s cubic-bezier(.2,1.3,.4,1) both;
}
@keyframes panelIn { from { opacity: 0; transform: translateY(18px) scale(.94); } to { opacity: 1; transform: none; } }
.panel.shake { animation: panelShake .55s cubic-bezier(.36,.07,.19,.97) both; }
@keyframes panelShake {
    10%,90% { transform: translateX(-2px); } 20%,80% { transform: translateX(4px); }
    30%,50%,70% { transform: translateX(-8px); } 40%,60% { transform: translateX(8px); }
}

.panel h2 {
    margin: 0 0 6px; font-size: 25px; font-weight: 900; color: #fff; letter-spacing: 1px;
    display: flex; align-items: center; justify-content: center; gap: 9px;
}
.panel .sub { font-size: 13px; color: #8fb0d4; margin-bottom: 16px; line-height: 1.7; }
.panel .sub kbd {
    background: rgba(255,255,255,.12); color: #7de6c2; border-radius: 5px;
    padding: 1px 6px; font-size: 11px; font-family: Menlo, Consolas, monospace; box-shadow: none;
}

.start-config {
    display: flex; flex-direction: column; gap: 10px;
    margin: 4px 0 16px;
    padding: 12px 14px;
    border-radius: 12px;
    background: rgba(255,255,255,.035);
    border: 1px solid rgba(110,170,240,.14);
}
.start-config .opt-group { margin-bottom: 0; }
.start-config .opt-group > .lbl { margin-bottom: 6px; }
.start-config .opt { flex: 1 1 0; min-width: 70px; padding: 7px 10px; font-size: 12.5px; }

.end-title.win { color: #ffd166; text-shadow: 0 0 26px rgba(255,209,102,.75); animation: winGlow 1.6s ease-in-out infinite; }
@keyframes winGlow { 0%,100% { text-shadow: 0 0 20px rgba(255,209,102,.55); } 50% { text-shadow: 0 0 40px rgba(255,209,102,1), 0 0 60px rgba(255,160,60,.6); } }
.end-title.lose { color: #ff7d7d; text-shadow: 0 0 26px rgba(255,80,80,.55); animation: losePulse 1.4s ease-in-out infinite; }
@keyframes losePulse { 0%,100% { opacity: .82; transform: scale(1); } 50% { opacity: 1; transform: scale(1.04); } }

.end-score {
    font-size: 46px; font-weight: 900; line-height: 1.1; color: #fff;
    font-variant-numeric: tabular-nums;
    text-shadow: 0 4px 26px rgba(120,200,255,.55);
    margin: 4px 0 2px;
}
.end-score small { font-size: 14px; font-weight: 600; color: #8fb0d4; margin-left: 6px; }

.metric-grid {
    display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px;
    margin: 16px 0 18px;
}
.metric {
    padding: 9px 6px; border-radius: 11px;
    background: rgba(255,255,255,.055);
    border: 1px solid rgba(120,180,240,.14);
    display: flex; flex-direction: column; align-items: center; gap: 3px;
}
.metric .glyphicon { font-size: 15px; color: #6fa8e8; }
.metric .v { font-size: 17px; font-weight: 800; color: #fff; font-variant-numeric: tabular-nums; line-height: 1; }
.metric .k { font-size: 11px; color: #7f9dbe; }

.end-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.btn-nz {
    display: inline-flex; align-items: center; justify-content: center; gap: 7px;
    min-width: 132px; height: 42px; padding: 0 20px;
    border: none; border-radius: 11px; cursor: pointer;
    font-size: 14px; font-weight: 700; letter-spacing: .5px;
    transition: transform .16s, box-shadow .16s, filter .16s;
    outline: none !important;
}
.btn-nz:active { transform: scale(.96); }
.btn-gold {
    background: linear-gradient(180deg, #ffd76e, #f5a623);
    color: #3a2600;
    box-shadow: 0 6px 22px rgba(245,166,35,.45);
}
.btn-gold:hover { filter: brightness(1.08); box-shadow: 0 9px 30px rgba(245,166,35,.62); transform: translateY(-2px); }
.btn-ghost {
    background: rgba(255,255,255,.09);
    color: #c3d8f0;
    border: 1px solid rgba(140,190,245,.22);
}
.btn-ghost:hover { background: rgba(255,255,255,.17); color: #fff; transform: translateY(-2px); }

.hint-row { margin-top: 14px; font-size: 12px; color: #7f9dbe; }
.hint-row kbd {
    background: rgba(255,255,255,.13); color: #7de6c2; border-radius: 5px;
    padding: 1px 6px; font-family: Menlo, Consolas, monospace; box-shadow: none;
}

#toastWrap {
    position: fixed; left: 50%; top: 50%;
    transform: translate(-50%, -50%);
    z-index: 2100; pointer-events: none;
    display: flex; flex-direction: column; align-items: center; gap: 8px;
}
.gtoast {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 10px 20px; border-radius: 11px;
    background: rgba(14,26,44,.96);
    border: 1px solid rgba(120,180,240,.3);
    color: #e2eeff; font-size: 13px; font-weight: 600;
    box-shadow: 0 12px 40px rgba(0,0,0,.6);
    animation: toastIn .28s cubic-bezier(.2,1.4,.4,1) both;
    white-space: nowrap;
}
.gtoast .glyphicon { font-size: 14px; }
.gtoast.good { border-color: rgba(90,230,160,.5); }
.gtoast.good .glyphicon { color: #5fe0a0; }
.gtoast.bad { border-color: rgba(255,110,110,.5); }
.gtoast.bad .glyphicon { color: #ff7d7d; }
.gtoast.info .glyphicon { color: #6fa8e8; }
.gtoast.out { animation: toastOut .4s ease forwards; }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px) scale(.92); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to { opacity: 0; transform: translateY(-14px) scale(.95); } }

#confetti {
    position: fixed; inset: 0; width: 100%; height: 100%;
    pointer-events: none; z-index: 2200; display: none;
}

.modal { text-align: center; padding: 0 !important; }
.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: .68; }

.nz-modal {
    width: min(620px, 94vw);
    border-radius: 16px; overflow: hidden;
    background: linear-gradient(180deg, #142a48 0%, #0c1c33 100%);
    border: 1px solid rgba(110,170,240,.22);
    box-shadow: 0 30px 80px rgba(0,0,0,.78);
}
.nz-modal .modal-header {
    padding: 15px 20px; border-bottom: 1px solid rgba(120,180,240,.16);
    background: rgba(255,255,255,.03);
}
.nz-modal .modal-title { font-size: 16px; font-weight: 800; color: #fff; display: flex; align-items: center; gap: 8px; }
.nz-modal .modal-title .glyphicon { color: #ffd166; }
.nz-modal .close { color: #8fc0f0; opacity: .8; text-shadow: none; font-size: 22px; margin-top: -2px; }
.nz-modal .close:hover { opacity: 1; color: #fff; }
.nz-modal .modal-body { padding: 16px 20px; max-height: 66vh; overflow-y: auto; }
.nz-modal .modal-footer { padding: 12px 20px; border-top: 1px solid rgba(120,180,240,.16); background: rgba(0,0,0,.16); }

.opt-group { margin-bottom: 15px; }
.opt-group > .lbl {
    display: flex; align-items: center; gap: 6px;
    font-size: 12px; font-weight: 700; color: #8fb0d4;
    margin-bottom: 8px; letter-spacing: .5px;
}
.opt-group > .lbl .glyphicon { color: #6fa8e8; }
.opt-row { display: flex; flex-wrap: wrap; gap: 7px; }
.opt {
    flex: 1 1 auto; min-width: 92px;
    padding: 8px 12px; border-radius: 10px; cursor: pointer;
    background: rgba(255,255,255,.055);
    border: 1px solid rgba(120,180,240,.16);
    color: #b6cde6; font-size: 13px; font-weight: 600;
    text-align: center; line-height: 1.35;
    transition: all .16s ease; outline: none !important;
    font-family: inherit;
}
.opt small { display: block; font-size: 10px; font-weight: 500; color: #6d8bab; margin-top: 2px; }
.opt:hover { background: rgba(90,180,255,.18); color: #fff; transform: translateY(-1px); }
.opt.active {
    background: linear-gradient(180deg, rgba(255,215,110,.26), rgba(245,166,35,.16));
    border-color: rgba(255,200,80,.72);
    color: #ffe9b0;
    box-shadow: 0 0 0 1px rgba(255,200,80,.25), 0 4px 18px rgba(245,166,35,.22);
}
.opt.active small { color: #d9b262; }
.opt:disabled { opacity: .38; cursor: not-allowed; }

.rule-block { font-size: 13px; line-height: 1.85; color: #b6cde6; }
.rule-block h4 {
    font-size: 13px; font-weight: 800; color: #7de6c2;
    margin: 16px 0 7px; display: flex; align-items: center; gap: 7px;
}
.rule-block h4:first-child { margin-top: 0; }
.rule-block h4 .glyphicon { font-size: 12px; }
.rule-block p { margin: 0 0 6px; }
.rule-block .kw { color: #7de6c2; font-weight: 700; }
.rule-block .kw2 { color: #ffb3c8; font-weight: 700; }
.up-list { display: grid; grid-template-columns: repeat(2, 1fr); gap: 7px; margin-top: 8px; }
.up-item {
    display: flex; gap: 8px; align-items: flex-start;
    padding: 8px 10px; border-radius: 9px;
    background: rgba(255,255,255,.045);
    border-left: 3px solid var(--c, #ffd166);
}
.up-item .ic { font-size: 16px; color: var(--c, #ffd166); line-height: 1.35; }
.up-item .tx { font-size: 12px; line-height: 1.5; color: #a9c2dc; }
.up-item .tx b { display: block; color: #fff; font-size: 12.5px; margin-bottom: 1px; }

@media (max-width: 1000px) { .stat.opt-acc { display: none; } }
@media (max-width: 860px)  { .stat.opt-wpm { display: none; } }
@media (max-width: 720px)  {
    .stat.opt-combo { display: none; }
    .gb-title small { display: none; }
    .gb-title { font-size: 13px; }
    .gbar { height: 46px; gap: 4px; padding: 0 6px; }
    .gbtn { width: 29px; height: 29px; font-size: 12px; }
    .stat { height: 24px; padding: 0 7px; font-size: 11px; }
    .up-list { grid-template-columns: 1fr; }
    .metric-grid { grid-template-columns: repeat(2, 1fr); }
    .end-score { font-size: 36px; }
    .start-config .opt { min-width: 56px; padding: 6px 8px; font-size: 12px; }
}
@media (max-width: 560px) {
    .gb-tools .opt-hide-sm { display: none; }
    .panel { padding: 16px; }
    .panel h2 { font-size: 20px; }
}
@media (max-height: 480px) {
    .gbar { height: 42px; }
    .gb-title small { display: none; }
}