.page {
  flex: 1;
  max-width: var(--w-base);
  width: 100%;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* ---------- Tool card ---------- */
.tool {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
}

/* ---------- 入力 ---------- */
.block {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
}
.block-label {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  margin-bottom: 10px;
}
.block-label .count {
  font-size: 12px;
  color: var(--muted);
  text-align: right;
}

textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  font-family: "Noto Sans JP", sans-serif;
  font-size: 14px;
  background: var(--surface);
  color: var(--ink);
  resize: vertical;
  outline: none;
  transition: border-color 140ms ease, box-shadow 140ms ease;
  line-height: 1.7;
}
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
textarea::placeholder { color: var(--muted); }

.hint {
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.6;
  margin: 10px 0 14px;
}

/* ---------- Buttons ---------- */
.draw-btn {
  appearance: none;
  width: 100%;
  border: none;
  background: var(--accent);
  color: white;
  font-family: "Noto Sans JP", sans-serif;
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.04em;
  padding: 14px 20px;
  border-radius: var(--radius);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: background 140ms ease, transform 140ms ease;
}
.draw-btn:hover:not(:disabled) {
  background: var(--accent-deep);
  transform: translateY(-1px);
}
.draw-btn:active:not(:disabled) { transform: translateY(0); }
.draw-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

.save-btn {
  appearance: none;
  width: 100%;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--sub);
  font-family: "Noto Sans JP", sans-serif;
  font-weight: 500;
  font-size: 13px;
  padding: 9px 16px;
  border-radius: 999px;
  cursor: pointer;
  margin-top: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: background 140ms ease;
}
.save-btn:hover { background: var(--bg); }

.sub-btn {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--sub);
  font-family: "Noto Sans JP", sans-serif;
  font-weight: 500;
  font-size: 13px;
  padding: 8px 16px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 140ms ease;
}
.sub-btn:hover { background: var(--bg); }

.error-msg {
  margin-top: 10px;
  padding: 10px 14px;
  color: var(--danger);
  font-size: 13px;
  font-weight: 500;
  background: var(--danger-soft);
  border-radius: var(--radius);
  display: none;
}
.error-msg.visible { display: block; }

/* くじ引きと同じ見た目のチェック */
.check-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 13.5px;
  color: var(--sub);
  cursor: pointer;
  line-height: 1.5;
}
.check-row input {
  width: 16px;
  height: 16px;
  margin: 2px 0 0;
  flex-shrink: 0;
  accent-color: var(--accent);
}
.check-hint {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}

/* ---------- ルーレット ---------- */
.stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}
.wheel-wrap {
  position: relative;
  width: min(100%, 420px);
  aspect-ratio: 1 / 1;
  /* 矢印が上にはみ出す分 */
  margin-top: 14px;
}
.wheel-wrap canvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: pointer;
  border-radius: 50%;
  filter: drop-shadow(0 6px 18px rgba(17, 24, 39, .14));
}
.wheel-pointer {
  position: absolute;
  top: -16px;
  left: 50%;
  width: 30px;
  height: 34px;
  transform: translateX(-50%);
  z-index: 1;
  fill: var(--ink);
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, .25));
  pointer-events: none;
}
.wheel-empty {
  position: absolute;
  inset: 22% 18%;
  margin: 0;
  display: grid;
  place-items: center;
  text-align: center;
  font-size: 13.5px;
  font-weight: 500;
  line-height: 1.7;
  color: var(--sub);
  pointer-events: none;
}
.wheel-empty[hidden] { display: none; }

.result {
  margin: 0;
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 12px;
  min-height: 44px;
  max-width: 100%;
}
.result-label {
  flex: none;
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
}
.result-value {
  font-size: 26px;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.3;
  overflow-wrap: anywhere;
  text-align: center;
}
.result.is-done .result-value {
  color: var(--accent-deep);
  animation: resultPop 360ms ease;
}
@keyframes resultPop {
  0%   { transform: scale(0.85); opacity: .4; }
  65%  { transform: scale(1.08); opacity: 1; }
  100% { transform: scale(1); }
}
.spin-btn { max-width: 420px; }

.options {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 18px;
  margin: 18px 0 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
.full-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
}

/* 全画面。iPhone では要素の全画面表示がないため、CSS でも画面いっぱいに広げる */
.stage-close { display: none; }
.stage.is-full {
  position: fixed;
  inset: 0;
  z-index: 1000;
  justify-content: center;
  padding: 24px 16px calc(24px + env(safe-area-inset-bottom));
  background: var(--surface);
  overflow-y: auto;
}
.stage.is-full .wheel-wrap { width: min(92vw, calc(100vh - 230px), 760px); }
.stage.is-full .result-value { font-size: clamp(26px, 5vw, 44px); }
.stage.is-full .spin-btn { max-width: 520px; }
.stage.is-full .stage-close {
  display: grid;
  place-items: center;
  position: absolute;
  top: 12px;
  right: 12px;
  width: 44px;
  height: 44px;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--surface);
  color: var(--sub);
  cursor: pointer;
}
.stage.is-full .stage-close[hidden] { display: none; }
body.roulette-full { overflow: hidden; }

/* ---------- 当たりやすさ ---------- */
.weights { margin-top: 12px; }
.weights summary {
  cursor: pointer;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--accent-deep);
}
.weights .hint { margin: 8px 0 10px; }
.weight-list {
  list-style: none;
  margin: 0 0 12px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.weight-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto 56px;
  align-items: center;
  gap: 10px;
  padding: 6px 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
}
.weight-row.is-out { opacity: .5; }
.weight-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.weight-step { display: inline-flex; align-items: center; gap: 4px; }
.weight-step button {
  appearance: none;
  width: 30px;
  height: 30px;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--surface);
  color: var(--sub);
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
}
.weight-step button:disabled { opacity: .35; cursor: default; }
.weight-value {
  min-width: 22px;
  text-align: center;
  font-family: "JetBrains Mono", monospace;
  font-weight: 600;
}
.weight-pct {
  text-align: right;
  font-family: "JetBrains Mono", monospace;
  font-size: 12.5px;
  color: var(--muted);
}

/* ---------- これまでの結果 ---------- */
.history {
  margin-top: 16px;
  padding: 16px 18px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.history-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}
.history-head .block-label { margin-bottom: 0; }
.history-head .sub-btn { padding: 5px 12px; font-size: 12.5px; }
.history-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 240px;
  overflow-y: auto;
}
.history-list li { display: flex; gap: 12px; font-size: 14px; }
.history-no {
  flex: none;
  min-width: 48px;
  font-family: "JetBrains Mono", monospace;
  font-size: 12.5px;
  color: var(--muted);
}
.history-label { overflow-wrap: anywhere; }
.history-list li:first-child .history-label { font-weight: 700; color: var(--accent-deep); }

.tool-foot {
  display: flex;
  justify-content: flex-end;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}
.reset-btn {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--danger);
  font-family: "Noto Sans JP", sans-serif;
  font-weight: 500;
  font-size: 12.5px;
  padding: 7px 14px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 140ms ease, border-color 140ms ease;
}
.reset-btn .nowrap { white-space: nowrap; }
.reset-btn:hover {
  background: var(--danger-soft);
  border-color: var(--danger-soft);
}

@media (max-width: 900px) {
  .tool { padding: 20px 16px; }
}
@media (max-width: 560px) {
  .full-btn { margin-left: 0; }
  .result-value { font-size: 22px; }
}
@media (prefers-reduced-motion: reduce) {
  .result.is-done .result-value { animation: none; }
}
