:root {
  --navy: #102a43;
  --navy-deep: #0a1e30;
  --ink: #17324d;
  --muted: #5d7082;
  --paper: #f6f1e6;
  --paper-light: #fffdf8;
  --yellow: #ffc857;
  --yellow-soft: #fff0ba;
  --line: #d8cdbb;
  --green: #176b50;
  --red: #a33a38;
  --shadow: 0 20px 50px rgba(16, 42, 67, 0.13);
  --radius-lg: 26px;
  --radius-md: 16px;
  --focus: 0 0 0 4px rgba(255, 200, 87, 0.52);
  font-family: ui-rounded, "Hiragino Maru Gothic ProN", "Yu Gothic", sans-serif;
  color: var(--ink);
  background: var(--paper);
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  position: relative;
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  background: var(--paper);
  color: var(--ink);
  line-height: 1.7;
}

button,
input,
select {
  font: inherit;
}

button,
a,
select,
input {
  -webkit-tap-highlight-color: transparent;
}

button,
a,
select {
  cursor: pointer;
}

button:focus-visible,
a:focus-visible,
select:focus-visible,
input:focus-visible {
  outline: none;
  box-shadow: var(--focus);
}

.paper-texture {
  position: fixed;
  z-index: -1;
  inset: 0;
  pointer-events: none;
  opacity: 0.46;
  background-color: var(--paper);
  background-image:
    linear-gradient(135deg, rgba(255, 255, 255, 0.68), rgba(246, 241, 230, 0.1) 55%),
    url("../assets/paper-dots.webp");
  background-position: center, center top;
  background-repeat: no-repeat;
  background-size: cover, cover;
}

.site-shell {
  width: min(1180px, calc(100% - 48px));
  margin: 0 auto;
}

.site-header {
  position: relative;
  z-index: 2;
  background: var(--navy);
  color: var(--paper-light);
  border-bottom: 5px solid var(--yellow);
}

.header-inner,
.footer-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 76px;
  gap: 24px;
}

.brand,
.header-link {
  color: inherit;
  text-decoration: none;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 13px;
  font-size: 1.03rem;
  font-weight: 800;
  letter-spacing: 0.05em;
}

.brand-mark {
  display: grid;
  grid-template-columns: repeat(2, 6px);
  gap: 4px 7px;
  padding: 5px;
  border: 1px solid rgba(255, 200, 87, 0.7);
  border-radius: 8px;
}

.brand-mark i {
  display: block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--yellow);
  box-shadow: inset 1px 1px 1px rgba(255, 255, 255, 0.45), 1px 1px 1px rgba(0, 0, 0, 0.25);
}

.header-link {
  padding: 10px 0;
  color: #d9e7ed;
  font-size: 0.85rem;
}

.header-link:hover {
  color: var(--yellow);
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 260px;
  gap: 64px;
  align-items: end;
  min-height: 390px;
  padding: 82px 0 74px;
}

.eyebrow {
  margin: 0 0 10px;
  color: #8b5b11;
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.18em;
}

.hero h1 {
  max-width: 760px;
  margin: 0;
  color: var(--navy);
  font-size: clamp(2.25rem, 5.2vw, 4.7rem);
  font-weight: 900;
  letter-spacing: -0.065em;
  line-height: 1.14;
}

.hero h1 span {
  position: relative;
  z-index: 0;
  display: inline-block;
}

.hero h1 span::after {
  position: absolute;
  z-index: -1;
  right: -0.04em;
  bottom: 0.07em;
  left: -0.04em;
  height: 0.28em;
  content: "";
  background: var(--yellow);
  transform: rotate(-1.2deg);
}

.hero-lead {
  max-width: 660px;
  margin: 30px 0 0;
  color: var(--muted);
  font-size: 1.02rem;
}

.input-example {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px 14px;
  margin-top: 28px;
  padding: 11px 16px;
  border-left: 4px solid var(--yellow);
  background: rgba(255, 253, 248, 0.74);
  color: var(--muted);
  font-size: 0.87rem;
}

