/* 井字棋 */
* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: linear-gradient(180deg, #b2dfdb, #4db6ac);
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
}

#stage { position: relative; width: 500px; transform-origin: center; }

#topbar {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 4px;
  color: #004d40;
}
#topbar a, #topbar button {
  font-size: 20px;
  width: 40px; height: 40px;
  border: none; border-radius: 12px;
  background: rgba(255, 255, 255, .75);
  cursor: pointer; text-decoration: none;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 3px 6px rgba(0, 77, 64, .25);
}
#topbar button:hover, #topbar a:hover { background: #fff; }

#statMe, #statDraw, #statAi {
  display: flex; align-items: center; gap: 8px;
  background: rgba(255, 255, 255, .75);
  padding: 6px 14px; border-radius: 12px;
  font-size: 14px; font-weight: 700;
  box-shadow: 0 3px 6px rgba(0, 77, 64, .25);
}
#statMe b, #statDraw b, #statAi b { font-size: 20px; color: #00695c; }
#ctrlBtns { margin-left: auto; display: flex; gap: 8px; }

#diffRow { display: flex; gap: 10px; justify-content: center; margin: 4px 0 12px; }
.diff {
  padding: 8px 22px;
  font-size: 15px; font-weight: 800;
  border: 3px solid transparent;
  border-radius: 999px;
  background: rgba(255, 255, 255, .6);
  color: #00695c;
  cursor: pointer;
}
.diff.on { background: #00695c; color: #fff; border-color: #b2dfdb; }

#board {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  background: #00695c;
  border-radius: 18px;
  padding: 12px;
  box-shadow: 0 12px 28px rgba(0, 77, 64, .35);
}

.cell {
  aspect-ratio: 1;
  border: none; border-radius: 14px;
  background: #e0f2f1;
  font-size: clamp(34px, 11vw, 56px);
  font-weight: 900;
  color: #004d40;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: transform .1s ease;
}
.cell:hover { background: #b2dfdb; }
.cell:active { transform: scale(.94); }
.cell.x { color: #e64a19; }
.cell.o { color: #00838f; }
.cell.pop { animation: pop .18s ease; }
.cell.winline { background: #ffd740; animation: flash 1s ease infinite alternate; }
@keyframes pop { from { transform: scale(.6); } }
@keyframes flash { to { filter: brightness(1.15); } }

#msg {
  text-align: center;
  margin-top: 12px;
  font-size: 15px; font-weight: 700;
  color: #004d40;
}

#overlay {
  position: absolute; inset: 44px 0 0 0;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0, 45, 40, .45);
  border-radius: 18px;
  z-index: 2;
}
#overlay.hidden { display: none; }

.screen {
  background: #fff;
  border-radius: 20px;
  padding: 26px 34px;
  text-align: center;
  color: #004d40;
  box-shadow: 0 14px 30px rgba(0, 0, 0, .3);
  animation: pop .22s ease;
}
.screen h2 { font-size: 26px; margin-bottom: 10px; }
.screen p { font-size: 14px; color: #456; margin-bottom: 16px; line-height: 1.8; }
.screen button {
  display: block; width: 200px; margin: 8px auto 0;
  padding: 10px 0;
  font-size: 16px; font-weight: 700;
  border: none; border-radius: 12px;
  background: #e0f2f1; color: #004d40;
  cursor: pointer;
}
.screen button:hover { background: #b2dfdb; }
.screen button.big { background: #26a69a; color: #fff; font-size: 18px; padding: 12px 0; }
.screen button.big:hover { background: #00897b; }
