@font-face {
    font-family: CurlzMT;
    src: url(../assets/font/curlzmt/CurlzMT.ttf);
}

:root {
    --font-display: CurlzMT, "Trebuchet MS", system-ui, sans-serif;
    --font-ui: "Trebuchet MS", "Segoe UI", system-ui, sans-serif;
    --houtbruin: #7b451f;
    --donkerbruin: #21120b;
    --perkament: #f5dca7;
    --goud-amber: #d99a2b;
    --kaarslicht-glow: rgba(255, 183, 72, 0.42);
    --bg: #1b100a;
    --ink: #fff2d2;
    --ink-soft: rgba(255, 237, 199, 0.82);
    --panel: rgba(58, 34, 19, 0.86);
    --panel-strong: rgba(39, 21, 12, 0.94);
    --panel-light: rgba(245, 220, 167, 0.16);
    --primary: #e0a33c;
    --primary-deep: #8f4d1f;
    --secondary: #6f9f7b;
    --accent: #b64f35;
    --green: #7fa95a;
    --brown: var(--houtbruin);
    --paper: var(--perkament);
    --paper-ink: #2a170d;
    --radius-sm: 12px;
    --radius: 18px;
    --radius-lg: 26px;
    --shadow: 0 18px 42px rgba(18, 8, 3, 0.48);
    --shadow-pop: 0 9px 0 rgba(46, 20, 7, 0.82), 0 18px 34px rgba(12, 5, 2, 0.42);
    --focus: 0 0 0 4px rgba(255, 190, 83, 0.34);
    --screen-pad: max(18px, env(safe-area-inset-left)) max(18px, env(safe-area-inset-right)) max(18px, env(safe-area-inset-bottom));
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    min-height: 100%;
    overflow: hidden;
    overscroll-behavior: none;
    background: var(--bg);
}

body {
    min-height: 100vh;
    min-height: 100dvh;
    color: var(--ink);
    font-family: var(--font-ui);
    background:
        radial-gradient(circle at 18% 16%, var(--kaarslicht-glow), transparent 28%),
        radial-gradient(circle at 82% 12%, rgba(255, 132, 61, 0.24), transparent 24%),
        linear-gradient(90deg, rgba(52, 24, 10, 0.72), rgba(126, 70, 31, 0.3) 42%, rgba(38, 18, 9, 0.72)),
        repeating-linear-gradient(90deg, rgba(255,255,255,0.035) 0 2px, transparent 2px 74px),
        repeating-linear-gradient(0deg, rgba(25, 11, 4, 0.24) 0 3px, transparent 3px 92px),
        linear-gradient(180deg, rgba(54, 26, 12, 0.34), rgba(18, 9, 5, 0.78)),
        url("../assets/art/bg-min.jpg") center / cover no-repeat;
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    background:
        radial-gradient(circle at 50% 0%, rgba(255, 197, 95, 0.2), transparent 34%),
        linear-gradient(180deg, rgba(17, 8, 3, 0.12), rgba(12, 5, 2, 0.58)),
        repeating-linear-gradient(135deg, rgba(255, 226, 164, 0.035) 0 1px, transparent 1px 16px);
}

section.vh-100,
.container.h-100 {
    min-height: 100vh;
    min-height: 100dvh;
}

.vh-100 {
    position: relative;
    z-index: 1;
    min-height: 100vh !important;
    min-height: 100dvh !important;
    overflow: hidden !important;
    padding: var(--screen-pad);
}

.container {
    max-width: 1120px;
}

.d-flex.flex-column.align-items-center.justify-content-center.h-100 {
    gap: 16px;
}

.txt,
.btn {
    color: var(--ink);
    font-family: var(--font-display);
    font-size: clamp(1.35rem, 3.4vw, 2.2rem);
    line-height: 1.05;
    text-align: center;
}

.txtshadow {
    text-shadow: 0 3px 0 rgba(47, 20, 7, 0.78), 0 0 18px var(--kaarslicht-glow);
}

.blacktxt {
    color: var(--paper-ink);
}

a {
    color: var(--ink);
    text-decoration: underline;
}

