:root {
    color-scheme: light;
    --fight-bg: #fbfaf4;
    --fight-ink: #20212b;
    --fight-muted: #6b6470;
    --fight-panel: rgba(255, 255, 255, 0.8);
    --fight-line: rgba(45, 46, 58, 0.12);
    --fight-rose: #ec4f8f;
    --fight-cyan: #0ba7c4;
    --fight-gold: #f2b84b;
    --fight-green: #269662;
    --fight-indigo: #4e5fd2;
    --game-header-side-bg: #eef4ef;
    --game-header-center-bg: #fff;
    --game-header-accent: var(--fight-rose);
}

* {
    box-sizing: border-box;
}

html,
body {
    min-height: 100%;
    margin: 0;
    touch-action: manipulation;
}

body {
    color: var(--fight-ink);
    font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", sans-serif;
    letter-spacing: 0;
    -webkit-text-size-adjust: 100%;
    background:
        linear-gradient(
            to right,
            #eef4ef 0,
            #eef4ef calc((100% - 450px) / 2),
            var(--fight-bg) calc((100% - 450px) / 2),
            var(--fight-bg) calc((100% + 450px) / 2),
            #eef4ef calc((100% + 450px) / 2),
            #eef4ef 100%
        );
}

button,
a {
    touch-action: manipulation;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
}

.fight-shell {
    display: grid;
    place-items: start center;
    min-height: 100vh;
    padding: 6px 10px max(14px, env(safe-area-inset-bottom));
}

.fight-stage {
    width: min(100%, clamp(300px, calc(100svh - 118px), 450px));
    touch-action: manipulation;
    user-select: none;
    -webkit-user-select: none;
}

.fight-hud > div,
.fight-touch-controls button {
    border: 1px solid rgba(255, 255, 255, 0.72);
    border-radius: 8px;
    background: var(--fight-panel);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.82),
        0 12px 26px rgba(43, 55, 75, 0.1);
    backdrop-filter: blur(14px) saturate(1.08);
    -webkit-backdrop-filter: blur(14px) saturate(1.08);
}

.fight-touch-controls button {
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    padding: 0;
    cursor: pointer;
}

.fight-board-wrap {
    position: relative;
    overflow: hidden;
    padding: 0;
    border-radius: 8px;
    background: transparent;
    box-shadow:
        inset 0 0 0 1px rgba(255, 255, 255, 0.42),
        0 18px 36px rgba(46, 88, 83, 0.16);
}

.fight-canvas {
    display: block;
    width: 100%;
    aspect-ratio: 16 / 9;
    border-radius: 8px;
    background: #75d2e0;
    box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.42);
    touch-action: none;
}

.fight-hud {
    position: absolute;
    top: 14px;
    right: 14px;
    left: 14px;
    z-index: 3;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 58px minmax(0, 1fr);
    align-items: stretch;
    gap: 6px;
    pointer-events: none;
}

.fight-hud > div {
    position: relative;
    overflow: hidden;
    min-width: 0;
    border: 0;
    color: #fff;
    background:
        radial-gradient(circle at 16% 0%, rgba(255, 255, 255, 0.42), transparent 34%),
        linear-gradient(145deg, rgba(255, 255, 255, 0.28), rgba(255, 255, 255, 0.1) 46%, rgba(11, 167, 196, 0.12)),
        linear-gradient(135deg, rgba(70, 82, 98, 0.42), rgba(30, 42, 58, 0.28));
    backdrop-filter: blur(18px) saturate(1.22);
    -webkit-backdrop-filter: blur(18px) saturate(1.22);
}

.fighter-status {
    display: grid;
    gap: 6px;
    min-height: 44px;
    padding: 6px;
    border: 0;
    border-radius: 8px;
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.26),
        inset 0 -18px 32px rgba(17, 24, 36, 0.18),
        0 10px 22px rgba(25, 32, 46, 0.16);
}

.fighter-status::before {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background:
        linear-gradient(90deg, rgba(236, 79, 143, 0.34), transparent 42%),
        linear-gradient(180deg, rgba(255, 255, 255, 0.28), transparent 48%);
    pointer-events: none;
}

