/* ことばの宇宙 */
:root {
  --bg: #060815;
  --bg2: #0d1130;
  --text: #e8eaf6;
  --dim: #9aa0c3;
  --accent: #8ab4ff;
  --accent-soft: rgba(138, 180, 255, 0.16);
  --gold: #ffe9a8;
  --card: rgba(16, 20, 46, 0.92);
  --border: rgba(138, 180, 255, 0.22);
}
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  font-family: "Hiragino Sans", "Yu Gothic", "Noto Sans JP", sans-serif;
  background: radial-gradient(ellipse at 30% 20%, var(--bg2) 0%, var(--bg) 60%);
  color: var(--text);
  overflow: hidden;
}
#stars { position: fixed; inset: 0; z-index: 0; }

/* ---------- ヘッダー ---------- */
.topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 20;
  padding: calc(env(safe-area-inset-top, 0px) + 14px) 16px 10px;
  text-align: center; pointer-events: none;
  background: linear-gradient(to bottom, rgba(6,8,21,.85), transparent);
}
.brand {
  font-size: 15px; font-weight: 600; letter-spacing: .35em; color: var(--dim);
  text-shadow: 0 0 12px rgba(138,180,255,.4);
}
.theme-chip {
  display: inline-flex; align-items: center; gap: 8px; margin-top: 10px;
  padding: 6px 14px; border-radius: 999px;
  background: var(--accent-soft); border: 1px solid var(--border);
  backdrop-filter: blur(6px);
}
.theme-label { font-size: 10px; color: var(--accent); letter-spacing: .15em; }
.theme-text { font-size: 13px; }

/* ---------- 宇宙(投稿フィールド) ---------- */
.space { position: fixed; inset: 0; z-index: 5; }
.word {
  position: absolute; z-index: 6;
  max-width: min(60vw, 260px);
  padding: 8px 12px; border-radius: 14px;
  font-size: 13px; line-height: 1.5; color: var(--text);
  background: rgba(14, 18, 42, 0.55);
  border: 1px solid rgba(138, 180, 255, 0.14);
  cursor: pointer; user-select: none;
  animation: floaty var(--dur, 9s) ease-in-out var(--delay, 0s) infinite alternate;
  transition: box-shadow .6s, transform .3s;
  will-change: transform;
}
.word:active { transform: scale(.96); }
.word.glow1 { box-shadow: 0 0 14px rgba(138,180,255,.35); border-color: rgba(138,180,255,.4); }
.word.glow2 { box-shadow: 0 0 22px rgba(255,233,168,.4); border-color: rgba(255,233,168,.45); font-size: 14px; }
.word.glow3 { box-shadow: 0 0 34px rgba(255,233,168,.65); border-color: rgba(255,233,168,.7); font-size: 15px; }
.word.sample { opacity: .55; border-style: dashed; }
.word .sample-tag { display: block; font-size: 9px; color: var(--dim); margin-top: 2px; }
.word.entering { animation: enter 1.2s ease-out forwards, floaty var(--dur, 9s) ease-in-out 1.2s infinite alternate; }
.word.mine { border-color: rgba(255,233,168,.8); box-shadow: 0 0 26px rgba(255,233,168,.5); }
.word.leaving { animation: leave .8s ease-in forwards; }
@keyframes floaty {
  from { transform: translate(0, 0); }
  to { transform: translate(var(--dx, 8px), var(--dy, -14px)); }
}
@keyframes enter {
  0% { opacity: 0; transform: scale(.4) translateY(30px); filter: blur(6px); }
  60% { opacity: 1; filter: blur(0); }
  100% { opacity: 1; transform: scale(1) translateY(0); }
}
@keyframes leave {
  to { opacity: 0; transform: scale(.5); filter: blur(8px); }
}

