/* @font-face {
    font-family: "Quattrocento";
    font-style: normal;
    src: url("Quattrocento-Regular.ttf");
}

@font-face {
    font-family: "Quattrocento";
    font-weight: bold;
    src: url("Quattrocento-Bold.ttf");
}

@font-face {
    font-family: "Open Sans";
    font-style: normal;
    src: url("OpenSans-VariableFont_wdth,wght.ttf");
}

@font-face {
    font-family: "Open Sans";
    font-style: italic;
    src: url("OpenSans-Italic-VariableFont_wdth,wght.ttf");
} */

@font-face {
    font-family: "EB Garamond";
    font-style: normal;
    src: url("../fonts/EBGaramond12-Regular.otf");
}
@font-face {
    font-family: "EB Garamond";
    font-style: italic;
    src: url("../fonts/EBGaramond12-Italic.otf");
}

/* @font-face {
    font-family: "EB Garamond";
    font-style: normal;
    font-weight: normal;
    src: url("../fonts/EBGaramond-Regular.otf") format("opentype");
}

@font-face {
    font-family: "EB Garamond";
    font-style:italic;
    font-weight: normal;
    src: url("../fonts/EBGaramond-Italic.otf") format("opentype");
} */

/* @font-face {
    font-family: "EB Garamond";
    font-style: normal;
    font-weight: bold;
    src: url("../fonts/EBGaramond-Bold.otf") format("opentype");
}

@font-face {
    font-family: "EB Garamond";
    font-style: italic;
    font-weight: bold;
    src: url("../fonts/EBGaramond-BoldItalic.otf") format("opentype");
} */

  html {
    font-family: 'EB Garamond', sans-serif;
    /* font-kerning: normal; */
    /* font-variant-ligatures: common-ligatures historical-ligatures; */
    /* font-variant-numeric: oldstyle-nums; */
    font-feature-settings: 'kern' on, 'liga' on, 'onum' on, 'dlig' on, 'clig' on, 'calt' on, 'hlig' off, 'swsh' on, 'locl' off;
    -webkit-font-smoothing: antialiased;
  }

sup {
    font-feature-settings: "sup" on;
    /* vertical-align: inherit; */
    font-size: inherit;
}

/* sub {
    font-feature-settings: "subs" on;
} */

double {
    font-size: 2rem;
    vertical-align: -10%;
    opacity: 0.8;
}

double.separator {
    display: block;
    margin: 2rem auto 3rem auto;
}

html, body {
    height: 100%;
    margin: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

body {
    overflow: hidden;
    background-image: url('../images/mat.png');
    background-position: center center;
    background-size: cover;
    background-repeat: no-repeat;
}

body.switched {
    transition: color 0.6s, background-color 0.6s;
}

:root {
    --book-width: 1421px;
    --book-height: 799px;
    --book-scale: 1;
    --page-line-count: 25;
    --book-page-top: 4.00%;
    --book-page-bottom: 19%;
    --book-page-height: calc(100% - var(--book-page-top) - var(--book-page-bottom));
    --book-left-page-left: 14%;
    --book-left-page-width: 34.9%;
    --book-right-page-right: 14%;
    --book-right-page-width: 34%;
    --book-page-perspective: 3200px;
    --book-left-page-transform: none;
    --book-right-page-transform: none;
    --story-line-height: calc((var(--book-height) * 0.77) / var(--page-line-count));
    --story-font-size: calc(var(--story-line-height) / 1.45);
    font-size: calc(var(--book-height)/(34 * 1.5));
    --img-aspect-ratio: 1.779;
    --aspect-ratio: min(var(--viewport-aspect-ratio), var(--img-aspect-ratio));  
}

h1 {
    font-size: 2rem;
    margin-bottom: 0.8rem;
    text-align: center;
    text-transform:uppercase;
    font-weight: normal;
}

h2 {
    font-size: 1.2rem;
    text-align: center;
    font-weight: normal;
}

h2.chapter-heading {
    font-style: italic;
    margin: 2rem auto 3rem auto;
}

h3 {
    font-size: 1.2rem;
    text-align: center;
    font-weight: normal;
}

.header {
    padding-top: 3rem;
    padding-bottom: 3rem;
}

/*
  Built-in class:
    # author: Name
*/
.byline {
    font-feature-settings: "smcp";
}

.subtitle {
    font-feature-settings: "scmp" off;
}

.separator {
    text-align: center;
}

/* 
  Enables <iframe> support work on itch.io when using mobile iOS
*/
.outerContainer {
    position: absolute;
    display: block;
    display: none;
    margin: 0;
    padding: 0;
    -webkit-overflow-scrolling: touch;
    overflow: scroll;
    overflow-x: hidden;
    height: 100%;
    width: 100%;
    top: 0;
    left: 0;
    margin-top: 24px;
    background-size: cover;
    background-repeat: no-repeat;
}

@media screen and (max-width: 980px) {
    .outerContainer {
        margin-top: 44px;
        background-size: cover;
        background-repeat: no-repeat;
    }
}

p, #ruler,#indent {
    font-size: 1.2rem;
    line-height: 1.45;
    color: rgba(0,0,0,0.9);
    margin-block-end: 0;
    margin-block-start: 0;
    /* text-indent: 1.5em; */
    /* text-align: justify; */
    /* hyphens: manual; */
}