.fighter-status--enemy::before {
    background:
        linear-gradient(270deg, rgba(23, 169, 196, 0.34), transparent 42%),
        linear-gradient(180deg, rgba(255, 255, 255, 0.28), transparent 48%);
}

.fighter-status-head {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    min-width: 0;
}

.fighter-status-head strong {
    overflow: hidden;
    min-width: 0;
    font-size: 12px;
    line-height: 1;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
}

.fighter-side {
    flex: 0 0 auto;
    min-width: 28px;
    padding: 3px 5px;
    border-radius: 4px;
    color: #171d2a;
    font-size: 10px;
    font-weight: 900;
    line-height: 1;
    text-align: center;
    background: var(--fight-gold);
}

.hp-track {
    position: relative;
    overflow: hidden;
    height: 8px;
    border: 0;
    border-radius: 999px;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.03)),
        rgba(10, 17, 27, 0.48);
    box-shadow:
        inset 0 1px 4px rgba(0, 0, 0, 0.28),
        0 1px 0 rgba(255, 255, 255, 0.08);
}

.hp-fill {
    position: absolute;
    inset: 0;
    width: 100%;
    border-radius: inherit;
    transform-origin: left center;
    transition: transform 520ms cubic-bezier(0.2, 0.72, 0.18, 1);
}

.hp-fill--player {
    background: linear-gradient(90deg, #42d99b, var(--fight-gold) 68%, var(--fight-rose));
}

.hp-fill--enemy {
    background: linear-gradient(90deg, var(--fight-cyan), var(--fight-indigo) 68%, var(--fight-rose));
}

.fight-timer {
    display: grid;
    place-items: center;
    width: 58px;
    height: 100%;
    min-height: 0;
    padding: 6px 4px;
    border: 0;
    border-radius: 50%;
    background:
        radial-gradient(circle at 50% 22%, rgba(255, 255, 255, 0.36), transparent 37%),
        linear-gradient(145deg, rgba(255, 255, 255, 0.22), rgba(255, 255, 255, 0.08) 48%),
        linear-gradient(145deg, rgba(31, 39, 54, 0.5), rgba(60, 75, 104, 0.36));
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.24),
        inset 0 -18px 28px rgba(11, 17, 28, 0.2),
        inset 0 0 0 2px rgba(242, 184, 75, 0.24),
        0 10px 20px rgba(20, 25, 34, 0.22);
}

.fight-timer strong {
    min-width: 0;
    color: #f8f1db;
    font-size: 23px;
    line-height: 1;
    white-space: nowrap;
    text-shadow: 0 2px 0 rgba(0, 0, 0, 0.44);
}

.fight-battle-cue {
    position: absolute;
    top: 50%;
    left: 50%;
    z-index: 6;
    width: min(82%, 360px);
    transform: translate(-50%, -50%) rotate(-4deg);
    color: #fff;
    font-size: 46px;
    font-weight: 1000;
    line-height: 1;
    text-align: center;
    text-shadow:
        0 3px 0 #111827,
        0 0 18px rgba(236, 79, 143, 0.88),
        0 0 36px rgba(23, 169, 196, 0.55);
    letter-spacing: 0;
    pointer-events: none;
}

.fight-battle-cue::before,
.fight-battle-cue::after {
    content: "";
    position: absolute;
    top: 50%;
    width: 34%;
    height: 6px;
    border-radius: 999px;
    background: linear-gradient(90deg, transparent, #f0c24a, transparent);
}

.fight-battle-cue::before {
    left: -16px;
    transform: translateY(-50%);
}

.fight-battle-cue::after {
    right: -16px;
    transform: translateY(-50%);
}

.fight-battle-cue[hidden] {
    display: none;
}

.fight-overlay {
    position: absolute;
    inset: 0;
    z-index: 5;
    display: grid;
    align-items: end;
    justify-items: center;
    border-radius: 8px;
    padding: 0 10px 12px;
    background: linear-gradient(180deg, rgba(28, 35, 50, 0.08), rgba(28, 35, 50, 0.22));
    pointer-events: none;
}

.fight-overlay[hidden] {
    display: none;
}

.fight-overlay-panel {
    display: grid;
    justify-items: center;
    width: min(86%, 320px);
    gap: 14px;
    padding: 20px;
    border: 1px solid rgba(255, 255, 255, 0.74);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.88);
    box-shadow: 0 18px 42px rgba(32, 47, 72, 0.18);
    pointer-events: auto;
}

