:root { --story-control-gold: #d7c7a5; }
/**
 * =============================================================================
 * This is the file where all your styling should go in.
 * Instead of modifying the styles found in the monogatari.css file or others,
 * you should overwrite those styles in this file.
 *
 * The CSS selectors shown are not an extensive list but they are the most
 * common you might want to change. To find what other elements are available,
 * you can take a look at the monogatari.css file or use your browser's dev
 * tools to inspect the elements.
 * =============================================================================
**/

/**
 * ===========================
 * General Styling
 * ===========================
**/

@font-face {
    font-family: 'PT Serif';
    src: url('../assets/fonts/PTSerif-Regular.ttf') format('truetype');
    font-style: normal;
    font-weight: 400;
    font-display: swap;
}

@font-face {
    font-family: 'Cormorant Garamond';
    src: url('../assets/fonts/CormorantGaramond.ttf') format('truetype');
    font-style: normal;
    font-weight: 300 700;
    font-display: swap;
}

.game-start-curtain {
    position: fixed;
    inset: 0;
    z-index: 11000;
    background: #000;
    opacity: 0;
}

game-screen { background-color: #000; }
#monogatari text-box {
    left: clamp(16px, 5vw, 100px);
    right: clamp(16px, 5vw, 100px);
    bottom: calc(var(--quick-menu-height, 40px) + clamp(16px, 3vh, 40px));
    width: auto;
    min-height: 150px;
    max-height: 32vh;
    padding: 12px 16px;
    border-radius: 12px;
    background: rgba(8, 10, 15, .86);
    border: 1px solid rgba(255, 255, 255, .18);
}

#monogatari text-box [data-ui="say"],
#monogatari text-box [data-content="dialog"],
#monogatari text-box type-writer {
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-weight: 400;
    font-size: clamp(26px, 2.6vw, 36px);
    line-height: 1.5;
}

#monogatari text-box::after { display: none; }
game-screen.prologue text-box,
game-screen.prologue quick-menu { visibility: hidden; }
/* Во время выбора оставляем отмотку и меню доступными. */
game-screen.story-choice quick-menu { visibility: visible; }
.story-scene #monogatari game-screen quick-menu [data-action="back"] {
    min-width: 44px;
    min-height: 44px;
    padding: 8px 12px;
    border: 1px solid rgba(235, 223, 196, .55);
    border-radius: 6px;
    background: rgba(8, 10, 15, .8);
}
.story-scene #monogatari game-screen.story-choice choice-container {
    top: 50%;
    bottom: auto;
    transform: translateY(-50%);
    z-index: 20;
}
.story-scene #monogatari game-screen.story-choice choice-container [data-content="wrapper"] {
    flex-direction: column;
    align-items: stretch;
    width: min(560px, calc(100vw - 32px));
    gap: 20px;
}
.story-scene #monogatari game-screen.story-choice choice-container button {
    min-height: 76px;
    padding: 18px 28px;
    font-size: clamp(28px, 3.5vw, 36px);
    line-height: 1.25;
    white-space: normal;
}
.story-scene game-screen::before {
    content: '';
    position: absolute;
    inset: 0;
    z-index: 10;
    background: rgba(0, 0, 0, .6);
    opacity: 0;
    pointer-events: none;
    transition: opacity 220ms ease;
}
.story-scene game-screen.story-choice::before {
    opacity: 1;
}
.story-scene game-screen.story-choice quick-menu {
    z-index: 21;
}
/* Движок закрывает меню сразу после Start. Сохраняем его под занавесом,
   пока картинка, кнопки и звук вместе уходят в чёрный. */
#monogatari main-screen.leaving-menu {
    display: flex !important;
    position: fixed;
    inset: 0;
    z-index: 10999;
    pointer-events: none;
}

#monogatari choice-container button {
    border: 1px solid rgba(235, 223, 196, .8);
    border-radius: 8px;
    padding: 16px 32px;
    background: rgba(12, 14, 20, .9);
    box-shadow: 0 0 0 4px rgba(235, 223, 196, .08);
    font-size: 1.4rem;
}

#monogatari choice-container button:hover,
#monogatari choice-container button:focus-visible {
    background: rgba(55, 49, 39, .95);
    border-color: #fff3da;
}

#scene-dissolve {
    position: absolute;
    inset: 0;
    z-index: 1;
    background-position: center;
    background-size: cover;
    pointer-events: none;
}
#scene-fade-black {
    position: absolute;
    inset: 0;
    z-index: 4;
    background: #000;
    pointer-events: none;
}

