:root {
    --sr-bg: #000;
    --sr-surface: rgba(10, 10, 10, 0.94);
    --sr-surface-soft: rgba(255, 255, 255, 0.055);
    --sr-text: #f8f8f5;
    --sr-muted: rgba(248, 248, 245, 0.72);
    --sr-line: rgba(255, 255, 255, 0.3);
    --sr-line-strong: rgba(255, 255, 255, 0.78);
    --sr-focus: #ffe8a3;
    --sr-radius: 16px;
    --sr-page-width: 1180px;
    --sr-ease: 180ms ease;
}

* {
    box-sizing: border-box;
}

html {
    margin: 0;
    width: 100%;
    min-height: 100%;
    height: auto;
    display: block;
    color-scheme: dark;
    background: var(--sr-bg);
    transform: none;
    scroll-behavior: smooth;
    scrollbar-gutter: stable;
}

body {
    margin: 0;
    padding: 0;
    width: 100%;
    min-height: 100dvh;
    height: auto;
    display: block;
    overflow-x: clip;
    color: var(--sr-text);
    background: var(--sr-bg);
    transform: none;
}

button,
a {
    -webkit-tap-highlight-color: transparent;
}

button {
    font: inherit;
}

button:focus-visible,
a:focus-visible,
summary:focus-visible {
    outline: 3px solid var(--sr-focus) !important;
    outline-offset: 3px;
}

.skip-link {
    position: fixed;
    top: 8px;
    left: 8px;
    z-index: 10000;
    padding: 10px 14px;
    border-radius: 8px;
    color: #000;
    background: var(--sr-focus);
    font: 700 1rem/1.2 Arial, sans-serif;
    transform: translateY(-160%);
    transition: transform var(--sr-ease);
}

.skip-link:focus {
    transform: translateY(0);
}

.container {
    position: relative;
    inset: auto auto auto 50%;
    width: min(100%, 1440px);
    min-height: 100dvh;
    margin: 0;
    padding: clamp(24px, 5vh, 58px) clamp(18px, 4vw, 56px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    transform: translateX(-50%);
    animation: srContainerFadeIn 700ms ease both;
}

@keyframes srContainerFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.hero-brand {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.hero-eyebrow {
    margin: 0 0 18px;
    color: var(--sr-muted);
    font: 700 clamp(0.72rem, 1.2vw, 0.9rem)/1.2 Arial, sans-serif;
    letter-spacing: 0.28em;
}

.site-emblem {
    width: min(32vw, 380px);
    max-width: 100%;
    max-height: none;
    height: auto;
    aspect-ratio: 737 / 728;
    object-fit: contain;
}

.text {
    margin: 8px 0 4px;
    font-size: clamp(5rem, 10vw, 8.5rem);
    line-height: 0.9;
    text-wrap: balance;
}

.hero-introduction {
    max-width: 680px;
    margin: 18px auto 22px;
    color: var(--sr-muted);
    font: 400 clamp(1rem, 1.7vw, 1.22rem)/1.65 Georgia, "Times New Roman", serif;
    text-wrap: balance;
}

.text-group {
    max-width: 100%;
}

.button {
    min-height: 44px;
    border: 1px solid transparent;
    color: var(--sr-text);
    background: transparent;
    line-height: 1;
    white-space: nowrap;
    touch-action: manipulation;
}

.button:not(:disabled):hover,
.button:not(:disabled).active {
    padding: 10px 20px;
    border-color: var(--sr-line);
    outline: 0;
    background: var(--sr-surface-soft);
}

.button:disabled {
    opacity: 0.54;
}

.discord-button {
    min-width: 44px;
    min-height: 44px;
    gap: 9px;
    padding: 8px 14px;
    border: 1px solid transparent;
    border-radius: 999px;
    color: var(--sr-muted);
    font: 700 0.72rem/1 Arial, sans-serif;
    letter-spacing: 0.15em;
    text-decoration: none;
    transition: color var(--sr-ease), border-color var(--sr-ease), background var(--sr-ease);
}

.discord-button:hover {
    color: var(--sr-text);
    border-color: var(--sr-line);
    background: var(--sr-surface-soft);
}

.discord-button:hover .discord-logo {
    filter: drop-shadow(0 0 8px rgba(255, 255, 255, 0.82));
}

#dynamic-buttons {
    width: 100%;
    max-width: min(100%, 1440px);
    margin: 0 auto;
    display: flex;
    flex-wrap: nowrap;
    justify-content: flex-start;
    gap: 6px;
    overflow-x: auto;
    overscroll-behavior-inline: contain;
    scrollbar-width: none;
    scroll-snap-type: inline proximity;
}

#dynamic-buttons::-webkit-scrollbar {
    display: none;
}

.dynamic-text {
    flex: 0 1 auto;
    padding: 9px clamp(6px, .72vw, 10px);
    font-size: clamp(.88rem, 1.34vw, 1.2rem);
    scroll-snap-align: start;
}

#dynamic-buttons .button:not(:disabled):hover,
#dynamic-buttons .button:not(:disabled).active {
    padding: 9px clamp(6px, .72vw, 10px);
}

@media (min-width: 1100px) {
    #dynamic-buttons {
        justify-content: center;
    }
}

#main-buttons .center-text {
    padding: 14px 22px;
    border-color: var(--sr-line-strong);
    border-radius: 999px;
    font-size: clamp(1.45rem, 2.7vw, 2.15rem);
    letter-spacing: 0.03em;
}

