.popugame-shell {
	margin: 1.5rem auto 2rem;
	max-width: min(920px, 96vw);
	width: 100%;
	display: grid;
	gap: 1.25rem;
	background: var(--contents);
	border: 1px solid var(--border);
	border-radius: 16px;
	padding: 1.5rem;
	box-shadow: 0 18px 40px rgba(0, 0, 0, 0.08);
	box-sizing: border-box;
	overflow-x: clip;
}

.popugame-shell * {
	box-sizing: border-box;
}

.popugame-shell[data-active-player="0"] {
	border-color: rgba(26, 127, 69, 0.55);
	box-shadow: 0 18px 40px rgba(0, 0, 0, 0.08), 0 0 0 1px rgba(26, 127, 69, 0.15);
}

.popugame-shell[data-active-player="1"] {
	border-color: rgba(43, 93, 209, 0.55);
	box-shadow: 0 18px 40px rgba(0, 0, 0, 0.08), 0 0 0 1px rgba(43, 93, 209, 0.15);
}

.popugame__header {
	display: grid;
	grid-template-columns: 1fr;
	align-items: center;
	gap: 1rem;
	text-align: center;
	font-weight: 600;
	min-width: 0;
}

.popugame__scorebox {
	justify-self: center;
	display: grid;
	justify-items: center;
	gap: 0.35rem;
	padding: 0.4rem 0.6rem;
	border-radius: 12px;
	background: var(--background);
	border: 1px solid var(--border);
	max-width: 100%;
	min-width: 0;
}

.popugame__score {
	padding: 0.05rem 0.2rem;
	border-radius: 8px;
}

.popugame__score--p0 {
	color: #1a7f45;
}

.popugame__score--p1 {
	color: #2b5dd1;
}

.popugame__center {
	display: grid;
	gap: 0.35rem;
	justify-items: center;
}

.popugame__score-sep {
	color: var(--form_text);
	font-weight: 700;
}

.popugame__scoreline {
	display: inline-flex;
	align-items: center;
	gap: 0.35rem;
}

.popugame__names {
	display: inline-flex;
	align-items: center;
	gap: 0.4rem;
	font-size: 0.85rem;
	color: var(--form_text);
}

.popugame__name {
	font-weight: 600;
}

.popugame__name--p0 {
	color: #1a7f45;
}

.popugame__name--p1 {
	color: #2b5dd1;
}

.popugame__name-sep {
	color: var(--form_text);
	font-size: 0.75rem;
	text-transform: uppercase;
	letter-spacing: 0.08em;
}

.popugame__statusbox {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	padding: 0.2rem 0.5rem;
	border-radius: 999px;
	background: var(--contents);
	border: 1px solid var(--border);
}

.popugame__turnbar {
	width: min(480px, 100%);
	display: grid;
	gap: 0.35rem;
	position: relative;
	min-width: 0;
}

.popugame__turnwrap {
	display: grid;
	gap: 0.35rem;
	width: min(520px, 100%);
	padding: 0.5rem;
	border-radius: 12px;
	border: 1px solid var(--border);
	background: var(--background);
	justify-items: center;
	min-width: 0;
}

.popugame__turnlabel {
	font-size: 0.85rem;
	color: var(--form_text);
	text-align: center;
}

.popugame__turnbar-track {
	position: relative;
	display: grid;
	grid-template-columns: repeat(var(--turn-limit), 1fr);
	gap: 2px;
	padding: 4px;
	border-radius: 999px;
	background: var(--contents);
	border: 1px solid var(--border);
	overflow: hidden;
}

.popugame__share-panel {
	display: grid;
	gap: 0.6rem;
	padding: 0.8rem;
	border: 1px dashed var(--border);
	border-radius: 12px;
	background: var(--background);
}

.popugame__share-panel[hidden] {
	display: none !important;
}

.popugame__share-title {
	font-weight: 700;
}

.popugame__share-subtitle {
	color: var(--form_text);
	font-size: 0.9rem;
}

.popugame__share-grid {
	display: grid;
	gap: 0.6rem;
}

.popugame__share-field {
	display: grid;
	gap: 0.3rem;
}

.popugame__share-field label {
	font-size: 0.8rem;
	color: var(--form_text);
}

.popugame__copy-chip {
	justify-content: space-between;
	width: 100%;
}

.popugame__dialog-actions {
	display: flex;
	justify-content: flex-end;
	gap: 0.5rem;
	margin-top: 0.75rem;
	flex-wrap: wrap;
}

