@import url('https://fonts.googleapis.com/css2?family=Yuji+Boku&family=Zen+Old+Mincho:wght@400;500;700&display=swap');

:root {
    --ink: #171917;
    --indigo: #102b52;
    --paper: #f5f0e4;
    --muted-ink: #74736d;
    --highlight-color: #164980;
    --completed-color: #989892;
    --error-color: #ae3d31;
    --display-font: "Yuji Boku", "Hiragino Mincho ProN", "Yu Mincho", "Noto Serif JP", serif;
    --body-font: "Hiragino Mincho ProN", "Yu Mincho", "Noto Serif JP", serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
    min-height: 100vh;
    margin: 0;
    color: var(--ink);
    font-family: var(--body-font);
    background: var(--paper) url("../assets/washi-background.png") center / cover fixed;
}

button { font: inherit; }

a { color: var(--indigo); text-underline-offset: .22em; }

.site-header {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    min-height: 64px;
    align-items: center;
    justify-content: space-between;
    gap: 2rem;
    padding: .8rem clamp(1.25rem, 4vw, 3.5rem);
    border-bottom: 1px solid rgba(16, 43, 82, .14);
    background: rgba(245, 240, 228, .88);
    backdrop-filter: blur(12px);
}

.site-brand { font-family: var(--display-font); font-size: 1.2rem; font-weight: 700; letter-spacing: .12em; text-decoration: none; }
.site-nav { display: flex; flex-wrap: wrap; gap: clamp(.8rem, 3vw, 2rem); font-size: .82rem; }
.site-nav a { text-decoration: none; }
.site-nav a:hover, .site-footer a:hover { text-decoration: underline; }

.start-screen {
    display: block;
}

.start-hero {
    display: grid;
    min-height: calc(100vh - 64px);
    place-items: center;
    padding: 2rem;
    text-align: center;
}

.start-content { position: relative; animation: rise-in 700ms ease-out both; }

.start-kicker {
    position: absolute;
    top: .6rem;
    right: -3.8rem;
    margin: 0;
    color: var(--indigo);
    font-size: 1rem;
    letter-spacing: .55em;
    writing-mode: vertical-rl;
}

.start-title {
    margin: 0 auto;
    font-family: var(--display-font);
    font-size: clamp(4.2rem, 9vw, 7rem);
    font-weight: 700;
    letter-spacing: .12em;
    line-height: 1;
    writing-mode: vertical-rl;
    text-shadow: 1px 2px 0 rgba(255,255,255,.38);
}

.start-lead {
    margin: 2rem 0 2.4rem;
    color: var(--indigo);
    font-size: clamp(1rem, 2.5vw, 1.3rem);
    letter-spacing: .18em;
}

.start-button, .reset-button {
    padding: .85rem 3.3rem;
    border: 1px solid transparent;
    border-radius: 3px;
    background: var(--indigo);
    color: #fffdf7;
    cursor: pointer;
    font-family: var(--body-font);
    font-size: 1.2rem;
    letter-spacing: .22em;
    box-shadow: 0 8px 18px rgba(16, 43, 82, .18);
    transition: transform .2s ease, background-color .2s ease;
}