#main-buttons .center-text:hover {
    padding: 14px 22px;
    color: #000;
    background: var(--sr-text);
    border-color: var(--sr-text);
}

body.is-exploring .container {
    position: sticky;
    top: 0;
    z-index: 3000;
    width: 100%;
    left: auto;
    min-height: auto;
    margin: 0 auto;
    padding: 9px max(14px, env(safe-area-inset-right)) 9px max(14px, env(safe-area-inset-left));
    background: rgba(0, 0, 0, 0.9);
    border-bottom: 1px solid var(--sr-line);
    box-shadow: 0 14px 32px rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    animation: none;
    transform: none;
}

body.is-exploring .hero-brand,
body.is-exploring #main-buttons,
body.is-exploring .discord-button {
    display: none !important;
}

body.is-exploring #dynamic-buttons {
    display: flex;
    padding: 0;
}

#app-content {
    position: relative;
    width: 100%;
    min-height: 1px;
    padding: 0 0 max(32px, env(safe-area-inset-bottom));
    isolation: isolate;
}

#app-content:focus {
    outline: 0;
}

body.is-exploring #app-content {
    padding-top: 8px;
}

.app-surface {
    transition: opacity var(--sr-ease);
}

.hidden {
    display: none !important;
}

.view-intro {
    width: min(var(--sr-page-width), calc(100% - 32px));
    margin: clamp(18px, 4vh, 42px) auto 16px;
    padding: 0 4px;
    text-align: center;
}

.view-intro-eyebrow {
    margin: 0 0 8px;
    color: var(--sr-muted);
    font: 700 0.74rem/1.2 Arial, sans-serif;
    letter-spacing: 0.25em;
}

.view-intro-title {
    margin: 0;
    font: 400 clamp(3rem, 7vw, 5.6rem)/0.95 'Arrancar', sans-serif;
    text-shadow: 2px 2px 5px rgba(0, 0, 0, 0.8), -1px -1px 4px rgba(255, 255, 255, 0.38);
    text-wrap: balance;
}

.view-intro-description {
    max-width: 760px;
    margin: 14px auto 0;
    color: var(--sr-muted);
    font: 400 clamp(1rem, 1.7vw, 1.16rem)/1.6 Georgia, "Times New Roman", serif;
    text-wrap: balance;
}

.content-panel,
.selection-panel.systems-panel,
#lore-panel {
    position: relative !important;
    inset: auto !important;
    left: auto !important;
    top: auto !important;
    bottom: auto !important;
    width: min(var(--sr-page-width), calc(100% - 32px)) !important;
    min-height: 0 !important;
    max-height: calc(100dvh - 112px) !important;
    margin: 12px auto 28px !important;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: none !important;
    border: 1px solid var(--sr-line-strong);
    border-radius: var(--sr-radius);
    background: var(--sr-surface);
}

.systems-tabs,
.kido-tabs {
    flex: 0 0 auto;
    display: flex;
    flex-wrap: nowrap;
    gap: 7px;
    overflow-x: auto;
    overscroll-behavior-inline: contain;
    scrollbar-width: thin;
    scroll-snap-type: inline proximity;
}

.content-panel[data-content-panel="systems"] .systems-tabs {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 7px;
    padding: 8px;
    overflow: visible;
    scroll-snap-type: none;
    scrollbar-width: none;
}

.content-panel[data-content-panel="systems"] .systems-tab {
    width: 100%;
    min-width: 0;
    padding: 8px 6px;
    font-size: clamp(.78rem, 1.15vw, 1rem);
    white-space: normal;
    text-wrap: balance;
}

.systems-tab,
.kido-tab {
    flex: 0 0 auto;
    min-height: 44px;
    border-radius: 9px;
    scroll-snap-align: start;
}

.systems-tab.active,
.kido-tab.active {
    color: #000;
    background: var(--sr-text);
    border-color: var(--sr-text);
}

.systems-content,
.kido-content {
    flex: 1 1 auto;
    min-height: 0;
    max-height: none;
    padding: clamp(16px, 2.5vw, 28px);
    overflow: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
}

.panel-controls {
    flex: 0 0 auto;
    padding: 6px 10px;
    display: flex;
    justify-content: flex-end;
    gap: 7px;
    border-bottom: 1px solid var(--sr-line);
    background: rgba(255, 255, 255, 0.025);
}

.panel-controls button {
    min-height: 44px;
    padding: 6px 10px;
    border: 1px solid var(--sr-line);
    border-radius: 8px;
    color: var(--sr-muted);
    background: transparent;
    font: 700 0.76rem/1 Arial, sans-serif;
    letter-spacing: 0.05em;
    cursor: pointer;
}

.panel-controls button:hover {
    color: var(--sr-text);
    border-color: var(--sr-line-strong);
    background: var(--sr-surface-soft);
}

.systems-content h2,
.kido-content h2 {
    font-size: clamp(2.1rem, 5vw, 3.25rem);
    line-height: 1;
}

.systems-content p,
.systems-content li,
.kido-content p,
.kido-content li,
.content {
    font-size: clamp(1rem, 1.6vw, 1.2rem);
    line-height: 1.62;
}

.systems-content summary,
.kido-content summary {
    min-height: 48px;
    padding: 12px 14px;
}

summary .label {
    font-size: clamp(1.25rem, 2.8vw, 1.85rem);
    line-height: 1.15;
}

.loading-message {
    color: var(--sr-muted);
}