a {
    transition: color 0.6s;
    color: #333;
    font-style: italic;
    text-decoration-thickness: 1px;
}

a:hover {
    color: black;
    transition: color 0.1s;
}

strong {
    color: black;
    font-weight: bold;
}

img {
    display: block;
    margin: 0 auto;
    max-width: 100%;
}

.drop-cap {
    font-size: 280%;
    line-height: 1;
    margin: 0;
    padding: 0;
    text-transform: uppercase;
}

.story-drop-cap {
    position: absolute;
    left: 0;
    top: 0;
    font-size: calc(2 * 1.45em);
    line-height: 1;
}

.drop-quote {
    font-size: 180%;
    line-height: 1;
    margin: 0;
    padding: 0;
}


cap {
    font-feature-settings: "smcp";
}

.container .hide {
    opacity: 0.0;
}

.container .invisible {
    display: none;
}

.container > *, .container > p > * {
    opacity: 1.0;
    transition: opacity 0.5s;
}


/*
  Class applied to all choices
  (Will always appear inside <p> element by default.)
*/
li.choice {
    text-align: center;
    line-height: 1.7rem;
}

ol.choice {
    position: relative;
    /* list-style-position: inside; To make sure the number is inside the li */
    counter-reset: item; /* Set a counter */    
    padding-inline-start: 3rem;
}

/* ol.choice li::before {
    position: absolute;
    top: 0;
    left: 0;
    content: "............................................................................";
    overflow: hidden;
    white-space: nowrap;
    text-indent: 1.5em;
} */

/* 
  Class applied to first choice
*/
:not(.choice)+.choice {
    padding-top: 1rem;
}

/*
  Class applied to choice links
*/
.choice a {
    font-size: 1.2rem;
}

/* 
  Built-in class:
    The End # CLASS: end
*/
.end {
    text-align: center;
    font-weight: bold;
    color: black;
    padding-top: 2rem;
    padding-bottom: 2rem;
}

#controls {
    z-index: 4;
    text-align: center;
    position: absolute;
    right: 0;
    left: 0;
    top: 0.45rem;
    user-select: none;
    transition: color 0.6s, background 0.6s;
    font-size: 0.82rem;
}

#controls [disabled] {
    color: #8f806a;
}

#controls input[type=range] {
    vertical-align: middle;
    -webkit-appearance: none;
    appearance: none;
    width: 5rem;
    cursor: pointer;
    outline: none;
    height: 0.5rem;
    background-color: transparent;
    box-sizing: border-box;
    border: 1px solid black;
    border-radius: 0.25rem;
    overflow: hidden;
}

#controls input::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    height: 0.5rem;
    width: 0.5rem;
    border-radius: 0.25rem;
    background-color: rgba(0,0,0,0.9);
    border: none;
    /*  slider progress trick  */
    box-shadow: -407px 0 0 400px rgba(0,0,0,0.3);
}

#controls input::-webkit-runnable-track {
    -webkit-appearance: none;
    appearance: none;
    height: 0.5rem;
    border-radius: 0.25rem;
}

#controls>a:not(:last-of-type):after, #controls>span::after {
    content: " | ";
}

#book {
    position: fixed;
    left: 50%;
    top: 50%;
    width: var(--book-width);
    height: var(--book-height);
    background-image: url('../images/book_detailed.png');
    background-size: contain; /* Changed from cover to contain */
    background-position: center;
    background-repeat: no-repeat; /* Prevents repeating the image when aspect ratio doesn't match */
    perspective: var(--book-page-perspective);
    perspective-origin: 50% 50%;
    transform: translate(-50%, -50%) scale(var(--book-scale));
    transform-origin: center center;
}

