@import url('https://fonts.googleapis.com/css2?family=Roboto+Slab:wght@400;500;600;700;800&family=Rye&display=swap');

* {
    box-sizing: border-box;
}

html,
body {
    min-height: 100%;
    margin: 0;
}

body {
    min-height: 100vh;
    min-height: 100dvh;
    display: grid;
    place-items: center;
    background: #252315;
    color: #17202a;
    font-family: Georgia,'Times New Roman',serif;
}

.page {
    position: relative;
    width: min(100vw,430px);
    margin: auto;
}

.background {
    display: block;
    width: 100%;
    height: auto;
}

.copy {
    position: absolute;
    left: 9%;
    width: 82%;
    text-align: center;
}

.story-copy {
    top: 23%;
    max-height: 59%;
    overflow: auto;
    padding: 2px;
}

.has-puzzle .story-copy {
    top: 20%;
    max-height: 37%;
}

.long-copy .story-copy {
    font-size: 14px;
}

.title {
    margin: 0;
    font-size: clamp(27px,8vw,40px);
    line-height: 1.06;
    font-weight: 700;
}

.intro,
.story {
    margin: 0;
    font-size: clamp(15px,4vw,19px);
    line-height: 1.25;
}

.intro {
    margin-top: 20px;
    font-weight: 600;
}

.story {
    margin-top: 16px;
    white-space: normal;
}

.long-copy .story {
    font-size: 14px;
    line-height: 1.18;
}

.puzzle {
    position: absolute;
    top: 60%;
    right: 7%;
    bottom: 4%;
    left: 7%;
    text-align: center;
}

.puzzle-question {
    margin: 0 0 13px;
    font-size: clamp(16px,4.4vw,20px);
    font-weight: 700;
}

.puzzle-inputs {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 7px;
}

.puzzle-box {
    width: 42px;
    height: 48px;
    padding: 2px;
    border: 2px solid #17202a;
    border-radius: 6px;
    background: #fff9e2f0;
    color: #17202a;
    font: 700 24px/1 Georgia,serif;
    text-align: center;
}

.puzzle-text-input,
.login-form input[type=text] {
    width: 100%;
    padding: 11px;
    border: 2px solid #17202a;
    border-radius: 7px;
    background: #fff9e2f0;
    color: #17202a;
    font: 700 19px/1.2 Georgia,serif;
    text-align: center;
}

.puzzle-box:focus-visible,
.puzzle-text-input:focus-visible,
input:focus-visible,
button:focus-visible,
a:focus-visible {
    outline: 3px solid #176078;
    outline-offset: 2px;
}

.hint-button {
    margin-top: 11px;
    padding: 7px 13px;
    border: 1px solid #17202a;
    border-radius: 999px;
    background: #fff9e2f0;
    color: inherit;
    font: 700 12px/1.2 Georgia,serif;
    cursor: pointer;
}

.puzzle-hint {
    margin: 11px auto 0;
    padding: 7px 9px;
    max-width: 300px;
    border-radius: 6px;
    background: #fff9e2eb;
    font-size: 14px;
    line-height: 1.2;
}

.score {
    position: absolute;
    right: 20%;
    bottom: 4.8%;
    left: 20%;
    display: flex;
    justify-content: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 700;
    white-space: nowrap;
}

.penalty {
    color: #8b1e16;
}

.page-number,
.next-button,
.check-answer-button,
.result-button {
    position: absolute;
    bottom: 3.5%;
    display: grid;
    place-items: center;
    border: 2px solid #17202a;
    background: #f4e1aee8;
    color: inherit;
    font-family: inherit;
    font-weight: 700;
    text-decoration: none;
    box-shadow: 0 2px 4px #0003;
}

.page-number {
    left: 6%;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    font-size: 14px;
}

.next-button,
.check-answer-button,
.result-button {
    right: 6%;
    min-height: 40px;
    max-width: 56%;
    padding: 8px 15px;
    border-radius: 999px;
    font-size: 13px;
    line-height: 1.1;
    cursor: pointer;
}

