:root {
  --bg: #f7f2e9;
  --card: #ffffff;
  --soft: #eee8dd;
  --line: #e4ddd0;
  --ink: #221e1b;
  --sub: #8a847c;
  --magenta: #bc2261;
  --accent: #d62c68;
  --navy: #252874;
  --purple: #782e8c;
  --peach: #fb7054;
  --gold: #e2a828;
  --grad: linear-gradient(135deg, #fb7054 0%, #bc2261 50%, #252874 100%);
  --radius: 20px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body {
  font-family: "Hiragino Sans", "Noto Sans JP", "Yu Gothic UI", "Meiryo", system-ui, sans-serif;
  font-size: 16px; line-height: 1.6; -webkit-font-smoothing: antialiased;
}
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
#app { max-width: 480px; margin: 0 auto; min-height: 100vh; padding-bottom: calc(84px + var(--safe-b)); }

/* 見出し */
.top {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 10px;
  padding: 12px 18px; background: rgba(247, 242, 233, .92); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.top img { width: 34px; height: 34px; border-radius: 9px; }
.top .name { font-weight: 900; font-size: 20px; letter-spacing: .02em; }
.top .clock { margin-left: auto; text-align: right; font-size: 12px; color: var(--sub); line-height: 1.35; }
.top .clock b { display: block; font-size: 15px; color: var(--ink); font-variant-numeric: tabular-nums; }

.wrap { padding: 16px 16px 0; display: grid; gap: 16px; }
.banner {
  background: var(--peach); color: #fff; font-weight: 700; border-radius: 14px; padding: 10px 14px; font-size: 14px;
}
.banner.final { background: var(--navy); }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.label { font-size: 13px; font-weight: 700; color: var(--accent); margin: 0 0 6px; }
.label.sub { color: var(--sub); }
.topic { font-size: 22px; font-weight: 900; line-height: 1.45; margin: 0; }
.topic.word { font-size: 34px; line-height: 1.25; }
.question { margin: 6px 0 0; font-weight: 700; color: var(--ink); font-size: 15px; }
.hint { text-align: center; font-size: 13px; font-weight: 700; color: var(--purple); margin: 0 0 2px; }
.muted { color: var(--sub); font-size: 13px; }
.row { display: flex; align-items: center; gap: 8px; }
.between { justify-content: space-between; }
h2 { font-size: 19px; margin: 0; font-weight: 900; }

/* 鍵のかかったお題 */
.locked { position: relative; overflow: hidden; }
.locked .lockline {
  margin-top: 12px; display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-radius: 12px;
  background: var(--soft); color: var(--sub); font-size: 14px; font-weight: 700;
}

/* 採点カード */
.progress { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin: 10px 0 14px; }
.progress span { height: 6px; border-radius: 3px; background: var(--soft); }
.progress span.on { background: var(--accent); }
.count { color: var(--accent); font-weight: 900; font-size: 18px; }
.answer {
  min-height: 170px; display: flex; align-items: center; justify-content: center; text-align: left;
  font-size: 19px; font-weight: 800; line-height: 1.65; padding: 18px 8px; word-break: break-word;
  animation: slidein .28s ease-out;
}
@keyframes slidein { from { opacity: 0; transform: translateX(40px); } to { opacity: 1; transform: none; } }
.anon { font-size: 12px; color: var(--sub); }
.votes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 12px; }
.vbtn {
  border: 2px solid currentColor; border-radius: 16px; padding: 12px 4px; background: #fff; font-weight: 800;
  display: grid; gap: 2px; transition: transform .08s;
}
.vbtn:active { transform: scale(.95); }
.vbtn small { font-size: 13px; }
.vbtn b { font-size: 22px; line-height: 1; }
.vbtn.no { color: var(--navy); }
.vbtn.yes { color: var(--purple); }
.vbtn.wow { color: var(--accent); }
.report { margin-top: 10px; font-size: 12px; color: var(--sub); text-decoration: underline; }

/* 理由を選ぶシート */
.sheet-bg { position: fixed; inset: 0; background: rgba(20, 16, 30, .45); z-index: 20; display: flex; align-items: flex-end; justify-content: center; }
.sheet {
  width: 100%; max-width: 480px; background: #fff; border-radius: 24px 24px 0 0; padding: 20px 18px calc(20px + var(--safe-b));
  animation: up .2s ease-out;
}
@keyframes up { from { transform: translateY(100%); } to { transform: none; } }
.sheet h3 { margin: 0 0 4px; font-size: 18px; }
.choice {
  width: 100%; text-align: left; padding: 14px 16px; border: 1px solid var(--line); border-radius: 14px; margin-top: 10px;
  font-weight: 700; background: #fff;
}
.choice small { display: block; font-weight: 400; color: var(--sub); font-size: 12px; }
.choice.danger { color: #b3261e; }
.cancel { width: 100%; margin-top: 12px; padding: 12px; color: var(--sub); }

/* 回答フォーム */
textarea {
  width: 100%; min-height: 120px; resize: none; border: 2px solid var(--accent); border-radius: 16px; padding: 14px;
  font-size: 18px; font-weight: 700; line-height: 1.5; background: #fff; outline: none;
}
.counter { text-align: right; font-size: 12px; color: var(--sub); margin-top: 4px; font-variant-numeric: tabular-nums; }
.counter.bad { color: #b3261e; font-weight: 700; }
.btn {
  display: block; width: 100%; border-radius: 999px; padding: 14px; font-weight: 900; font-size: 17px;
  background: var(--accent); color: #fff; text-align: center;
}
.btn:disabled { opacity: .4; cursor: default; }
.btn.ghost { background: transparent; color: var(--accent); border: 2px solid var(--accent); }
.btn.dark { background: var(--ink); }
.btn.small { display: inline-block; width: auto; padding: 8px 16px; font-size: 14px; }
.btns { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }
.posted { font-size: 20px; font-weight: 900; line-height: 1.5; padding: 6px 0; word-break: break-word; }
.ok { color: #2a7d4f; font-weight: 700; font-size: 14px; }
.note { font-size: 12px; color: var(--sub); margin-top: 8px; }

/* ランキング */
.tag { font-size: 12px; font-weight: 800; color: #fff; padding: 4px 12px; border-radius: 999px; background: var(--purple); white-space: nowrap; }
.tag.final { background: var(--accent); }
.tag.confirmed { background: var(--gold); }
.rank-list { display: grid; gap: 8px; margin-top: 12px; }
.rk {
  display: grid; grid-template-columns: 40px 1fr auto; gap: 10px; align-items: center; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: 16px; background: #fff;
}
.rk.first { border: 2px solid var(--gold); }
.rk.mine { background: #fff4f7; }
.rk .no {
  width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-weight: 900;
  background: var(--sub);
}
.rk .no.r1 { background: var(--gold); }
.rk .no.r2 { background: #a0a0aa; }
.rk .no.r3 { background: #c48050; }
.rk .txt { font-weight: 700; font-size: 15px; line-height: 1.45; word-break: break-word; }
.rk .who { font-size: 11px; color: var(--sub); }
.rk .sc { text-align: right; font-weight: 900; font-size: 18px; font-variant-numeric: tabular-nums; }
.rk .sc small { display: block; font-size: 10px; color: var(--sub); font-weight: 400; }
.rk.secret { background: var(--ink); color: #fff; border-color: var(--ink); grid-template-columns: 40px 1fr; }
.rk.secret .no { background: #44403c; }
.rk.secret .txt { font-size: 20px; letter-spacing: .3em; text-align: center; }
.me { margin-top: 12px; background: var(--soft); border-radius: 14px; padding: 10px 14px; font-weight: 700; font-size: 14px; }
.me.top3 { background: var(--grad); color: #fff; }
.share { font-size: 12px; color: var(--accent); font-weight: 700; margin-top: 4px; }

/* 下のメニュー */
.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; background: #fff; border-top: 1px solid var(--line);
  padding-bottom: var(--safe-b);
}
.nav div { max-width: 480px; margin: 0 auto; display: grid; grid-template-columns: repeat(3, 1fr); }
.nav button { padding: 10px 0 12px; font-size: 12px; font-weight: 700; color: var(--sub); display: grid; justify-items: center; gap: 2px; }
.nav button.on { color: var(--accent); }
.nav svg { width: 24px; height: 24px; }

/* はじめての画面 */
.welcome { min-height: 100vh; background: var(--grad); color: #fff; padding: 56px 24px 40px; display: grid; align-content: start; gap: 18px; }
.welcome .logo { width: 110px; height: 110px; border-radius: 26px; box-shadow: 0 12px 30px rgba(0, 0, 0, .25); justify-self: center; }
.welcome h1 { text-align: center; font-size: 46px; margin: 0; font-weight: 900; letter-spacing: .02em; }
.welcome .lead { text-align: center; margin: -8px 0 6px; opacity: .92; }
.welcome .panel { background: #fff; color: var(--ink); border-radius: 22px; padding: 20px; display: grid; gap: 12px; }
.welcome input[type=text] {
  width: 100%; padding: 14px; border: 2px solid var(--line); border-radius: 14px; font-size: 17px; outline: none;
}
.welcome input[type=text]:focus { border-color: var(--accent); }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; }
.check input { width: 20px; height: 20px; margin-top: 2px; accent-color: var(--accent); }
.link { color: var(--accent); text-decoration: underline; font-weight: 700; }
.steps { display: grid; gap: 8px; font-size: 14px; }
.steps div { display: flex; gap: 10px; align-items: center; }
.steps b { width: 26px; height: 26px; border-radius: 50%; background: rgba(255, 255, 255, .22); display: grid; place-items: center; flex: none; }
.accounts { display: flex; flex-wrap: wrap; gap: 8px; }
.accounts button { background: var(--soft); border-radius: 999px; padding: 6px 14px; font-size: 14px; font-weight: 700; }

.terms { font-size: 14px; }
.terms li { margin-bottom: 6px; }
.empty { text-align: center; color: var(--sub); padding: 24px 8px; font-size: 14px; }

.toast {
  position: fixed; left: 50%; bottom: calc(96px + var(--safe-b)); transform: translateX(-50%) translateY(20px);
  background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 999px; font-size: 14px; font-weight: 700;
  opacity: 0; pointer-events: none; transition: all .25s; z-index: 30; max-width: 90vw; text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%); }
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 25; overflow: hidden; }
.confetti i { position: absolute; top: -20px; width: 9px; height: 15px; animation: fall 1.6s ease-in forwards; }
@keyframes fall { to { transform: translateY(110vh) rotate(540deg); } }

/* Google でログイン */
.btn.google { display: flex; align-items: center; justify-content: center; gap: 10px; background: #fff; color: #1f1f1f; border: 1.5px solid #dadce0; }