.fight-overlay-panel strong {
    font-size: 22px;
    line-height: 1.2;
}

.fight-overlay-panel button {
    min-width: 112px;
    min-height: 42px;
    border: 0;
    border-radius: 8px;
    color: #fff;
    font-weight: 900;
    background: linear-gradient(135deg, var(--fight-rose), var(--fight-indigo));
    box-shadow: 0 10px 20px rgba(76, 95, 215, 0.22);
    cursor: pointer;
}

.result-panel {
    position: relative;
    grid-template-columns: minmax(0, 1fr) 40px;
    grid-template-areas:
        "title title"
        "stats retry";
    align-items: stretch;
    width: min(100%, 410px);
    max-height: none;
    gap: 7px 6px;
    padding: 0;
    border: 0;
    background: transparent;
    box-shadow: none;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    text-shadow:
        0 1px 0 rgba(255, 255, 255, 0.72),
        0 3px 12px rgba(12, 24, 40, 0.28);
}

.result-panel > strong {
    grid-area: title;
    color: #211f25;
    font-size: 24px;
    font-weight: 900;
    line-height: 1.1;
    text-align: center;
    letter-spacing: 0;
    text-shadow:
        -2px -2px 0 #fff,
        0 -2px 0 #fff,
        2px -2px 0 #fff,
        -2px 0 0 #fff,
        2px 0 0 #fff,
        -2px 2px 0 #fff,
        0 2px 0 #fff,
        2px 2px 0 #fff,
        0 5px 14px rgba(18, 34, 50, 0.24);
}

.result-stats {
    grid-area: stats;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    width: 100%;
    gap: 6px;
    margin: 0;
}

.result-stats > div {
    min-width: 0;
    padding: 6px 7px;
    border: 0;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.88);
    box-shadow:
        0 5px 14px rgba(18, 38, 56, 0.14);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.result-stats dt {
    margin: 0 0 1px;
    color: rgba(34, 32, 38, 0.78);
    font-size: 8px;
    font-weight: 900;
    line-height: 1.1;
    white-space: nowrap;
    text-shadow:
        -1px -1px 0 #fff,
        1px -1px 0 #fff,
        -1px 1px 0 #fff,
        1px 1px 0 #fff;
}

.result-stats dd {
    display: inline-flex;
    align-items: baseline;
    gap: 1px;
    margin: 0;
    color: var(--fight-ink);
    font-size: 15px;
    font-weight: 900;
    line-height: 1.15;
    white-space: nowrap;
    text-shadow:
        -1.5px -1.5px 0 #fff,
        0 -1.5px 0 #fff,
        1.5px -1.5px 0 #fff,
        -1.5px 0 0 #fff,
        1.5px 0 0 #fff,
        -1.5px 1.5px 0 #fff,
        0 1.5px 0 #fff,
        1.5px 1.5px 0 #fff;
}

.result-unit {
    display: inline-block;
    font-size: 0.5em;
    line-height: 1;
    vertical-align: baseline;
}

#retryButton {
    position: static;
    grid-area: retry;
    display: grid;
    place-items: center;
    align-self: stretch;
    justify-self: stretch;
    width: 40px;
    min-width: 40px;
    height: auto;
    min-height: 0;
    margin-top: 0;
    padding: 0;
    border: 0;
    border-radius: 8px;
    color: #fff;
    font-size: 0;
    background:
        radial-gradient(circle at 34% 22%, rgba(255, 255, 255, 0.42), transparent 34%),
        linear-gradient(145deg, #ff6aa3 0%, var(--fight-rose) 52%, #b93f85 100%);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.42),
        inset 0 -4px 0 rgba(111, 30, 77, 0.2),
        0 8px 16px rgba(236, 79, 143, 0.24);
}

#retryButton .material-icons {
    font-size: 23px;
    line-height: 1;
}

.fight-touch-controls {
    display: flex;
    align-items: end;
    justify-content: flex-end;
    width: fit-content;
    margin-left: auto;
    margin-top: 8px;
}

.fight-direction-controls {
    position: relative;
    display: grid;
    grid-template-columns: repeat(3, 40px);
    grid-template-rows: repeat(2, 40px);
    gap: 2px;
    padding: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
}