#page_left, #page_right {
    position: absolute;
    top: var(--book-page-top);
    bottom: var(--book-page-bottom);
    width: var(--book-right-page-width);
    box-sizing: border-box;
    padding: 0 3rem 1rem 1rem;
    /* border: 1px dotted rgba(200,200,200,1); */
    overflow: visible;
    opacity: 0.95;
    mix-blend-mode: darken;
    transform-style: preserve-3d;
    backface-visibility: hidden;
    will-change: transform;
}

#story {
    overflow: visible !important;
    box-sizing: border-box;
    overflow-anchor: none;
    text-align: justify;
    text-justify: inter-word;
    margin-bottom: 0;
    font-size: var(--story-font-size);
    line-height: var(--story-line-height);
    will-change: transform;
    transform: translateY(0);
}

#paragraphs {
    position: relative;
    box-sizing: border-box;
    overflow: visible !important;
    overflow-anchor: none;
    margin: 0;
    padding: 0;
    transition: opacity 220ms ease;
}

#paragraphs.story-history-fading {
    opacity: 0;
}

.story-block-archiving {
    opacity: 0;
    transition: opacity 320ms ease;
}

.story-image-block {
    box-sizing: border-box;
    margin: 0 auto;
    padding: 0;
    overflow: hidden;
    background: rgba(218, 188, 130, 0.18);
    background-blend-mode: multiply;
}

.story-image-block img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
    mix-blend-mode: color-burn;
    /* filter: grayscale(0.72) sepia(0.18) contrast(1.22) brightness(0.96); */
    opacity: 0.94;
}

.story-image-landscape,
.story-image-square {
    margin-left: auto;
    margin-right: auto;
}

.story-image-portrait {
    margin-left: 0;
    margin-right: 0;
}

.story-image-pending img {
    opacity: 0;
    clip-path: polygon(0 0, 0 0, 0 0);
}

.story-image-visible img {
    opacity: 1;
    clip-path: polygon(0 0, 220% 0, 0 220%);
    transition: opacity 2000ms ease, clip-path 2000ms ease;
}

/* #story p span {
    font-feature-settings: 'kern' on, 'liga' on, 'onum' on, 'clig' on, 'hlig' on;
} */

#page_left {
    left: var(--book-left-page-left);
    width: var(--book-left-page-width);
    overflow-y: auto;
    transform: var(--book-left-page-transform);
    transform-origin: 100% 50%;
    clip-path: polygon(0.5% 0.4%, 99.7% 0, 100% 99.2%, 0 100%);
}

#page_right {
    /* background-color: rgba(200,200,200,0.5); */
    right: var(--book-right-page-right);
    width: var(--book-right-page-width);
    padding-bottom: 0;
    overflow: hidden !important;
    overflow-x: hidden !important;
    overflow-y: hidden !important;
    scroll-behavior: auto;
    overscroll-behavior: none;
    overflow-anchor: none;
    scrollbar-width: none;
    transform: var(--book-right-page-transform);
    transform-origin: 0 50%;
    clip-path: polygon(0.2% 0, 99.3% 0.5%, 100% 99.5%, 0 99.1%);
}

#page_right::-webkit-scrollbar {
    display: none;
}

#page_right *,
#page_right *::-webkit-scrollbar {
    scrollbar-width: none;
}

#page_right *::-webkit-scrollbar {
    display: none;
}

#story_scrollbar {
    position: absolute;
    top: 0;
    right: 0.35rem;
    bottom: 0;
    width: 0.22rem;
    height: 100%;
    margin: 0;
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.12);
    z-index: 12;
    pointer-events: auto;
    touch-action: none;
    cursor: pointer;
}

#story_scrollbar_thumb {
    position: absolute;
    left: 0;
    right: 0;
    top: 0;
    min-height: 1rem;
    border-radius: inherit;
    background: rgba(0, 0, 0, 0.72);
    transition: top 260ms ease, height 260ms ease;
    pointer-events: auto;
}

#story_scrollbar[data-dragging="true"] #story_scrollbar_thumb {
    transition: none;
}


/* ===== Scrollbar CSS ===== */
  /* Firefox */
  * {
    scrollbar-width: auto;
    scrollbar-color: #000000 rgba(255,255,255,0);
  }

  /* Chrome, Edge, and Safari */
  *::-webkit-scrollbar {
    width: calc(1rem/4);
  }

  *::-webkit-scrollbar-track {
    background: rgba(255,255,255,0.0);
  }

  *::-webkit-scrollbar-thumb {
    background-color: #000000;
    border-radius: calc(1rem/4/2);
    border: none;
  }

.fade-in {
    animation: fadeIn ease 1s;
    -webkit-animation: fadeIn ease 1s;
    -moz-animation: fadeIn ease 1s;
    -o-animation: fadeIn ease 1s;
    -ms-animation: fadeIn ease 1s;
}

