/* KG Motors（kg-m.jp）ブランド — AI リバーシクラブ */

:root {
  --kg-yellow: #ffca28;
  --kg-yellow-dark: #f5b800;
  --kg-charcoal: #3a4049;
  --kg-charcoal-light: #525a66;
  --kg-bg: #f3f5f6;
  --kg-surface: #ffffff;
  --kg-border: #e5e7eb;
  --kg-text: #3a4049;
  --kg-muted: #6b7280;
  --kg-error: #dc2626;
  --kg-success: #059669;

  --bg: var(--kg-bg);
  --surface: var(--kg-surface);
  --border: var(--kg-border);
  --text: var(--kg-text);
  --muted: var(--kg-muted);
  --accent: var(--kg-yellow);
  --accent-hover: var(--kg-yellow-dark);
  --error: var(--kg-error);
  --success: var(--kg-success);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Noto Sans JP", "Hiragino Sans", system-ui, sans-serif;
  background: var(--kg-bg);
  color: var(--kg-text);
  line-height: 1.7;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a {
  color: var(--kg-charcoal);
  text-decoration: none;
  transition: color 0.2s ease;
}
a:hover {
  color: var(--kg-yellow-dark);
  text-decoration: underline;
}

.site-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 1.5rem;
  min-height: 64px;
  background: var(--kg-charcoal);
  box-shadow: 0 2px 8px rgba(58, 64, 73, 0.15);
  position: sticky;
  top: 0;
  z-index: 100;
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  color: #fff;
}
.logo:hover { text-decoration: none; color: #fff; }

.logo-img {
  height: 36px;
  width: auto;
  display: block;
}

.logo-text {
  font-family: Montserrat, "Noto Sans JP", sans-serif;
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--kg-yellow);
  white-space: nowrap;
}

@media (max-width: 640px) {
  .logo-text { display: none; }
  .site-header nav { gap: 0.65rem; font-size: 0.82rem; }
}

.site-header nav {
  display: flex;
  gap: 1.1rem;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.site-header nav a {
  color: rgba(255, 255, 255, 0.88);
  font-size: 0.88rem;
  font-weight: 500;
  text-decoration: none;
}
.site-header nav a:hover {
  color: var(--kg-yellow);
  text-decoration: none;
}

.user {
  color: var(--kg-yellow);
  font-size: 0.85rem;
  font-weight: 500;
}

.container {
  max-width: 1040px;
  margin: 0 auto;
  padding: 2rem 1.5rem 3rem;
  flex: 1;
  width: 100%;
}

.site-footer {
  background: var(--kg-charcoal);
  color: rgba(255, 255, 255, 0.75);
  padding: 1.5rem;
  text-align: center;
  font-size: 0.82rem;
  margin-top: auto;
}
.site-footer a {
  color: var(--kg-yellow);
  text-decoration: none;
}
.site-footer a:hover { text-decoration: underline; }
.site-footer p { margin: 0.25rem 0; }
.site-footer .footer-note {
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.5);
  margin-top: 0.5rem;
}

.hidden { display: none !important; }

/* 対戦依頼通知 — フッター付近の固定アイコン */
.footer-match-request {
  position: fixed;
  bottom: 1.25rem;
  right: 1.25rem;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 3rem;
  height: 3rem;
  border-radius: 50%;
  background: var(--kg-yellow);
  color: var(--kg-charcoal);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.28);
  text-decoration: none;
  transition: transform 0.15s ease;
}
.footer-match-request:hover {
  transform: scale(1.06);
  text-decoration: none;
  color: var(--kg-charcoal);
}
.footer-match-request-icon {
  flex-shrink: 0;
}
.footer-match-request-badge {
  position: absolute;
  top: -0.2rem;
  right: -0.2rem;
  min-width: 1.3rem;
  height: 1.3rem;
  padding: 0 0.35rem;
  border-radius: 999px;
  background: #d32f2f;
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1.3rem;
  text-align: center;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
}

.hero {
  text-align: center;
  padding: 3rem 1.5rem;
  background: var(--kg-surface);
  border-radius: 12px;
  border: 1px solid var(--kg-border);
  box-shadow: 0 4px 24px rgba(58, 64, 73, 0.06);
  margin-bottom: 2rem;
  position: relative;
  overflow: hidden;
}

.hero::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: var(--kg-yellow);
}

.hero h1 {
  font-family: Montserrat, "Noto Sans JP", sans-serif;
  font-size: clamp(1.6rem, 4vw, 2.25rem);
  font-weight: 700;
  margin: 0 0 0.75rem;
  color: var(--kg-charcoal);
  letter-spacing: 0.02em;
}

.hero p, .hero-lead { color: var(--kg-muted); max-width: 560px; margin: 0 auto; }