.fight-direction-controls::before,
.fight-direction-controls::after {
    display: none;
}

.fight-direction-controls::before {
    right: 7px;
    bottom: 7px;
    left: 7px;
    height: 40px;
    border-radius: 13px;
}

.fight-direction-controls::after {
    top: 7px;
    bottom: 7px;
    left: 49px;
    width: 40px;
    border-radius: 13px;
}

#jumpButton {
    grid-column: 2;
    grid-row: 1;
    justify-self: center;
}

#backstepButton {
    grid-column: 1;
    grid-row: 1;
}

#leftButton {
    grid-column: 1;
    grid-row: 2;
}

#punchButton {
    grid-column: 2;
    grid-row: 2;
}

#rightButton {
    grid-column: 3;
    grid-row: 2;
}

#specialButton {
    grid-column: 3;
    grid-row: 1;
}

.fight-touch-controls button {
    position: relative;
    z-index: 1;
    overflow: hidden;
    width: 40px;
    height: 40px;
    border-color: rgba(255, 255, 255, 0.28);
    border-radius: 12px;
    color: #fff;
    background:
        radial-gradient(circle at 34% 22%, rgba(255, 255, 255, 0.34), transparent 29%),
        linear-gradient(145deg, #53647d 0%, #34465f 56%, #1f2d45 100%);
    box-shadow:
        inset 0 2px 0 rgba(255, 255, 255, 0.34),
        inset 0 -4px 0 rgba(13, 22, 38, 0.34),
        0 4px 7px rgba(16, 26, 43, 0.18);
    transform: translateY(0) scale(1);
    transition:
        transform 80ms ease,
        box-shadow 80ms ease,
        filter 120ms ease;
}

.fight-touch-controls button::after {
    content: "";
    position: absolute;
    inset: 5px;
    border-radius: inherit;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.56) 0 14%, transparent 56%);
    opacity: 0;
    transform: scale(0.5);
    transition:
        opacity 150ms ease,
        transform 180ms ease;
    pointer-events: none;
}

.fight-touch-controls button:active,
.fight-touch-controls button.is-pressed {
    filter: brightness(1.08) saturate(1.08);
    transform: translateY(4px) scale(0.95);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.22),
        inset 0 -1px 0 rgba(13, 22, 38, 0.4),
        0 1px 2px rgba(16, 26, 43, 0.12);
}

.fight-touch-controls button:active::after,
.fight-touch-controls button.is-pressed::after {
    opacity: 0.82;
    transform: scale(1.35);
}

#punchButton {
    border-radius: 50%;
    background:
        radial-gradient(circle at 36% 23%, rgba(255, 255, 255, 0.46), transparent 30%),
        linear-gradient(145deg, #fff5f8 0%, #e7b7ca 42%, #7a5f7c 100%);
    color: #253248;
    box-shadow:
        inset 0 2px 0 rgba(255, 255, 255, 0.58),
        inset 0 -4px 0 rgba(31, 42, 60, 0.24),
        0 3px 7px rgba(15, 24, 39, 0.22);
}

#punchButton:active,
#punchButton.is-pressed {
    transform: translateY(4px) scale(0.9);
}

#specialButton {
    --special-rate: 0deg;
    width: 40px;
    height: 40px;
    border: 3px solid transparent;
    border-radius: 12px;
    color: #fff;
    background:
        radial-gradient(circle at 36% 23%, rgba(255, 255, 255, 0.5), transparent 30%) padding-box,
        linear-gradient(145deg, #fff4f8 0%, #e9a9c3 44%, #996a8a 100%) padding-box,
        conic-gradient(from -90deg, var(--fight-rose) 0deg, var(--fight-gold) var(--special-rate), transparent var(--special-rate), transparent 360deg) border-box;
    box-shadow:
        inset 0 2px 0 rgba(255, 255, 255, 0.5),
        inset 0 -4px 0 rgba(93, 37, 72, 0.24),
        0 4px 8px rgba(80, 42, 64, 0.18);
}

#specialButton::before {
    content: none;
}

#specialButton:active,
#specialButton.is-pressed {
    transform: translateY(4px) scale(0.95);
}

