/* つたわるかな — styles
   方針: スマホ縦持ち最優先 / 余白と動きを上質に / 紙のトーン / 60fps を妨げない軽い演出 */

:root {
  --paper: #f7f4ec;
  --paper-edge: #efe9dc;
  --ink: #23201c;
  --muted: #8c857a;
  --line: #e4ddcd;
  --accent: #5b6cf0;
  --accent-2: #8b5cf6;
  --gold: #f5b942;
  --danger: #e2574c;
  --shadow: 0 18px 50px rgba(40, 34, 24, 0.14);
  --radius: 24px;
  --font:
    -apple-system, BlinkMacSystemFont, "Hiragino Kaku Gothic ProN", "Hiragino Sans",
    "Noto Sans JP", "Yu Gothic", Meiryo, sans-serif;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* {
  box-sizing: border-box;
}

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

body {
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(120% 80% at 50% -10%, #fffdf8 0%, var(--paper) 55%, var(--paper-edge) 100%)
      fixed;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

#app {
  height: 100dvh;
}

/* ---------- 画面共通 ---------- */
.screen {
  height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: calc(16px + var(--safe-t)) 18px calc(16px + var(--safe-b));
  animation: screen-in 0.42s cubic-bezier(0.22, 1, 0.36, 1) both;
}
.screen.center {
  align-items: center;
  justify-content: center;
}
.title,
.result {
  align-items: center;
  justify-content: center;
  gap: 22px;
  text-align: center;
}
.muted {
  color: var(--muted);
  line-height: 1.7;
}

@keyframes screen-in {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
}

/* ---------- ボタン ---------- */
.btn-primary {
  appearance: none;
  border: 0;
  cursor: pointer;
  font-family: inherit;
  font-weight: 700;
  font-size: 20px;
  letter-spacing: 0.04em;
  color: #fff;
  padding: 18px 56px;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow:
    0 12px 30px rgba(91, 108, 240, 0.42),
    inset 0 1px 0 rgba(255, 255, 255, 0.25);
  transition:
    transform 0.12s ease,
    box-shadow 0.2s ease,
    filter 0.2s ease;
}
.btn-primary:active {
  transform: translateY(2px) scale(0.985);
  box-shadow: 0 6px 16px rgba(91, 108, 240, 0.36);
}

.link {
  appearance: none;
  border: 0;
  background: none;
  cursor: pointer;
  font-family: inherit;
  font-size: 14px;
  color: var(--muted);
  padding: 8px 10px;
  border-radius: 10px;
}
.link:active {
  background: rgba(0, 0, 0, 0.05);
}

.credit {
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.03em;
  opacity: 0.85;
}

/* ---------- AI オーブ ---------- */
.ai-orb {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 32% 30%, #fff 0%, rgba(255, 255, 255, 0) 38%),
    conic-gradient(from 210deg, var(--accent), var(--accent-2), var(--accent));
  box-shadow:
    0 4px 14px rgba(91, 108, 240, 0.45),
    inset 0 0 8px rgba(255, 255, 255, 0.35);
  position: relative;
  flex: none;
}
.ai-orb.big {
  width: 92px;
  height: 92px;
  animation: float 4.5s ease-in-out infinite;
}
.ai-orb.pulse {
  animation: pulse 1.2s ease-in-out infinite;
}
@keyframes float {
  0%,
  100% {
    transform: translateY(-4px);
  }
  50% {
    transform: translateY(6px);
  }
}
@keyframes pulse {
  0%,
  100% {
    transform: scale(0.92);
    opacity: 0.7;
  }
  50% {
    transform: scale(1.06);
    opacity: 1;
  }
}

/* ---------- タイトル ---------- */
.title-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}
.title-name {
  margin: 4px 0 0;
  font-size: clamp(34px, 11vw, 52px);
  font-weight: 800;
  letter-spacing: 0.08em;
}
.title-sub {
  margin: 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.8;
}
.title-actions {
  display: flex;
  gap: 8px;
}
.howto {
  max-width: 340px;
  font-size: 13.5px;
  line-height: 1.9;
  color: #6f685d;
  background: rgba(255, 255, 255, 0.6);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px 16px;
}

/* ---------- プレイ画面 ---------- */
.play {
  gap: 12px;
  padding-top: calc(12px + var(--safe-t));
}
.play-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.odai {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
  min-width: 0;
  flex: 1;
}
.odai-label {
  font-size: 11px;
  letter-spacing: 0.18em;
  color: var(--muted);
}
.odai-word {
  font-size: clamp(19px, 5.6vw, 34px);
  font-weight: 800;
  letter-spacing: 0.02em;
  line-height: 1.15;
  word-break: break-word;
}
.play-meta {
  display: flex;
  align-items: center;
  gap: 14px;
  flex: none;
}
.timer {
  font-size: 24px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 6px 12px;
  min-width: 70px;
  text-align: center;
  transition: color 0.2s ease;
  position: relative;
}
.timer.tense {
  color: var(--danger);
  border-color: rgba(226, 87, 76, 0.4);
  animation: tense 1s steps(1) infinite;
}
@keyframes tense {
  50% {
    background: rgba(226, 87, 76, 0.1);
  }
}
.timer.gain {
  color: #2e9e5b;
}
.time-bonus {
  position: absolute;
  top: -8px;
  right: -4px;
  font-size: 15px;
  font-weight: 800;
  color: #2e9e5b;
  pointer-events: none;
  animation: time-bonus 0.85s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}
@keyframes time-bonus {
  0% {
    opacity: 0;
    transform: translateY(6px) scale(0.8);
  }
  30% {
    opacity: 1;
    transform: translateY(-3px) scale(1.1);
  }
  100% {
    opacity: 0;
    transform: translateY(-24px) scale(1);
  }
}
.score {
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1;
}
.score span {
  font-size: 9px;
  letter-spacing: 0.16em;
  color: var(--muted);
}
.score b {
  font-size: 26px;
  font-weight: 800;
}

/* 描画ステージ */
.play-stage {
  position: relative;
  flex: 1;
  display: flex;
  min-height: 0;
}
.sketch-wrap {
  flex: 1;
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--paper);
  border: 1px solid var(--line);
  box-shadow:
    var(--shadow),
    inset 0 1px 0 rgba(255, 255, 255, 0.6);
  touch-action: none;
}
.sketch-canvas {
  display: block;
  touch-action: none;
  cursor: crosshair;
}

