/*
 * Chessbot: dark, compact controls to match the rest of the Ejectamenta apps.
 * The board squares come from the script; everything around them lives here.
 */

.chessbot-app {
	max-width: 960px;
	margin: 0 auto;
	color: #e6edf3;
	font-size: 14px;
	line-height: 1.5;
}

.chessbot-app *,
.chessbot-app *::before,
.chessbot-app *::after {
	box-sizing: border-box;
}

/* Toolbar ------------------------------------------------------------- */

.cb-toolbar {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 8px 14px;
	margin: 0 0 12px;
	padding: 8px 10px;
	background: #161b22;
	border: 1px solid #30363d;
	border-radius: 8px;
}

.cb-field {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	white-space: nowrap;
	font-size: 13px;
	color: #c9d1d9;
}

.cb-field label,
.cb-label {
	font-size: 12px;
	font-weight: 600;
	letter-spacing: .02em;
	color: #8b949e;
	text-transform: uppercase;
}

.cb-unit {
	font-size: 12px;
	color: #8b949e;
}

.cb-buttons {
	display: inline-flex;
	flex-wrap: wrap;
	gap: 6px;
	margin-left: auto;
}

/* Controls ------------------------------------------------------------ */

.chessbot-app select,
.chessbot-app input[type="text"],
.chessbot-app input[type="number"],
.chessbot-app textarea {
	background: #0d1117;
	border: 1px solid #30363d;
	border-radius: 6px;
	color: #e6edf3;
	font: 13px/1.4 "Open Sans", sans-serif;
	padding: 4px 6px;
	margin: 0;
	vertical-align: middle;
}

.chessbot-app select:focus,
.chessbot-app input:focus,
.chessbot-app textarea:focus {
	border-color: #58a6ff;
	outline: 2px solid rgba(88, 166, 255, .35);
	outline-offset: 0;
}

#TimePerMove {
	width: 66px;
}

.cb-btn,
.chessbot-app .cb-btn {
	display: inline-block;
	padding: 5px 11px;
	background: #21262d;
	border: 1px solid #30363d;
	border-radius: 6px;
	color: #e6edf3 !important;
	font-size: 13px;
	font-weight: 600;
	line-height: 1.3;
	text-decoration: none !important;
	cursor: pointer;
}

.cb-btn:hover,
.cb-btn:focus {
	background: #30363d;
	border-color: #3d444d;
	color: #ffffff !important;
}

.cb-btn-small {
	padding: 3px 9px;
	font-size: 12px;
}

/* Layout -------------------------------------------------------------- */

.cb-layout {
	display: flex;
	align-items: flex-start;
	justify-content: center;
	gap: 16px;
	flex-wrap: wrap;
}

.cb-board-column {
	flex: 0 1 360px;
	min-width: 0;
	max-width: 100%;
}

/* On a phone the theme leaves side padding around the content, which would
   squeeze the board into small squares. The controller measures that padding
   and exposes it as --cb-bleed, letting the board use the full screen width
   while the rest of the app stays aligned with the page text. */
.chessbot-app.cb-bleed .cb-board-column {
	flex: 0 0 auto;
	width: calc(100% + 2 * var(--cb-bleed, 0px));
	max-width: none;
	margin-left: calc(-1 * var(--cb-bleed, 0px));
	margin-right: calc(-1 * var(--cb-bleed, 0px));
}

/* The board is eight equal cells wide and scale with the column, so a narrow
   window shrinks the squares and the pieces instead of adding scrollbars.
   The controller measures the rendered table width to convert pointer
   positions back to squares. */
.cb-board {
	width: 100%;
	max-width: 360px;
	margin: 0 auto;
	overflow: visible;
	line-height: 0;
}

.cb-board table {
	width: 100%;
	margin: 0;
	border: 0;
	border-collapse: collapse;
	table-layout: fixed;
}

.cb-board td {
	width: 12.5%;
	padding: 0 !important;
	line-height: 0;
}

.cb-board td > div {
	width: 100%;
	height: 100%;
}