/* Style for individual words that need to fade in */
.word.fade-in {
    animation-fill-mode: forwards;
    opacity: 0; /* Start invisible */
}

@keyframes fadeIn {
    0% {opacity:0;}
    100% {opacity:1;}
}

@-moz-keyframes fadeIn {
    0% {opacity:0;}
    100% {opacity:1;}
}

@-webkit-keyframes fadeIn {
    0% {opacity:0;}
    100% {opacity:1;}
}

@-o-keyframes fadeIn {
    0% {opacity:0;}
    100% {opacity:1;}
}

@-ms-keyframes fadeIn {
    0% {opacity:0;}
    100% {opacity:1;}
}

#versions {
    position: fixed;
    top: 0px;
    right: 12px;
    font-size: 10px;
}

#preview {
    position: absolute;
    top: 0px;
    left: 0px;
    border: 1px none red;
    background-color: #d8bf89;
    box-shadow: 2px 2px 2px rgba(0,0,0,0.3);
}

#preview p {
    text-indent: 0;
    text-align: left;
}

#ruler, #indent {
    visibility: hidden;
    position: absolute;
    top: -8000px;
    width: auto;
    display: inline;
    left: -8000px;
    text-indent: 0;
    text-align: left;
    hyphens: none;
    margin-block-end: 0;
}

#ruler i {
    font-style: italic;
}

#indent {
    text-indent: 1.5em;
}

#remark {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0.65rem;
    text-align: center;
    margin: 0 auto;
    background-color: transparent;
    line-height: 1.1;
    pointer-events: none;
}

#remark_hint {
    font-size: 0.82rem;
}

#game_legal {
    margin-top: 0.18rem;
    font-size: 0.72rem;
    color: rgba(0, 0, 0, 0.62);
}

#credits_button {
    border: 0;
    padding: 0;
    margin: 0;
    background: transparent;
    color: rgba(0, 0, 0, 0.72);
    font: inherit;
    font-style: italic;
    cursor: pointer;
    pointer-events: auto;
}

#credits_button:hover {
    color: rgba(0, 0, 0, 0.95);
}

.credits-modal {
    position: fixed;
    inset: 0;
    z-index: 1200;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 4vh 4vw;
    background: rgba(10, 7, 4, 0.52);
}

.credits-modal.visible {
    display: flex;
}

.credits-dialog {
    width: min(48rem, 92vw);
    height: min(44rem, 88vh);
    background: rgba(229, 205, 155, 0.96);
    color: rgba(24, 18, 12, 0.92);
    border: 1px solid rgba(42, 31, 18, 0.45);
    box-shadow: 0 1.2rem 3rem rgba(0, 0, 0, 0.45);
    padding: 1.2rem;
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
}

.credits-dialog-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    border-bottom: 1px solid rgba(42, 31, 18, 0.28);
    padding-bottom: 0.55rem;
}

.credits-dialog-header h2 {
    margin: 0;
    font-size: 1.35rem;
    font-style: italic;
}

#credits_close {
    border: 1px solid rgba(42, 31, 18, 0.5);
    background: rgba(255, 246, 220, 0.35);
    color: rgba(24, 18, 12, 0.9);
    font: inherit;
    padding: 0.18rem 0.7rem;
    cursor: pointer;
}

.credits-logo-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.55rem;
}

.credits-logo-row a {
    color: rgba(31, 23, 15, 0.88);
    text-decoration: none;
}

.credits-logo-row img {
    display: block;
    width: 1.3rem;
    height: 1.3rem;
}

.credits-wordmark {
    border: 1px solid rgba(42, 31, 18, 0.34);
    padding: 0.08rem 0.45rem;
    background: rgba(255, 246, 220, 0.24);
    font-style: italic;
}

.story-popup-modal {
    position: fixed;
    inset: 0;
    z-index: 1250;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 4vh 4vw;
    background: rgba(10, 7, 4, 0.42);
}

.story-popup-modal.visible {
    display: flex;
}

.story-popup-dialog {
    width: min(30rem, 88vw);
    max-height: min(28rem, 80vh);
    overflow: auto;
    background: rgba(228, 202, 149, 0.97);
    color: rgba(22, 16, 10, 0.94);
    border: 1px solid rgba(42, 31, 18, 0.5);
    box-shadow: 0 1.1rem 2.6rem rgba(0, 0, 0, 0.42);
    padding: 1.15rem 1.3rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
    font-family: 'EB Garamond', var(--book-font), serif;
}

.story-popup-dialog h2 {
    margin: 0;
    font-size: 1.45rem;
    font-style: italic;
    line-height: 1.15;
}

