:root {
	font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
	color: #202428;
	background: #F3F5F7;
}

* {
	box-sizing: border-box;
}

body {
	margin: 0;
	min-height: 100vh;
}

button,
select,
input {
	font: inherit;
}

.app-shell {
	width: min(100%, 1180px);
	min-height: 100vh;
	margin: 0 auto;
	padding: 0.8rem;
	display: flex;
	flex-direction: column;
	gap: 0.7rem;
}

.app-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 1rem;
	flex-wrap: wrap;
}

h1,
h2,
p {
	margin-top: 0;
}

h1 {
	margin-bottom: 0.1rem;
	font-size: clamp(1.5rem, 3vw, 2.2rem);
}

.game-title {
	margin-bottom: 0;
	color: #5D646B;
}

.game-controls {
	display: flex;
	align-items: center;
	gap: 0.5rem;
	flex-wrap: wrap;
}

.game-layout {
	flex: 1;
	min-height: 0;
	display: grid;
	grid-template-columns: repeat(3, minmax(0, 1fr));
	grid-template-areas:
		"player1 goals player2"
		"playfield playfield playfield";
	grid-template-rows: auto minmax(320px, 1fr);
	gap: 0.7rem;
}

.player-one {
	grid-area: player1;
}

.goal-panel {
	grid-area: goals;
}

.player-two {
	grid-area: player2;
}

.playfield-panel {
	grid-area: playfield;
	min-width: 0;
	min-height: 0;
	border: 1px solid #ABB1B7;
	border-radius: 0.6rem;
	overflow: hidden;
	background: #FFF4E6;
}

.player-panel,
.goal-panel {
	min-width: 0;
	padding: 0.65rem 0.75rem;
	border: 1px solid #C6CBD0;
	border-radius: 0.6rem;
	background: #FFFFFF;
}

.player-panel h2,
.goal-panel h2 {
	margin-bottom: 0.45rem;
	font-size: 1rem;
}

.player-panel fieldset {
	margin: 0 0 0.45rem;
	padding: 0;
	border: 0;
	display: flex;
	gap: 0.7rem;
	flex-wrap: wrap;
}

.player-panel legend {
	position: absolute;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

.player-panel.current-player {
	outline: 4px solid black;
	outline-offset: -4px;
}

.player-aid-control {
	min-height: 3.15rem;
	display: flex;
	align-items: center;
}

.human-aid-controls {
	width: 100%;
}

.human-aid-controls[hidden],
.smartness-control[hidden] {
	display: none;
}

.suggest-moves,
.interaction-mode {
	width: 100%;
}

.interaction-mode-label {
	display: block;
	margin: 0.5rem 0 0.4rem;
	font-size: 0.88rem;
}

.smartness {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 0.5rem;
	font-size: 0.88rem;
}

.smartness input {
	width: 4rem;
}

.score {
	margin-top: 0.55rem;
	display: flex;
	align-items: baseline;
	justify-content: space-between;
	border-top: 1px solid #E1E4E7;
	padding-top: 0.45rem;
}

.score strong {
	font-size: 1.5rem;
}

.goal-list {
	display: flex;
	gap: 0.5rem;
	align-items: stretch;
	justify-content: center;
}

.goal-item {
	min-width: 0;
	flex: 1 1 0;
	text-align: center;
	font-size: 0.78rem;
}

.goal-canvas {
	display: block;
	width: 100%;
	height: 4rem;
}

.goal-text {
	line-height: 1.15;
}

#playfield {
	display: block;
	width: 100%;
	height: 100%;
	min-height: 320px;
	touch-action: manipulation;
}

.status-row {
	display: flex;
	align-items: center;
	gap: 0.5rem;
}

.turn-indicator {
	display: inline-block;
	width: 1.25rem;
	height: 1.25rem;
	flex: 0 0 1.25rem;
	border: 1px solid black;
}

.status {
	margin: 0;
	min-height: 1.4em;
	text-align: left;
	font-weight: 600;
	border: 1px solid black;
	border-radius: 0.5rem;
	background-color: #E9ECEF;
	padding: 0.4rem 0.6rem;
}

@media (orientation: landscape) and (min-width: 760px) {
	.app-shell {
		height: 100vh;
	}

	.game-layout {
		grid-template-columns: minmax(0, 1fr) minmax(180px, 230px);
		grid-template-rows: repeat(3, minmax(0, auto));
		grid-template-areas:
			"playfield player1"
			"playfield goals"
			"playfield player2";
	}

	.playfield-panel,
	#playfield {
		min-height: 0;
		height: 100%;
	}

	.goal-list {
		flex-direction: column;
	}

	.goal-canvas {
		height: 4rem;
	}
}

@media (max-width: 620px) {
	.app-shell {
		padding: 0.45rem;
	}

	.game-layout {
		gap: 0.45rem;
	}

	.player-panel,
	.goal-panel {
		padding: 0.45rem;
	}

	.player-panel fieldset {
		gap: 0.35rem;
		font-size: 0.82rem;
	}

	.player-aid-control {
		min-height: 3.15rem;
		display: flex;
		align-items: center;
	}

	.human-aid-controls {
		width: 100%;
	}

	.suggest-moves,
	.interaction-mode {
		width: 100%;
	}

	.smartness {
		font-size: 0.78rem;
	}

	.goal-text {
		font-size: 0.7rem;
	}
}


.about-dialog {
	width: min(48rem, calc(100vw - 2rem));
	max-height: calc(100vh - 2rem);
	padding: 0;
	border: 1px solid #777D83;
	border-radius: 0.7rem;
	box-shadow: 0 0.8rem 2.5rem rgb(0 0 0 / 25%);
}

.about-dialog::backdrop {
	background: rgb(0 0 0 / 35%);
}

.about-dialog-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 1rem;
	padding: 0.8rem 1rem;
	border-bottom: 1px solid #D6D9DC;
}

.about-dialog-header h2 {
	margin: 0;
	font-size: 1.15rem;
}

.about-close {
	width: 2rem;
	height: 2rem;
	padding: 0;
	border: 0;
	background: transparent;
	font-size: 1.5rem;
	line-height: 1;
	cursor: pointer;
}

.about-text {
	max-height: calc(100vh - 10rem);
	overflow-y: auto;
	padding: 1rem;
	white-space: pre-wrap;
	line-height: 1.45;
}

.about-dialog-footer {
	display: flex;
	justify-content: flex-end;
	padding: 0.7rem 1rem;
	border-top: 1px solid #D6D9DC;
}
