/* ?? Theme tokens ?????????????????????????????????? */

:root {
    --bg-body: #0c0c12;
    --bg-theme-tint: transparent;
    --bg-surface: #14141e;
    --bg-elevated: #1c1c2a;
    --bg-hover: #25253a;
    --bg-accent-surface: color-mix(in srgb, var(--accent) 92%, white);
    --text-primary: #ededf0;
    --text-secondary: #8e8ea0;
    --text-muted: #55556a;
    --border-color: #232338;
    --accent: #7c3aed;
    --accent-hover: #6d28d9;
    --accent-subtle: rgba(124, 58, 237, 0.15);
    --accent-secondary: #a855f7;
    --accent-glow: rgba(124, 58, 237, 0.30);
    --btn-gradient-start: #7c3aed;
    --btn-gradient-end: #6d28d9;
    --success: #22c55e;
    --success-subtle: rgba(34, 197, 94, 0.15);
    --error: #ef4444;
    --error-subtle: rgba(239, 68, 68, 0.15);
    --topbar-height: 3.5rem;
}

/* ?? Base ?????????????????????????????????????????? */

html, body {
    font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
                 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol',
                 'Noto Color Emoji', sans-serif;
    background:
        linear-gradient(var(--bg-theme-tint), var(--bg-theme-tint)),
        var(--bg-body);
    color: var(--text-primary);
    color-scheme: dark;
    forced-color-adjust: none;
    overflow-x: hidden;
}

html:has(.japanese-page) {
    scrollbar-gutter: stable;
}

*,
*::before,
*::after {
    forced-color-adjust: none;
}

button:active:not(:disabled),
a[class*="btn"]:active {
    transform: scaleY(0.88) scaleX(1.06);
    transition-duration: 0.06s;
}

.area-pill-scroller {
    width: 100%;
    display: flex;
    justify-content: center;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    padding: 0.1rem 0 0.18rem;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.area-pill-scroller::-webkit-scrollbar {
    display: none;
}

.area-pill-row {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.42rem;
    flex-wrap: nowrap;
    width: max-content;
    max-width: 100%;
    padding: 0.34rem;
    border: 1px solid color-mix(in srgb, var(--border-color) 94%, rgba(255, 255, 255, 0.08));
    border-radius: 999px;
    background: color-mix(in srgb, var(--bg-surface) 94%, transparent);
    box-shadow: 0 14px 30px rgba(0, 0, 0, 0.18);
    overscroll-behavior-x: contain;
}

.area-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 2.05rem;
    padding: 0.42rem 0.92rem;
    border: 1px solid transparent;
    border-radius: 999px;
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.75rem;
    font-weight: 700;
    white-space: nowrap;
    cursor: pointer;
    transition: border-color 0.18s ease, background 0.18s ease, color 0.18s ease, transform 0.18s ease, box-shadow 0.18s ease;
}

.area-pill:hover {
    border-color: rgba(255, 255, 255, 0.12);
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
    transform: translateY(-1px);
}

.area-pill.selected {
    border-color: color-mix(in srgb, var(--accent) 48%, transparent);
    background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 30%, transparent), color-mix(in srgb, var(--accent-secondary) 18%, transparent));
    color: #fff;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08), 0 8px 18px color-mix(in srgb, var(--accent) 20%, transparent);
}

.area-pill:focus-visible {
    outline: none;
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 58%, transparent);
}

