body:has(.othello) {
  background: #0d151b;
  color: #eaf3f1;
}

body:has(.othello) > header {
  max-width: 1040px;
  padding-bottom: 12px;
}

body:has(.othello) > header a {
  color: #9dafaf;
  font-size: 13px;
}

main:has(.othello) {
  max-width: 1040px;
  background: transparent;
  padding-top: 12px;
}

.othello {
  --accent: #38bdf8;
  --accent-green: #34d399;
  --muted: #9bafba;
  --panel: #17242d;
  --border: #2b3e49;
}

.game-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  gap: 12px;
  flex-wrap: wrap;
}

.eyebrow {
  font-size: 11px;
  letter-spacing: .18em;
  color: var(--muted);
  margin: 0 0 8px;
  font-weight: 700;
}

.game-heading h1 {
  font-size: 38px;
  line-height: 1.2;
  letter-spacing: .08em;
  margin: 0;
}

.game-heading h1 span {
  display: inline-block;
  font-size: 12px;
  letter-spacing: .12em;
  margin-left: 16px;
  color: var(--muted);
  font-weight: 400;
}

.game-tag {
  font-size: 13px;
  color: var(--accent-green);
}

/* 対局カード・AI選択バー */
.matchup-bar {
  display: grid;
  grid-template-columns: 1fr auto 1fr auto;
  gap: 12px;
  align-items: center;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 24px;
}

.player-select-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.player-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 700;
  color: #dce8e8;
}

.disc-badge {
  display: inline-block;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  flex-shrink: 0;
}

.disc-black {
  background: radial-gradient(circle at 35% 35%, #4a5568, #090d11 70%);
  border: 1px solid #64748b;
}

.disc-white {
  background: radial-gradient(circle at 35% 35%, #ffffff, #cbd5e1 75%);
  border: 1px solid #94a3b8;
}

.othello select {
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  color: #eaf3f1;
  background: #0f1921;
  border: 1px solid #38505e;
  border-radius: 8px;
  padding: 9px 10px;
  width: 100%;
  cursor: pointer;
}

.othello select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.player-meta {
  margin: 0;
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.matchup-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 0 4px;
}

.vs-badge {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .12em;
  color: var(--accent);
}

.matchup-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 170px;
}

.speed-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.speed-group label {
  font-size: 10px;
  letter-spacing: .08em;
  color: var(--muted);
}

/* レイアウト */
.game-layout {
  display: grid;
  grid-template-columns: minmax(0, 480px) minmax(240px, 320px);
  justify-content: center;
  gap: 28px;
  align-items: start;
}

.play-area {
  min-width: 0;
}

.board-wrap {
  position: relative;
  width: 100%;
  max-width: 480px;
  margin: auto;
  border: 1px solid #3a515d;
  border-radius: 10px;
  overflow: hidden;
  background: #0a141c;
  box-shadow: 0 16px 50px #0006;
}

#board {
  display: block;
  width: 100%;
  height: auto;
  touch-action: manipulation;
  cursor: pointer;
}

.game-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  text-align: center;
  background: #0b131bef;
  gap: 12px;
}

.game-overlay[hidden] {
  display: none;
}

.game-overlay p {
  margin: 0;
}

#overlay-title {
  font-size: 22px;
  font-weight: 700;
}

#overlay-description {
  color: var(--muted);
  font-size: 13px;
  white-space: pre-line;
  line-height: 1.6;
}

.othello button {
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  border: 1px solid #3b515e;
  border-radius: 8px;
  background: #213440;
  color: #eaf3f1;
  padding: 10px 14px;
  transition: background .15s, border-color .15s;
  touch-action: manipulation;
}

.othello button:hover:not(:disabled) {
  background: #304a59;
}

.othello button:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
}

.othello button:disabled {
  opacity: .4;
  cursor: default;
}

.othello #play,
.othello .accent-button {
  background: var(--accent-green);
  color: #062118;
  border-color: var(--accent-green);
}

.othello #play:hover:not(:disabled),
.othello .accent-button:hover:not(:disabled) {
  background: #4ade80;
}

.othello .sub-button {
  font-size: 11px;
  padding: 6px 10px;
}

.board-toolbar {
  max-width: 480px;
  margin: 12px auto 0;
  display: grid;
  grid-template-columns: 1fr 1fr 1.3fr;
  gap: 8px;
}

.board-toolbar button {
  font-size: 12px;
  padding: 10px 8px;
}

.board-toolbar button[aria-pressed="true"] {
  border-color: var(--accent-green);
  color: #a7f3d0;
}

/* サイドバー */
.score-card,
.stat-grid,
.model-inspector {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 18px;
}

.disc-scoreboard {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 14px;
}