.puzzle .check-answer-button {
    right: 0;
    bottom: 0;
}

.letter-reveal {
    margin-top: 15px;
}

.letter-medallion {
    display: grid;
    place-items: center;
    width: 72px;
    height: 72px;
    margin: 0 auto;
    border: 4px double #d6b75d;
    border-radius: 50%;
    background: #f4e1ae;
    color: #174b31;
    font-size: 46px;
    font-weight: 700;
    box-shadow: 0 4px 8px #0004;
}

.result-copy {
    top: 20%;
    max-height: 61%;
    overflow: auto;
}

.result-icon {
    width: 106px;
    height: 106px;
    margin: 0 auto 17px;
    filter: drop-shadow(0 4px 4px #0004);
}

.result-icon svg {
    display: block;
    width: 100%;
    height: 100%;
}

.result-seal-outer {
    stroke: #d6b75d;
    stroke-width: 6;
}

.result-seal-inner {
    fill: none;
    stroke: #ffffff40;
    stroke-width: 2;
}

.result-incorrect .result-seal-outer {
    fill: #8b1e16;
}

.final-seal {
    fill: #17562f;
}

.result-symbol {
    fill: none;
    stroke: #f6e8b8;
    stroke-width: 10;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.result-title {
    margin: 0;
    font-size: clamp(30px,8vw,42px);
    line-height: 1.05;
}

.result-text {
    margin: 18px 0 0;
    font-size: clamp(16px,4.2vw,20px);
    line-height: 1.3;
}

.auth-copy {
    top: 23%;
    max-height: 65%;
    overflow: auto;
}

.login-form {
    display: grid;
    gap: 11px;
    margin-top: 20px;
}

.login-form label {
    font-size: 17px;
    font-weight: 700;
}

.primary-action {
    padding: 10px 18px;
    border: 2px solid #17202a;
    border-radius: 999px;
    background: #f4e1ae;
    color: inherit;
    font: 700 15px/1.2 Georgia,serif;
    cursor: pointer;
}

.secondary-form {
    margin-top: 15px;
}

.text-button {
    border: 0;
    background: transparent;
    text-decoration: underline;
    cursor: pointer;
}

.team-badge,
.final-team {
    display: inline-block;
    margin: 20px 0 0;
    padding: 7px 12px;
    border-radius: 999px;
    background: #fff9e2d9;
    font-weight: 700;
}

.form-message {
    padding: 8px 10px;
    border-radius: 6px;
    font-size: 14px;
}

.form-error {
    border: 1px solid #8b1e16;
    background: #ffe6def0;
    color: #6d1711;
}

.final-inline-score {
    display: grid;
    gap: 5px;
    margin: 18px auto 0;
    padding: 10px;
    border-radius: 8px;
    background: #fff9e2e8;
}

.final-inline-score span {
    font-size: 25px;
    font-weight: 700;
}

.final-inline-score small {
    font-size: 12px;
}

.final-score-copy {
    top: 14%;
    max-height: 72%;
    overflow: auto;
}

.score-breakdown {
    width: min(100%,300px);
    margin: 18px auto 0;
    padding: 10px 15px;
    border-radius: 8px;
    background: #fff9e2e8;
}

.score-breakdown div {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 5px 0;
}

.score-breakdown dt,
.score-breakdown dd {
    margin: 0;
}

.score-breakdown dd {
    font-weight: 700;
}

.score-breakdown .score-total {
    margin-top: 5px;
    padding-top: 9px;
    border-top: 1px solid #17202a;
    font-size: 18px;
}

.final-letters {
    font-size: 18px;
}

@media(max-width:360px) {
    .title {
        font-size: 27px;
    }

    .intro,
    .story {
        font-size: 14px;
    }

    .story-copy {
        top: 21%;
    }

    .has-puzzle .story-copy {
        top: 18%;
        max-height: 38%;
    }

    .puzzle {
        top: 59%;
    }

    .puzzle-box {
        width: 35px;
        height: 41px;
        font-size: 20px;
    }

    .result-icon {
        width: 86px;
        height: 86px;
        margin-bottom: 11px;
    }

    .result-copy {
        top: 17%;
    }

    .next-button,
    .check-answer-button,
    .result-button {
        font-size: 12px;
        padding: 7px 11px;
    }

    .score {
        bottom: 4.5%;
        font-size: 12px;
    }

    .final-score-copy {
        top: 10%;
    }

}

/* ========================================================================== 
   VINTAGE ESCAPE EDAM THEME
   ========================================================================== */

:root {
    --navy: #13243a;
    --navy-dark: #0b1728;
    --navy-light: #29496f;
    --gold: #c9a14a;
    --gold-light: #f0d48a;
    --parchment-light: rgba(255, 247, 218, 0.9);
    --ink: #172438;
    --danger: #8b1e16;
}

body {
    background: #181913;
    color: var(--ink);
    font-family: 'Roboto Slab', Georgia, 'Times New Roman', serif;
}

.page {
    overflow: hidden;
    box-shadow: 0 0 28px rgba(0, 0, 0, 0.55);
}

.story-copy {
    padding: 4px 5px 8px;
    scrollbar-color: var(--gold) transparent;
    scrollbar-width: thin;
}

.title,
.result-title {
    color: var(--navy-dark);
    font-family: 'Rye', Georgia, 'Times New Roman', serif;
    font-weight: 400;
    letter-spacing: 0.035em;
    line-height: 1.12;
    text-transform: uppercase;
    text-shadow:
        0 1px 0 rgba(255, 239, 190, 0.8),
        1px 2px 0 rgba(19, 36, 58, 0.15);
}

.intro,
.story,
.result-text {
    color: var(--ink);
    font-family: 'Roboto Slab', Georgia, 'Times New Roman', serif;
    line-height: 1.42;
}

.intro {
    font-weight: 800;
}

.story {
    font-weight: 500;
}

.puzzle-question,
.login-form label {
    color: var(--navy-dark);
    font-family: 'Roboto Slab', Georgia, serif;
    font-weight: 800;
    line-height: 1.3;
}

.puzzle-inputs {
    gap: 8px;
}

.puzzle-box,
.puzzle-text-input,
.login-form input[type='text'] {
    border: 2px solid #8e713b;
    background: linear-gradient(
        rgba(255, 248, 220, 0.9),
        rgba(241, 216, 158, 0.9)
    );
    color: var(--navy-dark);
    font-family: 'Roboto Slab', Georgia, serif;
    font-weight: 800;
    box-shadow:
        inset 0 2px 5px rgba(76, 45, 10, 0.18),
        0 1px 0 rgba(255, 255, 255, 0.45);
}

.puzzle-box {
    border-radius: 7px;
}

.puzzle-text-input,
.login-form input[type='text'] {
    padding: 12px 15px;
    border-radius: 10px;
    font-size: 18px;
}

.puzzle-box:focus,
.puzzle-text-input:focus,
.login-form input[type='text']:focus {
    border-color: var(--navy-light);
    outline: 3px solid rgba(201, 161, 74, 0.45);
    outline-offset: 2px;
}

.hint-button {
    border: 2px solid var(--gold);
    background: var(--parchment-light);
    color: var(--navy-dark);
    font-family: 'Roboto Slab', Georgia, serif;
    font-weight: 800;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

.puzzle-hint {
    border: 1px solid var(--gold);
    background: var(--parchment-light);
    color: var(--navy-dark);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.13);
}

.score {
    color: var(--navy-dark);
    font-weight: 800;
}

.penalty {
    color: var(--danger);
}

.page-number,
.next-button,
.check-answer-button,
.result-button,
.primary-action {
    border: 2px solid var(--gold);
    background: linear-gradient(180deg, var(--navy-light), var(--navy-dark));
    color: #fff1c5;
    font-family: 'Rye', Georgia, serif;
    font-weight: 400;
    letter-spacing: 0.035em;
    text-shadow: 0 1px 1px #000;
    box-shadow:
        inset 0 0 0 1px rgba(255, 238, 177, 0.2),
        0 4px 8px rgba(0, 0, 0, 0.28);
}

.page-number {
    width: 36px;
    height: 36px;
    font-family: 'Roboto Slab', Georgia, serif;
    font-weight: 800;
}

.next-button,
.check-answer-button,
.result-button {
    min-height: 43px;
    max-width: 62%;
    padding: 9px 17px;
    font-size: 13px;
}

.primary-action {
    width: 100%;
    padding: 12px 18px;
    border-radius: 999px;
    font-size: 16px;
    cursor: pointer;
}

.next-button:hover,
.check-answer-button:hover,
.result-button:hover,
.primary-action:hover {
    border-color: var(--gold-light);
    background: linear-gradient(180deg, #2d4b70, #10233a);
    transform: translateY(-1px);
}

.next-button:active,
.check-answer-button:active,
.result-button:active,
.primary-action:active {
    transform: translateY(1px);
}

.letter-medallion {
    border-color: var(--gold);
    background: linear-gradient(145deg, #f5dfaa, #e4bd62);
    color: var(--navy-dark);
    font-family: 'Rye', Georgia, serif;
    font-weight: 400;
}

.result-seal-outer {
    stroke: var(--gold);
}

.result-incorrect .result-seal-outer {
    fill: var(--danger);
}

.team-badge,
.final-team,
.final-inline-score,
.score-breakdown {
    border: 1px solid var(--gold);
    background: var(--parchment-light);
    color: var(--navy-dark);
    box-shadow: 0 2px 7px rgba(0, 0, 0, 0.16);
}

.text-button {
    color: var(--navy-dark);
    font-family: 'Roboto Slab', Georgia, serif;
    font-weight: 700;
}

@media (max-width: 360px) {
    .title,
    .result-title {
        font-size: 25px;
        letter-spacing: 0.025em;
    }

    .next-button,
    .check-answer-button,
    .result-button {
        padding: 7px 11px;
        font-size: 11px;
    }
}

.story-copy,
.auth-copy {
    transform: translateY(12px);
}

/* Knoppen hoger plaatsen zodat de score zichtbaar blijft */
.next-button,
.result-button {
    bottom: 10%;
}

.puzzle .check-answer-button {
    bottom: 17%;
}

/* Tussenstand iets naar rechts */
.score {
    transform: translateX(12px);
}

/* Pages with their own full-page background (page 6, Eddie.jpeg): keep the
   template's 9:16 proportions and crop the image to fill the page, so the text
   and buttons sit where they do on the other pages. */
.page.has-custom-background {
    aspect-ratio: 9 / 16;
}

.page.has-custom-background .background {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}


/* Keep the hint between the answer field and the blue check button. */
.puzzle {
    display: flex;
    flex-direction: column;
    /* The button used to sit 17% above the form bottom; preserve that screen position. */
    bottom: 10%;
}

.puzzle-hint {
    position: relative;
    z-index: 1;
    width: min(100%, 340px);
    max-width: none;
    max-height: 60px;
    margin: 10px auto 0;
    padding: 8px 12px;
    overflow-y: auto;
    transform: none;
    line-height: 1.3;
    overscroll-behavior: contain;
}

.puzzle .check-answer-button {
    position: static;
    right: auto;
    bottom: auto;
    align-self: flex-end;
    margin-top: auto;
}
/* Answer directly above the submit button, leaving the rebus visible.
   The question remains at the top; hints appear before the answer field. */
.puzzle > .puzzle-question {
    order: 0;
}
.puzzle > .puzzle-hint,
.puzzle > .hint-button {
    order: 1;
    flex-shrink: 0;
}
.puzzle > .puzzle-inputs,
.puzzle > .puzzle-text-input {
    order: 2;
    margin-top: auto;
    margin-bottom: 0;
    flex-shrink: 0;
}
.puzzle > .check-answer-button {
    order: 3;
    margin-top: 12px;
    flex-shrink: 0;
}

/* Timer and penalty score at the top rather than the bottom of the screen. */
.page > .score {
    top: calc(12px + env(safe-area-inset-top, 0px));
    bottom: auto;
    z-index: 5;
}