.news-section { margin-bottom: 2rem; }
.news-section h2 {
  font-family: Montserrat, "Noto Sans JP", sans-serif;
  font-size: 0.85rem;
  letter-spacing: 0.12em;
  color: var(--kg-muted);
  margin: 0 0 1rem;
}
.news-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.news-item {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
  padding: 1rem 0;
  border-top: 1px solid var(--kg-border);
}
.news-item:first-child { border-top: none; padding-top: 0; }
.news-date {
  flex-shrink: 0;
  font-size: 0.8rem;
  color: var(--kg-muted);
  font-variant-numeric: tabular-nums;
  min-width: 5.5rem;
}
.news-title {
  margin: 0 0 0.5rem;
  font-size: 1.05rem;
  color: var(--kg-charcoal);
}
.news-body p { margin: 0.5rem 0; color: var(--kg-muted); }
.news-body ul {
  margin: 0.5rem 0;
  padding-left: 1.25rem;
  color: var(--kg-muted);
}
.news-body li { margin: 0.25rem 0; }

.actions {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
  margin-top: 2rem;
  flex-wrap: wrap;
}

.btn {
  display: inline-block;
  padding: 0.65rem 1.35rem;
  border-radius: 6px;
  border: 1px solid var(--kg-border);
  background: var(--kg-surface);
  color: var(--kg-charcoal);
  cursor: pointer;
  font-size: 0.92rem;
  font-weight: 500;
  text-decoration: none;
  transition: all 0.2s ease;
  font-family: inherit;
}

.btn:hover {
  border-color: var(--kg-charcoal-light);
  text-decoration: none;
  color: var(--kg-charcoal);
}

.btn.primary {
  background: var(--kg-yellow);
  border-color: var(--kg-yellow);
  color: var(--kg-charcoal);
  font-weight: 600;
}

.btn.primary:hover {
  background: var(--kg-yellow-dark);
  border-color: var(--kg-yellow-dark);
  color: var(--kg-charcoal);
  text-decoration: none;
}

.btn.small { padding: 0.35rem 0.75rem; font-size: 0.82rem; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.card {
  background: var(--kg-surface);
  border: 1px solid var(--kg-border);
  border-radius: 10px;
  padding: 1.35rem 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: 0 2px 12px rgba(58, 64, 73, 0.04);
}

.card h2 {
  margin-top: 0;
  font-size: 1.05rem;
  font-family: Montserrat, "Noto Sans JP", sans-serif;
  font-weight: 600;
  color: var(--kg-charcoal);
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--kg-yellow);
  display: inline-block;
  margin-bottom: 1rem;
}

.form label {
  display: block;
  margin-bottom: 1rem;
  color: var(--kg-muted);
  font-size: 0.88rem;
  font-weight: 500;
}

.form input, .form select {
  display: block;
  width: 100%;
  max-width: 360px;
  margin-top: 0.35rem;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--kg-border);
  border-radius: 6px;
  background: var(--kg-surface);
  color: var(--kg-text);
  font-family: inherit;
  transition: border-color 0.2s;
}

.form input:focus, .form select:focus {
  outline: none;
  border-color: var(--kg-yellow);
  box-shadow: 0 0 0 3px rgba(255, 202, 40, 0.25);
}

.mono, code, pre {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 0.88rem;
}

.api-key {
  word-break: break-all;
  background: var(--kg-bg);
  padding: 0.75rem;
  border-radius: 6px;
  border: 1px solid var(--kg-border);
}

.hint { color: var(--kg-muted); font-size: 0.85rem; }
.error { color: var(--kg-error); }
.success { color: var(--kg-success); }
.turn { color: var(--kg-yellow-dark); margin-left: 0.5rem; font-weight: 600; }

