* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --pink: #ff4fa3;
  --pink-soft: #ff9ecf;
  --bg1: #14082b;
  --bg2: #2a0f4a;
  --text: #fdf2fa;
  --ball-scale: 0.6;
}

html { scroll-behavior: smooth; }

body {
  font-family: 'Zen Maru Gothic', 'Hiragino Maru Gothic ProN', sans-serif;
  color: var(--text);
  background: radial-gradient(120% 90% at 50% 0%, var(--bg2) 0%, var(--bg1) 70%);
  min-height: 100vh;
  overflow-x: hidden;
}

/* 推しメン選択で切り替わる背景ティント */
#bg-tint {
  position: fixed; inset: 0; pointer-events: none; z-index: 0;
  opacity: 0; transition: opacity 1s ease;
  background: radial-gradient(120% 90% at 50% 0%, var(--tint1, var(--bg2)) 0%, var(--tint2, var(--bg1)) 70%);
}
#bg-tint.on { opacity: 1; }

#stars { position: fixed; inset: 0; pointer-events: none; z-index: 0; }
.star {
  position: absolute; border-radius: 50%; background: #fff;
  animation: twinkle 3s ease-in-out infinite;
}
@keyframes twinkle { 0%,100% { opacity: .15; } 50% { opacity: .9; } }

main { position: relative; z-index: 1; max-width: 560px; margin: 0 auto; padding: 28px 18px 60px; }