.input-example-label {
  color: var(--navy);
  font-size: 0.7rem;
  font-weight: 900;
  letter-spacing: 0.12em;
}

.input-example code {
  padding: 1px 8px;
  border-radius: 7px;
  background: var(--navy);
  color: var(--yellow);
  font-size: 1rem;
  font-weight: 800;
}

.hero-aside {
  display: grid;
  justify-items: start;
  align-content: end;
  min-height: 235px;
  padding: 29px 30px;
  border: 1px solid rgba(16, 42, 67, 0.18);
  border-radius: var(--radius-lg) 7px var(--radius-lg) 7px;
  background: var(--navy);
  color: var(--paper-light);
  box-shadow: 14px 14px 0 var(--yellow);
  transform: rotate(1.5deg);
}

.hero-number {
  color: var(--yellow);
  font-size: 4.6rem;
  font-weight: 900;
  letter-spacing: -0.1em;
  line-height: 0.9;
}

.hero-aside p {
  margin: 16px 0 0;
  font-size: 1.15rem;
  font-weight: 800;
  line-height: 1.45;
}

.hero-aside .hero-small {
  margin-top: 12px;
  color: #b4cad4;
  font-size: 0.73rem;
  font-weight: 500;
}

.hero-rule {
  width: 100%;
  height: 1px;
  margin-top: 22px;
  background: rgba(255, 200, 87, 0.44);
}

.practice-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(290px, 0.8fr);
  gap: 30px;
  align-items: start;
  padding-bottom: 95px;
}

.card,
.side-card {
  border: 1px solid rgba(16, 42, 67, 0.12);
  background: rgba(255, 253, 248, 0.94);
  box-shadow: var(--shadow);
}

.card {
  border-radius: var(--radius-lg);
}

.practice-main {
  padding: clamp(24px, 4vw, 48px);
}

.section-heading,
.result-topline,
.saved-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
}

.section-heading h2,
.result-topline h2,
.saved-heading h2,
.side-card h2,
.about-section h2 {
  margin: 0;
  color: var(--navy);
  font-size: clamp(1.35rem, 2.2vw, 2rem);
  letter-spacing: -0.045em;
  line-height: 1.3;
}

.step-chip,
.count-chip {
  display: inline-flex;
  align-items: center;
  min-height: 31px;
  padding: 4px 11px;
  border-radius: 999px;
  background: var(--yellow-soft);
  color: #6f4c0c;
  font-size: 0.73rem;
  font-weight: 900;
  letter-spacing: 0.03em;
  white-space: nowrap;
}

.field-group {
  margin: 39px 0 0;
  padding: 0;
  border: 0;
}

.field-group legend {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  margin-bottom: 16px;
  color: var(--navy);
  font-size: 1.04rem;
  font-weight: 900;
}

.step-number {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--navy);
  color: var(--yellow);
  font-size: 0.78rem;
}

.field-label,
.direct-input label {
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.select-control,
.direct-input input {
  width: 100%;
  min-height: 50px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fffefb;
  color: var(--ink);
  font-size: 1rem;
}

.select-control {
  padding: 0 15px;
}

.field-help,
.orientation-description,
.dot-map-alt,
.keyboard-hint,
.privacy-note,
.side-note,
.source-note {
  color: var(--muted);
  font-size: 0.82rem;
}

.field-help {
  margin: 8px 0 0;
}

.orientation-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.orientation-option {
  position: relative;
  display: block;
}

.orientation-option input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.orientation-option-body {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 76px;
  padding: 13px 15px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fffefb;
}

.orientation-option-body strong {
  color: var(--navy);
  font-size: 0.94rem;
}

.orientation-option-body small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.74rem;
  line-height: 1.45;
}

.orientation-option input:checked + .orientation-option-body {
  border-color: var(--navy);
  background: var(--navy);
  box-shadow: inset 4px 0 0 var(--yellow);
}

.orientation-option input:focus-visible + .orientation-option-body {
  box-shadow: var(--focus);
}

.result-panel:focus-visible {
  outline: 3px solid var(--yellow);
  outline-offset: 8px;
}

.orientation-option input:checked + .orientation-option-body strong {
  color: var(--yellow);
}

