:root {
  --bg-0: #050a14;
  --bg-1: #0a1428;
  --bg-2: #0e1c32;
  --surface: rgba(16, 31, 56, 0.72);
  --surface-solid: #0f2038;
  --line: rgba(200, 170, 110, 0.22);
  --line-strong: rgba(200, 170, 110, 0.55);

  --gold: #c8aa6e;
  --gold-bright: #f0e6d2;
  --gold-deep: #785a28;
  --teal: #0ac8b9;
  --blue: #2f9bff;
  --blue-deep: #0a2a52;
  --red: #ff4757;
  --red-deep: #4a0f1c;

  --text: #f0e6d2;
  --text-dim: #a3b1c2;
  --text-faint: #6b7a8d;

  --display: "Cinzel", "Times New Roman", serif;
  --body: "Noto Sans JP", "Segoe UI", "Hiragino Kaku Gothic ProN", sans-serif;
}

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

body {
  font-family: var(--body);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(900px 500px at 50% -8%, rgba(10, 200, 185, 0.14), transparent 60%),
    radial-gradient(700px 500px at 12% 8%, rgba(47, 155, 255, 0.12), transparent 55%),
    radial-gradient(700px 500px at 88% 12%, rgba(200, 170, 110, 0.12), transparent 55%),
    linear-gradient(180deg, var(--bg-1) 0%, var(--bg-0) 100%);
  background-attachment: fixed;
}

/* ===== ヘッダー ===== */
.header {
  text-align: center;
  padding: 48px 16px 12px;
  position: relative;
}

.title {
  font-family: var(--display);
  font-weight: 900;
  font-size: clamp(1.8rem, 5vw, 3.1rem);
  letter-spacing: 0.06em;
  background: linear-gradient(180deg, #fbf3df 0%, var(--gold) 55%, var(--gold-deep) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: 0 2px 30px rgba(200, 170, 110, 0.35);
}

.title::after {
  content: "";
  display: block;
  width: 180px;
  max-width: 60%;
  height: 1px;
  margin: 14px auto 0;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
}

.subtitle {
  color: var(--text-dim);
  margin-top: 12px;
  font-size: 0.95rem;
  letter-spacing: 0.02em;
}

/* ===== レイアウト ===== */
.container {
  flex: 1;
  width: 100%;
  max-width: 900px;
  margin: 0 auto;
  padding: 28px 16px 40px;
}

.input-section,
.result-section {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 24px;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.section-heading {
  font-family: var(--display);
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: 0.08em;
  color: var(--gold);
  margin-bottom: 18px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 10px;
}

.section-heading::before {
  content: "";
  width: 9px;
  height: 9px;
  transform: rotate(45deg);
  background: var(--gold);
  box-shadow: 0 0 10px rgba(200, 170, 110, 0.7);
}

/* ===== 共通フィールド ===== */
.field {
  background: rgba(5, 10, 20, 0.55);
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--text);
  font-family: var(--body);
  font-size: 1rem;
  padding: 12px 14px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.field::placeholder {
  color: var(--text-faint);
}

.field:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(200, 170, 110, 0.18);
}

/* ===== 検索 ===== */
.search-box {
  display: flex;
  gap: 10px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.riot-input-wrap {
  position: relative;
  flex: 1;
  min-width: 180px;
}

.search-box input {
  width: 100%;
  background: rgba(5, 10, 20, 0.55);
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--text);
  font-family: var(--body);
  font-size: 1rem;
  padding: 12px 14px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.search-box input::placeholder {
  color: var(--text-faint);
}

.search-box input:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(200, 170, 110, 0.18);
}

.search-box select {
  background: rgba(5, 10, 20, 0.55);
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--text);
  font-family: var(--body);
  font-size: 0.95rem;
  padding: 0 12px;
  cursor: pointer;
  outline: none;
}

.search-box select:focus {
  border-color: var(--gold);
}

/* 入力候補 */
.suggestions {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  list-style: none;
  margin: 0;
  padding: 6px;
  background: rgba(10, 20, 36, 0.98);
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  z-index: 20;
  max-height: 300px;
  overflow-y: auto;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(8px);
}

.suggestions li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 8px;
  cursor: pointer;
}

.suggestions li:hover,
.suggestions li.active {
  background: rgba(200, 170, 110, 0.16);
}

.suggestions .s-icon {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  flex-shrink: 0;
  border: 1px solid var(--line);
}