header { text-align: center; }
h1 { font-weight: 900; font-size: 2rem; letter-spacing: .05em; text-shadow: 0 0 24px rgba(255,79,163,.6); }
h1 .accent {
  background: linear-gradient(90deg, #ffd3ea, var(--pink));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.tagline { margin-top: 4px; font-size: .85rem; opacity: .8; }

/* ── イコラブ玉 ─────────────────────── */
#ball-section { text-align: center; margin-top: 8px; position: relative; }

#ball {
  position: relative; width: 320px; height: 300px; margin: 0 auto;
  transform: scale(var(--ball-scale));
  transition: transform 1s cubic-bezier(.34,1.56,.64,1);
}
#ball.bump { animation: bump .6s ease; }
@keyframes bump {
  0% { transform: scale(var(--ball-scale)); }
  35% { transform: scale(calc(var(--ball-scale) * 1.12)); }
  100% { transform: scale(var(--ball-scale)); }
}

#ball-heart { position: absolute; inset: 0; width: 100%; height: 100%; filter: drop-shadow(0 0 22px rgba(255,110,180,.8)); animation: beat 2.6s ease-in-out infinite; }
@keyframes beat { 0%,100% { transform: scale(1); } 12% { transform: scale(1.05); } 24% { transform: scale(1); } }

.glow { position: absolute; inset: 0; border-radius: 50%; pointer-events: none; }
.glow-outer { background: radial-gradient(circle, rgba(255,79,163,.35) 0%, transparent 65%); transform: scale(1.5); }
.glow-inner { background: radial-gradient(circle, rgba(255,214,236,.5) 0%, transparent 55%); animation: pulse 2.6s ease-in-out infinite; }
@keyframes pulse { 0%,100% { opacity: .6; } 50% { opacity: 1; } }

/* 高レベルで出る光の粒 */
.orbit { position: absolute; inset: -10px; border-radius: 50%; animation: spin 9s linear infinite; opacity: 0; transition: opacity 1s; }
.orbit::before, .orbit::after {
  content: ''; position: absolute; width: 10px; height: 10px; border-radius: 50%;
  background: #ffe4f2; box-shadow: 0 0 12px 4px rgba(255,158,207,.9);
}
.orbit::before { top: 0; left: 50%; }
.orbit::after { bottom: 8%; left: 12%; width: 7px; height: 7px; }
.orbit-2 { animation-duration: 14s; animation-direction: reverse; inset: -30px; }
@keyframes spin { to { transform: rotate(360deg); } }
#ball.lv5 .orbit { opacity: 1; }

#ball-status { margin-top: -14px; }
#level-label { font-size: 1.05rem; font-weight: 700; letter-spacing: .08em; }
#level { color: var(--pink-soft); }
#level-hearts { font-size: .9rem; letter-spacing: .12em; margin: 2px 0; min-height: 1.2em; }
#energy { font-size: 2.2rem; font-weight: 900; text-shadow: 0 0 18px rgba(255,79,163,.7); }
#energy .unit { font-size: .95rem; font-weight: 700; opacity: .75; letter-spacing: .2em; }

/* イベント玉（目標） */
#event { margin: 18px auto 0; max-width: 420px; background: rgba(255,255,255,.06); border: 1px solid rgba(255,158,207,.25); border-radius: 14px; padding: 12px 16px; }
#event-title { font-size: .85rem; font-weight: 700; margin-bottom: 8px; }
.bar { height: 12px; border-radius: 6px; background: rgba(255,255,255,.12); overflow: hidden; }
#event-fill { height: 100%; width: 0%; border-radius: 6px; background: linear-gradient(90deg, var(--pink-soft), var(--pink)); box-shadow: 0 0 10px rgba(255,79,163,.8); transition: width 1s ease; }
#event-nums { margin-top: 6px; font-size: .78rem; opacity: .85; text-align: right; letter-spacing: .05em; }

#relay { margin-top: 14px; font-size: .9rem; background: rgba(255,255,255,.07); display: inline-block; padding: 6px 16px; border-radius: 999px; border: 1px solid rgba(255,158,207,.3); }
#relay strong { color: var(--pink-soft); font-size: 1.1rem; }

/* 流れるコメント */
#bubble-layer { position: absolute; inset: 0; pointer-events: none; overflow: hidden; z-index: 2; }
.bubble {
  position: absolute; bottom: 10%; font-size: .75rem; padding: 4px 12px; border-radius: 999px;
  background: rgba(255,255,255,.12); backdrop-filter: blur(4px); white-space: nowrap;
  border: 1px solid rgba(255,255,255,.18); max-width: 80%; overflow: hidden; text-overflow: ellipsis;
  animation: rise 6s linear forwards; opacity: 0;
}
@keyframes rise {
  0% { transform: translateY(0); opacity: 0; }
  12% { opacity: .95; }
  80% { opacity: .8; }
  100% { transform: translateY(-240px); opacity: 0; }
}

/* ── メンバー選択 ─────────────────────── */
#send-section { margin-top: 40px; }
h2 { text-align: center; font-size: 1.1rem; font-weight: 700; margin-bottom: 16px; }

#members { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 10px; }
.member {
  cursor: pointer; text-align: center; padding: 12px 4px 10px; border-radius: 16px;
  background: rgba(255,255,255,.05); border: 2px solid transparent;
  transition: transform .15s, border-color .15s, background .15s;
}
.member:hover { transform: translateY(-2px); background: rgba(255,255,255,.09); }
.member.selected { border-color: var(--pink-soft); background: rgba(255,79,163,.15); box-shadow: 0 0 14px rgba(255,79,163,.35); }
.member .m-heart { font-size: 1.7rem; display: block; filter: drop-shadow(0 0 6px var(--c1)); }
.member .m-heart svg { width: 34px; height: 32px; }
.member .m-name { display: block; font-size: .78rem; font-weight: 700; margin-top: 4px; }
.member .m-energy { display: block; font-size: .68rem; opacity: .7; }

#compose { margin-top: 20px; text-align: center; }
#compose label { display: block; font-size: .85rem; margin-bottom: 8px; opacity: .9; }
#target-name { color: var(--pink-soft); font-weight: 700; }
#comment, #author-name {
  width: 100%; max-width: 420px; border-radius: 14px; border: 1px solid rgba(255,158,207,.35);
  background: rgba(255,255,255,.08); color: var(--text); padding: 12px 14px; font-family: inherit;
  font-size: .95rem; resize: none; outline: none;
}
#author-name { margin-bottom: 8px; }
#comment:focus, #author-name:focus { border-color: var(--pink-soft); box-shadow: 0 0 10px rgba(255,79,163,.4); }