/* Piece sprites. The sheet is one 45px column with a 95px stride; the
   controller scales it to the current cell size and sets the row offset
   inline, so the fallbacks below only matter before the first draw. */
.cb-board [class^="sprite-"] {
	display: block;
	width: 100%;
	height: 100%;
	background-repeat: no-repeat;
}

.cb-board .sprite-bishop_black { background-position: 0 0; }
.cb-board .sprite-bishop_white { background-position: 0 -95px; }
.cb-board .sprite-king_black { background-position: 0 -190px; }
.cb-board .sprite-king_white { background-position: 0 -285px; }
.cb-board .sprite-knight_black { background-position: 0 -380px; }
.cb-board .sprite-knight_white { background-position: 0 -475px; }
.cb-board .sprite-pawn_black { background-position: 0 -570px; }
.cb-board .sprite-pawn_white { background-position: 0 -665px; }
.cb-board .sprite-queen_black { background-position: 0 -760px; }
.cb-board .sprite-queen_white { background-position: 0 -855px; }
.cb-board .sprite-rook_black { background-position: 0 -950px; }
.cb-board .sprite-rook_white { background-position: 0 -1045px; }

.cb-board .no-highlight {
	-webkit-tap-highlight-color: rgba(0, 0, 0, 0);
}

.cb-status {
	min-height: 32px;
	margin: 0 0 8px;
	padding: 6px 10px;
	background: #161b22;
	border: 1px solid #30363d;
	border-left: 3px solid #2ea043;
	border-radius: 6px;
	font-weight: 700;
	font-size: 14px;
	color: #e6edf3;
}

.stats-panel {
	max-width: 960px;
	margin: 12px 0 16px;
	background: #161b22;
	border: 1px solid #30363d;
	border-radius: 8px;
	padding: 12px;
	color: #c9d1d9;
}

.cb-status-panel {
	margin: 12px 0 0;
	background: #161b22;
	border: 1px solid #30363d;
	border-radius: 8px;
	padding: 12px 14px;
	color: #c9d1d9;
}

.cb-status-panel h3 {
	margin: 0 0 8px;
	font-size: 15px;
	color: #e6edf3;
}

.cb-status-panel .stat-list {
	list-style: none;
	margin: 0;
	padding: 0;
	font-size: 13px;
	line-height: 1.7;
}

.cb-status-panel .stat-list li strong {
	color: #8b949e;
	font-weight: 600;
}

.cb-bot-state {
	font-size: 13px;
	margin-bottom: 6px;
	color: #c9d1d9;
}

.cb-dot {
	display: inline-block;
	width: 8px;
	height: 8px;
	border-radius: 50%;
	margin-right: 5px;
	vertical-align: middle;
}

.cb-dot-on {
	background: #2ea043;
	box-shadow: 0 0 6px #2ea043;
}

.cb-dot-off {
	background: #8b949e;
}

.cb-bot-offline {
	margin: 0;
	color: #8b949e;
	font-size: 13px;
}

.cb-status-panel .error {
	color: #f85149;
	font-size: 13px;
	margin: 0;
}

.cb-pv {
	display: block;
	min-height: 18px;
	margin: 6px 0;
	font-family: Menlo, Consolas, "DejaVu Sans Mono", monospace;
	font-size: 11.5px;
	line-height: 1.35;
	color: #8b949e;
	overflow-wrap: anywhere;
}

.cb-under-board {
	margin-top: 4px;
}

#PgnTextBox {
	width: 100%;
	min-height: 46px;
	resize: vertical;
	font-family: Menlo, Consolas, "DejaVu Sans Mono", monospace;
	font-size: 12px;
}

/* Text board ---------------------------------------------------------- */

.cb-text-column {
	flex: 0 1 320px;
	min-width: 200px;
}

.cb-text-board {
	background: #0b120d;
	border: 1px solid #223024;
	border-radius: 8px;
	padding: 10px;
	color: #0de049;
}

.cb-text-board pre.chess-text {
	margin: 0;
	padding: 0;
	border: 0;
	background: none;
	font-family: Menlo, Consolas, "DejaVu Sans Mono", "Liberation Mono", monospace;
	font-size: 12px;
	line-height: 1.25;
	white-space: pre;
	font-variant-ligatures: none;
	color: inherit;
}

