:root {
  --bg-color: #f8f8f8;
  --surface: #ffffff;
  --text-main: #111111;
  --text-sub: #696969;
  --text-faint: #999999;
  --accent: #000000;
  --border: #dddddd;
  --border-dark: #bcbcbc;
  --ok: #1c6b3c;
  --bad: #a82f2f;
  --max-width: 910px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { background: var(--bg-color); }
body {
  min-height: 100vh;
  background: var(--bg-color);
  color: var(--text-main);
  font-family: 'Helvetica Neue', Helvetica, Arial, 'Noto Sans JP', sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
button, input { font: inherit; }
button { color: inherit; }
button:focus-visible, input:focus-visible { outline: 2px solid #111; outline-offset: 3px; }

.site-shell {
  width: min(calc(100% - 40px), var(--max-width));
  margin: 0 auto;
  padding: 38px 0 calc(32px + env(safe-area-inset-bottom));
}

.site-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 20px;
  border-bottom: 1px solid var(--accent);
  padding-bottom: 15px;
}

.eyebrow, .section-index, .quiz-label {
  color: var(--text-sub);
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.14em;
  line-height: 1.4;
}

h1 {
  margin-top: 5px;
  font-size: clamp(2rem, 7vw, 3rem);
  font-weight: 500;
  letter-spacing: -0.06em;
  line-height: 0.95;
}

h2 {
  font-size: clamp(1.8rem, 6vw, 2.8rem);
  font-weight: 500;
  letter-spacing: -0.055em;
  line-height: 1.08;
}

.text-button {
  border: 0;
  background: none;
  color: var(--text-sub);
  cursor: pointer;
  font-size: 0.82rem;
  letter-spacing: 0.06em;
  padding: 7px 0;
  transition: color .18s ease;
}
.text-button:hover { color: var(--text-main); }

.mode-tabs {
  display: flex;
  width: 100%;
  gap: 0;
  overflow-x: auto;
  scrollbar-width: none;
  border-bottom: 1px solid var(--border);
}
.mode-tabs::-webkit-scrollbar { display: none; }
.mode-tab {
  flex: 0 0 auto;
  border: 0;
  border-right: 1px solid var(--border);
  background: transparent;
  color: var(--text-sub);
  cursor: pointer;
  padding: 12px 17px 11px;
  font-size: 0.76rem;
  font-weight: 500;
  letter-spacing: 0.06em;
  white-space: nowrap;
}
.mode-tab:first-child { border-left: 1px solid var(--border); }
.mode-tab.active { background: var(--accent); color: #fff; border-color: var(--accent); }

main { min-height: 560px; }
.view { display: none; padding-top: 32px; }
.view.active { display: block; animation: viewIn .28s cubic-bezier(.16,1,.3,1) both; }
@keyframes viewIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

.hero-grid {
  display: grid;
  grid-template-columns: 1.25fr .75fr;
  gap: 44px;
  align-items: end;
  padding: 20px 0 37px;
}
.hero-copy h2 { margin-top: 10px; }
.lead {
  max-width: 560px;
  margin-top: 22px;
  color: var(--text-sub);
  font-size: 0.92rem;
  line-height: 1.9;
  letter-spacing: 0.015em;
}
.status-panel { border-top: 1px solid var(--accent); }
.status-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: baseline;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: .72rem;
  letter-spacing: .06em;
}
.status-row span { color: var(--text-sub); }
.status-row strong { font-weight: 500; text-align: right; }

.home-menu {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  border-top: 1px solid var(--accent);
  border-left: 1px solid var(--border);
}
.home-card {
  display: grid;
  grid-template-columns: 38px 1fr auto;
  grid-template-rows: auto auto;
  align-items: baseline;
  gap: 9px 12px;
  min-height: 134px;
  padding: 18px;
  border: 0;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  background: transparent;
  text-align: left;
  cursor: pointer;
  transition: background .18s ease;
}
.home-card:hover { background: #fff; }
.card-no { color: var(--text-faint); font-size: .75rem; }
.card-title { font-size: 1.05rem; font-weight: 500; letter-spacing: .02em; }
.card-arrow { color: var(--text-sub); }
.card-desc { grid-column: 2 / 4; color: var(--text-sub); font-size: .8rem; line-height: 1.6; }

.section-head {
  display: grid;
  grid-template-columns: 1fr minmax(180px, 310px);
  gap: 30px;
  align-items: end;
  border-bottom: 1px solid var(--accent);
  padding-bottom: 18px;
  margin-bottom: 28px;
}
.section-head h2 { margin-top: 8px; }
.section-note { color: var(--text-sub); font-size: .8rem; line-height: 1.6; }

.profile-layout {
  display: grid;
  grid-template-columns: 1.1fr .9fr;
  gap: 38px;
}
.profile-table { border-top: 1px solid var(--border-dark); }
.profile-table > div {
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: 18px;
  padding: 15px 0;
  border-bottom: 1px solid var(--border);
}
.profile-table dt { color: var(--text-sub); font-size: .72rem; letter-spacing: .08em; }
.profile-table dd { font-size: .95rem; line-height: 1.55; }
.subtle { color: var(--text-sub); }
.profile-note { border-top: 1px solid var(--border-dark); padding-top: 14px; }
.profile-note p { color: var(--text-sub); font-size: .88rem; line-height: 1.9; margin-bottom: 14px; }
.profile-note .mono-line { color: var(--text-faint); font-size: .74rem; letter-spacing: .04em; }

.game-shell { max-width: 680px; margin: 0 auto; }
.game-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border);
  padding: 0 0 9px;
  color: var(--text-sub);
  font-size: .74rem;
  letter-spacing: .08em;
}

.wadokai-board {
  display: grid;
  grid-template-columns: 1fr 88px 1fr;
  grid-template-rows: 96px 88px 96px;
  grid-template-areas:
    ". top ."
    "left center right"
    ". bottom .";
  align-items: center;
  justify-items: center;
  margin: 28px auto 26px;
  max-width: 390px;
}
.center-cell {
  grid-area: center;
  display: grid;
  place-items: center;
  width: 88px;
  height: 88px;
  background: var(--accent);
  color: #fff;
  font-size: 2.25rem;
  font-weight: 500;
}
.arm { display: flex; align-items: center; gap: 8px; font-size: 1.9rem; }
.arm strong { font-weight: 500; }
.direction { color: var(--text-faint); font-size: .9rem; font-weight: 400; }
.arm-top { grid-area: top; flex-direction: column-reverse; gap: 2px; }
.arm-left { grid-area: left; }
.arm-right { grid-area: right; }
.arm-bottom { grid-area: bottom; flex-direction: column; gap: 2px; }

.answer-form { border-top: 1px solid var(--border-dark); padding-top: 14px; }
.answer-form label, .login-form label { display: block; color: var(--text-sub); font-size: .7rem; letter-spacing: .11em; margin-bottom: 9px; }
.answer-row { display: grid; grid-template-columns: 1fr auto; }
.answer-row input {
  min-width: 0;
  height: 48px;
  border: 1px solid var(--border-dark);
  border-right: 0;
  border-radius: 0;
  background: #fff;
  color: var(--text-main);
  padding: 0 14px;
  font-size: 1rem;
  appearance: none;
}
.answer-row input::placeholder { color: #aaa; }
.btn-solid, .btn-outline {
  border-radius: 0;
  cursor: pointer;
  padding: 0 22px;
  min-height: 42px;
  font-size: .84rem;
  font-weight: 500;
  letter-spacing: .05em;
  transition: opacity .18s ease, background .18s ease, color .18s ease;
}
.btn-solid { border: 1px solid var(--accent); background: var(--accent); color: #fff; }
.btn-solid:hover { opacity: .72; }
.btn-outline { border: 1px solid var(--border-dark); background: transparent; color: var(--text-sub); }
.btn-outline:hover { background: #fff; color: var(--text-main); }

.feedback {
  min-height: 68px;
  padding: 13px 0 8px;
  color: var(--text-sub);
  font-size: .86rem;
  line-height: 1.65;
}
.feedback.ok { color: var(--ok); }
.feedback.bad { color: var(--bad); }
.feedback strong { color: var(--text-main); font-weight: 500; }
.game-actions { display: flex; gap: 9px; flex-wrap: wrap; }

.quiz-shell { max-width: 760px; }
.quiz-label { margin-top: 25px; }
.quiz-question {
  min-height: 150px;
  padding: 18px 0 28px;
  font-size: clamp(1.25rem, 4.3vw, 1.7rem);
  font-weight: 400;
  line-height: 1.65;
  letter-spacing: .015em;
}
.quiz-hint { color: var(--text-sub); font-size: .8rem; line-height: 1.7; margin: -10px 0 24px; }
.quiz-hint:empty { display: none; }

.scrap-list { border-top: 1px solid var(--border-dark); }
.scrap-row {
  width: 100%;
  display: grid;
  grid-template-columns: 45px 1fr auto;
  gap: 16px;
  align-items: center;
  min-height: 62px;
  padding: 0 14px;
  border: 0;
  border-bottom: 1px solid var(--border);
  background: transparent;
  text-align: left;
  cursor: pointer;
}
.scrap-row:hover { background: #fff; }
.scrap-row span, .scrap-row em { color: var(--text-faint); font-size: .72rem; font-style: normal; }
.scrap-row strong { font-size: .9rem; font-weight: 400; }
.scrap-output { min-height: 80px; padding: 22px 14px; color: var(--text-sub); font-size: .82rem; letter-spacing: .08em; }

.footer {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  margin-top: 60px;
  padding-top: 10px;
  border-top: 1px solid var(--accent);
  color: var(--text-faint);
  font-size: .68rem;
  letter-spacing: .08em;
}

.login-page { display: grid; place-items: center; padding: 30px 20px; }
.login-shell { width: min(100%, 560px); }
.login-shell h1 { margin-top: 8px; padding-bottom: 16px; border-bottom: 1px solid var(--accent); }
.login-description { margin: 18px 0 30px; color: var(--text-sub); font-size: .88rem; line-height: 1.8; }
.login-feedback { min-height: 36px; padding-top: 10px; color: var(--bad); font-size: .8rem; }
.login-meta { display: flex; justify-content: space-between; margin-top: 46px; padding-top: 10px; border-top: 1px solid var(--border); color: var(--text-faint); font-size: .68rem; letter-spacing: .08em; }

@media (max-width: 700px) {
  .site-shell { width: min(calc(100% - 28px), var(--max-width)); padding-top: 24px; }
  .site-header { align-items: end; }
  .mode-tabs { margin-left: -14px; width: calc(100% + 28px); padding-left: 14px; }
  .mode-tabs::after { content: ''; flex: 0 0 14px; }
  .hero-grid { grid-template-columns: 1fr; gap: 30px; padding-top: 8px; }
  .home-menu { grid-template-columns: 1fr; }
  .home-card { min-height: 112px; }
  .section-head { grid-template-columns: 1fr; gap: 12px; }
  .profile-layout { grid-template-columns: 1fr; gap: 30px; }
  .profile-table > div { grid-template-columns: 84px 1fr; }
  .view { padding-top: 24px; }
  .wadokai-board { grid-template-columns: 1fr 76px 1fr; grid-template-rows: 86px 76px 86px; max-width: 330px; }
  .center-cell { width: 76px; height: 76px; font-size: 2rem; }
  .arm { font-size: 1.65rem; }
  .quiz-question { min-height: 130px; }
  .scrap-row { grid-template-columns: 34px 1fr; padding: 10px 8px; }
  .scrap-row em { grid-column: 2; }
}

@media (max-width: 420px) {
  .site-shell { width: calc(100% - 24px); }
  .mode-tabs { margin-left: -12px; width: calc(100% + 24px); padding-left: 12px; }
  .mode-tabs::after { flex-basis: 12px; }
  .mode-tab { padding-left: 14px; padding-right: 14px; }
  .wadokai-board { grid-template-columns: 1fr 68px 1fr; grid-template-rows: 78px 68px 78px; }
  .center-cell { width: 68px; height: 68px; }
  .answer-row input { height: 46px; }
  .btn-solid, .btn-outline { padding-left: 17px; padding-right: 17px; }
  .footer { flex-direction: column; gap: 4px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