h1 {
  font-family: Montserrat, "Noto Sans JP", sans-serif;
  font-weight: 700;
  color: var(--kg-charcoal);
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.table th {
  background: var(--kg-bg);
  color: var(--kg-charcoal);
  font-weight: 600;
  font-size: 0.82rem;
}

.table th, .table td {
  border-bottom: 1px solid var(--kg-border);
  padding: 0.7rem 0.5rem;
  text-align: left;
}

.table tbody tr:hover { background: rgba(255, 202, 40, 0.06); }

.steps ol { color: var(--kg-muted); padding-left: 1.25rem; }
.steps li { margin-bottom: 0.5rem; }
.steps h2 {
  font-family: Montserrat, "Noto Sans JP", sans-serif;
  color: var(--kg-charcoal);
}

pre {
  background: var(--kg-bg);
  padding: 1rem;
  border-radius: 6px;
  overflow-x: auto;
  border: 1px solid var(--kg-border);
}

.spec-header { margin-bottom: 1.5rem; }
.spec-header h1 { margin-top: 0; }
.spec-header .actions { display: flex; gap: 0.75rem; flex-wrap: wrap; margin-top: 1rem; }

.spec-body { line-height: 1.7; }
.spec-body h1 { font-size: 1.6rem; margin-top: 0; }
.spec-body h2 {
  font-size: 1.2rem;
  margin-top: 2rem;
  border-bottom: 2px solid var(--kg-yellow);
  padding-bottom: 0.35rem;
  color: var(--kg-charcoal);
}
.spec-body h3 { font-size: 1.05rem; margin-top: 1.5rem; color: var(--kg-charcoal-light); }
.spec-body p { color: var(--kg-muted); }
.spec-body li { color: var(--kg-muted); margin-left: 1.25rem; margin-bottom: 0.35rem; }
.spec-body hr { border: none; border-top: 1px solid var(--kg-border); margin: 1.5rem 0; }
.spec-body code {
  background: var(--kg-bg);
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  font-size: 0.88em;
  color: var(--kg-charcoal);
}
.spec-body pre { border: 1px solid var(--kg-border); margin: 0.75rem 0 1rem; }
.spec-body pre code { background: none; padding: 0; }
.spec-table {
  width: 100%;
  border-collapse: collapse;
  margin: 1rem 0;
  font-size: 0.9rem;
}
.spec-table th, .spec-table td {
  border: 1px solid var(--kg-border);
  padding: 0.5rem 0.75rem;
  text-align: left;
}
.spec-table th { background: var(--kg-bg); color: var(--kg-charcoal); }
.spec-table td { color: var(--kg-muted); }

.live-page h1 { margin-top: 0; }
.live-header { margin-bottom: 1.25rem; }
.live-status { color: var(--kg-charcoal-light); font-size: 1.05rem; font-weight: 500; }
.live-viewers {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  margin: 0.5rem 0 0;
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  background: rgba(255, 202, 40, 0.18);
  border: 1px solid var(--kg-yellow);
  color: var(--kg-charcoal);
  font-size: 0.95rem;
  font-weight: 600;
}
.live-viewers-dot {
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 50%;
  background: #e53935;
  box-shadow: 0 0 0 0 rgba(229, 57, 53, 0.55);
  animation: live-viewer-pulse 1.6s ease-out infinite;
}
.viewer-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin-top: 0.25rem;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  background: rgba(255, 202, 40, 0.15);
  border: 1px solid var(--kg-yellow);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--kg-charcoal);
}
.viewer-badge-dot {
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 50%;
  background: #e53935;
}
@keyframes live-viewer-pulse {
  0% { box-shadow: 0 0 0 0 rgba(229, 57, 53, 0.55); }
  70% { box-shadow: 0 0 0 0.45rem rgba(229, 57, 53, 0); }
  100% { box-shadow: 0 0 0 0 rgba(229, 57, 53, 0); }
}
.live-grid {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 1.25rem;
  align-items: start;
}
@media (max-width: 900px) { .live-grid { grid-template-columns: 1fr; } }
.live-badge {
  font-size: 0.75rem;
  background: var(--kg-bg);
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  color: var(--kg-muted);
}
.live-turn { color: var(--kg-charcoal); font-weight: 500; min-height: 1.5em; }
.live-score {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 1.5rem;
  flex-wrap: wrap;
}
.score-name { font-size: 0.95rem; color: var(--kg-muted); }
.live-score .player-with-avatar { font-size: 0.95rem; }
.score-num { font-weight: 700; font-size: 2rem; color: var(--kg-charcoal); }
.score-sep { color: var(--kg-muted); }