/* Фильтруем только изображение сцены: текст и элементы управления сохраняют цвет. */
game-screen.story-color-return [data-ui="background"],
game-screen.story-color-return #story-camera-viewport,
game-screen.story-color-return #scene-dissolve {
    filter: grayscale(0);
    transition: filter var(--story-color-return-ms, 1600ms) ease-in-out;
}
game-screen.story-grayscale [data-ui="background"],
game-screen.story-grayscale #story-camera-viewport,
game-screen.story-grayscale #story-ghost,
game-screen.story-grayscale #scene-dissolve {
    filter: grayscale(1);
}
#story-ghost {
    position: absolute;
    inset: 0;
    z-index: 2;
    opacity: .24;
    overflow: hidden;
    pointer-events: none;
}
.story-ghost-drift {
    position: absolute;
    inset: 0;
    animation: story-ghost-drift 3800ms ease-out forwards;
    will-change: transform;
}
.story-ghost-picture {
    position: absolute;
    inset: -1%;
    animation: story-ghost-jitter 230ms steps(2, end) infinite;
    will-change: transform;
}
@keyframes story-ghost-drift {
    from { transform: translate3d(-.9%, .3%, 0) scale(1.02); }
    to { transform: translate3d(1.1%, -.5%, 0) scale(1.04); }
}
@keyframes story-ghost-jitter {
    0%, 100% { transform: translate3d(0, 0, 0); }
    35% { transform: translate3d(2px, -1px, 0); }
    70% { transform: translate3d(-1px, 1px, 0); }
}
game-screen:not(.active) #story-ghost { display: none; }
@media (prefers-reduced-motion: reduce) {
    #story-ghost { display: none; }
}
game-screen.story-gentle-shake [data-ui="background"] {
    animation: story-gentle-shake 420ms ease-in-out infinite;
    will-change: transform;
}
@keyframes story-gentle-shake {
    0%, 100% { transform: translate3d(0, 0, 0) scale(1.012); }
    20% { transform: translate3d(-1.5px, .8px, 0) scale(1.012); }
    45% { transform: translate3d(1.2px, -.7px, 0) scale(1.012); }
    70% { transform: translate3d(-.7px, -1px, 0) scale(1.012); }
    85% { transform: translate3d(.8px, .6px, 0) scale(1.012); }
}
@media (prefers-reduced-motion: reduce) {
    game-screen.story-color-return [data-ui="background"],
    game-screen.story-color-return #story-camera-viewport,
    game-screen.story-color-return #scene-dissolve {
        transition: none;
    }
    game-screen.story-gentle-shake [data-ui="background"] {
        animation: none;
        will-change: auto;
    }
}

.storyboard-preview game-screen [data-ui="background"],
.storyboard-preview #scene-dissolve {
    background-size: contain !important;
    background-repeat: no-repeat;
    background-color: #000;
}
.storyboard-preview #monogatari choice-container {
    left: 0;
    right: 0;
    width: 100%;
    top: auto;
    bottom: 24px;
    height: auto;
    transform: none;
    display: flex;
    flex-direction: row;
    justify-content: center;
    gap: 12px;
    pointer-events: none;
}
.storyboard-preview #monogatari choice-container [data-content="wrapper"] {
    display: flex;
    flex-direction: row;
    width: auto;
    max-width: 100%;
    flex-wrap: wrap;
    justify-content: center;
    gap: 12px;
}
.storyboard-preview #monogatari choice-container button {
    width: auto;
    margin: 0;
    padding: 8px 20px;
    font-size: 23px;
    pointer-events: auto;
}
#storyboard-frame-number {
    position: absolute;
    top: calc(max(12px, env(safe-area-inset-top)) + 8px);
    left: calc(max(12px, env(safe-area-inset-left)) + 64px);
    z-index: 30;
    color: #eee;
    background: #121212b3;
    padding: 6px 12px;
    border-radius: 5px;
    font-size: 18px;
    pointer-events: none;
}
:is(#chapter-one-test-end, #chapter-one-test-start) {
    position: absolute;
    inset: 0;
    z-index: 100;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 24px;
    padding: 24px;
    background: #000;
    color: #eee;
    text-align: center;
}
:is(#chapter-one-test-end, #chapter-one-test-start) h1 { margin: 0; font-size: clamp(36px, 6vw, 72px); }
:is(#chapter-one-test-end, #chapter-one-test-start) p { margin: 0; font-size: clamp(16px, 2vw, 24px); }
:is(#chapter-one-test-end, #chapter-one-test-start) > div { display: flex; flex-wrap: wrap; justify-content: center; gap: 16px; }
:is(#chapter-one-test-end, #chapter-one-test-start) button {
    min-width: 160px;
    padding: 14px 24px;
    border: 1px solid #c7b58b;
    border-radius: 6px;
    background: #191816;
    color: #eee;
    font: inherit;
    font-size: clamp(22px, 2.4vw, 30px);
    cursor: pointer;
}
:is(#chapter-one-test-end, #chapter-one-test-start) button:hover, :is(#chapter-one-test-end, #chapter-one-test-start) button:focus-visible { background: #393326; }

/* Реплики сцены: одинаковые порции текста на компьютере и телефоне. */
.story-scene #monogatari text-box {
    --story-font-size: clamp(18px, 2vw, 28px);
    --story-line-size: calc(var(--story-font-size) * 1.5);
    --story-padding-y: clamp(16px, 2vw, 28px);
    --story-padding-x: clamp(16px, 2vw, 28px);
    --story-box-height: calc(var(--story-line-size) * 2 + var(--story-padding-y) * 2 + 2px);
    /* Движок задаёт inline display:grid при каждой реплике. */
    display: flex !important;
    flex-direction: column;
    justify-content: flex-start;
    grid-template-rows: auto;
    grid-template-columns: 1fr;
    grid-template-areas: "text";
    align-content: center;
    box-sizing: border-box;
    left: max(16px, 5vw, env(safe-area-inset-left));
    right: max(16px, 5vw, env(safe-area-inset-right));
    bottom: calc(var(--quick-menu-height, 40px) + 16px + env(safe-area-inset-bottom));
    height: var(--story-box-height);
    min-height: var(--story-box-height);
    max-height: var(--story-box-height);
    overflow-y: auto;
    padding: var(--story-padding-y) var(--story-padding-x);
    overscroll-behavior: contain;
}
.story-scene #monogatari text-box [data-content="name"],
.story-scene #monogatari text-box [data-content="side-image"] {
    display: none;
}
.story-scene #monogatari text-box [data-content="text"] {
    flex: 0 0 auto;
    max-height: none;
    min-height: 0;
    margin: 0;
    padding: 0;
}
.story-scene #monogatari text-box type-writer,
.story-scene #monogatari text-box p {
    margin: 0;
    padding: 0;
}
.story-scene #monogatari text-box .type-writer-container {
    margin: 0;
    padding: 0;
}
.story-scene #monogatari text-box [data-ui="say"],
.story-scene #monogatari text-box [data-content="dialog"],
.story-scene #monogatari text-box type-writer {
    font-size: var(--story-font-size);
    line-height: var(--story-line-size);
    overflow-wrap: anywhere;
}
.story-scene #monogatari choice-container {
    bottom: calc(24px + env(safe-area-inset-bottom));
}
.story-scene #monogatari choice-container button {
    min-height: 44px;
}
@media (max-width: 600px) {
    .story-scene #monogatari text-box {
        left: max(12px, env(safe-area-inset-left));
        right: max(12px, env(safe-area-inset-right));
        --story-padding-y: 14px;
        --story-padding-x: 16px;
    }
}
@media (orientation: landscape) and (max-height: 500px) {
    .story-scene #monogatari text-box {
        --story-font-size: 17px;
        --story-line-size: calc(var(--story-font-size) * 1.4);
        --story-padding-y: 10px;
        --story-padding-x: 16px;
        bottom: calc(var(--quick-menu-height, 40px) + 8px + env(safe-area-inset-bottom));
    }
    .story-scene #monogatari text-box [data-ui="say"],
    .story-scene #monogatari text-box [data-content="dialog"],
    .story-scene #monogatari text-box type-writer {
        font-size: var(--story-font-size);
        line-height: var(--story-line-size);
    }
}