/* AI 吹き出し(描画を隠さないよう左下に） */
.ai {
  position: absolute;
  left: 14px;
  bottom: 14px;
  display: flex;
  align-items: flex-end;
  gap: 10px;
  pointer-events: none;
}
.ai .ai-orb {
  transition: transform 0.2s ease;
}
.ai-thinking .ai-orb {
  animation: pulse 1s ease-in-out infinite;
}
.ai-correct .ai-orb {
  animation: pop-orb 0.5s cubic-bezier(0.22, 1, 0.36, 1);
  box-shadow: 0 0 0 6px rgba(245, 185, 66, 0.25);
}
@keyframes pop-orb {
  0% {
    transform: scale(1);
  }
  40% {
    transform: scale(1.35);
  }
  100% {
    transform: scale(1);
  }
}

/* thinking ドット */
.ai-dots {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  opacity: 0;
  transition: opacity 0.2s ease;
}
.ai-thinking .ai-dots {
  opacity: 1;
}
.ai-dots i {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.95);
  animation: blink 1.1s infinite ease-in-out;
}
.ai-dots i:nth-child(2) {
  animation-delay: 0.18s;
}
.ai-dots i:nth-child(3) {
  animation-delay: 0.36s;
}
@keyframes blink {
  0%,
  80%,
  100% {
    transform: scale(0.5);
    opacity: 0.4;
  }
  40% {
    transform: scale(1);
    opacity: 1;
  }
}

