:root {
    color-scheme: light;
    --paper: #f4f1e7;
    --paper-sheet: rgba(250, 248, 240, 0.94);
    --ink: #282923;
    --muted: #55574e;
    --line: #c3c0b4;
    --green: #31583f;
    --green-dark: #203f2c;
    --red: #762e2e;
    --gold: #654d19;
    --focus: #1e5a93;
    font-family: system-ui, -apple-system, "Segoe UI", "Noto Sans JP", "Yu Gothic UI", Meiryo, sans-serif;
    line-height: 1.7;
    background: var(--paper);
    color: var(--ink);
}

* {
    box-sizing: border-box;
}

html {
    min-width: 320px;
    scroll-behavior: smooth;
}

body {
    margin: 0;
    background-color: #e9e5d9;
    background-image: url("img/washi.png");
    background-repeat: repeat;
    color: var(--ink);
}

button,
input,
textarea {
    font: inherit;
}

button,
input[type="file"],
input[type="text"],
textarea {
    color: inherit;
}

a {
    color: var(--green-dark);
    text-underline-offset: 0.2em;
}

a:hover {
    text-decoration-thickness: 2px;
}

:where(a, button, input, textarea):focus-visible {
    outline: 3px solid var(--focus);
    outline-offset: 3px;
}

.skip-link {
    position: absolute;
    z-index: 20;
    top: 0;
    left: -10000px;
    display: inline-flex;
    min-height: 44px;
    align-items: center;
    padding: 0.6rem 0.9rem;
    background: #fff;
    color: #142b1b;
    font-weight: 700;
}

.skip-link:focus {
    position: fixed;
    top: 0.75rem;
    left: 0.75rem;
}

.page-shell {
    width: min(100%, 68rem);
    min-height: 100vh;
    margin: 0 auto;
    padding: clamp(1rem, 4vw, 3.5rem) clamp(1rem, 5vw, 4rem) 2.5rem;
    border-inline: 1px solid #d4d0c3;
    background: var(--paper-sheet);
}

.page-header {
    max-width: 48rem;
    padding-bottom: clamp(1.5rem, 4vw, 3rem);
    border-bottom: 2px solid var(--ink);
}

.breadcrumb {
    display: flex;
    min-height: 44px;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: clamp(2rem, 6vw, 4.5rem);
    color: var(--muted);
    font-size: 0.94rem;
}

.breadcrumb a {
    display: inline-flex;
    min-height: 44px;
    align-items: center;
}

.eyebrow {
    margin: 0 0 0.35rem;
    color: var(--green-dark);
    font-size: 0.84rem;
    font-weight: 700;
    letter-spacing: 0.06em;
}

h1,
h2,
h3,
p {
    overflow-wrap: anywhere;
}

h1,
h2,
h3 {
    line-height: 1.3;
}

h1 {
    margin: 0;
    font-family: Georgia, "Noto Serif JP", "Yu Mincho", serif;
    font-size: clamp(2.15rem, 7vw, 4.6rem);
    font-weight: 600;
    letter-spacing: 0.015em;
}

.intro {
    max-width: 39rem;
    margin: 1rem 0 0;
    color: #41433b;
    font-size: clamp(1rem, 2.4vw, 1.18rem);
}

main {
    max-width: 58rem;
}

main:focus {
    outline: 3px solid var(--focus);
    outline-offset: 0.45rem;
}

section {
    padding-block: clamp(1.65rem, 4.5vw, 3rem);
    border-bottom: 1px solid var(--line);
}

.section-heading {
    margin-bottom: 1.2rem;
}

.section-heading h2 {
    margin: 0;
    font-size: clamp(1.45rem, 4vw, 2rem);
}

.section-heading > p:last-child:not(.eyebrow) {
    max-width: 42rem;
    margin: 0.55rem 0 0;
    color: var(--muted);
}

.rule-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.3rem 2rem;
    margin: 0;
    padding-left: 1.4rem;
}

