/* 歯車あそび＝板（canvas）の上に HUD を重ねる。色は fuji21.com の根の頁と同じ系統（クリームの地に琥珀） */
@font-face {
  font-family: "Rounded";
  src: url("fonts/MPLUSRounded1c-Bold.subset.woff2") format("woff2");
  font-weight: 700;
  font-display: swap;
}
@font-face {
  font-family: "Rounded";
  src: url("fonts/MPLUSRounded1c-Regular.subset.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}

:root {
  --bg: #fffbf5;
  --ink: #44403c;
  --ink-light: #78716c;
  --accent: #b45309;
  --accent-light: #fef3c7;
  --card: rgba(255, 255, 255, 0.86);
  --line: rgba(68, 64, 60, 0.14);
  --font: "Rounded", "M PLUS Rounded 1c", "Hiragino Maru Gothic ProN", "ヒラギノ丸ゴ ProN W4", "BIZ UDPGothic", "Meiryo", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font);
  color: var(--ink);
  background-color: var(--bg);
  /* 板の目＝薄い点の格子 */
  background-image: radial-gradient(rgba(180, 83, 9, 0.16) 1.2px, transparent 1.3px);
  background-size: 26px 26px;
  background-position: 13px 13px;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

#board {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: crosshair;
}

.hud {
  position: fixed;
  z-index: 2;
  pointer-events: none;
}
.hud > * { pointer-events: auto; }

.top {
  top: max(10px, env(safe-area-inset-top));
  left: max(12px, env(safe-area-inset-left));
  right: max(12px, env(safe-area-inset-right));
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
}
.titlebar { display: flex; align-items: center; gap: 8px; }
.top h1 {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--card);
  border: 1px solid var(--line);
  box-shadow: 0 2px 10px rgba(68, 64, 60, 0.08);
}
.top p {
  margin: 0;
  font-size: 13px;
  line-height: 1.5;
  color: var(--ink-light);
  padding: 5px 11px;
  border-radius: 12px;
  background: var(--card);
  border: 1px solid var(--line);
  max-width: min(92vw, 420px);
  transition: color 0.3s;
}
.top p.jam { color: #b91c1c; font-weight: 700; }

.info {
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(max(10px, env(safe-area-inset-bottom)) + var(--bar-h, 96px) + 10px);
  margin: 0;
  font-size: 13px;
  padding: 6px 14px;
  border-radius: 999px;
  background: var(--card);
  border: 1px solid var(--line);
  white-space: nowrap;
  color: var(--ink);
}

.bottom {
  left: 0;
  right: 0;
  bottom: max(10px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 0 10px;
}
.row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
}

.btn {
  font: inherit;
  font-weight: 700;
  font-size: 14px;
  color: var(--ink);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 999px;
  min-height: 44px;
  padding: 0 16px;
  box-shadow: 0 2px 10px rgba(68, 64, 60, 0.08);
  cursor: pointer;
  touch-action: manipulation;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  transition: transform 0.08s, background 0.2s, color 0.2s, opacity 0.2s;
}
.btn:active { transform: scale(0.95); }
.btn:disabled { opacity: 0.4; cursor: default; transform: none; }
.btn.round { width: 44px; padding: 0; justify-content: center; font-size: 18px; }
.btn.wide { padding: 0 18px; }
.btn.on { background: var(--accent); color: #fff; border-color: transparent; }
.btn.primary { background: var(--accent); color: #fff; border-color: transparent; font-size: 16px; padding: 0 28px; }
.btn .ic { width: 14px; height: 14px; fill: currentColor; flex: none; }
.btn .ic.arrow { width: 20px; height: 20px; transition: transform 0.25s; }
.btn.rev .ic.arrow { transform: scaleX(-1); }
.btn .pause { display: none; }
.btn.on .pause { display: block; }
.btn.on .play { display: none; }

.stepper {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px;
  border-radius: 999px;
  background: var(--card);
  border: 1px solid var(--line);
  box-shadow: 0 2px 10px rgba(68, 64, 60, 0.08);
}
.stepper .btn { box-shadow: none; border-color: transparent; background: var(--accent-light); min-height: 38px; width: 38px; }
.teeth {
  min-width: 46px;
  text-align: center;
  line-height: 1;
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 3px;
}
.teeth b { font-size: 20px; font-variant-numeric: tabular-nums; }
.teeth small { font-size: 11px; color: var(--ink-light); }
.stepper.dim { opacity: 0.45; }

.overlay {
  position: fixed;
  inset: 0;
  z-index: 5;
  background: rgba(68, 64, 60, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.overlay[hidden] { display: none; }
.card {
  background: #fff;
  border-radius: 20px;
  padding: 22px 22px 20px;
  max-width: 400px;
  width: 100%;
  box-shadow: 0 10px 40px rgba(68, 64, 60, 0.25);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.card h2 { margin: 0; font-size: 20px; }
.card ol { margin: 0; padding-left: 1.4em; font-size: 15px; line-height: 1.7; display: flex; flex-direction: column; gap: 6px; }
.card .note { margin: 2px 0 6px; font-size: 13px; color: var(--ink-light); line-height: 1.6; }
.card .btn { align-self: center; }

@media (max-width: 420px) {
  .btn { font-size: 13px; padding: 0 13px; }
  .top h1 { font-size: 16px; }
}
@media (max-width: 350px) {
  .btn { font-size: 12px; padding: 0 10px; min-height: 40px; }
  .btn.round { width: 40px; }
  .stepper .btn { min-height: 34px; width: 34px; }
  .teeth { min-width: 40px; }
  .teeth b { font-size: 18px; }
  .row { gap: 6px; }
}
@media (min-width: 760px) {
  .bottom { flex-direction: row; justify-content: center; gap: 18px; }
}
