.ch { max-width: 860px; margin: 0 auto; padding: 10px 8px 16px; user-select: none; color: #dfe9ff; }
.ch [hidden] { display: none !important; }
.ch-top { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin: 0 0 12px; }
.ch-opts { display: flex; gap: 10px; flex-wrap: wrap; font-size: 13px; color: #8aa3c4; }
.ch-opts select { background: #0b1328; color: #dfe9ff; border: 1px solid #1c2b4a; border-radius: 6px; padding: 5px 8px; font-size: 13px; margin-left: 4px; }
.ch-tools { display: flex; gap: 6px; }
.ch-btn { background: #0b1328; color: #dfe9ff; border: 1px solid #1c2b4a; border-radius: 8px; padding: 7px 12px; font-weight: 700; font-size: 13px; cursor: pointer; }
@media (hover: hover) { .ch-btn:hover:not(:disabled) { border-color: #55d6ff; } } .ch-btn:disabled { opacity: 0.4; cursor: default; }
.ch-btn:active:not(:disabled) { transform: translateY(1px); }
.ch-btn-primary { background: #ffd166; color: #1a1200; border-color: #ffd166; } @media (hover: hover) { .ch-btn-primary:hover:not(:disabled) { background: #ffe08a; border-color: #ffe08a; } }
.ch-main { display: grid; grid-template-columns: minmax(0, 1fr) 220px; gap: 16px; align-items: start; }
.ch-boardwrap { width: 100%; max-width: 560px; margin: 0 auto; }
.ch-board { display: grid; grid-template-columns: repeat(8, 1fr); grid-template-rows: repeat(8, 1fr); aspect-ratio: 1; width: 100%; border: 2px solid #3d5a7a; border-radius: 6px; overflow: hidden; touch-action: none; position: relative; }
.ch-sq { position: relative; aspect-ratio: 1; min-width: 0; min-height: 0; overflow: hidden; }
.ch-sq.light { background: #c9d7e6; } .ch-sq.dark { background: #5a7fa6; }
.ch-sq.light.last { background: #ecdfa4; } .ch-sq.dark.last { background: #b9a865; }   /* solid tints: overlays turn muddy on blue */
.ch-sq.light.sel { background: #a9e3f5; } .ch-sq.dark.sel { background: #3fa6cf; }
.ch-sq.check { background-image: radial-gradient(circle, rgba(255,70,90,0.95) 0, rgba(255,70,90,0.6) 45%, rgba(255,70,90,0) 75%); }
.ch-sq.hint { box-shadow: inset 0 0 0 4px #ffd166; }
.ch-sq .dot { position: absolute; left: 37%; top: 37%; width: 26%; height: 26%; border-radius: 50%; background: rgba(10,20,40,0.35); pointer-events: none; }
.ch-sq .ring { position: absolute; inset: 6%; border-radius: 50%; border: 4px solid rgba(10,20,40,0.35); pointer-events: none; }
.ch-sq .coord { position: absolute; font-size: 9px; font-weight: 700; opacity: 0.6; pointer-events: none; }
.ch-sq .coord.f { right: 3px; bottom: 1px; } .ch-sq .coord.r { left: 3px; top: 1px; }
.ch-sq.light .coord { color: #3d5a7a; } .ch-sq.dark .coord { color: #e6eef7; }
.ch-sq > .ch-piece { position: absolute; inset: 7%; width: 86%; height: 86%; cursor: grab; }
.ch-sq:focus-visible { outline: none; box-shadow: inset 0 0 0 3px #55d6ff; z-index: 1; }
.ch-board:active .ch-piece { cursor: grabbing; }
.ch-piece.dragging { opacity: 0.25; }
.ch-ghost { position: absolute; pointer-events: none; z-index: 5; width: 12.5%; height: 12.5%; }
.ch-ghost .ch-piece { position: absolute; inset: 4%; width: 92%; height: 92%; filter: drop-shadow(0 6px 10px rgba(0,0,0,0.5)); }
.ch-captured { min-height: 20px; display: flex; gap: 1px; flex-wrap: wrap; align-items: center; padding: 1px 2px; }   /* fixed floor: no jump on first capture */
.ch-captured svg { width: 18px; height: 18px; display: block; } .ch-captured b { font-size: 12px; color: #8aa3c4; margin-left: 6px; }
.ch-side { background: #0b1328; border: 1px solid #1c2b4a; border-radius: 10px; padding: 12px; min-height: 200px; }
.ch-status { font-weight: 700; font-size: 15px; margin: 0 0 10px; color: #fff; }
.ch-moves { margin: 0; padding: 0; list-style: none; display: grid; grid-template-columns: 28px 1fr 1fr; gap: 2px 6px; font-size: 13px; max-height: 320px; overflow: auto; font-variant-numeric: tabular-nums; }
.ch-moves li { display: contents; } .ch-moves .n { color: #8aa3c4; } .ch-moves span { padding: 1px 4px; border-radius: 3px; } .ch-moves span.cur { background: #1c2b4a; color: #fff; }
.ch-record { margin-top: 12px; font-size: 12px; color: #8aa3c4; }
.ch-overlay { position: fixed; inset: 0; background: rgba(2,5,14,0.78); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 16px; }
.ch-overlay:not([hidden]) .ch-dialog { animation: ch-pop .18s ease-out; }
@keyframes ch-pop { from { transform: scale(.94); opacity: 0; } }
.ch-dialog { background: #0b1328; border: 1px solid #244b6b; border-radius: 12px; padding: 22px; width: min(100%, 380px); text-align: center; }
.ch-dialog h3 { margin: 0 0 6px; color: #fff; font-size: 22px; } .ch-dialog p { margin: 0 0 14px; color: #8aa3c4; }
.ch-promo { display: flex; gap: 8px; justify-content: center; margin: 0 0 8px; }
.ch-promo button { width: 64px; height: 64px; padding: 0; background: #c9d7e6; border: 2px solid #3d5a7a; border-radius: 8px; cursor: pointer; } @media (hover: hover) { .ch-promo button:hover { border-color: #ffd166; } }
.ch-promo button { position: relative; } .ch-promo svg { position: absolute; inset: 10%; width: 80%; height: 80%; }
.ch-cancel { margin-top: 6px; }
.ch-actions { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.ch-thinking { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #55d6ff; margin-left: 6px; animation: ch-pulse .8s infinite alternate; }
@keyframes ch-pulse { to { opacity: 0.2; } }
@media (max-width: 700px) {   /* phones (kept last so it overrides the base rules): whose turn sits above the board, the move list becomes a strip below it */
  .ch-main { grid-template-columns: 1fr; gap: 6px; }
  .ch-side { display: contents; }
  .ch-status { order: -1; text-align: center; margin: 0; font-size: 15px; }
  .ch-moves:empty { display: none; }
  .ch-moves { order: 1; display: flex; gap: 2px 10px; overflow-x: auto; max-height: none; padding: 6px 2px; scrollbar-width: none; }
  .ch-moves::-webkit-scrollbar { display: none; }
  .ch-moves li { display: flex; gap: 4px; flex: none; }
  .ch-record { order: 2; text-align: center; margin: 0; }
}
/* full screen (.ch-fit, set by game.js inside the site's immersive stage): no page scrolling, board sized to fit */
.ch.ch-fit { max-width: none; height: 100%; margin: 0; padding: 6px 4px 8px; display: flex; flex-direction: column; overflow: hidden; }
.ch-fit .ch-top { flex: none; margin: 0 0 6px; gap: 6px; justify-content: center; }
.ch-fit .ch-opts { gap: 6px; font-size: 12px; justify-content: center; } .ch-fit .ch-opts select { padding: 4px 6px; font-size: 12.5px; }
.ch-fit .ch-btn { padding: 6px 10px; font-size: 12.5px; }
.ch-fit .ch-main { flex: 1 1 auto; min-height: 0; gap: 6px; align-items: stretch; }
.ch-fit .ch-boardwrap { min-width: 0; min-height: 0; max-width: none; width: auto; margin: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.ch-fit .ch-board, .ch-fit .ch-captured { width: var(--ch-bs); flex: none; }
.ch-fit .ch-status { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* portrait: status, board, move strip, record stacked */
.ch.ch-port { justify-content: center; }   /* controls and board travel together as one centred group */
.ch-port .ch-main { flex: 0 0 auto; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto auto auto auto; }
.ch-port .ch-side { display: contents; }
.ch-port .ch-status { order: -1; text-align: center; margin: 0; font-size: 15px; }
.ch-port .ch-moves, .ch-port .ch-moves:empty { order: 1; display: flex; min-height: 24px; gap: 2px 10px; overflow-x: auto; max-height: none; padding: 2px; scrollbar-width: none; }
.ch-port .ch-moves li { display: flex; gap: 4px; flex: none; }
.ch-port .ch-record { order: 2; text-align: center; margin: 0; }
/* landscape: board on the left; controls, status and moves in a column beside it */
/* the grid is exactly board + panel, centred; the panel matches the board's height and scrolls its move list */
.ch.ch-land { display: grid; grid-template-columns: var(--ch-bs) 250px; grid-template-rows: auto minmax(0, 1fr); gap: 6px 14px; padding: 6px; height: auto; flex: 0 0 auto; margin: auto; justify-content: center; }
.ch-land .ch-main { display: contents; }
.ch-land .ch-boardwrap { grid-column: 1; grid-row: 1 / -1; }
.ch-land .ch-top { grid-column: 2; grid-row: 1; margin: 0; flex-direction: column; align-items: stretch; }
.ch-land .ch-opts { flex-direction: column; gap: 4px; }
.ch-land .ch-opts label { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.ch-land .ch-opts select { width: 62%; margin: 0; }
.ch-land .ch-tools { flex-wrap: wrap; } .ch-land .ch-tools .ch-btn { flex: 1 1 auto; }
.ch-land .ch-side { grid-column: 2; grid-row: 2; display: flex; flex-direction: column; height: 0; min-height: 100%; padding: 10px; overflow: hidden; }
.ch-land .ch-status { order: 0; text-align: left; margin: 0 0 8px; }
.ch-land .ch-moves { display: grid; flex: 1 1 auto; min-height: 0; max-height: none; align-content: start; }
.ch-land .ch-moves:empty { display: grid; }
.ch-land .ch-record { margin: 8px 0 0; text-align: left; }
.ch-fit .ch-captured { flex-wrap: nowrap; overflow: hidden; height: 20px; }
.ch-fit .ch-captured svg { width: min(18px, calc(var(--ch-bs) / 19)); height: min(18px, calc(var(--ch-bs) / 19)); flex: none; }
