/* 打字游戏 */

.game-root--typing { gap: 8px; }

.ty-hud {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 13px;
    padding: 4px 6px 8px;
    font-size: 10px;
    letter-spacing: .08em;
    color: #6f9a7d;
    border-bottom: 1px solid rgba(141, 240, 161, .14);
}

.ty-hud b { font-size: 13px; color: #c8f5d0; }
.ty-hud__lives {
    margin-left: auto;
    font-size: 14px;
    letter-spacing: .12em;
    color: #e2554a;
    text-shadow: 0 0 10px rgba(226, 85, 74, .5);
}
.ty-hud__lives .is-lost { color: #3f2b26; text-shadow: none; }

.ty-field {
    display: flex;
    flex-direction: column;
    border: 1px solid #2c4633;
    border-radius: 4px;
    background: #050d08;
    overflow: hidden;
}

.ty-stage {
    position: relative;
    height: clamp(300px, 38vh, 380px);
    overflow: hidden;
    background:
        radial-gradient(120% 90% at 50% 0%, rgba(35, 71, 47, .34), transparent 62%),
        repeating-linear-gradient(to bottom, rgba(141, 240, 161, .045) 0 1px, transparent 1px 32px),
        repeating-linear-gradient(to right, rgba(141, 240, 161, .03) 0 1px, transparent 1px 48px),
        #040b06;
    border-bottom: 1px solid rgba(141, 240, 161, .12);
}

.ty-stage::after {
    content: "";
    position: absolute;
    left: 6%;
    right: 6%;
    bottom: 10px;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(226, 85, 74, .55), transparent);
}

.ty-scan {
    position: absolute;
    inset: 0;
    pointer-events: none;
    background: linear-gradient(180deg, transparent 70%, rgba(2, 6, 4, .55));
}

.ty-word {
    position: absolute;
    top: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1px;
    transform: translateY(0);
    will-change: transform;
    user-select: none;
}

.ty-word .en {
    font-family: var(--font-pixel);
    font-size: 17px;
    font-weight: 700;
    letter-spacing: .1em;
    color: #c8f5d0;
    text-shadow: 0 0 12px rgba(141, 240, 161, .2);
}

.ty-word .en i {
    font-style: normal;
    color: var(--gold);
    text-shadow: 0 0 12px rgba(233, 185, 73, .5);
}

.ty-word .zh {
    font-family: var(--font-ui);
    font-size: 9px;
    letter-spacing: .08em;
    color: #5f8a6d;
}

.ty-word.is-locked .en { color: #f6dd9c; }
.ty-word.is-locked .zh { color: #9b8154; }

.ty-word.is-danger .en { color: #ff8a78; text-shadow: 0 0 14px rgba(226, 85, 74, .6); }

.ty-word.is-boom {
    animation: ty-boom .32s ease forwards;
    pointer-events: none;
}

@keyframes ty-boom {
    0% { transform: translateY(var(--ty-y)) scale(1); opacity: 1; filter: brightness(1); }
    40% { transform: translateY(var(--ty-y)) scale(1.25); opacity: 1; filter: brightness(2.4); }
    100% { transform: translateY(var(--ty-y)) scale(.5); opacity: 0; }
}

.ty-line {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 8px 12px;
    background: rgba(9, 20, 13, .92);
}

.ty-prompt {
    font-family: var(--font-pixel);
    font-size: 16px;
    color: var(--phosphor-dim);
}

.ty-input {
    flex: 1;
    min-width: 0;
    padding: 5px 2px;
    font-family: var(--font-pixel);
    font-size: 17px;
    letter-spacing: .14em;
    color: #e8ffe9;
    background: transparent;
    border: 0;
    outline: none;
    caret-color: var(--phosphor);
}

.ty-input::placeholder {
    font-family: var(--font-ui);
    font-size: 11px;
    letter-spacing: .04em;
    color: #43614b;
}

.ty-input.is-error { color: #ff8a78; animation: ty-shake .22s; }

@keyframes ty-shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-3px); }
    75% { transform: translateX(3px); }
}

.ty-clear {
    flex: 0 0 auto;
    font-size: 8px;
    letter-spacing: .1em;
    color: #4d6b55;
}

.ty-keyboard {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 8px 4px 2px;
    align-items: center;
}

.ty-krow { display: flex; gap: 4px; justify-content: center; }

.ty-key {
    display: grid;
    place-items: center;
    width: clamp(24px, 3vw, 32px);
    height: clamp(22px, 2.8vw, 28px);
    font-family: var(--font-pixel);
    font-size: 9px;
    color: #6f9a7d;
    background: linear-gradient(180deg, #17261b, #0d1811);
    border: 1px solid #2c4633;
    border-bottom-width: 2px;
    border-radius: 3px;
    transition: .06s ease;
}

.ty-key.is-down {
    color: #241706;
    background: linear-gradient(180deg, #f4d68c, #dda62f);
    border-color: #ffe8b2;
    transform: translateY(1px);
    box-shadow: 0 0 16px rgba(233, 185, 73, .35);
}

.ty-key.is-next {
    color: #e8ffe9;
    border-color: var(--phosphor);
    box-shadow: 0 0 0 1px rgba(141, 240, 161, .35), 0 0 14px rgba(141, 240, 161, .25);
}

.ty-overlay {
    position: absolute;
    inset: 0;
    z-index: 20;
    display: grid;
    place-items: center;
    padding: 16px;
    background: radial-gradient(circle at 50% 45%, rgba(4, 12, 7, .72), rgba(2, 6, 4, .94));
    transition: opacity .22s ease, visibility .22s;
}

.ty-overlay.is-off {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.ty-overlay__box {
    width: min(380px, 100%);
    padding: 20px;
    text-align: center;
    background: linear-gradient(180deg, rgba(15, 29, 20, .97), rgba(5, 11, 7, .98));
    border: 2px solid #375c42;
    border-radius: 8px;
    box-shadow: 0 0 0 4px rgba(141, 240, 161, .05), 0 20px 44px rgba(0, 0, 0, .7);
}

.ty-overlay__kicker {
    margin: 0 0 4px;
    font-size: 8px;
    letter-spacing: .26em;
    color: #57806a;
}

.ty-overlay h2 {
    margin: 0 0 8px;
    font-family: var(--font-hei);
    font-size: 23px;
    letter-spacing: .14em;
    color: var(--gold);
}

.ty-overlay p {
    margin: 0 0 15px;
    font-size: 10.5px;
    line-height: 1.8;
    color: #9db8a5;
}

.ty-overlay__tip {
    margin: 12px 0 0 !important;
    font-size: 8.5px !important;
    color: #5c7a65 !important;
}

.ty-stage.is-shake { animation: ty-stage-shake .3s ease; }

@keyframes ty-stage-shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-4px); }
    50% { transform: translateX(3px); }
    75% { transform: translateX(-2px); }
}

.ty-levelup {
    position: absolute;
    top: 26%;
    left: 50%;
    z-index: 15;
    transform: translateX(-50%);
    padding: 5px 14px;
    font-family: var(--font-pixel);
    font-size: 19px;
    letter-spacing: .18em;
    color: var(--gold);
    text-shadow: 0 0 18px rgba(233, 185, 73, .6);
    border: 1px solid rgba(233, 185, 73, .5);
    border-radius: 4px;
    background: rgba(12, 24, 15, .85);
    pointer-events: none;
    animation: ty-levelup 1.1s ease forwards;
}

@keyframes ty-levelup {
    0% { opacity: 0; transform: translate(-50%, 10px) scale(.86); }
    20% { opacity: 1; transform: translate(-50%, 0) scale(1.06); }
    70% { opacity: 1; transform: translate(-50%, 0) scale(1); }
    100% { opacity: 0; transform: translate(-50%, -18px) scale(1); }
}

@media (max-width: 560px) {
    .ty-hud { gap: 8px; font-size: 9px; }
    .ty-hud b { font-size: 11px; }
    .ty-stage { height: clamp(260px, 34vh, 320px); }
    .ty-key { width: 20px; height: 20px; font-size: 7px; }
    .ty-clear { display: none; }
    .ty-input { font-size: 14px; }
}