.race-image-container {
    position: relative;
    inset: auto;
    left: auto;
    top: auto;
    width: min(1280px, 100%);
    height: clamp(620px, calc(100dvh - 94px), 860px);
    margin: 0 auto;
    transform: none;
}

.choice-screen {
    width: min(var(--sr-page-width), calc(100% - 32px));
    height: auto;
    margin: 4px auto 32px;
    padding: 4px;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    align-items: stretch;
    gap: 14px;
}

.choice-screen .mobile-choice-card {
    appearance: none;
    min-width: 0;
    min-height: 420px;
    padding: 18px 14px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
    overflow: hidden;
    border: 1px solid var(--sr-line);
    border-radius: var(--sr-radius);
    color: var(--sr-text);
    background:
        radial-gradient(circle at 50% 20%, rgba(255, 255, 255, 0.13), transparent 52%),
        linear-gradient(180deg, rgba(255, 255, 255, 0.045), rgba(255, 255, 255, 0.015));
    cursor: pointer;
    transition: border-color var(--sr-ease), background var(--sr-ease), transform var(--sr-ease);
}

.choice-screen .mobile-choice-card:hover {
    border-color: var(--sr-line-strong);
    background:
        radial-gradient(circle at 50% 18%, rgba(255, 255, 255, 0.2), transparent 54%),
        linear-gradient(180deg, rgba(255, 255, 255, 0.07), rgba(255, 255, 255, 0.025));
    transform: translateY(-4px);
}

.choice-screen .mobile-choice-image,
.choice-screen .mobile-choice-label {
    position: relative !important;
    inset: auto !important;
    left: auto !important;
    top: auto !important;
    right: auto !important;
    bottom: auto !important;
    transform: none !important;
}

.choice-screen .mobile-choice-image {
    width: 100%;
    height: 340px;
    max-width: none;
    object-fit: contain;
    opacity: 0.72;
    filter: saturate(0.82) drop-shadow(0 16px 24px rgba(0, 0, 0, 0.55));
    transition: opacity var(--sr-ease), filter var(--sr-ease), transform var(--sr-ease) !important;
}

.choice-screen .mobile-choice-label {
    width: 100%;
    margin: 0;
    padding: 0;
    color: var(--sr-text);
    background: transparent !important;
    outline: 0 !important;
    font-size: clamp(1.65rem, 3vw, 2.35rem);
    text-align: center;
}

.choice-screen .mobile-choice-card:hover .mobile-choice-image,
.choice-screen .mobile-choice-card:focus-visible .mobile-choice-image {
    opacity: 1;
    filter: saturate(1) drop-shadow(0 18px 28px rgba(0, 0, 0, 0.66));
    transform: scale(1.025) !important;
}

#subrace-clock {
    position: relative;
    inset: auto;
    left: auto;
    top: auto;
    width: min(800px, 100%) !important;
    height: min(800px, calc(100dvh - 100px)) !important;
    margin: 8px auto 28px;
}

.lore-shelf {
    position: relative;
    inset: auto;
    left: auto;
    top: auto;
    width: min(1380px, calc(100% - 32px));
    max-width: none;
    margin: 12px auto 28px;
    padding: 8px;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    align-items: end;
    gap: 14px;
    transform: none;
}

.lore-book-wrap {
    width: 100%;
    min-width: 0;
    padding: 8px;
    border: 1px solid transparent;
    border-radius: 12px;
    color: var(--sr-text);
    background: transparent;
    cursor: pointer;
}

.lore-book-wrap:hover {
    border-color: var(--sr-line);
    background: var(--sr-surface-soft);
}

.lore-book {
    width: 100%;
    height: clamp(220px, 32vw, 390px);
    opacity: 0.76;
}

.lore-book-wrap:hover .lore-book,
.lore-book-wrap:focus-visible .lore-book {
    opacity: 1;
    transform: translateY(-4px);
}

.lore-book-caption {
    margin: 8px 0 0;
    font-size: clamp(1.1rem, 2vw, 1.5rem);
}

.lore-panel-header {
    flex: 0 0 auto;
    padding: 12px 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    border-bottom: 1px solid var(--sr-line);
    background: var(--sr-surface-soft);
}

.lore-back-button {
    min-height: 44px;
    padding: 8px 12px;
    border: 1px solid var(--sr-line);
    border-radius: 9px;
    color: var(--sr-text);
    background: transparent;
    font: 700 0.82rem/1 Arial, sans-serif;
    letter-spacing: 0.1em;
    cursor: pointer;
}

.lore-back-button:hover {
    background: var(--sr-surface-soft);
}

.lore-current-book {
    margin: 0;
    font: 400 clamp(1.8rem, 4vw, 2.7rem)/1 'Arrancar', sans-serif;
}

.map-page,
.faction-selection-screen,
.faction-detail-page {
    position: relative;
    inset: auto;
    left: auto;
    top: auto !important;
    width: min(1800px, calc(100% - 24px));
    max-height: none;
    margin: 4px auto 32px;
    transform: none;
}

.faction-selection-screen > .faction-selection-header {
    display: none;
}

.map-page {
    padding-bottom: 0;
}

.map-stage {
    min-height: 320px;
    height: clamp(380px, 58dvh, 720px);
}

.map-info-panel {
    min-width: 0;
}