.rule-list li {
    padding: 0.4rem 0.2rem 0.4rem 0.15rem;
}

.form-message {
    margin: 1.25rem 0 0;
    padding: 0.75rem 1rem;
    border-left: 4px solid var(--red);
    background: #f7eae5;
    color: #5d2222;
    font-weight: 700;
}

.contribute {
    padding-inline: clamp(1rem, 3vw, 1.75rem);
    border: 1px solid #aeb4a0;
    border-left: 5px solid var(--green);
    background: rgba(235, 237, 226, 0.78);
}

.submission-form {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem 1.25rem;
    align-items: end;
}

.field-group {
    display: grid;
    gap: 0.4rem;
    min-width: 0;
}

.field-group label,
.reply-form label {
    font-weight: 700;
}

.field-group label span {
    margin-left: 0.35rem;
    color: var(--muted);
    font-size: 0.9rem;
    font-weight: 400;
}

.field-group input[type="text"],
.field-group input[type="file"],
.reply-form textarea {
    width: 100%;
    min-height: 48px;
    padding: 0.65rem 0.75rem;
    border: 1px solid #777a70;
    border-radius: 0;
    background: #fffefa;
}

.field-group input[type="file"] {
    padding: 0.45rem;
}

.field-group small {
    color: #484a43;
    font-size: 0.9rem;
}

.button {
    display: inline-flex;
    min-width: 44px;
    min-height: 44px;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    padding: 0.55rem 0.85rem;
    border: 1px solid #73766b;
    border-radius: 0;
    background: #f9f7ef;
    color: #252720;
    cursor: pointer;
    text-align: center;
    text-decoration: none;
}

.button:hover {
    background: #eeece2;
}

.button-primary {
    min-height: 48px;
    padding-inline: 1.25rem;
    border-color: var(--green-dark);
    background: var(--green-dark);
    color: #fff;
    font-weight: 700;
}

.button-primary:hover {
    background: #173321;
}

.inline-form {
    display: inline-flex;
    margin: 0;
}

.current-entry {
    display: grid;
    grid-template-columns: minmax(12rem, 0.8fr) minmax(0, 1.2fr);
    gap: clamp(1rem, 4vw, 2.5rem);
    align-items: center;
}

.entry-image {
    min-width: 0;
    margin: 0;
}

.image-trigger {
    display: block;
    width: fit-content;
    max-width: 100%;
    min-width: 44px;
    min-height: 44px;
    padding: 0;
    border: 1px solid var(--line);
    border-radius: 0;
    background: #fffefa;
    cursor: zoom-in;
}

.image-trigger img {
    display: block;
    width: auto;
    max-width: 100%;
    max-height: 22rem;
    object-fit: contain;
}

.entry-image figcaption {
    margin-top: 0.35rem;
    color: var(--muted);
    font-size: 0.85rem;
}

.current-answer-hint {
    margin-top: 0;
    font-weight: 700;
}

.timestamp {
    color: var(--muted);
    font-size: 0.9rem;
}

.entry-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
    margin-top: 0.8rem;
}

.relay-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem 0.65rem;
    align-items: center;
    margin: 0;
    padding: 0;
    list-style: none;
}

.relay-list li {
    display: inline-flex;
    min-height: 44px;
    align-items: center;
}

.relay-list li + li::before {
    margin-right: 0.65rem;
    color: #696b62;
    content: "→";
}

.relay-word {
    display: inline-flex;
    min-height: 44px;
    align-items: center;
    padding-inline: 0.6rem;
    border-bottom: 1px solid #898b81;
    color: #292b25;
    font-weight: 700;
}

button.relay-word {
    border-top: 0;
    border-right: 0;
    border-left: 0;
    background: transparent;
    cursor: zoom-in;
}

.relay-next {
    color: var(--green-dark);
    font-weight: 700;
}

