:root {
  --ink: #26314d;
  --muted: #69748e;
  --paper: #fffdf5;
  --line: rgba(38, 49, 77, 0.16);
  --dad: #4e91ff;
  --baby: #ff6e8c;
  --sun: #ffd55a;
  --mint: #7bdcb5;
  --wood: #f6c978;
  --wood-deep: #c88935;
  --shadow: 0 18px 45px rgba(43, 58, 97, 0.18);
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  background:
    radial-gradient(circle at 12% 18%, rgba(255, 213, 90, 0.5) 0 7%, transparent 8%),
    radial-gradient(circle at 88% 14%, rgba(123, 220, 181, 0.42) 0 8%, transparent 9%),
    linear-gradient(135deg, #eaf7ff 0%, #fff6d8 48%, #ffeaf0 100%);
}

button {
  border: 0;
  font: inherit;
  cursor: pointer;
}

.game-shell {
  width: min(1180px, calc(100vw - 32px));
  min-height: calc(100vh - 32px);
  margin: 16px auto;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.hero-bar,
.tips-row,
.message-strip,
.player-panel,
.board-frame,
.start-panel,
.win-card {
  border: 2px solid rgba(255, 255, 255, 0.75);
  background: rgba(255, 253, 245, 0.86);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.hero-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px;
  border-radius: 24px;
}

.eyebrow {
  margin: 0 0 4px;
  color: #3975d8;
  font-size: 14px;
  font-weight: 900;
  letter-spacing: 0;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-family: "Kaiti SC", "STKaiti", "KaiTi", "PingFang SC", cursive;
  font-size: clamp(34px, 4vw, 56px);
  font-weight: 400;
  line-height: 1.05;
}

.round-status {
  min-width: 132px;
  border-radius: 999px;
  padding: 12px 18px;
  color: #1f5f4e;
  background: #dff8ec;
  font-weight: 900;
  text-align: center;
}

.play-area {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(132px, 180px) minmax(340px, 1fr) minmax(132px, 180px);
  gap: 18px;
  align-items: center;
}

.player-panel {
  min-height: 460px;
  padding: 22px 16px;
  border-radius: 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  text-align: center;
  transition: transform 180ms ease, border-color 180ms ease, background 180ms ease;
}

.player-panel.active {
  transform: translateY(-6px);
  border-color: var(--sun);
  background: rgba(255, 255, 255, 0.96);
}

.avatar-wrap {
  width: min(132px, 28vw);
  aspect-ratio: 1;
  border-radius: 50%;
  padding: 8px;
  background: white;
  box-shadow: inset 0 0 0 4px rgba(255, 213, 90, 0.55), 0 12px 24px rgba(60, 77, 113, 0.16);
}

.avatar-wrap img,
.start-avatars img,
.win-card img {
  width: 100%;
  height: 100%;
  display: block;
  border-radius: 50%;
  object-fit: cover;
}

.player-label {
  font-size: 28px;
  font-weight: 900;
}

.stone-name {
  color: var(--muted);
  font-weight: 700;
}

.score-pill {
  min-width: 78px;
  border-radius: 999px;
  padding: 8px 14px;
  background: #fff3b8;
  color: #7b5200;
  font-weight: 900;
}

.board-section {
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.message-strip {
  width: min(660px, 100%);
  border-radius: 18px;
  padding: 12px 14px 12px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: #315171;
  font-weight: 900;
}

.board-frame {
  width: min(660px, 100%);
  aspect-ratio: 1;
  border-radius: 24px;
  padding: 18px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.38), transparent),
    repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.18) 0 8px, transparent 8px 16px),
    var(--wood);
}

.board {
  --board-gap: 5.2%;

  position: relative;
  width: 100%;
  height: 100%;
  border-radius: 14px;
  background: #f7cf82;
  overflow: hidden;
}

.cell {
  --board-span: calc(100% - (var(--board-gap) * 2));
  --step: calc(var(--board-span) / 14);

  position: absolute;
  left: calc(var(--board-gap) + (var(--col) * var(--step)));
  top: calc(var(--board-gap) + (var(--row) * var(--step)));
  width: min(var(--step), 42px);
  height: min(var(--step), 42px);
  padding: 0;
  transform: translate(-50%, -50%);
  background: transparent;
  border-radius: 50%;
  z-index: 1;
}

.board::before {
  content: "";
  position: absolute;
  inset: var(--board-gap);
  border: 3px solid var(--wood-deep);
  border-radius: 8px;
  background:
    linear-gradient(to right, rgba(94, 56, 17, 0.32) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(94, 56, 17, 0.32) 1px, transparent 1px);
  background-size: calc(100% / 14) calc(100% / 14);
  background-position: 0 0;
  pointer-events: none;
}

.cell::after {
  content: "";
  position: absolute;
  inset: 14%;
  border-radius: 50%;
  transform: scale(0);
  transition: transform 140ms ease;
}

.cell.black-stone::after,
.cell.white-stone::after {
  transform: scale(1);
}

