@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&family=Libre+Caslon+Display&family=Noto+Serif+SC:wght@600&family=Noto+Serif+TC:wght@600&display=swap');

:root {
  color-scheme: dark;
  --bg: #161d1a;
  --ink: #f0ecdc;
  --muted: #a6afa3;
  --gold: #d3b477;
  --line: #354138;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.5 'DM Sans', sans-serif; }
header { height: 58px; border-bottom: 1px solid var(--line); padding: 0 20px; display: flex; justify-content: space-between; align-items: center; }
.brand { font-size: 17px; letter-spacing: 3px; text-decoration: none; color: var(--ink); display: flex; align-items: center; gap: 10px; }
.seal { font: 25px 'Noto Serif TC', 'Noto Serif SC', serif; color: var(--gold); border: 1px solid var(--gold); width: 34px; height: 34px; text-align: center; }
.muted, .tag { color: var(--muted); }
.tag { font-size: 10px; letter-spacing: 2px; }
main { max-width: 1200px; margin: auto; padding: 16px 20px 24px; }
.layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(270px, 320px); gap: 18px; align-items: start; max-width: min(100%, calc((100dvh - 180px) * .9 + 370px)); margin: auto; }
.arena { min-width: 0; padding: 12px; background: #222c25; border: 1px solid #414b3d; }
.board-heading, .board-footer { display: flex; justify-content: space-between; font-size: 10px; letter-spacing: 1.4px; color: #d7d8c7; gap: 8px; }
.board-footer { font-family: 'Noto Serif TC', 'Noto Serif SC', 'DM Sans', sans-serif; }
.board-heading { margin-bottom: 8px; }
.board-footer { margin-top: 8px; }
.live { color: #b4c49e; font-size: 9px; }
#board { position: relative; aspect-ratio: 9 / 10; background: radial-gradient(ellipse at 30% 30%, #ebcf99, #cfa86b); box-shadow: 0 5px 25px #0004; color: #47351f; }
#board svg { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
#board svg text { font-family: 'Noto Serif TC', 'Noto Serif SC', 'Noto Serif CJK SC', serif; }
.point { position: absolute; transform: translate(-50%, -50%); width: 9.5%; aspect-ratio: 1; border: 0; border-radius: 50%; background: transparent; padding: 0; cursor: pointer; display: grid; place-items: center; color: inherit; z-index: 1; }
.point.piece { background: radial-gradient(circle at 40% 30%, #f5e5b8, #d6b77a); box-shadow: 1px 3px 3px #40270c80, inset 0 0 0 2px #af8950, inset 0 0 0 4px #f1d7a0; font: clamp(17px, 3vw, 38px) 'Noto Serif TC', 'Noto Serif SC', 'Songti SC', 'Noto Serif CJK SC', serif; color: #26342b; }
.point.red { color: #a33226; }
.point.selected { outline: 3px solid #fff4d2; box-shadow: 0 0 0 5px #9b553d; }
.point.legal:after { content: ''; width: 22%; height: 22%; border-radius: 50%; background: #335a39b0; position: absolute; }
.point.legal.piece:after { width: 104%; height: 104%; background: transparent; border: 3px solid #39613b; }
.point.last:not(.selected) { outline: 2px solid #9a6d30; }
.point:focus-visible { outline: 3px solid #fff; }
.point:disabled { cursor: default; }
.panel { border: 1px solid var(--line); padding: 15px; margin-bottom: 12px; background: #1c2520; }
.panel > p:not(.eyebrow) { color: var(--muted); }
.eyebrow { font-size: 10px; font-weight: 700; letter-spacing: 2px; color: var(--gold); margin: 0 0 7px; }
h2 { font: 25px/1.15 'Libre Caslon Display', Georgia, serif; margin: 0 0 7px; }
h3 { font-size: 15px; margin: 0 0 8px; }
#help { font-size: 12px; min-height: 34px; margin: 0 0 10px; }
label { display: block; font-size: 11px; letter-spacing: 1px; color: #bbc3b6; margin: 8px 0 4px; }
select { width: 100%; padding: 7px 9px; border: 1px solid #465142; background: #202b24; color: var(--ink); border-radius: 0; font: inherit; font-size: 12px; }
.primary { margin-top: 12px; padding: 10px 12px; width: 100%; display: flex; justify-content: space-between; border: 0; background: var(--gold); color: #1c241e; font-weight: 700; cursor: pointer; }
.primary:disabled { opacity: .45; cursor: wait; }
.fine { font-size: 10px; line-height: 1.4; margin-bottom: 0; }
#history { max-height: 130px; overflow: auto; padding-left: 23px; margin: 0; font-size: 12px; color: #bfc7b8; }
#history li { padding: 3px 0; border-bottom: 1px solid #303b31; }
.empty { list-style: none; color: #778775; margin-left: -23px; }
details { font-size: 12px; color: var(--muted); }
summary { cursor: pointer; color: var(--ink); font-size: 13px; }
a { color: var(--gold); }

@media (max-width: 800px) {
  .tag { display: none; }
  main { padding: 12px 12px 24px; }
  .layout { display: flex; flex-direction: column; align-items: center; max-width: 100%; gap: 12px; }
  .arena, aside { width: min(100%, 550px); }
  .arena { padding: 8px; }
  .point.piece { font-size: clamp(18px, 5vw, 34px); }
  .panel:first-child { padding-bottom: 56px; }
  #new { position: fixed; left: 12px; right: 12px; bottom: max(12px, env(safe-area-inset-bottom)); width: auto; margin: 0; z-index: 10; box-shadow: 0 4px 20px #0008; }
}

@media (max-height: 650px) and (min-width: 801px) {
  .layout { max-width: min(100%, calc((100dvh - 145px) * .9 + 350px)); }
}