/* Interface and story text use the same Cormorant Garamond family. */
#monogatari button,
#monogatari h1,
#monogatari h2,
#monogatari h3,
#monogatari label,
#monogatari select,
#monogatari input,
#monogatari output,
#monogatari settings-screen,
#monogatari help-screen,
#monogatari quick-menu,
#monogatari [data-ui="who"],
#monogatari [data-content="name"],
#entry-screen,
#menu-volume-control {
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-weight: 600;
}

#monogatari main-menu button {
    font-size: 1.5rem;
}

/* General Style */
html { font-size: 112.5%; }
body {
    font-family: 'Cormorant Garamond', Georgia, serif;
}

/* Simple Button styles*/
button {

}

/* Simple Button Style on Hover */
button:hover {

}

/* General Styling for Menu Screens */
[data-screen] {

}

/**
 * ===========================
 * Main Menu Styling
 * ===========================
**/

/* Main Menu Styling */
[data-screen="main"] {

}

/* Main Menu Buttons Styling */
[data-screen="main"] button {

}

/**
 * ===========================
 * Save and Load Menus Styling
 * ===========================
**/

/* Slots Style */
[data-component="save-slot"] figure {

}

/* Slot's Image Style */
[data-component="save-slot"] img {

}

/* Slots Title Style */
[data-component="save-slot"] figcaption {

}

/* Slots Delete Button Style */
[data-component="save-slot"] button {

}

/**
 * ===========================
 * Game Elements Styling
 * ===========================
**/

/* Choice Buttons style */
[data-component="choice-container"] button {

}

/* Choice Button Style on Hover */
[data-component="choice-container"] button:hover {

}

/* Text Box styling */
[data-component="text-box"] {

}

/* Character Name Style */
[data-ui="who"] {

}

/* Style for Centered Text */
[data-component="centered-dialog"] {

}

/* Character Images Styles */
[data-screen="game"] [data-character] {

}

/* Other Images Styles */
[data-screen="game"] [data-image] {

}

/**
 * ===========================
 * Quick Menu Styling
 * ===========================
**/

/* These styles are applied to the Mobile version of the Quick Menu */

/* Quick Menu Style */
[data-component="quick-menu"] {

}

/* Quick Menu Buttons Style */
[data-component="quick-menu"] span {

}

/* Quick Menu Buttons Style on Hover */
[data-component="quick-menu"] span:hover {

}

/* Quick Menu Buttons Icon Style */
[data-component="quick-menu"] > span > .fa {

}

/**
 * ===========================
 * Range Styling
 * ===========================
**/

/* Use the background property to set a color for these */
input[type=range]:focus::-webkit-slider-runnable-track {

}

input[type=range]::-webkit-slider-runnable-track {

}

input[type=range]:focus::-ms-fill-upper {

}

input[type=range]:focus::-ms-fill-lower {

}

input[type=range]::-moz-range-track {

}

input[type=range]::-ms-fill-lower {

}

input[type=range]::-ms-fill-upper {

}

/** Medium Screens, Phablets (601px) **/
@media screen and (min-width: 37.56255em) {
	/* Styles for the desktop version of the Quick Menu */

	/* Quick Menu Style */
	[data-component="quick-menu"] {

	}

	/* Quick Menu Buttons Style */
	[data-component="quick-menu"] span {

	}

	/* Quick Menu Buttons Style on Hover */
	[data-component="quick-menu"] span:hover {

	}
}

/** Medium Devices, Tablets (992px)**/
@media screen and (min-width: 62em) {

}

/** HD Screen, Large Devices, Wide Screens, Desktop (1200px) **/
@media screen and (min-width: 75em) {

}

/** Full HD Screen, Large Devices, Wide Screens, Large Desktops (1920px) **/
@media screen and (min-width: 120em) {

}

/** Retina Screen , Large Devices, Wide Screens(2560px) **/
@media screen and (min-width: 160em) {

}

