html,
body {
    min-height: 100%;
}

html {
    height: 100%;
}

#site-wrapper {
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    height: 100vh;
}


/* Set your background colour here */
body {
    margin: 0;
    padding: 0;
    background: #b7e4c7;
    background: var(--primary-bg-color);
    overflow-y: scroll;
    scroll-snap-type: y mandatory;
    position: relative;
}



/* The paper overlay */
body::before {
    content: "";
    position: fixed;
    inset: 0;
    background-image: url("./paper.jpg");
    background-size: cover;
    /* or 'contain' if you prefer */
    background-position: center;
    background-repeat: no-repeat;

    opacity: 0.2;
    /* adjust to taste */
    pointer-events: none;
    /* don't block clicks */
    z-index: 9999;
    /* sits above everything */
}





.svg-container {
    height: 100%;
    width: 98vw;
    display: flex;
    justify-content: center;
    margin: auto;
    padding-top: .5vh;
}


.page svg {
    height: 100%;
    width: auto;
    display: block;
    object-fit: contain;
    color: var(--primary-bg-color);
}

.barrier {
    height: 2vh;
}

#dice-box {
    display: block;
    position: fixed;
    inset: 0;
    /* top:0; right:0; bottom:0; left:0 */
    width: 100vw;
    /* full viewport width */
    height: 100vh;
    /* full viewport height */
    pointer-events: none;
    z-index: 1;
}


.dice-box-canvas {
    width: 100%;
    height: 100%;
}

.results.showEffect {
    font-size: 0 !important;
}

.results.showEffect strong {
    font-size: 8rem;
    font-family: "Skranji", system-ui;
    font-weight: 400;
    font-style: normal;
}


canvas.fade {
    opacity: 0;
    transition: opacity 0.5s ease;

}

.displayResults .results {
    opacity: 1;
    transition: opacity 0.5s ease;
}

.displayResults .results.hiddenResult {
    opacity: 0;
}

#roll-button {
    position: fixed;
    right: .4rem;
    top: 240px;
    transform: translateY(-50%);
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    transition: transform 1s;
}

#roll-button img {
    width: 64px;
    /* adjust size */
    height: auto;
    display: block;
}

#roll-button:active {
    transform: translateY(-40%);
}

#advantage {
    position: fixed;
    right: .4rem;
    top: 300px;
    transform: translateY(-50%);
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    transition: transform 1s;
}

#advantage img {
    width: 48px;
    height: auto;
    display: block;
}

#advantage:active {
    transform: translateY(-20%);
}


.history-button {
    position: fixed;
    bottom: 20px;
    left: 0px;
}

.history-button img {
    width: 64px;
    /* adjust as needed */
    height: auto;
    cursor: pointer;
}


.critical-text {
    color: rgb(177, 62, 62);
    font-size: 24px;
    text-align: center;
    margin-top: 10px;
    font-weight: bold;
    font-size: 2rem;
    font-family: "Skranji", system-ui;
    font-weight: 400;
    font-style: normal;
}

.criticalFail-text {
    color: rgb(0, 0, 0);
    font-size: 24px;
    text-align: center;
    margin-top: 10px;
    font-weight: bold;
    font-size: 2rem;
    font-family: "Skranji", system-ui;
    font-weight: 400;
    font-style: normal;
}