#send-btn {
  display: block; margin: 16px auto 0; cursor: pointer; font-family: inherit;
  font-size: 1.15rem; font-weight: 900; color: #fff; letter-spacing: .05em;
  background: linear-gradient(135deg, var(--pink), #d4308a);
  border: none; border-radius: 999px; padding: 14px 44px;
  box-shadow: 0 6px 24px rgba(255,79,163,.5);
  transition: transform .15s, box-shadow .15s;
}
#send-btn:hover { transform: translateY(-2px) scale(1.03); box-shadow: 0 8px 30px rgba(255,79,163,.7); }
#send-btn:disabled { opacity: .5; transform: none; cursor: default; }

.error { color: #ffb3c8; font-size: .85rem; margin-top: 10px; }

/* ── グループ全体カード ─────────────────────── */
#group-card {
  display: flex; align-items: center; gap: 14px;
  max-width: 440px; margin: 0 auto 14px; padding: 12px 18px;
  background: linear-gradient(135deg, rgba(255,79,163,.16), rgba(139,92,246,.16));
  border: 1px solid rgba(255,158,207,.35); border-radius: 16px;
  cursor: pointer; transition: transform .15s, border-color .15s, box-shadow .15s;
}
#group-card:hover { transform: translateY(-2px); }
#group-card.selected {
  border-color: var(--pink-soft);
  box-shadow: 0 0 16px rgba(255,79,163,.45);
  background: linear-gradient(135deg, rgba(255,79,163,.28), rgba(139,92,246,.28));
}
#group-card .m-heart { width: 44px; height: 44px; flex: none; }
#group-card .m-heart svg { width: 100%; height: 100%; }
#group-card .g-text { flex: 1; display: flex; flex-direction: column; text-align: left; }
#group-card .g-name { font-weight: 900; font-size: 1rem; }
#group-card .g-sub { font-size: .7rem; opacity: .7; }
#group-card .m-energy { font-size: .8rem; opacity: .85; }

/* ── 自分のコメント管理 ─────────────────────── */
#mine-section { margin-top: 44px; }
.mine-note { text-align: center; font-size: .75rem; opacity: .7; margin-bottom: 12px; }
#mine-list { list-style: none; max-width: 440px; margin: 0 auto; }
#mine-list li {
  display: flex; align-items: center; gap: 10px;
  background: rgba(255,255,255,.06); border: 1px solid rgba(255,158,207,.2);
  border-radius: 12px; padding: 10px 12px; margin-bottom: 8px; font-size: .85rem;
}
#mine-list .mine-member { color: var(--pink-soft); font-weight: 700; white-space: nowrap; font-size: .75rem; }
#mine-list .mine-text { flex: 1; overflow-wrap: anywhere; }
.mine-del {
  cursor: pointer; border: none; background: rgba(255,255,255,.1); color: var(--text);
  border-radius: 8px; padding: 6px 10px; font-family: inherit; font-size: .75rem;
  transition: background .15s;
}
.mine-del:hover { background: rgba(255,79,163,.4); }

/* ── 初回チュートリアル ─────────────────────── */
#tut-overlay { position: fixed; inset: 0; z-index: 90; }
#tut-overlay.dim { background: rgba(10, 4, 24, .78); }
#tut-spot {
  position: fixed; border-radius: 18px; pointer-events: none;
  border: 2px solid var(--pink-soft);
  box-shadow: 0 0 0 100vmax rgba(10, 4, 24, .78), 0 0 24px rgba(255, 79, 163, .55);
  transition: top .35s ease, left .35s ease, width .35s ease, height .35s ease;
}
#tut-card {
  position: fixed; z-index: 91; width: min(88vw, 340px);
  background: linear-gradient(160deg, #2b1150, #1a0a33);
  border: 1px solid rgba(255, 158, 207, .45); border-radius: 18px;
  padding: 18px 18px 14px; text-align: center;
  box-shadow: 0 8px 40px rgba(0, 0, 0, .5);
  transition: top .35s ease, left .35s ease;
}
#tut-card.center { left: 50% !important; top: 50% !important; transform: translate(-50%, -50%); }
#tut-emoji { font-size: 2rem; margin-bottom: 6px; }
#tut-text { font-size: .9rem; line-height: 1.7; }
#tut-dots { margin: 12px 0 10px; display: flex; justify-content: center; gap: 6px; }
#tut-dots span { width: 7px; height: 7px; border-radius: 50%; background: rgba(255,255,255,.25); }
#tut-dots span.on { background: var(--pink-soft); }
.tut-btns { display: flex; justify-content: center; gap: 10px; }
#tut-next {
  cursor: pointer; border: none; font-family: inherit; font-weight: 700;
  background: linear-gradient(135deg, #ff4fa3, #ff8cc6); color: #fff;
  border-radius: 999px; padding: 9px 26px; font-size: .9rem;
}
#tut-skip { font-size: .8rem; }