#story_popup_message {
    white-space: pre-wrap;
    line-height: 1.35;
    font-size: 1.05rem;
}

#story_popup_ok {
    align-self: flex-end;
    border: 1px solid rgba(42, 31, 18, 0.5);
    background: rgba(255, 246, 220, 0.36);
    color: rgba(24, 18, 12, 0.92);
    font: inherit;
    padding: 0.18rem 0.85rem;
    cursor: pointer;
}

.credits-content {
    flex: 1;
    overflow: auto;
    margin: 0;
    padding: 0.8rem;
    background: rgba(255, 246, 220, 0.2);
    border: 1px solid rgba(42, 31, 18, 0.22);
    white-space: pre-wrap;
    font-family: "EB Garamond", serif;
    font-size: 0.92rem;
    line-height: 1.28;
}

#lighting {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 999;
    overflow: hidden;
}

#lighting::before,
#lighting::after {
    content: "";
    position: absolute;
    inset: -18%;
    pointer-events: none;
}

#lighting::before {
    background:
        radial-gradient(circle at 16% 5%,
            rgba(255, 214, 150, 0.36) 0%,
            rgba(210, 126, 64, 0.20) 14%,
            rgba(120, 65, 38, 0.08) 34%,
            rgba(60, 36, 24, 0.025) 58%,
            rgba(60, 36, 24, 0) 76%);
    mix-blend-mode: soft-light;
    opacity: 0.42;
    animation: candle-flicker 6.8s infinite ease-in-out;
    will-change: opacity, transform, filter;
}

#lighting::after {
    background:
        radial-gradient(ellipse at center,
            rgba(0, 0, 0, 0) 0%,
            rgba(0, 0, 0, 0.035) 50%,
            rgba(0, 0, 0, 0.18) 100%);
    mix-blend-mode: multiply;
    opacity: 0.24;
}

@keyframes candle-flicker {
    0% {
        opacity: 0.36;
        filter: brightness(0.99) sepia(0.08) saturate(1.02);
        transform: translate3d(0, 0, 0) scale(1);
    }
    18% {
        opacity: 0.46;
        filter: brightness(1.06) sepia(0.12) saturate(1.07);
        transform: translate3d(0.18%, -0.08%, 0) scale(1.008);
    }
    31% {
        opacity: 0.39;
        filter: brightness(1.01) sepia(0.09) saturate(1.04);
        transform: translate3d(-0.08%, 0.08%, 0) scale(1.003);
    }
    49% {
        opacity: 0.5;
        filter: brightness(1.08) sepia(0.14) saturate(1.08);
        transform: translate3d(0.24%, -0.13%, 0) scale(1.011);
    }
    64% {
        opacity: 0.41;
        filter: brightness(1.02) sepia(0.1) saturate(1.04);
        transform: translate3d(-0.12%, 0.1%, 0) scale(1.004);
    }
    81% {
        opacity: 0.47;
        filter: brightness(1.065) sepia(0.13) saturate(1.07);
        transform: translate3d(0.14%, -0.06%, 0) scale(1.008);
    }
    100% {
        opacity: 0.36;
        filter: brightness(1) sepia(0.08) saturate(1.02);
        transform: translate3d(0, 0, 0) scale(1);
    }
}
  

/* Command history */
#command_history {
    max-height: 8rem;
    overflow-y: auto;
    font-size: 1rem;
    line-height: 1.2;
    margin-bottom: 1rem;
    border-top: 1px solid #b69b68;
    padding-top: 0.6rem;
    scrollbar-width: thin;
    scrollbar-color: #7b654a rgba(151, 111, 64, 0.12);
}

body:not([data-game-running="true"]) #command_history {
    display: none;
}

#command_history .history-item {
    margin-bottom: 0.25rem;
    color: rgba(0, 0, 0, 0.82);
    cursor: pointer;
    transition: color 160ms ease, opacity 160ms ease;
}

#command_history .history-item:hover,
#command_history .history-item.active {
    color: rgba(0, 0, 0, 1);
}

#command_history .history-item.active {
    font-weight: 600;
}

#command_history::-webkit-scrollbar {
    width: 6px;
}

#command_history::-webkit-scrollbar-track {
    background: rgba(151, 111, 64, 0.12);
}

#command_history::-webkit-scrollbar-thumb {
    background-color: #7b654a;
    border-radius: 4px;
}

/* Input area */
#input_area {
    display: block;
    margin-top: 15px;
    margin-bottom: 10px;
    width: 100%;
}