.ai-bubble {
  max-width: min(64vw, 280px);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 16px 16px 16px 4px;
  padding: 10px 15px;
  font-size: 17px;
  font-weight: 700;
  color: var(--ink);
  box-shadow: 0 10px 24px rgba(40, 34, 24, 0.16);
  animation: bubble-in 0.26s cubic-bezier(0.22, 1, 0.36, 1) both;
}
.ai-correct .ai-bubble {
  color: #fff;
  border-color: transparent;
  background: linear-gradient(135deg, var(--gold), #f0972f);
  box-shadow: 0 12px 28px rgba(240, 151, 47, 0.45);
}
@keyframes bubble-in {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.92);
  }
}

/* 正解フラッシュ */
.flash {
  position: absolute;
  inset: 0;
  pointer-events: none;
  border-radius: var(--radius);
  background: radial-gradient(circle at 50% 55%, rgba(255, 255, 255, 0.85), rgba(255, 255, 255, 0) 60%);
  animation: flash 0.42s ease-out forwards;
}
@keyframes flash {
  from {
    opacity: 0.9;
  }
  to {
    opacity: 0;
  }
}

/* 正解パーティクル */
.burst {
  position: absolute;
  left: 50%;
  top: 52%;
  width: 0;
  height: 0;
  pointer-events: none;
}
.burst i {
  position: absolute;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  background: hsl(var(--h) 85% 62%);
  animation: burst 0.9s cubic-bezier(0.18, 0.7, 0.3, 1) forwards;
}
@keyframes burst {
  0% {
    transform: translate(0, 0) scale(1) rotate(0deg);
    opacity: 1;
  }
  100% {
    transform: translate(var(--x), var(--y)) scale(0.3) rotate(220deg);
    opacity: 0;
  }
}

/* ツール */
.play-tools {
  display: flex;
  gap: 10px;
}
.tool {
  appearance: none;
  cursor: pointer;
  font-family: inherit;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 11px 0;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.78);
  color: var(--ink);
  transition:
    transform 0.1s ease,
    background 0.15s ease;
}
.tool .ti {
  font-size: 20px;
  line-height: 1;
}
.tool .tl {
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.08em;
}
.tool:active {
  transform: translateY(2px) scale(0.97);
  background: rgba(0, 0, 0, 0.04);
}
.tool.pass {
  background: linear-gradient(135deg, rgba(91, 108, 240, 0.12), rgba(139, 92, 246, 0.12));
  border-color: rgba(91, 108, 240, 0.3);
}
.tool.pass .ti,
.tool.pass .tl {
  color: var(--accent);
}

