.xaj, .xaj * { box-sizing: border-box; }

.xaj {
	--light: #e7d7bd;
	--dark: #72533d;
	--accent: #2c371f;
	container: xaj / inline-size;
	width: 100%;
	max-width: 1080px;
	min-width: 0;
	margin: 1.5rem auto;
	font-family: inherit;
	color: inherit;
	line-height: 1.5;
}

.xaj__header { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 20px 0; }
.xaj__brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.xaj__brand-mark { display: grid; place-items: center; flex: 0 0 42px; width: 42px; height: 42px; border: 1px solid currentColor; border-radius: 12px; font-size: 28px; line-height: 1; }
.xaj .xaj__brand h2 { margin: 0; font: inherit; font-size: 20px; font-weight: 750; letter-spacing: -0.5px; }
.xaj .xaj__mode-summary { margin: 2px 0 0; font-size: 12px; opacity: 0.75; }
.xaj__header-note { font-size: 12px; opacity: 0.7; }
.xaj__layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: 20px; }
.xaj__play, .xaj__game, .xaj__panel { min-width: 0; }

.xaj__status { display: flex; align-items: center; gap: 10px; min-height: 48px; padding: 10px 14px; margin-bottom: 8px; border: 1px solid currentColor; border-radius: 10px; font-size: 14px; font-weight: 650; overflow-wrap: anywhere; }
.xaj__status::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: currentColor; flex: 0 0 8px; }
.xaj--thinking .xaj__status::before { animation: xaj-pulse 1s ease-in-out infinite; }
.xaj__player { display: flex; align-items: center; gap: 8px; min-height: 44px; padding: 8px 2px; font-size: 13px; }
.xaj__player strong { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.xaj__token { display: grid; place-items: center; flex: 0 0 26px; width: 26px; height: 26px; border-radius: 7px; background: #e9e5dc; }
.xaj__token .xaj__piece { width: 24px; height: 24px; }
.xaj__turn-badge { margin-inline-start: auto; flex-shrink: 0; border: 1px solid currentColor; border-radius: 20px; padding: 2px 8px; font-size: 10px; font-weight: 650; }
.xaj__turn-badge:empty { display: none; }

.xaj__board {
	display: grid;
	grid-template-columns: repeat(8, minmax(0, 1fr));
	grid-template-rows: repeat(8, minmax(0, 1fr));
	width: 100%;
	aspect-ratio: 1;
	overflow: hidden;
	border-radius: 8px;
	box-shadow: 0 4px 14px rgb(35 30 20 / 14%);
	user-select: none;
}
.xaj .xaj__square {
	position: relative;
	display: grid;
	place-items: center;
	width: 100%;
	height: 100%;
	min-width: 0;
	min-height: 0;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 0;
	box-shadow: none;
	background: var(--light);
	color: #342b20;
	font: inherit;
	cursor: pointer;
	touch-action: manipulation;
	-webkit-tap-highlight-color: transparent;
}
.xaj .xaj__square--dark { background: var(--dark); color: #fff8eb; }
.xaj .xaj__square--last::after { position: absolute; inset: 0; background: rgb(255 221 84 / 27%); content: ''; pointer-events: none; }
.xaj .xaj__square--selected { box-shadow: inset 0 0 0 3px #f6cc54; }
.xaj .xaj__square--move::before { position: absolute; z-index: 2; width: 22%; aspect-ratio: 1; border-radius: 50%; background: rgb(24 36 19 / 40%); content: ''; pointer-events: none; }
.xaj .xaj__square--capture::before { position: absolute; z-index: 2; inset: 4%; border: 3px solid #b43535; border-radius: 50%; content: ''; pointer-events: none; }
.xaj .xaj__square--check { background: #ca6054; }
.xaj .xaj__square[aria-disabled="true"] { cursor: default; }
.xaj__piece { display: block; position: relative; z-index: 1; width: 84%; height: 84%; overflow: visible; fill: #fff9eb; stroke: #382e24; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; pointer-events: none; }
.xaj__piece--black { fill: #28332e; stroke: #f0e4ce; stroke-width: 1.6; }
.xaj__coord { position: absolute; z-index: 3; font-family: system-ui, sans-serif; font-size: 9px; font-size: clamp(7px, 1.5cqi, 11px); font-weight: 700; line-height: 1; pointer-events: none; }
.xaj__coord--file { right: 3px; bottom: 2px; }
.xaj__coord--rank { top: 2px; left: 3px; }

.xaj__actions { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-top: 8px; }
.xaj .xaj__button { display: flex; align-items: center; justify-content: center; gap: 6px; width: 100%; min-height: 46px; margin: 0; padding: 8px; font-family: inherit; font-size: 12px; font-weight: 600; line-height: 1.25; text-align: center; white-space: normal; cursor: pointer; touch-action: manipulation; }
.xaj__button span { font-size: 19px; font-weight: 400; }
.xaj .xaj__button:disabled { opacity: 0.45; cursor: not-allowed; }
.xaj .xaj__help { margin: 12px 0 0; text-align: center; font-size: 12px; opacity: 0.75; }
.xaj__panel { display: flex; flex-direction: column; gap: 16px; }
.xaj__settings, .xaj__history-panel { padding: 18px; border: 1px solid currentColor; border-radius: 12px; }
.xaj .xaj__settings h3 { margin: 0 0 16px; font: inherit; font-size: 15px; font-weight: 700; }
.xaj__fields { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; }
.xaj__field { min-width: 0; }
.xaj__settings label { display: block; margin: 0 0 6px; font-size: 12px; font-weight: 600; }
.xaj__settings select { display: block; width: 100%; max-width: 100%; min-width: 0; min-height: 46px; margin: 0; padding: 10px 26px 10px 10px; font-family: inherit; font-size: 16px; line-height: 1.25; }
.xaj__history-panel summary { display: flex; align-items: center; gap: 8px; min-height: 44px; margin: -10px 0; padding: 10px 0; font-size: 14px; font-weight: 650; cursor: pointer; list-style: none; }
.xaj__history-panel summary::-webkit-details-marker { display: none; }
.xaj__history-panel summary::after { content: '+'; margin-inline-start: auto; font-size: 20px; font-weight: 400; }
.xaj__history-panel[open] summary::after { content: '−'; }
.xaj__move-count { min-width: 22px; padding: 1px 6px; border: 1px solid currentColor; border-radius: 20px; font-size: 11px; text-align: center; font-variant-numeric: tabular-nums; }
.xaj .xaj__history-empty { margin: 24px 0 8px; font-size: 13px; opacity: 0.7; line-height: 1.7; }
.xaj__history-heading { display: grid; grid-template-columns: repeat(2, 1fr); padding: 20px 0 8px; font-size: 11px; font-weight: 650; opacity: 0.7; }
.xaj__history-heading span:first-child { padding-inline-start: 30px; }
.xaj .xaj__history { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0; max-height: 300px; overflow: auto; overscroll-behavior: contain; scrollbar-width: thin; list-style: none; margin: 0; padding: 0; font-size: 14px; font-variant-numeric: tabular-nums; }
.xaj__history li { display: flex; align-items: center; min-height: 34px; margin: 0; padding: 4px 6px; }
.xaj__history li:nth-child(odd)::before { content: attr(data-number); width: 24px; flex: 0 0 24px; font-size: 11px; opacity: 0.6; }
.xaj__history li:last-child { font-weight: 750; }
.xaj__sr-only { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

.xaj__promotion { width: min(360px, calc(100% - 24px)); max-width: calc(100% - 24px); padding: 20px; border: 1px solid #ddd6c9; border-radius: 16px; color: #25312b; background: #faf8f3; box-shadow: 0 20px 80px rgb(0 0 0 / 30%); }
.xaj__promotion::backdrop { background: rgb(22 28 23 / 60%); }
.xaj__promotion form { margin: 0; }
.xaj__promotion p { margin: 0 0 18px; text-align: center; font-size: 17px; font-weight: 700; }
.xaj__promotion-options { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.xaj__promotion-options button { display: grid; place-items: center; width: 100%; min-width: 0; min-height: 48px; aspect-ratio: 1; padding: 0; border: 1px solid #d6cebd; border-radius: 10px; background: #e7d7bd; cursor: pointer; }
.xaj__promotion-cancel { display: block; width: 100%; min-height: 44px; margin-top: 16px; border: 1px solid #d6cebd; border-radius: 8px; color: inherit; background: transparent; font: inherit; cursor: pointer; }
.xaj button:focus-visible, .xaj select:focus-visible, .xaj summary:focus-visible, .xaj__history:focus-visible { outline: 3px solid #277bbb; outline-offset: 3px; }
.xaj .xaj__square:focus-visible { z-index: 4; outline-offset: -4px; }

.xaj--plugin { padding: 0 24px 24px; border: 1px solid #e2dfd5; border-radius: 20px; background: #f7f6f2; color: #27332b; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
.xaj--plugin .xaj__brand-mark { background: var(--accent); color: #fff; border-color: transparent; }
.xaj--plugin .xaj__status { border-color: #dce3d5; color: #35472f; background: #edf1e8; }
.xaj--plugin.xaj--check .xaj__status { color: #942f23; border-color: #edc7be; background: #fff0eb; }
.xaj--plugin .xaj__turn-badge { background: #e8edde; color: #344629; border-color: #d7dfcc; }
.xaj--plugin .xaj__button { border: 1px solid #dcded4; border-radius: 9px; color: #344030; background: #fffefa; }
.xaj--plugin .xaj__restart { background: var(--accent); color: #fff; border-color: transparent; }
.xaj--plugin .xaj__settings, .xaj--plugin .xaj__history-panel { border-color: #e2e2d9; background: #fffefa; }
.xaj--plugin .xaj__settings select { border: 1px solid #d9dbd1; border-radius: 8px; background-color: #fff; color: #28352c; }
.xaj--plugin .xaj__move-count { border-color: #e2e2d9; color: #5b6559; background: #f5f5ef; }
.xaj--plugin .xaj__history li:nth-child(4n+1), .xaj--plugin .xaj__history li:nth-child(4n+2) { background: #f3f4ed; }
@media (hover: hover) { .xaj--plugin .xaj__button:not(:disabled):hover { filter: brightness(0.95); } .xaj .xaj__square:not([aria-disabled="true"]):hover { filter: brightness(1.07); } }

/* React to the shortcode's width, including narrow WordPress content columns. */
@container xaj (min-width: 720px) {
	.xaj__layout { grid-template-columns: minmax(0, 1fr) 260px; gap: 24px; }
	.xaj__panel { padding-top: 0; }
	.xaj .xaj__button { font-size: 13px; }
}
@container xaj (min-width: 420px) and (max-width: 719px) {
	.xaj__fields { grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); }
}
@container xaj (max-width: 419px) {
	.xaj__header { padding: 14px 0; }
	.xaj__header-note { display: none; }
	.xaj__layout { gap: 18px; }
	.xaj__brand-mark { width: 34px; height: 34px; flex-basis: 34px; border-radius: 9px; }
	.xaj .xaj__brand h2 { font-size: 18px; }
	.xaj__actions { gap: 6px; }
	.xaj .xaj__button { flex-direction: column; gap: 2px; min-height: 56px; padding: 6px 2px; font-size: 11px; }
	.xaj__settings, .xaj__history-panel { padding: 14px; }
	.xaj__status { font-size: 13px; padding: 10px; }
	.xaj .xaj__help { font-size: 11px; }
}
@media (max-width: 600px) { .xaj--plugin { padding: 0 10px 14px; border-radius: 14px; margin-block: 12px; } }
@media (prefers-reduced-motion: reduce) { .xaj--thinking .xaj__status::before { animation: none; } }
@keyframes xaj-pulse { 50% { opacity: 0.3; } }

.xaj [hidden] { display: none; }