#specialButton:disabled {
    opacity: 0.78;
    filter: saturate(0.92);
}

#specialButton.is-ready {
    filter: brightness(1.08) saturate(1.16);
    box-shadow:
        inset 0 2px 0 rgba(255, 255, 255, 0.56),
        inset 0 -4px 0 rgba(93, 37, 72, 0.24),
        0 0 16px rgba(236, 79, 143, 0.32),
        0 5px 9px rgba(80, 42, 64, 0.16);
}

#backstepButton.is-ready {
    background:
        radial-gradient(circle at 34% 22%, rgba(255, 255, 255, 0.38), transparent 29%),
        linear-gradient(145deg, #5f78a6 0%, #3b5687 54%, #203457 100%);
}

.fight-touch-controls button:disabled {
    opacity: 0.46;
    filter: grayscale(0.35);
    transform: none;
}

.fight-touch-controls .material-icons {
    align-self: center;
    position: relative;
    z-index: 2;
    font-size: 24px;
    text-shadow: 0 2px 0 rgba(15, 22, 36, 0.22);
}

#punchButton .material-icons {
    font-size: 22px;
    text-shadow: 0 1px 0 rgba(255, 255, 255, 0.28);
}

.fight-button-label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

.fight-special-panel {
    display: none;
    width: min(58%, 260px);
    gap: 4px;
    margin-top: 8px;
    margin-left: auto;
    padding: 6px 8px 7px;
    border: 1px solid rgba(242, 184, 75, 0.46);
    border-radius: 8px;
    background:
        linear-gradient(135deg, rgba(255, 249, 232, 0.86), rgba(255, 255, 255, 0.56)),
        rgba(32, 33, 43, 0.08);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.82),
        0 8px 18px rgba(64, 55, 37, 0.08);
}

.fight-special-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    color: #253044;
    font-size: 10px;
    font-weight: 1000;
    line-height: 1;
}

.fight-special-head strong {
    color: var(--fight-rose);
    font-size: 11px;
}

.fight-special-track {
    position: relative;
    overflow: hidden;
    height: 8px;
    border-radius: 999px;
    background: rgba(23, 29, 42, 0.16);
    box-shadow: inset 0 1px 4px rgba(23, 29, 42, 0.18);
}

.fight-special-track span {
    position: absolute;
    inset: 0;
    width: 0%;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--fight-cyan), var(--fight-gold), var(--fight-rose));
    box-shadow: 0 0 14px rgba(236, 79, 143, 0.42);
    transition: width 160ms ease;
}

@media (max-width: 520px) {
    .fight-shell {
        padding-right: 8px;
        padding-left: 8px;
    }

    .fight-hud {
        top: 12px;
        right: 12px;
        left: 12px;
        grid-template-columns: minmax(0, 1fr) 54px minmax(0, 1fr);
        gap: 5px;
    }

    .fighter-status {
        min-height: 42px;
        padding: 6px;
    }

    .fighter-status-head strong {
        font-size: 11px;
    }

    .fighter-side {
        min-width: 24px;
        padding: 3px 4px;
        font-size: 9px;
    }

    .hp-track {
        height: 7px;
    }

    .fight-timer {
        width: 54px;
        height: 100%;
        min-height: 0;
    }

    .fight-timer strong {
        font-size: 20px;
    }

    .fight-battle-cue {
        font-size: 38px;
    }

    .result-panel {
        width: 100%;
    }

    .fight-touch-controls {
        margin-top: 8px;
    }

    .fight-direction-controls {
        grid-template-columns: repeat(3, 40px);
        grid-template-rows: repeat(2, 40px);
        gap: 2px;
        padding: 6px;
        border-radius: 17px;
    }

    .fight-direction-controls::before {
        right: 6px;
        bottom: 6px;
        left: 6px;
        height: 40px;
        border-radius: 12px;
    }

    .fight-direction-controls::after {
        top: 6px;
        bottom: 6px;
        left: 48px;
        width: 40px;
        border-radius: 12px;
    }

    .fight-touch-controls button {
        width: 40px;
        height: 40px;
    }

    #specialButton {
        width: 40px;
        height: 40px;
    }

    .fight-touch-controls .material-icons {
        font-size: 22px;
    }
}
