:root {
  color-scheme: light;
  --paper: #f8f6ef;
  --white: #fffdf7;
  --ink: #242c22;
  --muted: #565d50;
  --green: #293829;
  --green-light: #dfe6d8;
  --rust: #a34429;
  --line: #d9d8cb;
  --charcoal: #201e18;
  --gold: #d8af68;
  --gold-dark: #735625;
  --serif: Georgia, 'Yu Mincho', 'YuMincho', 'Hiragino Mincho ProN', serif;
  font-family: 'Yu Gothic UI', 'Hiragino Kaku Gothic ProN', 'Meiryo', sans-serif;
  line-height: 1.65;
  color: var(--ink);
  background: var(--paper);
}

*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; display: flex; flex-direction: column; }
main { flex: 1; }
[hidden] { display: none !important; }

#style-games li { overflow-wrap: anywhere; }
#style-games select, #cpu-opening { max-width: 100%; }

.personal-play-layout { display: grid; grid-template-columns: minmax(0, 30rem) minmax(0, 1fr); gap: 24px; align-items: start; }
#personal-board { width: 100%; }
#personal-generate-panel { margin-block: 12px; }
#personal-list textarea { display: block; width: 100%; }
#personal-weakness-title { margin-top: 0; }
@media (max-width: 850px) { .personal-play-layout { grid-template-columns: minmax(0, 1fr); } }
button { font: inherit; cursor: pointer; }
button:disabled { cursor: default; }
:focus-visible { outline: 3px solid var(--rust); outline-offset: 4px; }
h1, h2, h3, p { margin: 0; }
h1, h2, h3 { line-height: 1.35; }
.shell { width: min(1160px, calc(100% - 64px)); margin-inline: auto; }

