:root {
  --bg: #0b1122;
  --bg-deep: #080d1b;
  --panel: rgba(20, 29, 52, 0.84);
  --panel-strong: #151f39;
  --line: rgba(143, 160, 202, 0.16);
  --line-bright: rgba(143, 160, 202, 0.28);
  --text: #eef2ff;
  --muted: #8f9ab8;
  --muted-2: #66718f;
  --accent: #8fe6dd;
  --accent-deep: #4dbdbb;
  --gold: #f4c86c;
  --danger: #ff8f99;
  --shadow: 0 30px 80px rgba(0, 0, 0, 0.28);
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }

html { min-width: 320px; background: var(--bg-deep); }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(circle at 14% 12%, rgba(73, 121, 179, 0.16), transparent 29rem),
    radial-gradient(circle at 94% 66%, rgba(111, 85, 159, 0.15), transparent 29rem),
    linear-gradient(135deg, #0c1328 0%, #080e1c 100%);
  overflow-x: hidden;
}

button, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: 0.45; }

.ambient {
  position: fixed;
  z-index: 0;
  width: 1px;
  height: 1px;
  border-radius: 50%;
  box-shadow: 0 0 160px 90px rgba(120, 201, 209, 0.08);
  pointer-events: none;
}
.ambient-one { top: 19%; left: 4%; }
.ambient-two { right: 8%; bottom: 15%; box-shadow: 0 0 180px 100px rgba(173, 126, 212, 0.08); }

.app-shell {
  position: relative;
  z-index: 1;
  width: min(1400px, calc(100% - 56px));
  margin: 0 auto;
  padding: 28px 0 20px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 28px;
}

.brand { display: flex; align-items: center; gap: 14px; }
.brand-mark {
  position: relative;
  display: grid;
  grid-template-columns: repeat(2, 10px);
  grid-template-rows: repeat(2, 10px);
  gap: 5px;
  width: 34px;
  height: 34px;
  padding: 5px;
  border: 1px solid rgba(143, 230, 221, 0.5);
  border-radius: 10px;
  transform: rotate(45deg);
  box-shadow: 0 0 24px rgba(143, 230, 221, 0.16);
}
.brand-mark span { display: block; border-radius: 3px; background: var(--accent); }
.brand-mark span:nth-child(2) { background: var(--gold); }
.brand-mark span:nth-child(3) { background: rgba(143, 230, 221, 0.4); }
.eyebrow {
  margin: 0 0 7px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.2em;
  line-height: 1;
}
.brand h1 { margin: 0; font-size: 19px; letter-spacing: 0.15em; font-weight: 700; }
.topbar-note {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--muted);
  font-size: 12px;
}
.pulse-dot, .online-badge i, .speech-line span {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 14px rgba(143, 230, 221, 0.85);
}

.game-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.34fr) minmax(320px, 0.66fr);
  gap: 22px;
  align-items: start;
}