@media (max-width: 640px) {
    .area-pill-scroller {
        justify-content: center;
        padding: 0 0 0.06rem;
    }

    .area-pill-row {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        flex-wrap: nowrap;
        width: max-content;
        max-width: 100%;
        gap: 0.24rem;
        padding: 0.22rem;
        border: 1px solid color-mix(in srgb, var(--border-color) 94%, rgba(255, 255, 255, 0.08));
        border-radius: 999px;
        background: color-mix(in srgb, var(--bg-surface) 94%, transparent);
        box-shadow: 0 8px 18px rgba(0, 0, 0, 0.14);
        overflow-x: auto;
        overflow-y: hidden;
        scrollbar-width: none;
        -ms-overflow-style: none;
    }

    .area-pill-row::-webkit-scrollbar {
        display: none;
    }

    .area-pill {
        flex: 0 0 auto;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: auto;
        min-height: 1.68rem;
        padding: 0.28rem 0.56rem;
        border-radius: 999px;
        font-size: 0.62rem;
        white-space: nowrap;
    }

    .area-pill-row:not(:has(.area-pill:nth-child(6))) {
        justify-content: stretch;
        width: 100%;
        overflow-x: visible;
    }

    .area-pill-row:not(:has(.area-pill:nth-child(6))) .area-pill {
        flex: 1 1 0;
        min-width: 0;
        min-height: 2.06rem;
        padding: 0.3rem 0.18rem;
        font-size: clamp(0.52rem, 1.7vw, 0.62rem);
        line-height: 1.05;
        text-align: center;
        white-space: normal;
        overflow-wrap: anywhere;
        text-wrap: balance;
    }
}