/* Command input container */
#command_input {
    width: 100%;
    position: relative;
    margin-top: 10px;
    transition: opacity 0.5s ease; /* Add transition for fading effect */
}

/* Fade out command input when loading */
#command_input.fading {
    opacity: 0;
    pointer-events: none; /* Prevent interaction while faded out */
}

.story-choices {
    width: 100%;
    margin: 0 0 1rem 0;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.45s ease;
    pointer-events: none;
}

.story-choices[hidden] {
    display: none;
}

html[data-history-restoring="true"] .story-choices,
body:not([data-game-running="true"]) .story-choices,
html[data-process-state="waiting-generating"] .story-choices,
html[data-process-state="playing-generating"] .story-choices,
html[data-process-state="playing-ready"] .story-choices,
html[data-process-state="command-waiting"] .story-choices {
    opacity: 0;
    pointer-events: none;
}

html[data-process-state="ready"] .story-choices[data-choice-ready="true"] {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.choice-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.choice-list-item {
    margin: 0 0 0.45rem 0;
}

.choice-list .choice-button {
    display: grid;
    grid-template-columns: 1.8em 1fr;
    align-items: baseline;
    gap: 0.45rem;
    width: 100%;
    padding: 0.15rem 0;
    border: 0;
    background: transparent;
    color: rgba(37, 31, 24, 0.72);
    font-family: inherit;
    font-size: 1rem;
    line-height: 1.25;
    text-align: left;
    cursor: pointer;
    transition: color 0.25s ease, opacity 0.25s ease;
}

.choice-list .choice-button:hover,
.choice-list .choice-button:focus-visible {
    color: rgba(0, 0, 0, 0.96);
    text-decoration: none;
    outline: none;
}

.choice-list kbd {
    display: inline-block;
    min-width: 1.4em;
    font-family: inherit;
    font-size: 0.85em;
    font-weight: 700;
    text-align: center;
    border-bottom: 0;
}

/* Input wrapper for positioning cursor */
.input-wrapper {
    position: relative;
    width: 100%;
    display: inline-block;
    min-height: 1.5em; /* Minimum height for one line */
    max-height: 6em; /* Maximum height - about 4 lines */
    overflow: visible; /* Changed from 'auto' to 'visible' to hide scrollbars when not needed */
}

/* Player input styling - now a textarea for multiline support */
#player_input {
    width: 100%;
    background: transparent;
    border: none;
    border-bottom: 1px solid #8b7765;
    font-family: 'EB Garamond', serif;
    font-size: 1.1rem;
    color: #333;
    outline: none;
    padding: 5px 0;
    caret-color: transparent; /* Hide the default caret */
    box-sizing: border-box;
    resize: none; /* Disable manual resizing */
    overflow: hidden; /* Hide all scrollbars */
    line-height: 1.2; /* Match paragraph line height */
    height: auto; /* Allow height to adjust */
    min-height: 1.5em; /* Ensure minimum height */
}

/* Custom cursor styling */
#cursor {
    position: absolute;
    display: inline-block;
    width: 8px;
    height: 1.2em;
    background-color: #333;
    top: 6px;
    left: 0;
    animation: blink 1s step-end infinite;
    pointer-events: none; /* Allow clicks to pass through to the input */
    z-index: 1; /* Ensure cursor appears above text */
}

html[data-process-state="command-waiting"],
html[data-process-state="command-waiting"] * {
    cursor: var(--process-cursor, wait) !important;
}

html[data-process-state="waiting-generating"],
html[data-process-state="waiting-generating"] *,
html[data-process-state="playing-generating"],
html[data-process-state="playing-generating"] *,
html[data-process-state="playing-ready"],
html[data-process-state="playing-ready"] * {
    cursor: var(--process-cursor, progress) !important;
}

/* Placeholder styling - lighter and italic, with padding to avoid cursor overlap */
#player_input::placeholder {
    color: #8f806a;
    font-style: italic;
    padding-left: 15px; /* Add padding to move placeholder text to the right */
}

/* Blinking animation */
@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

/* Fade-in animation for input area */
@keyframes fadeInInput {
    from { opacity: 0.3; }
    to { opacity: 1; }
}

.fade-in-input {
    animation: fadeInInput 0.5s ease forwards;
}

/* Text animation and typography styles */

/* Fade-in animation for text elements */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.fade-in {
  opacity: 0;
  animation: fadeIn 0.5s ease-in forwards;
}

/* Hyphenation settings */
.story-paragraph {
  hyphens: auto;
  -webkit-hyphens: auto;
  -ms-hyphens: auto;
}

/* Justified text styles */
#story p {
  text-align: justify;
  text-justify: inter-word;
  font-size: var(--story-font-size);
  margin: 0;
  line-height: var(--story-line-height);
}