.panel {
  background: linear-gradient(145deg, rgba(25, 37, 67, 0.88), rgba(13, 21, 42, 0.88));
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.board-stage { padding: clamp(22px, 3vw, 38px); }
.stage-heading, .card-title-row, .opponent-title {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}
.stage-heading h2 { margin: 0; font-size: clamp(22px, 3vw, 33px); letter-spacing: -0.03em; font-weight: 700; }
.status-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
  padding: 9px 13px;
  border: 1px solid rgba(143, 230, 221, 0.2);
  border-radius: 99px;
  color: var(--accent);
  background: rgba(143, 230, 221, 0.07);
  font-size: 12px;
}
.status-pill span { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
.status-pill.thinking span { background: var(--gold); box-shadow: 0 0 12px rgba(244, 200, 108, 0.75); }
.status-pill.thinking { color: var(--gold); border-color: rgba(244, 200, 108, 0.22); }

.board-wrap {
  position: relative;
  width: min(100%, 720px);
  margin: 28px auto 22px;
  padding: 12px;
  border-radius: 24px;
  background: linear-gradient(140deg, rgba(113, 90, 68, 0.5), rgba(44, 40, 58, 0.8));
  box-shadow: 0 26px 60px rgba(0, 0, 0, 0.35), inset 0 0 0 1px rgba(245, 215, 156, 0.12);
}
.board-rim {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  overflow: hidden;
  border-radius: 16px;
  background: #b69362;
  box-shadow: inset 0 0 0 2px rgba(54, 37, 26, 0.38), inset 0 0 35px rgba(53, 30, 14, 0.22);
}
#board { display: block; width: 100%; height: 100%; touch-action: none; cursor: crosshair; }
.board-corner { position: absolute; width: 17px; height: 17px; pointer-events: none; opacity: 0.45; }
.board-corner::before, .board-corner::after { content: ""; position: absolute; background: var(--accent); }
.board-corner::before { width: 100%; height: 1px; top: 0; }
.board-corner::after { width: 1px; height: 100%; left: 0; }
.corner-tl { top: 5px; left: 5px; }
.corner-tr { top: 5px; right: 5px; transform: rotate(90deg); }
.corner-bl { bottom: 5px; left: 5px; transform: rotate(-90deg); }
.corner-br { right: 5px; bottom: 5px; transform: rotate(180deg); }

.board-footer { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.player-legend { display: flex; flex-wrap: wrap; gap: 15px; }
.legend-item { display: inline-flex; align-items: center; gap: 7px; color: var(--muted); font-size: 12px; }
.stone { display: inline-block; width: 13px; height: 13px; border-radius: 50%; }
.stone.black { background: #101522; box-shadow: 0 2px 5px rgba(0, 0, 0, 0.45); }
.stone.white { background: #f2eee4; box-shadow: 0 2px 5px rgba(0, 0, 0, 0.25); }
.turn-tip { max-width: 230px; color: var(--muted-2); font-size: 12px; text-align: right; }

.side-column { display: grid; gap: 16px; }
.opponent-card { overflow: hidden; }
.portrait-frame {
  position: relative;
  height: 235px;
  overflow: hidden;
  background:
    radial-gradient(circle at 60% 30%, rgba(143, 230, 221, 0.24), transparent 35%),
    linear-gradient(160deg, rgba(43, 76, 104, 0.66), rgba(18, 29, 59, 0.95));
}
.portrait-frame::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, transparent 40%, rgba(11, 17, 34, 0.88) 100%);
  pointer-events: none;
}
.portrait-frame img {
  position: absolute;
  z-index: 1;
  top: -18px;
  left: 50%;
  width: min(74%, 280px);
  height: 280px;
  object-fit: contain;
  object-position: center top;
  transform: translateX(-50%);
  filter: drop-shadow(0 12px 24px rgba(4, 10, 22, 0.52));
}
.portrait-glow {
  position: absolute;
  z-index: 0;
  left: 50%;
  bottom: -58px;
  width: 230px;
  height: 120px;
  transform: translateX(-50%);
  border-radius: 50%;
  background: rgba(143, 230, 221, 0.26);
  filter: blur(26px);
}
.online-badge {
  position: absolute;
  z-index: 2;
  top: 16px;
  right: 16px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 10px;
  border: 1px solid rgba(143, 230, 221, 0.25);
  border-radius: 99px;
  color: var(--accent);
  background: rgba(8, 14, 28, 0.42);
  font-size: 11px;
  backdrop-filter: blur(10px);
}
.opponent-info { padding: 18px 20px 20px; }
.opponent-title h2 { margin: 0; font-size: 25px; letter-spacing: 0.04em; }
.opponent-title h2 span { margin-left: 5px; color: var(--muted); font-size: 10px; font-weight: 600; letter-spacing: 0.18em; vertical-align: middle; }
.rank-chip { padding: 6px 9px; border: 1px solid rgba(244, 200, 108, 0.2); border-radius: 8px; color: var(--muted); font-size: 11px; }
.rank-chip strong { margin-left: 3px; color: var(--gold); font-size: 14px; }
.opponent-desc { margin: 14px 0 16px; color: #c3cbe0; font-size: 13px; line-height: 1.7; }
.speech-line { display: flex; align-items: center; gap: 8px; color: var(--accent); font-size: 12px; }
.speech-line span { flex: 0 0 auto; width: 5px; height: 5px; }

.control-card { padding: 21px 20px 18px; }
.card-title-row h3 { margin: 0; font-size: 18px; }
.move-counter { padding-top: 3px; color: var(--muted-2); font-size: 12px; }
.move-counter b { color: var(--text); font-size: 18px; }
.select-label { display: block; margin: 23px 0 9px; color: var(--muted); font-size: 12px; }
.select-wrap { position: relative; }
.select-wrap select {
  width: 100%;
  padding: 12px 38px 12px 13px;
  appearance: none;
  border: 1px solid var(--line-bright);
  border-radius: 11px;
  outline: none;
  color: var(--text);
  background: rgba(8, 14, 29, 0.5);
}
.select-wrap select:focus { border-color: rgba(143, 230, 221, 0.55); box-shadow: 0 0 0 3px rgba(143, 230, 221, 0.08); }
.select-arrow { position: absolute; top: 8px; right: 13px; color: var(--accent); font-size: 20px; pointer-events: none; }
.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); margin: 17px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.stat-item { padding: 13px 4px; text-align: center; }
.stat-item + .stat-item { border-left: 1px solid var(--line); }
.stat-item span { display: block; margin-bottom: 4px; color: var(--muted-2); font-size: 10px; }
.stat-item strong { color: var(--text); font-size: 19px; font-weight: 500; }
.action-row { display: flex; gap: 9px; }
.primary-button, .secondary-button, .utility-button { border: 0; transition: transform 0.2s ease, background 0.2s ease, border-color 0.2s ease; }
.primary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 43px;
  padding: 0 17px;
  border-radius: 10px;
  color: #10202b;
  background: linear-gradient(135deg, #a6f2e7, #70cfcb);
  box-shadow: 0 8px 22px rgba(86, 209, 201, 0.16);
  font-size: 13px;
  font-weight: 700;
}
.primary-button:hover { transform: translateY(-2px); background: linear-gradient(135deg, #bcfff6, #7bded9); }
.primary-button span { font-size: 16px; }
.secondary-button {
  width: 45px;
  border: 1px solid var(--line-bright);
  border-radius: 10px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.035);
  font-size: 23px;
}
.secondary-button:hover { border-color: rgba(143, 230, 221, 0.48); color: var(--accent); background: rgba(143, 230, 221, 0.08); }
.utility-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 14px; }
.utility-button { display: inline-flex; align-items: center; gap: 7px; padding: 0; color: var(--muted); background: transparent; font-size: 11px; }
.utility-button:hover { color: var(--accent); }
.utility-button span:first-child { color: var(--accent); font-size: 17px; }
.shortcut-hint { color: var(--muted-2); font-size: 10px; }

.insight-card { display: flex; align-items: flex-start; gap: 12px; padding: 17px 18px; }
.insight-icon { display: grid; flex: 0 0 auto; place-items: center; width: 29px; height: 29px; border: 1px solid rgba(143, 230, 221, 0.2); border-radius: 9px; color: var(--accent); background: rgba(143, 230, 221, 0.08); font-size: 19px; }
.insight-card p:last-child { margin: 0; color: #c2cadf; font-size: 12px; line-height: 1.65; }

.footer { display: flex; justify-content: space-between; gap: 20px; margin-top: 22px; padding: 0 4px; color: var(--muted-2); font-size: 10px; letter-spacing: 0.14em; }

.modal-backdrop {
  position: fixed;
  z-index: 10;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 22px;
  background: rgba(3, 7, 17, 0.72);
  backdrop-filter: blur(12px);
}
.modal-backdrop[hidden] { display: none; }
.result-modal { position: relative; width: min(360px, 100%); padding: 35px 28px 28px; text-align: center; overflow: hidden; }
.result-modal::before { content: ""; position: absolute; top: -80px; left: 50%; width: 220px; height: 150px; transform: translateX(-50%); border-radius: 50%; background: rgba(143, 230, 221, 0.13); filter: blur(25px); }
.result-orbit { position: relative; display: grid; place-items: center; width: 55px; height: 55px; margin: 0 auto 18px; border: 1px solid rgba(143, 230, 221, 0.3); border-radius: 50%; color: var(--accent); background: rgba(143, 230, 221, 0.09); font-size: 23px; }
.result-modal h2 { margin: 0 0 9px; font-size: 25px; }
.result-modal > p:not(.eyebrow) { margin: 0 0 24px; color: var(--muted); font-size: 13px; line-height: 1.7; }
.modal-button { width: 100%; }

@media (max-width: 980px) {
  .game-layout { grid-template-columns: 1fr; }
  .board-stage { max-width: 760px; margin: 0 auto; width: 100%; }
  .side-column { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: start; }
  .opponent-card { grid-row: span 2; }
}

@media (max-width: 640px) {
  .app-shell { width: min(100% - 28px, 560px); padding-top: 18px; }
  .topbar { margin-bottom: 18px; }
  .topbar-note { display: none; }
  .board-stage { padding: 18px 13px 15px; border-radius: 17px; }
  .stage-heading { display: block; }
  .status-pill { width: fit-content; margin-top: 14px; }
  .board-wrap { margin-top: 19px; padding: 8px; border-radius: 17px; }
  .board-footer { display: block; }
  .turn-tip { max-width: none; margin-top: 10px; text-align: left; }
  .side-column { display: flex; flex-direction: column; }
  .opponent-card { display: grid; grid-template-columns: 39% 61%; }
  .portrait-frame { height: 188px; }
  .portrait-frame img { top: -8px; width: 100%; height: 220px; }
  .opponent-info { padding: 17px 14px 13px; }
  .opponent-title h2 { font-size: 21px; }
  .opponent-desc { margin: 10px 0; font-size: 11px; }
  .rank-chip { display: none; }
  .footer { font-size: 8px; }
}

@media (prefers-reduced-motion: no-preference) {
  .panel { animation: panel-in 0.55s ease both; }
  .side-column .panel:nth-child(2) { animation-delay: 0.08s; }
  .side-column .panel:nth-child(3) { animation-delay: 0.14s; }
  @keyframes panel-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
}