#inGameCode {
    position: fixed;
    left: max(14px, env(safe-area-inset-left));
    top: max(12px, env(safe-area-inset-top));
    z-index: 5;
    display: inline-flex;
    align-items: center;
    min-height: 34px;
    padding: 5px 12px 7px;
    border: 1px solid rgba(245, 220, 167, 0.32);
    border-radius: 10px;
    color: var(--perkament);
    background:
        linear-gradient(180deg, rgba(255,255,255,0.08), rgba(0,0,0,0.08)),
        linear-gradient(90deg, #4b2813, #6d3d1d 48%, #3a1f10);
    box-shadow: 0 7px 0 rgba(35, 15, 5, 0.72), 0 12px 24px rgba(0, 0, 0, 0.28);
    backdrop-filter: blur(10px);
    font-family: var(--font-ui);
    font-size: 0.95rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-shadow: none;
}

#inGameCode:empty,
#inGameCode[hidden],
#gameCodeDisplay:empty {
    display: none;
}

#title-img {
    width: min(420px, 82vw);
    min-height: 118px;
    margin: 0 0 14px;
    padding: 18px 24px 22px;
    border: 2px solid rgba(245, 220, 167, 0.34);
    border-radius: 18px;
    color: var(--perkament);
    background:
        radial-gradient(circle at 50% 0%, rgba(255, 190, 83, 0.22), transparent 48%),
        linear-gradient(180deg, rgba(255, 226, 164, 0.14), rgba(0,0,0,0.08)),
        repeating-linear-gradient(90deg, rgba(255,255,255,0.035) 0 2px, transparent 2px 48px),
        linear-gradient(135deg, #7a421d, #4b2813 58%, #2f170b);
    box-shadow:
        0 10px 0 rgba(35, 15, 5, 0.78),
        0 22px 34px rgba(16, 7, 2, 0.52),
        0 0 30px rgba(255, 183, 72, 0.16),
        inset 0 2px 0 rgba(255, 226, 164, 0.16),
        inset 0 -4px 0 rgba(16, 7, 2, 0.28);
    filter: none;
    font-family: var(--font-display);
    font-size: clamp(2.45rem, 10vw, 4.25rem);
    line-height: 0.82;
    text-align: center;
    text-shadow:
        0 3px 0 rgba(49, 21, 7, 0.95),
        0 7px 16px rgba(12, 5, 2, 0.5),
        0 0 18px rgba(255, 190, 83, 0.4);
    letter-spacing: 0;
    transform-origin: center;
    animation: titlePop 220ms ease-out both, signGlow 3600ms ease-in-out 400ms infinite;
}

#title-img::before,
#title-img::after {
    content: "";
    position: absolute;
    top: 13px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: radial-gradient(circle, #ffe0a0 0 24%, #9a5624 28% 58%, #2f170b 62%);
    box-shadow: 0 2px 0 rgba(16, 7, 2, 0.7), 0 0 12px rgba(255, 190, 83, 0.22);
}

#title-img::before {
    left: 16px;
}

#title-img::after {
    right: 16px;
}

.tavern-logo {
    position: relative;
    display: grid;
    place-items: center;
}

.tavern-logo span {
    position: relative;
    z-index: 1;
    display: block;
    background: linear-gradient(180deg, #fff0bf 0%, #e0a33c 52%, #b66d24 100%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    -webkit-text-stroke: 1px rgba(57, 25, 9, 0.62);
}

.tavern-logo span:first-child {
    transform: translateX(-10px);
}

.tavern-logo span:last-child {
    transform: translateX(10px);
}

#initialScreen,
#waitingScreen,
#gameScreen,
#displayStoryScreen,
#waitingForNextRoundScreen {
    width: 100%;
    margin: 0 auto;
}

#initialScreen {
    display: table;
}

#waitingScreen,
#displayStoryScreen,
#gameScreen {
    display: none;
}

#waitingScreen,
#initialScreen,
#displayStoryScreen,
#gameScreen {
    margin-top: 0;
}

#waitingForNextRoundScreen {
    display: none;
    min-height: 100vh;
    min-height: 100dvh;
    align-items: center;
    justify-content: center;
}

#initialScreen[style*="table"],
#waitingScreen[style*="table"],
#gameScreen[style*="block"],
#displayStoryScreen[style*="block"],
#waitingForNextRoundScreen[style*="flex"] {
    animation: screenIn 180ms ease-out both;
}

.form-group {
    display: contents;
    margin-bottom: 0;
}