#story p.story-chapter-heading {
  position: relative;
  height: auto;
  text-align: center;
  font-size: var(--story-font-size);
  font-style: italic;
  line-height: var(--story-line-height);
}

#story p.story-section-heading {
  position: relative;
  height: auto;
  text-align: center;
  font-style: normal;
  line-height: var(--story-line-height);
}

/* Typography for word elements in rendered paragraphs */
.word {
  display: inline-block;
  position: absolute;
  opacity: 0;
  visibility: hidden;
  overflow: hidden;
  clip-path: inset(0 100% 0 0);
  will-change: clip-path, opacity;
}

@keyframes wordReveal {
  0% {
    opacity: 1;
    clip-path: inset(0 100% 0 0);
  }
  100% {
    opacity: 1;
    clip-path: inset(0 0 0 0);
  }
}

strong {
  font-weight: bold;
}

em {
  font-style: italic;
}

/* Typography for hyphen at line breaks */
.hyphen-marker {
  display: inline-block;
}

/* Highlight the latest paragraph being rendered */
.latest-paragraph {
  color: #000;
}

/* Completed paragraphs style */
.completed-paragraph {
  color: #222;
}

/* Animation speed controls */
#speed {
  width: 80px;
  vertical-align: middle;
  margin: 0 5px;
}

body:not([data-game-running="true"]) #command_input {
  display: none;
}

#start_prompt {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 0 12%;
  font-family: 'EB Garamond', var(--book-font), serif;
  font-size: 34px;
  font-style: italic;
  color: rgba(45, 34, 24, 0.78);
  opacity: 0;
  pointer-events: none;
  transition: opacity 260ms ease;
}

body:not([data-game-running="true"]) #start_prompt {
  opacity: 1;
}

/* Options Modal Styling */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    background-color: rgba(0, 0, 0, 0.5);
    box-sizing: border-box;
    padding: max(1rem, env(safe-area-inset-top)) max(1rem, env(safe-area-inset-right)) max(1rem, env(safe-area-inset-bottom)) max(1rem, env(safe-area-inset-left));
}

.modal-content {
    background-color: rgba(255, 252, 245, 0.97);
    border-radius: 0.4rem;
    box-shadow: 0 0 1.5rem rgba(0, 0, 0, 0.4);
    width: min(42rem, calc(100vw - 2rem));
    max-width: 100%;
    max-height: calc(100vh - 2rem);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 0;
    font-family: 'EB Garamond', var(--book-font), serif;
    color: #333;
    position: relative;
    border: 1px solid #d9c8a9;
    font-size: 1rem;
    /* Scale like the book */
    transform-origin: center center;
}

.modal-header {
    display: flex;
    flex: 0 0 auto;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0;
    border-bottom: 1px solid #d9c8a9;
    padding: 1rem 1.5rem 0.7rem 1.5rem;
}

.modal-header h2 {
    margin: 0;
    font-family: 'EB Garamond', var(--book-font), serif;
    font-weight: normal;
    font-size: 1.4rem;
    color: #5a3921;
    letter-spacing: 0.02rem;
}

.close {
    background: none;
    border: none;
    font-size: 1.4rem;
    cursor: pointer;
    color: #7a6e59;
    font-family: 'EB Garamond', var(--book-font), serif;
    line-height: 1;
}

.close:hover {
    color: #5a3921;
}

.options-section {
    margin-bottom: 1.5rem;
}

.modal-body {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 1rem 1.5rem;
}

.modal-footer {
    flex: 0 0 auto;
    border-top: 1px solid #d9c8a9;
    padding: 0.8rem 1.5rem 1rem;
    text-align: right;
}

.modal-footer button,
.option-item input[type="text"],
.option-item input[type="password"],
.option-item input[type="url"] {
    background-color: transparent;
    border: 1px solid black;
    border-radius: 0.25rem;
    color: rgba(0,0,0,0.9);
    font-family: 'EB Garamond', var(--book-font), serif;
    font-size: 1rem;
}

.modal-footer button {
    padding: 0.35rem 1rem;
    cursor: pointer;
}

.modal-footer button:hover {
    background-color: rgba(0,0,0,0.06);
}

.option-item input[type="text"],
.option-item input[type="password"],
.option-item input[type="url"] {
    box-sizing: border-box;
    width: min(18rem, 60%);
    padding: 0.3rem 0.5rem;
}

.option-item input[type="text"]:focus,
.option-item input[type="password"]:focus,
.option-item input[type="url"]:focus {
    outline: none;
    box-shadow: 0 0 0 2px rgba(90, 57, 33, 0.14);
}

