:root {
  --paper: #fffaf0;
  --paper-deep: #f7e7c6;
  --panel: #fffdfa;
  --shelf: #fff4d9;
  --ink: #2b251d;
  --muted: #736651;
  --line: #dfc895;
  --green: #4f8f63;
  --green-deep: #2f6844;
  --green-dark: #183b29;
  --leaf-light: #b9d88d;
  --gold: #e7bb52;
  --danger: #a8493d;
  --radius: 8px;
  --shadow: 0 10px 26px rgba(86, 60, 24, .09);
  color-scheme: light;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { min-width: 320px; background: var(--paper); }
body {
  min-width: 320px;
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: "Yu Gothic", "Hiragino Kaku Gothic ProN", Meiryo, system-ui, sans-serif;
  line-height: 1.6;
  overflow-x: clip;
}
a { color: inherit; }
button, input { font: inherit; }
button { cursor: pointer; touch-action: manipulation; }
button:disabled, input:disabled { cursor: not-allowed; }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 3px; }

.site-header {
  min-height: 56px;
  color: #f9fff8;
  background: var(--green-deep);
  border-bottom: 4px solid #83b778;
}
.header-inner, .footer-inner {
  width: min(1100px, calc(100% - 36px));
  margin: 0 auto;
  padding: 9px 0;
}
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}
.brand {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: baseline;
  gap: 9px;
  color: #fff;
  text-decoration: none;
  white-space: nowrap;
}
.brand strong { font-size: 1rem; letter-spacing: .04em; }
.brand span { color: #b9d9c9; font-size: .75rem; letter-spacing: .06em; }
.nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 4px;
}
.nav a, .site-footer a {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  padding: 5px 8px;
  border-radius: 7px;
  color: #eef8f1;
  font-size: .8rem;
  text-decoration: none;
}
.nav a:hover, .nav a:focus-visible, .site-footer a:hover, .site-footer a:focus-visible { background: rgba(131, 183, 120, .18); }

.page-shell {
  width: min(1320px, calc(100% - 24px));
  margin: 0 auto;
  padding: 22px 0 48px;
  display: grid;
  grid-template-columns: minmax(92px, 110px) minmax(0, 1100px) minmax(92px, 110px);
  gap: 18px;
  align-items: start;
}
.word-tree-main { min-width: 0; width: 100%; display: grid; gap: 16px; }
.ad-rail { min-width: 0; min-height: 260px; }
.ad-box {
  position: sticky;
  top: 18px;
  min-height: 150px;
  display: grid;
  place-items: center;
  padding: 10px;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  color: var(--muted);
  background: rgba(247, 231, 198, .42);
  font-size: .72rem;
  letter-spacing: .08em;
}