.orientation-option input:checked + .orientation-option-body small {
  color: #d6e5ea;
}

.orientation-description {
  min-height: 26px;
  margin: 11px 0 0;
}

.dot-map-wrap {
  padding: 19px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: #f4eddf;
}

.dot-map-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.mini-label {
  color: var(--navy);
  font-size: 0.75rem;
  font-weight: 900;
  letter-spacing: 0.08em;
}

.orientation-label {
  color: #8b5b11;
  font-size: 0.73rem;
  font-weight: 900;
}

.dot-grid,
.preview-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(44px, 82px));
  grid-template-rows: repeat(3, minmax(44px, 82px));
  justify-content: center;
  gap: 12px 22px;
  margin: 22px auto 9px;
}

.dot-button {
  display: grid;
  place-items: center;
  min-width: 44px;
  min-height: 44px;
  border: 1px solid #bfae91;
  border-radius: 50%;
  background: #e5dac7;
  color: var(--navy);
  font-size: 1.05rem;
  font-weight: 900;
  box-shadow: inset 4px 4px 7px rgba(122, 101, 72, 0.15), inset -3px -3px 5px rgba(255, 255, 255, 0.68), 0 2px 0 rgba(73, 55, 32, 0.12);
  transition: transform 120ms ease, background 120ms ease, color 120ms ease;
}

.dot-button:hover {
  transform: translateY(-2px);
}

.dot-button[aria-pressed="true"] {
  border-color: var(--navy);
  background: var(--yellow);
  color: var(--navy-deep);
  box-shadow: inset 3px 3px 6px rgba(155, 102, 0, 0.2), 0 3px 0 rgba(73, 55, 32, 0.16);
}

.dot-map-alt {
  max-width: 400px;
  margin: 12px auto 0;
  text-align: center;
}

.direct-input {
  margin-top: 21px;
}

.direct-input-row {
  display: flex;
  align-items: stretch;
  gap: 8px;
}

.direct-input input {
  flex: 1 1 auto;
  min-width: 0;
  padding: 0 13px;
}

.direct-input-row .button {
  flex: 0 0 auto;
}

.form-status {
  min-height: 1.5em;
  margin: 8px 0 0;
  font-size: 0.82rem;
  font-weight: 700;
}

.form-status:empty {
  margin: 0;
}

.form-status[data-tone="error"] {
  color: var(--red);
}

.form-status[data-tone="success"] {
  color: var(--green);
}

.keyboard-hint {
  margin: 13px 0 0;
}

kbd {
  display: inline-block;
  min-width: 22px;
  padding: 0 5px;
  border: 1px solid #c5b59b;
  border-bottom-width: 2px;
  border-radius: 5px;
  background: #fffaf0;
  color: var(--navy);
  font-size: 0.77rem;
  font-weight: 800;
  text-align: center;
}

.form-actions,
.result-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.form-actions {
  margin-top: 32px;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  padding: 9px 16px;
  border: 1px solid transparent;
  border-radius: 9px;
  font-size: 0.87rem;
  font-weight: 900;
  line-height: 1.2;
  text-decoration: none;
  transition: transform 120ms ease, background 120ms ease, border-color 120ms ease;
}

.button:hover:not(:disabled) {
  transform: translateY(-2px);
}

.button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.button-primary {
  background: var(--navy);
  color: var(--paper-light);
  box-shadow: 0 3px 0 var(--navy-deep);
}

.button-primary:hover:not(:disabled) {
  background: #1d496c;
}

.button-secondary {
  border-color: var(--navy);
  background: transparent;
  color: var(--navy);
}

.button-secondary:hover:not(:disabled) {
  background: var(--yellow-soft);
}

.button-quiet {
  border-color: transparent;
  background: transparent;
  color: var(--muted);
}

.button-quiet:hover:not(:disabled) {
  background: #f0e7d7;
  color: var(--navy);
}

.result-panel {
  margin-top: 47px;
  padding-top: 35px;
  border-top: 1px dashed var(--line);
}

