/* Chess — an Atlas board of sand and jade squares in a bronze frame; ivory pieces against dark jade. */
.ch-col { padding: 4px 6px 6px; gap: 4px; }
.ch-wrap { direction: ltr; flex: 0 1 auto; aspect-ratio: 1 / 1; max-width: 640px; container-type: size; }
/* the frame is the largest square that fits the space between the two trays */
.ch-frame { position: relative; width: min(100cqw, 100cqh); height: min(100cqw, 100cqh); padding: 1.6%; border-radius: 10px;
  background: linear-gradient(145deg, #C99A4A, #8A5A33 55%, #6E4526); box-shadow: 0 10px 26px rgba(0, 0, 0, 0.45), inset 0 0 0 1px rgba(246, 236, 203, 0.35); }
.ch-board { display: grid; grid-template-columns: repeat(8, 1fr); grid-template-rows: repeat(8, 1fr); width: 100%; height: 100%;
  border-radius: 4px; overflow: hidden; touch-action: none; user-select: none; -webkit-user-select: none; box-shadow: 0 0 0 1px rgba(11, 31, 28, 0.6); }

.ch-sq { position: relative; min-width: 0; min-height: 0; margin: 0; padding: 0; border: 0; border-radius: 0; cursor: pointer; overflow: visible;
  -webkit-tap-highlight-color: transparent; font: inherit; }
.ch-sq--l { background: #DCCB98; color: #2C7A66; }
.ch-sq--d { background: #37907A; color: #E6D8AA; }
.ch-sq:focus-visible { outline: 3px solid #FFF7DC; outline-offset: -3px; z-index: 3; }
.ch-sq.is-last { box-shadow: inset 0 0 0 100px rgba(255, 214, 94, 0.42); }
.ch-sq.is-sel { box-shadow: inset 0 0 0 100px rgba(255, 214, 94, 0.62); }
.ch-sq.is-check { box-shadow: inset 0 0 0 100px rgba(226, 85, 58, 0.78); animation: ch-pulse 1s ease-in-out infinite; }
.ch-sq.is-mate { box-shadow: inset 0 0 0 100px rgba(226, 85, 58, 0.85); }
/* where the chosen piece may go: a dot on an empty square, a ring round a piece it can take */
.ch-sq.is-go { background-image: radial-gradient(circle, rgba(11, 31, 28, 0.42) 0 17%, transparent 19%); }
.ch-sq.is-take { background-image: radial-gradient(circle, transparent 0 52%, rgba(226, 85, 58, 0.9) 54% 66%, transparent 68%); }
/* board coordinates along the left and bottom edges */
.ch-sq::before, .ch-sq::after { position: absolute; font-size: clamp(8px, 1.5vmin, 12px); font-weight: 700; line-height: 1; opacity: 0.9; pointer-events: none; }
.ch-sq::before { content: attr(data-r); left: 3px; top: 3px; }
.ch-sq::after { content: attr(data-f); right: 3px; bottom: 2px; }

.ch-pc { position: relative; z-index: 2; display: block; width: 100%; height: 100%; pointer-events: none; stroke-width: 1.3; stroke-linejoin: round; paint-order: stroke; }
.ch-pc--w { fill: #FBF5DF; stroke: #4A3A18; }
.ch-pc--b { fill: #0D3B33; stroke: #04130F; }
.ch-sq--d .ch-pc--b, .ch-ghost .ch-pc--b, .ch-promo .ch-pc--b { stroke: #04130F; filter: drop-shadow(0 0 0.6px rgba(234, 217, 168, 0.9)); }
.ch-sq.is-lift .ch-pc { opacity: 0.28; }
.ch-sq.is-mate .ch-pc { animation: ch-fall 0.9s cubic-bezier(.5, 0, .7, 1) 0.25s both; transform-origin: 50% 88%; }
.ch-ghost { position: fixed; left: 0; top: 0; z-index: 50; pointer-events: none; filter: drop-shadow(0 8px 8px rgba(0, 0, 0, 0.45)); }
@keyframes ch-pulse { 50% { box-shadow: inset 0 0 0 100px rgba(226, 85, 58, 0.45); } }
@keyframes ch-fall { 60% { transform: rotate(96deg); } 80% { transform: rotate(84deg); } 100% { transform: rotate(90deg); } }

/* captured pieces beside each player */
.ch-tray { direction: ltr; flex: none; display: flex; align-items: center; width: min(100%, 640px); height: 24px; padding: 0 4px; }
.ch-pc--mini { flex: none; width: 20px; height: 20px; margin-inline-end: -6px; stroke-width: 1.6; }
.ch-tray .ch-pc--b { fill: #12493F; stroke: #EAD9A8; stroke-width: 1.3; }
.ch-tray b { margin-inline-start: 12px; font-size: 13px; color: var(--mist); }

.ch-status { flex: none; gap: 8px; min-height: 28px; font-size: 0.97rem; line-height: 1.2; }
.ch-dot { flex: none; width: 13px; height: 13px; border-radius: 50%; box-shadow: 0 0 0 1.5px rgba(234, 217, 168, 0.7); }
.ch-dot--w { background: #FBF5DF; }
.ch-dot--b { background: #0D3B33; }
.ch-chk { color: var(--w-vermilion) !important; }

/* choosing a piece for a pawn that has crossed the board */
.ch-promo { position: absolute; inset: 0; z-index: 6; display: flex; align-items: center; justify-content: center; border-radius: 10px; background: rgba(8, 32, 29, 0.62); }
.ch-promo[hidden] { display: none; }
.ch-promo__row { display: flex; gap: 2.5%; width: 86%; padding: 3%; border-radius: 14px; background: var(--lapis-raise); box-shadow: 0 10px 24px rgba(0, 0, 0, 0.5), inset 0 0 0 1px var(--hairline); animation: ch-pop 0.16s ease-out; }
.ch-promo__btn { flex: 1 1 0; aspect-ratio: 1 / 1; min-width: 0; padding: 4%; border: 0; border-radius: 10px; background: #37907A; cursor: pointer; }
.ch-promo__btn:active, .ch-promo__btn:focus-visible { background: #DCCB98; outline: none; }
@keyframes ch-pop { from { transform: scale(0.85); opacity: 0; } }

/* the new-game panel */
.ch-opts { display: grid; gap: 12px; text-align: start; }
.ch-opt { transition: opacity 0.2s linear; }
.ch-opt.is-off { opacity: 0.35; pointer-events: none; }
.ch-opt__label { margin-bottom: 5px; font-size: 12px; font-weight: 650; letter-spacing: 0.1em; text-transform: uppercase; color: var(--mist); }
html[lang="ar"] .ch-opt__label { letter-spacing: 0; font-size: 13px; }
.ch-opts .fa-seg { display: flex; width: 100%; border-radius: 16px; }
.ch-opts .fa-seg button { flex: 1 1 0; min-width: 0; min-height: 44px; padding: 4px 6px; border-radius: 13px; line-height: 1.15; }
.kit-result .fa-panel__row .fa-btn--small { padding-left: 0.5em; padding-right: 0.5em; }
.kit-dock-btn:disabled { opacity: 0.45; }

@media (max-width: 360px) {
  .kit-result .fa-panel__title { font-size: 1.7rem; }
  .ch-status { font-size: 0.9rem; }
}
/* a phone on its side: the board takes the full height, trays and status move beside it */
@media (max-height: 480px) and (orientation: landscape) {
  .ch-col { display: grid; grid-template: "top board sub" 1fr "bot board sub" 1fr / 1fr auto 1fr; align-items: center; justify-items: center; gap: 4px 10px; padding: 3px 8px; }
  .ch-wrap { grid-area: board; width: auto; height: 100%; container-type: normal; }
  .ch-frame { width: auto; height: 100%; aspect-ratio: 1 / 1; }
  .ch-tray { width: 100%; height: auto; min-height: 20px; flex-wrap: wrap; row-gap: 2px; }
  #trayTop { grid-area: top; align-self: start; }
  #trayBottom { grid-area: bot; align-self: end; }
  .ch-status { grid-area: sub; flex-direction: column; padding: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .ch-sq.is-check, .ch-promo__row { animation: none; }
  .ch-sq.is-mate .ch-pc { animation: none; transform: rotate(90deg); }
}