#selection-layout {
    position: relative;
    inset: auto;
    left: auto;
    top: auto;
    width: min(var(--sr-page-width), calc(100% - 24px));
    margin: 8px auto 12px;
    display: grid;
    grid-template-columns: minmax(320px, 1fr) minmax(260px, 420px);
    grid-template-areas:
        "tree name"
        "tree image";
    gap: clamp(18px, 3vw, 42px);
    align-items: start;
    scroll-margin-top: 68px;
    transform: none !important;
}

#selection-layout.general-tree-layout {
    grid-template-columns: 1fr;
    grid-template-areas: "tree";
}

#selection-layout.general-tree-layout .name-column,
#selection-layout.general-tree-layout .image-column {
    display: none;
}

.selection-column {
    min-width: 0;
}

.tree-column {
    grid-area: tree;
}

.name-column {
    grid-area: name;
    justify-content: center;
}

.image-column {
    grid-area: image;
    justify-content: center;
}

.name-column .race-name {
    width: 100%;
    margin: 16px 0 0;
    font-size: clamp(3rem, 5vw, 4.8rem);
    text-align: center;
}

.image-column img {
    width: 100%;
    height: min(58dvh, 560px);
    max-width: 100%;
    max-height: 560px;
    object-fit: contain;
    filter: drop-shadow(0 18px 32px rgba(0, 0, 0, 0.62));
}

.selection-panel.systems-panel {
    max-height: min(68dvh, 760px) !important;
}

.tooltip {
    max-width: min(450px, calc(100vw - 24px));
    border: 1px solid var(--sr-line);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.72);
}

@media (max-width: 980px) {
    .text {
        font-size: clamp(4.5rem, 12vw, 7.5rem);
    }

    .map-page {
        width: min(760px, calc(100% - 24px));
    }

    .map-stage {
        height: clamp(300px, 48dvh, 520px);
    }

    .faction-column-panel {
        min-height: 420px;
    }

    .content-panel[data-content-panel="systems"] .systems-tabs {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

@media (max-width: 768px) {
    .container {
        width: 100%;
        min-height: 100svh;
        padding: max(18px, env(safe-area-inset-top)) 12px max(30px, env(safe-area-inset-bottom));
    }

    .site-emblem {
        width: min(55vw, 230px);
    }

    .text {
        margin-top: 12px;
        font-size: clamp(3.45rem, 17vw, 5rem);
        line-height: 0.92;
    }

    .hero-eyebrow {
        margin-bottom: 14px;
        font-size: 0.68rem;
        letter-spacing: 0.2em;
    }

    .hero-introduction {
        max-width: 34rem;
        margin: 16px 10px 20px;
        font-size: 1rem;
        line-height: 1.55;
    }

    #main-buttons {
        display: flex;
        width: auto;
        gap: 8px;
    }

    #main-buttons .center-text {
        font-size: 1.65rem;
    }

    body.is-exploring .container {
        padding-top: max(7px, env(safe-area-inset-top));
        padding-bottom: 7px;
    }

    body.is-exploring #dynamic-buttons {
        width: 100%;
        max-width: 100%;
        flex-wrap: nowrap;
        justify-content: flex-start;
        gap: 5px;
        overflow-x: auto;
        overscroll-behavior-inline: contain;
        scrollbar-width: none;
        scroll-snap-type: inline proximity;
    }

    body.is-exploring #dynamic-buttons::-webkit-scrollbar {
        display: none;
    }

    .dynamic-text {
        flex: 0 0 auto;
        min-height: 42px;
        padding: 8px 11px;
        font-size: 1rem;
        scroll-snap-align: start;
    }

    .button:not(:disabled):hover,
    .button:not(:disabled).active {
        padding: 8px 11px;
    }

    body.is-exploring #app-content {
        padding-top: 4px;
    }

    .view-intro {
        width: calc(100% - 24px);
        margin: 20px auto 12px;
    }

    .view-intro-eyebrow {
        font-size: 0.68rem;
        letter-spacing: 0.18em;
    }

    .view-intro-title {
        font-size: clamp(2.8rem, 15vw, 4.2rem);
    }

    .view-intro-description {
        margin-top: 10px;
        font-size: 0.98rem;
        line-height: 1.52;
    }

    .content-panel,
    .selection-panel.systems-panel,
    #lore-panel {
        width: calc(100% - 20px) !important;
        max-height: calc(100dvh - 76px) !important;
        margin: 6px auto 18px !important;
        border-radius: 13px;
    }

    .systems-tabs,
    .kido-tabs {
        padding: 8px;
    }

    .systems-tab,
    .kido-tab {
        font-size: 0.98rem;
        padding: 8px 11px;
    }

    .content-panel[data-content-panel="systems"] .systems-tabs {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .content-panel[data-content-panel="systems"] .systems-tab {
        padding: 7px 4px;
        font-size: .78rem;
    }

    .systems-content,
    .kido-content {
        padding: 16px 14px 22px;
        overflow: auto;
    }

    .systems-content h2,
    .kido-content h2 {
        font-size: clamp(2rem, 10vw, 2.7rem);
    }

    .systems-content p,
    .systems-content li,
    .kido-content p,
    .kido-content li,
    .content {
        font-size: 1rem;
        line-height: 1.58;
    }

    summary .label {
        font-size: clamp(1.18rem, 6vw, 1.55rem);
    }

    .race-image-container {
        width: 100%;
        height: auto;
        margin: 0;
    }

    .choice-screen.mobile-choice-screen {
        width: 100%;
        max-width: 640px;
        margin: 8px auto 24px;
        padding: 8px 2px;
        gap: 10px;
    }

    .choice-screen .mobile-choice-card {
        min-height: 44px;
        padding: 12px 8px 14px;
        border-radius: 16px;
    }

    .choice-screen .mobile-choice-image {
        height: clamp(170px, 50vw, 225px);
    }

    .choice-screen .mobile-choice-label {
        font-size: clamp(1.2rem, 6vw, 1.7rem);
    }

    .lore-shelf {
        width: calc(100% - 20px);
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
        margin: 6px auto 20px;
        padding: 0;
    }

    .lore-book-wrap {
        padding: 7px 4px;
    }

    .lore-book {
        height: clamp(200px, 64vw, 300px);
    }

    .lore-panel-header {
        padding: 9px 10px;
    }

    .lore-current-book {
        font-size: 1.65rem;
    }

    .map-page,
    .faction-selection-screen,
    .faction-detail-page {
        width: calc(100% - 16px);
        margin-top: 4px;
    }

    .map-page-header,
    .faction-selection-header,
    .faction-detail-header {
        align-items: center;
        text-align: center;
    }

    .map-stage {
        min-height: 240px;
        height: clamp(260px, 42dvh, 390px);
    }

    .map-info-panel {
        min-height: 360px;
        padding: 16px 14px;
    }

    .map-realm-tabs,
    .map-info-tabs,
    .faction-bottom-tabs {
        flex-wrap: nowrap;
        max-width: 100%;
        overflow-x: auto;
        scrollbar-width: thin;
    }

    #selection-layout {
        width: 100%;
        grid-template-columns: 1fr;
        grid-template-areas:
            "name"
            "image"
            "tree";
        gap: 12px;
        padding: 8px 10px 0;
    }

    .name-column {
        order: 1;
        justify-content: center;
    }

    .image-column {
        order: 2;
    }

    .tree-column {
        order: 3;
    }

    .name-column .race-name {
        font-size: clamp(2rem, 11vw, 3rem);
        white-space: normal;
        text-align: center;
    }

    .image-column img {
        max-height: min(42dvh, 390px);
    }

    .selection-panel.systems-panel {
        max-height: calc(100dvh - 76px) !important;
    }

    .faction-selection-wheel {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 12px 8px;
    }

    .faction-column-panel {
        min-height: 360px;
    }

    .faction-portrait,
    .faction-emblem-frame {
        min-height: 220px;
    }

    .tooltip {
        position: fixed;
        left: 12px !important;
        right: 12px;
        bottom: 12px;
        top: auto !important;
        width: auto;
        max-width: none;
        max-height: min(62dvh, 520px) !important;
        overflow: auto !important;
    }
}

