/* 棋院年鉴：以纸、墨和朱砂建立可长期维护的棋局界面。
   This file only changes presentation; original game/engine code remains intact. */
:root,
[data-theme="light"] {
  --bg-primary: #f4f1e9;
  --bg-secondary: #fffdf8;
  --bg-tertiary: #eee9dd;
  --bg-hover: #e6dfcf;
  --text-primary: #202a26;
  --text-secondary: #53615b;
  --text-tertiary: #69766e;
  --border-color: #d5d0c3;
  --border-subtle: #e6e0d5;
  --accent-color: #9f4936;
  --accent-hover: #823928;
  --base-font-size: 14px;
  color-scheme: light;
  background: var(--bg-primary);
}

html, body, #root { min-height: 100%; }
body { margin: 0; color: var(--text-primary); background: var(--bg-primary); }
button, select { -webkit-tap-highlight-color: transparent; }
button:focus-visible, select:focus-visible, input:focus-visible {
  outline: 3px solid #b34f36;
  outline-offset: 3px;
}
::selection { background: #e4c7b6; color: #202a26; }
::-webkit-scrollbar-thumb { background: #a6afa4; }

.app { min-height: 100dvh; height: 100dvh; }
.app > header[class*="_header_"] {
  height: 72px;
  padding: 0 clamp(20px, 3vw, 48px);
  background: #1d302b;
  border: 0;
  box-shadow: 0 3px 16px #1d302b20;
  z-index: 8;
}
.app > header [class*="_title_"] {
  color: #faf6ea;
  font-family: Georgia, 'Songti SC', 'STSong', serif;
  font-size: 29px;
  font-weight: 600;
  letter-spacing: -.025em;
}
.app > header [class*="_headerLeft_"] { gap: 16px; min-width: 0; }
.app > header [class*="_headerRight_"] { gap: 10px; }
.app > header [class*="_statusBadge_"] {
  padding: 6px 11px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .04em;
}
.app > header [class*="_statusOnline_"] { background: #d7e9d4; color: #214a32; }
.app > header [class*="_statusOffline_"] { background: #f4d6cf; color: #842f24; }
.app > header [class*="_statusThinking_"] { background: #eecda7; color: #55371a; }
.app > header [class*="_modelBadge_"] {
  max-width: min(31vw, 320px);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #bfcfc5;
  background: #2b443b;
  border-radius: 4px;
  padding: 5px 8px;
  font-size: 10px;
}
.app > header button[class*="_iconButton_"] {
  color: #d3dfd3;
  width: 36px;
  height: 36px;
  border-radius: 5px;
}
.app > header button[class*="_iconButton_"]:hover { color: #fff; background: #355347; }
.app > header button[class*="_iconButton_"] svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.appBody { gap: 0; background: var(--bg-primary); }
.boardSection {
  justify-content: flex-start;
  gap: 0;
  padding: 22px clamp(20px, 3vw, 48px) 28px;
  background: #f4f1e9;
}
.boardSection > [class*="_toolbar_"] {
  order: 0;
  width: min(100%, 752px);
  padding: 0 0 18px;
  gap: 9px;
  background: transparent;
  border: 0;
}
.boardSection [class*="_toolbarRow_"] { gap: 8px; }
.boardSection [class*="_toolbarRow_"]:last-child { border-top: 1px solid #ddd7ca; padding-top: 10px; }
.boardSection [class*="_btn_de17w_"] {
  border: 1px solid #d1c8b7;
  background: #fffdf8;
  color: #2d3b33;
  padding: 8px 12px;
  min-height: 36px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
}
.boardSection [class*="_btnPrimary_"] { background: #9f4936; border-color: #9f4936; color: #fffdf8; }
.boardSection [class*="_modeSelect_"] {
  border: 1px solid #d1c8b7;
  background-color: #fffdf8;
  color: #20332b;
  font-weight: 650;
  border-radius: 6px;
  min-height: 36px;
}
.boardSection > [class*="_container_"] {
  order: 2;
  width: min(100%, calc(100dvh - 300px), 700px);
  max-width: 700px;
  max-height: 700px;
  border: 10px solid #d6b678;
  outline: 1px solid #b5975b;
  box-shadow: 0 8px 20px #483b2430, 0 2px 3px #483b2416;
}
.boardSection > [class*="_navigation_"] {
  order: 3;
  margin-top: 18px;
  width: min(100%, 752px);
  background: transparent;
  border: 0;
  gap: 10px;
}
.boardSection [class*="_navBtn_"] {
  color: #20362e;
  border-color: #d0c8b7;
  background: #fffdf8;
  border-radius: 6px;
  min-width: 42px;
  min-height: 38px;
}
.boardSection [class*="_navCounter_"] { font-size: 13px; color: #425448; font-weight: 700; }

.sideSection {
  width: clamp(340px, 31vw, 460px);
  background: #fffdf8;
  box-shadow: -5px 0 20px #1c2b2010;
}
.sideSection [class*="_sidePanel_"] { background: transparent; border-left: 1px solid #ddd8cb; }
.sideSection [class*="_gameInfo_"] {
  min-height: 72px;
  padding: 14px 22px;
  gap: 6px 18px;
  background: #f0ebe0;
  border-bottom: 1px solid #d8d1c0;
  font-size: 13px;
  color: #4c5a51;
}
.sideSection [class*="_turnInfo_"] { color: #1d302b; font-size: 16px; }
.sideSection [class*="_winRateChart_"] { height: 148px; background: #fffdf8; }
.sideSection [class*="_tabs_"] { border-bottom: 1px solid #ded8ca; }
.sideSection [class*="_tab_"] {
  padding: 16px 10px;
  color: #627065;
  font-size: 13px;
  font-weight: 700;
  border-bottom-width: 3px;
}
.sideSection [class*="_tabActive_"] { color: #9f4936; border-bottom-color: #9f4936; }
.sideSection [class*="_tabContent_"] { background: #fffdf8; }
.sideSection [class*="_emptyState_"] { color: #6b786e; line-height: 1.6; }

#go-save-status {
  order: 1;
  width: min(100%, 752px);
  padding: 0 0 13px;
  color: #41634f;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .02em;
}
#go-save-status.go-save-error { color: #a33428; }
#go-save-status.go-save-flash { animation: go-saved .55s ease-out; }
@keyframes go-saved { from { color: #a74d35; } to { color: #41634f; } }
#go-action-dock { display: none; }

body.go-night {
  --bg-primary: #192a24;
  --bg-secondary: #243830;
  --bg-tertiary: #34483b;
  --bg-hover: #3b5849;
  --text-primary: #f4f0e6;
  --text-secondary: #c1cfc4;
  --text-tertiary: #aab9ad;
  --border-color: #476052;
  --border-subtle: #384e41;
  --accent-color: #d78c6c;
  --accent-hover: #e4a88b;
  color-scheme: dark;
  background: #192a24;
}
body.go-night .appBody,
body.go-night .boardSection { background: #192a24; }
body.go-night .boardSection > [class*="_toolbar_"] { background: transparent; }
body.go-night .boardSection [class*="_btn_de17w_"],
body.go-night .boardSection [class*="_modeSelect_"],
body.go-night .boardSection [class*="_navBtn_"] {
  color: #f2ece0;
  background-color: #2e4438;
  border-color: #536b5a;
}
body.go-night .boardSection [class*="_btnPrimary_"] { background: #a9533a; color: #fff; border-color: #a9533a; }
body.go-night .boardSection [class*="_navCounter_"] { color: #d5e1d3; }
body.go-night .boardSection [class*="_toolbarRow_"]:last-child { border-top-color: #4d6253; }
body.go-night .sideSection,
body.go-night .sideSection [class*="_tabContent_"],
body.go-night .sideSection [class*="_winRateChart_"] { background: #24382f; }
body.go-night .sideSection [class*="_sidePanel_"] { border-color: #476052; }
body.go-night .sideSection [class*="_gameInfo_"] { background: #30463a; color: #d2ddce; border-color: #476052; }
body.go-night .sideSection [class*="_turnInfo_"] { color: #fff8e8; }
body.go-night .sideSection [class*="_tabs_"] { border-color: #476052; }
body.go-night .sideSection [class*="_tab_"] { color: #aebead; }
body.go-night .sideSection [class*="_tabActive_"] { color: #e6a084; border-color: #e6a084; }
body.go-night .sideSection [class*="_emptyState_"] { color: #b6c6b7; }
body.go-night #go-save-status { color: #b7d6ba; }

@media (max-width: 768px) {
  :root, [data-theme="light"] { --base-font-size: 14px; }
  .app { height: 100dvh; }
  .app > header[class*="_header_"] {
    height: 62px;
    padding: 0 19px;
  }
  .app > header [class*="_title_"] { font-size: 24px; }
  .app > header [class*="_headerLeft_"] { gap: 11px; }
  .app > header [class*="_modelBadge_"] { display: none; }
  .app > header [class*="_statusBadge_"] { font-size: 10px; padding: 5px 8px; }
  .app > header [class*="_headerRight_"] { gap: 2px; }
  .appBody { display: block; overflow-x: hidden; overflow-y: auto; padding-bottom: calc(82px + env(safe-area-inset-bottom)); }
  .boardSection { display: flex; flex: none; max-height: none; padding: 12px 14px 10px; }
  .boardSection > [class*="_container_"] {
    order: 1;
    width: min(100%, 620px);
    max-width: 620px;
    max-height: none;
    border-width: 6px;
    box-shadow: 0 5px 12px #483b2424;
  }
  #go-save-status { order: 0; padding: 2px 0 10px; font-size: 11px; }
  .boardSection > [class*="_navigation_"] { order: 2; margin: 8px 0 0; padding: 0; gap: 6px; }
  .boardSection [class*="_navBtn_"] { min-width: 38px; min-height: 34px; }
  .boardSection [class*="_navCounter_"] { min-width: 70px; }
  .boardSection > [class*="_toolbar_"] {
    display: none;
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: calc(80px + env(safe-area-inset-bottom));
    z-index: 20;
    width: auto;
    max-height: min(54dvh, 420px);
    overflow-y: auto;
    padding: 18px;
    background: #fffdf8;
    border: 1px solid #d4ccb9;
    border-radius: 14px;
    box-shadow: 0 12px 35px #1c29243d;
  }
  .go-tools-open .boardSection > [class*="_toolbar_"] { display: flex; }
  .boardSection [class*="_toolbarRow_"] { gap: 8px; }
  .boardSection [class*="_toolbarRow_"] > * { flex: 1 0 auto; }
  .boardSection [class*="_toolbarRow_"]:last-child { padding-top: 12px; }
  .sideSection { width: 100%; max-height: none; min-height: 360px; box-shadow: none; }
  .sideSection [class*="_sidePanel_"] { min-height: 360px; height: auto; border: 0; border-top: 1px solid #d7d0c2; }
  .sideSection [class*="_gameInfo_"] { min-height: 57px; padding: 10px 17px; font-size: 12px; }
  .sideSection [class*="_turnInfo_"] { font-size: 15px; }
  .sideSection [class*="_winRateChart_"] { height: 88px; }
  .sideSection [class*="_tab_"] { padding: 11px 10px; }
  .sideSection [class*="_tabContent_"] { min-height: 200px; flex: none; }
  #go-action-dock {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 21;
    padding: 7px 9px calc(8px + env(safe-area-inset-bottom));
    border-top: 1px solid #d8d2c5;
    background: #fffdf8;
    box-shadow: 0 -5px 17px #18292115;
  }
  #go-action-dock button {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    min-height: 56px;
    border: 0;
    border-radius: 9px;
    color: #3d5147;
    background: transparent;
    font-size: 11px;
    font-weight: 700;
    cursor: pointer;
  }
  #go-action-dock button.go-dock-primary { background: #1e4635; color: #fffdf8; }
  #go-action-dock button:active { transform: scale(.96); }
  #go-action-dock svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
  #go-action-dock circle { fill: currentColor; stroke: none; }
  body.go-night .boardSection > [class*="_toolbar_"],
  body.go-night #go-action-dock { background: #24382f; border-color: #476052; }
  body.go-night #go-action-dock button { color: #d6e5d8; }
  body.go-night #go-action-dock button.go-dock-primary { color: #fff; background: #a9533a; }
  body.go-night .sideSection [class*="_sidePanel_"] { border-color: #476052; }
}

@media (max-width: 380px) {
  .app > header[class*="_header_"] { padding-inline: 12px; }
  .boardSection { padding-inline: 8px; }
  .sideSection [class*="_gameInfo_"] { gap: 4px 10px; }
}

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