body.dark {
    background: #121212;
    font-family: Inter, "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
}

body.dark::before,
body.dark::after {
    display: none;
}

body.dark header {
    background: #121212;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
}

body.dark main {
    max-width: none;
    margin: 0;
    padding: 0;
    animation: none;
}

.lg-page {
    --lg-card-bg: linear-gradient(180deg, #1e1e25 0%, #161619 100%);
    --lg-card-bd: rgba(255, 255, 255, 0.06);
    --lg-field-bg: #232329;
    --lg-accent: #8774e1;
    --lg-accent-active: #6a5bc7;
    --lg-x: #8b78ff;
    --lg-o: #ffd54f;
    --lg-good: #00e24b;
    --lg-bad: #ff1f44;
    --lg-ink: #fff;
    --lg-ink-dim: rgba(255, 255, 255, 0.5);
    --lg-ease: cubic-bezier(0.2, 0.8, 0.2, 1);

    min-height: calc(100vh - 60px);
    color: var(--lg-ink);
    overflow-x: hidden;
    animation: lg-rise .5s var(--lg-ease) both;
}

@keyframes lg-rise {
    from {
        opacity: 0;
        transform: translateY(12px);
    }

    to {
        opacity: 1;
        transform: none;
    }
}

.lg-top {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px 10px;
    max-width: 520px;
    width: 100%;
    margin: 0 auto;
    box-sizing: border-box;
}

.lg-title {
    font-size: 18px;
    font-weight: 800;
    letter-spacing: -.2px;
}

.lg-body {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
    max-width: 520px;
    margin: 0 auto;
    padding: 4px 16px 24px;
    box-sizing: border-box;
}

.lg-body.is-untitled {
    padding-top: 16px;
}

.lg-card {
    position: relative;
    border-radius: 24px;
    border: 1px solid var(--lg-card-bd);
    background: var(--lg-card-bg);
    padding: 16px;
}

.lg-score {
    display: flex;
    gap: 8px;
    margin-bottom: 14px;
}

.lg-stat {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 10px 12px;
    border-radius: 16px;
    background: var(--lg-field-bg);
    border: 1px solid var(--lg-card-bd);
}

.lg-stat span {
    font-size: 12px;
    color: var(--lg-ink-dim);
}

.lg-stat b {
    font-size: 22px;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    line-height: 1;
}

.lg-stat.is-win b {
    color: #4ade80;
}

.lg-stat.is-lose b {
    color: #ff5470;
}

.lg-flash {
    animation: lg-flash 450ms ease-out;
}

@keyframes lg-flash {
    0% {
        color: #8b78ff;
        transform: scale(1.25);
    }

    100% {
        transform: scale(1);
    }
}

.lg-pills {
    display: flex;
    align-items: center;
    gap: 6px;
    height: 28px;
    margin-bottom: 12px;
    overflow: hidden;
    -webkit-mask-image: linear-gradient(90deg, #000 78%, transparent);
    mask-image: linear-gradient(90deg, #000 78%, transparent);
}

.lg-pills-empty {
    font-size: 12px;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.25);
}

.lg-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: none;
    height: 24px;
    min-width: 40px;
    padding: 0 8px;
    box-sizing: border-box;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.06);
    color: rgba(255, 255, 255, 0.5);
    font-size: 13px;
    font-weight: 700;
}

.lg-pill.is-win {
    background: rgba(34, 197, 94, 0.15);
    color: #4ade80;
}

.lg-pill.is-lose {
    background: rgba(239, 45, 66, 0.15);
    color: #ff5470;
}