.popugame__dialog-actions .btn {
	min-width: 90px;
	max-width: 100%;
}

.popugame__dialog-field {
	display: grid;
	gap: 0.35rem;
	margin: 0.6rem 0;
}

.popugame__dialog-field label {
	font-size: 0.85rem;
	color: var(--form_text);
}

.popugame__dialog-field input {
	padding: 0.5rem 0.6rem;
	border-radius: 10px;
	border: 1px solid var(--form_border);
	background: var(--form_body);
	color: var(--form_text);
	font-family: inherit;
	font-size: 0.95rem;
}

.popugame__dialog-field input::placeholder {
	color: var(--form_placeholder, rgba(255, 255, 255, 0.55));
}

.popugame__dialog-field input:focus {
	outline: none;
	border-color: var(--form_border_focus, var(--form_border));
	box-shadow: 0 0 0 2px color-mix(in srgb, var(--form_border_focus, var(--form_border)) 25%, transparent);
}

.popugame__turnbar-block {
	height: 10px;
	border-radius: 6px;
	background: rgba(86, 156, 214, 0.18);
	transition: background 160ms ease;
}

.popugame__turnbar-block.is-remaining {
	background: var(--block-color);
}


.popugame__status {
	font-size: 1rem;
}

.popugame-shell[data-active-player="0"] .popugame__status {
	color: #1a7f45;
}

.popugame-shell[data-active-player="1"] .popugame__status {
	color: #2b5dd1;
}

.popugame__turn {
	font-size: 0.9rem;
	color: var(--form_text);
}

.popugame__board {
	display: grid;
	grid-template-columns: repeat(var(--grid-size), minmax(30px, 1fr));
	gap: 6px;
	padding: 0.5rem;
	background: var(--background);
	border-radius: 12px;
	border: 1px solid var(--border);
	width: 100%;
	max-width: 100%;
	min-width: 0;
}

.popugame__cell {
	width: 100%;
	aspect-ratio: 1 / 1;
	border-radius: 10px;
	border: 1px solid var(--border);
	background: var(--contents);
	font-family: var(--font-base);
	font-size: 1rem;
	font-weight: 700;
	color: var(--default);
	cursor: pointer;
	transition: transform 120ms ease, box-shadow 120ms ease;
}

.popugame__cell:disabled {
	opacity: 0.45;
	cursor: not-allowed;
}

.popugame__cell:not(:disabled):hover {
	transform: translateY(-1px);
	box-shadow: 0 6px 14px rgba(0, 0, 0, 0.12);
}

.popugame__cell.is-claim-p0 {
	background: rgba(26, 127, 69, 0.28);
}

.popugame__cell.is-claim-p1 {
	background: rgba(43, 93, 209, 0.28);
}

.popugame-shell[data-active-player="0"] .popugame__cell.is-claim-p0 {
	background: rgba(26, 127, 69, 0.30);
}

.popugame-shell[data-active-player="0"] .popugame__cell.is-claim-p1 {
	background: rgba(43, 93, 209, 0.34);
}

.popugame-shell[data-active-player="1"] .popugame__cell.is-claim-p1 {
	background: rgba(43, 93, 209, 0.30);
}

.popugame-shell[data-active-player="1"] .popugame__cell.is-claim-p0 {
	background: rgba(26, 127, 69, 0.34);
}

.popugame__cell.is-claim-p0:not(:disabled):hover {
	background: rgba(26, 127, 69, 0.34);
}

.popugame__cell.is-claim-p1:not(:disabled):hover {
	background: rgba(43, 93, 209, 0.34);
}

.popugame__cell.is-token-p0 {
	color: #1a7f45;
}

.popugame__cell.is-token-p1 {
	color: #2b5dd1;
}

.popugame__controls {
	display: grid;
	gap: 0.62rem;
}

.popugame__controls-group {
	display: flex;
	justify-content: center;
	flex-wrap: wrap;
	gap: 0.52rem;
	padding: 0.5rem;
	border-radius: 12px;
	border: 1px solid var(--border);
	background: color-mix(in srgb, var(--contents) 86%, var(--background) 14%);
}

.popugame__controls-group--play {
	background: color-mix(in srgb, var(--contents) 92%, var(--background) 8%);
}

.popugame__controls-group--multi {
	background: color-mix(in srgb, var(--contents) 84%, var(--background) 16%);
}