.hp-button {
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

.hp-button.visible {
    opacity: 1;
    pointer-events: auto;
}

.hp-button.visible path {
    opacity: 1;
    pointer-events: auto;
}


.portrait {
    opacity: 0;
    transition: opacity 0.8s ease-in-out;
}

.portrait.visible {
    opacity: 1;
}

@font-face {
    font-family: "BlackCastleMF";
    src: url("./BlackCastleMF.woff2") format("woff2");
    font-weight: normal;
    font-style: normal;
}

svg text {
    font-family: "BlackCastleMF";
}

.results.showEffect .critical-text,
.results.showEffect .criticalFail-text {
    font-size: 2rem !important;
}


.scroll-container {
    max-width: 900px;
    margin: 40px auto;
    padding: 40px;
    background: rgba(255, 248, 230, 0.9);
    border: 4px solid #c9a86a;
    border-radius: 11px;
    box-shadow: 0 0 30px rgba(0, 0, 0, 0.3);
}

.act-block {
    margin-bottom: 60px;
}

.act-block img {
    width: 100%;
    border: 3px solid #c9a86a;
    border-radius: 8px;
    margin-bottom: 20px;
}

.act-title {
    font-size: 1.8em;
    font-weight: bold;
    margin-bottom: 10px;
    text-shadow: 1px 1px #fff;
    font-family: "Modern Antiqua", serif;
    font-weight: 400;
    font-style: normal;
}

.act-text {
    font-size: 1.6em;
    line-height: 1.6em;
    font-family: "Modern Antiqua", serif;
    font-weight: 400;
    font-style: normal;
}

.modern-antiqua-regular {
    font-family: "Modern Antiqua", serif;
    font-weight: 400;
    font-style: normal;
}

@font-face {
    font-family: 'Gothic Leaf';
    src: url('./GothicLeaf-VEay.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
}


.act-text::first-letter {
    float: left;
    font-family: 'Gothic Leaf', serif;
    font-size: 3.5em;
    line-height: 0.8;
    margin-right: 11px;
    margin-top: 4px;
    padding: 6px 10px;
    color: #e0ae09;




    /* hard outline */
    text-shadow:
        -1px -1px 0 #2b0e0e,
        1px -1px 0 #2b0e0e,
        -1px 1px 0 #2b0e0e,
        1px 1px 0 #2b0e0e
}

#modal-overlay {
    pointer-events: auto;

    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;

    display: flex !important;
    align-items: center !important;
    justify-content: center !important;

    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(3px);
    z-index: 2147483647;
}

#modal-overlay.hidden {
    display: none !important;
}


.modal-box {
    position: relative;
    margin: auto;
    background: #fdfaf3;
    border: 3px solid #333;
    padding: 20px;
    width: min(500px, 90vw);
    max-width: calc(100vw - 2rem);
    max-height: calc(100vh - 2rem);
    overflow-y: auto;
    border-radius: 8px;
    box-shadow: 0 0 25px rgba(0, 0, 0, 0.4);
}

.modal-close {
    position: absolute;
    top: 6px;
    right: 10px;
    font-size: 24px;
    background: none;
    border: none;
    cursor: pointer;
}

/* Dialog-based modal styling (medieval / old-timey) */
dialog#modal-box {
    width: min(900px, 90%);
    max-width: calc(100% - 2rem);
    max-height: calc(100vh - 2rem);
    margin: 0;
    border: 8px solid #3b2f2f;
    border-radius: 10px;
    padding: 1.25rem 1.25rem 1.5rem 1.25rem;
    background: linear-gradient(180deg, #fbf5e6 0%, #f4ead1 100%);
    box-shadow: 0 12px 30px rgba(0,0,0,0.45), inset 0 2px 0 rgba(255,255,255,0.45);
    color: #2b120e;
    font-family: "Georgia", serif;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    overflow-y: auto;
}

dialog#modal-box::backdrop {
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(2px);
}

dialog#modal-box::before {
    content: "";
    position: absolute;
    pointer-events: none;
    border-radius: 12px;
    border: 2px solid rgba(58,38,22,0.12);
    box-shadow: 0 0 0 4px rgba(60,40,20,0.02) inset;
}

/* Force native dialog to accept our styles on browsers that apply UA chrome
   (Firefox Android sometimes renders dialogs with platform defaults). */
dialog#modal-box,
dialog#modal-box * {
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
    appearance: none !important;
    font-family:  "Georgia", serif !important;
    color: #2b120e !important;
}

dialog[open] {
    z-index: 2147483647;
    background-clip: padding-box;
}

/* Make sure the backdrop styling wins on UA-limited implementations */
dialog#modal-box::backdrop {
    background: rgba(0,0,0,0.6) !important;
    backdrop-filter: blur(2px) !important;
}

dialog#modal-box button[command="close"],
dialog#modal-box button[commandfor="modal-box"] {
    position: absolute;
    top: 10px;
    right: 12px;
    background: rgba(60,40,20,0.04);
    border: 2px solid rgba(60,40,20,0.18);
    color: #2b120e;
    padding: 4px 8px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
}

dialog#modal-box button[command="close"]:hover,
dialog#modal-box button[commandfor="modal-box"]:hover {
    background: rgba(60,40,20,0.08);
}

#modal-content h2 {
    margin-top: 0;
    font-size: 2rem;
    color: #2b120e;
}

#modal-content p {
    line-height: 1.5;
    color: #2b120e;
}

#modal-content img {
    float:left;
    padding: 1rem;
}

#modal-content model-viewer {
    float:left;
    padding: 1rem;

     width:100%; 
     height:50vh;
     display:block;
}


#modal-content{
    overflow-x: hidden;
}