.result-badge {
  display: inline-flex;
  align-items: center;
  min-height: 35px;
  padding: 5px 13px;
  border-radius: 999px;
  background: var(--yellow);
  color: var(--navy);
  font-size: 0.83rem;
  font-weight: 900;
}

.result-badge[data-tone="error"] {
  background: #f6d6ce;
  color: #7e2826;
}

.result-summary {
  margin: 15px 0 21px;
  color: var(--muted);
  font-size: 0.95rem;
}

.preview-and-actions {
  display: grid;
  grid-template-columns: minmax(170px, 0.75fr) minmax(230px, 1fr);
  gap: 24px;
  align-items: center;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: #f4eddf;
}

.preview-grid {
  grid-template-columns: repeat(2, 40px);
  grid-template-rows: repeat(3, 40px);
  gap: 8px 16px;
  margin: 0 auto;
}

.preview-dot {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 1px solid #bfae91;
  border-radius: 50%;
  background: #e4dac8;
  color: #81909c;
  font-size: 0.78rem;
  font-weight: 800;
}

.preview-dot.is-on {
  border-color: var(--navy);
  background: var(--yellow);
  color: var(--navy);
  box-shadow: inset 2px 2px 4px rgba(155, 102, 0, 0.2);
}

.result-actions {
  justify-content: flex-start;
}

.comparison-panel {
  margin-top: 23px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: #fffefb;
}

.comparison-panel h3 {
  margin: 0 0 12px;
  color: var(--navy);
  font-size: 0.96rem;
}

.comparison-table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}

th,
td {
  padding: 9px 8px;
  border-bottom: 1px solid #e8dfd2;
  text-align: left;
}

th {
  color: var(--muted);
  font-size: 0.72rem;
}

td:last-child {
  color: var(--green);
  font-weight: 900;
}

.practice-side {
  display: grid;
  gap: 20px;
}

.side-card {
  padding: 28px;
  border-radius: 7px var(--radius-lg) 7px var(--radius-lg);
}

.orientation-card {
  background: var(--navy);
  color: var(--paper-light);
  box-shadow: 12px 12px 0 rgba(255, 200, 87, 0.85);
}

.orientation-card .eyebrow,
.orientation-card h2 {
  color: var(--yellow);
}

.orientation-sketches {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 15px;
  margin-top: 27px;
}

.orientation-sketch {
  padding: 13px 10px;
  border: 1px solid rgba(217, 231, 237, 0.2);
  border-radius: 11px;
  text-align: center;
}

.sketch-label {
  display: block;
  color: var(--yellow);
  font-size: 0.76rem;
  font-weight: 900;
}

.sketch-grid {
  display: grid;
  grid-template-columns: repeat(2, 17px);
  grid-template-rows: repeat(3, 17px);
  justify-content: center;
  gap: 4px 7px;
  margin: 11px 0 9px;
}

.sketch-grid b {
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #dbe8ea;
  color: var(--navy);
  font-size: 0.58rem;
  line-height: 1;
}

.orientation-sketch small {
  color: #b4cad4;
  font-size: 0.68rem;
}

.orientation-card .side-note {
  margin: 22px 0 0;
  color: #c3d4db;
}

.saved-card {
  background: rgba(255, 253, 248, 0.93);
}

.history-list {
  display: grid;
  gap: 9px;
  min-height: 30px;
  margin: 15px 0 0;
  padding: 0;
  list-style: none;
}

.history-empty {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.history-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid #e8dfd2;
}

.history-item-main {
  min-width: 0;
}

.history-item-main strong,
.history-item-main small {
  display: block;
}

.history-item-main strong {
  color: var(--navy);
  font-size: 0.82rem;
}