input,
#sentenceInput {
    appearance: none;
    border: 0;
    outline: none;
    color: var(--ink);
    font-family: var(--font-ui);
}

input {
    width: min(280px, 74vw);
    height: 72px;
    padding: 0 18px;
    border: 2px solid rgba(112, 65, 28, 0.7);
    border-radius: var(--radius);
    background:
        linear-gradient(180deg, rgba(255, 246, 214, 0.92), rgba(230, 187, 109, 0.86)),
        var(--perkament);
    box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.38), inset 0 -3px 0 rgba(112, 65, 28, 0.2), 0 14px 30px rgba(18, 8, 3, 0.34);
    text-align: center;
    text-transform: uppercase;
    font-family: var(--font-ui);
    font-size: clamp(1.9rem, 8vw, 2.5rem);
    font-weight: 900;
    letter-spacing: 0.24em;
    text-shadow: none;
    color: var(--paper-ink);
    transition: transform 160ms ease, border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

input,
input.txtshadow,
textarea,
textarea.txtshadow,
#sentenceInput,
#theStory,
#storyDisplay,
#scrollStudioName,
#sentenceToTypeDisplay,
#playerWaitCounter,
#customAlertDialog {
    text-shadow: none;
    filter: none;
}

input:focus,
#sentenceInput:focus {
    border-color: rgba(224, 163, 60, 0.92);
    box-shadow: var(--focus), inset 0 2px 0 rgba(255, 255, 255, 0.28), 0 18px 34px rgba(18, 8, 3, 0.34);
}

::-ms-input-placeholder {
    color: rgba(255, 255, 255, 0.55);
}

::placeholder {
    color: rgba(75, 43, 21, 0.58);
}

.btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 210px;
    min-height: 64px;
    padding: 12px 26px 15px;
    border: 0;
    border: 1px solid rgba(255, 222, 148, 0.34);
    border-radius: 14px;
    color: var(--ink);
    background:
        linear-gradient(180deg, rgba(255, 221, 139, 0.34), rgba(255,255,255,0) 42%),
        repeating-linear-gradient(90deg, rgba(255,255,255,0.035) 0 2px, transparent 2px 42px),
        linear-gradient(135deg, #9a5624, #5e2d13 52%, #3b1b0d);
    box-shadow: var(--shadow-pop);
    cursor: pointer;
    user-select: none;
    touch-action: manipulation;
    transition: transform 140ms ease, filter 140ms ease, box-shadow 140ms ease, background 180ms ease;
    will-change: transform;
}

.btn,
.btn:hover,
.btn:focus,
.btn:focus-visible,
.btn:active,
.btn:not(:disabled):not(.disabled):active,
.btn:not(:disabled):not(.disabled).active,
.dropbtn,
.dropbtn:hover,
.dropbtn:focus,
.dropbtn:active {
    color: var(--ink);
}

.btn::after {
    content: "";
    position: absolute;
    inset: 7px 16px auto;
    height: 14px;
    border-radius: 999px;
    background: linear-gradient(90deg, rgba(255, 226, 164, 0.36), rgba(255,255,255,0.04));
    pointer-events: none;
}

.btn:hover {
    color: var(--ink);
    filter: saturate(1.08) brightness(1.05);
    transform: translateY(-2px);
    text-shadow: 0 3px 0 rgba(58, 24, 5, 0.65), 0 6px 18px rgba(0, 0, 0, 0.3);
}

.btn:active {
    color: var(--ink);
    transform: translateY(6px) scale(0.98);
    box-shadow: 0 4px 0 rgba(72, 38, 5, 0.62), 0 10px 22px rgba(0, 0, 0, 0.24);
}

.btn:focus-visible {
    color: var(--ink);
    outline: none;
    box-shadow: var(--focus), var(--shadow-pop);
}

.btn:disabled,
.btn[disabled] {
    color: var(--ink-soft);
    cursor: not-allowed;
    filter: grayscale(0.5) brightness(0.82);
    opacity: 0.7;
}

#newGameButton,
#joinGameButton,
#startGameButton,
#finishGameButton,
#enterSentenceButton {
    background:
        linear-gradient(180deg, rgba(255, 224, 145, 0.36), rgba(255,255,255,0) 42%),
        repeating-linear-gradient(90deg, rgba(255,255,255,0.035) 0 2px, transparent 2px 42px),
        linear-gradient(135deg, #a65f29, #6c3518 54%, #3f1d0e);
}