.lg-pill.is-new {
    animation: lg-pill-in 260ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

.lg-pill.is-pending {
    display: none;
}

@keyframes lg-pill-in {
    from {
        transform: scale(0.4);
        opacity: 0;
    }

    to {
        transform: scale(1);
        opacity: 1;
    }
}

.lg-hint {
    margin-top: 14px;
    text-align: center;
    font-size: 15px;
    font-weight: 700;
    min-height: 22px;
    color: var(--lg-ink-dim);
}

.lg-hint.is-win {
    color: #4ade80;
}

.lg-hint.is-lose {
    color: #ff5470;
}

.lg-hint.is-draw {
    color: var(--lg-o);
}

.lg-late {
    opacity: 0;
    transition: opacity .3s;
}

.lg-late.is-shown {
    opacity: 1;
}

.lg-btn {
    position: relative;
    overflow: hidden;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 52px;
    padding: 0 20px;
    border: none;
    border-radius: 18px;
    background: var(--lg-accent);
    color: #fff;
    font: inherit;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 6px 18px -8px rgba(135, 116, 225, 0.9);
    transition: transform 0.15s, background-color 0.15s, opacity 0.15s;
}

.lg-btn:active:not(:disabled) {
    transform: scale(0.975);
    background: var(--lg-accent-active);
}

.lg-btn:disabled {
    opacity: 0.4;
    cursor: default;
}

.lg-btn:not(:disabled)::after {
    content: '';
    position: absolute;
    inset: 0;
    pointer-events: none;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    animation: lg-sheen 3s linear infinite;
}

@keyframes lg-sheen {
    0% {
        transform: translate(-200%) skew(-45deg);
    }

    100% {
        transform: translate(200%) skew(-45deg);
    }
}

.lg-btn.secondary {
    background: #2a2a33;
    box-shadow: none;
}

.lg-btn.secondary::after {
    display: none;
}

.lg-btn span {
    position: relative;
}

.lg-form {
    margin: 0;
}

.lg-players {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 14px;
}

.lg-player {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 44px;
    border-radius: 14px;
    background: var(--lg-field-bg);
    border: 1px solid var(--lg-card-bd);
    font-size: 14px;
    font-weight: 700;
    color: var(--lg-ink-dim);
    transition: border-color .25s, color .25s, box-shadow .25s, background-color .25s;
}

.lg-player i {
    font-style: normal;
    font-size: 18px;
    font-weight: 800;
}

.lg-player.x i {
    color: var(--lg-x);
}

.lg-player.o i {
    color: var(--lg-o);
}

.lg-player.is-active {
    color: #fff;
    border-color: rgba(139, 120, 255, 0.6);
    box-shadow: 0 0 18px rgba(139, 120, 255, 0.25);
}

.lg-player.is-winner {
    color: #fff;
    border-color: var(--lg-good);
    background: rgba(0, 226, 75, 0.1);
    box-shadow: 0 0 18px rgba(0, 226, 75, 0.25);
}

.lg-player.is-loser {
    opacity: .5;
}

.lg-board {
    position: relative;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    max-width: 360px;
    margin: 0 auto;
}

.lg-board form {
    display: contents;
}

.lg-cell {
    position: relative;
    aspect-ratio: 1;
    padding: 18%;
    display: grid;
    place-items: center;
    cursor: pointer;
    font: inherit;
    border-radius: 20px;
    border: 1px solid var(--lg-card-bd);
    background: var(--lg-field-bg);
    transition: background-color .2s, transform .2s var(--lg-ease), border-color .2s, box-shadow .25s;
}

.lg-cell:not(:disabled):hover {
    background: #2b2b35;
    border-color: rgba(139, 120, 255, 0.45);
    transform: translateY(-2px);
}

.lg-cell:not(:disabled):active {
    transform: scale(.95);
}

.lg-cell:disabled {
    cursor: default;
}

.lg-cell.empty:not(:disabled):hover::after {
    content: '';
    position: absolute;
    inset: 28%;
    opacity: .22;
    pointer-events: none;
    background:
        linear-gradient(45deg, transparent 46%, var(--lg-x) 46% 54%, transparent 54%),
        linear-gradient(-45deg, transparent 46%, var(--lg-x) 46% 54%, transparent 54%);
}

.lg-cell svg {
    width: 100%;
    height: 100%;
    overflow: visible;
}

.lg-cell .mark {
    fill: none;
    stroke-width: 10;
    stroke-linecap: round;
    stroke-dasharray: 100;
    stroke-dashoffset: 0;
}

.lg-cell.x .mark {
    stroke: var(--lg-x);
    filter: drop-shadow(0 0 7px rgba(139, 120, 255, .75));
}

.lg-cell.o .mark {
    stroke: var(--lg-o);
    filter: drop-shadow(0 0 7px rgba(255, 213, 79, .65));
}

.lg-cell.fresh .mark {
    animation: lg-draw .45s ease-out both;
}

.lg-cell.fresh.late .mark {
    animation-delay: .45s;
}

.lg-cell.fresh.late svg {
    animation: lg-appear 0s .45s backwards;
}

.lg-cell.x.fresh .mark:nth-child(2) {
    animation-delay: .2s;
}

.lg-cell.x.fresh.late .mark:nth-child(2) {
    animation-delay: .65s;
}

.lg-cell.win {
    background: rgba(0, 226, 75, 0.1);
    border-color: rgba(0, 226, 75, .55);
}

.lg-cell.dim {
    opacity: .45;
    transition: opacity .4s .9s;
}

@keyframes lg-draw {
    from {
        stroke-dashoffset: 100;
    }

    to {
        stroke-dashoffset: 0;
    }
}

@keyframes lg-appear {
    from {
        opacity: 0;
    }

    to {
        opacity: 0;
    }
}

.lg-strike {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    overflow: visible;
}

.lg-strike:not(.is-on) line {
    display: none;
}

.lg-strike line {
    stroke-width: 7;
    stroke-linecap: round;
    fill: none;
    stroke: var(--lg-good);
    filter: drop-shadow(0 0 8px rgba(0, 226, 75, .9));
}

.lg-strike.is-lose line {
    stroke: var(--lg-bad);
    filter: drop-shadow(0 0 8px rgba(255, 31, 68, .9));
}

.lg-arena {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 10px;
    margin: 6px 0 4px;
}

.lg-fighter {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 18px 8px 14px;
    border-radius: 22px;
    background: var(--lg-field-bg);
    border: 1px solid var(--lg-card-bd);
    transition: border-color .3s, box-shadow .3s, opacity .3s, background-color .3s;
}

.lg-fighter .ico {
    font-size: 58px;
    line-height: 1;
    height: 64px;
    display: grid;
    place-items: center;
}

.lg-fighter small {
    font-size: 12px;
    font-weight: 700;
    color: var(--lg-ink-dim);
    letter-spacing: .3px;
    text-align: center;
}

.lg-fighter .ico.idle {
    opacity: .25;
}

.lg-fighter.is-winner {
    border-color: var(--lg-good);
    background: rgba(0, 226, 75, 0.08);
    box-shadow: 0 0 24px rgba(0, 226, 75, .25);
}

.lg-fighter.is-loser {
    opacity: .5;
    border-color: rgba(255, 31, 68, .35);
}

.lg-fighter.is-draw {
    border-color: rgba(255, 213, 79, .5);
}

.lg-vs {
    font-size: 13px;
    font-weight: 800;
    color: rgba(255, 255, 255, .3);
}

.lg-shake {
    animation: lg-shake .38s ease-in-out 2;
}

.lg-fighter.them .lg-shake {
    animation-direction: reverse;
}

@keyframes lg-shake {

    0%,
    100% {
        transform: translateY(0) rotate(0);
    }

    50% {
        transform: translateY(-14px) rotate(-8deg);
    }
}

.lg-reveal {
    animation: lg-pop .45s var(--lg-ease);
}

@keyframes lg-pop {
    0% {
        transform: scale(.4);
        opacity: 0;
    }

    60% {
        transform: scale(1.18);
        opacity: 1;
    }

    100% {
        transform: scale(1);
    }
}

.lg-fighter .ico .glyph {
    display: inline-block;
}

.lg-fighter.them .ico .glyph {
    transform: scaleX(-1);
}

.lg-choices {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

.lg-choice {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 16px 0 12px;
    border-radius: 20px;
    cursor: pointer;
    background: var(--lg-field-bg);
    border: 1px solid var(--lg-card-bd);
    color: #fff;
    font: inherit;
    transition: transform .2s var(--lg-ease), background-color .2s, border-color .2s, box-shadow .25s;
}

.lg-choice .ico {
    font-size: 38px;
    line-height: 1;
}

.lg-choice span {
    font-size: 13px;
    font-weight: 700;
    color: var(--lg-ink-dim);
}

.lg-choice:not(:disabled):hover {
    transform: translateY(-3px);
    background: #2b2b35;
    border-color: rgba(139, 120, 255, .6);
    box-shadow: 0 10px 24px -10px rgba(135, 116, 225, .6);
}

.lg-choice:not(:disabled):active {
    transform: scale(.94);
}

.lg-choice:disabled {
    opacity: .45;
    cursor: default;
}

.lg-toast {
    position: fixed;
    top: 70px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10000;
    padding: 9px 16px;
    border-radius: 12px;
    color: #fff;
    font-size: 13px;
    font-weight: 700;
    white-space: nowrap;
    background: #2a2a33;
    animation: lg-toast-in 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.lg-toast[hidden] {
    display: none;
}

.lg-toast.is-win {
    background: rgba(22, 163, 74, 0.95);
    box-shadow: 0 8px 28px rgba(22, 163, 74, 0.35);
}

.lg-toast.is-error {
    background: rgba(239, 45, 66, 0.95);
    box-shadow: 0 8px 28px rgba(239, 45, 66, 0.35);
}

.lg-toast.is-neutral {
    background: rgba(60, 60, 72, 0.97);
}

@keyframes lg-toast-in {
    from {
        opacity: 0;
        transform: translate(-50%, -12px);
    }

    to {
        opacity: 1;
        transform: translate(-50%, 0);
    }
}

@media (max-width: 420px) {
    .lg-fighter .ico {
        font-size: 46px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .lg-btn::after {
        animation: none;
    }
}