/** 4k Screens, Large Devices, Wide Screens (3840px) **/
@media screen and (min-width: 240em) {

}

/** 5k Screens, Large Devices, Wide Screens (5000px) **/
@media screen and (min-width: 312.5em) {

}

/** 8k Screens, Large Devices, Wide Screens (8000px) **/
@media screen and (min-width: 500em) {

}

#intro-screen {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: grid;
    place-items: center;
    background: #000 url('../assets/images/BlackSolid.jpg') center / cover no-repeat;
}

#intro-screen.loading-menu #intro-fullscreen-toggle,
#intro-screen.loading-menu #intro-fullscreen-arrow { display: none; }

#intro-logo {
    width: min(60vw, 640px);
    max-height: 60vh;
    object-fit: contain;
    opacity: 0;
}

#entry-screen[hidden] { display: none; }
#intro-fullscreen-arrow[hidden] { display: none; }
.intro-copy { display: block; width: min(820px, calc(100vw - 48px)); }
#intro-fullscreen-advice { display: block; font-size: clamp(26px, 3vw, 46px); font-weight: 400; line-height: 1.25; }
.intro-menu-advice { display: block; max-width: 720px; margin: 22px auto 0; font-size: clamp(18px, 1.8vw, 24px); font-weight: 400; line-height: 1.4; color: #d6d2ca; }
.intro-menu-touch { display: none; }
@media (hover: none) {
    .intro-menu-mouse { display: none; }
    .intro-menu-touch { display: inline; }
}
.intro-continue { display: block; margin-top: 30px; font-size: clamp(19px, 1.8vw, 25px); font-weight: 400; line-height: 1.4; opacity: .7; transform: translateY(14px); animation: intro-continue-pulse 3.6s ease-in-out infinite; }
@keyframes intro-continue-pulse {
    0%, 100% { opacity: .9; }
    50% { opacity: .2; }
}
@media (prefers-reduced-motion: reduce) {
    .intro-continue { animation: none; }
}
.intro-menu-arrow, #intro-fullscreen-arrow { position: fixed; top: 82px; right: 48px; width: clamp(180px, 24vw, 300px); height: auto; z-index: 10001; pointer-events: none; overflow: visible; }
#intro-fullscreen-arrow path { fill: none; stroke: var(--story-control-gold); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
@media (max-height: 420px) {
    #entry-screen { padding-top: 75px !important; }
    .intro-menu-arrow, #intro-fullscreen-arrow { width: 150px; }
}

#entry-screen {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    max-width: none;
    margin: 0;
    padding: 1.5rem;
    border: 0;
    border-radius: 0;
    background: transparent;
    color: #fff;
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-weight: 600;
    font-size: clamp(1.25rem, 3vw, 2rem);
    cursor: pointer;
    opacity: 1;
}

main-screen {
    isolation: isolate;
    overflow: hidden;
}

/* The menu master has baked-in side bars (130 px on each side at 4096 px). */
#menu-video {
    position: absolute;
    top: 0; left: -3.45%;
    width: 106.9%; max-width: none;
    height: 100%;
    object-fit: cover;
    z-index: 0;
    pointer-events: none;
}

main-screen {
    --menu-inset: max(3.5vw, 20px, env(safe-area-inset-left));
    --menu-ink: #f2e5cd;
}
#monogatari main-screen .menu-title {
    position: absolute; z-index: 1; pointer-events: none;
    left: var(--menu-inset); top: max(2.8vh, env(safe-area-inset-top));
    color: var(--menu-ink); text-align: left;
}
#monogatari .menu-title h1 {
    margin: 0; font: 500 clamp(54px, min(11.4vw, 17vh), 216px)/.84 'Cormorant Garamond', Georgia, serif;
    letter-spacing: -.045em; color: #e8d6b3; opacity: .72;
    background: linear-gradient(155deg, #b7ae98, #edd9b5 74%);
    background-clip: text; -webkit-background-clip: text; -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 1px 6px rgb(0 0 0 / 22%));
}
#monogatari .menu-title p {
    margin: .45em 0 0; font: italic 500 clamp(24px, min(4vw, 6vh), 72px)/1 'Cormorant Garamond', Georgia, serif;
    text-shadow: 0 1px 5px #30291f;
}
#monogatari main-screen main-menu {
    z-index: 1; left: max(7vw, 32px, env(safe-area-inset-left)); right: auto; top: auto; bottom: max(9vh, 28px, env(safe-area-inset-bottom));
    align-items: flex-start; width: max-content; max-width: 85%; max-height: 48%; overflow-y: auto;
    background: transparent; padding: 0; margin: 0;
}
#monogatari main-menu button {
    flex: none; width: auto; margin: 0; padding: .12em .35em .12em 0;
    border: 0; border-radius: 0; box-shadow: none; background: transparent; color: var(--menu-ink);
    font: 600 clamp(24px, min(2.5vw, 4.4vh), 44px)/1.12 'Cormorant Garamond', Georgia, serif;
    text-align: left; text-shadow: 0 1px 5px #17130e, 0 0 14px #201b14;
}
#monogatari main-menu button:hover, #monogatari main-menu button:focus-visible {
    color: white; text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: .15em;
}
#menu-volume-control {
    position: absolute; z-index: 2; right: max(3vw, 18px, env(safe-area-inset-right));
    bottom: max(5vh, 18px, env(safe-area-inset-bottom)); display: grid;
    grid-template-columns: 44px minmax(72px, 9vw) auto; align-items: center; gap: 0 10px;
    color: var(--menu-ink); font-size: 20px; text-shadow: 0 1px 5px #17130e;
}
#menu-volume-control label { grid-column: 2 / -1; text-align: left; }
#menu-volume-value { min-width: 4ch; font-variant-numeric: tabular-nums; }
#menu-volume {
    appearance: none; -webkit-appearance: none; width: 100%; height: 36px; padding: 0; margin: 0;
    border: 0; background: transparent; cursor: pointer; color: var(--story-control-gold);
}
#menu-mute-toggle {
    grid-column: 1; grid-row: 1 / 3; display: grid; place-items: center;
    width: 44px; height: 44px; margin: 0; padding: 8px;
    border: 1px solid #ac9e83; border-radius: 12px; background: rgba(8,10,15,.8);
    color: var(--story-control-gold); cursor: pointer;
}
#menu-mute-toggle svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
#menu-mute-toggle .menu-volume-cross { display: none; }
#menu-mute-toggle[aria-pressed="true"] .menu-volume-cross { display: initial; }
#menu-mute-toggle[aria-pressed="true"] .menu-volume-waves { display: none; }
#menu-mute-toggle[aria-pressed="true"] { color: #e8caa0; border-color: currentColor; }
#menu-mute-toggle:focus-visible, :is(#menu-volume, #monogatari settings-screen input[type="range"]):focus-visible { outline: 2px solid #e8caa0; outline-offset: 4px; }