/* Shared unit accordion motion used by the Japanese roadmap and Custom Training. */
.unit-chapters {
    --unit-chapters-pad-x: 1rem;
    --unit-chapters-pad-bottom: 1rem;
    display: block;
    padding: 0 var(--unit-chapters-pad-x) var(--unit-chapters-pad-bottom);
    overflow: hidden;
    transform-origin: top;
    animation: unit-expand-in 320ms cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.unit-chapters-clip {
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
    overflow: hidden;
}

.unit-chapters.closing {
    pointer-events: none;
    animation: unit-collapse-out 320ms cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.unit-chapters-clip > .unit-chapter {
    opacity: 0;
    animation: unit-chapter-in 320ms cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.unit-chapters.closing .unit-chapters-clip > .unit-chapter {
    opacity: 1;
    animation: unit-chapter-out 240ms cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.unit-chapters-clip > .unit-chapter:nth-child(1) { animation-delay: 40ms; }
.unit-chapters-clip > .unit-chapter:nth-child(2) { animation-delay: 80ms; }
.unit-chapters-clip > .unit-chapter:nth-child(3) { animation-delay: 115ms; }
.unit-chapters-clip > .unit-chapter:nth-child(4) { animation-delay: 145ms; }
.unit-chapters-clip > .unit-chapter:nth-child(5) { animation-delay: 170ms; }
.unit-chapters-clip > .unit-chapter:nth-child(6) { animation-delay: 192ms; }
.unit-chapters-clip > .unit-chapter:nth-child(7) { animation-delay: 210ms; }

.unit-chapters.closing .unit-chapters-clip > .unit-chapter:nth-child(1) { animation-delay: 0ms; }
.unit-chapters.closing .unit-chapters-clip > .unit-chapter:nth-child(2) { animation-delay: 20ms; }
.unit-chapters.closing .unit-chapters-clip > .unit-chapter:nth-child(3) { animation-delay: 35ms; }
.unit-chapters.closing .unit-chapters-clip > .unit-chapter:nth-child(4) { animation-delay: 48ms; }
.unit-chapters.closing .unit-chapters-clip > .unit-chapter:nth-child(5) { animation-delay: 58ms; }
.unit-chapters.closing .unit-chapters-clip > .unit-chapter:nth-child(6) { animation-delay: 66ms; }
.unit-chapters.closing .unit-chapters-clip > .unit-chapter:nth-child(7) { animation-delay: 72ms; }

@keyframes unit-expand-in {
    0% {
        opacity: 0;
        transform: translateY(14px) scaleY(0.9) scaleX(1.03);
    }

    55% {
        opacity: 1;
        transform: translateY(-3px) scaleY(1.03) scaleX(0.99);
    }

    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes unit-collapse-out {
    0% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }

    45% {
        opacity: 1;
        transform: translateY(-3px) scaleY(1.03) scaleX(0.99);
    }

    100% {
        opacity: 0;
        transform: translateY(14px) scaleY(0.9) scaleX(1.03);
    }
}

@keyframes unit-chapter-in {
    0% {
        opacity: 0;
        transform: translateY(10px) scaleY(0.92) scaleX(1.025);
    }

    55% {
        opacity: 1;
        transform: translateY(-2px) scaleY(1.02) scaleX(0.995);
    }

    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes unit-chapter-out {
    0% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }

    45% {
        opacity: 1;
        transform: translateY(-2px) scaleY(1.02) scaleX(0.995);
    }

    100% {
        opacity: 0;
        transform: translateY(10px) scaleY(0.92) scaleX(1.025);
    }
}

@media (max-width: 720px) {
    .unit-chapters {
        --unit-chapters-pad-x: 0.62rem;
        --unit-chapters-pad-bottom: 0.62rem;
    }

    .unit-chapters-clip {
        gap: 0.38rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    .unit-chapters,
    .unit-chapters-clip > .unit-chapter {
        animation: none;
        opacity: 1;
        transform: none;
        filter: none;
    }

    .unit-chapters {
        padding-bottom: var(--unit-chapters-pad-bottom);
    }
}

a, .btn-link {
    color: var(--accent);
}

.btn-primary {
    color: #fff;
    background: linear-gradient(135deg, var(--btn-gradient-start), var(--btn-gradient-end));
    border-color: var(--accent-hover);
}

.btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus {
    box-shadow: 0 0 0 0.1rem var(--bg-body), 0 0 0 0.25rem var(--accent);
}

h1:focus {
    outline: none;
}

.valid.modified:not([type=checkbox]) {
    outline: 1px solid var(--success);
}

.invalid {
    outline: 1px solid var(--error);
}

.validation-message {
    color: var(--error);
}

.blazor-error-boundary {
    background: url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTYiIGhlaWdodD0iNDkiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIG92ZXJmbG93PSJoaWRkZW4iPjxkZWZzPjxjbGlwUGF0aCBpZD0iY2xpcDAiPjxyZWN0IHg9IjIzNSIgeT0iNTEiIHdpZHRoPSI1NiIgaGVpZ2h0PSI0OSIvPjwvY2xpcFBhdGg+PC9kZWZzPjxnIGNsaXAtcGF0aD0idXJsKCNjbGlwMCkiIHRyYW5zZm9ybT0idHJhbnNsYXRlKC0yMzUgLTUxKSI+PHBhdGggZD0iTTI2My41MDYgNTFDMjY0LjcxNyA1MSAyNjUuODEzIDUxLjQ4MzcgMjY2LjYwNiA1Mi4yNjU4TDI2Ny4wNTIgNTIuNzk4NyAyNjcuNTM5IDUzLjYyODMgMjkwLj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1oiIGZpbGw9IiNGRkU1MDAiIGZpbGwtcnVsZT0iZXZlbm9kZCIvPjwvZz48L3N2Zz4=) no-repeat 1rem/1.8rem, #b32121;
    padding: 1rem 1rem 1rem 3.7rem;
    color: white;
}

    .blazor-error-boundary::after {
        content: "An error has occurred."
    }

.darker-border-checkbox.form-check-input {
    border-color: #929292;
}

.form-floating > .form-control-plaintext::placeholder, .form-floating > .form-control::placeholder {
    color: var(--bs-secondary-color);
    text-align: end;
}

.form-floating > .form-control-plaintext:focus::placeholder, .form-floating > .form-control:focus::placeholder {
    text-align: start;
}

/* ?? Anime Theme ??????????????????????????????????????? */

.theme-anime h1,
.theme-anime h2,
.theme-anime h3,
.theme-anime h4 {
    font-family: var(--theme-font, inherit) !important;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.theme-anime button,
.theme-anime .sb-label,
.theme-anime .badge,
.theme-anime .price-tag,
.theme-anime .fc-name,
.theme-anime .ic-name {
    font-family: var(--theme-font, inherit) !important;
    letter-spacing: 0.03em;
}

/* Speed-line accent behind page content */
.theme-anime body::before {
    content: '';
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    background:
        repeating-conic-gradient(
            from 0deg at 100% 0%,
            rgba(255, 59, 59, 0.03) 0deg 3deg,
            transparent 3deg 12deg
        );
    mask-image: radial-gradient(ellipse 70% 60% at 95% 5%, black 0%, transparent 100%);
    -webkit-mask-image: radial-gradient(ellipse 70% 60% at 95% 5%, black 0%, transparent 100%);
}

/* Decorative star sparkle - top-left */
.theme-anime body::after {
    content: '';
    position: fixed;
    top: 4.5rem;
    left: 1.5rem;
    width: 28px;
    height: 28px;
    pointer-events: none;
    z-index: 1;
    opacity: 0.45;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23FFD93D'%3E%3Cpath d='M12 0l3.09 8.26L24 9.27l-6.91 5.52L19.18 24 12 18.9 4.82 24l2.09-9.21L0 9.27l8.91-1.01z'/%3E%3C/svg%3E") center/contain no-repeat;
    animation: anime-sparkle 3s ease-in-out infinite;
}

/* Manga-style exclamation marks on sidebar */
.theme-anime .shop-nav-shell::before {
    content: '!!';
    position: absolute;
    top: -0.2rem;
    right: 0.6rem;
    font-family: var(--theme-font, inherit);
    font-size: 1.6rem;
    color: var(--accent-secondary);
    opacity: 0.35;
    transform: rotate(8deg);
    pointer-events: none;
}

/* Action/impact starburst behind featured cards */
.theme-anime .featured-card::before {
    content: '';
    position: absolute;
    inset: -12px;
    pointer-events: none;
    z-index: -1;
    border-radius: inherit;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Cpolygon points='50,0 61,35 98,35 68,57 79,91 50,70 21,91 32,57 2,35 39,35' fill='none' stroke='%23FFD93D' stroke-width='0.5' opacity='0.15'/%3E%3C/svg%3E") center/90% no-repeat;
    opacity: 0;
    transition: opacity 0.3s ease;
}
.theme-anime .featured-card:hover::before {
    opacity: 1;
}

/* Action lines radiating from the currency bar */
.theme-anime .currency-bar::after {
    content: '';
    position: absolute;
    top: 50%;
    right: -10px;
    width: 80px;
    height: 80px;
    pointer-events: none;
    transform: translateY(-50%);
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 80 80'%3E%3Cline x1='40' y1='40' x2='80' y2='10' stroke='%23FF3B3B' stroke-width='1' opacity='0.18'/%3E%3Cline x1='40' y1='40' x2='80' y2='25' stroke='%23FFD93D' stroke-width='1' opacity='0.14'/%3E%3Cline x1='40' y1='40' x2='80' y2='40' stroke='%23FF3B3B' stroke-width='1' opacity='0.18'/%3E%3Cline x1='40' y1='40' x2='80' y2='55' stroke='%23FFD93D' stroke-width='1' opacity='0.14'/%3E%3Cline x1='40' y1='40' x2='80' y2='70' stroke='%23FF3B3B' stroke-width='1' opacity='0.18'/%3E%3C/svg%3E") center/contain no-repeat;
    opacity: 0.7;
}

/* Small sparkle on item cards */
.theme-anime .item-card::after {
    content: '?';
    position: absolute;
    top: 6px;
    right: 8px;
    font-size: 0.7rem;
    color: var(--accent-secondary);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease, transform 0.25s ease;
    transform: scale(0.5) rotate(-15deg);
}
.theme-anime .item-card:hover::after {
    opacity: 0.55;
    transform: scale(1) rotate(0deg);
}

@keyframes anime-sparkle {
    0%, 100% { opacity: 0.45; transform: scale(1) rotate(0deg); }
    30% { opacity: 0.6; transform: scaleX(1.2) scaleY(0.9) rotate(8deg); }
    50% { opacity: 0.75; transform: scaleX(0.9) scaleY(1.2) rotate(14deg); }
    70% { opacity: 0.6; transform: scaleX(1.1) scaleY(0.95) rotate(10deg); }
}

/* Floating background particles (hearts, bubble tea, etc.) */
#anime-particles {
    position: fixed;
    inset: 0;
    overflow: hidden;
    pointer-events: none;
    z-index: 0;
}

.anime-particle {
    --sway: 0px;
    position: absolute;
    bottom: -2.5rem;
    opacity: 0;
    animation: anime-float-up linear infinite;
    filter: blur(0.3px);
    will-change: transform, opacity;
}

@keyframes anime-float-up {
    0% {
        transform: translateY(0) translateX(0) rotate(0deg) scale(1);
        opacity: 0;
    }
    5% {
        opacity: 0.35;
    }
    50% {
        transform: translateY(-50vh) translateX(var(--sway)) rotate(180deg) scale(1.05);
        opacity: 0.25;
    }
    90% {
        opacity: 0.1;
    }
    100% {
        transform: translateY(-105vh) translateX(calc(var(--sway) * -0.5)) rotate(360deg) scale(0.9);
        opacity: 0;
    }
}

/* Falling sakura petals from the top-right */
#sakura-petals {
    position: fixed;
    inset: 0;
    overflow: hidden;
    pointer-events: none;
    z-index: 0;
}

.sakura-petal {
    --drift: -80px;
    position: absolute;
    top: -2rem;
    opacity: 0;
    animation: sakura-fall linear infinite;
    will-change: transform, opacity;
}

@keyframes sakura-fall {
    0% {
        transform: translateY(0) translateX(0) rotate(0deg) scale(1);
        opacity: 0;
    }
    5% {
        opacity: 0.45;
    }
    40% {
        opacity: 0.35;
    }
    70% {
        transform: translateY(70vh) translateX(var(--drift)) rotate(260deg) scale(0.95);
        opacity: 0.2;
    }
    100% {
        transform: translateY(110vh) translateX(calc(var(--drift) * 1.3)) rotate(400deg) scale(0.85);
        opacity: 0;
    }
}

/* ?? Drawer toggle (global - crosses component boundaries) ?? */

.drawer-toggle {
    display: none;
}

.drawer-toggle:checked ~ .drawer-backdrop {
    opacity: 1;
    pointer-events: auto;
}

.drawer-toggle:checked ~ .drawer {
    transform: translateX(0);
}

/* ?? StrokeOrderAnimation fallback styles (global) ????????????????????????? */

.soa-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
}

.soa-svg {
    width: min(200px, 52vw);
    aspect-ratio: 1;
    overflow: visible;
}

.soa-stroke {
    fill: none;
    stroke: var(--text-primary);
    stroke-width: 4;
    stroke-linecap: round;
    stroke-linejoin: round;
    transition: stroke 0.35s ease;
}

.soa-stroke.drawing {
    stroke: var(--accent);
    stroke-dasharray: 1;
    stroke-dashoffset: 1;
    animation: soa-draw var(--soa-dur, 700ms) cubic-bezier(0, 0, 0.15, 1) forwards;
}

@keyframes soa-draw {
    from { stroke-dashoffset: 1; }
    to   { stroke-dashoffset: 0; }
}

.soa-svg .soa-marker circle {
    fill: var(--accent);
}

.soa-svg .soa-marker .soa-marker-pulse {
    fill: none;
    stroke: var(--accent);
    stroke-width: 1.5;
}

.soa-svg.soa-svg--done {
    transform-box: fill-box;
    transform-origin: center;
    animation: soa-complete 0.55s cubic-bezier(0.34, 1.8, 0.64, 1) forwards;
}

@keyframes soa-complete {
    from { transform: scale(1); }
    30%  { transform: scaleX(1.08) scaleY(0.94); }
    55%  { transform: scaleX(0.97) scaleY(1.05); }
    75%  { transform: scaleX(1.02) scaleY(0.99); }
    to   { transform: scale(1); }
}
