/* ---------- タイトル画面・遊び方（明るい和紙っぽい背景） ---------- */
:root {
  --paper: #f6f1e6;
  --ink: #17150f;
}
body.on-title { overflow: hidden; }
#start, #howto {
  position: fixed;
  inset: 0;
  z-index: 20;
  color: var(--ink);
  background:
    repeating-linear-gradient(0deg, transparent 0 39px, rgba(90, 63, 23, .06) 39px 40px),
    repeating-linear-gradient(90deg, transparent 0 39px, rgba(90, 63, 23, .06) 39px 40px),
    radial-gradient(ellipse at 50% 30%, #fffdf7 0%, var(--paper) 60%, #ebe2cf 100%);
}
#start {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: max(24px, env(safe-area-inset-top)) 16px calc(max(24px, env(safe-area-inset-bottom)) + var(--title-bottom-ui));
  transition: opacity .35s ease, visibility .35s;
}
#start.hidden { opacity: 0; visibility: hidden; pointer-events: none; }

.title { margin-top: 18dvh; text-align: center; line-height: 1; }
/* X アプリの中は下に投稿の帯が重なって縦が狭いので、タイトルを上に寄せ、
   難易度〜遊び方のボタンはスイッチの上に収まるところまで上げる */
html.in-x-app .title { margin-top: 3dvh; }
html.in-x-app .start-menu { margin-bottom: 100px; }
.title-dopa {
  display: block;
  font-family: "Dela Gothic One", "Hiragino Sans", sans-serif;
  font-size: clamp(52px, 18vw, 96px);
  letter-spacing: .02em;
  background: linear-gradient(90deg, #ff3b5c, #ff9f1a, #ffe11a, #36d36b, #1aa8ff, #7a5cff, #ff3bd4, #ff3b5c);
  background-size: 200% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  /* 輪郭とポップな影で明るい背景の上でも読ませる */
  filter: drop-shadow(0 0 1px var(--ink)) drop-shadow(0 0 1px var(--ink)) drop-shadow(4px 4px 0 var(--ink));
  transform: rotate(-4deg);
  animation: rainbow 3s linear infinite, dopaBounce 1.6s ease-in-out infinite;
}

@keyframes dopaBounce {
  0%, 100% { transform: rotate(-4deg) translateY(0); }
  50%      { transform: rotate(-4deg) translateY(-6px); }
}
.title-gomoku {
  display: block;
  margin-top: 18px;
  font-family: "Yuji Boku", "Hiragino Mincho ProN", "Yu Mincho", serif;
  font-size: clamp(44px, 14vw, 76px);
  letter-spacing: .12em;
  padding-left: .12em;
  color: var(--ink);
}

.start-menu {
  margin-top: auto;
  margin-bottom: 16dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}
.paper-btn {
  width: min(72vw, 280px);
  padding: 14px 0;
  font-family: "Zen Maru Gothic", "Hiragino Maru Gothic ProN", system-ui, sans-serif;
  font-size: 1.3rem;
  font-weight: 700;
  letter-spacing: .2em;
  padding-left: .2em;
  color: var(--ink);
  background: #fff;
  border: 2px solid var(--ink);
  border-radius: 16px;
  box-shadow: 0 4px 0 var(--ink);
  cursor: pointer;
  touch-action: manipulation;
  transition: transform .06s, box-shadow .06s;
}
.paper-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }

/* 難易度（スタートの上の3択） */
/* 4択なので、スタートボタンより少し広くとる */
.diff-select {
  display: flex;
  width: min(88vw, 330px);
  padding: 4px;
  gap: 3px;
  background: #fff;
  border: 2px solid var(--ink);
  border-radius: 14px;
}
.diff-select button {
  flex: 1;
  padding: 8px 0;
  white-space: nowrap;
  font-family: "Zen Maru Gothic", "Hiragino Maru Gothic ProN", system-ui, sans-serif;
  font-size: .8rem;
  font-weight: 700;
  color: var(--ink);
  background: transparent;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  touch-action: manipulation;
  transition: background .12s, color .12s;
}
.diff-select button[aria-checked="true"] { color: #fff; background: var(--ink); }

/* 効果音・振動のオン/オフ（右下に縦に並べる） */
.switches {
  position: absolute;
  right: 16px;
  bottom: calc(max(16px, env(safe-area-inset-bottom)) + var(--title-bottom-ui));
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
}
.switch {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 8px 10px 8px 12px;
  font: inherit;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--ink);
  background: #fff;
  border: 2px solid var(--ink);
  border-radius: 999px;
  cursor: pointer;
  touch-action: manipulation;
}
.switch svg { width: 20px; height: 20px; }
.switch .track {
  position: relative;
  width: 38px; height: 22px;
  border-radius: 999px;
  background: #c9c2b2;
  transition: background .15s;
}
.switch .knob {
  position: absolute;
  top: 3px; left: 3px;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 2px rgba(0,0,0,.3);
  transition: transform .15s;
}
.switch[aria-checked="true"] .track { background: #2fae6e; }
.switch[aria-checked="true"] .knob { transform: translateX(16px); }
.switch .state { min-width: 2em; text-align: left; }

/* ---------- カウントダウン ---------- */
#countdown {
  position: fixed;
  inset: 0;
  z-index: 15;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}
.cd-num {
  position: absolute;
  font-family: "Dela Gothic One", "Hiragino Sans", sans-serif;
  font-size: clamp(120px, 40vw, 220px);
  line-height: 1;
  /* タイトルと同じレインボー。輪郭は drop-shadow で付ける（text-stroke はこのフォントで内側に線が出る） */
  background: linear-gradient(90deg, #ff3b5c, #ff9f1a, #ffe11a, #36d36b, #1aa8ff, #7a5cff, #ff3bd4);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 0 2px var(--ink)) drop-shadow(0 0 2px var(--ink)) drop-shadow(6px 6px 0 var(--ink));
}

@media (prefers-reduced-motion: reduce) {
  .title-dopa { animation: none; }
}

/* タイトル画面の左下：プライバシーポリシー（控えめな文字リンク） */
.policy-link {
  position: absolute;
  left: 16px;
  bottom: calc(max(16px, env(safe-area-inset-bottom)) + var(--title-bottom-ui));
  font-size: .72rem;
  color: var(--ink);
  opacity: .6;
}