:is(#menu-volume, #monogatari settings-screen input[type="range"])::-webkit-slider-runnable-track {
    height: 4px; border-radius: 6px;
    background: linear-gradient(to right, currentColor var(--menu-volume-fill, 80%), #565049 var(--menu-volume-fill, 80%));
}
:is(#menu-volume, #monogatari settings-screen input[type="range"])::-moz-range-track { height: 4px; background: #565049; border-radius: 6px; }
:is(#menu-volume, #monogatari settings-screen input[type="range"])::-moz-range-progress { height: 4px; background: currentColor; }
:is(#menu-volume, #monogatari settings-screen input[type="range"])::-webkit-slider-thumb {
    appearance: none; -webkit-appearance: none; width: 16px; height: 16px; margin-top: -6px;
    border: 1px solid #f0e0c2; border-radius: 50%; background: var(--story-control-gold);
}
:is(#menu-volume, #monogatari settings-screen input[type="range"])::-moz-range-thumb { width: 14px; height: 14px; border: 1px solid #f0e0c2; border-radius: 50%; background: var(--story-control-gold); }
@media (max-width: 620px) and (orientation: portrait) {
    #menu-volume-control { left: var(--menu-inset); right: auto; bottom: max(12px, env(safe-area-inset-bottom)); font-size: 17px; }
    #monogatari main-screen main-menu { bottom: calc(max(20px, env(safe-area-inset-bottom)) + 85px); }
}
@media (max-height: 480px) and (orientation: landscape) {
    #monogatari main-screen main-menu { display: grid; grid-template-columns: repeat(2, max-content); column-gap: 1.2em; }
}
/* Выезжающее игровое меню вместо постоянной нижней полосы. */
#story-movie[hidden] { display: none !important; }
#story-movie {
    position: absolute;
    inset: 0;
    z-index: 6;
    background: #000;
}
/* Keep the story bars black above both the movie and its white exit overlay. */
#story-movie::before, #story-movie::after {
    content: ''; position: absolute; left: 0; right: 0;
    height: var(--cinema-bar-height, 13%); background: #000;
    z-index: 3; pointer-events: none;
}
#story-movie::before { top: 0; }
#story-movie::after { bottom: 0; }
#story-movie-player {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}
#story-movie [hidden] { display: none !important; }
#story-developer-menu[hidden] { display: none !important; }
#story-developer-menu {
    position: absolute;
    inset: max(20px, env(safe-area-inset-top)) auto auto 50%;
    transform: translateX(-50%);
    width: min(540px, calc(100% - 40px));
    max-height: calc(100dvh - 40px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
    overflow-y: auto;
    box-sizing: border-box;
    padding: 20px;
    z-index: 80;
    border: 1px solid rgba(235, 223, 196, .6);
    border-radius: 12px;
    background: rgba(8, 10, 15, .98);
    color: #fff;
    box-shadow: 0 0 0 100vmax rgba(0, 0, 0, .65);
}
#story-developer-menu h2 { margin: 0 0 12px; font-size: 32px; }
#story-developer-menu button {
    display: block;
    width: 100%;
    min-height: 44px;
    margin: 6px 0;
    padding: 10px 14px;
    font-size: 25px;
    text-align: left;
    border: 1px solid rgba(235, 223, 196, .3);
    border-radius: 6px;
    background: rgba(255, 255, 255, .06);
    color: #fff;
}
.story-scene-links {
    border-top: 1px solid rgba(235, 223, 196, .3);
    margin-top: 8px;
    padding-top: 10px;
}
.story-scene-links strong {
    display: block;
    padding: 4px 14px;
    font-size: 23px;
}
.intro-menu-gear,
.story-scene #monogatari game-screen #story-menu-toggle {
    position: absolute;
    top: max(12px, env(safe-area-inset-top));
    left: max(12px, env(safe-area-inset-left));
    z-index: 51;
    display: grid;
    place-items: center;
    width: 48px;
    height: 48px;
    min-width: 48px;
    padding: 0;
    margin: 0;
    border: 1px solid rgba(235, 223, 196, .55);
    border-radius: 12px;
    background: rgba(8, 10, 15, .86);
    color: var(--story-control-gold);
    font-family: system-ui, sans-serif;
    font-size: 30px;
    line-height: 1;
    touch-action: manipulation;
}
.story-scene #monogatari game-screen quick-menu {
    display: flex !important;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    position: absolute;
    top: calc(max(12px, env(safe-area-inset-top)) + 60px);
    left: max(12px, env(safe-area-inset-left));
    right: auto;
    bottom: auto;
    width: min(280px, calc(100vw - 24px - env(safe-area-inset-left) - env(safe-area-inset-right)));
    height: auto;
    max-height: calc(100vh - 100px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
    max-height: calc(100dvh - 100px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
    box-sizing: border-box;
    overflow-y: auto;
    padding: 10px;
    gap: 4px;
    border: 1px solid rgba(235, 223, 196, .4);
    border-radius: 12px;
    background: rgba(8, 10, 15, .96);
    z-index: 50;
    transform: translateX(calc(-100% - 32px - env(safe-area-inset-left)));
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: transform 220ms ease, opacity 220ms ease, visibility 0s linear 220ms;
}
.story-scene #monogatari game-screen.story-menu-open quick-menu {
    transition: transform 220ms ease, opacity 220ms ease, visibility 0s linear 0s;
    transform: translateX(0);
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}
.story-scene #monogatari game-screen quick-menu button {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    flex-shrink: 0;
    gap: 12px;
    width: 100%;
    min-height: 44px;
    margin: 0;
    padding: 10px 14px;
    border: 1px solid transparent;
    border-radius: 6px;
    font-size: 25px;
    text-align: left;
}
.story-scene #monogatari game-screen quick-menu button [data-string] {
    display: inline;
}
.story-scene #monogatari game-screen quick-menu button:hover,
.story-scene #monogatari game-screen quick-menu button:focus-visible {
    border: 1px solid rgba(235, 223, 196, .55);
    background: rgba(255, 255, 255, .08);
}
.story-scene #monogatari game-screen text-box {
    bottom: calc(18px + env(safe-area-inset-bottom));
}
@media (prefers-reduced-motion: reduce) {
    .story-scene #monogatari game-screen quick-menu { transition: none !important; }
}