.options-section h3 {
    font-family: 'EB Garamond', var(--book-font), serif;
    font-weight: normal;
    font-size: 1.2rem;
    margin-top: 0;
    margin-bottom: 0.8rem;
    border-bottom: 1px solid #e9ddc8;
    padding-bottom: 0.4rem;
    color: #5a3921;
}

.option-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    margin-bottom: 0.7rem;
    padding: 0.25rem 0;
}

.option-item label {
    font-family: 'EB Garamond', var(--book-font), serif;
    font-size: 1rem;
    color: #4a4234;
    flex: 1 1 auto;
}

.option-item .slider-value {
    min-width: 3rem;
    text-align: right;
}

.option-item .game-language-value {
    min-width: 8rem;
    text-align: right;
    font-style: italic;
}

.volume-option {
    justify-content: flex-start;
}

.volume-option label {
    flex: 1 1 auto;
}

.volume-toggle {
    width: 1.7rem;
    height: 1.4rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid black;
    border-radius: 0.25rem;
    background: transparent;
    color: rgba(0,0,0,0.9);
    cursor: pointer;
    font-size: 0.85rem;
    line-height: 1;
}

.volume-toggle:hover {
    background-color: rgba(0,0,0,0.06);
}

.volume-toggle.is-muted {
    opacity: 0.55;
}

.provider-status-list {
    margin: 0.5rem 0 1rem;
    border: 1px solid #e9ddc8;
    border-radius: 0.25rem;
}

.provider-status-row {
    display: grid;
    grid-template-columns: minmax(7rem, 1fr) auto;
    gap: 1rem;
    padding: 0.35rem 0.5rem;
    border-bottom: 1px solid #eee4d2;
    font-size: 0.9rem;
}

.provider-status-row:last-child {
    border-bottom: none;
}

.provider-status-value {
    font-style: italic;
    text-align: right;
}

/* Elegant checkboxes */
.option-item input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    width: 1rem;
    height: 1rem;
    border: 1px solid black;
    border-radius: 0.25rem;
    outline: none;
    cursor: pointer;
    position: relative;
    background-color: transparent;
    overflow: hidden;
}

.option-item input[type="checkbox"]:checked::before {
    content: "✓";
    position: absolute;
    font-family: 'EB Garamond', var(--book-font), serif;
    font-size: 0.9rem;
    top: -0.05rem;
    left: 0.15rem;
    color: rgba(0,0,0,0.9);
}

/* Elegant select dropdowns */
.option-item select {
    appearance: none;
    -webkit-appearance: none;
    background-color: transparent;
    border: 1px solid black;
    border-radius: 0.25rem;
    padding: 0.3rem 1.5rem 0.3rem 0.5rem;
    font-family: 'EB Garamond', var(--book-font), serif;
    font-size: 1rem;
    color: rgba(0,0,0,0.9);
    cursor: pointer;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpath d='M6 9l6 6 6-6'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 0.4rem center;
    background-size: 0.6rem;
    min-width: 8rem;
}

.option-item select:focus {
    outline: none;
}

/* Range inputs (sliders) - match the main menu style */
.option-item input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    width: 8rem;
    height: 0.5rem;
    background-color: transparent;
    box-sizing: border-box;
    border: 1px solid black;
    border-radius: 0.25rem;
    outline: none;
    margin: 0;
    overflow: hidden;
    cursor: pointer;
}

.option-item input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    height: 0.5rem;
    width: 0.5rem;
    border-radius: 0.25rem;
    background-color: rgba(0,0,0,0.9);
    border: none;
    box-shadow: -407px 0 0 400px rgba(0,0,0,0.3);
}

.option-item input[type="range"]::-moz-range-thumb {
    height: 0.5rem;
    width: 0.5rem;
    border-radius: 0.25rem;
    background-color: rgba(0,0,0,0.9);
    border: none;
    box-shadow: -407px 0 0 400px rgba(0,0,0,0.3);
}

/* Reload notice */
.reload-notice {
    margin-top: 1rem;
    padding: 0.5rem;
    border: 1px solid #d9c8a9;
    border-radius: 0.25rem;
    background-color: rgba(233, 221, 200, 0.3);
    font-family: 'EB Garamond', var(--book-font), serif;
    font-style: italic;
    font-size: 0.9rem;
    color: #7a6e59;
    text-align: center;
}

.api-settings {
    margin-top: 1rem;
    padding: 0;
}

.elevenlabs-setting,
.openai-setting {
    display: none; /* Hidden by default, shown when the relevant provider is selected */
}