.popugame__btn {
	min-height: 38px;
	padding-inline: 0.9rem;
}

.popugame__btn.is-hidden {
	display: none !important;
}

.popugame__controls-group .popugame__btn[data-popugame-host],
.popugame__controls-group .popugame__btn[data-popugame-join] {
	min-width: 168px;
}

@media (max-width: 640px) {
	.popugame__controls-group .popugame__btn[data-popugame-host],
	.popugame__controls-group .popugame__btn[data-popugame-join] {
		min-width: 0;
		width: 100%;
	}
}


.popugame__backdrop {
	position: fixed;
	inset: 0;
	background: rgba(0, 0, 0, 0.4);
	display: flex;
	align-items: center;
	justify-content: center;
	opacity: 0;
	pointer-events: none;
	transition: opacity 150ms ease;
	padding: 1.5rem;
}

.popugame__backdrop.is-open {
	opacity: 1;
	pointer-events: auto;
}

.popugame__modal {
	background: var(--contents);
	border: 1px solid var(--border);
	border-radius: 16px;
	box-shadow: 0 20px 50px rgba(0, 0, 0, 0.2);
	max-width: min(520px, 92vw);
	width: 100%;
	padding: 1.4rem 1.6rem 1.6rem;
	display: grid;
	gap: 0.75rem;
	box-sizing: border-box;
	min-width: 0;
}

.popugame__modal-header {
	display: flex;
	justify-content: space-between;
	align-items: center;
}

.popugame__modal-body p {
	margin: 0.4rem 0;
	line-height: 1.45;
	color: var(--form_text);
}

.popugame__close {
	border: 1px solid var(--border);
	background: var(--background);
	color: var(--form_text);
	border-radius: 8px;
	width: 32px;
	height: 32px;
	font-size: 1.2rem;
	cursor: pointer;
}

.popugame__close:hover {
	filter: brightness(1.05);
}

.popugame__endgame-modal {
	max-width: min(540px, 92vw);
}

.popugame__endgame-result {
	font-size: 1.25rem;
	font-weight: 700;
	line-height: 1.2;
}

.popugame__endgame-result.is-p0 {
	color: #1a7f45;
}

.popugame__endgame-result.is-p1 {
	color: #2b5dd1;
}

.popugame__endgame-meta {
	font-size: 0.95rem;
	color: var(--default);
}

.popugame__endgame-elo {
	margin-top: 0.35rem;
	padding: 0.6rem 0.75rem;
	border: 1px solid var(--border);
	border-radius: 10px;
	background: color-mix(in srgb, var(--contents) 88%, var(--background) 12%);
	display: grid;
	gap: 0.25rem;
}

.popugame__endgame-elo p {
	margin: 0;
	font-size: 0.9rem;
}

.popugame__endgame-modal .popugame__dialog-actions {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: 0.5rem;
}

.popugame__endgame-modal .popugame__dialog-actions .btn {
	width: 100%;
	min-width: 0;
}

.popugame__elo-value {
	color: #1a7f45;
	font-weight: 700;
}

.popugame__delta--positive {
	color: #1a7f45;
	font-weight: 700;
}

.popugame__delta--negative {
	color: #c23e3e;
	font-weight: 700;
}

@media (max-width: 720px) {
	.popugame__header {
		grid-template-columns: 1fr;
		text-align: center;
	}

	.popugame-shell {
		padding: 1rem;
		gap: 0.9rem;
	}

	.popugame__board {
		padding: 0.25rem;
		gap: 4px;
	}
}

@media (max-width: 480px) {
	.popugame-shell {
		margin: 0.35rem 0 1rem;
		max-width: 100%;
		padding: 0.6rem;
		border-radius: 14px;
	}

	.popugame__board {
		padding: 0;
		gap: 3px;
	}

	.popugame__modal {
		max-width: 96vw;
		padding: 1rem;
		border-radius: 12px;
	}

	.popugame__dialog-actions {
		justify-content: stretch;
		gap: 0.42rem;
	}

	.popugame__dialog-actions .btn {
		flex: 1 1 100%;
		min-width: 0;
	}

	.popugame__endgame-modal .popugame__dialog-actions {
		grid-template-columns: 1fr;
	}

	.popugame__names {
		flex-wrap: wrap;
		justify-content: center;
	}

	.popugame__status {
		overflow-wrap: anywhere;
		word-break: break-word;
	}
}
