/* 逆アキネーター Web版 — スマホファーストUI
   デザイン言語: リーグカラーのヒーローヘッダー / 質問=紫バブル / 名前当て=ピンクバブル / AI回答=AIバッジ付き */
:root {
  --bg: #0d1220;
  --surface: #171e33;
  --surface-2: #1f2947;
  --border: #2a3352;
  --text: #eef1f8;
  --muted: #9aa5c4;
  --q: #8b5cf6;          /* 質問（紫） */
  --q-deep: #4c2d95;
  --guess: #ec4899;      /* 名前当て（ピンク） */
  --guess-deep: #831843;
  --ai: #22c55e;         /* AIバッジ */
  --danger: #e05260;
  --composer-h: 68px;
  /* リーグカラー（既定 = プレミアリーグ） */
  --league-a: #3d195b;
  --league-b: #00ff85;
  --league-accent: #00ff85;
  --league-accent-text: #0b2413;
}
body[data-league="ucl"] {
  --league-a: #0a1e5e;
  --league-b: #2b6cff;
  --league-accent: #4f83ff;
  --league-accent-text: #ffffff;
}
body[data-league="wc"] {
  --league-a: #7a2d0e;
  --league-b: #f5b921;
  --league-accent: #f5b921;
  --league-accent-text: #2a1a00;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: "Hiragino Kaku Gothic ProN", "Hiragino Sans", "Noto Sans JP", system-ui, sans-serif;
  background:
    radial-gradient(1200px 500px at 50% -120px, color-mix(in srgb, var(--league-a) 55%, transparent), transparent 70%),
    var(--bg);
  color: var(--text);
  /* 下部固定の入力バーに本文が隠れないように */
  padding-bottom: calc(var(--composer-h) + env(safe-area-inset-bottom) + 12px);
}

/* ---------- ヒーローヘッダー ---------- */
.hero {
  background: linear-gradient(135deg, var(--league-a) 20%, color-mix(in srgb, var(--league-b) 55%, var(--league-a)) 130%);
  transition: background .35s ease;
  padding: calc(22px + env(safe-area-inset-top)) 16px 20px;
  text-align: center;
  border-bottom: 1px solid var(--border);
}
.hero-inner { max-width: 560px; margin: 0 auto; }
.hero-eyebrow { margin: 0 0 4px; font-size: .68rem; letter-spacing: .35em; opacity: .75; font-weight: 700; }
.hero h1 { margin: 0; font-size: clamp(1.7rem, 7vw, 2.3rem); letter-spacing: .04em; line-height: 1.2; }
.hero .sub { opacity: .92; margin: 10px auto 0; font-size: .88rem; line-height: 1.7; max-width: 34em; }
.hero-rules { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin-top: 12px; }
.rule-chip { font-size: .7rem; font-weight: 700; padding: 4px 10px; border-radius: 999px; background: rgba(255,255,255,.14); border: 1px solid rgba(255,255,255,.25); }
.rule-chip.q { box-shadow: inset 0 0 0 1px var(--q); }
.rule-chip.guess { box-shadow: inset 0 0 0 1px var(--guess); }
.rule-chip.ai { box-shadow: inset 0 0 0 1px var(--ai); }

/* ---------- レイアウト ---------- */
main { max-width: 560px; margin: 0 auto; padding: 14px 12px 8px; display: grid; gap: 14px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 16px 14px; }
.card h2 { margin: 0 0 12px; font-size: 1.05rem; letter-spacing: .03em; }
.field-label { margin: 12px 0 6px; font-size: .78rem; font-weight: 700; color: var(--muted); letter-spacing: .08em; }
.card .field-label:first-of-type { margin-top: 0; }
.note { font-size: .8rem; color: var(--muted); line-height: 1.6; }

