:root {
  color-scheme: light;
  --site-bg: #f6f8fb;
  --site-text: #162033;
  --site-muted: #667085;
  --site-line: #d9e1ec;
  --site-primary: #0d6b8f;
  --site-primary-dark: #09506b;
  font-family: "Segoe UI", "Yu Gothic", "Hiragino Sans", sans-serif;
  background: var(--site-bg);
  color: var(--site-text);
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0 20px 32px;
  background:
    radial-gradient(circle at 12% 8%, rgba(13, 107, 143, 0.12), transparent 28rem),
    linear-gradient(180deg, #eef5fa 0%, var(--site-bg) 38%, #ffffff 100%);
}

/* 研究所トップと同じ戻り導線にして、ゲーム部分から視線を外しすぎないようにします。 */
.site-header,
.site-footer {
  width: min(100%, 1040px);
}

.site-header {
  padding: 22px 0 12px;
}

.site-footer {
  padding: 22px 0 0;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  color: var(--site-primary);
  font-weight: 700;
  text-decoration: none;
}

.back-link::before {
  content: "←";
  font-size: 1.05em;
}

.back-link:hover,
.back-link:focus-visible {
  color: var(--site-primary-dark);
}

.game {
  width: min(100%, 420px);
  display: grid;
  gap: 20px;
  justify-items: center;
  margin: 10px auto 0;
  padding: 22px;
  border: 1px solid rgba(217, 225, 236, 0.9);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.78);
  box-shadow: 0 10px 28px rgba(22, 32, 51, 0.08);
}

h1 {
  margin: 0;
  font-size: 2.4rem;
  line-height: 1.1;
  letter-spacing: 0;
  color: var(--site-text);
}

.panel {
  width: 100%;
  min-height: 74px;
  display: grid;
  gap: 6px;
  align-content: center;
  padding: 14px 18px;
  border: 1px solid #d8dee4;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: 0 10px 24px rgba(23, 32, 42, 0.07);
}

.turn,
.result {
  margin: 0;
  text-align: center;
}

.turn {
  font-size: 1.1rem;
  font-weight: 700;
}

.result {
  min-height: 1.4em;
  color: #b03a2e;
  font-size: 1rem;
  font-weight: 700;
}

.controls {
  width: 100%;
  display: grid;
  gap: 12px;
}

.mode-control {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin: 0;
  padding: 0;
  border: 0;
}

.mode-control legend {
  grid-column: 1 / -1;
  margin-bottom: 6px;
  font-weight: 700;
}

.mode-control label {
  min-height: 44px;
  display: grid;
  place-items: center;
  border: 1px solid #b9c6d3;
  border-radius: 8px;
  background: #ffffff;
  cursor: pointer;
  font-weight: 700;
}

.mode-control input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.mode-control label:has(input:checked) {
  border-color: #1f618d;
  background: #d6eaf8;
  color: #154360;
}

.difficulty-control {
  display: grid;
  grid-template-columns: 1fr minmax(140px, 180px);
  gap: 10px;
  align-items: center;
  font-weight: 700;
}

.difficulty-control select {
  min-height: 42px;
  padding: 8px 12px;
  border: 1px solid #b9c6d3;
  border-radius: 8px;
  background: #ffffff;
  color: #17202a;
  font: inherit;
  cursor: pointer;
}

.difficulty-control select:disabled {
  color: #77808a;
  background: #eef1f4;
  cursor: default;
}

.rule-summary {
  width: 100%;
  display: grid;
  gap: 6px;
  padding: 14px 16px;
  border-left: 4px solid #d68910;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.78);
  color: #273746;
}

.rule-summary h2,
.rule-summary p {
  margin: 0;
}

.rule-summary h2 {
  font-size: 1rem;
  line-height: 1.3;
}

.rule-summary p {
  font-size: 0.92rem;
  line-height: 1.55;
}

.board {
  width: min(100%, 360px);
  aspect-ratio: 1;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.cell {
  width: 100%;
  aspect-ratio: 1;
  border: 2px solid #2c3e50;
  border-radius: 8px;
  background: #ffffff;
  color: #17202a;
  font-size: clamp(2.8rem, 18vw, 5rem);
  font-weight: 800;
  line-height: 1;
  cursor: pointer;
  transition: transform 120ms ease, background-color 120ms ease, border-color 120ms ease;
}

.cell:hover:not(:disabled),
.cell:focus-visible {
  background: #eef6fb;
  border-color: #2874a6;
  transform: translateY(-1px);
  outline: none;
}

.cell:disabled {
  cursor: default;
}

.cell.expiring {
  background: #fff3cd;
  border-color: #d68910;
  color: #7d4f00;
  box-shadow: inset 0 0 0 4px rgba(214, 137, 16, 0.22);
}

.cell.winner {
  background: #d5f5e3;
  border-color: #1e8449;
  color: #145a32;
  box-shadow: none;
}

.reset-button {
  min-width: 132px;
  min-height: 46px;
  padding: 10px 20px;
  border: 0;
  border-radius: 8px;
  background: #1f618d;
  color: #ffffff;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: background-color 120ms ease, transform 120ms ease;
}

.reset-button:hover,
.reset-button:focus-visible {
  background: #154360;
  transform: translateY(-1px);
  outline: none;
}

@media (max-width: 420px) {
  body {
    padding: 0 14px 24px;
  }

  .game {
    gap: 16px;
    padding: 16px;
  }

  h1 {
    font-size: 2rem;
  }

  .board {
    gap: 8px;
  }

  .difficulty-control {
    grid-template-columns: 1fr;
  }
}


#version-history {
  width: 100%
}
