/* ============================================================
   共通: デザイントークン
   ============================================================ */
/* 配色・角丸・タイポは gmaker (slate + pink) の作法に合わせている */
:root {
  --color-bg: #0f172a;
  --color-surface: #1e293b;
  --color-surface-2: #334155;
  --color-text: #f1f5f9;
  --color-muted: #94a3b8;
  /* accent は文字色にも使うので明るいピンク。塗り面は accent-fill + 白文字 */
  --color-accent: #f472b6;
  --color-accent-fill: #db2777;
  --color-accent-2: #6366f1;
  --color-ok: #34d399;
  --color-danger: #ef4444;
  --color-border: #334155;
  /* Player/Admin のヘッダー・フッター共通グラデーション（VS魂暖色系、目に優しめのトーン） */
  --header-gradient: linear-gradient(120deg, #ea580c, #db2777);
  --radius: 12px;
  --radius-lg: 16px;
  --shadow: 0 12px 32px rgba(0, 0, 0, 0.24);
  --font: 'LINE Seed JP', 'Hiragino Kaku Gothic ProN', 'Noto Sans JP', 'Yu Gothic', sans-serif;
  --team-0: #e5484d;
  --team-1: #4a90d9;
  --team-2: #3ecf6f;
  --team-3: #f39c12;
  --team-4: #9b59b6;
  --team-5: #1abc9c;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.6;
  color: var(--color-text);
  background: var(--color-bg);
  font-synthesis: none;
}

/* 見出しは太く詰め気味、英字ラベルは大文字＋広めのトラッキング（gmaker の作法） */
h1,
h2,
h3 {
  font-weight: 900;
  letter-spacing: -0.02em;
}

button {
  font-family: inherit;
  font-size: 16px;
  border: none;
  border-radius: var(--radius);
  padding: 12px 20px;
  min-height: 22px;
  cursor: pointer;
  background: var(--color-accent-2);
  color: #fff;
  transition: background .15s ease, box-shadow .15s ease, transform .15s ease;
}

button:not(:disabled):hover {
  transform: translateY(-1px);
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
a:focus-visible,
summary:focus-visible {
  outline: 3px solid rgb(249 115 22 / 55%);
  outline-offset: 2px;
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

button.primary {
  background: var(--color-accent-fill);
  color: #fff;
  font-weight: 900;
}

button.danger {
  background: var(--color-danger);
}

button.ghost {
  background: var(--color-surface-2);
  color: var(--color-text);
}

input,
select,
textarea {
  font-family: inherit;
  font-size: 16px;
  color: var(--color-text);
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 10px 12px;
  min-height: 22px;
  width: 100%;
}

input[type="color"] {
  padding: 4px;
  width: 56px;
  min-height: 40px;
  cursor: pointer;
}

label {
  display: block;
  margin: 12px 0 4px;
  font-size: 14px;
  color: var(--color-muted);
}

.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 20px;
  margin: 16px 0;
}

.hidden {
  display: none !important;
}

.muted {
  color: var(--color-muted);
  font-size: 14px;
}

.error-text {
  color: var(--color-danger);
  font-size: 14px;
  min-height: 1.4em;
}

/* 接続状態バナー（全画面共通・常設） */
#conn-status {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  text-align: center;
  font-size: 14px;
  padding: 6px;
  background: var(--color-danger);
  color: #fff;
}

#conn-status.connected {
  display: none;
}

#conn-status.reconnected {
  background: var(--color-ok);
}

/* チームカラー */
.team-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 13px;
  color: #fff;
}

.team-color-0 {
  background: var(--team-0);
}

.team-color-1 {
  background: var(--team-1);
}

.team-color-2 {
  background: var(--team-2);
}

.team-color-3 {
  background: var(--team-3);
}

.team-color-4 {
  background: var(--team-4);
}

.team-color-5 {
  background: var(--team-5);
}

/* ============================================================
   共通: 配置枠の中身（Player の縦積みBOXと OBS のスロットで共有）
   Player 固有の見た目は player.css、OBS 固有は下の OBS セクション。
   ============================================================ */
.slot-rank {
  flex: 0 0 32px;
  text-align: center;
  font-weight: bold;
  color: var(--color-accent);
}

.slot-text {
  flex: 1 1 auto;
  font-size: 15px;
  overflow-wrap: anywhere;
}

.text-button {
  min-height: 22px;
  padding: 6px 10px;
  background: transparent;
  color: var(--color-muted);
  text-decoration: underline;
}

.discord-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  border-radius: var(--radius);
  padding: 10px 16px;
  background: #5865f2;
  color: #fff;
  font-size: 16px;
  font-weight: 800;
  text-decoration: none;
}

.discord-button:hover {
  background: #4752c4;
}

.discord-button[aria-disabled="true"] {
  pointer-events: none;
  opacity: .5;
}

.discord-profile {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 10px;
}

.discord-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
}

.fixed-team {
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 12px;
  color: var(--color-text);
  font-weight: 700;
}

.full-width {
  width: 100%;
}

/* ============================================================
   Admin: 運営操作
   ============================================================ */
.admin-page main {
  max-width: 720px;
  margin: 0 auto;
  padding: 24px 16px 80px;
}

.admin-page h1 {
  font-size: 22px;
}

.admin-page h2 {
  font-size: 18px;
  border-bottom: 1px solid var(--color-border);
  padding-bottom: 6px;
}