/* ---------- リザルト ---------- */
.result-label {
  margin: 0;
  font-size: 13px;
  letter-spacing: 0.2em;
  color: var(--muted);
}
.result-score {
  font-size: 92px;
  font-weight: 800;
  line-height: 1;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.result-badge {
  font-size: 18px;
  font-weight: 800;
  color: #c98208;
  background: rgba(245, 185, 66, 0.16);
  padding: 8px 18px;
  border-radius: 999px;
  animation: pop-badge 0.5s cubic-bezier(0.22, 1, 0.36, 1) both;
}
@keyframes pop-badge {
  from {
    transform: scale(0.6);
    opacity: 0;
  }
}
.result-best,
.result-streak {
  color: var(--muted);
  font-size: 15px;
}
.result-streak b {
  color: var(--ink);
}

/* ---------- M2: パスコード / 無効化 / 終了メッセージ ---------- */
.passcode {
  font-family: inherit;
  font-size: 18px;
  text-align: center;
  letter-spacing: 0.12em;
  width: min(78vw, 280px);
  padding: 14px 18px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
}
.passcode:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
.start-msg {
  color: var(--danger);
  font-size: 14px;
  min-height: 1em;
}
.btn-primary:disabled {
  opacity: 0.5;
  filter: grayscale(0.25);
  box-shadow: none;
  cursor: default;
}
.result-note {
  max-width: 320px;
  font-size: 14px;
  line-height: 1.75;
  color: #6f685d;
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 16px;
}

/* ---------- 本日のランキング(タイトル) ---------- */
.board {
  width: min(86vw, 340px);
  background: rgba(255, 255, 255, 0.6);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 12px 16px;
}
.board-title {
  font-size: 11px;
  letter-spacing: 0.18em;
  color: var(--muted);
  text-align: center;
  margin-bottom: 8px;
}
.board-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.board-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 15px;
}
.board-list .rank {
  width: 22px;
  text-align: center;
  flex: none;
}
.board-list .bn {
  flex: 1;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.board-list .bs {
  font-variant-numeric: tabular-nums;
  font-weight: 800;
  color: var(--accent);
}

/* ---------- 名前登録 / 1位演出 ---------- */
.name-entry {
  align-items: center;
  justify-content: center;
  gap: 18px;
  text-align: center;
}
.ne-badge,
.result-top {
  font-size: 22px;
  font-weight: 800;
  color: #c98208;
  background: rgba(245, 185, 66, 0.16);
  padding: 9px 22px;
  border-radius: 999px;
  animation: pop-badge 0.5s cubic-bezier(0.22, 1, 0.36, 1) both;
}
.ne-sub {
  color: var(--muted);
  line-height: 1.8;
  margin: 0;
}

/* ---------- TSUKI(ナビキャラ) ---------- */
.tsuki {
  display: flex;
  gap: 10px;
}
.tsuki-sm {
  flex-direction: row;
  align-items: flex-end;
}
.tsuki-md,
.tsuki-lg {
  flex-direction: column;
  align-items: center;
  gap: 12px;
}
.tsuki-ava {
  flex: none;
  border-radius: 50%;
  overflow: hidden;
  border: 2px solid #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 8px 22px rgba(91, 108, 240, 0.35);
}
.tsuki-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center top;
  display: block;
}
.tsuki-orb {
  width: 100%;
  height: 100%;
  background:
    radial-gradient(circle at 32% 30%, #fff 0%, rgba(255, 255, 255, 0) 38%),
    conic-gradient(from 210deg, var(--accent), var(--accent-2), var(--accent));
}
.tsuki-sm .tsuki-ava {
  width: 76px;
  height: 76px;
}
.tsuki-md .tsuki-ava {
  width: 104px;
  height: 104px;
}
.tsuki-lg .tsuki-ava {
  width: 140px;
  height: 140px;
  animation: float 4.5s ease-in-out infinite;
}
.tsuki-bubble {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 16px 16px 16px 4px;
  padding: 9px 14px;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.5;
  color: var(--ink);
  box-shadow: 0 8px 20px rgba(40, 34, 24, 0.14);
  max-width: min(70vw, 320px);
  animation: bubble-in 0.26s cubic-bezier(0.22, 1, 0.36, 1) both;
}
.tsuki-md .tsuki-bubble,
.tsuki-lg .tsuki-bubble {
  border-radius: 16px;
  text-align: center;
}
.tsuki-correct .tsuki-bubble {
  background: linear-gradient(135deg, var(--gold), #f0972f);
  color: #fff;
  border-color: transparent;
}
.tsuki-correct .tsuki-ava {
  box-shadow:
    0 0 0 5px rgba(245, 185, 66, 0.3),
    0 8px 22px rgba(240, 151, 47, 0.4);
}
/* プレイ画面:キャンバス左下に小さく */
.play-tsuki {
  position: absolute;
  left: 12px;
  bottom: 12px;
  pointer-events: none;
  max-width: calc(100% - 24px);
}
/* 縦に長くなっても見切れないように */
.title,
.result,
.name-entry {
  overflow-y: auto;
}

/* ---------- 課金チケット ---------- */
.buy {
  align-items: center;
  justify-content: center;
  gap: 16px;
  text-align: center;
  overflow-y: auto;
}
.buy .ne-sub small {
  color: var(--muted);
  font-size: 12px;
}
.packs {
  display: flex;
  gap: 14px;
}
.pack {
  position: relative;
  appearance: none;
  cursor: pointer;
  font-family: inherit;
  min-width: 120px;
  padding: 18px 22px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  box-shadow: 0 8px 20px rgba(40, 34, 24, 0.08);
  transition:
    transform 0.1s ease,
    box-shadow 0.2s ease;
}
.pack b {
  font-size: 26px;
  font-weight: 800;
}
.pack span {
  font-size: 15px;
  font-weight: 700;
  color: var(--muted);
}
.pack:active {
  transform: translateY(2px) scale(0.98);
}
.pack.reco {
  border-color: var(--accent);
  box-shadow: 0 10px 26px rgba(91, 108, 240, 0.28);
}
.pack em {
  position: absolute;
  top: -10px;
  right: -8px;
  font-style: normal;
  font-size: 11px;
  font-weight: 800;
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  padding: 3px 9px;
  border-radius: 999px;
}
.credits-note {
  color: var(--muted);
  font-size: 14px;
}
.credits-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 13px;
  font-weight: 700;
  color: var(--accent);
  background: rgba(91, 108, 240, 0.1);
  border: 1px solid rgba(91, 108, 240, 0.25);
  padding: 5px 12px;
  border-radius: 999px;
}
.notice {
  color: #2e7d46;
  font-weight: 700;
  font-size: 14px;
  background: rgba(46, 158, 91, 0.14);
  border: 1px solid rgba(46, 158, 91, 0.3);
  padding: 8px 16px;
  border-radius: 12px;
}

/* ---------- 招待(無料で増やす) ---------- */
.invite-card {
  width: 100%;
  max-width: 360px;
  margin: 8px auto 4px;
  padding: 14px 16px;
  border-radius: 16px;
  background: rgba(46, 158, 91, 0.1);
  border: 1px solid rgba(46, 158, 91, 0.32);
  text-align: center;
}
.invite-h {
  font-weight: 800;
  font-size: 15px;
  color: #1f7a44;
}
.invite-p {
  margin: 6px 0 10px;
  font-size: 13px;
  color: var(--ink);
  line-height: 1.6;
}
.invite-p small {
  color: var(--muted);
}
.btn-line {
  width: 100%;
  border: 0;
  border-radius: 999px;
  padding: 12px 18px;
  font-weight: 800;
  font-size: 15px;
  color: #fff;
  background: #06c755; /* LINE グリーン */
  cursor: pointer;
}
.btn-line:disabled {
  opacity: 0.6;
}
.invite-have {
  margin-top: 8px;
  font-size: 12.5px;
  font-weight: 700;
  color: #1f7a44;
}
.buy-or {
  margin: 16px 0 8px;
  font-size: 12.5px;
  color: var(--muted);
}
.ne-foot {
  margin: 8px 0 0;
}
.credits-chip.bonus {
  background: rgba(46, 158, 91, 0.14);
  color: #1f7a44;
}

/* ---------- TSUKI 公式LINE CTA ---------- */
.line-cta {
  display: inline-block;
  margin-top: 12px;
  padding: 9px 18px;
  border-radius: 999px;
  background: rgba(6, 199, 85, 0.12);
  border: 1px solid rgba(6, 199, 85, 0.42);
  color: #06a34a;
  font-weight: 800;
  font-size: 13.5px;
  text-decoration: none;
}

/* ---------- 無料は数量限定の空気(タイトル) ---------- */
.scarce {
  margin: 2px 0 0;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.02em;
}

/* ---------- リザルトの残数/チケット案内 ---------- */
.result-status {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  justify-content: center;
  font-size: 14px;
  color: var(--muted);
}
.result-status b {
  color: var(--ink);
}
.shoplink {
  color: var(--accent);
  font-weight: 700;
}

/* ---------- 動きを減らす設定を尊重 ---------- */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