@media (prefers-reduced-motion: reduce) {
    .realm-gate,
    .realm-gate::after,
    .character-choice,
    .character-choice-image,
    .character-choice-label,
    .lore-library-stage,
    .lore-book-wrap,
    .lore-book {
        animation: none !important;
        transition: none !important;
    }
}

@media (max-width: 430px) {
    #main-buttons {
        width: auto;
    }

    .choice-screen .mobile-choice-label {
        overflow-wrap: anywhere;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* =========================================================
   Realm gateway, bookshelf, and character-select identity
   ========================================================= */

.realm-selector,
#main-buttons.realm-selector {
    width: min(1120px, 100%);
    margin: 4px auto 6px !important;
    display: grid;
    grid-template-columns: minmax(0, .72fr) minmax(0, .72fr) minmax(240px, 1.2fr) minmax(0, .72fr) minmax(0, .72fr);
    gap: clamp(10px, 2vw, 22px);
}

.realm-selector .realm-gate,
#main-buttons .realm-gate {
    position: relative;
    min-height: 142px;
    width: 100%;
    padding: 18px !important;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 7px;
    overflow: hidden;
    border: 1px solid var(--sr-line);
    border-radius: 4px;
    background:
        linear-gradient(135deg, transparent 46%, rgba(255,255,255,.08) 49%, transparent 52%),
        rgba(255, 255, 255, 0.018);
    isolation: isolate;
}

.realm-selector .realm-gate::before,
.realm-selector .realm-gate::after {
    content: "";
    position: absolute;
    inset: 8px;
    z-index: -1;
    border: 1px solid rgba(255,255,255,.12);
    pointer-events: none;
}

.realm-selector .realm-gate::after {
    inset: 0;
    border: 0;
    background: radial-gradient(circle at 50% 110%, rgba(255,255,255,.17), transparent 58%);
    opacity: 0;
    transition: opacity 260ms ease;
}

.realm-selector .realm-gate:not(:disabled):hover,
.realm-selector .realm-gate:not(:disabled):focus-visible {
    padding: 18px !important;
    color: var(--sr-text);
    border-color: var(--sr-line-strong);
    background: rgba(255,255,255,.04);
    transform: translateY(-4px);
}

.realm-selector .realm-gate:not(:disabled):hover::after,
.realm-selector .realm-gate:not(:disabled):focus-visible::after {
    opacity: 1;
}

.realm-selector .realm-gate:disabled {
    opacity: .34;
    filter: grayscale(1);
}

.realm-gate-eyebrow,
.realm-gate-description {
    font-family: Arial, sans-serif;
}

.realm-gate-eyebrow {
    color: var(--sr-muted);
    font-size: .66rem;
    font-weight: 800;
    letter-spacing: .24em;
}

.realm-gate-label {
    font-size: clamp(1.7rem, 3.6vw, 3rem);
    line-height: .95;
    letter-spacing: .04em;
}