.choice-row {
  display: grid;
  grid-template-columns: 44px 1fr 100px;
  gap: 8px;
  align-items: center;
  margin: 8px 0;
}

.choice-row img {
  width: 44px;
  height: 44px;
  object-fit: cover;
  border-radius: 6px;
  background: var(--color-surface-2);
}

.choice-explanation-input {
  grid-column: 1 / -1;
  resize: vertical;
  min-height: 40px;
}

.choice-image-hint {
  grid-column: 1 / -1;
  font-size: 12px;
}

.control-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin: 12px 0;
}

.status-line {
  font-size: 18px;
}

.status-line strong {
  color: var(--color-accent);
}

.admin-header,
.score-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.admin-header {
  margin: 8px 0 20px;
}

.admin-header h1 {
  margin: 0;
}

.eyebrow {
  margin: 0;
  color: var(--color-accent);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

.status-chip,
.count-badge {
  border: 1px solid var(--color-border);
  border-radius: 999px;
  padding: 4px 10px;
  color: var(--color-muted);
  font-size: 13px;
}

.status-chip.ok {
  border-color: var(--color-ok);
  color: var(--color-ok);
}

.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

fieldset {
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  margin: 16px 0;
  padding: 12px;
}

legend {
  padding: 0 6px;
  font-weight: bold;
}

details>summary {
  cursor: pointer;
  font-size: 18px;
  font-weight: bold;
}

details[open]>summary {
  margin-bottom: 16px;
}

.choice-editor-row {
  grid-template-columns: 44px minmax(170px, 1.3fr) minmax(140px, 1fr) 84px;
}

.choice-editor-row input {
  min-width: 0;
}

.choice-number {
  text-align: center;
  color: var(--color-accent);
}

.empty-state {
  color: var(--color-muted);
  padding: 12px 0;
}

.score-row {
  border-bottom: 1px solid var(--color-border);
  padding: 10px 0;
}

.score-row:last-child {
  border-bottom: 0;
}

.score-row strong {
  color: var(--color-accent);
}

.toast {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 90;
  max-width: min(420px, calc(100vw - 32px));
  border-left: 4px solid var(--color-ok);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 12px 16px;
  background: var(--color-surface-2);
}

.toast[data-kind="error"] {
  border-left-color: var(--color-danger);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 680px) {

  .admin-header {
    align-items: stretch;
    flex-direction: column;
  }

  .field-grid {
    grid-template-columns: 1fr;
  }

  .choice-editor-row {
    grid-template-columns: 40px 1fr 72px;
  }

  .choice-editor-row input[type="file"] {
    grid-column: 2 / -1;
  }

  .choice-editor-row input[type="text"] {
    grid-column: 2;
  }

}

/* ============================================================
   Admin: OBSプレビュー・ダッシュボード（続き）
   OBS 本体のスタイルは obs.css（obs.html から読む）。
   ============================================================ */
.admin-page main.wide {
  max-width: 1400px;
}

.admin-console {
  display: grid;
  grid-template-columns: minmax(280px, 340px) minmax(320px, 1fr) minmax(340px, 440px);
  gap: 16px;
  align-items: start;
}

.admin-col {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.admin-col.card {
  display: block;
}

.action-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 12px 0;
}

.action-grid button {
  width: 100%;
}

/* OBSプレビュー: iframe は本番と同じ 1920x1080 のまま描き、枠幅に合わせて JS が縮小する */
.obs-preview {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #000;
  border-radius: var(--radius);
  overflow: hidden;
}

.obs-preview iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 1920px;
  height: 1080px;
  border: 0;
  transform-origin: top left;
  pointer-events: none;
}

.players-header,
.questions-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}

.tag-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 8px 0;
}

.question-filter-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.question-filter-label {
  flex: 0 0 48px;
  padding-top: 12px;
  color: var(--color-muted);
  font-size: 13px;
}

.question-filter-row .tag-chip-row {
  flex: 1;
}

.tag-chip {
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 13px;
  color: var(--color-text);
  background: var(--color-surface);
  cursor: pointer;
  border: 2px solid var(--color-border);
}

.tag-chip.active {
  box-shadow: 0 0 0 2px var(--color-accent);
}

.filter-count {
  margin-left: 6px;
  color: var(--color-muted);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 8px 0;
}

.tabs .tab {
  background: var(--color-surface-2);
  color: var(--color-muted);
  padding: 6px 12px;
  min-height: 36px;
  font-size: 13px;
}

.tabs .tab.active {
  background: var(--color-accent-fill);
  color: #fff;
  font-weight: 900;
}

.question-bank-card {
  display: flex;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--color-border);
}

.question-bank-card:last-child {
  border-bottom: 0;
}

.question-bank-card .qb-prompt {
  font-weight: bold;
  overflow-wrap: anywhere;
}

.question-bank-card .qb-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin: 4px 0;
}

.question-bank-card .qb-actions {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.question-bank-card .qb-actions button {
  padding: 6px 10px;
  min-height: 36px;
  font-size: 13px;
}

.question-bank-card input[type="checkbox"] {
  width: 22px;
  min-height: 22px;
  align-self: flex-start;
}

.file-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

@media (max-width: 1100px) {
  .admin-console {
    grid-template-columns: 1fr;
  }
}

.site-footer {
  padding: 16px;
  text-align: center;
  font-size: 12px;
  color: var(--color-muted);
}

.site-footer .footer-version {
  margin-left: 6px;
}