/* ---------- フッター ---------- */
.bottombar {
  position: fixed; left: 0; right: 0; z-index: 20;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 18px);
  display: flex; justify-content: center; align-items: center; gap: 14px;
}
.btn-primary {
  appearance: none; border: none; cursor: pointer;
  padding: 15px 38px; border-radius: 999px;
  font-size: 16px; font-weight: 600; color: #0a0d20;
  background: linear-gradient(135deg, #cfe0ff, #8ab4ff);
  box-shadow: 0 0 24px rgba(138,180,255,.5);
  text-decoration: none; display: inline-block; text-align: center;
  transition: transform .15s;
}
.btn-primary:active { transform: scale(.96); }
.btn-primary.small { padding: 10px 22px; font-size: 14px; }
.btn-glow, .btn-rules {
  width: 46px; height: 46px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: rgba(16,20,46,.8); border: 1px solid var(--border);
  color: var(--dim); font-size: 18px; cursor: pointer; text-decoration: none;
}

/* ---------- シート/モーダル ---------- */
.sheet-backdrop {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(3,4,12,.7); backdrop-filter: blur(3px);
  display: flex; align-items: flex-end; justify-content: center;
}
.sheet, .word-card {
  width: 100%; max-width: 480px;
  background: var(--card); border: 1px solid var(--border);
  border-radius: 22px 22px 0 0; padding: 22px 20px calc(env(safe-area-inset-bottom, 0px) + 24px);
  animation: slideup .3s ease-out;
}
@media (min-width: 600px) {
  .sheet-backdrop { align-items: center; }
  .sheet, .word-card { border-radius: 22px; margin: 0 16px; padding-bottom: 24px; }
}
@keyframes slideup { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
.sheet-theme { font-size: 12px; color: var(--accent); margin-bottom: 10px; letter-spacing: .05em; }
textarea#composeText {
  width: 100%; resize: none; border-radius: 14px;
  background: rgba(6,8,21,.7); border: 1px solid var(--border);
  color: var(--text); font-size: 16px; line-height: 1.7; padding: 14px;
  outline: none; font-family: inherit;
}
textarea#composeText:focus { border-color: var(--accent); }
.sheet-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 12px; }
.char-count { font-size: 12px; color: var(--dim); }
.char-count.over { color: #ff9a9a; }
.sheet-error { margin-top: 10px; font-size: 13px; color: #ffb3b3; }
.btn-ghost {
  appearance: none; background: none; border: none; cursor: pointer;
  color: var(--dim); font-size: 13px; padding: 10px 12px; text-decoration: none;
  display: inline-block;
}

/* ---------- 投稿カード ---------- */
.word-card-text { font-size: 18px; line-height: 1.8; text-align: center; padding: 10px 4px 18px; word-break: break-word; }
.react-row { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.react-btn {
  appearance: none; cursor: pointer;
  background: var(--accent-soft); border: 1px solid var(--border);
  color: var(--text); border-radius: 999px; padding: 8px 12px; font-size: 13px;
  transition: transform .15s, background .2s;
}
.react-btn:active { transform: scale(.92); }
.react-btn.on { background: rgba(255,233,168,.2); border-color: var(--gold); color: var(--gold); }
.react-btn span { opacity: .8; margin-left: 2px; }
.card-actions { display: flex; gap: 10px; justify-content: center; margin-top: 18px; }
.btn-share-x {
  background: #000; color: #fff; border: 1px solid #333;
  border-radius: 999px; padding: 10px 18px; font-size: 13px; font-weight: 600;
  text-decoration: none;
}
.card-sub { display: flex; justify-content: space-between; margin-top: 10px; }
.btn-report { appearance: none; background: none; border: none; cursor: pointer; color: #7c7f9e; font-size: 12px; padding: 10px 12px; }

/* ---------- 人気投稿 ---------- */
.top-title { font-size: 15px; font-weight: 600; color: var(--gold); text-align: center; margin-bottom: 14px; letter-spacing: .1em; text-shadow: 0 0 14px rgba(255,233,168,.5); }
.top-list { list-style: none; display: flex; flex-direction: column; gap: 10px; max-height: 50vh; overflow-y: auto; }
.top-list li {
  padding: 12px 14px; border-radius: 14px; cursor: pointer;
  background: rgba(255,233,168,.06); border: 1px solid rgba(255,233,168,.2);
  font-size: 14px; line-height: 1.6;
}
.top-list li .top-score { display: block; font-size: 11px; color: var(--gold); margin-top: 4px; }
.top-empty { text-align: center; color: var(--dim); font-size: 13px; padding: 16px 0; }
.top-sheet .btn-ghost { display: block; margin: 14px auto 0; }

/* ---------- トースト ---------- */
.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(env(safe-area-inset-bottom, 0px) + 92px); z-index: 60;
  background: var(--card); border: 1px solid var(--gold); color: var(--gold);
  padding: 12px 22px; border-radius: 999px; font-size: 14px;
  box-shadow: 0 0 30px rgba(255,233,168,.35);
  animation: toastin .4s ease-out;
  max-width: 88vw; text-align: center;
}
@keyframes toastin { from { opacity: 0; transform: translate(-50%, 12px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* ---------- 詳細ページ ---------- */
.detail-body { overflow: auto; }
.detail-main {
  position: relative; z-index: 5; min-height: 100vh;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 22px; padding: 40px 20px; text-align: center;
}
.detail-brand { color: var(--dim); text-decoration: none; letter-spacing: .35em; font-size: 14px; }
.detail-card {
  width: 100%; max-width: 480px; padding: 40px 28px;
  background: var(--card); border: 1px solid var(--border); border-radius: 24px;
  box-shadow: 0 0 40px rgba(138,180,255,.18);
}
.detail-card.faded { opacity: .6; }
.detail-text { font-size: 22px; line-height: 2; word-break: break-word; }
.detail-meta { margin-top: 18px; font-size: 12px; color: var(--dim); }
.detail-copy { font-size: 12px; color: var(--dim); }

/* ---------- ルールページ ---------- */
.rules-main { position: relative; z-index: 5; max-width: 560px; margin: 0 auto; padding: 48px 24px 80px; }
.rules-main h1 { font-size: 20px; letter-spacing: .2em; margin-bottom: 8px; }
.rules-main .lead { color: var(--dim); font-size: 13px; margin-bottom: 28px; line-height: 1.8; }
.rules-main h2 { font-size: 15px; color: var(--accent); margin: 26px 0 10px; }
.rules-main p, .rules-main li { font-size: 14px; line-height: 1.9; color: var(--text); }
.rules-main ul { padding-left: 20px; }
.rules-main .back { display: inline-block; margin-top: 36px; color: var(--accent); text-decoration: none; }