.othello-board-wrap { margin: 0.5rem auto; max-width: 440px; }
.othello-coords-grid {
  display: grid;
  grid-template-columns: minmax(1.4rem, auto) 1fr minmax(1.4rem, auto);
  grid-template-rows: auto 1fr auto;
  gap: 0.15rem 0.3rem;
  align-items: stretch;
}
.othello-corner {
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--kg-charcoal);
  line-height: 1.2;
  align-self: center;
}
.othello-corner-tl { grid-column: 1; grid-row: 1; }
.othello-corner-tr { grid-column: 3; grid-row: 1; text-align: right; }
.othello-corner-bl { grid-column: 1; grid-row: 3; }
.othello-corner-br { grid-column: 3; grid-row: 3; text-align: right; }
.othello-coords {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  text-align: center;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--kg-muted);
  gap: 2px;
}
.othello-coords-top { grid-column: 2; grid-row: 1; align-self: end; }
.othello-coords-bottom { grid-column: 2; grid-row: 3; align-self: start; }
.othello-coords-left,
.othello-coords-right {
  grid-template-columns: 1fr;
  grid-template-rows: repeat(8, 1fr);
  align-items: center;
  justify-items: center;
}
.othello-coords-left { grid-column: 1; grid-row: 2; }
.othello-coords-right { grid-column: 3; grid-row: 2; }
.othello-board-host {
  grid-column: 2;
  grid-row: 2;
  min-width: 0;
}
.othello-board-host .othello-board,
.othello-board-host .replay-board {
  width: 100%;
}
.othello-board {
  --othello-line: #0a4a2c;
  --othello-cell: #1a6b40;
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  aspect-ratio: 1;
  background: var(--othello-line);
  border: 3px solid #0d3d24;
  border-radius: 4px;
  gap: 2px;
  padding: 2px;
  box-sizing: border-box;
}
.othello-cell {
  background: var(--othello-cell);
  border-radius: 2px;
  aspect-ratio: 1;
  margin: 0;
  box-sizing: border-box;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.12);
}
.othello-cell.black,
.othello-cell.white {
  border-radius: 50%;
  margin: 9%;
  box-shadow: none;
}
.othello-cell.black {
  background: radial-gradient(circle at 30% 30%, #555, #111);
  box-shadow: inset 0 0 2px rgba(255,255,255,0.2);
}
.othello-cell.white {
  background: radial-gradient(circle at 30% 30%, #fff, #ccc);
  box-shadow: inset 0 0 2px rgba(0,0,0,0.2);
}

.live-connections { display: flex; flex-direction: column; gap: 0.75rem; }
.conn-card {
  border: 1px solid var(--kg-border);
  border-radius: 8px;
  padding: 0.75rem;
  background: var(--kg-bg);
}
.conn-card.conn-online { border-color: var(--kg-success); }
.conn-card.conn-stale { border-color: var(--kg-yellow); }
.conn-card.conn-offline { border-color: var(--kg-border); opacity: 0.85; }
.conn-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.35rem; gap: 0.5rem; }
.conn-head .player-with-avatar strong { font-weight: 600; color: var(--kg-charcoal); }
.conn-badge {
  font-size: 0.75rem;
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  background: var(--kg-surface);
}
.conn-online .conn-badge { color: var(--kg-success); }
.conn-stale .conn-badge { color: var(--kg-yellow-dark); }
.conn-offline .conn-badge { color: var(--kg-muted); }
.conn-meta { font-size: 0.82rem; color: var(--kg-muted); margin-top: 0.2rem; }

.live-ai-setup { font-size: 0.78rem; line-height: 1.5; word-break: break-all; }
.live-ai-setup p { margin: 0.5rem 0; }
.live-moves {
  list-style: none;
  padding: 0;
  margin: 0.75rem 0 0;
  max-height: 120px;
  overflow-y: auto;
  font-size: 0.85rem;
}
.live-moves li { padding: 0.25rem 0; border-bottom: 1px solid var(--kg-border); color: var(--kg-muted); }
.live-move-item {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
}
.live-move-item .player-with-avatar strong { color: var(--kg-charcoal); font-weight: 600; }

.stats-grid { display: flex; gap: 1.5rem; flex-wrap: wrap; margin: 0.5rem 0; }
.stat-box { text-align: center; min-width: 4rem; }
.stat-num {
  display: block;
  font-size: 2rem;
  font-weight: 700;
  color: var(--kg-charcoal);
  font-family: Montserrat, sans-serif;
}
.stat-label { font-size: 0.85rem; color: var(--kg-muted); }
.ranking-table td:first-child { color: var(--kg-muted); width: 3rem; }
.avatar-cell {
  width: 3rem;
  padding: 0.45rem 0.5rem 0.25rem 0;
  vertical-align: middle;
  overflow: visible;
}

.avatar-with-crown,
.avatar-badged {
  position: relative;
  display: inline-block;
  vertical-align: middle;
}
.avatar-badged .user-avatar,
.avatar-badged .avatar-fallback,
.avatar-with-mantle .user-avatar,
.avatar-with-mantle .avatar-fallback {
  position: relative;
  z-index: 1;
}
.avatar-badged.has-crown .rank-crown,
.avatar-with-crown .rank-crown {
  position: absolute;
  top: -2px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 2;
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.22));
  pointer-events: none;
}
.avatar-with-crown {
  padding-top: 0.45rem;
}
.rank-crown {
  position: absolute;
  top: -2px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 2;
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.22));
  pointer-events: none;
}
.avatar-crown-size-lg { padding-top: 0.65rem; }
.avatar-crown-size-lg .rank-crown { width: 32px; height: 18px; top: -4px; }
.avatar-crown-size-sm,
.avatar-badge-size-sm { padding-top: 0.45rem; }
.avatar-badged.avatar-badge-size-sm.has-crown { padding-top: 0.45rem; }
.avatar-crown-size-xs,
.avatar-badge-size-xs { padding-top: 0.35rem; }
.avatar-badged.avatar-badge-size-xs.has-crown { padding-top: 0.35rem; }
.avatar-crown-size-xs .rank-crown,
.avatar-badge-size-xs .rank-crown,
.avatar-badged.avatar-badge-size-xs.has-crown .rank-crown { width: 14px; height: 9px; top: 0; }
.avatar-crown-size-nav,
.avatar-badge-size-nav { padding-top: 0.35rem; margin-right: 0.35rem; }
.avatar-badged.avatar-badge-size-nav.has-crown { padding-top: 0.35rem; }
.avatar-crown-size-nav .rank-crown,
.avatar-badge-size-nav .rank-crown,
.avatar-badged.avatar-badge-size-nav.has-crown .rank-crown { width: 16px; height: 10px; top: 0; }
.avatar-badge-size-lg { padding-top: 0.65rem; }
.avatar-badged.avatar-badge-size-lg.has-crown { padding-top: 0.65rem; }
.avatar-badge-size-lg .rank-crown,
.avatar-badged.avatar-badge-size-lg.has-crown .rank-crown { width: 32px; height: 18px; top: -4px; }

