:root {
  --bg-top: #fff6d8;
  --bg-bottom: #e1f6ff;
  --panel: rgba(255, 255, 255, 0.88);
  --panel-strong: rgba(255, 255, 255, 0.96);
  --text-main: #3d2b1f;
  --text-soft: #7b6655;
  --accent: #ff9f43;
  --accent-strong: #ff7e36;
  --green: #65c18c;
  --line: rgba(118, 84, 56, 0.18);
  --shadow: 0 20px 50px rgba(95, 132, 159, 0.16);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Noto Sans SC", sans-serif;
  color: var(--text-main);
  background:
    radial-gradient(circle at top left, rgba(255, 255, 255, 0.75), transparent 28%),
    radial-gradient(circle at bottom right, rgba(174, 236, 255, 0.7), transparent 30%),
    linear-gradient(180deg, var(--bg-top), var(--bg-bottom));
}

body::before,
body::after {
  content: "";
  position: fixed;
  inset: auto;
  border-radius: 999px;
  filter: blur(10px);
  opacity: 0.55;
  pointer-events: none;
}

body::before {
  width: 180px;
  height: 180px;
  top: 88px;
  right: 9vw;
  background: rgba(255, 186, 119, 0.42);
}

body::after {
  width: 220px;
  height: 220px;
  bottom: 60px;
  left: 4vw;
  background: rgba(142, 226, 255, 0.3);
}

.back-home {
  position: fixed;
  top: 12px;
  left: 16px;
  z-index: 10;
  padding: 10px 16px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--text-main);
  text-decoration: none;
  font-weight: 700;
  box-shadow: 0 12px 26px rgba(75, 99, 114, 0.14);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.back-home:hover {
  transform: translateY(-2px);
  box-shadow: 0 16px 32px rgba(75, 99, 114, 0.2);
}

.app-shell {
  width: min(1280px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 58px 0 18px;
}

.hero-card,
.board-card,
.side-card {
  background: var(--panel);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.55);
  box-shadow: var(--shadow);
}

.hero-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 10px;
  padding: 14px 18px;
  border-radius: 24px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent-strong);
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0.04em;
}

h1,
h2,
h3 {
  margin: 0;
  font-family: "ZCOOL KuaiLe", cursive;
  font-weight: 400;
}

h1 {
  font-size: clamp(1.6rem, 1.9vw, 2.25rem);
  line-height: 1;
}

.hero-inline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.subtitle {
  margin: 0;
  max-width: 34rem;
  color: var(--text-soft);
  line-height: 1.35;
  font-size: 0.88rem;
}

.control-panel {
  display: grid;
  gap: 8px;
}

.toolbar-row {
  display: grid;
  grid-template-columns: minmax(180px, 250px) minmax(180px, 250px) auto;
  gap: 10px;
  align-items: end;
  justify-content: space-between;
}

.field {
  display: grid;
  gap: 4px;
  font-weight: 700;
}

.field span {
  font-size: 0.82rem;
}

select,
button {
  font: inherit;
}

select {
  width: 100%;
  border: 1.5px solid rgba(255, 177, 95, 0.34);
  border-radius: 14px;
  background: var(--panel-strong);
  padding: 9px 12px;
  color: var(--text-main);
  outline: none;
  min-height: 44px;
}

select:focus {
  border-color: var(--accent);
}

.button-row {
  display: flex;
  gap: 8px;
  flex-wrap: nowrap;
  align-items: center;
}

button {
  border: 0;
  border-radius: 14px;
  padding: 10px 14px;
  font-weight: 800;
  cursor: pointer;
  transition: transform 0.2s ease, filter 0.2s ease, opacity 0.2s ease;
  white-space: nowrap;
}

button:hover:not(:disabled) {
  transform: translateY(-1px);
  filter: brightness(1.03);
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.primary-button {
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  color: #fff;
}

.soft-button {
  background: #fff;
  color: var(--text-main);
  border: 1px solid rgba(125, 98, 74, 0.12);
}

.status-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 14px;
  background: rgba(255, 251, 241, 0.92);
  border: 1px dashed rgba(255, 154, 63, 0.28);
  border-radius: 16px;
}

.status-copy {
  min-width: 0;
}

.status-label {
  margin: 0 0 2px;
  color: var(--text-soft);
  font-size: 0.74rem;
}

.status-text {
  margin: 0;
  font-size: 0.9rem;
  font-weight: 700;
  line-height: 1.28;
}

.badge-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.turn-badge,
.rule-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 78px;
  padding: 7px 12px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 800;
}

.turn-badge {
  background: rgba(101, 193, 140, 0.18);
  color: #236647;
}

.turn-badge.waiting {
  background: rgba(111, 135, 160, 0.14);
  color: #5e7387;
}

.turn-badge.black {
  background: rgba(70, 55, 48, 0.16);
  color: #35251c;
}