#joinGameButton,
#shareRoomButton {
    background:
        linear-gradient(180deg, rgba(255, 224, 145, 0.28), rgba(255,255,255,0) 42%),
        repeating-linear-gradient(90deg, rgba(255,255,255,0.03) 0 2px, transparent 2px 42px),
        linear-gradient(135deg, #667d48, #3e522f 54%, #24321f);
    box-shadow: 0 9px 0 rgba(24, 38, 17, 0.76), 0 18px 36px rgba(12, 5, 2, 0.42);
}

#coffeeBtn {
    min-width: 210px;
    min-height: 58px;
    margin-top: 4px;
    background:
        linear-gradient(180deg, rgba(255, 224, 145, 0.28), rgba(255,255,255,0) 42%),
        linear-gradient(135deg, #8b3e2f, #5a221a);
    box-shadow: 0 8px 0 rgba(46, 17, 11, 0.76), 0 16px 32px rgba(12, 5, 2, 0.36);
    font-size: clamp(1.1rem, 2.8vw, 1.45rem);
}

#startGameButton {
    display: none;
    background:
        linear-gradient(180deg, rgba(255, 230, 166, 0.36), rgba(255,255,255,0) 42%),
        linear-gradient(135deg, #8aa35a, #4d6a35 56%, #263a20);
    box-shadow: 0 9px 0 rgba(26, 47, 17, 0.76), 0 18px 36px rgba(12, 5, 2, 0.42);
}

#startGameButton[style*="block"] {
    display: inline-flex;
}

#enterSentenceButton {
    min-width: 250px;
}

#replayGameButton {
    min-width: 210px;
    width: auto;
    min-height: 64px;
    height: auto;
    padding: 12px 26px 15px;
    gap: 0;
    border-radius: 14px;
    background:
        linear-gradient(180deg, rgba(255, 224, 145, 0.36), rgba(255,255,255,0) 45%),
        linear-gradient(135deg, #9a5624, #5e2d13);
    box-shadow: 0 8px 0 rgba(46, 20, 7, 0.82), 0 16px 28px rgba(12, 5, 2, 0.38);
    font-size: clamp(1.35rem, 3.4vw, 2.2rem);
    font-weight: inherit;
}

#replayGameButton::before {
    content: none;
}

#replayGameButton span {
    position: relative;
    z-index: 1;
}

#replayGameButton::after {
    content: "";
    position: absolute;
    inset: 7px 16px auto;
    width: auto;
    height: 14px;
    display: block;
    border: 0;
    border-radius: 999px;
    background: linear-gradient(90deg, rgba(255, 226, 164, 0.36), rgba(255,255,255,0.04));
    filter: none;
    pointer-events: none;
}

#waitroomButtonsWrapper,
#waitRoomButtonsWrapper,
#endButtonsWrapper {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 16px;
}

#codeBlock,
#hint,
.textarea-frame,
#codeBlockAlert {
    position: relative;
    border: 2px solid rgba(166, 103, 45, 0.72);
    border-radius: var(--radius-lg);
    background:
        linear-gradient(180deg, rgba(255, 226, 164, 0.12), rgba(77, 39, 18, 0.12)),
        repeating-linear-gradient(90deg, rgba(255,255,255,0.028) 0 2px, transparent 2px 54px),
        linear-gradient(135deg, rgba(85, 45, 21, 0.93), rgba(43, 22, 12, 0.94));
    box-shadow: var(--shadow), inset 0 2px 0 rgba(255, 226, 164, 0.16), inset 0 -4px 0 rgba(20, 8, 3, 0.28);
    backdrop-filter: blur(10px);
}

#codeBlock::before,
#hint::before,
.textarea-frame::before,
#codeBlockAlert::before {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    pointer-events: none;
    background:
        radial-gradient(circle at 20% 8%, var(--kaarslicht-glow), transparent 26%),
        linear-gradient(135deg, rgba(245, 220, 167, 0.12), transparent 38%, rgba(91, 52, 25, 0.14));
}

#codeBlock {
    width: min(92vw, 760px);
    min-height: 238px;
    padding: 30px 28px;
    margin-bottom: 12px;
    text-align: center;
    animation: floatCard 2800ms ease-in-out infinite;
}

#waitingForNextRoundScreen #codeBlock {
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
}

