:root {
  --bg: #fff8ef;
  --ink: #1d1b2f;
  --muted: #6b6880;
  --card: #ffffff;
  --line: #ece4d8;
  --radius: 20px;
  font-family: "Hiragino Maru Gothic ProN", "Hiragino Sans", "BIZ UDPGothic", "Noto Sans JP", "Yu Gothic", sans-serif;
  color: var(--ink);
  background: var(--bg);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 10% 0%, #ffe1ea 0, transparent 40%),
    radial-gradient(circle at 90% 10%, #dcecff 0, transparent 40%),
    var(--bg);
}

/* ---------- ヘッダー ---------- */
.hero { text-align: center; padding: 40px 20px 16px; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 12px;
  padding: 6px 14px;
  border-radius: 999px;
  background: var(--ink);
  color: #fff;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #ff4d6d;
  animation: pulse 1.6s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.35; transform: scale(0.8); }
}

h1 { margin: 0; font-size: clamp(1.8rem, 6vw, 3rem); font-weight: 900; letter-spacing: 0.02em; }
.question { margin: 10px 0 0; font-size: clamp(1rem, 3.5vw, 1.3rem); color: var(--muted); font-weight: 700; }

main {
  max-width: 960px;
  margin: 0 auto;
  padding: 8px 16px 32px;
  display: grid;
  gap: 28px;
}

.section-title { margin: 0 0 6px; font-size: 1.1rem; font-weight: 800; }

.vote-status { margin: 0 0 14px; color: var(--muted); font-size: 0.95rem; }
.vote-status.is-done { color: #067a5b; font-weight: 700; }

.text-link { color: var(--accent, var(--ink)); font-weight: 700; }

/* ---------- 投票カード ---------- */
.choices {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}

@media (min-width: 760px) {
  .choices { grid-template-columns: repeat(4, 1fr); }
}

.choice-item { display: flex; flex-direction: column; gap: 6px; }

.choice {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 14px 10px 12px;
  border: 3px solid transparent;
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: 0 6px 18px rgba(29, 27, 47, 0.08);
  font: inherit;
  color: inherit;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease, opacity 0.2s;
}

.choice:hover:not(:disabled) {
  transform: translateY(-3px);
  border-color: var(--accent);
  box-shadow: 0 10px 24px rgba(29, 27, 47, 0.14);
}

.choice:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
.choice:disabled { cursor: default; opacity: 0.55; }
.choice.is-mine { opacity: 1; border-color: var(--accent); }

.choice-img {
  width: 100%;
  max-width: 160px;
  height: auto;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 16px;
}

.choice-name { font-weight: 800; font-size: 1rem; }

.choice-cta {
  margin-top: 2px;
  padding: 8px 18px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-weight: 800;
  font-size: 0.9rem;
}

.detail-link {
  text-align: center;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--accent);
  text-decoration: none;
  padding: 4px;
}
.detail-link:hover { text-decoration: underline; }

/* ---------- 定型の応援メッセージ ---------- */
.message-panel {
  background: var(--card);
  border-radius: var(--radius);
  padding: 20px;
  border: 3px solid var(--accent);
  box-shadow: 0 6px 18px rgba(29, 27, 47, 0.08);
}

.message-hint { margin: 0 0 12px; font-size: 0.9rem; color: var(--muted); }

.presets { display: flex; flex-wrap: wrap; gap: 10px; }

.preset {
  padding: 10px 18px;
  border: 2px solid var(--accent);
  border-radius: 999px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-weight: 800;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease, transform 0.15s ease;
}
.preset:hover:not(:disabled) { background: var(--accent); color: #fff; transform: translateY(-2px); }
.preset:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.preset:disabled { opacity: 0.5; cursor: default; }

.message-error { margin: 8px 0 0; color: #d62839; font-weight: 700; font-size: 0.9rem; min-height: 1em; }

.message-done-title { margin: 0 0 6px; font-weight: 800; color: #067a5b; font-size: 1.05rem; }
.message-done-text { margin: 0 0 10px; font-size: 1.1rem; font-weight: 700; }

/* ---------- 集計結果 ---------- */
.results-panel {
  background: var(--card);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: 0 6px 18px rgba(29, 27, 47, 0.08);
}

.results-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 10px;
}

.total { margin: 0; color: var(--muted); }
.total strong { color: var(--ink); font-size: 1.6rem; font-variant-numeric: tabular-nums; }

.results { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; }

.result-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 6px; font-weight: 700; }
.result-name { color: inherit; text-decoration: none; }
.result-name:hover { text-decoration: underline; }
.result-msg { margin-left: auto; font-size: 0.82rem; color: var(--muted); text-decoration: none; white-space: nowrap; }
.result-msg:hover { color: var(--accent); }
.result-num { font-variant-numeric: tabular-nums; color: var(--muted); white-space: nowrap; }

.result.is-top .result-name::before {
  content: "1 位";
  margin-right: 6px;
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 0.75rem;
  vertical-align: 2px;
}
.result.is-mine .result-name::after { content: "（あなたの 1 票）"; font-size: 0.8rem; color: var(--muted); font-weight: 600; }

.bar-track { height: 22px; border-radius: 999px; background: #f3eee6; overflow: hidden; }
.bar-fill {
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: var(--accent);
  transition: width 0.6s cubic-bezier(0.22, 1, 0.36, 1);
}

.updated {
  margin: 14px 0 0;
  font-size: 0.8rem;
  color: var(--muted);
  text-align: right;
}

/* ---------- キャラクター詳細ダイアログ ---------- */
.detail {
  width: min(560px, calc(100vw - 24px));
  max-height: calc(100vh - 48px);
  padding: 24px;
  border: 0;
  border-top: 8px solid var(--accent);
  border-radius: var(--radius);
  color: var(--ink);
  background: var(--card);
  box-shadow: 0 20px 50px rgba(29, 27, 47, 0.3);
}
.detail::backdrop { background: rgba(29, 27, 47, 0.45); }

.detail-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 50%;
  background: #f3eee6;
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
}

.detail-head { display: flex; gap: 16px; align-items: center; margin-bottom: 18px; }
.detail-img { width: 120px; height: 120px; border-radius: 18px; flex-shrink: 0; }
.detail-name { margin: 0 0 6px; font-size: 1.5rem; font-weight: 900; }
.detail-profile { margin: 0 0 8px; color: var(--muted); font-size: 0.92rem; line-height: 1.6; }
.detail-stats { margin: 0; font-weight: 800; color: var(--accent); }

.detail-sub { margin: 0 0 10px; font-size: 1rem; font-weight: 800; }
.detail-count { color: var(--muted); font-weight: 700; font-size: 0.9rem; }

.detail-messages { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.detail-message {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 14px;
  background: #faf6f0;
  border-left: 4px solid var(--accent);
}
.detail-message-text { margin: 0; font-weight: 700; }
.detail-message-time { margin: 0; font-size: 0.75rem; color: var(--muted); white-space: nowrap; }

.detail-empty { color: var(--muted); font-size: 0.9rem; }

@media (max-width: 480px) {
  .detail-head { flex-direction: column; text-align: center; }
}

.footer { text-align: center; padding: 0 16px 32px; font-size: 0.8rem; color: var(--muted); }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