.turn-badge.white {
  background: rgba(255, 255, 255, 0.96);
  color: #866339;
  border: 1px solid rgba(134, 99, 57, 0.18);
}

.rule-badge {
  background: rgba(255, 159, 67, 0.16);
  color: #b86012;
}

.game-layout {
  margin-top: 12px;
  display: grid;
  grid-template-columns: minmax(0, 1.28fr) minmax(300px, 0.72fr);
  gap: 16px;
  align-items: start;
}

.board-card,
.side-card {
  border-radius: 32px;
  padding: 20px;
}

.board-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.board-header p {
  margin: 8px 0 0;
  color: var(--text-soft);
}

.legend {
  display: flex;
  gap: 14px;
  font-weight: 700;
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.stone {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: inline-block;
}

.stone.black {
  background: radial-gradient(circle at 32% 28%, #707070, #242424 65%, #070707 100%);
}

.stone.white {
  background: radial-gradient(circle at 30% 26%, #fff, #f0f0f0 60%, #d4d4d4 100%);
  border: 1px solid rgba(100, 100, 100, 0.18);
}

.board-frame {
  position: relative;
  width: min(100%, 760px);
  aspect-ratio: 1;
  margin: 0 auto;
  padding: 14px;
  border-radius: 32px;
  background:
    linear-gradient(135deg, rgba(255, 246, 224, 0.94), rgba(247, 218, 159, 0.95)),
    repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.14), rgba(255, 255, 255, 0.14) 8px, transparent 8px, transparent 16px);
  box-shadow: inset 0 4px 10px rgba(255, 255, 255, 0.42), inset 0 -6px 12px rgba(135, 97, 62, 0.12);
}

canvas {
  width: 100%;
  height: 100%;
  display: block;
  border-radius: 24px;
  touch-action: manipulation;
}

.side-card {
  display: grid;
  gap: 16px;
}

.info-block {
  padding: 18px;
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.5);
}

.info-block h3 {
  margin-bottom: 14px;
  font-size: 1.35rem;
}

.info-list {
  margin: 0;
  display: grid;
  gap: 10px;
}

.info-list div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 10px;
  border-bottom: 1px dashed var(--line);
}

.info-list div:last-child {
  padding-bottom: 0;
  border-bottom: 0;
}

dt {
  color: var(--text-soft);
  font-weight: 700;
}

dd {
  margin: 0;
  font-weight: 800;
  text-align: right;
}

.tips-list {
  margin: 0;
  padding-left: 1.2em;
  color: var(--text-soft);
  line-height: 1.75;
}

.tips-list.compact {
  line-height: 1.7;
}

.result-modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(74, 56, 39, 0.28);
  backdrop-filter: blur(8px);
}

.result-modal.hidden {
  display: none;
}

.result-card {
  width: min(560px, calc(100vw - 28px));
  padding: 28px;
  border-radius: 30px;
  background:
    radial-gradient(circle at top right, rgba(255, 240, 184, 0.82), transparent 32%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(255, 248, 233, 0.98));
  box-shadow: 0 28px 60px rgba(67, 52, 38, 0.26);
  border: 1px solid rgba(255, 255, 255, 0.75);
  animation: modal-pop 0.24s ease;
}

.result-tag {
  margin: 0 0 10px;
  color: var(--accent-strong);
  font-size: 0.95rem;
  font-weight: 800;
}

.result-summary {
  margin: 12px 0 0;
  color: var(--text-soft);
  line-height: 1.75;
}

.result-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 20px;
}

.result-stats div {
  padding: 16px 14px;
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid rgba(255, 211, 161, 0.7);
  text-align: center;
}

.result-stats span {
  display: block;
  color: var(--text-soft);
  font-size: 0.88rem;
}

.result-stats strong {
  display: block;
  margin-top: 6px;
  font-size: 1.35rem;
}

.modal-actions {
  margin-top: 22px;
  justify-content: center;
}

@keyframes modal-pop {
  from {
    transform: translateY(12px) scale(0.96);
    opacity: 0;
  }
  to {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
}

@media (max-width: 1080px) {
  .game-layout {
    grid-template-columns: 1fr;
  }

  .hero-inline,
  .toolbar-row {
    grid-template-columns: 1fr;
    display: grid;
  }

  .button-row {
    flex-wrap: wrap;
  }
}

@media (max-width: 720px) {
  .app-shell {
    width: min(100vw - 18px, 100%);
    padding-top: 72px;
  }

  .hero-card,
  .board-card,
  .side-card {
    padding: 18px;
    border-radius: 26px;
  }

  .status-card,
  .board-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .badge-row {
    justify-content: flex-start;
  }

  .back-home {
    top: 10px;
    left: 14px;
    padding: 9px 13px;
  }

  .result-stats {
    grid-template-columns: 1fr;
  }
}