.tree-intro {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(290px, .8fr);
  gap: 16px;
}
.tree-intro-card, .tree-rule-panel, .tree-status-panel, .tree-stage-panel, .tree-choice-panel, .tree-input-panel, .tree-result-panel, .tree-howto-panel, .tree-related-nav {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 253, 250, .96);
  box-shadow: var(--shadow);
}
.tree-intro-card { padding: 25px 28px; }
.eyebrow, .tree-panel-kicker {
  margin: 0 0 6px;
  color: var(--green);
  font-size: .72rem;
  font-weight: 800;
  letter-spacing: .12em;
  text-transform: uppercase;
}
h1, h2, h3, p { overflow-wrap: anywhere; }
h1, h2, h3 { color: var(--green-dark); }
h1 { margin: 0 0 9px; font-size: clamp(30px, 4.2vw, 46px); line-height: 1.13; letter-spacing: -.03em; }
h1 span { display: block; margin-top: 5px; color: var(--muted); font-size: .43em; font-weight: 800; letter-spacing: .08em; }
.tree-lead { margin: 0; color: var(--muted); font-size: 1.02rem; }
.tree-rule-panel { padding: 20px 22px; background: var(--shelf); }
.tree-rule-panel h2, .tree-stage-panel h2, .tree-choice-panel h2, .tree-result-panel h2, .tree-howto-panel h2, .tree-related-nav h2 {
  margin: 0; color: var(--green-dark); font-size: clamp(21px, 3vw, 29px); line-height: 1.2;
}
.tree-rule-copy { margin: 9px 0 10px; font-size: .91rem; }
.tree-rule-list { margin: 0 0 17px; padding-left: 1.2em; color: var(--muted); font-size: .84rem; }
.tree-button {
  min-height: 44px;
  padding: 8px 18px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  font-weight: 800;
  letter-spacing: .03em;
}
.tree-button-primary { color: #fff; background: var(--green); border-color: var(--green-deep); }
.tree-button-primary:hover:not(:disabled), .tree-button-primary:focus-visible { background: var(--green-deep); }
.tree-button-primary:disabled { opacity: .52; }

.tree-status-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 15px;
  align-items: center;
  padding: 14px 17px;
  background: var(--shelf);
}
.tree-status-copy { min-width: 0; }
.tree-game-status { margin: 0 0 2px; color: var(--green-dark); font-weight: 800; }
.tree-input-status { min-height: 1.4em; margin: 0; color: var(--muted); font-size: .84rem; }
.tree-input-status.is-warning { color: #87522e; }
.tree-input-status.is-success { color: var(--green-deep); }
.tree-input-status.is-danger { color: var(--danger); font-weight: 800; }
.tree-metrics {
  min-width: 300px;
  margin: 0;
  display: grid;
  grid-template-columns: repeat(4, minmax(62px, 1fr));
  border: 1px solid var(--line);
  border-radius: 7px;
  overflow: hidden;
}
.tree-metrics > div { min-width: 0; padding: 6px 8px 5px; text-align: center; background: rgba(255, 253, 250, .72); border-left: 1px solid var(--line); }
.tree-metrics > div:first-child { border-left: 0; }
.tree-metrics dt { color: var(--muted); font-size: .66rem; font-weight: 800; letter-spacing: .08em; white-space: nowrap; }
.tree-metrics dd { margin: 0; color: var(--green-dark); font-size: 1.02rem; font-weight: 800; line-height: 1.25; white-space: nowrap; }

.tree-stage-panel, .tree-choice-panel, .tree-input-panel { padding: 16px 18px; }
.tree-section-heading { display: flex; align-items: end; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.tree-section-heading .tree-panel-kicker { margin-bottom: 3px; }
.tree-round-note, .tree-choice-note {
  margin: 0; padding: 5px 9px; border: 1px solid var(--line); border-radius: 999px;
  color: var(--muted); background: var(--paper-deep); font-size: .77rem; font-weight: 800; white-space: nowrap;
}
.tree-stage {
  position: relative;
  min-height: 230px;
  height: clamp(230px, calc(100vh - 495px), 320px);
  overflow: hidden;
  isolation: isolate;
  border: 1px solid #b4cb9b;
  border-radius: 10px;
  background: radial-gradient(circle at 50% 26%, rgba(236, 247, 193, .9), transparent 42%), linear-gradient(180deg, #edf5d9 0%, #d9ebca 58%, #b7d395 100%);
}
.tree-stage-glow {
  position: absolute;
  inset: 8% 13% 10%;
  z-index: 0;
  border-radius: 50%;
  background: radial-gradient(ellipse, rgba(255, 255, 255, .5), transparent 68%);
}
.tree-svg { position: absolute; z-index: 1; inset: 0; width: 100%; height: 100%; }
.tree-ground { fill: none; stroke: rgba(47, 104, 68, .32); stroke-width: 3; }
.tree-trunk { fill: none; stroke: #725138; stroke-width: 15; stroke-linecap: round; }
.tree-trunk-highlight { fill: none; stroke: #a8794f; stroke-width: 4; stroke-linecap: round; opacity: .72; }
.tree-crown { fill: #5d9a5e; stroke: #386f48; stroke-width: 3; }
.tree-branch {
  fill: none; stroke: var(--green-deep); stroke-width: 8; stroke-linecap: round; stroke-linejoin: round;
  transform-origin: 300px 230px; animation: tree-grow .23s ease-out both;
}
.tree-branch-right { stroke: #3d7d51; }
.tree-leaf { fill: var(--leaf-light); stroke: #4f8f63; stroke-width: 2; animation: leaf-appear .23s ease-out both; }
.tree-summary {
  position: absolute; z-index: 2; right: 12px; bottom: 8px; max-width: calc(100% - 24px); margin: 0; padding: 4px 8px;
  border-radius: 6px; color: #315b3b; background: rgba(255, 253, 250, .78); font-size: .76rem; font-weight: 700; text-align: right;
}
@keyframes tree-grow {
  from { opacity: .18; stroke-dasharray: 160; stroke-dashoffset: 160; }
  to { opacity: 1; stroke-dashoffset: 0; }
}
@keyframes leaf-appear {
  from { opacity: 0; transform: scale(.35); transform-origin: center; }
  to { opacity: 1; transform: scale(1); }
}

.tree-choice-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.tree-choice-card {
  min-width: 0; min-height: 84px; display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto;
  align-items: center; column-gap: 10px; padding: 11px 13px; border: 2px solid var(--line); border-radius: var(--radius); background: #fffdf7;
}
.tree-choice-card:first-child { border-color: #86b979; }
.tree-choice-card:last-child { border-color: #8eb0ce; }
.tree-choice-label {
  grid-row: 1 / span 2; min-width: 40px; display: grid; place-items: center; align-self: stretch;
  border-radius: 6px; color: #fff; background: var(--green); font-size: .75rem; font-weight: 800;
}
.tree-choice-card:last-child .tree-choice-label { background: #557da6; }
.tree-choice-card strong { min-width: 0; color: var(--green-dark); font-size: clamp(1.05rem, 2.8vw, 1.55rem); line-height: 1.2; overflow-wrap: anywhere; }
.tree-choice-hint { color: var(--muted); font-size: .72rem; }

.tree-input-panel { background: rgba(255, 253, 250, .98); }
.tree-input-panel > label { display: block; margin-bottom: 6px; color: var(--green-dark); font-size: .9rem; font-weight: 800; }
.tree-input-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 9px; }
.tree-input-row input {
  width: 100%; min-width: 0; min-height: 46px; padding: 8px 12px; border: 2px solid #c9b580; border-radius: var(--radius);
  color: var(--ink); background: #fffefa; font-size: 1.08rem;
}
.tree-input-row input:focus { border-color: var(--green); outline: 3px solid rgba(79, 143, 99, .18); outline-offset: 1px; }
.tree-input-row .tree-button { min-width: 82px; }
.tree-input-hint { min-height: 1.35em; margin: 6px 0 0; color: var(--muted); font-size: .78rem; }

.tree-result-panel { padding: 21px 23px 23px; background: var(--shelf); }
.tree-result-message { margin: 7px 0 14px; color: var(--muted); }
.tree-result-grid {
  margin: 0 0 17px; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr));
  border: 1px solid var(--line); border-radius: 7px; overflow: hidden;
}
.tree-result-grid > div { min-width: 0; padding: 8px 7px; text-align: center; background: rgba(255, 253, 250, .74); border-left: 1px solid var(--line); }
.tree-result-grid > div:first-child { border-left: 0; }
.tree-result-grid dt { color: var(--muted); font-size: .68rem; font-weight: 800; white-space: nowrap; }
.tree-result-grid dd { margin: 2px 0 0; color: var(--green-dark); font-size: 1.12rem; font-weight: 800; white-space: nowrap; }

.tree-howto-panel { padding: 20px 22px; }
.tree-howto-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-top: 11px; }
.tree-howto-grid > div { padding: 11px 12px; border: 1px solid var(--line); border-radius: 7px; background: var(--paper-deep); }
.tree-howto-grid span { color: var(--green); font-size: .75rem; font-weight: 900; letter-spacing: .08em; }
.tree-howto-grid p { margin: 4px 0 0; color: var(--muted); font-size: .82rem; }

.tree-related-nav {
  display: grid; grid-template-columns: minmax(150px, .65fr) minmax(0, 1.35fr); gap: 15px; align-items: center; padding: 17px 18px;
}
.tree-related-links { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 7px; }
.tree-related-links a {
  min-height: 54px; display: flex; flex-direction: column; justify-content: center; padding: 7px 9px;
  border: 1px solid var(--line); border-radius: 7px; color: var(--green-dark); background: var(--paper-deep); text-decoration: none;
}
.tree-related-links a:hover, .tree-related-links a:focus-visible { border-color: var(--green); background: #fffdf7; }
.tree-related-links strong { font-size: .78rem; }
.tree-related-links small { color: var(--muted); font-size: .66rem; }

.site-footer { color: #eef8f1; background: var(--green-deep); border-top: 4px solid #83b778; }
.footer-inner { display: flex; justify-content: flex-end; }
.footer-links { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 4px; }

body.is-playing .tree-intro, body.is-playing .tree-howto-panel, body.is-playing .tree-related-nav { display: none; }

@media (max-width: 1280px) {
  .page-shell { width: min(1100px, calc(100% - 36px)); grid-template-columns: minmax(0, 1fr); }
  .ad-rail { display: none; }
}
@media (max-width: 760px) {
  .header-inner { align-items: flex-start; flex-direction: column; gap: 5px; }
  .nav { justify-content: flex-start; }
  .page-shell { padding-top: 12px; }
  .tree-intro { grid-template-columns: 1fr; }
  .tree-status-panel { grid-template-columns: 1fr; gap: 10px; }
  .tree-metrics { width: 100%; min-width: 0; }
  .tree-stage-panel, .tree-choice-panel, .tree-input-panel { padding: 13px 12px; }
  .tree-stage { height: 230px; }
  .tree-related-nav { grid-template-columns: 1fr; }
  .tree-related-links { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 430px) {
  .header-inner, .footer-inner { width: min(100% - 24px, 1100px); }
  .page-shell { width: calc(100% - 20px); }
  .tree-status-panel { padding: 11px 10px; }
  .tree-game-status { font-size: .9rem; }
  .tree-input-status { font-size: .76rem; }
  .tree-metrics dt { font-size: .6rem; }
  .tree-metrics dd { font-size: .91rem; }
  .tree-choice-card { min-height: 78px; padding: 9px 8px; column-gap: 7px; }
  .tree-choice-label { min-width: 35px; font-size: .68rem; }
  .tree-choice-card strong { font-size: 1.05rem; }
  .tree-choice-hint { font-size: .64rem; }
  .tree-result-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .tree-result-grid > div:nth-child(4) { border-left: 0; border-top: 1px solid var(--line); }
  .tree-result-grid > div:nth-child(5) { border-top: 1px solid var(--line); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}