.realm-selector .realm-gate:disabled .realm-gate-label {
    font-size: clamp(1.25rem, 2.1vw, 1.8rem);
    letter-spacing: .015em;
    white-space: nowrap;
}

.realm-gate-description {
    max-width: 330px;
    color: var(--sr-muted);
    font-size: clamp(.76rem, 1.1vw, .9rem);
    font-weight: 400;
    line-height: 1.45;
    letter-spacing: 0;
    text-wrap: balance;
}

.character-select-stage.choice-screen {
    position: relative;
    width: min(1440px, calc(100% - 24px));
    height: clamp(520px, calc(100dvh - 285px), 720px);
    margin: 0 auto 28px;
    padding: 24px clamp(10px, 2vw, 34px) 0;
    display: flex;
    grid-template-columns: none;
    align-items: stretch;
    justify-content: flex-start;
    gap: 0;
    overflow: clip;
    border: 0;
    background: transparent;
    isolation: isolate;
}

.character-select-stage::after {
    content: none;
    display: none;
}

.character-choice {
    appearance: none;
    position: relative;
    flex: 1 1 0;
    min-width: 0;
    height: 100%;
    margin: 0 -1.1%;
    padding: 0;
    border: 0;
    color: var(--sr-text);
    background: transparent;
    cursor: pointer;
    isolation: isolate;
    transition: flex-grow 260ms ease, transform 260ms ease;
}

.character-choice:nth-child(even) {
    transform: translateY(14px);
}

.character-select-stage .character-choice-image {
    --portrait-facing: 1;
    --portrait-scale: 1;
    --portrait-shift: -50%;
    position: absolute !important;
    inset: auto auto 62px 50% !important;
    width: clamp(220px, 28vw, 440px);
    height: calc(100% - 72px);
    max-width: none;
    max-height: none;
    object-fit: contain;
    object-position: center bottom;
    opacity: .58;
    filter: grayscale(.25) saturate(.78) drop-shadow(0 24px 22px rgba(0,0,0,.72));
    transform: translateX(var(--portrait-shift)) scaleX(var(--portrait-facing)) scale(var(--portrait-scale)) !important;
    transform-origin: center bottom;
    transition: opacity 220ms ease, filter 220ms ease, transform 260ms ease !important;
    pointer-events: none;
}

.choice-screen--types .character-choice-image {
    width: clamp(300px, 38vw, 570px);
}

.choice-screen--types .sinner {
    --portrait-facing: -1;
}

.choice-screen--races .character-choice-image {
    width: clamp(270px, 31vw, 470px);
}

.choice-screen--races .fae {
    --portrait-scale: 1.2;
    --portrait-shift: -70%;
}

.choice-screen--races .character-choice:has(.human) {
    z-index: 4;
}

.choice-screen--races .character-choice:has(.beast) {
    z-index: 3;
}

.choice-screen--races .character-choice:has(.mod-soul),
.choice-screen--races .character-choice:has(.fae) {
    z-index: 1;
}

.choice-screen--subraces .character-choice-image {
    width: clamp(180px, 20vw, 300px);
}

.choice-screen--subraces.character-select-stage {
    height: clamp(480px, calc(100dvh - 325px), 680px);
    padding-inline: clamp(64px, 7vw, 112px);
}

.character-select-stage .character-choice-label {
    position: absolute !important;
    inset: auto 0 12px !important;
    width: auto;
    margin: 0;
    padding: 7px 5px;
    color: rgba(255,255,255,.7);
    background: transparent !important;
    outline: 0 !important;
    font-size: clamp(1.5rem, 2.8vw, 2.65rem);
    line-height: 1;
    text-align: center;
    white-space: nowrap;
    transform: none !important;
    transition: color 220ms ease, letter-spacing 220ms ease, transform 220ms ease !important;
    pointer-events: none;
}

.choice-screen--subraces .character-choice-label {
    font-size: clamp(1.2rem, 2vw, 2rem);
}

.character-choice:hover,
.character-choice:focus-visible {
    z-index: 20;
    flex-grow: 1.24;
    transform: translateY(-8px);
}

.character-choice:nth-child(even):hover,
.character-choice:nth-child(even):focus-visible {
    transform: translateY(2px);
}

.character-choice:hover .character-choice-image,
.character-choice:focus-visible .character-choice-image,
.character-choice .character-choice-image.active {
    opacity: 1;
    filter: grayscale(0) saturate(1.05) drop-shadow(0 28px 30px rgba(0,0,0,.8));
    transform: translateX(var(--portrait-shift)) scaleX(var(--portrait-facing)) scale(var(--portrait-scale)) scale(1.055) !important;
}

.character-choice:hover .character-choice-label,
.character-choice:focus-visible .character-choice-label,
.character-choice .character-choice-label.active {
    color: #fff;
    letter-spacing: .045em;
    transform: translateY(-3px) !important;
}

.character-select-stage:has(.character-choice:hover) .character-choice:not(:hover) .character-choice-image,
.character-select-stage:has(.character-choice:focus-visible) .character-choice:not(:focus-visible) .character-choice-image {
    opacity: .16;
    filter: grayscale(.65) saturate(.45) drop-shadow(0 18px 14px rgba(0,0,0,.6));
}

.lore-library-stage {
    width: min(1480px, calc(100% - 24px));
    margin: 6px auto 30px;
    opacity: 0;
    transition: opacity 500ms ease;
}