#playerWaitCounter {
    width: 100%;
    margin: 0;
    text-align: center;
    line-height: 1.18;
}

#waitingScreen #codeBlock {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    gap: 24px;
    width: min(94vw, 860px);
    min-height: 250px;
    text-align: left;
}

#waitRoomInfo {
    position: relative;
    z-index: 1;
    min-width: 0;
    text-align: left;
}

#inviteQrCard {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 160px;
    height: 160px;
    padding: 12px;
    border: 2px solid rgba(122, 71, 30, 0.62);
    border-radius: 18px;
    background:
        linear-gradient(180deg, rgba(255, 248, 223, 0.98), rgba(232, 194, 126, 0.96)),
        var(--perkament);
    box-shadow:
        inset 0 2px 0 rgba(255, 255, 255, 0.42),
        inset 0 -3px 0 rgba(112, 65, 28, 0.2),
        0 12px 22px rgba(16, 7, 2, 0.28);
}

#inviteQrCard[hidden] {
    display: none;
}

#inviteQrImage {
    display: block;
    flex: 0 0 auto;
    width: 132px;
    height: 132px;
    max-width: 100%;
    max-height: 100%;
    margin: 0;
    object-fit: contain;
    image-rendering: pixelated;
    background: #fff8e5;
    border-radius: 6px;
    text-shadow: none;
    filter: none;
}

#codeBlock::after,
#hint::after {
    content: "";
    position: absolute;
    left: 18px;
    right: 18px;
    top: 12px;
    height: 4px;
    border-radius: 999px;
    background: linear-gradient(90deg, transparent, rgba(245, 220, 167, 0.4), transparent);
    pointer-events: none;
}

#codeBlock p {
    position: relative;
    margin: 0 0 12px;
}

#gameCodeDisplay {
    display: inline-flex;
    align-items: center;
    min-height: 58px;
    margin-left: 8px;
    padding: 6px 18px 9px;
    border: 2px solid rgba(245, 220, 167, 0.42);
    border-radius: 13px;
    color: var(--perkament);
    background:
        linear-gradient(180deg, rgba(255, 226, 164, 0.2), rgba(255,255,255,0) 42%),
        repeating-linear-gradient(90deg, rgba(255,255,255,0.04) 0 2px, transparent 2px 36px),
        linear-gradient(135deg, #6f3c1b, #3d1e0e);
    box-shadow: 0 8px 0 rgba(35, 15, 5, 0.76), 0 15px 28px rgba(12, 5, 2, 0.34), 0 0 22px rgba(255, 176, 65, 0.12);
    font-family: var(--font-ui);
    font-size: clamp(1.5rem, 7vw, 2.4rem);
    font-weight: 950;
    letter-spacing: 0.12em;
    text-shadow: 0 2px 0 rgba(35, 15, 5, 0.82), 0 0 16px rgba(255, 190, 83, 0.25);
    animation: badgePop 220ms ease-out both;
}

#playerCount {
    color: var(--perkament);
    font-family: var(--font-ui);
    font-size: clamp(1.05rem, 3vw, 1.35rem);
    font-weight: 900;
    text-shadow: none;
}

#playerNum {
    display: inline-grid;
    place-items: center;
    min-width: 42px;
    min-height: 42px;
    padding: 4px 11px;
    border-radius: 999px;
    color: #201207;
    background:
        linear-gradient(180deg, #ffe0a0, var(--goud-amber));
    box-shadow: 0 6px 0 rgba(90, 48, 16, 0.62), 0 0 14px rgba(255, 190, 83, 0.18);
    font-weight: 950;
}

#hint {
    display: grid;
    place-items: center;
    width: min(92vw, 900px);
    min-height: 140px;
    padding: 22px 28px;
    margin-bottom: 8px;
    background:
        linear-gradient(180deg, rgba(255, 235, 184, 0.88), rgba(226, 184, 112, 0.88)),
        var(--perkament);
    border-color: rgba(122, 71, 30, 0.78);
}

#hint .txt,
#sentenceToTypeDisplay {
    position: relative;
}

#sentenceToTypeDisplay {
    display: block;
    font-family: var(--font-ui);
    font-size: clamp(1.3rem, 4vw, 2rem);
    font-weight: 950;
    line-height: 1.12;
    color: var(--paper-ink);
    text-shadow: none;
}

