:root {
  color-scheme: light;
  --paper: #fbf4e7;
  --paper-strong: #fff9ed;
  --ink: #2d2419;
  --muted: #756750;
  --line: #dbc9aa;
  --green: #536b46;
  --green-deep: #32432f;
  --gold: #ba8435;
  --red: #9f4d3c;
  --shadow: 0 18px 50px rgba(73, 54, 31, .16);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 0;
  background: #f4ead8;
}

body {
  margin: 0;
  color: var(--ink);
  font-family: "Hiragino Sans", "Yu Gothic", "Meiryo", system-ui, sans-serif;
  line-height: 1.7;
  background:
    radial-gradient(circle at 15% 4%, rgba(255, 255, 255, .86), transparent 34rem),
    linear-gradient(135deg, #f9f0df 0%, #eadbc0 100%);
}

button,
textarea,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.lab-shell {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0 48px;
}

.title-bar {
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: 20px;
  align-items: end;
  padding: 22px 0 18px;
}

.home-link {
  color: var(--green-deep);
  font-weight: 800;
  text-decoration: none;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: rgba(255, 250, 241, .72);
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--green);
  font-size: .78rem;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 4px;
  font-size: clamp(2rem, 4vw, 4.2rem);
  line-height: 1.04;
  letter-spacing: 0;
}

.lead {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 1.08rem;
}

.control-panel,
.province-panel,
.input-panel,
.meter-grid article,
.result-panel,
.related-panel,
.prompt-list {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 249, 237, .86);
  box-shadow: var(--shadow);
}

.control-panel {
  padding: 16px;
  margin-bottom: 16px;
}

.status-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  align-items: center;
  margin-bottom: 12px;
  color: var(--muted);
}

.status-code {
  color: var(--paper-strong);
  background: var(--green-deep);
  border-radius: 999px;
  padding: 4px 10px;
  font-weight: 800;
  font-size: .82rem;
}

.control-row,
.result-actions,
.related-links {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.primary-button,
.secondary-button {
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  padding: 10px 18px;
  font-weight: 800;
}

.primary-button {
  color: #fffaf0;
  background: var(--green-deep);
}

.secondary-button {
  color: var(--green-deep);
  background: #efe1c7;
  border: 1px solid var(--line);
}

.primary-button:focus-visible,
.secondary-button:focus-visible,
textarea:focus-visible,
a:focus-visible {
  outline: 3px solid rgba(186, 132, 53, .38);
  outline-offset: 3px;
}

.toggle-label {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  color: var(--muted);
  font-weight: 700;
}

.province-panel {
  position: relative;
  min-height: 290px;
  overflow: hidden;
  padding: 26px;
  display: grid;
  place-items: center;
  background:
    linear-gradient(90deg, rgba(95, 111, 77, .08) 1px, transparent 1px),
    linear-gradient(0deg, rgba(95, 111, 77, .08) 1px, transparent 1px),
    linear-gradient(135deg, #fbf1dd 0%, #efe0c2 100%);
  background-size: 44px 44px, 44px 44px, auto;
}

.map-lines {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: .34;
  background:
    radial-gradient(ellipse at 28% 58%, transparent 0 18%, rgba(83, 107, 70, .32) 18.5% 19%, transparent 19.5%),
    radial-gradient(ellipse at 66% 35%, transparent 0 16%, rgba(186, 132, 53, .24) 16.5% 17%, transparent 17.5%);
}

.wood-tag {
  position: relative;
  z-index: 1;
  width: min(700px, 100%);
  min-height: 190px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 12px;
  padding: 28px 22px;
  border: 2px solid #9f7642;
  border-radius: 8px;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, .22), transparent 24%, rgba(67, 41, 19, .06) 70%),
    #d6b174;
  box-shadow: inset 0 0 0 7px rgba(255, 242, 205, .24), 0 14px 28px rgba(81, 55, 26, .22);
}

.tag-label {
  color: #f9f1df;
  background: rgba(45, 36, 25, .72);
  border-radius: 999px;
  padding: 3px 10px;
  font-size: .78rem;
  font-weight: 800;
}

.province-word {
  min-height: 1.25em;
  font-family: "Yu Mincho", "Hiragino Mincho ProN", serif;
  font-size: clamp(3.3rem, 9vw, 7.6rem);
  line-height: 1;
  font-weight: 900;
  letter-spacing: .08em;
  color: #2b2118;
  text-shadow: 0 2px 0 rgba(255, 244, 213, .38);
}

.province-note {
  margin: 0;
  color: #4a3b2a;
  font-weight: 700;
  text-align: center;
}

.input-panel {
  margin-top: 16px;
  padding: 16px;
}

.input-label {
  display: block;
  margin-bottom: 8px;
  font-weight: 800;
}

textarea {
  width: 100%;
  max-width: 100%;
  resize: vertical;
  min-height: 96px;
  border: 2px solid #cdb78f;
  border-radius: 8px;
  padding: 12px;
  color: var(--ink);
  background: #fffdf8;
  font-size: 1.08rem;
}

textarea:disabled {
  color: #8a7d68;
  background: #eee2cc;
}

.rule-note {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: .92rem;
}

.meter-grid,
.result-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  margin-top: 16px;
}

.meter-grid article,
.result-grid article {
  padding: 12px;
}

.meter-grid span,
.result-grid span {
  display: block;
  color: var(--muted);
  font-size: .82rem;
  font-weight: 700;
}

.meter-grid strong,
.result-grid strong {
  display: block;
  font-size: 1.25rem;
}

.result-panel,
.related-panel,
.prompt-list {
  margin-top: 18px;
  padding: 18px;
}

.result-panel h2 {
  margin-bottom: 12px;
  font-size: clamp(2rem, 5vw, 3.4rem);
}

.result-copy {
  color: var(--muted);
  font-weight: 700;
}

.review-panel {
  margin-top: 18px;
}

.review-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.review-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fffaf0;
}

.review-card.is-lost {
  border-color: rgba(159, 77, 60, .38);
}

.review-card span {
  color: var(--green);
  font-size: .78rem;
  font-weight: 800;
}

.review-card strong,
.review-card em,
.review-card small {
  display: block;
}

.review-card strong {
  font-size: 1.45rem;
  letter-spacing: .04em;
}

.review-card em {
  color: var(--muted);
  font-style: normal;
  font-weight: 700;
}

.review-card p {
  margin-bottom: 4px;
}

.review-card small {
  color: var(--muted);
}

.related-links a {
  color: var(--green-deep);
  text-decoration: none;
  font-weight: 800;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: #fffaf0;
}

.prompt-list summary {
  cursor: pointer;
  font-weight: 800;
}

#allPrompts {
  columns: 2;
  margin-top: 12px;
  color: var(--muted);
}

#allPrompts p {
  break-inside: avoid;
  margin-bottom: 8px;
}

@media (max-width: 760px) {
  .lab-shell {
    width: min(100% - 20px, 680px);
    padding-top: 12px;
  }

  .title-bar {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .home-link {
    width: fit-content;
  }

  .province-panel {
    min-height: 250px;
    padding: 16px;
  }

  .wood-tag {
    min-height: 170px;
    padding: 22px 16px;
  }

  .province-word {
    font-size: clamp(2.6rem, 17vw, 4.6rem);
  }

  .meter-grid,
  .result-grid,
  .review-list {
    grid-template-columns: 1fr;
  }

  #allPrompts {
    columns: 1;
  }
}

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