.suggestions .s-name {
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.suggestions .s-meta {
  color: var(--text-dim);
  font-size: 0.78rem;
  margin-left: auto;
  white-space: nowrap;
}

/* 検索結果メッセージ */
.search-result {
  min-height: 1.1em;
  margin-bottom: 14px;
  font-size: 0.92rem;
  display: flex;
  align-items: center;
  gap: 8px;
}

.search-result:empty {
  margin-bottom: 0;
  min-height: 0;
}

.search-result.error {
  color: #ff96a1;
}

.search-result.loading {
  color: var(--text-dim);
}

.search-result.success {
  color: #9fe7df;
  background: rgba(10, 200, 185, 0.1);
  border: 1px solid rgba(10, 200, 185, 0.35);
  border-radius: 10px;
  padding: 10px 14px;
}

.search-result.batch {
  display: block;
}

.batch-failed {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
  color: #ff96a1;
  font-size: 0.82rem;
}

.batch-failed li {
  padding: 2px 0;
}

/* ===== まとめて貼り付け ===== */
.bulk-add {
  margin-bottom: 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(5, 10, 20, 0.35);
  overflow: hidden;
}

.bulk-add summary {
  cursor: pointer;
  padding: 11px 14px;
  font-size: 0.9rem;
  color: var(--gold);
  list-style: none;
  user-select: none;
}

.bulk-add summary::-webkit-details-marker {
  display: none;
}

.bulk-add summary::before {
  content: "▸ ";
  color: var(--gold);
}

.bulk-add[open] summary::before {
  content: "▾ ";
}

.bulk-add textarea {
  display: block;
  width: calc(100% - 28px);
  margin: 0 14px 12px;
  background: rgba(5, 10, 20, 0.6);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  font-family: var(--body);
  font-size: 0.95rem;
  padding: 10px 12px;
  resize: vertical;
  outline: none;
}

.bulk-add textarea:focus {
  border-color: var(--gold);
}

.bulk-add .btn {
  margin: 0 14px 14px;
}

/* ===== 手動追加 ===== */
.manual-add {
  display: flex;
  gap: 10px;
  margin-bottom: 22px;
}

.manual-add input {
  flex: 1;
  min-width: 0;
  background: rgba(5, 10, 20, 0.55);
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--text);
  font-family: var(--body);
  font-size: 1rem;
  padding: 12px 14px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.manual-add input::placeholder {
  color: var(--text-faint);
}

.manual-add input:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(200, 170, 110, 0.18);
}

/* ===== メンバー一覧 ===== */
.roster-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 12px;
}

.roster-header > span:first-child {
  font-family: var(--display);
  letter-spacing: 0.06em;
  color: var(--gold);
  font-size: 0.95rem;
}

.roster-count {
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
  font-size: 0.9rem;
}

.roster {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin: 0 0 8px;
  padding: 0;
}

.roster-empty {
  grid-column: 1 / -1;
  color: var(--text-faint);
  text-align: center;
  padding: 26px 12px;
  border: 1px dashed var(--line);
  border-radius: 12px;
  font-size: 0.9rem;
}

.roster-item {
  display: flex;
  align-items: center;
  gap: 11px;
  background: linear-gradient(180deg, rgba(16, 31, 56, 0.9), rgba(10, 20, 36, 0.7));
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  transition: transform 0.12s ease, border-color 0.15s ease;
}

.roster-item:hover {
  border-color: var(--line-strong);
  transform: translateY(-1px);
}

.roster-item .r-icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  flex-shrink: 0;
  border: 1px solid var(--line-strong);
}

.roster-item .r-name {
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.roster-item .r-rank {
  color: var(--gold);
  font-size: 0.76rem;
  margin-left: auto;
  white-space: nowrap;
  padding: 3px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(200, 170, 110, 0.08);
}

.roster-item .r-remove {
  margin-left: auto;
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  border: none;
  border-radius: 50%;
  background: rgba(255, 71, 87, 0.16);
  color: #ff96a1;
  font-size: 1.05rem;
  line-height: 1;
  cursor: pointer;
  transition: background 0.15s ease;
}

.roster-item .r-rank + .r-remove {
  margin-left: 10px;
}

.roster-item .r-remove:hover {
  background: rgba(255, 71, 87, 0.36);
}

.roster-item.just-added {
  border-color: var(--teal);
  box-shadow: 0 0 0 2px rgba(10, 200, 185, 0.35);
  animation: pop 0.4s ease;
}

/* ===== ボタン ===== */
.controls {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 26px;
}

.btn {
  font-family: var(--display);
  font-size: 0.98rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  padding: 13px 30px;
  border-radius: 10px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform 0.1s ease, filter 0.15s ease, box-shadow 0.15s ease;
}

.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  background: linear-gradient(180deg, #f0e0bf 0%, var(--gold) 45%, #a8884e 100%);
  color: #1a1206;
  box-shadow: 0 6px 18px rgba(200, 170, 110, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.4);
}

.btn-primary:hover {
  filter: brightness(1.07);
  box-shadow: 0 8px 24px rgba(200, 170, 110, 0.42), inset 0 1px 0 rgba(255, 255, 255, 0.4);
}

.btn-primary:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  filter: grayscale(0.3);
  box-shadow: none;
}

