:root {
  font-family: system-ui, -apple-system, "Hiragino Kaku Gothic ProN", "Yu Gothic", sans-serif;
  background: #faf7f2;
  color: #28241e;
}
* { box-sizing: border-box; }
html { min-width: 0; }
body { margin: 0; min-width: 0; }
a { color: inherit; }
button, input, textarea, select { font: inherit; }
.shell { max-width: 1250px; margin: 0 auto; padding: 30px 24px; }
header, .row, .toolbar { display: flex; align-items: center; justify-content: space-between; gap: 15px; }
header { align-items: end; }
h1 { font-size: clamp(25px, 3vw, 30px); letter-spacing: -.05em; margin: 8px 0 0; line-height: 1.25; }
h2 { font-size: 15px; margin: 0; font-weight: 600; }
.sub { font-size: 12px; line-height: 1.6; color: #817668; overflow-wrap: anywhere; }
main { display: grid; grid-template-columns: minmax(0, 1fr) minmax(270px, 340px); align-items: start; gap: 16px; margin-top: 26px; }
.card { min-width: 0; background: #fffdfa; border: 1px solid #e7ded2; border-radius: 10px; padding: 19px; box-shadow: 0 3px 16px #6c4c2508; }
button, .btn { display: inline-flex; justify-content: center; align-items: center; gap: 5px; min-height: 40px; border: 1px solid #d9cfc1; border-radius: 6px; background: #fff; color: #302920; cursor: pointer; padding: 9px 12px; font-size: 13px; line-height: 1.25; text-align: center; text-decoration: none; }
button:hover, .btn:hover { background: #f4ece2; }
button:disabled { opacity: .4; cursor: default; }
button:focus-visible, a:focus-visible, summary:focus-visible, select:focus-visible, .btn:focus-within { outline: 3px solid #ba8256; outline-offset: 2px; }
.primary { background: #302820; color: #fff; border-color: #302820; }
.primary:hover { background: #584330; }
input[type=file] { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; }
.header-actions, .output-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
#import { margin-top: 18px; }
textarea { display: block; width: 100%; min-height: 125px; margin: 12px 0; padding: 12px; border: 1px solid #dfd5c7; border-radius: 5px; background: #fcf8f2; font: 13px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; resize: vertical; }
#notice { margin-top: 12px; color: #9e532f; font-size: 13px; }
#notice:empty { display: none; }
.board-header { align-items: start; flex-wrap: wrap; }
#meta { display: block; margin-top: 5px; }
.board-tools { display: flex; justify-content: flex-end; align-items: center; flex-wrap: wrap; gap: 14px; margin-left: auto; }
.orientation { display: inline-flex; align-items: center; gap: 5px; cursor: pointer; font-size: 13px; color: #665a4b; min-height: 36px; white-space: nowrap; }
.orientation input { width: 17px; height: 17px; accent-color: #9a5e36; }
.edit { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; cursor: pointer; font-size: 13px; color: #9a5e36; min-height: 36px; }
.edit input { width: 17px; height: 17px; accent-color: #9a5e36; }
#board { width: min(100%, 560px); margin: 18px auto; touch-action: manipulation; user-select: none; }
#board svg { display: block; width: 100%; height: auto; aspect-ratio: 1; background: #e8c695; border-radius: 5px; }
svg .grid { stroke: #715735; stroke-width: 1; }
svg .stoneB { fill: #252321; stroke: #171613; }
svg .stoneW { fill: #fffefa; stroke: #5e5549; }
svg text { font: 12px monospace; fill: #57452f; }
svg .hit { fill: transparent; cursor: crosshair; }
svg .hit:hover { fill: #a5754560; }
#slider { display: block; width: 100%; margin: 12px 0; min-height: 28px; accent-color: #ad7049; }
.controls { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)) minmax(78px, auto) repeat(2, minmax(0, 1fr)); gap: 8px; align-items: center; }
.controls button { min-width: 0; min-height: 44px; padding: 8px 4px; }
.controls b { text-align: center; font: 13px/1.2 ui-monospace, monospace; white-space: nowrap; }
.status-row { align-items: center; flex-wrap: wrap; }
.status-row .sub { flex: 1 1 170px; }
.status-row button { margin-left: auto; }
aside { display: grid; gap: 16px; min-width: 0; }
.panel > summary { display: flex; align-items: center; justify-content: space-between; gap: 8px; list-style: none; cursor: pointer; font-size: 15px; font-weight: 600; }
.panel > summary::-webkit-details-marker { display: none; }
.panel > summary::after { content: "⌄"; color: #8d8171; transition: transform .15s ease; }
.panel[open] > summary::after { transform: rotate(180deg); }
.panel > .scroll, .panel > .panel-content { margin-top: 12px; }
.scroll { max-height: 325px; min-width: 0; overflow: auto; overscroll-behavior: contain; }
#tree, #history { overflow-anchor: none; }
.item { display: flex; align-items: center; gap: 9px; width: 100%; min-height: 36px; padding: 7px 8px; text-align: left; border: 0; background: transparent; font: 13px/1.3 ui-monospace, monospace; border-radius: 4px; justify-content: flex-start; overflow-wrap: anywhere; }
.item.active { background: #f8ebdf; color: #8b4a29; }
.item .dot { width: 11px; height: 11px; border-radius: 50%; border: 1px solid #8b8172; flex-shrink: 0; }
.dot.B { background: #252321; }
.dot.W { background: #fff; }
#count { min-height: 36px; max-width: 100%; border: 1px solid #d9cfc1; border-radius: 6px; background: white; font-size: 13px; padding: 5px; }
.output { grid-column: 1 / -1; }
.output .toolbar { flex-wrap: wrap; }
.export-settings { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 16px; }
.export-settings label { font-size: 13px; color: #665a4b; }
.export-settings select { min-height: 42px; max-width: 100%; background: #fff; border: 1px solid #d9cfc1; border-radius: 6px; color: #302920; padding: 8px 10px; font-size: 13px; }
.output pre { display: block; min-width: 0; max-width: 100%; max-height: 470px; overflow: auto; padding: 17px; margin: 15px 0 9px; border: 1px solid #eee4d8; border-radius: 6px; background: #fbf8f3; font: 12px/1.6 ui-monospace, SFMono-Regular, Menlo, monospace; white-space: pre; -webkit-overflow-scrolling: touch; }
.output p { margin: 0; }
footer { font-size: 11px; color: #8c7f71; margin: 24px 0; }

@media (max-width: 860px) {
  .shell { padding: 22px 18px; }
  main { grid-template-columns: minmax(0, 1fr); gap: 14px; margin-top: 18px; }
  .output { grid-column: 1; }
  aside { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
  .scroll { max-height: 260px; }
  header { align-items: center; }
}
@media (max-width: 640px) {
  .shell { padding: 16px 12px 26px; }
  header { display: block; }
  header h1 { margin: 9px 0 14px; }
  .header-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; width: 100%; }
  .header-actions > * { min-width: 0; width: 100%; min-height: 44px; }
  .card { padding: 13px; border-radius: 8px; }
  .board-header { gap: 8px; }
  .board-tools { width: 100%; margin-left: 0; justify-content: flex-end; gap: 20px; }
  #board { width: 100%; margin: 13px auto 14px; }
  .controls { gap: 5px; grid-template-columns: repeat(2, minmax(0, 1fr)) minmax(73px, auto) repeat(2, minmax(0, 1fr)); }
  .controls button { min-height: 46px; font-size: 15px; }
  .controls b { font-size: 12px; }
  .status-row { gap: 8px; }
  .status-row button { min-height: 42px; }
  aside { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .scroll { max-height: 210px; }
  .item { min-height: 42px; }
  .output .toolbar { display: block; }
  .export-settings { align-items: stretch; }
  .export-settings label { align-self: center; }
  .export-settings select { flex: 1 1 180px; min-width: 0; }
  .output .toolbar h2 { margin-bottom: 12px; }
  .output-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .output-actions button { width: 100%; min-height: 44px; }
  #copy { grid-column: 1 / -1; }
  .output pre { padding: 12px; font-size: 11px; line-height: 1.55; max-height: 360px; }
  #import .row { align-items: stretch; flex-wrap: wrap; }
  #import .row button { min-height: 44px; }
}
@media (max-width: 360px) {
  .shell { padding: 10px 8px 20px; }
  .card { padding: 10px; }
  .controls { gap: 3px; }
  .controls button { padding: 7px 1px; }
  .header-actions button, .header-actions .btn { font-size: 12px; }
}
@media (prefers-reduced-motion: reduce) {
  .panel > summary::after { transition: none; }
}