/* Своя кнопка fullscreen для запуска отдельным сайтом. */
#monogatari #fullscreen-toggle,
#intro-fullscreen-toggle {
    position: fixed;
    top: max(12px, env(safe-area-inset-top));
    right: max(12px, env(safe-area-inset-right));
    z-index: 60;
    display: grid;
    place-items: center;
    width: 48px;
    height: 48px;
    min-width: 48px;
    margin: 0;
    padding: 0;
    border: 1px solid rgba(235, 223, 196, .55);
    border-radius: 12px;
    background: rgba(8, 10, 15, .86);
    color: var(--story-control-gold);
    font-family: system-ui, sans-serif;
    font-size: 32px;
    line-height: 1;
    touch-action: manipulation;
}
#intro-fullscreen-toggle { z-index: 10002; }
#fullscreen-message {
    position: fixed;
    top: calc(max(12px, env(safe-area-inset-top)) + 60px);
    right: max(12px, env(safe-area-inset-right));
    z-index: 10003;
    box-sizing: border-box;
    width: min(360px, calc(100vw - 32px));
    padding: 16px;
    border-radius: 10px;
    background: rgba(8, 10, 15, .96);
    color: #fff;
    font: 21px/1.4 'Cormorant Garamond', Georgia, serif;
}
html:fullscreen, html:-webkit-full-screen { background: #000; }

#monogatari :is(settings-screen, help-screen, save-screen, load-screen) {
    --text-color: #eee6d7;
    --main-color: #39332b;
    color-scheme: dark;
    color: var(--text-color);
    background: radial-gradient(ellipse at top left, #27231e, #141311 55%, #0e0e0d);
}
#monogatari :is(settings-screen, help-screen, save-screen, load-screen) :is(h1, h2, h3, h4) { color: #ead7b1; }
#monogatari :is(settings-screen, help-screen, save-screen, load-screen) :is(p, label, [data-string]) { color: inherit; }
#monogatari :is(settings-screen, help-screen) :is(.settings-group, .help__section) {
    color: #eee6d7; background: #1d1b18; border: 1px solid #4b4336; border-radius: 10px;
}
#monogatari settings-screen select, #monogatari settings-screen option {
    background: #211e19; color: #f2eadb;
}
#monogatari settings-screen output { color: var(--story-control-gold); }
#monogatari help-screen [data-content="symbols"] [data-content="shortcut"],
#monogatari :is(settings-screen, help-screen, save-screen, load-screen) [data-action="back"] {
    color: #ead7b1; background: #302c26; border: 1px solid #736650;
}
#monogatari settings-screen input[type="range"] {
    appearance: none; -webkit-appearance: none; height: 44px;
    padding: 0; border: 0; background: transparent; color: var(--story-control-gold); cursor: pointer;
}
#monogatari settings-screen .story-volume-controls {
    width: min(440px, 100%);
    padding: 0 12px;
    box-sizing: border-box;
    text-align: left;
}
#monogatari settings-screen .story-volume-controls label {
    display: block;
    margin-top: 18px;
    font-size: 25px;
}
#monogatari settings-screen .story-volume-row {
    display: flex;
    align-items: center;
    gap: 14px;
}
#monogatari settings-screen .story-volume-row input {
    flex: 1;
    min-width: 0;
    min-height: 44px;
    margin: 0;
}
#monogatari settings-screen .story-volume-row output {
    min-width: 4ch;
    text-align: right;
    font-size: 23px;
}

