:root {
  --bg: #fff;
  --panel: #f5f6f8;
  --line: #e6e8eb;
  --text: #21262e;
  --muted: #6b7380;
  --brand: linear-gradient(90deg, #fd267a, #ff7854);
  --yes: #1fd290;
  --no: #ff4458;
  --skip: #2db0f7;
  --undo: #f7b500;
  --left: #3b6cf6;
  --right: #f0503c;
  --radius: 20px;
  color-scheme: light;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", Meiryo, sans-serif;
  -webkit-font-smoothing: antialiased;
}

body { overflow-x: hidden; }

[hidden] { display: none !important; }

.app {
  max-width: 520px;
  min-height: 100dvh;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  position: relative;
}

/* ---------- ヘッダー ---------- */
.bar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  padding-top: max(12px, env(safe-area-inset-top));
  background: rgba(255, 255, 255, .9);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.home {
  color: var(--muted);
  text-decoration: none;
  font-weight: 700;
  font-size: 14px;
  white-space: nowrap;
}
.home:hover { color: var(--text); }
.bar__logo {
  font-weight: 900;
  font-size: 17px;
  background: var(--brand);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  white-space: nowrap;
}
.bar__count {
  justify-self: end;
  font-size: 14px;
  font-weight: 700;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.progress { height: 3px; background: var(--line); }
.app:not(.is-playing) .progress { visibility: hidden; }
.progress i {
  display: block;
  height: 100%;
  background: var(--brand);
  transform-origin: left;
  transform: scaleX(0);
  transition: transform .3s;
}

/* ---------- 共通 ---------- */
.screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 24px 16px 32px;
}
.kicker { margin: 0; color: var(--muted); font-size: 14px; text-align: center; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 52px;
  padding: 0 32px;
  border-radius: 999px;
  border: 2px solid transparent;
  font: inherit;
  font-weight: 800;
  font-size: 16px;
  cursor: pointer;
  text-decoration: none;
  transition: filter .15s, transform .1s, background .15s;
}
.btn:active { transform: scale(.97); }
.btn--primary { background: var(--brand); color: #fff; box-shadow: 0 6px 18px rgba(253, 38, 122, .3); }
.btn--primary:hover { filter: brightness(1.05); }
.btn--ghost { background: #fff; color: var(--text); border-color: var(--line); }
.btn--ghost:hover { background: var(--panel); }

/* ---------- タイトル ---------- */
.screen--title { align-items: center; justify-content: center; gap: 20px; text-align: center; }

.logo {
  margin: 0;
  font-size: clamp(26px, 7.5vw, 36px);
  line-height: 1.25;
  font-weight: 900;
}
.logo span {
  display: inline-block;
  font-size: clamp(44px, 13vw, 64px);
  line-height: 1.1;
  background: var(--brand);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.howto {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  width: 100%;
  max-width: 400px;
}
.howto__item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 14px 10px;
  border-radius: 16px;
  border: 2px solid currentColor;
}
.howto__dir { font-size: 12px; color: var(--muted); }
.howto__item b { font-size: 24px; }
.howto__item small { font-size: 12px; color: var(--muted); }
.howto__item--no { color: var(--no); }
.howto__item--yes { color: var(--yes); }

.rules {
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 14px;
  line-height: 1.8;
  color: #464d57;
}
.rules b { color: var(--text); }
kbd {
  display: inline-block;
  min-width: 1.8em;
  padding: 0 .4em;
  border: 1px solid #c6cbd2;
  border-bottom-width: 2px;
  border-radius: 6px;
  font-family: inherit;
  font-size: 12px;
  line-height: 1.6;
  background: #fff;
}
.caution {
  margin: -6px 0 0;
  font-size: 12px;
  color: var(--muted);
}

.last { margin: -6px 0 0; color: var(--muted); font-size: 14px; }
.last b { color: var(--text); }
.note { margin: 0; color: var(--muted); font-size: 12px; }

/* ---------- プレイ ---------- */
.screen--play { padding: 14px 14px 0; gap: 14px; }

.deck {
  position: relative;
  flex: 1;
  min-height: 380px;
}

.card {
  position: absolute;
  inset: 0;
  border-radius: var(--radius);
  color: #fff;
  overflow: hidden;
  box-shadow: 0 10px 30px rgba(20, 30, 50, .22);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  cursor: grab;
  will-change: transform;
  transition: transform .25s cubic-bezier(.2, .8, .3, 1.2), opacity .25s;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  z-index: 2;
}
.card:active { cursor: grabbing; }
.card::after {
  content: "";
  position: absolute;
  inset: 40% 0 0;
  background: linear-gradient(transparent, rgba(0, 0, 0, .55));
  pointer-events: none;
}
.card.is-back {
  transform: scale(.94) translateY(12px);
  filter: brightness(.85);
  pointer-events: none;
  z-index: 1;
}
.card.is-gone {
  pointer-events: none;
  z-index: 3;
  transition: transform .35s ease-in, opacity .35s ease-in;
}
.card.is-return { animation: back .35s ease-out; }
@keyframes back {
  0% { transform: translateX(-60%) rotate(-12deg); opacity: 0; }
  100% { transform: none; opacity: 1; }
}

.card__emoji {
  position: absolute;
  top: 18%;
  left: 50%;
  transform: translateX(-50%);
  font-size: clamp(96px, 30vw, 140px);
  line-height: 1;
  opacity: .9;
  filter: drop-shadow(0 8px 20px rgba(0, 0, 0, .25));
  pointer-events: none;
}
.card__body {
  position: relative;
  z-index: 1;
  padding: 20px 20px 24px;
}
.card__tag {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .22);
  font-size: 13px;
  font-weight: 700;
  backdrop-filter: blur(4px);
}
.card__q {
  margin: 10px 0 0;
  font-size: clamp(21px, 6vw, 26px);
  font-weight: 800;
  line-height: 1.45;
  text-shadow: 0 2px 8px rgba(0, 0, 0, .3);
  word-break: auto-phrase;
}
.card__ask {
  margin: 10px 0 0;
  font-size: 14px;
  opacity: .85;
}

.stamp {
  position: absolute;
  top: 28px;
  z-index: 4;
  padding: 4px 14px;
  border: 5px solid currentColor;
  border-radius: 12px;
  font-size: 34px;
  font-weight: 900;
  letter-spacing: .06em;
  opacity: 0;
  pointer-events: none;
  background: rgba(255, 255, 255, .9);
}
.stamp--yes { left: 22px; color: var(--yes); transform: rotate(-14deg); }
.stamp--no { right: 22px; color: var(--no); transform: rotate(14deg); }
.stamp--skip { top: auto; bottom: 46%; left: 50%; color: var(--skip); transform: translateX(-50%); font-size: 28px; white-space: nowrap; }

.controls {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 16px;
  padding: 4px 16px max(22px, env(safe-area-inset-bottom));
}
.ctl {
  display: grid;
  place-items: center;
  width: 66px;
  height: 66px;
  border-radius: 50%;
  border: none;
  background: #fff;
  box-shadow: 0 4px 16px rgba(20, 30, 50, .14);
  cursor: pointer;
  transition: transform .12s, box-shadow .15s;
}
.ctl svg {
  width: 30px;
  height: 30px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.ctl:hover { transform: scale(1.06); box-shadow: 0 6px 20px rgba(20, 30, 50, .2); }
.ctl:active { transform: scale(.92); }
.ctl--no { color: var(--no); }
.ctl--yes { color: var(--yes); }
.ctl--yes svg { fill: currentColor; stroke: none; }
.ctl--skip, .ctl--undo { width: 50px; height: 50px; }
.ctl--skip svg, .ctl--undo svg { width: 24px; height: 24px; }
.ctl--skip { color: var(--skip); }
.ctl--skip svg { fill: currentColor; stroke: none; }
.ctl--undo { color: var(--undo); }
.ctl:disabled { opacity: .35; cursor: default; transform: none; box-shadow: 0 2px 8px rgba(20, 30, 50, .1); }

/* ---------- 結果 ---------- */
.screen--result { align-items: center; text-align: center; gap: 10px; }

.type {
  margin: 4px 0 0;
  font-size: clamp(26px, 8vw, 36px);
  font-weight: 900;
  line-height: 1.3;
  word-break: auto-phrase;
}
.type-desc { margin: 0; color: #464d57; font-size: 14px; line-height: 1.7; max-width: 420px; }

.meter { width: 100%; max-width: 420px; margin: 18px 0 0; }
.meter__track {
  position: relative;
  height: 14px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--left), #c9ccd3 50%, var(--right));
}
.meter__pin {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #fff;
  border: 5px solid #8a909a;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .25);
  transform: translate(-50%, -50%);
  transition: left .8s cubic-bezier(.2, .8, .3, 1.2);
}
.meter__pin[data-side="l"] { border-color: var(--left); }
.meter__pin[data-side="r"] { border-color: var(--right); }
.meter__labels {
  display: flex;
  justify-content: space-between;
  margin-top: 8px;
  font-size: 13px;
  font-weight: 800;
}
.meter__labels span:first-child { color: var(--left); }
.meter__labels span:nth-child(2) { color: var(--muted); }
.meter__labels span:last-child { color: var(--right); }

.score { margin: 4px 0 0; font-size: 16px; font-weight: 700; }
.score b { font-size: 28px; font-variant-numeric: tabular-nums; }
.score small { display: block; margin-top: 2px; font-size: 12px; font-weight: 400; color: var(--muted); }

.sec-title {
  align-self: stretch;
  margin: 22px 0 4px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
  font-size: 17px;
  text-align: left;
}

.cats {
  align-self: stretch;
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.cats li {
  display: grid;
  grid-template-columns: 9.5em 1fr 4em;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  text-align: left;
}
.cats__name { font-weight: 700; white-space: nowrap; }
.cats__bar {
  position: relative;
  height: 10px;
  border-radius: 999px;
  background: var(--panel);
}
.cats__bar::before {
  content: "";
  position: absolute;
  left: 50%;
  top: -3px;
  bottom: -3px;
  width: 2px;
  background: #c9ccd3;
}
.cats__bar i { position: absolute; top: 0; bottom: 0; border-radius: 999px; }
.cats__bar i.is-l { background: var(--left); }
.cats__bar i.is-r { background: var(--right); }
.cats__word { color: var(--muted); font-weight: 700; text-align: right; }

.result-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin: 20px 0 0;
}

.review {
  align-self: stretch;
  margin: 0;
  padding: 0;
  list-style: none;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.review li {
  padding: 14px;
  border-radius: 14px;
  background: var(--panel);
}
.review__q { margin: 0 0 8px; font-size: 15px; font-weight: 700; line-height: 1.55; }
.review__ans, .review__lean {
  display: inline-block;
  margin-right: 6px;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
}
.review__ans.is-yes { background: rgba(31, 210, 144, .16); color: #0e8a5c; }
.review__ans.is-no { background: rgba(255, 68, 88, .14); color: #d1243a; }
.review__ans.is-skip { background: rgba(45, 176, 247, .14); color: #127fbf; }
.review__lean { padding-left: 0; padding-right: 0; }
.review__lean.is-l { color: var(--left); }
.review__lean.is-r { color: var(--right); }
.review__views { margin: 10px 0 0; display: grid; gap: 6px; }
.review__views div { padding-left: 10px; border-left: 3px solid; font-size: 13px; line-height: 1.6; }
.review__views div.is-r { border-color: var(--right); }
.review__views div.is-l { border-color: var(--left); }
.review__views dt { font-weight: 800; font-size: 12px; }
.review__views .is-r dt { color: var(--right); }
.review__views .is-l dt { color: var(--left); }
.review__views dd { margin: 0; color: #464d57; }

.disclaimer {
  margin: 18px 0 0;
  font-size: 12px;
  line-height: 1.7;
  color: var(--muted);
  text-align: left;
}

@media (max-width: 380px) {
  .cats li { grid-template-columns: 8.5em 1fr 3.5em; font-size: 12px; }
  .ctl { width: 60px; height: 60px; }
  .ctl--skip, .ctl--undo { width: 46px; height: 46px; }
}

@media (max-height: 680px) {
  .deck { min-height: 300px; }
  .card__emoji { top: 10%; font-size: 84px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ---------- チュートリアル（1枚目だけ） ---------- */
.card.is-hint { animation: nudge 2.6s ease-in-out .4s infinite; }
@keyframes nudge {
  0%, 100% { transform: none; }
  20% { transform: translateX(38px) rotate(3deg); }
  40% { transform: none; }
  60% { transform: translateX(-38px) rotate(-3deg); }
  80% { transform: none; }
}

.coach {
  position: absolute;
  inset: 0;
  z-index: 5;
  pointer-events: none;
  border-radius: var(--radius);
  animation: coach-in .4s ease-out;
}
@keyframes coach-in { from { opacity: 0; } }
.coach__msg {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  width: max-content;
  max-width: calc(100% - 28px);
  margin: 0;
  padding: 10px 16px;
  border-radius: 14px;
  background: rgba(20, 24, 32, .82);
  color: #fff;
  font-size: 12px;
  text-align: center;
  line-height: 1.5;
}
.coach__msg b { display: block; font-size: 15px; }
.coach__dir {
  position: absolute;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 12px;
  border-radius: 999px;
  background: #fff;
  font-size: 15px;
  font-weight: 900;
  box-shadow: 0 4px 14px rgba(0, 0, 0, .25);
}
.coach__dir b { font-size: 18px; }
.coach__dir--no { left: -6px; top: 46%; color: var(--no); }
.coach__dir--yes { right: -6px; top: 46%; color: var(--yes); }
.coach__dir--skip { left: 50%; top: 96px; transform: translateX(-50%); color: var(--skip); font-size: 13px; }
.coach__hand {
  position: absolute;
  left: 50%;
  top: 58%;
  font-size: 44px;
  transform: translateX(-50%);
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, .35));
  animation: hand 2.6s ease-in-out .4s infinite;
}
@keyframes hand {
  0%, 100% { transform: translateX(-50%); }
  20% { transform: translateX(calc(-50% + 60px)); }
  40% { transform: translateX(-50%); }
  60% { transform: translateX(calc(-50% - 60px)); }
  80% { transform: translateX(-50%); }
}