.btn-ghost {
  background: rgba(200, 170, 110, 0.06);
  color: var(--gold);
  border-color: var(--line-strong);
}

.btn-ghost:hover {
  background: rgba(200, 170, 110, 0.14);
}

.hint {
  text-align: center;
  color: #ff96a1;
  margin-top: 16px;
  min-height: 1.2em;
  font-size: 0.9rem;
}

/* ===== サウンド切り替え ===== */
.mute-btn {
  position: fixed;
  top: 16px;
  right: 16px;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  backdrop-filter: blur(8px);
  color: var(--text);
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
  z-index: 30;
  transition: border-color 0.15s ease, transform 0.1s ease;
}

.mute-btn:hover {
  border-color: var(--gold);
}

.mute-btn:active {
  transform: scale(0.92);
}

/* ===== 回転ルーレット ===== */
.wheel-wrap {
  position: relative;
  width: min(420px, 86vw);
  margin: 4px auto 30px;
  aspect-ratio: 1 / 1;
}

#wheelCanvas {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: var(--surface-solid);
  box-shadow:
    0 0 0 6px rgba(200, 170, 110, 0.6),
    0 0 0 11px rgba(10, 20, 36, 0.9),
    0 0 40px rgba(10, 200, 185, 0.25),
    0 18px 50px rgba(0, 0, 0, 0.6);
}

.wheel-pointer {
  position: absolute;
  top: -8px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 17px solid transparent;
  border-right: 17px solid transparent;
  border-top: 28px solid var(--gold);
  filter: drop-shadow(0 3px 4px rgba(0, 0, 0, 0.6));
  z-index: 2;
}

.wheel-wrap::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 17%;
  height: 17%;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, var(--gold-bright), var(--gold) 55%, #6f561f);
  box-shadow: 0 0 14px rgba(0, 0, 0, 0.7), inset 0 0 8px rgba(255, 255, 255, 0.3);
  z-index: 1;
}

/* ===== チーム結果 ===== */
.teams {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 16px;
  align-items: stretch;
}

.team {
  border-radius: 14px;
  padding: 20px 16px;
  min-height: 280px;
}

.team-blue {
  background: linear-gradient(180deg, rgba(47, 155, 255, 0.22) 0%, rgba(10, 42, 82, 0.25) 100%);
  border: 1px solid rgba(47, 155, 255, 0.6);
  box-shadow: 0 0 30px rgba(47, 155, 255, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.team-red {
  background: linear-gradient(180deg, rgba(255, 71, 87, 0.22) 0%, rgba(74, 15, 28, 0.25) 100%);
  border: 1px solid rgba(255, 71, 87, 0.6);
  box-shadow: 0 0 30px rgba(255, 71, 87, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.team-title {
  font-family: var(--display);
  text-align: center;
  font-size: 1.4rem;
  font-weight: 900;
  letter-spacing: 0.12em;
  margin-bottom: 18px;
}

.team-blue .team-title {
  color: #9fd2ff;
  text-shadow: 0 0 16px rgba(47, 155, 255, 0.6);
}

.team-red .team-title {
  color: #ffaab2;
  text-shadow: 0 0 16px rgba(255, 71, 87, 0.6);
}

.team-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.team-list li {
  background: rgba(5, 10, 20, 0.45);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 8px;
  padding: 12px 16px;
  font-size: 1.05rem;
  font-weight: 500;
  text-align: center;
  animation: pop 0.35s ease backwards;
}

@keyframes pop {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.88);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.vs {
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--display);
  font-size: 1.7rem;
  font-weight: 900;
  color: var(--gold);
  text-shadow: 0 0 14px rgba(200, 170, 110, 0.5);
}

/* ===== フッター ===== */
.footer {
  text-align: center;
  padding: 20px 16px 28px;
  color: var(--text-faint);
  font-size: 0.82rem;
}

/* ===== レスポンシブ ===== */
@media (max-width: 600px) {
  .roster {
    grid-template-columns: 1fr;
  }
  .teams {
    grid-template-columns: 1fr;
  }
  .vs {
    padding: 6px 0;
  }
  .input-section,
  .result-section {
    padding: 18px;
  }
}