#help-btn {
  position: fixed; top: 14px; right: 14px; z-index: 80;
  width: 34px; height: 34px; border-radius: 50%; cursor: pointer;
  border: 1px solid rgba(255,158,207,.4); background: rgba(255,255,255,.08);
  color: var(--pink-soft); font-family: inherit; font-weight: 900; font-size: 1rem;
}
#help-btn:hover { background: rgba(255,79,163,.25); }

footer { margin-top: 60px; text-align: center; font-size: .68rem; opacity: .5; }

/* ── 飛ぶハート ─────────────────────── */
.fly-heart {
  position: fixed; z-index: 50; font-size: 1.6rem; pointer-events: none;
  transition: transform 1s cubic-bezier(.5,-0.2,.6,1), opacity 1s;
  filter: drop-shadow(0 0 8px rgba(255,110,180,.9));
}

.spark {
  position: fixed; z-index: 49; width: 6px; height: 6px; border-radius: 50%;
  background: #ffe4f2; pointer-events: none; box-shadow: 0 0 8px 3px rgba(255,158,207,.8);
}

/* ── 送信後モーダル ─────────────────────── */
#done-overlay {
  position: fixed; inset: 0; z-index: 100; background: rgba(10,4,24,.7); backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
#done-card {
  background: linear-gradient(160deg, #331352, #1c0a38);
  border: 1px solid rgba(255,158,207,.4); border-radius: 24px;
  max-width: 380px; width: 100%; padding: 32px 26px; text-align: center;
  box-shadow: 0 0 60px rgba(255,79,163,.35);
  animation: pop .4s cubic-bezier(.34,1.56,.64,1);
}
@keyframes pop { from { transform: scale(.7); opacity: 0; } }
.done-heart { font-size: 3rem; animation: beat 1.6s ease-in-out infinite; }
#done-card h3 { font-size: 1.15rem; margin: 10px 0 8px; line-height: 1.5; }
#done-detail { font-size: .85rem; opacity: .85; }
.spread { margin-top: 18px; font-size: .8rem; letter-spacing: .15em; opacity: .8; }
.btn-x {
  display: block; margin: 10px auto 0; max-width: 260px; text-decoration: none;
  background: #000; color: #fff; font-weight: 700; border: 1px solid #444;
  border-radius: 999px; padding: 12px 0; font-size: 1rem;
}
.btn-x:hover { background: #111; }
.btn-sub {
  display: block; margin: 10px auto 0; max-width: 260px; width: 100%; cursor: pointer;
  background: rgba(255,255,255,.1); color: var(--text); font-family: inherit; font-weight: 700;
  border: 1px solid rgba(255,158,207,.35); border-radius: 999px; padding: 11px 0; font-size: .9rem;
}
.btn-ghost {
  margin-top: 14px; cursor: pointer; background: none; border: none; color: var(--text);
  font-family: inherit; font-size: .85rem; opacity: .7; text-decoration: underline;
}

[hidden] { display: none !important; }

@media (max-width: 420px) {
  #ball { width: 260px; height: 244px; }
  h1 { font-size: 1.6rem; }
  #members { grid-template-columns: repeat(3, 1fr); }
}
