:root {
    color-scheme: dark;
    --ink: #0a0a0c;
    --panel: #151412;
    --paper: #f1ead9;
    --muted: #aaa394;
    --gold: #c9a75d;
    --gold-bright: #f0d38b;
    --line: rgba(201, 167, 93, 0.28);
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
    background: var(--ink);
}

body {
    min-width: 320px;
    min-height: 100vh;
    min-height: 100dvh;
    margin: 0;
    background:
        radial-gradient(circle at 50% -10%, rgba(132, 94, 39, 0.2), transparent 44%),
        linear-gradient(180deg, #121112 0%, #08080a 100%);
    color: var(--paper);
    font-family: "Yu Mincho", "Hiragino Mincho ProN", "Hiragino Mincho Pro", Georgia, serif;
    -webkit-font-smoothing: antialiased;
}

body:not(.records-page) {
    --panel: #211a14;
    --muted: #b6aa97;
    --gold: #d0a451;
    --gold-bright: #f4cf77;
    --line: rgba(214, 169, 83, 0.32);
    background:
        radial-gradient(circle at 18% 12%, rgba(225, 157, 57, 0.17), transparent 30%),
        radial-gradient(circle at 84% 72%, rgba(136, 81, 28, 0.18), transparent 36%),
        linear-gradient(160deg, #271b11 0%, #17120e 52%, #21140b 100%);
}

body:not(.records-page)::before {
    content: "";
    position: fixed;
    top: 14%;
    right: -74px;
    width: 230px;
    aspect-ratio: 1;
    border: 1px solid rgba(236, 185, 91, 0.5);
    border-radius: 50%;
    background:
        radial-gradient(circle, transparent 0 31%, rgba(236, 185, 91, 0.46) 31.5% 32%, transparent 32.5%),
        conic-gradient(
            from 45deg,
            transparent 0 12%,
            rgba(236, 185, 91, 0.5) 12.2% 12.8%,
            transparent 13% 37%,
            rgba(236, 185, 91, 0.5) 37.2% 37.8%,
            transparent 38% 62%,
            rgba(236, 185, 91, 0.5) 62.2% 62.8%,
            transparent 63% 87%,
            rgba(236, 185, 91, 0.5) 87.2% 87.8%,
            transparent 88%
        );
    opacity: 0.1;
    pointer-events: none;
}

a {
    color: inherit;
}

.title-screen {
    width: min(100%, 720px);
    min-height: 100vh;
    min-height: 100dvh;
    margin: 0 auto;
    padding:
        max(22px, env(safe-area-inset-top))
        clamp(16px, 5vw, 34px)
        max(16px, env(safe-area-inset-bottom));
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 14px;
    position: relative;
}

.hero {
    text-align: center;
}

.title-lockup {
    min-height: 62px;
    display: grid;
    place-content: center;
}

.title-lockup img {
    display: block;
    width: min(76vw, 420px);
    max-height: 96px;
    object-fit: contain;
}

.title-kicker {
    margin: 0 0 4px;
    color: #a69272;
    font-family: Georgia, serif;
    font-size: 9px;
    letter-spacing: 0.24em;
    text-transform: uppercase;
}

h1 {
    margin: 0;
    color: #f5eedf;
    font-size: clamp(26px, 8vw, 44px);
    font-weight: 500;
    letter-spacing: 0.1em;
    line-height: 1.1;
    text-shadow: 0 2px 22px rgba(215, 173, 92, 0.18);
}

.introduction {
    margin: 8px 0 13px;
    color: #ddd1bd;
    font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", "Hiragino Kaku Gothic ProN", sans-serif;
    font-size: 14px;
    letter-spacing: 0.035em;
    line-height: 1.55;
}

.start-button {
    width: 100%;
    min-height: 76px;
    padding: 12px 20px;
    border: 1px solid rgba(255, 216, 126, 0.92);
    border-radius: 5px;
    background:
        linear-gradient(180deg, rgba(255, 243, 205, 0.17), transparent 48%),
        linear-gradient(135deg, #865a1f, #bd8432 52%, #79501d);
    box-shadow:
        0 10px 28px rgba(0, 0, 0, 0.34),
        0 0 30px rgba(221, 162, 61, 0.2),
        inset 0 1px 0 rgba(255, 246, 216, 0.36);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: inherit;
    font: inherit;
    cursor: pointer;
    text-decoration: none;
    transition: border-color 160ms ease, filter 160ms ease, transform 160ms ease;
}

.start-button:hover {
    filter: brightness(1.09);
}

.start-button:active {
    transform: translateY(1px);
}

.start-button:focus-visible {
    outline: 3px solid var(--gold-bright);
    outline-offset: 3px;
}

.chapter-name {
    color: #fff4d7;
    font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", "Hiragino Kaku Gothic ProN", sans-serif;
    font-size: 13px;
    letter-spacing: 0.04em;
}

.start-label {
    margin-top: 4px;
    color: #fffaf0;
    font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", "Hiragino Kaku Gothic ProN", sans-serif;
    font-size: 20px;
    font-weight: 700;
    letter-spacing: 0.08em;
}

.startup-error[hidden] {
    display: none;
}

.save-picker-row:focus-visible,
.records-back:focus-visible {
    outline: 2px solid var(--gold-bright);
    outline-offset: 2px;
}

.startup-error {
    margin: 0 0 8px;
    padding: 9px 12px;
    border: 1px solid rgba(205, 98, 82, 0.55);
    background: rgba(100, 28, 22, 0.24);
    color: #efc0b7;
    font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", "Hiragino Kaku Gothic ProN", sans-serif;
    font-size: 11px;
    line-height: 1.5;
}

.records-screen {
    width: min(100%, 560px);
    min-height: 100vh;
    min-height: 100dvh;
    margin: 0 auto;
    padding:
        max(20px, env(safe-area-inset-top))
        16px
        max(20px, env(safe-area-inset-bottom));
    display: grid;
    align-content: center;
    gap: 10px;
}

.records-back {
    width: fit-content;
    color: #928a7b;
    font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", "Hiragino Kaku Gothic ProN", sans-serif;
    font-size: 11px;
    text-decoration: none;
}

.records-panel {
    min-height: 0;
    max-height: calc(100dvh - 72px);
    border: 1px solid rgba(201, 167, 93, 0.48);
    border-radius: 6px;
    background:
        radial-gradient(circle at 50% 0%, rgba(132, 94, 39, 0.14), transparent 34%),
        #151412;
    box-shadow: 0 18px 52px rgba(0, 0, 0, 0.64);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.records-header {
    padding: 18px 16px 14px;
    border-bottom: 1px solid var(--line);
    text-align: center;
}

.records-header p {
    margin: 0 0 4px;
    color: var(--gold);
    font-size: 11px;
    letter-spacing: 0.12em;
}

.records-header h1 {
    margin: 0 0 7px;
    color: #f2e8d2;
    font-size: 24px;
    font-weight: 500;
    letter-spacing: 0.08em;
}

.records-header span {
    color: #928a7b;
    font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", "Hiragino Kaku Gothic ProN", sans-serif;
    font-size: 10px;
    letter-spacing: 0.08em;
}

.records-error {
    margin: 10px 10px 0;
}

.records-list {
    min-height: 0;
    padding: 10px;
    display: grid;
    gap: 8px;
    overflow-y: auto;
    overscroll-behavior: contain;
}

.save-picker-row {
    width: 100%;
    min-height: 66px;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.025);
    color: var(--paper);
    font: inherit;
    cursor: pointer;
    text-align: left;
    display: grid;
    gap: 5px;
}

.save-picker-row:hover:not(:disabled) {
    border-color: rgba(240, 211, 139, 0.62);
    background: rgba(201, 167, 93, 0.08);
}

.save-picker-row:disabled {
    color: #706b62;
    cursor: default;
}

.save-picker-row strong {
    color: #f0dfbb;
    font-size: 13px;
    font-weight: 500;
}

.save-picker-row:disabled strong {
    color: #77736c;
}

.save-picker-row span {
    font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", "Hiragino Kaku Gothic ProN", sans-serif;
    font-size: 10px;
    line-height: 1.45;
    white-space: pre-line;
}

.new-game-row {
    border-color: rgba(240, 211, 139, 0.54);
    background: rgba(201, 167, 93, 0.1);
}

.new-game-row strong {
    color: #fff0c9;
}

.chapter-menu {
    display: grid;
}

.chapter-list {
    margin-top: 9px;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
}

.chapter-item {
    min-height: 34px;
    border: 1px solid rgba(214, 169, 83, 0.13);
    background: rgba(126, 83, 31, 0.08);
    display: grid;
    place-items: center;
    color: #77736c;
    font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", "Hiragino Kaku Gothic ProN", sans-serif;
    font-size: 11px;
    letter-spacing: 0.02em;
    text-decoration: none;
}

.chapter-item-name,
.chapter-item-status {
    display: block;
}

.chapter-item-status {
    margin-top: 2px;
    font-size: 10px;
    color: #66625c;
}

.is-disabled {
    cursor: default;
}

.characters {
    min-height: 196px;
    border: 1px solid rgba(224, 176, 87, 0.48);
    background: #241c15;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    overflow: hidden;
}

.character-card {
    --character-image: none;
    --character-position: center;
    --character-filter: none;
    min-width: 0;
    padding: 14px 12px;
    position: relative;
    background:
        radial-gradient(circle at 50% 27%, rgba(232, 178, 94, 0.22), transparent 58%),
        linear-gradient(145deg, #3b3125, #211a16);
    display: flex;
    align-items: flex-end;
    isolation: isolate;
    overflow: hidden;
}

.character-card::before,
.character-card::after {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
}

.character-card::before {
    z-index: -2;
    background-image: var(--character-image);
    background-position: var(--character-position);
    background-size: cover;
    background-repeat: no-repeat;
    filter: var(--character-filter);
}

.character-card::after {
    z-index: -1;
    background: linear-gradient(
        180deg,
        rgba(18, 12, 8, 0.02) 0%,
        rgba(18, 12, 8, 0.1) 30%,
        rgba(18, 12, 8, 0.62) 56%,
        rgba(13, 10, 8, 0.92) 100%
    );
}

.character-card + .character-card {
    border-left: 1px solid rgba(224, 176, 87, 0.4);
}

.character-card--cain {
    --character-image: url("images/top-cain-costume.png");
    --character-position: 48% 36%;
    --character-filter: brightness(1.27) contrast(1.08) saturate(1.02)
        drop-shadow(0 0 11px rgba(235, 184, 104, 0.4));
}

.character-card--owen {
    --character-image: url("images/top-owen-costume.png");
    --character-position: 61% 34%;
    --character-filter: brightness(1.09) contrast(1.04) saturate(1.08)
        drop-shadow(0 0 9px rgba(206, 166, 232, 0.28));
}

.character-copy {
    width: 100%;
    position: relative;
    z-index: 1;
}

.character-copy h2 {
    margin: 0 0 7px;
    color: #eee4ce;
    font-size: 17px;
    font-weight: 500;
    letter-spacing: 0.08em;
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.96);
}

.character-copy p {
    margin: 0;
    color: #c4bdaf;
    font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", "Hiragino Kaku Gothic ProN", sans-serif;
    font-size: 10.5px;
    line-height: 1.65;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.98);
}

.utility-links {
    display: flex;
    justify-content: center;
    gap: 14px;
    color: #958b7c;
    font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", "Hiragino Kaku Gothic ProN", sans-serif;
    font-size: 14px;
}

.utility-links a:not([href]) {
    cursor: default;
    text-decoration: none;
}

.utility-links a {
    display: inline-block;
    padding: 8px 6px;
}

.utility-links a.feedback-link {
    color: #f2d697;
}

.utility-links a.feedback-link:hover {
    color: #f7dea0;
}

.utility-links a[href]:hover {
    color: #d8c8aa;
}

.creator-note {
    margin: 0;
    color: #7d7364;
    font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", "Hiragino Kaku Gothic ProN", sans-serif;
    font-size: 11px;
    line-height: 1.6;
    text-align: center;
}

.guide-screen {
    width: min(100%, 680px);
    min-height: 100vh;
    min-height: 100dvh;
    margin: 0 auto;
    padding:
        max(20px, env(safe-area-inset-top))
        clamp(14px, 4vw, 28px)
        max(28px, env(safe-area-inset-bottom));
    position: relative;
}

.guide-back,
.guide-bottom-link {
    color: #b8aa93;
    font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", "Hiragino Kaku Gothic ProN", sans-serif;
    font-size: 12px;
    text-decoration: none;
}

.guide-back {
    display: inline-block;
    margin-bottom: 16px;
}

.guide-back:hover,
.guide-bottom-link:hover {
    color: #f2d697;
}

.guide-back:focus-visible,
.guide-bottom-link:focus-visible,
.guide-form-link:focus-visible,
.guide-disclosures summary:focus-visible {
    outline: 2px solid var(--gold-bright);
    outline-offset: 3px;
}

.guide-hero {
    margin-bottom: 14px;
    padding: 22px 18px;
    border: 1px solid rgba(224, 176, 87, 0.48);
    border-radius: 7px;
    background:
        radial-gradient(circle at 12% 0%, rgba(224, 160, 65, 0.16), transparent 38%),
        rgba(26, 19, 14, 0.86);
    box-shadow: 0 14px 34px rgba(0, 0, 0, 0.22);
}

.guide-kicker {
    margin: 0 0 5px;
    color: #c7a665;
    font-family: Georgia, serif;
    font-size: 9px;
    letter-spacing: 0.2em;
    text-transform: uppercase;
}

.guide-hero h1 {
    margin: 0 0 14px;
    font-size: clamp(28px, 9vw, 40px);
    letter-spacing: 0.08em;
}

.guide-hero p,
.guide-section > p,
.guide-answer,
.guide-history {
    font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", "Hiragino Kaku Gothic ProN", sans-serif;
}

.guide-hero p {
    margin: 0;
    color: #d8cebc;
    font-size: 13px;
    line-height: 1.7;
}

.guide-hero p + p {
    margin-top: 6px;
    color: #ac9f8c;
    font-size: 11px;
}

.guide-section {
    margin-top: 10px;
    padding: 16px 14px;
    border: 1px solid rgba(214, 169, 83, 0.3);
    border-radius: 6px;
    background: rgba(24, 19, 15, 0.8);
}

.guide-section h2 {
    margin: 0 0 12px;
    color: #f1e2c4;
    font-size: 18px;
    font-weight: 500;
    letter-spacing: 0.06em;
}

.guide-section > p {
    margin: 0 0 12px;
    color: #c7bdad;
    font-size: 12px;
    line-height: 1.7;
}

.guide-section .guide-section-note {
    color: #958a7a;
    font-size: 10.5px;
}

.guide-disclosures {
    display: grid;
    gap: 7px;
}

.guide-disclosures details {
    border: 1px solid rgba(214, 169, 83, 0.26);
    border-radius: 5px;
    background: rgba(255, 255, 255, 0.025);
    overflow: hidden;
}

.guide-disclosures details[open] {
    border-color: rgba(232, 187, 101, 0.5);
    background: rgba(137, 91, 34, 0.1);
}

.guide-disclosures summary {
    min-height: 48px;
    padding: 12px 12px 12px 38px;
    position: relative;
    display: flex;
    align-items: center;
    color: #eadcc2;
    font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", "Hiragino Kaku Gothic ProN", sans-serif;
    font-size: 13px;
    line-height: 1.45;
    cursor: pointer;
    list-style: none;
}

.guide-disclosures summary::-webkit-details-marker {
    display: none;
}

.guide-disclosures summary::before {
    content: "▶";
    position: absolute;
    left: 14px;
    color: #d2a958;
    font-size: 10px;
}

.guide-disclosures details[open] summary::before {
    content: "▼";
}

.guide-answer {
    padding: 12px 14px;
    border-top: 1px solid rgba(214, 169, 83, 0.2);
    color: #c9bfaf;
    font-size: 12px;
    line-height: 1.7;
}

.guide-answer p,
.guide-history p {
    margin: 0;
}

.guide-spoiler {
    border-color: rgba(166, 130, 183, 0.32);
    background:
        radial-gradient(circle at 100% 0%, rgba(122, 86, 143, 0.1), transparent 42%),
        rgba(23, 18, 22, 0.82);
}

.guide-form-link {
    min-height: 48px;
    margin-top: 4px;
    border: 1px solid rgba(255, 216, 126, 0.72);
    border-radius: 5px;
    background: linear-gradient(135deg, #7c531e, #a9722a 52%, #70491b);
    display: grid;
    place-items: center;
    color: #fff4d7;
    font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", "Hiragino Kaku Gothic ProN", sans-serif;
    font-size: 13px;
    font-weight: 700;
    text-decoration: none;
}

.guide-form-link:hover {
    filter: brightness(1.08);
}

.guide-section .guide-form-note {
    margin: 7px 0 0;
    color: #958a7a;
    font-size: 10px;
}

.guide-history {
    color: #c9bfaf;
    font-size: 12px;
    line-height: 1.7;
}

.guide-history time {
    display: block;
    margin-bottom: 5px;
    color: #e2c98f;
}

.guide-history .guide-section-note {
    margin-top: 7px;
}

.guide-bottom-link {
    display: block;
    width: fit-content;
    margin: 18px auto 0;
}

@media (max-height: 680px) {
    .title-screen {
        justify-content: flex-start;
        gap: 11px;
        padding-top: max(14px, env(safe-area-inset-top));
    }

    .title-lockup {
        min-height: 56px;
    }

    .introduction {
        margin: 8px 0 11px;
        line-height: 1.5;
    }

    .start-button {
        min-height: 66px;
    }

    .characters {
        min-height: 160px;
    }

    .records-screen {
        align-content: start;
        padding-top: max(14px, env(safe-area-inset-top));
    }

    .records-panel {
        max-height: calc(100dvh - 58px);
    }

    .records-header {
        padding: 13px 14px 10px;
    }
}

@media (min-width: 600px) {
    .title-screen {
        padding-inline: 42px;
    }

    .characters {
        min-height: 220px;
    }

    .character-card {
        padding: 20px;
    }

    .character-copy p {
        font-size: 12px;
    }

    .guide-screen {
        padding-top: 32px;
        padding-bottom: 42px;
    }

    .guide-hero {
        padding: 28px 24px;
    }

    .guide-section {
        padding: 20px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .start-button {
        transition: none;
    }
}