.start-button:hover, .reset-button:hover { background: #1c4579; transform: translateY(-2px); }
.start-button:focus-visible, .reset-button:focus-visible, .back-button:focus-visible { outline: 3px solid #b48836; outline-offset: 4px; }

.content-wrap {
    border-top: 1px solid rgba(16, 43, 82, .15);
    background: rgba(245, 240, 228, .94);
}

.info-section {
    display: grid;
    grid-template-columns: 5rem minmax(0, 1fr);
    gap: clamp(1.5rem, 5vw, 4rem);
    width: min(860px, calc(100% - 2.5rem));
    margin: 0 auto;
    padding: clamp(4rem, 8vw, 7rem) 0;
    border-bottom: 1px solid rgba(16, 43, 82, .14);
}

.info-section:last-child { border-bottom: 0; }
.section-mark { margin: 0; color: #a27d35; font-family: var(--display-font); font-size: 3rem; line-height: 1; }
.info-section h2 { margin: 0 0 1.5rem; font-family: var(--display-font); font-size: clamp(1.8rem, 4vw, 2.7rem); letter-spacing: .1em; }
.info-section p { max-width: 42rem; margin: 0 0 1rem; font-size: 1.02rem; line-height: 2.05; }
.steps { margin: 0; padding-left: 1.4rem; }
.steps li { margin-bottom: .85rem; padding-left: .5rem; line-height: 1.9; }
.note { margin-top: 1.8rem !important; padding: 1rem 1.2rem; border-left: 3px solid #a27d35; background: rgba(255, 255, 255, .35); font-size: .9rem !important; }

.container {
    width: min(900px, calc(100% - 2.5rem));
    min-height: 100vh;
    margin: 0 auto;
    padding: 2rem 0 4rem;
}

.typing-header { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; margin-bottom: 2.6rem; }
.title { grid-column: 2; margin: 0; font-family: var(--display-font); font-size: clamp(2.4rem, 6vw, 4rem); font-weight: 700; letter-spacing: .18em; }
.back-button { grid-column: 1; justify-self: start; padding: .35rem 0; border: 0; border-bottom: 1px solid currentColor; background: transparent; color: var(--indigo); cursor: pointer; font-size: .9rem; }

.sutra-area { min-height: 60vh; font-size: clamp(1.7rem, 4vw, 2.5rem); line-height: 2.5; text-align: center; white-space: pre-wrap; word-break: keep-all; scroll-behavior: smooth; }
.char { display: inline-block; transition: color .2s ease, font-weight .2s ease; }
.char.current { color: var(--highlight-color); font-weight: bold; }
.char.completed { color: var(--completed-color); }
.char.error { color: var(--error-color); animation: flash-error .3s ease-out forwards; }
rt { font-size: .42em; transition: color .2s ease; }
.char.current + rt { color: var(--highlight-color); }
.char.completed + rt { color: var(--completed-color); }
.char.error + rt { color: var(--error-color); animation: flash-error .3s ease-out forwards; }
.completion-message { margin-top: 2rem; font-size: 1.15rem; text-align: center; }
.reset-button { display: block; margin: 2.4rem auto 0; font-size: 1rem; }

.ad-area {
    min-height: 120px;
    margin: 5rem 0 0;
    padding: 1rem 0;
    border-top: 1px solid rgba(16, 43, 82, .12);
    text-align: center;
}
.ad-label { margin: 0 0 .5rem; color: var(--muted-ink); font-size: .7rem; letter-spacing: .18em; }

.site-footer {
    padding: 3rem clamp(1.25rem, 5vw, 4rem);
    background: var(--indigo);
    color: #f8f3e8;
    text-align: center;
}
.footer-name { margin: 0 0 1.5rem; font-family: var(--display-font); font-size: 1.4rem; letter-spacing: .12em; }
.site-footer nav { display: flex; flex-wrap: wrap; justify-content: center; gap: .8rem 1.8rem; }
.site-footer a { color: inherit; font-size: .82rem; text-decoration: none; }
.copyright { margin: 1.8rem 0 0; color: rgba(248, 243, 232, .7); }

.document-main { min-height: calc(100vh - 64px); padding: clamp(3rem, 8vw, 7rem) 1.25rem; background: rgba(245, 240, 228, .94); }
.document-header, .document-body { width: min(760px, 100%); margin: 0 auto; }
.document-header { margin-bottom: clamp(3rem, 7vw, 5rem); }
.document-header h1 { margin: 0 0 1rem; font-family: var(--display-font); font-size: clamp(2.5rem, 7vw, 4.5rem); letter-spacing: .12em; }
.document-header .document-title-long { font-size: clamp(2.1rem, 6vw, 4rem); letter-spacing: .08em; }
.document-lead { margin: 0; color: var(--indigo); font-size: 1.05rem; line-height: 1.9; }
.document-body section { margin: 0 0 3.5rem; }
.document-body h2 { margin: 0 0 1.2rem; padding-bottom: .6rem; border-bottom: 1px solid rgba(16, 43, 82, .18); font-size: 1.35rem; letter-spacing: .08em; }
.document-body h3 { margin: 2rem 0 .8rem; font-size: 1.08rem; }
.document-body p, .document-body li, .document-body dd { font-size: .98rem; line-height: 1.95; }
.document-body ul, .document-body ol { padding-left: 1.4rem; }
.document-body li { margin-bottom: .5rem; }
.document-body dl { display: grid; grid-template-columns: 9rem 1fr; gap: 0; margin: 0; border-top: 1px solid rgba(16, 43, 82, .15); }
.document-body dt, .document-body dd { margin: 0; padding: 1rem; border-bottom: 1px solid rgba(16, 43, 82, .15); }
.document-body dt { color: var(--indigo); font-weight: 700; }
.revision-date { color: var(--muted-ink); font-size: .85rem !important; }
.source-sutra {
    margin: 1.5rem 0 0;
    padding: clamp(1.3rem, 4vw, 2rem);
    border: 1px solid rgba(16, 43, 82, .18);
    background: rgba(255, 255, 255, .32);
    font-family: var(--display-font);
    font-size: clamp(1.08rem, 3vw, 1.35rem) !important;
    letter-spacing: .08em;
    line-break: strict;
}
.verification-notice {
    padding: 1.2rem 1.3rem;
    border-left: 4px solid #a27d35;
    background: rgba(255, 255, 255, .42);
}
.verification-notice strong { color: var(--indigo); }
.revision-list { margin-top: 1rem; }
.contact-form { display: grid; gap: 1.1rem; }
.contact-form label { display: grid; gap: .45rem; font-size: .92rem; }
.contact-form input, .contact-form textarea { width: 100%; padding: .8rem .9rem; border: 1px solid rgba(16, 43, 82, .35); border-radius: 2px; background: rgba(255,255,255,.55); color: var(--ink); font: inherit; }
.contact-form textarea { min-height: 12rem; resize: vertical; }
.contact-form button { justify-self: start; padding: .75rem 2rem; border: 0; border-radius: 2px; background: var(--indigo); color: white; cursor: pointer; }
.contact-form button:disabled { cursor: not-allowed; opacity: .45; }
.setup-notice { padding: 1rem 1.2rem; border: 1px solid rgba(162, 125, 53, .45); background: rgba(255,255,255,.38); line-height: 1.8; }

@keyframes flash-error { from { opacity: 1; } to { opacity: .55; } }
@keyframes rise-in { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: translateY(0); } }

@media (max-height: 760px) and (min-width: 561px) {
    .start-title { font-size: 4.5rem; }
    .start-lead { margin: 1rem 0 1.4rem; }
}

@media (max-width: 560px) {
    body { background-attachment: scroll; }
    .site-header { align-items: center; gap: .7rem; }
    .site-brand { flex: 0 0 auto; font-size: .92rem; letter-spacing: .06em; white-space: nowrap; }
    .site-nav { justify-content: flex-end; gap: .5rem .75rem; font-size: .72rem; }
    .site-nav a:last-child { display: none; }
    .document-header .document-title-long { font-size: 1.8rem; letter-spacing: .05em; }
    .start-title { font-size: clamp(4.3rem, 20vw, 5.7rem); }
    .start-kicker { right: -2.7rem; font-size: .85rem; }
    .start-lead { margin-top: 1.5rem; }
    .typing-header { margin-bottom: 1.8rem; }
    .sutra-area { line-height: 2.25; }
    .info-section { grid-template-columns: 2.3rem minmax(0, 1fr); gap: 1rem; }
    .section-mark { font-size: 2rem; }
    .document-body dl { grid-template-columns: 1fr; }
    .document-body dt { padding-bottom: .35rem; border-bottom: 0; }
    .document-body dd { padding-top: 0; }
}

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