.history-item-main small {
  overflow: hidden;
  color: var(--muted);
  font-size: 0.68rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-item .button {
  min-width: 44px;
  min-height: 40px;
  padding: 7px 8px;
  font-size: 0.72rem;
}

.history-clear {
  width: 100%;
  margin-top: 12px;
}

.privacy-note {
  margin: 15px 0 0;
  font-size: 0.7rem;
}

.about-section {
  display: grid;
  grid-template-columns: 0.75fr 1.25fr;
  gap: 50px;
  padding: 65px 0 90px;
  border-top: 1px solid var(--line);
}

.about-section h2 {
  font-size: clamp(1.5rem, 3vw, 2.4rem);
}

.about-copy {
  max-width: 700px;
  color: var(--muted);
}

.about-copy p {
  margin: 0 0 16px;
}

.about-copy .source-note {
  padding-top: 14px;
  border-top: 1px dashed var(--line);
  font-size: 0.78rem;
}

.source-list {
  display: grid;
  gap: 8px;
  margin: 22px 0 0;
  padding: 18px 18px 18px 38px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 253, 248, 0.78);
  font-size: 0.82rem;
}

.source-list a {
  color: var(--navy);
  font-weight: 800;
  text-underline-offset: 0.2em;
}

.site-footer {
  background: var(--navy);
  color: #c3d4db;
}

.footer-inner {
  min-height: 86px;
  font-size: 0.76rem;
}

.error-page {
  display: grid;
  justify-items: start;
  align-content: center;
  min-height: 100vh;
  padding-top: 40px;
  padding-bottom: 40px;
}

.error-page h1 {
  margin: 0;
  color: var(--navy);
  font-size: clamp(2rem, 6vw, 4rem);
  letter-spacing: -0.06em;
}

.error-page p {
  margin: 18px 0 28px;
  color: var(--muted);
}

[hidden] {
  display: none !important;
}

@media (max-width: 850px) {
  .hero {
    grid-template-columns: minmax(0, 1fr) 210px;
    gap: 32px;
  }

  .practice-layout {
    grid-template-columns: 1fr;
  }

  .practice-side {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .site-shell {
    width: min(100% - 28px, 560px);
  }

  .header-inner {
    min-height: 68px;
  }

  .header-link {
    display: none;
  }

  .hero {
    display: block;
    min-height: auto;
    padding: 55px 0 67px;
  }

  .hero h1 {
    font-size: clamp(2.35rem, 13vw, 4rem);
  }

  .hero-lead {
    margin-top: 22px;
    font-size: 0.94rem;
  }

  .hero-aside {
    display: inline-grid;
    min-height: 0;
    margin: 41px 0 0 13px;
    padding: 22px;
  }

  .hero-number {
    font-size: 3.6rem;
  }

  .practice-layout {
    padding-bottom: 65px;
  }

  .practice-main {
    padding: 22px 17px;
  }

  .section-heading,
  .result-topline,
  .saved-heading {
    display: block;
  }

  .step-chip,
  .result-badge,
  .count-chip {
    margin-top: 13px;
  }

  .field-group {
    margin-top: 32px;
  }

  .orientation-options {
    grid-template-columns: 1fr;
  }

  .dot-map-wrap {
    padding: 15px 11px;
  }

  .dot-grid {
    gap: 10px 18px;
  }

  .direct-input-row {
    align-items: stretch;
  }

  .direct-input-row .button {
    padding-right: 12px;
    padding-left: 12px;
  }

  .form-actions .button {
    width: 100%;
  }

  .preview-and-actions {
    grid-template-columns: 1fr;
    gap: 18px;
  }

  .result-actions .button {
    flex: 1 1 calc(50% - 10px);
    min-width: 130px;
  }

  .practice-side {
    grid-template-columns: 1fr;
  }

  .about-section {
    display: block;
    padding: 48px 0 66px;
  }

  .about-copy {
    margin-top: 23px;
  }

  .footer-inner {
    display: grid;
    align-content: center;
    gap: 3px;
    min-height: 76px;
  }
}

@media print {
  .site-header,
  .hero,
  .practice-side,
  .form-actions,
  .result-actions,
  .about-section,
  .site-footer,
  .direct-input,
  .keyboard-hint {
    display: none !important;
  }

  .site-shell {
    width: 100%;
  }

  .practice-layout,
  .practice-main {
    display: block;
    padding: 0;
    box-shadow: none;
  }

  .result-panel {
    margin-top: 0;
    padding-top: 0;
    border-top: 0;
  }

  .paper-texture {
    display: none;
  }
}

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