#intro-screen:not([data-step="menu-guide"]) #intro-fullscreen-toggle,
#intro-screen:not([data-step="menu-guide"]) #intro-fullscreen-arrow,
#device-picker[hidden], #iphone-guide[hidden] { display: none; }
#device-picker, #iphone-guide {
    box-sizing: border-box; width: 100%; text-align: center; color: #f5f1ea;
    font-family: 'Cormorant Garamond', Georgia, serif;
}
#device-picker { padding: 1rem; }
#device-picker h1, #iphone-title { margin: 0; font: 500 clamp(32px, 5vw, 76px)/1.05 'Cormorant Garamond', Georgia, serif; }
#device-picker .device-options {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: clamp(32px, 9vw, 144px);
    width: min(84%, 1120px);
    margin: clamp(32px, 9vh, 100px) auto 0;
}
#device-picker .device-options button {
    box-sizing: border-box;
    width: 100%;
    min-width: 0;
    min-height: clamp(84px, 15vh, 156px);
    padding: .45em .7em;
    font-size: clamp(32px, 3.3vw, 54px);
    background: linear-gradient(160deg, #191714, #0c0c0b);
}
#device-picker .device-options button:focus-visible {
    outline: 2px solid #ebd6ae;
    outline-offset: 5px;
}
@media (hover: hover) {
    #device-picker .device-options button:hover { background: #27231c; border-color: #ebd6ae; }
}
@media (max-width: 620px) and (orientation: portrait) {
    #device-picker .device-options {
        grid-template-columns: 1fr;
        width: min(90%, 390px);
        gap: clamp(16px, 3vh, 26px);
        margin-top: clamp(24px, 6vh, 54px);
    }
    #device-picker .device-options button { min-height: clamp(72px, 12vh, 104px); }
}
.device-options button, #iphone-continue {
    width: auto; min-width: 7em; min-height: 44px; margin: 0; padding: .35em 1em;
    border: 1px solid #bdab88; border-radius: 5px; color: #f5f1ea; background: #111;
    font: 500 clamp(20px, 2vw, 30px)/1.25 'Cormorant Garamond', Georgia, serif; cursor: pointer;
}
#iphone-guide { height: 100%; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
.iphone-guide-content {
    box-sizing: border-box; min-height: 100%; max-width: 1440px; margin: auto;
    display: flex; flex-direction: column; justify-content: center; align-items: center;
    gap: clamp(12px, 3vh, 32px); padding: max(20px, env(safe-area-inset-top)) max(24px, env(safe-area-inset-right)) max(20px, env(safe-area-inset-bottom)) max(24px, env(safe-area-inset-left));
}
#iphone-guide p { margin: 0; font-size: clamp(18px, 2vw, 32px); line-height: 1.2; }
#iphone-guide ol { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 1.6rem; width: 100%; margin: .5rem 0; padding: 0; list-style: none; counter-reset: guide; }
#iphone-guide li { position: relative; counter-increment: guide; }
#iphone-guide li h2::before { content: counter(guide) ". "; }
#iphone-guide li h2 { font: 600 clamp(20px, 2.3vw, 36px)/1.1 'Cormorant Garamond', Georgia, serif; margin: .45em 0 .3em; }
#iphone-guide li p { font-size: clamp(17px, 1.7vw, 26px); }
#iphone-guide li svg, .intro-fingerprint { fill: none; stroke: var(--story-control-gold); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
#iphone-guide li svg { width: clamp(44px, 6vw, 90px); height: auto; }
#iphone-guide li:not(:last-child)::after { content: "→"; position: absolute; top: .1em; right: -1em; color: #d7c7a5; font-size: clamp(28px, 4vw, 56px); }
.intro-fingerprint { width: 1.15em; height: 1.3em; margin-right: .45em; vertical-align: -.28em; }
@media (max-width: 620px) {
    #iphone-guide ol { grid-template-columns: 1fr; text-align: left; gap: 1rem; }
    #iphone-guide li { padding-left: 60px; }
    #iphone-guide li svg { position: absolute; top: 0; left: 0; }
    #iphone-guide li h2 { margin-top: 0; }
    #iphone-guide li::after { display: none; }
}


#entry-screen { overflow-y: auto; }
#entry-screen .intro-copy {
    width: min(1180px, 92%); margin: auto; display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start;
    gap: clamp(28px, 9vh, 96px) clamp(18px, 9vw, 160px);
}
#entry-screen .intro-menu-advice, #entry-screen #intro-fullscreen-advice {
    grid-row: 1; width: 100%; max-width: 23ch; justify-self: center; margin: 0; text-align: center; text-wrap: balance;
    font-size: clamp(21px, 2.5vw, 38px); line-height: 1.2;
}
#entry-screen .intro-menu-advice { grid-column: 1; }
#entry-screen #intro-fullscreen-advice { grid-column: 2; }
.intro-menu-arrow {
    display: block; left: 48px; right: auto; transform: scaleX(-1);
    fill: none; stroke: var(--story-control-gold); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}
#entry-screen .intro-continue {
    grid-column: 1 / -1; margin: 0; transform: translateY(clamp(24px, 6vh, 68px)); font-size: clamp(26px, 3.2vw, 48px);
}
@media (max-width: 620px) {
    #entry-screen .intro-copy { width: 100%; column-gap: 12px; }
    #entry-screen .intro-menu-advice, #entry-screen #intro-fullscreen-advice { font-size: clamp(18px, 4.5vw, 24px); }
    .intro-menu-arrow, #intro-fullscreen-arrow { width: 88px; }
}
@media (max-height: 450px) {
    #intro-screen #entry-screen { padding: 18px 6vw !important; }
    #entry-screen .intro-copy { row-gap: 20px; }
    .intro-menu-arrow, #intro-fullscreen-arrow { width: 72px; top: 52px; }
}