.lore-library-stage.visible {
    opacity: 1;
}

.lore-shelf-prompt {
    margin: 0 0 8px;
    color: var(--sr-muted);
    font: 700 .72rem/1.2 Arial, sans-serif;
    letter-spacing: .18em;
    text-align: center;
    text-transform: uppercase;
}

.lore-library-stage .lore-shelf {
    position: relative;
    inset: auto;
    width: 100%;
    max-width: none;
    height: 430px;
    margin: 0;
    padding: 24px 18px 38px;
    display: flex;
    flex-wrap: nowrap;
    align-items: flex-end;
    justify-content: center;
    gap: 0;
    overflow-x: hidden;
    overflow-y: hidden;
    overscroll-behavior-inline: contain;
    scroll-snap-type: none;
    scrollbar-width: none;
    transform: none;
    opacity: 1;
    background:
        linear-gradient(180deg, rgba(255,255,255,.025), transparent 50%),
        radial-gradient(ellipse at 50% 100%, rgba(124,79,37,.17), transparent 52%);
    perspective: 1100px;
}

.lore-library-stage .lore-shelf::after {
    content: "";
    position: absolute;
    right: 16px;
    bottom: 15px;
    left: 16px;
    height: 18px;
    border: 1px solid rgba(255,255,255,.23);
    background: linear-gradient(180deg, #2c2119, #0b0908 70%);
    box-shadow: 0 12px 22px rgba(0,0,0,.85), inset 0 2px rgba(255,255,255,.08);
    pointer-events: none;
}

.lore-library-stage .lore-book-wrap {
    position: relative;
    z-index: 1;
    flex: 0 1 clamp(78px, 6.9vw, 100px);
    width: auto;
    min-width: 0;
    height: 360px;
    margin: 0 -7px;
    padding: 0 2px 16px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    border: 0;
    border-radius: 0;
    background: transparent;
    scroll-snap-align: center;
    transform: rotateY(calc((var(--choice-index, 0) - 6) * .15deg));
    transform-origin: center bottom;
    transition: opacity 220ms ease, transform 260ms cubic-bezier(.2,.8,.2,1), filter 220ms ease;
}

.lore-library-stage .lore-book-wrap:hover,
.lore-library-stage .lore-book-wrap:focus-visible {
    z-index: 30;
    border: 0;
    background: transparent;
    transform: translateY(-19px) scale(1.09) rotateY(0);
}

.lore-library-stage .lore-book {
    width: auto;
    height: min(338px, 100%);
    max-width: none;
    opacity: .62;
    filter: saturate(.72) drop-shadow(0 9px 7px rgba(0,0,0,.72));
    transition: opacity 220ms ease, filter 220ms ease;
}

.lore-library-stage .lore-book-wrap:hover .lore-book,
.lore-library-stage .lore-book-wrap:focus-visible .lore-book {
    opacity: 1;
    filter: saturate(1) drop-shadow(0 18px 14px rgba(0,0,0,.82));
    transform: none;
}

.lore-library-stage .lore-book-caption {
    position: absolute;
    right: -16px;
    bottom: 2px;
    left: -16px;
    z-index: 2;
    margin: 0;
    color: rgba(255,255,255,.72);
    font-size: clamp(.82rem, 1.25vw, 1.12rem);
    line-height: 1;
    text-align: center;
    text-shadow: 0 2px 5px #000;
    white-space: nowrap;
    transition: color 220ms ease;
}

.lore-library-stage .lore-book-wrap:hover .lore-book-caption,
.lore-library-stage .lore-book-wrap:focus-visible .lore-book-caption,
.lore-library-stage .lore-book-wrap.active .lore-book-caption {
    color: #fff;
}

.lore-library-stage .lore-book-wrap.active {
    z-index: 25;
    transform: translateY(-11px) scale(1.045);
}

.lore-library-stage .lore-book-wrap.active .lore-book {
    opacity: 1;
    filter: saturate(1) drop-shadow(0 14px 11px rgba(0,0,0,.8));
}

.lore-library-stage.has-open-book .lore-shelf {
    height: 330px;
}

.lore-library-stage.has-open-book .lore-book-wrap {
    height: 280px;
}

.lore-library-stage.has-open-book .lore-book {
    height: 258px;
}

.lore-library-stage .lore-shelf:has(.lore-book-wrap:hover) .lore-book-wrap:not(:hover),
.lore-library-stage .lore-shelf:has(.lore-book-wrap:focus-visible) .lore-book-wrap:not(:focus-visible) {
    opacity: .28;
    filter: grayscale(.55);
}

#lore-panel {
    border: 10px solid #17100c !important;
    border-radius: 10px !important;
    background: #17100c;
    box-shadow: 0 24px 60px rgba(0,0,0,.68), inset 0 0 0 1px rgba(255,255,255,.12);
}

#lore-panel .lore-panel-header,
#lore-panel .systems-tabs {
    border-color: rgba(255,255,255,.16);
    background: linear-gradient(180deg, #261b14, #120d0a);
}

#lore-panel .lore-panel-header {
    justify-content: center;
}

