:root {
  color-scheme: light;
  --ink: #3e2f23;
  --muted: #655b51;
  --line: #efe7d9;
  --paper: #fefefb;
  --green: #257836;
  --green-pale: #e9f5e8;
  --orange-pale: #fff0e8;
  --blue: #1c6a8c;
  --shadow: 0 12px 32px #3e2f2314;
}

* { box-sizing: border-box; }

html, body {
  max-width: 100%;
  overflow-x: hidden;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Hiragino Sans", "Yu Gothic", sans-serif;
}

.app-shell { width: min(1120px, 100%); margin: auto; padding: clamp(16px, 3vw, 32px); }
.intro { margin-bottom: 20px; }
.eyebrow, .step-label { margin: 0; color: var(--green); font-weight: 800; }
.intro h1 { margin: .2rem 0; font-size: clamp(2rem, 5vw, 3.25rem); }
.intro p:not(.eyebrow), .section-heading > p { color: var(--muted); }

.tabs { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; margin-bottom: 18px; }
.tab, button, select, input { font: inherit; }
.tab, button { min-height: 48px; border: 2px solid var(--line); border-radius: 8px; background: #fff; color: var(--ink); font-weight: 800; cursor: pointer; }
.tab.is-active, .primary { border-color: var(--green); background: var(--green); color: #fff; }

.panel { padding: clamp(16px, 3vw, 28px); border: 1px solid var(--line); border-radius: 12px; background: #fff; box-shadow: var(--shadow); }
.section-heading { display: flex; justify-content: space-between; align-items: start; gap: 16px; margin-bottom: 18px; border-bottom: 1px solid var(--line); }
.section-heading h2 { margin: .2rem 0 1rem; font-size: clamp(1.45rem, 3vw, 2rem); }
.settings { display: flex; flex-wrap: wrap; align-items: end; gap: 12px; margin-bottom: 18px; }
.settings label { display: grid; gap: 5px; font-weight: 800; }
.settings select, .settings input { min-height: 46px; padding: 6px 10px; border: 2px solid var(--line); border-radius: 8px; background: #fff; color: var(--ink); }
.primary, .secondary, .check { padding: 8px 14px; }
.secondary { border-color: #e8bda9; background: var(--orange-pale); color: #713713; }
.check { border-color: #e6bf3e; background: #fff8d7; }

.make-stage { display: grid; grid-template-columns: minmax(130px, 190px) 1fr; gap: 20px; align-items: center; }
.target-card { padding: 20px; border: 2px solid #b9d7b5; border-radius: 12px; background: var(--green-pale); text-align: center; }
.target-card span, .group-label { font-weight: 800; }
.target-card strong { display: block; font-size: 5rem; line-height: 1.05; }
.objects { display: flex; flex-wrap: wrap; gap: 10px; min-height: 60px; }
.ten-group, .ones-group { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding: 8px; border: 2px solid #3983a7; border-radius: 10px; background: #eef8fc; }
.ones-group { border-color: #b97625; background: #fff6e5; }
.group-label { width: 100%; color: var(--muted); font-size: .8rem; }
.block { width: 30px; height: 30px; border: 2px solid #b97625; border-radius: 7px; background: #ffcb70; }
.action-row, .choices { display: flex; flex-wrap: wrap; gap: 10px; }
.feedback { min-height: 28px; margin-top: 16px; padding: 8px 12px; border-left: 4px solid var(--blue); background: #eef8fc; font-weight: 800; }
.feedback.success { border-color: var(--green); background: var(--green-pale); }
.feedback.error { border-color: #a53b32; background: #fff0ee; }
.place-value { margin-top: 12px; font-size: 1.1rem; font-weight: 800; }

.number-chart, .mini-chart { display: grid; grid-template-columns: repeat(10, minmax(0, 1fr)); gap: 4px; max-width: 720px; }
.chart-cell { aspect-ratio: 1; border: 1px solid #cbd8df; border-radius: 5px; background: #fff; color: var(--ink); font-size: clamp(.75rem, 2vw, 1rem); font-weight: 800; }
.chart-cell:nth-child(10n + 1) { border-left: 3px solid #6c9b6a; }
.chart-cell.is-filled, .chart-cell.is-model, .chart-cell.is-lit { border-color: var(--green); background: var(--green); color: #fff; }
.chart-cell.is-wrong { border-color: #a53b32; background: #fff0ee; }
.sequence { padding: 16px; border-radius: 10px; background: var(--orange-pale); font-size: clamp(1.4rem, 4vw, 2.2rem); font-weight: 900; letter-spacing: .08em; }
.choices button { min-width: 88px; padding: 10px 16px; font-size: 1.2rem; }
.big-problem { font-size: clamp(2rem, 7vw, 4rem); font-weight: 900; text-align: center; }
.dot-hint { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 14px; background: #f8f6f0; }
.dot-group { display: flex; flex-wrap: wrap; gap: 6px; padding: 6px; border: 2px solid #3983a7; border-radius: 8px; }
.added-dots { border-color: #b97625; background: #fff6e5; }
.hint-symbol { font-size: 1.5rem; font-weight: 900; }
.dot { width: 20px; height: 20px; border-radius: 50%; background: #4695b7; }
.dot.removed { background: #e3b0aa; box-shadow: inset 0 0 0 2px #a53b32; }

.hundred-grid-wrap { overflow-x: auto; padding-bottom: 8px; }
.hundred-grid { display: grid; grid-template-columns: repeat(11, minmax(44px, 1fr)); min-width: 540px; border-top: 2px solid #9daeb1; border-left: 2px solid #9daeb1; }
.hundred-cell { display: grid; min-height: 46px; place-items: center; border: 0; border-right: 1px solid #9daeb1; border-bottom: 1px solid #9daeb1; background: #fff; color: var(--ink); font-weight: 800; }
.hundred-cell.is-header { background: #eef8fc; }
button.hundred-cell:not(.is-header):not(.is-answered) { cursor: pointer; }
button.hundred-cell:not(.is-header):not(.is-answered):hover, button.hundred-cell:not(.is-header):not(.is-answered):focus-visible { outline: 3px solid #e6bf3e; outline-offset: -3px; background: #fff8d7; }
.hundred-cell.is-selected { background: #fff8d7; box-shadow: inset 0 0 0 3px #e6bf3e; }
.hundred-cell.is-answered { background: var(--green-pale); color: #155724; }
.hundred-answer { max-width: 520px; margin: 20px auto 0; padding: 16px; border: 2px solid #b9d7b5; border-radius: 12px; background: #fbfefb; text-align: center; }
.hundred-answer .big-problem { margin: 0; }
.hundred-input { min-height: 1.5em; margin: 8px 0 14px; color: var(--green); font-size: clamp(2rem, 7vw, 3.2rem); font-weight: 900; }
.hundred-keypad { display: grid; grid-template-columns: repeat(3, minmax(64px, 1fr)); gap: 8px; margin: auto; max-width: 360px; }
.hundred-keypad button { min-height: 52px; font-size: 1.25rem; }
.hundred-keypad .wide-key { grid-column: span 2; }

@media (max-width: 720px) {
  .tabs { grid-template-columns: repeat(2, 1fr); }
  .make-stage { grid-template-columns: 1fr; }
  .section-heading { display: block; }
  .number-chart, .mini-chart { gap: 2px; }
  .chart-cell { border-radius: 3px; }
}

@media (max-width: 390px) {
  .app-shell { padding: 12px; }
  .tabs { gap: 6px; }
  .tab { padding: 4px; font-size: .9rem; }
  .settings { display: grid; grid-template-columns: 1fr 1fr; }
  .settings label, .settings button { min-width: 0; }
  .action-row button { flex: 1 1 100%; }
}