.site-header { border-bottom: 1px solid var(--line); }
.header-inner { min-height: 64px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.brand { display: inline-flex; align-items: center; color: var(--ink); font: bold 1.75rem/1 Georgia, serif; text-decoration: none; letter-spacing: -.055em; }
.brand-mark { display: block; width: 36px; height: 36px; margin-right: 9px; border-radius: 50%; }

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
  align-items: center;
  gap: clamp(18px, 4vw, 60px);
  margin-top: 28px;
  padding: clamp(26px, 5.2vw, 68px);
  border: 1px solid #51452f;
  border-radius: 16px;
  color: var(--white);
  background: radial-gradient(ellipse at 82% 38%, #423421, var(--charcoal) 64%);
}
.hero-copy { min-width: 0; }
.eyebrow { color: var(--rust); font-size: .875rem; font-weight: 700; letter-spacing: .12em; }
.hero h1 { font-family: var(--serif); font-size: clamp(2.05rem, 5.2vw, 4.65rem); line-height: 1.17; letter-spacing: -.035em; margin-bottom: 14px; }
.hero h1 em { display: block; color: var(--gold); font-style: normal; }
.hero-description { max-width: 28rem; color: #eee5d5; font-size: clamp(1rem, 1.5vw, 1.1rem); line-height: 1.75; text-wrap: pretty; margin-bottom: 20px; }
.button { display: inline-flex; justify-content: center; align-items: center; min-height: 52px; padding: 11px 24px; border: 1px solid transparent; border-radius: 7px; text-align: center; text-decoration: none; font-weight: 700; }
.hero-button { gap: 14px; background: var(--gold); color: var(--charcoal); }
.hero-button:hover { background: #edc686; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 8px 12px; }
.hero-secondary { border-color: #b99354; color: var(--white); }
.hero-secondary:hover { background: #423421; }
.hero :focus-visible { outline-color: var(--gold); }
.primary { background: var(--green); color: var(--white); }
.primary:hover:not(:disabled) { background: #3d513c; }
.primary:disabled { background: #e3e4da; color: #5b6156; }

.hero-art { display: grid; place-items: center; min-width: 0; padding: 10px; }
.board-frame { width: min(100%, 355px); display: grid; grid-template-columns: 12px 1fr; grid-template-rows: auto 12px; gap: 4px; padding: 11px; color: #edd6aa; background: #28221a; border: 1px solid #ac8955; border-radius: 6px; box-shadow: 0 18px 36px #120e0ac9; transform: rotate(-8deg); }
.board-grid { display: grid; grid-template: repeat(8, minmax(0, 1fr)) / repeat(8, minmax(0, 1fr)); aspect-ratio: 1; min-width: 0; background: conic-gradient(#ab8052 25%, #e6cea1 0 50%, #ab8052 0 75%, #e6cea1 0) left top / 25% 25%; }
.board-ranks { align-self: stretch; text-align: center; line-height: 1; display: grid; align-content: space-around; font-size: 0; }
.board-ranks span, .board-files span { font: .68rem/1 Georgia, serif; }
.board-files { grid-column: 2; display: grid; grid-template-columns: repeat(8, 1fr); text-align: center; align-items: center; }
.piece { grid-area: var(--row) / var(--col); width: 100%; height: 100%; padding: 8%; min-width: 0; min-height: 0; object-fit: contain; }
.piece.featured { background: #e9bc63; }

.home-section { margin-top: clamp(24px, 4vw, 50px); }
.home-section h2 { font-family: var(--serif); font-size: clamp(1.35rem, 3.2vw, 2rem); margin-bottom: 14px; scroll-margin-top: 14px; }
.home-diagnostics { margin-bottom: 40px; padding-top: 20px; border-top: 1px solid var(--line); }
.home-more { margin-top: 8px; margin-bottom: 0; }
.home-settings summary { display: list-item; width: fit-content; min-height: 44px; padding-block: 9px; cursor: pointer; color: var(--muted); }
.first-step-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.first-step-card {
  display: grid;
  align-content: start;
  gap: 10px;
  padding: clamp(16px, 2.2vw, 24px);
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 10px;
}
.first-step-grid > :first-child { border-top: 3px solid #a98649; }
.first-step-card h3 { font-size: clamp(1.05rem, 1.6vw, 1.22rem); }
.first-step-card p { color: var(--muted); line-height: 1.65; }
.first-step-card .goal-links { margin: 0; }
.first-step-card .goal-links a { font-size: .95rem; }

.result-axes h2 { font-size: 1rem; margin-bottom: 12px; }
.result-axes ul { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.result-axes li { padding: 10px 13px; border: 1px solid var(--line); border-radius: 7px; background: var(--white); font-size: .875rem; }
.axis-code { color: var(--rust); font: bold 1rem Georgia, serif; white-space: nowrap; }

.chess-term {
  display: inline;
  min-width: 24px;
  min-height: 24px;
  padding: 0 1px;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-decoration: underline dotted;
  text-underline-offset: .22em;
  text-decoration-thickness: .075em;
}
.chess-term:hover, .chess-term[aria-expanded='true'] { background: #eedcba; color: var(--charcoal); }
.chess-term:focus-visible { outline-offset: 2px; border-radius: 2px; }
.chess-term-popup {
  position: fixed;
  z-index: 10;
  width: min(21rem, calc(100% - 16px));
  max-height: calc(100dvh - 16px);
  overflow: auto;
  padding: 10px 13px;
  border: 1px solid var(--gold-dark);
  border-radius: 8px;
  background: var(--charcoal);
  color: var(--white);
  box-shadow: 0 4px 14px #201e1838;
  font-size: .875rem;
}
.chess-term-popup strong { color: var(--gold); }
.chess-term-popup p { margin-top: 4px; }
.chess-term-popup .text-button { margin-top: 2px; color: var(--gold); font-weight: 700; }
.chess-term-popup :focus-visible { outline-color: var(--gold); }
.chess-term-popup.is-overlay { pointer-events: none; }
.chess-term-popup.is-inline { position: static; max-height: none; margin: 6px 0 12px; }
.glossary-controls { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 10px 16px; }
.glossary-controls label { min-width: 0; font-weight: 700; }
.glossary-controls input, .glossary-controls select {
  display: block;
  width: 100%;
  min-height: 46px;
  margin-top: 4px;
  padding: 7px 10px;
  border: 1px solid var(--gold-dark);
  border-radius: 6px;
  background: var(--white);
  color: var(--ink);
  font: inherit;
}
.glossary-metadata, .glossary-english { color: var(--muted); font-size: .92rem; }
#chess-glossary-status { margin-top: 8px; }
.glossary-category { margin-top: 22px; }
.glossary-category h2 { padding-bottom: 8px; border-bottom: 2px solid var(--gold); font-size: 1.3rem; }
.chess-glossary-list { margin: 0; }
.glossary-entry { padding: 14px 0; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
.glossary-entry dt { font-size: 1.12rem; font-weight: 700; scroll-margin: 20px; }
.glossary-english { display: block; margin-top: 2px; font-weight: 400; }
.glossary-entry dd { margin: 6px 0 0; line-height: 1.75; }
.glossary-entry p + p { margin-top: 6px; }
.glossary-example { background: #f4e9d3; padding: 6px 10px; border-radius: 5px; }
.glossary-related { display: flex; flex-wrap: wrap; align-items: center; column-gap: 12px; color: var(--muted); font-size: .92rem; }
.site-footer { padding: 17px 0; border-top: 1px solid var(--line); color: var(--muted); font: bold 1rem Georgia, serif; }
.analytics-notice { margin-block: 12px; padding: 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--white); }
.analytics-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.analytics-actions .button { min-height: 44px; padding: 6px 12px; }
.journey-home { margin-block: 18px 0; }
.journey-hero { background: var(--green); color: var(--white); padding: clamp(20px, 5vw, 48px); border-radius: 12px; }
.journey-hero h1 { margin-block: 4px 12px; font: 700 clamp(1.8rem, 6vw, 3.4rem)/1.25 var(--serif); }
.journey-hero p { max-width: 38em; }
.journey-hero .journey-eyebrow, .journey-hero .text-button { color: var(--gold); }
.journey-eyebrow { letter-spacing: .14em; font-weight: 700; }
.journey-section { margin-block: clamp(24px, 5vw, 48px); }
.journey-section h2 { margin-bottom: 12px; }
.journey-principles { color: var(--green); font: 700 clamp(1.1rem, 3vw, 1.45rem)/1.55 var(--serif); }
.journey-pillars { display: flex; flex-wrap: wrap; gap: 8px; padding: 0; list-style: none; }
.journey-pillars li, .journey-status { background: var(--green-light); color: var(--green); border-radius: 6px; padding: 3px 10px; font-weight: 700; }
.journey-card { padding: clamp(12px, 3vw, 22px); background: var(--white); border: 1px solid var(--line); border-radius: 8px; }
.journey-facts { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; }
.journey-facts dt { font-weight: 700; }
.journey-facts dd { margin: 0; }
.journey-timeline { list-style: none; padding-inline-start: 16px; margin-inline-start: 4px; border-inline-start: 2px solid var(--gold); }
.journey-timeline > li { position: relative; margin-block: 12px; }
.journey-timeline > li::before { content: ""; position: absolute; inset-inline-start: -22px; top: 22px; width: 9px; height: 9px; border-radius: 50%; background: var(--gold-dark); }
.journey-entry-heading { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 12px; color: var(--muted); }
.journey-card h3 { margin-block: 8px; }
.journey-card ul { margin-block: 8px; padding-inline-start: 1.35em; }
.journey-release { margin-block: 8px; padding-block: 0; }
.journey-release summary { min-height: 44px; align-content: center; font-weight: 700; cursor: pointer; }
.journey-release[open] { padding-bottom: 12px; }
.journey-page h2 { scroll-margin-top: 16px; }
@media (max-width: 480px) {
  .journey-facts { grid-template-columns: 1fr; }
  .journey-facts dd { margin-bottom: 6px; }
}
.migration-notice { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 12px; padding: clamp(12px, 3vw, 24px); border-top: 3px solid var(--gold); }
.migration-logo { border-radius: 8px; }
.migration-notice h2 { font-family: var(--serif); font-size: clamp(1.25rem, 3vw, 1.75rem); }
.migration-notice details { margin-top: 10px; }
.migration-notice summary, .migration-notice button { min-height: 44px; }
.migration-notice summary { align-content: center; cursor: pointer; }
.migration-notice ol { padding-inline-start: 1.5em; }
.migration-notice li + li { margin-top: 0.35em; }
@media (max-width: 480px) {
  .migration-notice { grid-template-columns: minmax(0, 1fr); gap: 8px; }
  .migration-notice .analytics-actions { align-items: flex-start; flex-direction: column; }
}

.inner-screen { max-width: 790px; margin: 0 auto; padding: clamp(34px, 7vw, 72px) 0 55px; }
.inner-screen h1 { font-family: var(--serif); font-size: clamp(1.65rem, 4.6vw, 2.7rem); overflow-wrap: anywhere; }
.about-page { max-width: 960px; }
.about-hero {
  padding: clamp(30px, 6vw, 76px) clamp(14px, 4vw, 40px);
  border: 1px solid #756139;
  border-radius: 16px;
  color: var(--white);
  background: radial-gradient(ellipse at center top, #304b37, #12271d 72%);
  text-align: center;
}
.about-hero img { display: block; width: 64px; height: 64px; margin: 0 auto 14px; border-radius: 50%; }
.about-name { margin-bottom: 10px; color: var(--gold); font-size: .9rem; font-weight: 700; }
.about-hero h1 { margin-bottom: 12px; font-size: clamp(1.75rem, 5.8vw, 4.15rem); }
.about-hero h1 em { display: inline-block; color: var(--gold); font-style: normal; }
.about-hero > p:last-child { color: #eee5d5; font-size: clamp(1rem, 2.2vw, 1.2rem); text-wrap: balance; }
.about-content { display: grid; gap: clamp(28px, 5vw, 52px); max-width: 780px; margin: clamp(32px, 6vw, 60px) auto 0; }
.about-content h2 { margin-bottom: 12px; font-family: var(--serif); font-size: clamp(1.3rem, 3.4vw, 1.9rem); }
.about-principle { padding-inline-start: clamp(12px, 3vw, 24px); border-inline-start: 2px solid #a98649; }
.about-principle p { line-height: 1.8; }
.about-principle p + p { margin-top: 8px; }
.about-pillar-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.first-step-card .about-future { padding-top: 8px; border-top: 1px solid var(--line); font-size: .875rem; }
.about-start { padding: clamp(16px, 3vw, 28px); border: 1px solid var(--line); border-radius: 10px; background: var(--green-light); }
.about-start .hero-actions { margin-top: 14px; }
.about-start .button { min-height: 46px; padding-inline: 14px; }
.about-start .button:not(.primary) { color: var(--ink); border-color: #76856f; }
.about-start .button:not(.primary):hover { background: var(--white); }

@media (max-width: 700px) {
  .first-step-grid, .about-pillar-grid { grid-template-columns: minmax(0, 1fr); }
}
.text-button { display: inline-flex; align-items: center; min-height: 44px; padding: 8px 0; border: 0; background: transparent; color: var(--green); text-decoration: underline; text-underline-offset: .23em; }
.text-button:hover { color: var(--rust); }
.mode-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; margin-top: 23px; }
.mode-card, .quiz-panel, .result-details > section { background: var(--white); border: 1px solid var(--line); border-radius: 12px; padding: clamp(17px, 4vw, 34px); }
.mode-card { display: flex; flex-direction: column; align-items: start; gap: 13px; }
.mode-card h2 { font-size: 1.3rem; }
.mode-card p { flex: 1; color: var(--muted); }
.mode-card .button { margin-top: 8px; }
.guide-screen h1 { margin: 6px 0 18px; }
.guide-intro { color: var(--muted); line-height: 1.75; margin-bottom: 20px; }
.learning-steps { margin: 0; padding: 0; list-style-type: none; counter-reset: step; display: grid; gap: 12px; }
.learning-steps > li {
  position: relative;
  counter-increment: step;
  padding: clamp(16px, 3vw, 25px);
  padding-inline-start: clamp(49px, 8vw, 72px);
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--white);
}
.learning-steps > li::before { content: counter(step); position: absolute; inset-inline-start: clamp(11px, 3vw, 24px); color: var(--gold-dark); font: 700 1.23rem/1.65 Georgia, serif; }
.learning-steps h2, .opening-catalog h2 { font-size: 1.2rem; margin-bottom: 8px; }
.learning-steps p + p { margin-top: 8px; }
.learning-steps .button { margin-top: 14px; }
.goal-links { display: grid; gap: 8px; margin: 10px 0 0; padding: 0; list-style: none; }
.goal-links a { display: flex; justify-content: space-between; align-items: center; gap: 8px; min-height: 46px; border: 1px solid var(--line); border-radius: 7px; background: var(--paper); color: var(--ink); text-decoration: none; font-weight: 700; padding: 8px 12px; }
.goal-links a:hover { background: #fff2dc; border-color: #a98649; }
.goal-links a span { color: var(--gold-dark); flex: none; }
.opening-catalog { display: grid; gap: 22px; }
.opening-catalog .goal-links { grid-template-columns: repeat(2, minmax(0, 1fr)); }

.quiz-top, .quiz-actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.quiz-intro { color: var(--muted); margin-bottom: 12px; }
.question-number { color: var(--muted); font-weight: 700; font-variant-numeric: tabular-nums; }
progress { appearance: none; display: block; width: 100%; height: 8px; border: 0; border-radius: 99px; overflow: hidden; color: var(--rust); background: var(--green-light); margin: 12px 0 23px; }
progress::-webkit-progress-bar { background: var(--green-light); }
progress::-webkit-progress-value { background: var(--rust); }
progress::-moz-progress-bar { background: var(--rust); }
.answers { display: grid; gap: 12px; margin-top: 23px; }
.answer { display: flex; align-items: center; gap: 13px; text-align: left; padding: 11px 14px; min-height: 56px; border: 1px solid var(--line); border-radius: 8px; color: var(--ink); background: var(--paper); overflow-wrap: anywhere; }
.answer:hover { border-color: var(--green); }
.answer[aria-pressed='true'] { background: var(--green-light); border-color: var(--green); box-shadow: inset 0 0 0 1px var(--green); }
.answer-letter { flex: 0 0 31px; display: grid; place-items: center; height: 31px; border: 1px solid var(--line); border-radius: 5px; background: var(--white); font: bold 1rem Georgia, serif; }
.answer[aria-pressed='true'] .answer-letter { background: var(--green); border-color: var(--green); color: var(--white); }
.quiz-actions { margin-top: 20px; }

.result-banner {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  column-gap: 24px;
  background: var(--green);
  color: var(--white);
  border-radius: 15px;
  padding: clamp(20px, 5vw, 46px);
}
.result-banner > :not(.result-emblem) { grid-column: 1; }
.result-emblem {
  grid-area: 1 / 2 / 5 / 3;
  align-self: center;
  display: block;
  inline-size: clamp(64px, 17vw, 136px);
  block-size: auto;
  aspect-ratio: 1;
  border-radius: 50%;
}
.result-banner .eyebrow { color: #f1c5a8; }
.result-banner h1 { margin-bottom: 12px; }
.result-banner h1:focus-visible { outline-color: #f1c5a8; }
.result-code { font: bold clamp(2rem, 7vw, 4rem)/1 Georgia, serif; letter-spacing: .13em; margin: 13px 0 9px; }
.result-note { color: var(--muted); margin: 16px 0 26px; padding-inline-start: 12px; border-inline-start: 3px solid var(--line); }
.result-axes li { display: grid; grid-template-columns: 2rem minmax(0, 1fr); gap: 8px; font-weight: 700; }
.result-axes .axis-code { display: grid; place-items: center; min-height: 2rem; border-radius: 5px; background: var(--green-light); }
.result-details { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin: 18px 0 24px; }
.result-details h2 { font-size: 1.05rem; margin-bottom: 9px; }
.result-details .result-strength { border-top: 3px solid #73896c; }
.result-details .result-caution { border-top: 3px solid #ad583b; }
.result-details .opening { background: var(--green-light); grid-column: 1 / -1; }
.result-details .opening p:first-of-type { font-size: 1.16rem; }
.result-details > :last-child { grid-column: 1 / -1; }
.opening p:first-of-type { color: var(--green); font-weight: 700; }
.opening-note { font-size: .875rem; margin-top: 4px; color: var(--muted); }

.share-card { max-width: 560px; margin: clamp(24px, 5vw, 36px) auto; }
.share-card h2 { margin-bottom: 10px; font-size: clamp(1.1rem, 3.5vw, 1.3rem); }
#share-preview {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 10px;
  background: #151219;
  box-shadow: 0 6px 22px #201e1826;
}
.share-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }
.share-actions .button { flex: 1 1 180px; }
.secondary { color: var(--green); border-color: var(--green); background: var(--white); }
#card-status:not(:empty) { margin-top: 8px; color: var(--muted); }
.result-link { max-width: 510px; margin: 24px auto 30px; min-width: 0; }
.result-link h2 { font-size: 1.2rem; }
.result-link p:not(:empty), #manual-result-link, #error p { margin-top: 12px; }
#result-link-url { display: block; width: 100%; min-height: 48px; padding: 8px; border: 1px solid var(--line); border-radius: 6px; font: inherit; }
#result > .button { margin: 0 8px 8px 0; }
#error-home { margin-top: 20px; }

.opening-banner {
  padding: clamp(20px, 5vw, 46px);
  color: var(--white);
  background: var(--green);
  border: 1px solid #a98649;
  border-radius: 15px;
}
.opening-banner h1 { margin: 8px 0 12px; }
.opening-banner h1 span { display: inline-block; }
.opening-banner .eyebrow { color: #f1d4aa; }
.opening-banner h1:focus-visible { outline-color: #f1d4aa; }
.opening-results { display: grid; gap: 14px; }
.opening-card {
  min-width: 0;
  padding: clamp(17px, 4vw, 28px);
  background: var(--white);
  border: 1px solid var(--line);
  border-inline-start: 3px solid #a98649;
  border-radius: 12px;
  overflow-wrap: anywhere;
}
.opening-card h2 { margin: 5px 0 2px; font-size: 1.3rem; }
.opening-english, .opening-condition { color: var(--muted); }
.opening-card h3 { font-size: 1rem; margin: 14px 0 3px; }
.opening-condition { margin-top: 8px; }
.opening-ratings, .opening-actions { display: flex; flex-wrap: wrap; gap: 10px 20px; margin: 20px 0 0; }
.opening-ratings > div { display: flex; gap: 8px; padding: 5px 10px; border-radius: 5px; background: var(--paper); }
.opening-ratings dd { margin: 0; font-weight: 700; }
.opening-learn { margin-top: 18px; }

#opening-study { max-width: 1050px; padding-top: clamp(12px, 3vw, 32px); }
.study-navigation { display: flex; flex-wrap: wrap; gap: 4px 20px; }
#study-slot { margin-top: 12px; }
#study-title { margin-top: 4px; }
.study-english, #study-instructions, .study-count, .study-feedback { color: var(--muted); }
.study-layout {
  display: grid;
  grid-template-columns: minmax(0, min(55%, clamp(360px, 100vh - 290px, 570px))) minmax(0, 1fr);
  gap: clamp(17px, 3.5vw, 40px);
  align-items: start;
  margin-top: 16px;
}
.study-board-area { min-width: 0; }
.study-board-bar { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 44px; }
.study-turn { display: inline-flex; align-items: center; gap: 8px; font-weight: 700; }
.study-turn::before { content: ''; width: 14px; height: 14px; border: 1px solid var(--ink); border-radius: 50%; background: var(--white); }
.study-turn[data-color='b']::before { background: var(--ink); }
.study-board {
  display: grid;
  grid-template: repeat(8, minmax(0, 1fr)) / repeat(8, minmax(0, 1fr));
  width: 100%;
  aspect-ratio: 1;
  border: 2px solid #443a29;
  border-radius: 5px;
  overflow: clip;
}
.study-square {
  position: relative;
  display: grid;
  place-items: center;
  min-width: 0;
  min-height: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  color: #513c26;
  background: #edddbf;
  touch-action: manipulation;
}
.study-square.dark-square { color: #281f16; background: #ad9070; }
.study-square.last-move { background: #e9cb7c; }
.study-square.dark-square.last-move { background: #ccaa63; }
.study-square.last-from::before, .study-square.last-to::before {
  content: ''; position: absolute; inset: 3px; border: 2px dashed #695020; pointer-events: none;
}
.study-square.last-to::before { border-style: solid; }
.study-square.checked-square { background: radial-gradient(#d77460, #b94f41 77%, #8e3129); }
.study-square.checked-square::before { content: '!'; position: absolute; inset: 1px 3px auto auto; font-weight: 800; color: #fff; border: 0; }
.study-square.hint-from { outline: 3px dashed #593a87; outline-offset: -5px; }
.study-square.hint-to::after {
  content: '★'; position: absolute; inset: 1px 3px auto auto; width: 1.05em; aspect-ratio: 1; line-height: 1;
  color: #fff; background: #593a87; border: 1px solid #fff; border-radius: 3px; font-size: clamp(.65rem, 2vw, 1rem); pointer-events: none;
}
.study-square[aria-pressed='true'] { z-index: 1; box-shadow: inset 0 0 0 3px #287147; }
.study-square:focus-visible { z-index: 2; outline: 3px solid #144d90; outline-offset: -3px; }
.study-square.legal-target:not(.hint-to)::after {
  content: '';
  position: absolute;
  width: 24%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: #1e5339a6;
  pointer-events: none;
}
.study-square.legal-target:not(.hint-to):has(.study-piece)::after { width: 87%; background: transparent; border: 3px solid #1e5339b8; }
.study-piece { width: 97%; height: 97%; object-fit: contain; pointer-events: none; }
.study-square.draggable-piece { touch-action: none; cursor: grab; }
.study-board { user-select: none; }
.study-square.drag-source { box-shadow: inset 0 0 0 3px #287147; }
.drag-source .study-piece { visibility: hidden; }
.study-square.drag-target { outline: 3px solid #1a4d58; outline-offset: -4px; }
.study-square.drag-legal::after { content: ''; position: absolute; width: 23%; aspect-ratio: 1; border-radius: 50%; background: #1e5339a6; pointer-events: none; }
.study-square.drag-legal:has(.study-piece)::after { width: 87%; background: transparent; border: 3px solid #1e5339b8; }
.drag-piece { position: fixed; z-index: 10; pointer-events: none; aspect-ratio: 1; transform: translate(-50%, -50%); }
.study-coordinates { position: absolute; inset: 1px 2px; pointer-events: none; font: 700 clamp(.55rem, 1.3vw, .78rem)/1.1 system-ui, sans-serif; }
.study-coordinates span:first-child { position: absolute; inset-block-start: 0; inset-inline-start: 0; }
.study-coordinates span:last-child { position: absolute; inset-block-end: 0; inset-inline-end: 0; }
.study-panel { min-width: 0; padding-top: 44px; }
.study-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin: 12px 0 16px; }
.study-explanation {
  background: var(--white);
  border: 1px solid var(--line);
  border-inline-start: 3px solid #a98649;
  border-radius: 12px;
  padding: clamp(15px, 3.2vw, 24px);
}
.study-status { font-weight: 700; }
.study-count { margin-top: 8px; font-size: .875rem; font-variant-numeric: tabular-nums; }
.study-explanation h2 { margin: 3px 0 8px; font-size: 1.2rem; }
.study-feedback:not(:empty) { margin-top: 10px; }
.study-complete { margin-top: 16px; padding: clamp(16px, 3vw, 24px); color: var(--white); background: var(--charcoal); border: 1px solid #a98649; border-radius: 12px; }
.study-complete h2 { color: var(--gold); font-size: 1.2rem; }
.study-complete-actions { display: flex; flex-wrap: wrap; gap: 8px 12px; margin-top: 14px; }
.study-complete .primary { background: var(--gold); color: var(--charcoal); }
.study-complete .primary:hover { background: #edc686; }
.study-complete .text-button { color: var(--white); }
.study-complete :focus-visible { outline-color: var(--gold); }
.study-mode-links { display: flex; flex-wrap: wrap; align-items: center; gap: 7px 12px; margin-block: 8px 12px; }
.study-mode-links [aria-current] { font-weight: 800; }
.study-mode-links a[aria-current] { background: #eedcba; border-color: var(--gold-dark); }
#opening-practice { max-width: 1050px; }
#practice-show-hint { margin-inline-end: 12px; }
#practice-show-hint:disabled { opacity: .58; }
.study-resource { margin-top: 25px; padding: 17px; border: 1px solid var(--line); border-radius: 10px; background: var(--white); }
.study-resource h2 { margin-bottom: 9px; font-size: 1.25rem; }
.study-resource h3 { margin-top: 16px; font-size: 1.08rem; }
.study-resource li p { padding: 3px 8px 6px; }
#variation-facts dt, #practice-result-stats dt, .review-card dt { font-weight: 700; }
#variation-facts dd, #practice-result-stats dd, .review-card dd { margin: 0 0 8px; }

/* Learning dashboard and site menu */
.learning-block, .dashboard-priority { margin-block: 0 14px; }
.dashboard-priority .learning-block { background: var(--charcoal); color: var(--white); border-color: #a98649; }
.dashboard-priority .learning-block h2 { color: var(--gold); }
.dashboard-priority .learning-block .primary { background: var(--gold); color: var(--charcoal); }
.dashboard-priority .text-button { color: var(--white); }
.learning-block > p { margin: 8px 0 12px; }
.learning-values { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 5px 10px; margin: 10px 0 0; }
.learning-values dd { margin: 0; font-weight: 700; }
.daily-list { padding-inline-start: 24px; margin: 10px 0; }
.daily-list li { margin-bottom: 7px; }
.daily-list li > a, .daily-list li > .learning-done { margin-inline-start: 9px; }
.learning-done { color: #356546; font-weight: 700; }
.catalog-controls { display: flex; flex-wrap: wrap; gap: 10px 14px; margin-bottom: 12px; }
.catalog-controls label, #backup label { display: grid; min-width: 0; font-weight: 700; }
.catalog-controls input, .catalog-controls select, #backup-import { min-height: 44px; max-width: 100%; font: inherit; border: 1px solid var(--line); border-radius: 7px; padding: 5px 8px; background: var(--white); color: var(--ink); }
.catalog-entry h3 { margin-bottom: 3px; }
.catalog-entry p { margin-bottom: 7px; }
.catalog-meta { color: var(--muted); font-size: .88rem; }
#opening-catalog details { border-top: 1px solid var(--line); padding-top: 7px; }
#opening-catalog summary { cursor: pointer; padding: 8px 0; font-weight: 700; }
#opening-catalog details .catalog-entry { border-inline-start: 3px solid #a98649; padding-inline-start: 13px; margin-top: 12px; }
.progress-table { overflow-x: auto; margin-top: 16px; }
.progress-table table { border-collapse: collapse; width: 100%; }
.progress-table caption { font-weight: 700; text-align: start; margin-bottom: 5px; }
.progress-table th, .progress-table td { white-space: nowrap; border-bottom: 1px solid var(--line); padding: 7px 9px; text-align: start; }
.review-history-title { margin: 22px 0 8px; font-size: 1.2rem; }
.menu-toggle { width: 44px; height: 44px; flex: 0 0 44px; border: 1px solid #765a2f; border-radius: 7px; background: var(--charcoal); color: var(--gold); font-size: 1.5rem; }
#site-menu { position: fixed; inset: 0 0 0 auto; margin: 0; width: min(360px, 92vw); max-height: none; height: 100dvh; padding: 0; border: 0; border-inline-start: 1px solid #765a2f; background: var(--charcoal); color: var(--white); overscroll-behavior: contain; overflow-y: auto; }
#site-menu[open] { animation: site-menu-in .16s ease-out; }
@keyframes site-menu-in { from { transform: translateX(100%); } to { transform: translateX(0); } }
#site-menu::backdrop { background: #14120fd0; }
body:has(#site-menu[open]) { overflow: hidden; }
.menu-panel { min-height: 100%; padding: 12px 18px 24px; }
.menu-heading { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.menu-heading h2, .menu-group h3 { color: var(--gold); }
.menu-group { border-top: 1px solid #786849; padding-top: 8px; margin-top: 12px; }
.menu-group h3 { font-size: .9rem; margin-bottom: 5px; }
.menu-group a { display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 4px 8px; border-inline-start: 3px solid transparent; border-radius: 4px; color: var(--white); text-decoration: none; font-weight: 600; }
.menu-group a span { color: var(--gold); width: 20px; text-align: center; }
.menu-group a:hover, .menu-group a[aria-current="page"] { border-inline-start-color: var(--gold); background: #433721; }
#site-menu :focus-visible { outline-color: var(--gold); }
@media (max-width: 760px) {
  #site-menu-toggle { order: 1; margin-inline-start: auto; }
}
@media (prefers-reduced-motion: reduce) {
  #site-menu[open] { animation: none; }
}

#review-list { display: grid; gap: 12px; margin-bottom: 15px; }
.promotion-dialog {
  width: min(380px, calc(100% - 32px));
  padding: 20px;
  border: 1px solid #a98649;
  border-radius: 12px;
  background: var(--white);
  color: var(--ink);
}
.promotion-dialog::backdrop { background: #242c2270; }
.promotion-dialog h2 { font-size: 1.2rem; }
.study-promotion-options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: 14px; }
.study-promotion-options button { padding-inline: 6px; }

.intro-overview { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; margin-bottom: 22px; }
.intro-overview p { color: var(--muted); }
.intro-storage { padding: 18px; margin-top: 30px; border-top: 1px solid var(--line); }
.intro-storage h2 { font-size: 1.2rem; margin-bottom: 6px; }
#intro-storage-warning { color: var(--rust); margin-top: 6px; }
#intro-clear-prompt p { margin-bottom: 8px; }
#intro-clear-prompt button { margin-inline-end: 8px; }
#intro-lesson { max-width: 1050px; padding-top: clamp(12px, 3vw, 32px); }
.lesson-description { max-width: 48rem; color: var(--muted); margin-top: 8px; }
.lesson-goal { display: flex; gap: 8px 13px; padding: 10px 14px; margin-top: 14px; background: var(--charcoal); color: var(--white); border-radius: 8px; }
.lesson-goal strong { flex: none; color: var(--gold); }
.lesson-layout { margin-top: 5px; }
.lesson-actions { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; margin-top: 12px; }
.lesson-layout .answers { margin-top: 0; }
.lesson-layout .answer[aria-disabled='true'] { cursor: default; }
.lesson-feedback:not(:empty), .lesson-hint { margin-top: 12px; }
.lesson-feedback[data-correct='true'] { color: #235d38; font-weight: 700; }
.lesson-feedback[data-correct='false'] { color: var(--rust); font-weight: 700; }
.lesson-hint { background: #fbefd5; border-radius: 6px; padding: 8px 10px; }
.intro-next-guide { margin-top: 18px; }
.intro-quiz-results { list-style: none; padding: 0; margin: 9px 0 0; }
.intro-quiz-results li { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 2px 12px; padding: 6px 0; border-top: 1px solid var(--line); }
.intro-quiz-results a { display: inline-flex; align-items: center; min-height: 44px; color: var(--green); }
.intro-quiz-results span { font-size: .875rem; color: var(--muted); }

@media (max-width: 760px) {
  .shell { width: calc(100% - 40px); }
  .hero { margin-top: 18px; }
  .hero-art { padding: 5px; }
  .result-axes ul { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .study-layout { grid-template-columns: minmax(0, 1fr); max-width: 550px; margin-inline: auto; }
  .study-panel { padding-top: 0; }
}

@media (max-width: 600px) {
  .hero { grid-template-columns: minmax(0, 1fr); padding: 23px; }
  .hero-art { display: none; }
  .opening-catalog .goal-links { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 520px) {
  .shell { width: calc(100% - 32px); }
  .mode-grid, .result-details { grid-template-columns: 1fr; }
  .inner-screen { padding-top: 26px; }
  .button, .text-button { min-height: 48px; }
  .hero .button, .mode-card .button, #result > .button, .opening-actions > button, .opening-learn, .study-complete-actions > .button { width: 100%; }
  .hero { padding: 19px; }
  .hero-actions .hero-button { min-height: 52px; }
  .home-diagnostics { padding-top: 15px; }
  .glossary-controls { grid-template-columns: minmax(0, 1fr); }
  .study-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .lesson-actions .button { width: 100%; }
  .lesson-layout:has(#lesson-choices:not([hidden])) .study-board-area { width: min(100%, 68vw, 18rem); margin-inline: auto; }
  #study-reset { grid-column: 1 / -1; justify-self: start; }
  .quiz-panel { padding: 16px; }
  #question-title { font-size: 1.4rem; line-height: 1.5; }
  .answers { margin-top: 16px; }
  .answer { min-height: 64px; padding: 12px; gap: 10px; font-size: 1.0625rem; line-height: 1.6; }
  .answer > span:last-child { min-width: 0; }
  .quiz-actions { display: grid; grid-template-columns: minmax(0, 1fr); gap: 6px; margin-top: 12px; }
  .result-banner { column-gap: 10px; }
  .result-emblem { grid-row: 1 / 3; }
  .result-banner h1, #result-description { grid-column: 1 / -1; }
  .result-banner h1 { font-size: 1.65rem; margin-top: 8px; }
  .result-axes li { padding: 8px; }
  .result-details > section, .result-axes li { overflow-wrap: anywhere; }
}

/* Dashboard and learning report */
.dashboard-priority .learning-block { padding: clamp(17px, 3vw, 29px); }
.dashboard-priority .learning-block p { margin-block: 5px 12px; }
.dashboard-priority .learning-block :focus-visible { outline-color: var(--gold); }
.dashboard-review-count { font-size: clamp(1.6rem, 4vw, 2.4rem); font-weight: 750; line-height: 1.2; }
.dashboard-menu-cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-top: 12px; }
.dashboard-task, .mastery-card { padding: 13px; border: 1px solid var(--line); border-radius: 8px; min-width: 0; }
.dashboard-task h3, .mastery-card h3 { font-size: 1.06rem; }
.dashboard-task p { margin-block: 5px 10px; }
.dashboard-resume { display: block; width: fit-content; margin-top: 4px; text-align: start; }
#progress.guide-screen { max-width: 1040px; }
.report-kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-block: 12px 16px; }
.report-kpis > div { display: flex; flex-direction: column-reverse; justify-content: start; gap: 3px; padding: clamp(9px, 2vw, 16px); }
.report-kpis dt, .report-note { font-size: .86rem; color: var(--muted); }
.report-kpis dd { margin: 0; font-size: clamp(1.23rem, 2.8vw, 1.85rem); font-weight: 750; }
.report-section { margin-bottom: 14px; padding: clamp(11px, 2.5vw, 22px); min-width: 0; }
.report-section h2, .report-section > summary { margin-bottom: 7px; font-size: clamp(1.12rem, 2.2vw, 1.45rem); font-weight: 750; }
.report-section summary { cursor: pointer; }
.learning-calendar { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 3px; width: min(100%, 435px); margin-block: 10px; }
.calendar-weekday { color: var(--muted); text-align: center; font-size: .875rem; }
.calendar-day { display: grid; place-items: center; min-height: 33px; padding: 0; border: 2px solid transparent; border-radius: 5px; background: #f0e9df; color: #33291e; font-size: .86rem; }
.calendar-day[data-intensity='1'] { background: #f3dba7; }
.calendar-day[data-intensity='2'] { background: #e0b971; }
.calendar-day[data-intensity='3'] { background: #aa7438; color: #171410; }
.calendar-day[data-intensity='4'] { background: #68471f; color: #fff; }
.calendar-day[aria-current='date'] { border-color: #835400; outline: 1px solid #e7b84d; outline-offset: -3px; }
.calendar-day:focus-visible { outline: 2px solid var(--charcoal); outline-offset: 1px; z-index: 1; }
.calendar-day[aria-pressed='true'] { box-shadow: inset 0 0 0 1px currentColor; font-weight: 750; }
.report-readout { background: #f4eddf; padding: 8px 10px; margin-top: 10px; border-radius: 5px; min-height: 40px; }
.report-periods, .report-legend { display: flex; flex-wrap: wrap; gap: 5px 9px; margin-block: 9px; }
.report-periods button { padding-inline: 10px; min-height: 44px; }
.report-periods button[aria-pressed='true'] { background: var(--charcoal); color: var(--white); }
.report-chart-body { max-width: 710px; }
.report-chart { display: block; width: 100%; height: 182px; cursor: crosshair; }
.report-chart text { fill: var(--ink); font-size: 13px; }
.chart-rule { stroke: #b4aa9a; stroke-width: 1; }
.chart-trend { stroke: #825619; stroke-width: 2; }
.chart-point { fill: #825619; }
.chart-practice { --series: #936423; }
.chart-review { --series: #394d49; }
.chart-questions { --series: #bf842c; }
.chart-study { --series: #786144; }
.chart-unknown { --series: #7b746e; }
.report-chart rect { fill: var(--series); }
.report-legend { padding: 0; list-style: none; font-size: .875rem; }
.report-legend li { display: inline-flex; align-items: center; gap: 4px; }
.report-legend span { width: 11px; height: 11px; border-radius: 2px; background: var(--series); }
.report-date-picker { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; font-size: .88rem; }
.report-date-picker select { min-height: 44px; max-width: 100%; background: var(--white); color: var(--ink); border: 1px solid #a69b89; border-radius: 5px; padding-inline: 6px; }
.mastery-list { display: grid; gap: 9px; margin-top: 10px; }
.mastery-status { color: var(--gold-dark); font-weight: 750; }
.mastery-card progress { margin-block: 5px; }
.mastery-card .study-mode-links { margin-top: 7px; }
.review-suggestion { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 6px; border-top: 1px solid var(--line); padding-block: 7px; }
.promotion-dialog { max-height: calc(100% - 24px); overflow: auto; }
@media (max-width: 760px) {
  .site-header .header-inner { flex-wrap: nowrap; padding-block: 8px; }
  .report-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 520px) {
  .dashboard-menu-cards { grid-template-columns: minmax(0, 1fr); }
  .report-periods { gap: 5px; }
}
.welcome-choices {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.65rem;
  margin-block: 0.9rem;
}

#welcome-guide .button, #welcome-skip, .install-help summary {
  min-height: 44px;
}

.rookori-fields {
  min-inline-size: 0;
}

.rookori-fields label:not(.batch-check) {
  display: block;
  margin-block: 0.65rem;
}

.rookori-fields input:not([type="checkbox"]), .rookori-fields textarea, .rookori-fields select {
  max-inline-size: 100%;
}

.rookori-fields textarea {
  display: block;
  width: 100%;
}

.batch-list, .batch-errors {
  margin-block: 1rem;
  padding-inline-start: 0;
  list-style: none;
  overflow-wrap: anywhere;
}

.batch-list li + li { margin-top: 0.5rem; }

.batch-check {
  display: flex;
  gap: 0.6rem;
  align-items: center;
  min-height: 44px;
}

.daily-next .text-button { display: block; margin-top: 0.5rem; }
.install-help { margin-block: 0.5rem; }
.install-help summary { cursor: pointer; }

@media (max-width: 480px) {
  .welcome-choices { grid-template-columns: 1fr; }
  .rookori-fields .button { white-space: normal; min-height: 44px; }
}
