:root {
  --bg: #fbf7ea;
  --card: #fffdf6;
  --ink: #3a332c;
  --sub: #7b6f62;
  --line: #e6dcc6;
  --accent: #ef7d1a;
  --accent-ink: #ffffff;
  --teal: #2a9d8f;
  --thumb: 40px;
}

* { box-sizing: border-box; }

/* button などに display を当てているので、hidden が負けないようにする */
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Hiragino Maru Gothic ProN", "Zen Maru Gothic", "M PLUS Rounded 1c",
    "BIZ UDPGothic", "Yu Gothic UI", "Meiryo", sans-serif;
  line-height: 1.6;
}

.wrap {
  max-width: 560px;
  margin: 0 auto;
  padding: 16px 16px 40px;
}

header h1 {
  margin: 8px 0 0;
  font-size: 22px;
  letter-spacing: 0.02em;
}

header h1 a.home {
  color: inherit;
  text-decoration: none;
}

header p {
  margin: 2px 0 12px;
  color: var(--sub);
  font-size: 14px;
}

.notice {
  margin: 0 0 12px;
  padding: 8px 12px;
  border: 1px dashed var(--line);
  border-radius: 10px;
  background: var(--card);
  color: var(--sub);
  font-size: 13px;
}
.notice[hidden] { display: none; }

.stage {
  position: relative;
  border: 2px solid var(--line);
  border-radius: 20px;
  overflow: hidden;
  background: #fdfbf2;
  aspect-ratio: 1 / 1;
}

.stage canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.loading {
  position: absolute;
  left: 0;
  bottom: 0;
  height: 4px;
  width: 0;
  background: var(--teal);
  transition: width 0.2s, opacity 0.6s;
}
.loading.done { opacity: 0; }

.readout {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin: 14px 2px 0;
}

.readout .label {
  flex: none;
  white-space: nowrap;
  font-size: 16px;
  color: var(--sub);
}

.readout .num {
  width: 100%;
  min-width: 0;
  padding: 2px 6px;
  border: 2px solid transparent;
  border-radius: 10px;
  background: transparent;
  font: inherit;
  font-size: clamp(34px, 11vw, 52px);
  font-weight: 800;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
}

/* 手入力できることが分かるよう、触れたら枠を出す */
.readout .num:hover { border-color: var(--line); }
.readout .num:focus { outline: none; border-color: var(--teal); background: var(--card); }

.caption {
  min-height: 3.2em;
  margin: 6px 2px 0;
  font-size: 15px;
}

.slider-box {
  margin-top: 4px;
  padding: 0 2px;
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: var(--thumb);
  margin: 0;
  background: transparent;
  touch-action: pan-y;
  cursor: pointer;
}

input[type="range"]::-webkit-slider-runnable-track {
  height: 12px;
  border-radius: 6px;
  background: linear-gradient(90deg, #f6c9a8, #c9b28c 50%, #8fae7a);
  border: 1px solid var(--line);
}
input[type="range"]::-moz-range-track {
  height: 12px;
  border-radius: 6px;
  background: linear-gradient(90deg, #f6c9a8, #c9b28c 50%, #8fae7a);
  border: 1px solid var(--line);
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: var(--thumb);
  height: var(--thumb);
  margin-top: calc((12px - var(--thumb)) / 2 - 1px);
  border-radius: 50%;
  border: 4px solid #fff;
  background: var(--accent);
  box-shadow: 0 2px 6px rgba(60, 40, 10, 0.35);
}
input[type="range"]::-moz-range-thumb {
  width: calc(var(--thumb) - 8px);
  height: calc(var(--thumb) - 8px);
  border-radius: 50%;
  border: 4px solid #fff;
  background: var(--accent);
  box-shadow: 0 2px 6px rgba(60, 40, 10, 0.35);
}

input[type="range"]:focus-visible {
  outline: 3px solid var(--teal);
  outline-offset: 4px;
  border-radius: 12px;
}

.ticks {
  position: relative;
  height: 26px;
  margin: 0 calc(var(--thumb) / 2);
}

.ticks span {
  position: absolute;
  top: 0;
  transform: translateX(-50%);
  font-size: 14px;
  font-weight: 700;
  color: var(--sub);
  font-variant-numeric: tabular-nums;
}

.ticks span::before {
  content: "";
  display: block;
  width: 2px;
  height: 6px;
  margin: 0 auto 1px;
  background: var(--line);
}

.actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-top: 14px;
}

.actions .row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

button, .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 10px 14px;
  border: 2px solid var(--line);
  border-radius: 14px;
  background: var(--card);
  color: var(--ink);
  font: inherit;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}

button.primary, .btn.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 17px;
}

button:active, .btn:active { transform: translateY(1px); }

.toast {
  min-height: 1.6em;
  margin-top: 8px;
  color: var(--teal);
  font-size: 13px;
  text-align: center;
}

footer {
  margin-top: 28px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  color: var(--sub);
  font-size: 13px;
}

footer p { margin: 0 0 6px; }

a { color: #1c7a6f; }

.chars {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 0 0 12px;
}
.chars:empty { display: none; }
.chars .char {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  border: 2px solid var(--line);
  border-radius: 12px;
  background: var(--card);
  color: var(--ink);
  font-weight: 700;
  text-decoration: none;
}
.chars .char.on {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-ink);
}

.note h2 { margin: 18px 0 6px; font-size: 18px; }
.note ul { margin: 0; padding-left: 1.2em; }
.note li { margin: 4px 0; }