.textarea-frame {
    width: min(92vw, 900px);
    height: min(360px, 38vh);
    padding: 20px;
    overflow: hidden;
    background:
        linear-gradient(180deg, rgba(95, 50, 23, 0.92), rgba(42, 21, 11, 0.94)),
        var(--panel);
}

#sentenceInput {
    position: relative;
    z-index: 1;
    width: 100%;
    height: 100%;
    padding: 18px;
    border: 2px solid rgba(122, 71, 30, 0.54);
    border-radius: 22px;
    background:
        linear-gradient(180deg, rgba(255, 246, 214, 0.9), rgba(235, 197, 128, 0.88)),
        var(--perkament);
    box-shadow: inset 0 2px 14px rgba(74, 38, 16, 0.18);
    font-size: clamp(1.25rem, 3.4vw, 1.85rem);
    font-weight: 800;
    line-height: 1.25;
    text-align: center;
    color: var(--paper-ink);
    text-shadow: none;
    resize: none;
    overflow-y: auto;
    overflow-x: hidden;
    white-space: pre-wrap;
    word-break: break-word;
    transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

#sentenceInput:focus {
    background:
        linear-gradient(180deg, rgba(255, 248, 223, 0.96), rgba(242, 204, 137, 0.94)),
        var(--perkament);
}

::-webkit-scrollbar {
    width: 7px;
}

::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.12);
    border-radius: 999px;
}

::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, var(--goud-amber), #7a3f1b);
    border-radius: 999px;
}

#storyDisplay {
    position: relative;
    display: flex;
    flex-direction: column;
    width: min(92vw, 1050px);
    min-height: min(620px, 70dvh);
    max-height: min(80dvh, 820px);
    padding: clamp(38px, 6vw, 54px) clamp(38px, 6vw, 54px) clamp(58px, 8vw, 76px);
    border: 3px solid rgba(245, 220, 167, 0.28);
    border-radius: 24px;
    color: var(--paper-ink);
    background:
        radial-gradient(circle at 50% 0%, rgba(255, 190, 83, 0.24), transparent 38%),
        linear-gradient(180deg, rgba(255, 226, 164, 0.12), rgba(0,0,0,0.12)),
        repeating-linear-gradient(90deg, rgba(255,255,255,0.026) 0 2px, transparent 2px 52px),
        linear-gradient(135deg, #6f3c1b, #3d1e0e 62%, #241107);
    box-shadow:
        0 14px 0 rgba(35, 15, 5, 0.82),
        0 30px 44px rgba(16, 7, 2, 0.52),
        0 0 34px rgba(255, 183, 72, 0.16),
        inset 0 2px 0 rgba(255, 226, 164, 0.16);
    filter: none;
    text-align: center;
    font-family: var(--font-ui);
    font-size: clamp(1rem, 2.7vw, 1.45rem);
    font-weight: 800;
    text-shadow: none;
    animation: resultPop 240ms ease-out both;
}

#storyDisplay > * {
    position: relative;
    z-index: 1;
}

#storyDisplay::after {
    content: "";
    position: absolute;
    inset: 20px;
    border: 2px solid rgba(122, 71, 30, 0.48);
    border-radius: 18px;
    background:
        radial-gradient(circle at 50% 0%, rgba(255, 255, 255, 0.22), transparent 26%),
        linear-gradient(180deg, rgba(255, 248, 223, 0.96), rgba(230, 190, 119, 0.95)),
        var(--perkament);
    box-shadow:
        inset 0 2px 0 rgba(255, 255, 255, 0.32),
        inset 0 -3px 0 rgba(112, 65, 28, 0.2),
        0 12px 24px rgba(16, 7, 2, 0.24);
    pointer-events: none;
}

#storyDisplay::before,
#storyDisplay .tavern-spark {
    content: "";
    position: absolute;
    top: 18px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--goud-amber);
    box-shadow:
        28px 18px 0 #8b3e2f,
        56px 6px 0 #f1c36a,
        84px 22px 0 #6f9f7b;
    animation: confettiNudge 1200ms ease-in-out infinite alternate;
}

#storyDisplay::before {
    left: 46px;
    z-index: 2;
}