.cb-text-controls {
	margin-top: 10px;
}

.cb-link {
	display: inline-block;
	margin-bottom: 8px;
	color: #58a6ff;
	font-size: 13px;
	text-decoration: none;
}

.cb-link:hover,
.cb-link:focus {
	color: #79c0ff;
	text-decoration: underline;
}

.cb-fen {
	display: block;
	width: 100%;
	margin: 4px 0 6px;
	min-height: 44px;
	resize: vertical;
	font-family: Menlo, Consolas, "DejaVu Sans Mono", monospace;
	font-size: 11.5px;
}

/* Move entry ---------------------------------------------------------- */

.cb-move-row {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 8px;
	margin-top: 14px;
	padding-top: 12px;
	border-top: 1px solid #30363d;
}

.cb-command {
	width: 120px;
	font-family: Menlo, Consolas, "DejaVu Sans Mono", monospace !important;
}

/* On-page help (dark, matching the other Ejectamenta apps) ------------- */

.cb-help {
	max-width: 900px;
	margin: 2em auto 3em;
	padding: 20px 22px 22px;
	background: #0d1117;
	border: 1px solid #30363d;
	border-radius: 10px;
	color: #c9d1d9;
	font-size: 15px;
	line-height: 1.65;
	text-align: left;
	box-shadow: 0 10px 30px rgba(0, 0, 0, .25);
}

.cb-help h2 {
	font-size: 24px;
	margin: 0 0 .35em;
	color: #e6edf3;
}

.cb-help-intro {
	color: #8b949e;
	margin: 0 0 1.1em;
}

.cb-help ul {
	margin: .3em 0 .7em 1.3em;
	padding: 0;
}

.cb-help li {
	margin: .25em 0;
}

.cb-help strong {
	color: #e6edf3;
}

.cb-help a {
	color: #58a6ff;
}

.cb-help code {
	background: #161b22;
	border: 1px solid #30363d;
	border-radius: 4px;
	padding: 1px 5px;
	color: #e6edf3;
}

.cb-help .ui-accordion-header {
	position: relative;
	background: #161b22 !important;
	border: 1px solid #30363d !important;
	border-radius: 6px !important;
	margin: .45em 0 0 !important;
	padding: .65em 2.4em .65em .9em !important;
	font-size: 15px !important;
	color: #e6edf3 !important;
	font-weight: 600 !important;
	cursor: pointer;
}

.cb-help .ui-accordion-header:hover {
	background: #1c2128 !important;
}

.cb-help .ui-accordion-header-active {
	background: #1f2a40 !important;
	border-color: #3b4a63 !important;
	color: #ffffff !important;
}

.cb-help .ui-accordion-header-icon {
	display: none !important;
}

.cb-help .ui-accordion-header::after {
	content: "";
	position: absolute;
	right: 14px;
	top: 50%;
	width: 7px;
	height: 7px;
	border-right: 2px solid #8b949e;
	border-bottom: 2px solid #8b949e;
	transform: translateY(-70%) rotate(45deg);
	transition: transform .15s ease, border-color .15s ease;
}

.cb-help .ui-accordion-header-active::after {
	border-color: #58a6ff;
	transform: translateY(-30%) rotate(-135deg);
}

.cb-help .ui-accordion-content {
	background: #0d1117 !important;
	border: 1px solid #30363d !important;
	border-top: 0 !important;
	border-radius: 0 0 6px 6px !important;
	padding: .9em 1.05em !important;
	color: #c9d1d9 !important;
}

.cb-help .ui-accordion-content p {
	margin: .5em 0;
}

.cb-help .ui-accordion-content p:last-child {
	margin-bottom: 0;
}

/* Narrow screens ------------------------------------------------------ */

@media (max-width: 780px) {
	.cb-buttons {
		margin-left: 0;
	}

	.cb-text-column {
		flex: 1 1 100%;
		max-width: 100%;
	}

	.cb-help {
		padding: 16px 14px 18px;
	}
}