.disc-score-item {
  flex: 1;
  background: #101a22;
  border: 1px solid #263844;
  border-radius: 10px;
  padding: 10px 12px;
  text-align: center;
  transition: border-color .15s, box-shadow .15s;
}

.disc-score-item.active {
  border-color: var(--accent-green);
  box-shadow: 0 0 0 1px var(--accent-green);
}

.disc-label {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 10px;
  letter-spacing: .12em;
  color: var(--muted);
  margin-bottom: 4px;
}

.score-value {
  font-size: 32px;
  font-weight: 700;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.score-divider {
  font-size: 20px;
  color: var(--muted);
  font-weight: 700;
}

.best-row {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--muted);
  gap: 8px;
  margin-top: 6px;
}

.best-row strong {
  color: #eaf3f1;
}

.stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 12px 0;
  padding: 14px 18px;
}

.stat-grid span {
  display: block;
  font-size: 10px;
  letter-spacing: .1em;
  color: var(--muted);
}

.stat-grid strong {
  font-size: 18px;
}

.storage-note {
  font-size: 11px;
  color: var(--muted);
  margin: 4px 0;
}

.game-buttons {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.game-buttons button {
  flex: 1;
  padding: 10px 6px;
}

.game-status {
  color: var(--accent-green);
  font-size: 12px;
  min-height: 2.2em;
  margin: 10px 0;
}

.model-inspector {
  margin-bottom: 14px;
}

.model-inspector h2 {
  font-size: 13px;
  margin: 0 0 4px;
  color: #eaf3f1;
}

.folder-hint {
  font-size: 11px;
  color: var(--muted);
  margin: 0 0 10px;
}

.folder-hint code {
  color: #93c5fd;
  background: #0f1921;
  padding: 2px 5px;
  border-radius: 4px;
}

.model-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 210px;
  overflow-y: auto;
}

.model-item {
  background: #101a22;
  border: 1px solid #263844;
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 11px;
}

.model-item-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
}

.model-item-head strong {
  color: #fff;
  font-size: 12px;
}

.format-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  letter-spacing: .04em;
}

.format-js {
  background: rgba(56, 189, 248, 0.16);
  color: #7dd3fc;
  border: 1px solid rgba(56, 189, 248, 0.35);
}

.format-json {
  background: rgba(245, 177, 107, 0.16);
  color: #fdba74;
  border: 1px solid rgba(245, 177, 107, 0.35);
}

.model-item-desc {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.model-item-file {
  margin: 4px 0 0;
  font-family: monospace;
  font-size: 10px;
  color: #7fa2b5;
}

.how-to {
  border-top: 1px solid var(--border);
  padding-top: 12px;
  color: var(--muted);
}

.how-to h2 {
  font-size: 13px;
  color: #eaf3f1;
  margin: 0 0 8px;
}

.how-to dl {
  margin: 0;
  font-size: 12px;
}

.how-to dl div {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 4px;
}

.how-to dt {
  font-family: monospace;
  color: #dce8e8;
}

.how-to dd {
  margin: 0;
}

/* AIモデル作成ガイドセクション */
.template-guide {
  margin-top: 28px;
  background: var(--panel);
  border: 1px solid #38505e;
  border-radius: 14px;
  padding: 22px;
}

.template-guide[hidden] {
  display: none;
}

.guide-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 10px;
}

.guide-header h2 {
  font-size: 20px;
  margin: 0;
}

.guide-lead {
  font-size: 13px;
  color: #bed0d8;
  margin: 0 0 18px;
}

.guide-lead code,
.guide-desc code {
  background: #0f1921;
  color: #7dd3fc;
  padding: 2px 6px;
  border-radius: 4px;
}

.guide-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}

.guide-card {
  background: #101a22;
  border: 1px solid #283a47;
  border-radius: 10px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.guide-card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}

.guide-card-head h3 {
  font-size: 15px;
  margin: 6px 0 0;
}

.guide-desc {
  font-size: 12px;
  color: var(--muted);
  margin: 0;
}

.prompt-box {
  width: 100%;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11px;
  line-height: 1.5;
  color: #dce8e8;
  background: #091016;
  border: 1px solid #2b3e49;
  border-radius: 8px;
  padding: 10px;
  resize: vertical;
}

@media (max-width: 820px) {
  .matchup-bar {
    grid-template-columns: 1fr;
  }
  .matchup-center {
    flex-direction: row;
    justify-content: space-between;
  }
  .game-layout {
    grid-template-columns: 1fr;
  }
  .guide-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 600px) {
  main:has(.othello) {
    margin: 0;
    padding: 12px;
  }
  .game-heading h1 {
    font-size: 28px;
  }
  .game-heading h1 span {
    display: block;
    margin: 4px 0 0;
  }
  .board-toolbar {
    grid-template-columns: 1fr 1fr;
  }
  .board-toolbar #open-template-guide {
    grid-column: 1 / -1;
  }
}