#scrollTitle {
    color: var(--paper-ink);
    font-family: var(--font-display);
    font-size: clamp(1.35rem, 4vw, 2rem);
    margin: 0 0 8px;
    text-shadow: 0 1px 0 rgba(255,255,255,0.35);
}

#theStory {
    flex: 1 1 auto;
    min-height: clamp(260px, 34dvh, 420px);
    max-height: clamp(320px, 54dvh, 620px);
    max-width: min(820px, 78vw);
    margin: 10px auto 0;
    padding: 8px 10px 2px;
    line-height: 1.24;
    color: var(--paper-ink);
    text-shadow: none;
    overflow-y: auto;
    overflow-x: hidden;
}

.allow-scroll {
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    touch-action: pan-y;
}

#storyScreenBottom {
    position: absolute;
    left: clamp(38px, 6vw, 54px);
    right: clamp(38px, 6vw, 54px);
    bottom: clamp(30px, 4vw, 38px);
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    width: auto;
    margin: 0 auto;
    padding-top: 8px;
    border-top: 1px solid rgba(122, 71, 30, 0.24);
}

#shareBtn {
    position: relative;
    min-width: 150px;
    width: auto;
    min-height: 64px;
    height: 64px;
    padding: 10px 22px 13px 54px;
    border: 1px solid rgba(255, 222, 148, 0.34);
    margin: 0;
    border-radius: 14px;
    background:
        linear-gradient(180deg, rgba(255, 224, 145, 0.36), rgba(255,255,255,0.04)),
        linear-gradient(135deg, #667d48, #3e522f 54%, #24321f);
    box-shadow: 0 7px 0 rgba(46, 20, 7, 0.72);
    visibility: visible;
    cursor: pointer;
    transition: transform 140ms ease, filter 140ms ease, box-shadow 140ms ease;
}

#shareBtn::before {
    content: "";
    position: absolute;
    left: 18px;
    top: 50%;
    width: 25px;
    height: 25px;
    transform: translateY(-50%);
    background: url("../assets/art/baseline_share_white_48dp.png") center / contain no-repeat;
    filter: drop-shadow(0 2px 0 rgba(0, 0, 0, 0.34));
    pointer-events: none;
}

#shareBtn::after {
    content: "";
    position: absolute;
    inset: 7px 16px auto;
    height: 14px;
    border-radius: 999px;
    background: linear-gradient(90deg, rgba(255, 226, 164, 0.24), rgba(255,255,255,0.04));
    pointer-events: none;
}

#shareBtn:active {
    transform: translateY(5px) scale(0.98);
    box-shadow: 0 2px 0 rgba(4, 45, 120, 0.5);
}

#scrollStudioName {
    display: block;
    width: 100%;
    margin: 0 auto;
    color: rgba(45, 33, 25, 0.72);
    font-size: clamp(0.78rem, 2vw, 1rem);
    font-weight: 900;
    line-height: 1.1;
    text-align: center;
    white-space: nowrap;
    text-shadow: none;
}

#alert {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 10;
    background: rgba(20, 10, 5, 0.52);
    backdrop-filter: blur(8px);
}

#codeBlockAlert {
    width: min(460px, 88vw);
    min-height: 220px;
    padding: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: resultPop 180ms ease-out both;
}

#customAlertDialog {
    position: relative;
    margin: 0;
    font-family: var(--font-ui);
    font-size: clamp(1.25rem, 4vw, 1.75rem);
    font-weight: 950;
}

#check {
    position: absolute;
    right: 20px;
    bottom: 18px;
    width: 54px;
    height: 54px;
    padding: 0;
    border: 0;
    border-radius: 18px;
    background:
        linear-gradient(180deg, #ffe0a0, var(--goud-amber));
    box-shadow: 0 7px 0 rgba(90, 48, 16, 0.62), 0 12px 24px rgba(12, 5, 2, 0.32);
    cursor: pointer;
    object-fit: contain;
    transition: transform 140ms ease, box-shadow 140ms ease;
}

#check:active {
    transform: translateY(5px);
    box-shadow: 0 2px 0 rgba(4, 77, 36, 0.52);
}