.empty-state {
    margin: 0;
    padding-block: 1rem;
    border-top: 1px solid var(--line);
    color: var(--muted);
}

.post-list {
    border-top: 1px solid var(--line);
}

.post-entry {
    display: grid;
    grid-template-columns: minmax(10rem, 0.72fr) minmax(0, 1.28fr);
    gap: clamp(1rem, 4vw, 2rem);
    padding-block: 1.5rem;
    border-bottom: 1px solid var(--line);
}

.post-entry .entry-image img {
    max-height: 18rem;
}

.post-invalid {
    background: rgba(112, 48, 43, 0.035);
}

.post-incorrect {
    border-left: 3px solid #8a4c26;
    padding-left: 1rem;
}

.post-correct {
    border-left: 3px solid var(--green);
    padding-left: 1rem;
}

.post-heading {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem 0.75rem;
    align-items: center;
}

.post-heading h3 {
    margin: 0;
    font-size: 1.1rem;
}

.post-status {
    display: inline-flex;
    min-height: 30px;
    align-items: center;
    padding: 0.1rem 0.55rem;
    border: 1px solid currentColor;
    font-size: 0.86rem;
    font-weight: 700;
}

.status-correct {
    color: #23492f;
}

.status-incorrect {
    color: #713719;
}

.status-invalid {
    color: #5f3030;
}

.post-answer {
    margin: 0.65rem 0;
    font-weight: 700;
}

.reply-editor {
    margin-top: 0.85rem;
    padding: 0.85rem;
    border-left: 3px solid #8a8c80;
    background: rgba(238, 236, 226, 0.72);
}

.reply-form {
    display: grid;
    gap: 0.55rem;
}

.reply-form textarea {
    min-height: 6rem;
    resize: vertical;
}

.reply-list {
    margin-top: 1rem;
    padding-left: 1rem;
    border-left: 2px solid #b6b5aa;
}

.reply-entry {
    padding-block: 0.55rem;
    border-bottom: 1px dotted #b6b5aa;
}

.reply-entry p:first-child {
    margin-top: 0;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.reply-entry p:last-child {
    margin-bottom: 0;
}

.visually-hidden {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

.image-dialog {
    width: min(92vw, 62rem);
    max-width: 62rem;
    max-height: 92vh;
    max-height: 92dvh;
    padding: clamp(0.75rem, 3vw, 1.5rem);
    border: 1px solid #d1cec1;
    border-radius: 0;
    background: var(--paper);
    color: var(--ink);
}

.image-dialog::backdrop {
    background: rgba(24, 25, 21, 0.82);
}

.dialog-content {
    display: grid;
    max-height: calc(92dvh - 3rem);
    gap: 0.75rem;
}

.dialog-heading {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 0.5rem;
    align-items: center;
}

.dialog-heading h2 {
    margin: 0;
    font-size: 1.2rem;
}

#dialog-image {
    display: block;
    width: 100%;
    max-height: calc(82dvh - 5rem);
    object-fit: contain;
}

.page-footer {
    display: flex;
    min-height: 64px;
    align-items: center;
    margin-top: 1.5rem;
    border-top: 1px solid var(--line);
}

.page-footer a {
    display: inline-flex;
    min-height: 44px;
    align-items: center;
}

@media (max-width: 42rem) {
    .page-shell {
        padding-inline: 1rem;
    }

    .breadcrumb {
        margin-bottom: 2rem;
    }

    .rule-list {
        grid-template-columns: minmax(0, 1fr);
        gap: 0;
    }

    .submission-form {
        grid-template-columns: minmax(0, 1fr);
    }

    .current-entry,
    .post-entry {
        grid-template-columns: minmax(0, 1fr);
    }

    .post-incorrect,
    .post-correct {
        padding-left: 0.75rem;
    }

    .post-entry .entry-image img,
    .current-entry .entry-image img {
        max-height: 20rem;
    }

    .entry-actions {
        gap: 0.4rem;
    }
}

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