/* オセロ評価ランキング — 1〜3位マント */
.avatar-with-mantle,
.avatar-badged.has-mantle {
  position: relative;
  display: inline-block;
  vertical-align: middle;
}
.avatar-badged.has-mantle .rank-mantle,
.avatar-with-mantle .rank-mantle {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -46%);
  z-index: 0;
  pointer-events: none;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.2));
}
.rank-mantle {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -46%);
  z-index: 0;
  pointer-events: none;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.2));
}
.avatar-badge-size-sm .rank-mantle,
.avatar-badged.avatar-badge-size-sm.has-mantle .rank-mantle { width: 46px; height: auto; }
.avatar-badge-size-xs .rank-mantle,
.avatar-badged.avatar-badge-size-xs.has-mantle .rank-mantle { width: 34px; height: auto; transform: translate(-50%, -44%); }
.avatar-badge-size-nav .rank-mantle,
.avatar-badged.avatar-badge-size-nav.has-mantle .rank-mantle { width: 38px; height: auto; transform: translate(-50%, -44%); }
.avatar-badge-size-lg .rank-mantle,
.avatar-badged.avatar-badge-size-lg.has-mantle .rank-mantle { width: 148px; height: auto; transform: translate(-50%, -42%); }

.nav-user .avatar-with-crown,
.nav-user .avatar-badged { margin-right: 0.35rem; }
.history-players {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin: 0.5rem 0;
}
.schedule-players-cell { min-width: 14rem; }

.user-avatar {
  display: inline-block;
  border-radius: 50%;
  object-fit: cover;
  vertical-align: middle;
  background: var(--kg-bg);
  border: 2px solid var(--kg-border);
}
.user-avatar-lg { width: 128px; height: 128px; }
.user-avatar-sm { width: 40px; height: 40px; }
.user-avatar-nav { width: 32px; height: 32px; margin-right: 0.35rem; }
.user-avatar-xs { width: 28px; height: 28px; }
.avatar-fallback {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--kg-yellow), #e6b800);
  color: var(--kg-charcoal);
  font-weight: 700;
  font-family: Montserrat, sans-serif;
  border: 2px solid var(--kg-border);
}
.user-avatar-lg.avatar-fallback { width: 128px; height: 128px; font-size: 3rem; }
.user-avatar-sm.avatar-fallback { width: 40px; height: 40px; font-size: 1rem; }
.user-avatar-nav.avatar-fallback { width: 32px; height: 32px; font-size: 0.85rem; margin-right: 0.35rem; }
.user-avatar-xs.avatar-fallback { width: 28px; height: 28px; font-size: 0.75rem; }

.player-with-avatar {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  vertical-align: middle;
}
.player-with-avatar a {
  color: inherit;
  text-decoration: none;
  font-weight: 500;
}
.player-with-avatar a:hover { text-decoration: underline; }

.schedule-players { min-width: 14rem; }
.schedule-players .player-with-avatar { margin-right: 0.1rem; }
.schedule-vs {
  margin: 0 0.45rem;
  color: var(--kg-muted);
  font-size: 0.85rem;
  font-weight: 600;
}

.profile-header {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  margin-bottom: 1rem;
}
.profile-header-page { margin-bottom: 1.5rem; }
.profile-header h1, .profile-header h2 { margin: 0 0 0.35rem; }
.profile-meta .hint { margin: 0; }
.avatar-form { margin-top: 0.5rem; }
.mail-notice {
  margin: 0.75rem 0 1rem;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  border: 1px solid rgba(255, 202, 40, 0.45);
  background: rgba(255, 202, 40, 0.12);
  font-size: 0.9rem;
  color: var(--kg-charcoal);
  line-height: 1.6;
}
.mail-notice strong { font-weight: 600; }
.nav-user {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  text-decoration: none;
  color: inherit;
  margin-right: 0.75rem;
}
.nav-user:hover .user { color: var(--kg-charcoal); }