.cell.black-stone::after {
  background:
    radial-gradient(circle at 32% 26%, rgba(255, 255, 255, 0.72) 0 9%, transparent 10%),
    radial-gradient(circle at 36% 30%, rgba(255, 255, 255, 0.2) 0 18%, transparent 22%),
    radial-gradient(circle at 62% 72%, rgba(0, 0, 0, 0.72), transparent 52%),
    linear-gradient(145deg, #3b3f4b 0%, #11141d 48%, #02030a 100%);
  box-shadow:
    inset -4px -6px 10px rgba(0, 0, 0, 0.62),
    inset 3px 4px 7px rgba(255, 255, 255, 0.14),
    0 5px 9px rgba(47, 31, 16, 0.34);
}

.cell.white-stone::after {
  background:
    radial-gradient(circle at 32% 25%, rgba(255, 255, 255, 1) 0 14%, transparent 15%),
    radial-gradient(circle at 62% 72%, rgba(185, 169, 130, 0.34), transparent 54%),
    linear-gradient(145deg, #ffffff 0%, #f4f0df 52%, #d8ceb1 100%);
  border: 1px solid rgba(112, 93, 49, 0.2);
  box-shadow:
    inset -4px -5px 10px rgba(144, 126, 84, 0.28),
    inset 3px 4px 8px rgba(255, 255, 255, 0.95),
    0 5px 9px rgba(47, 31, 16, 0.28);
}

.cell.winning::after {
  animation: winnerPulse 800ms ease-in-out infinite alternate;
}

.control-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
}

.primary-button,
.secondary-button,
.ghost-button {
  min-height: 44px;
  border-radius: 999px;
  padding: 0 22px;
  font-weight: 900;
  transition: transform 150ms ease, box-shadow 150ms ease, opacity 150ms ease;
}

.primary-button {
  color: white;
  background: linear-gradient(135deg, #ff7f98, #ffb347);
  box-shadow: 0 10px 18px rgba(235, 95, 91, 0.25);
}

.secondary-button,
.ghost-button {
  color: #315171;
  background: #e9f4ff;
}

.ghost-button {
  min-height: 36px;
  padding: 0 16px;
}

.large {
  min-height: 54px;
  padding-inline: 30px;
  font-size: 18px;
}

button:not(.cell):hover {
  transform: translateY(-2px);
}

.cell:hover {
  transform: translate(-50%, -50%);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
  transform: none;
}

.tips-row {
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
  border-radius: 20px;
  padding: 12px;
}

.tips-row span {
  border-radius: 999px;
  padding: 8px 12px;
  background: white;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.start-overlay,
.win-overlay {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(40, 52, 82, 0.38);
  z-index: 10;
}

.start-panel,
.win-card {
  width: min(440px, 100%);
  border-radius: 28px;
  padding: 28px;
  text-align: center;
}

.start-avatars {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 14px;
  margin-bottom: 16px;
}

.start-avatars img {
  width: 112px;
  justify-self: center;
  background: white;
}

.start-avatars span {
  border-radius: 999px;
  padding: 8px 10px;
  background: var(--sun);
  color: #78540c;
  font-weight: 900;
}

.start-panel h2,
.win-card h2 {
  margin-bottom: 8px;
  font-size: 34px;
  font-weight: 900;
}

.start-panel p,
.win-card p {
  margin-bottom: 20px;
  color: var(--muted);
  font-weight: 700;
}

.hidden {
  display: none;
}

.win-overlay {
  overflow: hidden;
  background: rgba(23, 28, 55, 0.46);
}

.win-card {
  position: relative;
  z-index: 2;
  animation: cardPop 560ms cubic-bezier(0.2, 1.5, 0.36, 1) both;
}

.win-card img {
  width: 132px;
  height: 132px;
  margin: 0 auto 14px;
  background: white;
  box-shadow: 0 0 0 8px rgba(255, 213, 90, 0.56), 0 16px 30px rgba(42, 55, 92, 0.22);
  animation: avatarBounce 900ms ease-in-out infinite;
}

.win-kicker {
  color: #ff6e31 !important;
}

.confetti {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.confetti-piece {
  position: absolute;
  top: -12px;
  width: 12px;
  height: 18px;
  border-radius: 4px;
  animation: fall linear forwards;
}

@keyframes fall {
  to {
    transform: translateY(110vh) rotate(720deg);
  }
}

@keyframes cardPop {
  from {
    opacity: 0;
    transform: scale(0.7) translateY(30px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

@keyframes avatarBounce {
  50% {
    transform: translateY(-12px) rotate(-3deg);
  }
}

@keyframes winnerPulse {
  to {
    transform: scale(1.16);
    box-shadow: 0 0 0 6px rgba(255, 255, 255, 0.38), 0 0 22px rgba(255, 213, 90, 0.86);
  }
}

@media (max-width: 860px) {
  .game-shell {
    width: min(100vw - 20px, 720px);
    margin-block: 10px;
  }

  .hero-bar {
    align-items: flex-start;
    gap: 12px;
    flex-direction: column;
  }

  .play-area {
    grid-template-columns: 1fr 1fr;
  }

  .board-section {
    grid-column: 1 / -1;
    order: 2;
  }

  .player-panel {
    min-height: 180px;
    padding: 16px 10px;
  }

  .avatar-wrap {
    width: 96px;
  }

  .player-label {
    font-size: 22px;
  }
}

@media (max-width: 520px) {
  .board-frame {
    padding: 10px;
    border-radius: 18px;
  }

  .message-strip {
    align-items: stretch;
    flex-direction: column;
    gap: 8px;
  }

  .ghost-button {
    width: 100%;
  }

  .start-avatars img {
    width: 86px;
  }
}
