:root {
  --ink: #17231f;
  --ink-soft: #42504a;
  --cream: #f2eee3;
  --paper: #e9e2d2;
  --gold: #b78a45;
  --red: #a94735;
  --wood: #c9975b;
  --wood-light: #d8ad71;
  --line: rgba(23, 35, 31, 0.22);
  --shadow: 0 30px 80px rgba(24, 32, 28, 0.16);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at 13% 18%, rgba(183, 138, 69, 0.11), transparent 28rem),
    linear-gradient(115deg, #f5f1e8 0%, #ece7da 100%);
  font-family: "Noto Serif SC", "Songti SC", SimSun, serif;
  overflow-x: hidden;
}

button { font: inherit; }
button:focus-visible { outline: 2px solid var(--red); outline-offset: 3px; }

.grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: .2;
  z-index: 20;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.11'/%3E%3C/svg%3E");
  mix-blend-mode: multiply;
}

.site-header {
  height: 90px;
  padding: 0 clamp(24px, 5vw, 78px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(23, 35, 31, .13);
}

.brand { display: flex; align-items: center; gap: 12px; color: inherit; text-decoration: none; }
.brand-mark {
  width: 42px; height: 42px; display: grid; place-items: center;
  color: var(--cream); background: var(--red); border-radius: 3px;
  font-size: 23px; font-weight: 700; box-shadow: inset 0 0 0 2px rgba(255,255,255,.18);
}
.brand-copy { display: flex; flex-direction: column; gap: 2px; }
.brand-copy strong { font-size: 17px; letter-spacing: .16em; }
.brand-copy small { font-family: Arial, sans-serif; font-size: 8px; letter-spacing: .19em; color: var(--ink-soft); }
.header-note { margin: 0; color: var(--ink-soft); font-size: 12px; letter-spacing: .28em; }

.game-shell {
  width: min(1460px, calc(100% - 64px));
  margin: 0 auto;
  min-height: calc(100vh - 160px);
  display: grid;
  grid-template-columns: minmax(220px, .8fr) minmax(450px, 620px) minmax(270px, .92fr);
  gap: clamp(34px, 4vw, 76px);
  align-items: center;
  padding: 50px 0 42px;
}

.intro { align-self: center; max-width: 360px; }
.eyebrow { display: flex; align-items: center; gap: 10px; color: var(--red); font-family: Arial, sans-serif; font-size: 10px; font-weight: 700; letter-spacing: .2em; }
.eyebrow span { display: block; width: 30px; height: 1px; background: var(--red); }
.intro h1 { margin: 22px 0 20px; font-size: clamp(45px, 5vw, 78px); line-height: .98; font-weight: 500; letter-spacing: .06em; }
.intro h1 em { color: var(--red); font-style: normal; }
.intro-copy { margin: 0 0 38px; font-size: 14px; line-height: 2; letter-spacing: .05em; color: var(--ink-soft); }
blockquote { position: relative; margin: 0; padding: 26px 0 0 22px; border-top: 1px solid rgba(23,35,31,.18); }
blockquote .quote-mark { position: absolute; top: 15px; left: 0; color: var(--gold); font-size: 52px; line-height: 1; }
blockquote p { min-height: 70px; margin: 0; font-size: 17px; font-weight: 600; line-height: 1.85; letter-spacing: .04em; transition: opacity .2s, transform .2s; }
blockquote footer { margin-top: 10px; color: var(--red); font-size: 12px; letter-spacing: .1em; }
.next-viewpoint { margin: 22px 0 0 22px; padding: 0 0 5px; color: var(--ink-soft); background: none; border: 0; border-bottom: 1px solid var(--ink-soft); cursor: pointer; font-size: 12px; letter-spacing: .08em; }

.board-column { width: 100%; }
.status-bar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; padding: 0 4px; }
.turn-indicator { display: flex; align-items: center; gap: 12px; }
.turn-indicator div { display: flex; flex-direction: column; gap: 3px; }
.turn-indicator small, .move-count small { color: var(--ink-soft); font-size: 10px; letter-spacing: .12em; }
.turn-indicator strong { font-size: 14px; letter-spacing: .06em; }
.status-stone, .mini-stone { display: inline-block; border-radius: 50%; flex: 0 0 auto; }
.status-stone { width: 25px; height: 25px; }
.status-stone.black, .mini-stone.black { background: radial-gradient(circle at 35% 30%, #4c5551, #101613 63%, #050706); box-shadow: 0 4px 7px rgba(0,0,0,.25); }
.status-stone.white, .mini-stone.white { background: radial-gradient(circle at 35% 30%, #fff, #e5e1d7 67%, #b8b2a8); box-shadow: 0 3px 6px rgba(0,0,0,.18); }
.move-count { display: flex; align-items: baseline; gap: 8px; }
.move-count strong { color: var(--red); font-family: Georgia, serif; font-size: 25px; font-weight: 500; }

.board-frame {
  position: relative;
  padding: clamp(19px, 2.5vw, 31px);
  border-radius: 4px;
  background: linear-gradient(145deg, var(--wood-light), var(--wood));
  box-shadow: var(--shadow), inset 0 0 0 1px rgba(81, 51, 22, .25), inset 0 0 24px rgba(90,56,22,.12);
}
.board-frame::after { content: "李以恒观点"; position: absolute; right: 10px; bottom: 7px; color: rgba(68,36,13,.55); font-size: 8px; letter-spacing: .16em; writing-mode: vertical-rl; }
.board {
  position: relative;
  aspect-ratio: 1;
  display: grid;
  grid-template-columns: repeat(15, 1fr);
  grid-template-rows: repeat(15, 1fr);
  background-color: transparent;
  background-image:
    linear-gradient(to right, transparent calc(50% - .5px), rgba(51, 35, 19, .64) calc(50% - .5px), rgba(51, 35, 19, .64) calc(50% + .5px), transparent calc(50% + .5px)),
    linear-gradient(to bottom, transparent calc(50% - .5px), rgba(51, 35, 19, .64) calc(50% - .5px), rgba(51, 35, 19, .64) calc(50% + .5px), transparent calc(50% + .5px));
  background-size: calc(100% / 15) calc(100% / 15);
  background-position: 0 0;
}
.cell { position: relative; padding: 0; border: 0; background: none; cursor: pointer; z-index: 2; }
.cell::before { content: ""; position: absolute; inset: 12%; border-radius: 50%; opacity: 0; transform: scale(.65); transition: opacity .13s, transform .13s; }
.cell.can-place:hover::before { opacity: .2; transform: scale(.8); background: var(--ink); }
.cell .stone { position: absolute; width: 86%; height: 86%; left: 7%; top: 7%; border-radius: 50%; animation: place .18s cubic-bezier(.2,.9,.3,1.3); }
.cell .stone.black { background: radial-gradient(circle at 36% 30%, #53605a 0%, #17201c 47%, #060908 100%); box-shadow: 0 5px 7px rgba(30,19,8,.4), inset -2px -3px 5px rgba(0,0,0,.35), inset 2px 2px 3px rgba(255,255,255,.15); }
.cell .stone.white { background: radial-gradient(circle at 36% 28%, #fffdf7 0%, #ece8de 58%, #c7c0b3 100%); box-shadow: 0 5px 7px rgba(30,19,8,.3), inset -2px -3px 4px rgba(93,79,58,.2); }
.cell .stone.last::after { content: ""; position: absolute; width: 18%; height: 18%; left: 41%; top: 41%; border-radius: 50%; background: var(--red); box-shadow: 0 0 0 1px rgba(255,255,255,.3); }
.cell .stone.winning { animation: winPulse .8s ease-in-out infinite alternate; }
.star { position: absolute; width: 5px; height: 5px; background: rgba(43,29,15,.78); border-radius: 50%; transform: translate(-50%,-50%); z-index: 1; pointer-events: none; }
@keyframes place { from { opacity: .2; transform: scale(1.45); } to { opacity: 1; transform: scale(1); } }
@keyframes winPulse { to { box-shadow: 0 0 0 5px rgba(169,71,53,.5), 0 5px 8px rgba(30,19,8,.35); } }

.thinking { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; gap: 5px; background: rgba(218, 174, 114, .44); backdrop-filter: blur(1px); z-index: 8; opacity: 0; pointer-events: none; transition: opacity .2s; }
.thinking.visible { opacity: 1; }
.thinking span { width: 7px; height: 7px; border-radius: 50%; background: var(--ink); animation: think .8s infinite alternate; }
.thinking span:nth-child(2) { animation-delay: .15s; }
.thinking span:nth-child(3) { animation-delay: .3s; }
.thinking small { margin-left: 8px; letter-spacing: .12em; }
@keyframes think { to { transform: translateY(-7px); opacity: .35; } }

.board-actions { margin-top: 18px; display: grid; grid-template-columns: 1fr 1fr auto; gap: 10px; }
.action-button, .icon-button { min-height: 45px; border: 1px solid rgba(23,35,31,.23); color: var(--ink); background: rgba(255,255,255,.2); cursor: pointer; transition: transform .16s, color .16s, background .16s; }
.action-button:hover, .icon-button:hover { transform: translateY(-2px); background: rgba(255,255,255,.5); }
.action-button.primary { color: #f4efe5; border-color: var(--ink); background: var(--ink); }
.action-button.primary:hover { background: #293a33; }
.action-button span { margin-right: 6px; }
.icon-button { width: 46px; font-family: Arial, sans-serif; font-size: 18px; }

.control-panel { border-left: 1px solid rgba(23,35,31,.16); padding-left: clamp(24px, 3vw, 48px); }
.panel-section { display: grid; grid-template-columns: 30px 1fr; gap: 10px; padding: 24px 0; border-bottom: 1px solid rgba(23,35,31,.13); }
.panel-section:first-child { padding-top: 0; }
.section-number { padding-top: 4px; color: var(--red); font-family: Arial, sans-serif; font-size: 9px; letter-spacing: .08em; }
.section-content h2 { margin: 0 0 15px; font-size: 14px; letter-spacing: .1em; }
.mode-switch { display: flex; flex-direction: column; gap: 8px; }
.mode-option { min-height: 60px; padding: 10px 12px; display: grid; grid-template-columns: 34px 1fr 18px; gap: 9px; align-items: center; text-align: left; color: var(--ink); background: rgba(255,255,255,.22); border: 1px solid rgba(23,35,31,.14); cursor: pointer; }
.mode-option.active { border-color: var(--red); background: rgba(169,71,53,.06); }
.mode-option .mode-icon { width: 32px; height: 32px; display: grid; place-items: center; border: 1px solid rgba(23,35,31,.24); border-radius: 50%; font-size: 12px; }
.mode-option > span:nth-child(2) { display: flex; flex-direction: column; gap: 3px; }
.mode-option strong { font-size: 13px; }
.mode-option small { color: var(--ink-soft); font-size: 10px; }
.mode-option i { display: none; color: var(--red); font-style: normal; }
.mode-option.active i { display: block; }
.difficulty { display: grid; grid-template-columns: repeat(3, 1fr); }
.difficulty button { height: 35px; color: var(--ink-soft); border: 1px solid rgba(23,35,31,.18); border-right: 0; background: rgba(255,255,255,.18); cursor: pointer; font-size: 11px; }
.difficulty button:last-child { border-right: 1px solid rgba(23,35,31,.18); }
.difficulty button.active { color: #fff; background: var(--red); border-color: var(--red); }
.color-choice { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.color-choice button { height: 42px; display: flex; align-items: center; justify-content: center; gap: 8px; color: var(--ink-soft); background: rgba(255,255,255,.18); border: 1px solid rgba(23,35,31,.16); cursor: pointer; font-size: 11px; }
.color-choice button.active { color: var(--ink); border-color: var(--red); background: rgba(169,71,53,.06); }
.mini-stone { width: 18px; height: 18px; }
.panel-section.hidden { display: none; }

.record-card { margin-top: 24px; padding: 20px; color: #ebe5d9; background: var(--ink); }
.record-card > div:first-child { display: flex; align-items: end; justify-content: space-between; }
.record-card small { color: #aab3af; font-size: 10px; letter-spacing: .12em; }
.record-card strong { font-family: Georgia, serif; font-size: 25px; font-weight: 400; }
.record-card i { margin: 0 5px 0 2px; color: #9ba8a2; font-family: SimSun, serif; font-size: 9px; font-style: normal; }
.record-line { margin: 13px 0; height: 2px; background: rgba(255,255,255,.16); }
.record-line span { display: block; width: 50%; height: 100%; background: var(--red); transition: width .3s; }
.record-card p { margin: 0; color: #bcc4c0; font-size: 10px; line-height: 1.7; letter-spacing: .06em; }

.site-footer { min-height: 70px; padding: 18px clamp(24px, 5vw, 78px); display: flex; justify-content: space-between; align-items: center; border-top: 1px solid rgba(23,35,31,.13); color: var(--ink-soft); font-size: 10px; letter-spacing: .1em; }
.site-footer p { margin: 0; }

.result-modal[hidden] { display: none; }
.result-modal { position: fixed; inset: 0; z-index: 30; display: grid; place-items: center; padding: 20px; background: rgba(16,24,21,.65); backdrop-filter: blur(5px); }
.modal-card { position: relative; width: min(410px, 100%); padding: 45px 40px 38px; text-align: center; background: var(--cream); box-shadow: 0 35px 100px rgba(0,0,0,.3); animation: modalIn .28s ease-out; }
.modal-card::before { content: ""; position: absolute; inset: 8px; border: 1px solid rgba(23,35,31,.14); pointer-events: none; }
.modal-close { position: absolute; right: 18px; top: 15px; border: 0; background: none; color: var(--ink-soft); font-size: 23px; cursor: pointer; }
.modal-seal { margin: 0 auto 18px; width: 58px; height: 58px; display: grid; place-items: center; color: var(--cream); background: var(--red); border-radius: 50%; font-size: 27px; font-weight: 700; }
.modal-card small { color: var(--gold); font: 9px Arial, sans-serif; letter-spacing: .2em; }
.modal-card h2 { margin: 12px 0 10px; font-size: 28px; letter-spacing: .08em; }
.modal-card p { margin: 0 0 25px; color: var(--ink-soft); font-size: 12px; line-height: 1.8; }
.modal-card .action-button { width: 150px; }
@keyframes modalIn { from { transform: translateY(15px) scale(.97); opacity: 0; } }

@media (max-width: 1120px) {
  .game-shell { grid-template-columns: minmax(440px, 600px) minmax(250px, 340px); justify-content: center; }
  .intro { grid-column: 1 / -1; max-width: none; display: grid; grid-template-columns: 1fr 1fr; column-gap: 60px; }
  .intro .eyebrow, .intro h1, .intro-copy { grid-column: 1; }
  .intro h1 { margin-bottom: 12px; }
  .intro blockquote { grid-column: 2; grid-row: 1 / span 3; align-self: end; }
  .next-viewpoint { grid-column: 2; justify-self: start; }
}

@media (max-width: 790px) {
  .site-header { height: 75px; }
  .header-note { display: none; }
  .game-shell { width: min(100% - 30px, 620px); grid-template-columns: 1fr; gap: 35px; padding-top: 34px; }
  .intro { display: block; }
  .intro h1 { font-size: 54px; }
  .intro-copy { margin-bottom: 25px; }
  blockquote p { min-height: auto; }
  .board-column { grid-row: 2; }
  .control-panel { border-left: 0; border-top: 1px solid rgba(23,35,31,.16); padding: 28px 0 0; }
  .panel-section { grid-template-columns: 30px 1fr; }
  .site-footer { align-items: flex-start; gap: 8px; flex-direction: column; }
}

@media (max-width: 450px) {
  .site-header { padding: 0 18px; }
  .brand-copy strong { font-size: 15px; }
  .game-shell { width: calc(100% - 20px); }
  .intro { padding: 0 8px; }
  .intro h1 { font-size: 46px; }
  .board-frame { padding: 15px; }
  .cell .stone { width: 94%; height: 94%; left: 3%; top: 3%; }
  .board-actions { grid-template-columns: 1fr 1fr 42px; }
  .action-button { font-size: 13px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
