/* Xiangqi page, page-scoped styles. The board is a direct child of .stage like every other
   Arcade cabinet: no intermediate panel, no duplicate toolbar. 654px is the approved board
   width, kept as a cap so the board does not inflate on wide screens. */
.xq-panel .xq-status{margin:10px 0 0;font-size:12px;line-height:1.5;color:#9fb3c8;height:30px}
.xq-board{position:relative;width:100%;max-width:654px;aspect-ratio:1229/1355;margin:0 auto;
  background:url(assets/board.svg) center center/100% 100% no-repeat;border-radius:8px}
.xq-piece{position:absolute;width:9.6775%;height:auto;transform:translate(-50%,-50%);pointer-events:none;user-select:none}
@media (max-width:760px){.xq-board{border-radius:6px}
  /* Shared chrome defect, worked around locally: arcade.css switches .hero-line to one column at
     760 px but leaves grid-column:1/2/3 on the children, so the chip still gets its own implicit
     column and a long label pushes the layout viewport wider than the screen. Let it take a row. */
  .hero-line>.levelnote{grid-column:1/-1;justify-self:start;white-space:normal}}

/* The page is named in English for newcomers, with the traditional name beside it. The h1 is
   uppercased by the shared sheet; CJK has no case, so only the size and colour need setting. */
.hero-line h1 .hero-zh{display:inline-block;margin-left:.22em;font-size:.44em;font-weight:650;
  letter-spacing:.02em;line-height:1;color:var(--gold);vertical-align:.22em}

/* Small-viewport board widening. At <=360px the shell/stage padding left the board at 240-270px,
   which put the pieces at 23.8-26.6px and cost legibility on the denser characters (傌 砲 馬 象).
   Trim the outer padding and cap the board so pieces land at 27-28px with no horizontal overflow.
   Measured: 320px -> board 296 / pieces 28.6px; 360px -> board 296 / pieces 28.6px. */
@media (max-width:360px){.shell{padding-left:6px;padding-right:6px}
  .stage{padding-left:6px;padding-right:6px}
  .xq-board{max-width:296px}}

/* indicator legend */
.xq-indicators{display:grid;grid-template-columns:1fr 1fr;gap:10px 14px;margin:6px 0 14px}
.xq-ind{display:flex;align-items:center;gap:10px;font-size:12px;color:#9fb3c8}
.xq-ind-piece{position:relative;display:inline-flex;width:38px;height:38px}
.xq-ind-piece img{width:38px;height:38px;display:block}
.xq-ind-piece i{position:absolute;inset:-4px;border-radius:50%;pointer-events:none}
.xq-ring-selected{border:2px solid #b5f779}
.xq-ring-last{border:2px solid #b5f779;opacity:.55;inset:-6px}
.xq-dot{inset:auto -10px 50% auto;width:9px;height:9px;margin-bottom:-4px;background:#b5f779;border-radius:50%}
.xq-ring-check{border:2px solid #4a2500;box-shadow:0 0 0 2px #ffd98a inset}

/* the "at real sizes" sample row was a review aid, not guidance - removed with the Status block */
.xq-small{font-size:12px;color:#8ea6c0;line-height:1.5}

/* ---- local play -----------------------------------------------------------
   The pieces only become interactive once game.js has taken over the board, so if the module
   fails to load the page degrades to the static preview it was before. Marks are positioned on
   the same percentage grid as the pieces, so they stay on the painted intersections at any
   board width; all sizes are a percentage of board width for the same reason. */
/* Pieces and marks live in their own layers so a selection repaints only the marks. */
.xq-layer{position:absolute;inset:0}
.xq-layer--marks{z-index:2}
.xq-board.is-playable .xq-piece{pointer-events:auto;cursor:pointer}
.xq-board.is-playable .xq-piece:focus-visible{outline:2px solid #b5f779;outline-offset:2px;border-radius:50%}
.xq-piece.is-dragging{z-index:5;cursor:grabbing;filter:drop-shadow(0 6px 10px rgba(0,0,0,.5))}

.xq-mark{position:absolute;transform:translate(-50%,-50%);border-radius:50%;pointer-events:none;z-index:3}
.xq-mark--sel{width:10.6%;aspect-ratio:1;border:2px solid #b5f779}
.xq-mark--last{width:10.4%;aspect-ratio:1;border:2px solid rgba(181,247,121,.5)}
.xq-mark--check{width:11%;aspect-ratio:1;border:2px solid #4a2500;box-shadow:0 0 0 2px #ffd98a inset}
.xq-mark--dot{width:2.4%;aspect-ratio:1;background:#b5f779;box-shadow:0 0 0 1px rgba(6,22,45,.6)}
.xq-mark--cap{width:10.8%;aspect-ratio:1;border:3px solid #ffd98a}
.xq-target{pointer-events:auto;cursor:pointer;padding:0;appearance:none;border-radius:50%}
.xq-target.xq-mark--dot{border:0}
.xq-target.xq-mark--cap{background:transparent}
.xq-target:focus-visible{outline:2px solid #ffffff;outline-offset:2px}

/* One panel: Play controls on top, Guide below, ending level with the stage.
   .game-layout is a wrapping flex row (arcade.css), so the panel is a flex item - 360px beside
   the board above 820px, full width beneath it after that. 360px is the narrowest width that
   holds ELEPHANT (42px at 8px type) on one line in a seven-column key; the board keeps its 654px
   because the stage only shrinks to 798px. */
.game-layout>.xq-panel{flex:0 0 360px;max-width:360px;min-width:0;align-self:stretch}
.xq-panel h2:not(:first-of-type){margin-top:20px;padding-top:16px;border-top:1px solid #27436280}

/* The stage's shared flex-basis is 857.6px, which makes a line too wide for both items and pushes
   the panel to the next row. A 686px basis (the board's 654px plus the stage's own 32px) lets the
   two share a row from 1108px of viewport upward, with the stage growing back to 858px when the
   room is there. Below that the panel takes the full row beneath the board. */
.game-layout>.stage{flex:1 1 686px}
@media (max-width:1107px){
  /* capped at the stage's own maximum so the two boxes stay the same width in the stacked
     layout; .game-layout centres both, so they stay aligned */
  .game-layout>.xq-panel{flex:1 1 100%;max-width:857.6px}
  .xq-panel h2:not(:first-of-type){margin-top:16px;padding-top:14px}
}

/* piece key: name, Red disc, Black disc - one column per piece */
.xq-key{display:grid;grid-template-columns:repeat(7,minmax(0,1fr));gap:2px;margin:2px 0 8px}
.xq-key-col{display:grid;justify-items:center;gap:3px;min-width:0}
.xq-key-name{font-size:8px;line-height:1.2;letter-spacing:0;text-transform:uppercase;
  color:#cfd8e3;white-space:nowrap}
.xq-key-hint{font-size:8px;line-height:1.3;color:#9fb3c8;text-align:center;text-wrap:balance;
  min-height:2.6em}  /* two lines reserved so every caption sits on the same baseline */
.xq-key img{width:30px;height:30px;display:block}
@media (max-width:820px){.xq-key img{width:36px;height:36px}.xq-key-name{font-size:9px}
  .xq-key-hint{font-size:8px}}
@media (max-width:430px){.xq-key img{width:32px;height:32px}.xq-key-name{font-size:8px}}
/* ELEPHANT is the widest label: 42px at 8px type against a 43.7px column at 360px, 36px of
   label in a 36px column at 320px. */
@media (max-width:360px){.xq-key-name{font-size:7px;letter-spacing:-.01em}}

/* Guide section headings sit one level below the panel title */
.xq-panel h3{margin:12px 0 6px;font-size:11px;font-weight:850;letter-spacing:.14em;
  text-transform:uppercase;color:#8ea6c0}
.xq-panel h2{margin-bottom:8px}
.xq-panel p{margin:0 0 6px;font-size:12px;line-height:1.55}
.xq-panel ul{margin:0 0 6px;padding-left:15px}
.xq-panel li{font-size:12px;line-height:1.5;color:#9fb3c8;margin:0 0 4px}
.xq-panel li::marker{color:#b5f779}
.xq-panel .xq-small{margin:0 0 6px;font-size:11px;line-height:1.45}

/* The shared stage cap (arcade.css, max-height:748px above 767px) is sized for 16:9 canvases.
   The Xiangqi board is a portrait SVG: at the approved 654px width it is 721px tall, so board +
   controls + status cannot fit inside 748px and the board was painting 26px above and 24px below
   the stage border. Keep the approved board size and let this page's stage wrap its content.
   Scoped to this page; no shared rule is changed. */
.game-layout>.stage{max-height:none}
/* Match setup sits above the board and the play buttons below it, so the panel carries only the
   state of the game and the guide. Both strips are capped at the board width and centred. */
.xq-setup{display:flex;flex-wrap:wrap;align-items:center;justify-content:center;gap:8px;
  width:100%;max-width:654px;margin:0 auto 12px}
.xq-seg{display:flex;gap:6px;justify-content:center;flex-wrap:wrap}
.xq-seg[hidden]{display:none}
.xq-seg-btn{font:inherit;font-size:11px;font-weight:800;letter-spacing:.07em;text-transform:uppercase;
  color:#b9c8d6;background:#122234;border:1px solid #27405a;border-radius:6px;padding:7px 12px;
  cursor:pointer;flex:0 0 auto;white-space:nowrap}
.xq-seg-btn:hover{border-color:#b5f779;color:#fff}
.xq-seg-btn.is-on{color:#b5f779;background:rgba(181,247,121,.12);border-color:rgba(181,247,121,.5)}
.xq-seg-btn:focus-visible{outline:2px solid #b5f779;outline-offset:2px}
.stage .xq-controls{display:flex;align-items:center;justify-content:center;gap:8px;flex-wrap:wrap;
  width:100%;max-width:654px;margin:12px auto 0}
/* Only the cursor changes while the AI thinks. Dimming the whole piece layer forced a repaint of
   every piece on each ply, which showed up as a flicker. */
.xq-board.is-thinking{cursor:progress}
@media (max-width:430px){.xq-seg-btn{font-size:10px;padding:6px 8px}}

.xq-btn{font:inherit;font-size:12px;font-weight:700;letter-spacing:.04em;text-transform:uppercase;color:#dbe7f3;background:#16273a;border:1px solid #2b4159;border-radius:6px;padding:7px 12px;cursor:pointer}
.xq-btn:hover:not(:disabled){border-color:#b5f779;color:#fff}
.xq-btn:disabled{opacity:.4;cursor:default}
.xq-btn:focus-visible{outline:2px solid #b5f779;outline-offset:2px}
.xq-panel .xq-turn{margin:4px 0 0;text-align:center;font-size:14px;line-height:1.3;letter-spacing:.08em;text-transform:uppercase;font-weight:800;color:#cfd8e3}
.xq-turn[data-side="r"]{color:#ff9f8b}
.xq-turn[data-side="b"]{color:#cfd8e3}

/* Result panel. Mirrors the Chess panel so the two strategy games read the same: the finished
   position stays visible behind translucent navy and the board is never cleared. */
/* The board replaces its own children on every render (replaceChildren of the piece and mark
   layers), so the panel cannot live inside it. It is a sibling in the stage, and its box is set
   from the board's measured geometry so it covers exactly the board at every width. */
.stage{position:relative}
.xq-result{position:absolute;z-index:6;display:flex;align-items:center;justify-content:center;
  padding:12px;text-align:center;background:rgba(6,22,45,.58);border-radius:inherit}
.xq-result[hidden]{display:none}
.xq-result-card{display:flex;flex-direction:column;align-items:center;gap:3px;max-width:100%;
  padding:18px;background:rgba(8,26,52,.95);border:1px solid rgba(181,247,121,.28);border-radius:14px;
  box-shadow:0 18px 40px rgba(0,0,0,.45)}
.xq-result-kicker{margin:0;font:600 10.5px/1 system-ui,-apple-system,sans-serif;letter-spacing:.22em;color:#8fa1b8}
.xq-result-title{margin:4px 0 0;font:800 clamp(20px,4.2vw,34px)/1.08 system-ui,-apple-system,sans-serif;
  color:#b5f779;text-transform:uppercase}
.xq-result-reason{margin:0;font:13px/1.4 system-ui,-apple-system,sans-serif;color:#cdd7e5}
.xq-result-actions{display:flex;flex-wrap:wrap;gap:10px;justify-content:center;margin-top:14px}
.xq-result-btn{appearance:none;border:1px solid #b5f779;background:#b5f779;color:#0d1117;border-radius:10px;
  padding:9px 16px;font:600 14px/1 system-ui,-apple-system,sans-serif;cursor:pointer}
.xq-result-btn.is-quiet{background:transparent;color:#cdd7e5;border-color:#354761}
.xq-result-btn:focus-visible{outline:2px solid #b5f779;outline-offset:2px}
@media (max-width:420px){
  .xq-result{padding:8px}
  .xq-result-card{padding:14px 12px}
  .xq-result-actions{flex-direction:column;align-items:stretch;width:100%;max-width:190px}
}