#lore-panel .systems-content {
    position: relative;
    padding: clamp(24px, 4vw, 50px);
    color: #2a2118;
    background:
        linear-gradient(90deg, rgba(80,55,30,.14), transparent 5%, transparent 48%, rgba(80,55,30,.18) 50%, transparent 52%, transparent 95%, rgba(80,55,30,.14)),
        repeating-linear-gradient(0deg, rgba(80,55,30,.025) 0 1px, transparent 1px 5px),
        #d8c8a5;
    box-shadow: inset 0 0 44px rgba(71,45,23,.28);
    font-family: Georgia, "Times New Roman", serif;
    font-size: clamp(1rem, 1.5vw, 1.18rem);
    line-height: 1.78;
    text-shadow: 0 1px rgba(255,255,255,.2);
}

#lore-panel .systems-content h2,
#lore-panel .systems-content h3,
#lore-panel .systems-content strong,
#lore-panel .systems-content code {
    color: #20170f;
}

#lore-panel .systems-content h2 {
    font-family: 'Arrancar', Georgia, serif;
    font-size: clamp(2.2rem, 5vw, 4rem);
    line-height: 1;
}

@media (max-width: 768px) {
    .container {
        padding-top: max(20px, env(safe-area-inset-top));
    }

    .site-emblem {
        width: min(48vw, 230px);
    }

    .text {
        font-size: clamp(4rem, 20vw, 6rem);
    }

    .hero-introduction {
        margin-block: 12px 16px;
    }

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

    #main-buttons.realm-selector {
        display: grid;
        width: 100%;
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }

    #main-buttons.realm-selector .realm-gate[data-realm="bleach"] {
        grid-column: 1 / -1;
        grid-row: 1;
    }

    .realm-selector .realm-gate,
    #main-buttons .realm-gate {
        min-height: 122px;
        padding: 10px 7px !important;
    }

    .realm-selector .realm-gate:disabled,
    #main-buttons .realm-gate:disabled {
        min-height: 82px;
    }

    .realm-selector .realm-gate:not(:disabled):hover,
    .realm-selector .realm-gate:not(:disabled):focus-visible {
        padding: 10px 7px !important;
    }

    .realm-selector .realm-gate:disabled .realm-gate-description {
        display: none;
    }

    .realm-selector .realm-gate:disabled .realm-gate-label {
        font-size: clamp(.78rem, 3vw, 1rem);
        letter-spacing: 0;
    }

    .realm-gate-eyebrow {
        font-size: .52rem;
        letter-spacing: .12em;
    }

    .realm-gate-label {
        font-size: clamp(1rem, 6vw, 2rem);
    }

    .realm-gate-description {
        font-size: .68rem;
        line-height: 1.3;
    }

    .character-select-stage.choice-screen {
        width: 100%;
        height: clamp(490px, 67dvh, 610px);
        margin-bottom: 18px;
        padding: 15px calc((100vw - min(68vw, 270px)) / 2) 0;
        align-items: stretch;
        overflow-x: auto;
        overflow-y: clip;
        scroll-snap-type: x mandatory;
        scrollbar-width: thin;
    }

    .character-select-stage::after {
        top: 22px;
        font-size: 3.2rem;
    }

    .character-choice,
    .character-choice:nth-child(even) {
        flex: 0 0 min(68vw, 270px);
        width: min(68vw, 270px);
        margin: 0 -16px;
        transform: none;
        scroll-snap-align: center;
    }

    .character-choice:hover,
    .character-choice:focus-visible,
    .character-choice:nth-child(even):hover,
    .character-choice:nth-child(even):focus-visible {
        flex-grow: 0;
        transform: translateY(-5px);
    }

    .character-select-stage .character-choice-image,
    .choice-screen--types .character-choice-image,
    .choice-screen--races .character-choice-image,
    .choice-screen--subraces .character-choice-image {
        width: min(78vw, 330px);
        height: calc(100% - 60px);
    }

    .choice-screen--subraces.character-select-stage {
        padding-inline: calc((100vw - min(68vw, 270px)) / 2);
    }

    .character-select-stage .character-choice-label,
    .choice-screen--subraces .character-choice-label {
        bottom: 9px !important;
        font-size: clamp(1.55rem, 8vw, 2.2rem);
    }

    .lore-library-stage {
        width: 100%;
        margin-top: 0;
    }

    .lore-shelf-prompt {
        padding-inline: 16px;
        font-size: .62rem;
    }

    .lore-library-stage .lore-shelf {
        width: 100%;
        height: auto;
        padding: 12px 6px 30px;
        display: grid;
        grid-template-columns: repeat(5, minmax(0, 1fr));
        align-items: end;
        overflow: hidden;
        scroll-snap-type: none;
    }

    .lore-library-stage .lore-book-wrap {
        width: 100%;
        height: 182px;
        margin: 0;
        padding-inline: 0;
        scroll-snap-align: none;
    }

    .lore-library-stage .lore-book {
        width: 100%;
        height: 165px;
    }

    .lore-library-stage .lore-book-caption {
        right: -3px;
        left: -3px;
        font-size: .67rem;
        white-space: normal;
    }

    .lore-library-stage.has-open-book .lore-shelf {
        height: auto;
    }

    .lore-library-stage.has-open-book .lore-book-wrap {
        height: 156px;
    }

    .lore-library-stage.has-open-book .lore-book {
        height: 140px;
    }

    #lore-panel {
        width: calc(100% - 12px) !important;
        border-width: 6px !important;
    }

    #lore-panel .systems-content {
        padding: 24px 20px 34px;
        background:
            repeating-linear-gradient(0deg, rgba(80,55,30,.025) 0 1px, transparent 1px 5px),
            #d8c8a5;
        font-size: 1rem;
        line-height: 1.68;
    }
}