/* ---------- プロフィール ---------- */
.row { display: grid; gap: 10px; }
label { display: grid; gap: 5px; font-size: .85rem; font-weight: 600; }
input[type="text"] {
  padding: 0 12px; height: 48px;
  border-radius: 10px; border: 1px solid #3a4568;
  background: #0d1220; color: #fff;
  font-size: 16px; /* 16px未満だとiOSが自動ズームする */
  width: 100%;
  -webkit-appearance: none; appearance: none;
}
input[type="text"]:focus { outline: 2px solid var(--q); outline-offset: 0; border-color: transparent; }
input[type="text"]:disabled { opacity: .5; }
.my-ratings { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.my-ratings .chip { background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; padding: 6px 12px; font-size: .8rem; }

/* ---------- ボタン ---------- */
.btn {
  min-height: 48px; padding: 10px 18px;
  border-radius: 12px; border: 1px solid #3a4568;
  background: #232c49; color: #fff; cursor: pointer;
  font-size: .95rem; font-weight: 700;
  touch-action: manipulation; -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: scale(.98); }
.btn.primary { background: linear-gradient(135deg, var(--q), var(--q-deep)); border-color: transparent; }
.btn.big { width: 100%; min-height: 54px; font-size: 1.05rem; margin-top: 12px; }
.btn.danger { background: #4a1f2b; border-color: #7a2f42; color: #ffb3c0; }
.btn.small { min-height: 40px; padding: 6px 12px; font-size: .82rem; border-radius: 10px; }
.btn:disabled { opacity: .4; cursor: not-allowed; transform: none; }

/* ---------- セグメント選択（リーグ/難易度） ---------- */
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; background: #0d1220; border: 1px solid var(--border); border-radius: 12px; padding: 4px; }
.seg-btn {
  min-height: 46px; padding: 8px 4px;
  border: none; border-radius: 9px; background: transparent;
  color: var(--muted); font-size: .85rem; font-weight: 700; line-height: 1.3;
  cursor: pointer; touch-action: manipulation; -webkit-tap-highlight-color: transparent;
}
.seg-btn.active { background: var(--league-accent); color: var(--league-accent-text); }
.pool-note { margin: 10px 0 0; text-align: center; }

/* ---------- ステータスバー ---------- */
.status-bar { display: flex; align-items: center; gap: 10px; margin-top: 14px; }
.status { flex: 1; margin: 0; font-size: .88rem; line-height: 1.55; font-weight: 600; }
.status:empty { display: none; }

/* ---------- チャットログ ---------- */
.log { display: flex; flex-direction: column; gap: 10px; margin-top: 14px; }
.log:empty { display: none; }
.msg-row { display: flex; flex-direction: column; max-width: 88%; }
.msg-row.me { align-self: flex-end; align-items: flex-end; }
.msg-row.ai { align-self: flex-start; align-items: flex-start; }
.msg-row.sys { align-self: center; max-width: 96%; align-items: center; }
.msg-tag { font-size: .68rem; font-weight: 700; letter-spacing: .06em; color: var(--muted); margin: 0 4px 3px; display: flex; align-items: center; gap: 5px; }
.badge-ai {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 22px; height: 22px; padding: 0 6px;
  border-radius: 999px; background: var(--ai); color: #08130a;
  font-size: .68rem; font-weight: 900; letter-spacing: .04em;
}
.msg { padding: 10px 13px; border-radius: 16px; font-size: .95rem; line-height: 1.55; word-break: break-word; overflow-wrap: anywhere; }
.msg.q { background: linear-gradient(135deg, var(--q), var(--q-deep)); color: #fff; border-bottom-right-radius: 5px; }
.msg.guess { background: linear-gradient(135deg, var(--guess), var(--guess-deep)); color: #fff; border-bottom-right-radius: 5px; }
.msg.a { background: var(--surface-2); border: 1px solid var(--border); border-bottom-left-radius: 5px; font-weight: 700; }
.msg.sys { background: transparent; border: 1px dashed var(--border); color: var(--muted); font-size: .82rem; text-align: center; border-radius: 12px; }
.msg.thinking { display: inline-flex; gap: 5px; align-items: center; background: var(--surface-2); border: 1px solid var(--border); border-bottom-left-radius: 5px; }
.msg.thinking .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); animation: blink 1.2s infinite; }
.msg.thinking .dot:nth-child(2) { animation-delay: .2s; }
.msg.thinking .dot:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }

/* ---------- 結果パネル ---------- */
.result { margin-top: 16px; padding: 16px 14px; border-radius: 14px; background: #10241a; border: 1px solid var(--ai); line-height: 1.65; }
.result.hidden { display: none; }
.result h3 { margin: 0 0 8px; font-size: 1.15rem; }
.result p { margin: 6px 0; font-size: .92rem; }
.result .delta-plus { color: #4ade80; font-weight: 800; }
.result .delta-minus { color: #f87171; font-weight: 800; }

/* ---------- ランキング表 ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -4px; padding: 0 4px; }
table { width: 100%; border-collapse: collapse; font-size: .85rem; min-width: 430px; }
th, td { padding: 8px 7px; border-bottom: 1px solid var(--border); text-align: left; white-space: nowrap; }
th { color: var(--muted); font-weight: 600; font-size: .78rem; }
td a { color: var(--q); text-decoration: underline; text-underline-offset: 2px; font-weight: 600; padding: 4px 2px; }
footer a { color: var(--q); text-decoration: underline; text-underline-offset: 2px; font-weight: 600; }
tr td:first-child { font-weight: 800; color: var(--muted); }

/* ---------- 入力バー（画面下部固定） ---------- */
.composer {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  background: rgba(13, 18, 32, .92);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
}
.composer-inner { max-width: 560px; margin: 0 auto; display: flex; gap: 8px; padding: 10px 12px; align-items: center; }
.composer input { flex: 1; min-width: 0; border-radius: 999px; padding: 0 16px; }
.composer .send { border-radius: 999px; min-width: 76px; flex-shrink: 0; }

footer { text-align: center; padding: 10px 18px 4px; font-size: .75rem; color: var(--muted); }

/* ---------- PC幅 ---------- */
@media (min-width: 720px) {
  main { padding: 20px 16px 8px; gap: 18px; }
  .card { padding: 20px; border-radius: 18px; }
  .row { grid-template-columns: 1fr 1fr auto; align-items: end; }
  .msg-row { max-width: 78%; }
  .hero { padding-top: 34px; padding-bottom: 26px; }
}