.schedule-table td { vertical-align: top; }
.schedule-actions { white-space: nowrap; }
.schedule-actions .btn { margin: 0.1rem 0; }
.schedule-badge {
  display: inline-block;
  font-size: 0.78rem;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  background: var(--kg-bg);
  font-weight: 500;
}
.schedule-badge.schedule-active { color: var(--kg-success); border: 1px solid var(--kg-success); }
.schedule-badge.schedule-scheduled { color: var(--kg-charcoal); border: 1px solid var(--kg-yellow); background: rgba(255,202,40,0.15); }
.schedule-badge.schedule-pending { color: var(--kg-charcoal); border: 1px solid var(--kg-orange, #ff9800); background: rgba(255,152,0,0.12); }
.schedule-badge.schedule-finished { color: var(--kg-muted); border: 1px solid var(--kg-border); }
.inline-form { display: inline; margin: 0; }

.history-page h1 { margin-top: 0; }
.history-id { font-size: 0.8rem; color: var(--kg-muted); }
.timeline {
  list-style: none;
  padding: 0;
  margin: 0;
  border-left: 3px solid var(--kg-yellow);
  margin-left: 0.5rem;
}
.timeline li {
  padding: 0.5rem 0 0.5rem 1rem;
  position: relative;
  color: var(--kg-muted);
  font-size: 0.9rem;
}
.timeline li::before {
  content: '';
  position: absolute;
  left: -6px;
  top: 0.85rem;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--kg-border);
}
.timeline-move::before { background: var(--kg-yellow); }
.timeline-round_end::before, .timeline-match_end::before { background: var(--kg-charcoal); }
.timeline li time { display: block; font-size: 0.75rem; color: var(--kg-muted); }
.timeline li strong { color: var(--kg-charcoal); margin-right: 0.35rem; }

.round-layout {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 1.5rem;
  align-items: start;
}
@media (max-width: 600px) { .round-layout { grid-template-columns: 1fr; } }
.mini-board {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  width: 160px;
  aspect-ratio: 1;
  background: #1a6b40;
  border: 2px solid #0d3d24;
  gap: 1px;
  padding: 2px;
  border-radius: 4px;
}
.mini-cell { background: #1a6b40; border-radius: 50%; margin: 15%; }
.mini-cell.black { background: #222; }
.mini-cell.white { background: #eee; }
.round-moves ol {
  margin: 0;
  padding-left: 1.25rem;
  font-size: 0.85rem;
  max-height: 200px;
  overflow-y: auto;
}
.round-moves li { margin: 0.2rem 0; color: var(--kg-muted); }
.round-moves li.replay-move-item { cursor: pointer; border-radius: 4px; padding: 0.15rem 0.35rem; margin-left: -0.35rem; }
.round-moves li.replay-move-item:hover { background: rgba(255, 202, 40, 0.2); }
.round-moves li.replay-move-item.active { background: rgba(255, 202, 40, 0.35); color: var(--kg-charcoal); font-weight: 500; }

.replay-root { width: 100%; }
.replay-mode-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}
.replay-mode-btn.active {
  background: var(--kg-yellow);
  border-color: var(--kg-yellow);
  color: var(--kg-charcoal);
  font-weight: 600;
}
.replay-move-full-only[hidden] { display: none; }
.replay-panel {
  width: min(100%, 320px);
  min-width: 260px;
}
.replay-root .replay-board {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  width: 100%;
  max-width: 320px;
  aspect-ratio: 1;
}
/* ライブ盤面と同じマス目・石の描画 */
.replay-root .replay-board.othello-board .othello-cell.black {
  background: radial-gradient(circle at 30% 30%, #555, #111);
  box-shadow: inset 0 0 2px rgba(255, 255, 255, 0.2);
}
.replay-root .replay-board.othello-board .othello-cell.white {
  background: radial-gradient(circle at 30% 30%, #fff, #ccc);
  box-shadow: inset 0 0 2px rgba(0, 0, 0, 0.2);
}
.replay-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.75rem;
  flex-wrap: wrap;
}
.replay-slider { flex: 1; min-width: 100px; accent-color: var(--kg-yellow); }
.replay-count { font-size: 0.85rem; color: var(--kg-muted); font-variant-numeric: tabular-nums; }
.replay-status { margin: 0.5rem 0 0; min-height: 1.25em; }
.replay-status.replay-error { color: var(--kg-error, #c62828); font-weight: 500; }
.replay-divergence-notice {
  margin: 0 0 0.75rem;
  padding: 0.65rem 0.85rem;
  border-radius: 8px;
  background: #fff8e1;
  border: 1px solid #ffca28;
  color: #6d4c00;
  font-size: 0.88rem;
  line-height: 1.45;
}
.round-moves li.replay-move-unavailable {
  opacity: 0.55;
  text-decoration: line-through;
  text-decoration-color: rgba(198, 40, 40, 0.45);
}
.round-moves li.replay-move-unavailable:hover {
  background: rgba(198, 40, 40, 0.08);
}

.test-page h1 { margin-top: 0; }
.test-status { font-size: 1.1rem; margin: 0.5rem 0 1rem; font-weight: 500; }
.test-status.status-passed { color: var(--kg-success); }
.test-status.status-failed, .test-status.status-expired { color: var(--kg-error); }
.test-status.status-running { color: var(--kg-charcoal-light); }
.test-checks { list-style: none; padding: 0; margin: 0; }
.test-check {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  padding: 0.45rem 0;
  border-bottom: 1px solid var(--kg-border);
  font-size: 0.9rem;
  color: var(--kg-muted);
}
.test-check.done { color: var(--kg-text); }
.test-check .check-icon { width: 1.2rem; font-weight: bold; }
.test-check.done .check-icon { color: var(--kg-success); }
.check-at { margin-left: auto; font-size: 0.75rem; }
.test-command {
  display: block;
  background: var(--kg-bg);
  padding: 0.75rem;
  border-radius: 6px;
  font-size: 0.82rem;
  word-break: break-all;
  margin-top: 0.5rem;
  border: 1px solid var(--kg-border);
}

/* --- 管理画面 --- */
.admin-body { background: #f5f5f5; }
.admin-header { background: #2c2c2c; }
.admin-header .logo-text { color: #fff; }
.admin-header nav a { color: #ddd; }
.admin-container { max-width: 1100px; }
.admin-login-form { max-width: 360px; }
.admin-table input[type="text"],
.admin-table input[type="password"],
.admin-table input[type="email"] {
  font-size: 0.85rem;
  padding: 0.25rem 0.4rem;
  max-width: 140px;
}
.admin-table input[type="email"] { max-width: 220px; }
.admin-inline-form { display: inline-flex; gap: 0.35rem; align-items: center; flex-wrap: wrap; margin: 0.15rem 0; }
.admin-actions { min-width: 220px; }
.admin-match-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.25rem;
  align-items: center;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--kg-border);
}
.admin-bulk-delete-form { flex: 1 1 auto; min-width: 280px; }
.admin-match-selected-count { margin-left: 0.25rem; white-space: nowrap; }
.admin-col-check { width: 2.5rem; text-align: center; vertical-align: middle; }
.admin-match-table .admin-match-check { width: 1rem; height: 1rem; cursor: pointer; }
.admin-row-test-bot { background: rgba(255, 193, 7, 0.08); }
.btn-danger { color: var(--kg-error); border-color: var(--kg-error); }
.btn-danger:hover { background: var(--kg-error); color: #fff; }

/* --- オセロ分析 --- */
.analytics-card { overflow: hidden; }
.analytics-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 0.25rem;
}
.analytics-header h2 { margin: 0; }
.rating-badge {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 4.5rem;
  padding: 0.5rem 1rem;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--kg-yellow), #e6b800);
  color: var(--kg-charcoal);
  box-shadow: 0 2px 12px rgba(255, 193, 7, 0.35);
}
.rating-num {
  font-family: Montserrat, sans-serif;
  font-size: 2rem;
  font-weight: 700;
  line-height: 1;
}
.rating-label { font-size: 0.72rem; font-weight: 600; opacity: 0.85; }
.rating-inline { color: var(--kg-charcoal); font-family: Montserrat, sans-serif; }
a .rating-inline { color: var(--kg-charcoal); text-decoration: none; }
a:hover .rating-inline { text-decoration: underline; }

.analytics-metrics {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin: 1rem 0 1.25rem;
}
.metric-box {
  flex: 1 1 6rem;
  min-width: 5.5rem;
  padding: 0.65rem 0.75rem;
  border-radius: 8px;
  background: var(--kg-bg);
  border: 1px solid var(--kg-border);
  text-align: center;
}
.metric-num {
  display: block;
  font-family: Montserrat, sans-serif;
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--kg-charcoal);
}
.metric-label { font-size: 0.75rem; color: var(--kg-muted); }
.metric-warn { border-color: #ef9a9a; background: #fff5f5; }
.metric-warn .metric-num { color: #c62828; }

.analytics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
}
.analytics-panel {
  padding: 1rem;
  border-radius: 10px;
  border: 1px solid var(--kg-border);
  background: var(--kg-surface);
}
.analytics-panel-wide { grid-column: 1 / -1; }
.analytics-panel h3 {
  margin: 0 0 0.75rem;
  font-size: 0.95rem;
  color: var(--kg-charcoal);
}
.chart-hint { margin: -0.35rem 0 0.5rem !important; font-size: 0.75rem !important; }
.chart-empty {
  color: var(--kg-muted);
  font-size: 0.85rem;
  padding: 1rem 0;
  text-align: center;
}

.chart-donut-wrap { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.chart-legend { display: flex; flex-direction: column; gap: 0.35rem; font-size: 0.82rem; }
.chart-legend-item { display: flex; align-items: center; gap: 0.4rem; }
.chart-legend-swatch {
  width: 0.65rem;
  height: 0.65rem;
  border-radius: 2px;
  flex-shrink: 0;
}

.chart-hbars { display: flex; flex-direction: column; gap: 0.55rem; }
.chart-hbar-row {
  display: grid;
  grid-template-columns: 5.5rem 1fr 2.5rem;
  gap: 0.5rem;
  align-items: center;
  font-size: 0.82rem;
}
.chart-hbar-label { color: var(--kg-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chart-hbar-track {
  height: 0.55rem;
  border-radius: 999px;
  background: var(--kg-bg);
  border: 1px solid var(--kg-border);
  overflow: hidden;
}
.chart-hbar-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.6s ease;
}
.chart-hbar-val {
  text-align: right;
  font-weight: 600;
  font-family: Montserrat, sans-serif;
  font-size: 0.8rem;
}

.form-strip {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
  padding: 0.25rem 0;
}
.form-dot {
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 4px;
  cursor: default;
  transition: transform 0.15s ease;
}
.form-dot:hover { transform: scale(1.15); }
.form-win { background: #2e7d32; }
.form-loss { background: #c62828; }
.form-draw { background: #9e9e9e; }

.chart-margin { display: block; width: 100%; max-width: 100%; }

.eval-table th { font-size: 0.78rem; white-space: nowrap; }
.eval-table td { font-size: 0.88rem; }
.analytics-note { margin-top: -0.25rem; font-size: 0.78rem !important; color: var(--kg-muted); }

/* 黒/白プレイヤー表示 — 石アイコン + アバター */
.color-disc {
  display: inline-block;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  flex-shrink: 0;
  border: 1.5px solid rgba(0, 0, 0, 0.15);
  box-shadow: inset 0 1px 2px rgba(255, 255, 255, 0.25);
}
.color-disc-black {
  background: radial-gradient(circle at 35% 35%, #555, #111);
}
.color-disc-white {
  background: radial-gradient(circle at 35% 35%, #fff, #ddd);
  border-color: rgba(0, 0, 0, 0.2);
}

.player-color-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin: 0.75rem 0 1rem;
  padding: 0.65rem 0.75rem;
  border-radius: 10px;
  background: var(--kg-bg);
  border: 1px solid var(--kg-border);
}
.live-color-bar { margin-top: 0.25rem; }
.player-color-side {
  display: flex;
  align-items: center;
  padding: 0.25rem 0.5rem;
  border-radius: 8px;
  transition: background 0.15s ease;
}
.player-color-side.is-turn {
  background: rgba(255, 202, 40, 0.18);
  box-shadow: inset 0 0 0 1px rgba(255, 202, 40, 0.45);
}
.player-color-vs {
  color: var(--kg-muted);
  font-size: 0.85rem;
  font-weight: 600;
}
.player-color-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}
.player-color-chip a {
  color: inherit;
  text-decoration: none;
  font-weight: 500;
}
.player-color-chip a:hover { text-decoration: underline; }
.player-color-chip strong { font-weight: 700; color: var(--kg-charcoal); }
.move-player-name { color: var(--kg-muted); font-size: 0.88rem; }

.player-move-item,
.live-move-item.player-move-item {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
}
.live-turn-active {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
  font-weight: 500;
}
.live-round-meta { margin-top: -0.25rem; }
.replay-root .player-color-bar { margin-top: 0; margin-bottom: 0.75rem; }
.round-moves .player-color-chip { font-size: 0.88rem; }
.round-moves .player-color-chip .user-avatar-xs,
.round-moves .player-color-chip .user-avatar-xs.avatar-fallback { width: 22px; height: 22px; font-size: 0.65rem; }
.round-moves .color-disc { width: 12px; height: 12px; }

.result-summary {
  margin: 0.65rem 0 0;
  padding: 0.65rem 0.85rem;
  border-radius: 8px;
  background: rgba(46, 125, 50, 0.08);
  border: 1px solid rgba(46, 125, 50, 0.22);
  color: var(--kg-charcoal);
  font-size: 0.92rem;
  line-height: 1.5;
}
.result-summary-warn {
  background: rgba(198, 40, 40, 0.07);
  border-color: rgba(198, 40, 40, 0.28);
}
.result-summary-alert {
  background: rgba(106, 27, 154, 0.07);
  border-color: rgba(106, 27, 154, 0.25);
}
.result-summary-inline {
  display: block;
  margin-top: 0.25rem;
  color: var(--kg-muted);
  line-height: 1.45;
  max-width: 28rem;
}
.live-header .result-summary { margin-top: 0.5rem; }
.round-card .result-summary { margin: 0.35rem 0 0.75rem; }
