:root {
  --ink: #17221f;
  --muted: #6d7771;
  --paper: #f7f3eb;
  --card: #fffdf8;
  --line: #dedbd2;
  --red: #d74f3f;
  --red-dark: #b83e31;
  --green: #244a3c;
  --mint: #dce9df;
  --yellow: #f2c75c;
  --shadow: 0 16px 45px rgba(32, 47, 40, .09);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; background: var(--paper); color: var(--ink); font-family: "DM Sans", sans-serif; }
button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }
.shell { width: min(1180px, calc(100% - 56px)); margin: 0 auto; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.hidden { display: none !important; }

.topbar { position: sticky; top: 0; z-index: 30; background: rgba(247, 243, 235, .92); backdrop-filter: blur(18px); border-bottom: 1px solid rgba(23, 34, 31, .08); }
.nav { min-height: 78px; display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.brand { display: flex; align-items: center; gap: 12px; font-weight: 700; font-size: 20px; white-space: nowrap; }
.mark { width: 38px; height: 38px; position: relative; background: var(--red); color: white; border-radius: 12px; display: grid; place-items: center; font-family: "DM Sans", sans-serif; font-size: 13px; font-weight: 800; letter-spacing: -.06em; transform: rotate(-4deg); box-shadow: inset -4px -4px 0 rgba(87, 24, 18, .12); }
.mark::after { content: ""; position: absolute; width: 5px; height: 5px; border-radius: 50%; background: var(--yellow); top: 5px; right: 5px; }
.links { display: flex; gap: 6px; align-items: center; }
.nav-link { padding: 10px 15px; border-radius: 10px; color: #53605a; white-space: nowrap; }
.nav-link:hover, .nav-link.active { background: #ebe6dc; color: var(--ink); }

h1, h2, h3 { font-family: "Noto Serif JP", serif; margin: 0; }
.eyebrow { display: flex; align-items: center; gap: 10px; color: var(--red); font-weight: 700; font-size: 13px; letter-spacing: .13em; text-transform: uppercase; }
.eyebrow::before { content: ""; width: 32px; height: 2px; background: var(--red); }
.lead { font-size: 18px; line-height: 1.75; color: var(--muted); max-width: 720px; }
.primary, .secondary, .google-button { display: inline-flex; align-items: center; justify-content: center; gap: 10px; min-height: 48px; border-radius: 13px; padding: 13px 20px; font-weight: 700; border: 1px solid var(--ink); }
.primary { background: var(--ink); color: white; }
.primary:hover { background: var(--green); }
.primary:disabled, .secondary:disabled { cursor: not-allowed; opacity: .58; }
.secondary { background: transparent; color: var(--ink); }
.secondary:hover { background: white; }
.text-link { color: var(--red-dark); font-weight: 700; }
.text-link:hover { text-decoration: underline; }
.status { padding: 14px 16px; border-radius: 12px; background: #edf3ee; color: #3f5d4e; line-height: 1.5; }
.status.error { background: #f8e4df; color: #8f3228; }
.status.success { background: #e2f0e6; color: #275841; }

.hero { padding: 76px 0 48px; display: grid; grid-template-columns: 1.2fr .8fr; gap: 60px; align-items: center; }
.hero h1 { font-size: clamp(48px, 7vw, 82px); line-height: 1.03; letter-spacing: -.05em; margin: 18px 0 22px; }
.hero h1 span { color: var(--red); }
.actions { display: flex; gap: 12px; margin-top: 32px; flex-wrap: wrap; }
.hero-art { height: 410px; position: relative; }
.sun { position: absolute; width: 260px; height: 260px; border-radius: 50%; background: #efd7c7; top: 10px; right: 25px; }
.paper { position: absolute; width: 260px; height: 320px; background: var(--card); border: 1px solid var(--line); box-shadow: var(--shadow); border-radius: 8px; right: 70px; top: 44px; transform: rotate(5deg); padding: 28px; }
.paper-lines i { display: block; height: 7px; background: #e9e5dc; border-radius: 4px; margin: 13px 0; }
.paper-lines i:nth-child(2) { width: 70%; }
.paper-kanji { font-family: "Noto Serif JP"; font-size: 72px; color: var(--green); text-align: center; margin: 32px 0 22px; }
.stamp { position: absolute; width: 70px; height: 70px; border: 4px double var(--red); border-radius: 50%; color: var(--red); display: grid; place-items: center; font-family: "Noto Serif JP"; font-weight: 700; bottom: 26px; right: 24px; transform: rotate(-10deg); }
.scribble { position: absolute; font-family: "Noto Serif JP"; font-size: 14px; writing-mode: vertical-rl; color: #65736c; left: 25px; bottom: 10px; letter-spacing: .2em; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); margin-bottom: 82px; }
.stat { padding: 24px; text-align: center; border-right: 1px solid var(--line); }
.stat:last-child { border-right: 0; }
.stat strong { display: block; font-family: "Noto Serif JP"; font-size: 24px; }
.stat span { color: var(--muted); font-size: 13px; }
.home-choice { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; padding-bottom: 90px; }
.home-choice article, .seo-panel { border: 1px solid var(--line); background: var(--card); border-radius: 18px; padding: 30px; }
.home-choice h2 { font-size: 30px; margin: 18px 0 8px; }
.home-choice p, .seo-panel p { color: var(--muted); line-height: 1.7; }

.page-hero { padding: 72px 0 48px; }
.page-hero h1 { font-size: clamp(44px, 6vw, 72px); line-height: 1.08; letter-spacing: -.045em; margin: 18px 0; }
.section { padding: 15px 0 90px; }
.section-head { display: flex; align-items: end; justify-content: space-between; gap: 24px; margin-bottom: 28px; }
.section-head h2 { font-size: 40px; letter-spacing: -.03em; }
.section-head p { margin: 8px 0 0; color: var(--muted); }
.level-switch { display: flex; gap: 7px; background: #ece7dd; padding: 5px; border-radius: 13px; }
.level-switch span { border-radius: 9px; padding: 9px 15px; color: #777; }
.level-switch .active { background: var(--ink); color: white; }
.practice-grid, .test-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.practice-card { min-height: 310px; border: 1px solid var(--line); border-radius: 18px; padding: 26px; background: var(--card); position: relative; overflow: hidden; transition: .25s; }
.practice-card:hover { transform: translateY(-5px); box-shadow: var(--shadow); }
.practice-card::after { content: attr(data-jp); position: absolute; font-family: "Noto Serif JP"; font-size: 120px; opacity: .045; right: -6px; bottom: -37px; pointer-events: none; }
.iconbox { width: 48px; height: 48px; display: grid; place-items: center; border-radius: 14px; background: var(--mint); font-size: 23px; }
.practice-card:nth-child(2) .iconbox { background: #f1e0d9; }
.practice-card:nth-child(3) .iconbox { background: #f3e7b8; }
.practice-card h3 { font-size: 22px; margin: 22px 0 8px; }
.jp-label { color: var(--muted); font-size: 13px; }
.practice-card p { color: var(--muted); line-height: 1.6; }
.practice-card button { position: absolute; z-index: 1; bottom: 26px; border: 0; background: none; padding: 0; }
.practice-random { margin-top: 20px; border: 1px dashed #b9b5aa; padding: 23px; border-radius: 17px; display: flex; align-items: center; justify-content: space-between; gap: 20px; background: var(--card); }
.practice-random p { margin: 6px 0 0; color: var(--muted); }

.tests-page { background: var(--green); color: white; min-height: calc(100vh - 135px); }
.tests-page .page-hero .lead, .tests-page .section-head p { color: #bfd0c8; }
.tests-page .level-switch { background: rgba(255, 255, 255, .1); }
.tests-page .level-switch span { color: #b9cbc2; }
.tests-page .level-switch .active { background: white; color: var(--green); }
.light-panel { color: var(--ink); }
.test-card { background: var(--card); color: var(--ink); border-radius: 18px; padding: 24px; box-shadow: 0 20px 30px rgba(0, 0, 0, .1); }
.test-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 14px; }
.setno { color: var(--red); font-weight: 700; font-size: 12px; letter-spacing: .12em; }
.test-card h3 { font-size: 23px; margin-top: 7px; }
.pill { background: #eee9df; color: #5d6862; font-size: 12px; padding: 7px 10px; border-radius: 20px; white-space: nowrap; }
.score-row { display: grid; grid-template-columns: 1fr auto; gap: 10px; border-bottom: 1px solid #ebe7de; padding: 15px 0; font-size: 14px; }
.score-row span:first-child { color: var(--muted); }
.score-row b { font-variant-numeric: tabular-nums; }
.details-btn { width: 100%; border: 0; background: var(--red); color: white; border-radius: 12px; padding: 13px; margin-top: 18px; font-weight: 700; }
.details-btn:hover { background: var(--red-dark); }
.loading-card { min-height: 280px; display: grid; place-items: center; color: var(--muted); }

.about { display: grid; grid-template-columns: .8fr 1.2fr; gap: 80px; align-items: start; }
.about h2 { font-size: 43px; }
.about-copy > p { color: var(--muted); line-height: 1.8; margin-top: 0; }
.principles { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 25px; }
.principle { padding: 16px; border: 1px solid var(--line); border-radius: 13px; background: var(--card); }
.principle b { display: block; margin-bottom: 5px; }
.principle small { color: var(--muted); line-height: 1.5; }

.auth-page { min-height: 500px; padding-bottom: 90px; }
.login-card { max-width: 560px; background: var(--card); padding: 32px; border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); }
.login-card h2 { font-size: 28px; margin-bottom: 10px; }
.login-card p { color: var(--muted); line-height: 1.7; }
.google-button { width: 100%; background: white; color: #26312d; border-color: var(--line); margin-top: 12px; }
.google-button:hover { border-color: #9aa39e; box-shadow: 0 8px 25px rgba(32, 47, 40, .08); }
.google-logo { width: 20px; height: 20px; }
.account-card { display: flex; align-items: center; gap: 16px; }
.avatar { width: 52px; height: 52px; border-radius: 50%; object-fit: cover; background: var(--mint); }
.account-card strong { display: block; font-size: 17px; }
.account-card span { color: var(--muted); font-size: 14px; }

.question-page { min-height: calc(100vh - 135px); padding: 48px 0 80px; background: linear-gradient(180deg, #f1ece2 0%, var(--paper) 100%); }
.question-shell { width: min(920px, calc(100% - 56px)); margin: 0 auto; }
.question-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-bottom: 20px; }
.back-link { color: var(--muted); font-weight: 700; padding: 10px 0; }
.back-link:hover { color: var(--red); }
.practice-badge { background: var(--mint); color: var(--green); border-radius: 999px; padding: 9px 14px; font-size: 13px; font-weight: 700; }
.timer { display: flex; align-items: center; gap: 14px; background: var(--ink); color: white; padding: 9px 14px 9px 17px; border-radius: 12px; box-shadow: var(--shadow); }
.timer span { font-size: 11px; text-transform: uppercase; letter-spacing: .09em; color: #c7d2cd; }
.timer strong { font-size: 21px; font-variant-numeric: tabular-nums; letter-spacing: .06em; }
.timer strong.warning { color: #ff9d8f; }
.question-panel { background: var(--card); border: 1px solid var(--line); border-radius: 22px; padding: clamp(24px, 5vw, 48px); box-shadow: var(--shadow); }
.question-progress { display: flex; justify-content: space-between; gap: 20px; color: var(--red); font-size: 12px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; }
.question-panel h1 { font-size: clamp(30px, 4vw, 44px); margin: 18px 0 6px; }
.question-meta { font-size: 12px; color: var(--red); font-weight: 700; letter-spacing: .1em; text-transform: uppercase; margin-top: 22px; }
.question-copy { font-family: "Noto Serif JP"; font-size: clamp(24px, 3.2vw, 34px); line-height: 1.65; padding: 30px 0 20px; }
.prompt-pair.revealed { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: stretch; margin: 20px 0 12px; }
.prompt-pair.revealed .question-copy { display: flex; align-items: center; padding: 18px; border: 1px solid var(--line); border-radius: 10px; }
.prompt-pair.revealed .translation { display: flex; align-items: center; margin: 0; }
.translation { background: #f0ede5; border-left: 3px solid var(--yellow); padding: 14px 16px; border-radius: 4px; color: #53605a; margin-bottom: 12px; }
.audio-button { margin-top: 20px; }
.reveal-button { padding: 10px 14px; margin-bottom: 18px; }
.options { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 22px; }
.option { border: 1px solid var(--line); border-radius: 12px; padding: 18px; text-align: left; background: white; font-size: 16px; }
.option:hover, .option.selected { border-color: var(--red); background: #fff8f5; }
.option.correct { border-color: #3e8a61; background: #e8f4eb; }
.option.wrong { border-color: var(--red); background: #fbe9e5; }
.option:disabled { color: inherit; cursor: default; }
.feedback { margin-top: 18px; padding: 15px 16px; border-radius: 12px; background: #edf3ee; color: #3f5d4e; line-height: 1.55; }
.feedback.wrong { background: #f8e4df; color: #8f3228; }
.question-footer { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-top: 26px; padding-top: 22px; border-top: 1px solid var(--line); }
.question-footer span { font-size: 13px; color: var(--muted); }
.result { text-align: center; padding: 20px 0; }
.result-score { font-family: "Noto Serif JP"; font-size: 68px; color: var(--red); line-height: 1; margin: 22px 0 10px; }

.modal-wrap { position: fixed; inset: 0; background: rgba(12, 20, 17, .72); z-index: 60; display: grid; place-items: center; padding: 22px; }
.modal { background: var(--card); width: min(620px, 100%); border-radius: 20px; padding: 28px; box-shadow: 0 30px 90px rgba(0, 0, 0, .3); max-height: 92vh; overflow: auto; color: var(--ink); }
.modal-head { display: flex; justify-content: space-between; align-items: center; gap: 20px; }
.modal h2 { font-size: 28px; }
.modal p { color: var(--muted); line-height: 1.7; }
.close { border: 0; background: #eee9df; min-width: 36px; height: 36px; border-radius: 50%; font-size: 20px; }
.modal-options { display: grid; gap: 10px; margin: 22px 0; }
.modal-option { border: 1px solid var(--line); border-radius: 12px; padding: 14px; text-align: left; background: white; }
.modal-option:hover { border-color: var(--red); background: #fff8f5; }
.modal-option small { color: var(--muted); }
.toast { position: fixed; bottom: 25px; left: 50%; transform: translateX(-50%); background: var(--ink); color: white; padding: 12px 18px; border-radius: 12px; z-index: 100; box-shadow: var(--shadow); }

footer { border-top: 1px solid var(--line); padding: 28px 0; color: var(--muted); }
.footer-in { display: flex; justify-content: space-between; gap: 18px; }

@media (max-width: 850px) {
  .nav { min-height: 116px; align-items: flex-start; padding: 12px 0 10px; gap: 8px; flex-direction: column; }
  .brand { padding: 4px 0; }
  .links { width: 100%; justify-content: space-between; gap: 2px; overflow-x: auto; }
  .nav-link { padding: 8px 10px; font-size: 13px; }
  .hero { grid-template-columns: 1fr; padding-top: 48px; }
  .hero-art { display: none; }
  .practice-grid, .test-grid { grid-template-columns: 1fr; }
  .about { grid-template-columns: 1fr; gap: 30px; }
  .section-head { align-items: flex-start; flex-direction: column; }
  .practice-random { align-items: flex-start; flex-direction: column; }
  .stats { grid-template-columns: 1fr 1fr; }
  .stat:last-child { grid-column: span 2; border-top: 1px solid var(--line); }
  .stat:nth-child(2) { border-right: 0; }
  .home-choice { grid-template-columns: 1fr; }
}

@media (max-width: 650px) {
  .shell, .question-shell { width: min(100% - 36px, 1180px); }
  .hero h1 { font-size: 46px; }
  .actions { flex-direction: column; }
  .actions > * { width: 100%; }
  .page-hero { padding-top: 48px; }
  .page-hero h1 { font-size: 41px; }
  .section-head h2, .about h2 { font-size: 33px; }
  .level-switch { width: 100%; overflow: auto; }
  .principles, .options { grid-template-columns: 1fr; }
  .prompt-pair.revealed { grid-template-columns: 1fr; }
  .footer-in { flex-direction: column; }
  .question-page { padding-top: 26px; }
  .question-toolbar { align-items: flex-start; }
  .timer { gap: 8px; }
  .timer span { display: none; }
  .question-panel { padding: 22px; border-radius: 16px; }
  .question-progress { font-size: 10px; }
  .question-footer { align-items: stretch; flex-direction: column; }
  .question-footer .primary { width: 100%; }
}