#intro-menu-edge { display: none; }
#intro-screen[data-step="menu-guide"] #intro-menu-edge {
    display: block; position: absolute; inset: 0 0 auto; z-index: 10001;
    width: 100%; height: clamp(48px, 13vh, 128px); margin: 0; padding: 0;
    background: transparent; border: 0; border-radius: 0; box-shadow: none;
}
#intro-menu-edge .intro-menu-gear {
    pointer-events: none; opacity: 0;
    transform: translateY(calc(-100% - 50px));
    transition: transform 220ms ease, opacity 220ms ease;
}
#intro-screen.preview-gear-visible .intro-menu-gear {
    opacity: 1; transform: translateY(0);
}
@media (prefers-reduced-motion: reduce) {
    #intro-menu-edge .intro-menu-gear { transition: none; }
}

/* Keep the engine's history and save actions intact while styling their surfaces. */
#monogatari quick-menu button[string="Hide"] { display: none !important; }
#monogatari :is(save-screen, load-screen) save-slot {
    background: #211f1b; color: #eee6d7; border: 1px solid #5a5041; border-radius: 10px;
}
#monogatari save-slot [data-content="background"] { border-radius: 9px 9px 0 0; }
#monogatari save-slot figcaption { color: inherit; }
#monogatari save-slot .badge { background: #24211d; color: #ead7b1; border-radius: 8px 0; }
#monogatari save-slot [data-delete] { color: #ead7b1; background: #302c26; border: 1px solid #736650; }
#monogatari save-screen input[data-content="slot-name"], alert-modal input[data-content="context"] {
    background: #151412; color: #f2eadb; border: 1px solid #736650; border-radius: 6px;
    padding: .45em .7em; font-family: 'Cormorant Garamond', Georgia, serif;
}
#monogatari save-screen input::placeholder { color: #c7bcab; opacity: 1; }
:is(dialog-log, alert-modal).modal { background: rgb(6 6 5 / 80%); }
:is(dialog-log, alert-modal).modal .modal__content {
    background: #1d1b18; color: #eee6d7; border: 1px solid #665944; border-radius: 10px;
    font-family: 'Cormorant Garamond', Georgia, serif;
}
dialog-log.modal .modal__content { display: flex; flex-direction: column; align-items: center; }
dialog-log.modal .modal__content [data-content="log"] { box-sizing: border-box; width: 100%; min-height: 0; flex: 1; }
dialog-log.modal .modal__content [data-content="log"] [data-spoke] { border-color: #494136; }
dialog-log.modal .modal__content [data-content="log"] [data-spoke=narrator] > p { color: #eee6d7; }
dialog-log.modal [data-content="log"] .named > span { color: #ead7b1; }
#monogatari save-screen [data-action="save"], :is(dialog-log, alert-modal).modal button {
    background: #302c26; color: #ead7b1; border: 1px solid #736650; border-radius: 6px;
    font-family: 'Cormorant Garamond', Georgia, serif;
}
dialog-log.modal button { flex: none; margin: .6em; }
#monogatari :is(save-screen, load-screen) :is(button, save-slot, input):focus-visible,
:is(dialog-log, alert-modal).modal :is(button, input):focus-visible {
    outline: 2px solid var(--story-control-gold); outline-offset: 2px;
}

#monogatari main-menu button, .story-scene #monogatari game-screen quick-menu button {
    color: var(--story-control-gold);
}
#monogatari main-menu button:is(:hover, :focus-visible),
.story-scene #monogatari game-screen quick-menu button:is(:hover, :focus-visible) { color: #fff2da; }

#monogatari :is(save-screen, load-screen) slot-container {
    display: grid; grid-template-columns: repeat(2, minmax(0, 1fr));
    box-sizing: border-box; width: min(100%, 64rem); margin: 1rem auto;
    padding: 0 1rem; gap: 1.2rem; align-items: stretch;
}
#monogatari :is(save-screen, load-screen) :is(save-slot, .empty-save-cell) {
    box-sizing: border-box; width: 100%; min-width: 0; min-height: clamp(11rem, 25vh, 17rem); margin: 0;
}
#monogatari :is(save-screen, load-screen) save-slot [data-content="background"] { flex: 1; }
@media (max-width: 540px) and (orientation: portrait) {
    #monogatari :is(save-screen, load-screen) slot-container { grid-template-columns: 1fr; }
}
#monogatari .empty-save-cell {
    display: grid; align-content: center; gap: .35em; justify-items: center;
    font: 600 1.35rem/1.2 'Cormorant Garamond', Georgia, serif; color: #ead7b1;
    border: 1px dashed #74674f; border-radius: 10px; background: #1d1b18;
}
#monogatari .empty-save-cell small { font-size: 1rem; color: #c8bead; }
#monogatari .empty-save-cell:disabled { opacity: .8; cursor: default; }
#monogatari .empty-save-cell:enabled:hover { border-color: var(--story-control-gold); background: #302b23; }
#monogatari save-slot[data-cell]::before {
    content: "Ячейка " attr(data-cell); display: block; padding: .35em .65em; color: #ead7b1;
}
#monogatari save-slot[data-cell] .badge { top: 2.2em; }
#monogatari dialog-log.modal [data-content="log"] [data-spoke] > p {
    font-size: 1.55rem; line-height: 1.32;
}
#monogatari dialog-log.modal [data-content="log"] [data-spoke] span {
    font-size: 1.25rem; line-height: 1.25;
}