.toast-msg {
    visibility: hidden;
    min-width: 210px;
    max-width: calc(100vw - 32px);
    padding: 13px 18px;
    position: fixed;
    left: 50%;
    bottom: calc(20px + env(safe-area-inset-bottom));
    z-index: 9999;
    transform: translate(-50%, 12px) scale(0.96);
    border: 1px solid rgba(245, 220, 167, 0.32);
    border-radius: 14px;
    color: var(--ink);
    background:
        linear-gradient(180deg, rgba(255, 226, 164, 0.12), rgba(0,0,0,0.08)),
        rgba(52, 28, 15, 0.94);
    box-shadow: var(--shadow);
    opacity: 0;
    text-align: center;
    font-family: var(--font-ui);
    font-size: 0.95rem;
    font-weight: 900;
    transition: opacity 180ms ease, transform 180ms ease, visibility 180ms ease;
    backdrop-filter: blur(12px);
}

.toast-msg.show {
    visibility: visible;
    opacity: 1;
    transform: translate(-50%, 0) scale(1);
}

#dropdownWrapper,
#\ dropdownWrapper {
    position: fixed;
    top: max(12px, env(safe-area-inset-top));
    right: max(14px, env(safe-area-inset-right));
    z-index: 6;
    display: flex;
    width: auto;
    padding-top: 0 !important;
    margin-top: 0;
}

.dropdown {
    position: relative;
    display: inline-block;
    margin-left: 0;
}

.dropbtn {
    min-width: 52px;
    width: 52px;
    min-height: 52px;
    height: 52px;
    padding: 0;
    border-radius: 14px;
    background:
        linear-gradient(180deg, rgba(255, 224, 145, 0.3), rgba(255,255,255,0.04)),
        linear-gradient(135deg, #6f3c1b, #3d1e0e);
    box-shadow: 0 7px 0 rgba(35, 15, 5, 0.76), 0 14px 26px rgba(12, 5, 2, 0.34);
    font-family: var(--font-ui);
    font-size: 1rem;
    font-weight: 950;
    text-shadow: none;
}

.dropdown-content {
    display: none;
    max-height: min(360px, 62vh);
    overflow-y: auto;
    position: absolute;
    right: 0;
    z-index: 7;
    padding: 8px;
    border: 1px solid rgba(245, 220, 167, 0.24);
    border-radius: 18px;
    background:
        linear-gradient(180deg, rgba(255, 226, 164, 0.1), rgba(0,0,0,0.08)),
        rgba(38, 20, 11, 0.96);
    box-shadow: var(--shadow);
    backdrop-filter: blur(12px);
}

.dropdown-content a {
    display: block;
    min-width: 64px;
    padding: 10px 12px;
    border-radius: 12px;
    color: var(--ink);
    background: transparent;
    text-align: center;
    text-decoration: none;
    font-family: var(--font-ui);
    font-size: 0.95rem;
    font-weight: 950;
    transition: background 140ms ease, transform 140ms ease;
}

.dropdown-content a:hover {
    cursor: pointer;
    background: rgba(224, 163, 60, 0.2);
    transform: translateX(-2px);
}

.show {
    display: block;
}

@keyframes screenIn {
    from {
        opacity: 0;
        transform: translateY(12px) scale(0.985);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes titlePop {
    from {
        opacity: 0;
        transform: translateY(10px) scale(0.94);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes signGlow {
    0%,
    100% {
        box-shadow:
            0 10px 0 rgba(35, 15, 5, 0.78),
            0 22px 34px rgba(16, 7, 2, 0.52),
            0 0 24px rgba(255, 183, 72, 0.12),
            inset 0 2px 0 rgba(255, 226, 164, 0.16),
            inset 0 -4px 0 rgba(16, 7, 2, 0.28);
    }
    50% {
        box-shadow:
            0 10px 0 rgba(35, 15, 5, 0.78),
            0 22px 34px rgba(16, 7, 2, 0.52),
            0 0 34px rgba(255, 183, 72, 0.22),
            inset 0 2px 0 rgba(255, 226, 164, 0.2),
            inset 0 -4px 0 rgba(16, 7, 2, 0.28);
    }
}

@keyframes badgePop {
    from {
        transform: scale(0.9);
    }
    to {
        transform: scale(1);
    }
}

@keyframes resultPop {
    from {
        opacity: 0;
        transform: translateY(16px) scale(0.96);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes floatCard {
    0%,
    100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-5px);
    }
}

@keyframes confettiNudge {
    from {
        opacity: 0.56;
        transform: translateY(0);
    }
    to {
        opacity: 0.95;
        transform: translateY(7px);
    }
}

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