* {
	margin: 0;
	padding: 0;
	box-sizing: border-box;
}

#loginPromptBtn {
	position: fixed;
	bottom: 24px;
	left: 50%;
	transform: translateX(-50%);
	z-index: 900;
	display: none;
	pointer-events: none;
}

#loginPromptBtn.visible {
	display: block;
	pointer-events: auto;
	animation: loginBtnFadeIn 0.4s ease forwards;
}

#loginPromptButton {
	background: #1979f7;
	color: white;
	border: none;
	padding: 16px 32px;
	font-size: 17px;
	font-weight: 700;
	border-radius: 12px;
	cursor: pointer;
	box-shadow: 0 4px 20px rgba(102, 126, 234, 0.5), 0 0 0 0 rgba(102, 126, 234, 0.4);
	transition: transform 0.2s ease, box-shadow 0.2s ease;
	white-space: nowrap;
	touch-action: manipulation;
	-webkit-tap-highlight-color: transparent;
	animation: loginBtnPulse 2.5s ease-in-out infinite;
}

#loginPromptButton:hover {
	transform: translateY(-2px);
	box-shadow: 0 6px 20px rgba(102, 126, 234, 0.6);
	animation: none;
}

#loginPromptButton:active {
	transform: translateY(0) scale(0.97);
}

@keyframes loginBtnFadeIn {
	from {
		opacity: 0;
		transform: translateX(-50%) translateY(20px);
	}
	to {
		opacity: 1;
		transform: translateX(-50%) translateY(0);
	}
}

@keyframes loginBtnPulse {
	0%, 100% {
		box-shadow: 0 4px 20px rgba(102, 126, 234, 0.5), 0 0 0 0 rgba(102, 126, 234, 0.4);
	}
	50% {
		box-shadow: 0 4px 20px rgba(102, 126, 234, 0.5), 0 0 0 8px rgba(102, 126, 234, 0);
	}
}

html, body {
	touch-action: none;
	-webkit-touch-callout: none;
	-webkit-user-select: none;
	user-select: none;
}

body {
	overflow: hidden;
	background: #141414;
	font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

canvas {
	display: block;
	cursor: grab;
	touch-action: none;
}

canvas.dragging {
	cursor: grabbing;
}

canvas.piece-selected {
	cursor: pointer;
}

.label {
	color: #aaa;
	font-size: 12px;
}

/* Login Modal */
#loginModal {
	display: none;
	position: fixed;
	top: 0; left: 0; right: 0; bottom: 0;
	background: rgba(0,0,0,0.6);
	z-index: 1000;
	justify-content: center;
	align-items: center;
}
#loginModal.visible {
	display: flex;
}
#loginModalContent {
	background: #191919;
	border-radius: 12px;
	padding: 32px;
	min-width: 340px;
	max-width: 400px;
	color: #ecf0f1;
	text-align: center;
	box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}
#loginModalContent h2 {
	margin-bottom: 16px;
	font-size: 22px;
}
#loginModalContent p {
	margin-bottom: 20px;
	color: #bdc3c7;
	font-size: 14px;
}
#googleSignInBtn {
	margin: 0 auto 12px auto;
}
#loginError {
	color: #e74c3c;
	font-size: 13px;
	margin-top: 8px;
	min-height: 18px;
}
#loginCloseBtn {
	margin-top: 12px;
	background: none;
	border: 1px solid #7f8c8d;
	color: #bdc3c7;
	padding: 6px 18px;
	border-radius: 6px;
	cursor: pointer;
	font-size: 13px;
}
#loginCloseBtn:hover {
	background: #7f8c8d;
	color: #fff;
}

/* Username Modal */
#usernameModal {
	display: none;
	position: fixed;
	top: 0; left: 0; right: 0; bottom: 0;
	background: rgba(0,0,0,0.6);
	z-index: 1001;
	justify-content: center;
	align-items: center;
}
#usernameModal.visible {
	display: flex;
}
#usernameModalContent {
	background: #191919;
	border-radius: 12px;
	padding: 32px;
	min-width: 340px;
	max-width: 400px;
	color: #ecf0f1;
	text-align: center;
	box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}
#usernameModalContent h2 {
	margin-bottom: 16px;
}
#usernameInput {
	width: 100%;
	padding: 10px;
	border-radius: 6px;
	border: 1px solid #7f8c8d;
	background: #141414;
	color: #ecf0f1;
	font-size: 16px;
	margin-bottom: 12px;
}
#usernameSubmitBtn {
	background: #27ae60;
	color: white;
	border: none;
	padding: 10px 28px;
	border-radius: 6px;
	cursor: pointer;
	font-size: 15px;
}
#usernameSubmitBtn:hover {
	background: #2ecc71;
}
#usernameError {
	color: #e74c3c;
	font-size: 13px;
	margin-top: 8px;
	min-height: 18px;
}

/* Profile Icon */
#profileIcon {
	display: none;
	position: fixed;
	top: 16px;
	right: 16px;
	width: 42px;
	height: 42px;
	border-radius: 50%;
	background: #191919;
	border: 3px solid #fff;
	cursor: pointer;
	z-index: 500;
	justify-content: center;
	align-items: center;
	font-size: 20px;
	color: #ecf0f1;
	user-select: none;
	overflow: hidden;
}
#profileIcon.visible {
	display: flex;
}

/* Right side icon buttons (shop, info) */
.right-icon-btn {
	display: none;
	position: fixed;
	right: 16px;
	width: 42px;
	height: 42px;
	border-radius: 50%;
	background: #fdfdfd;
	border: 2px solid #d0d0d0;
	cursor: pointer;
	z-index: 500;
	justify-content: center;
	align-items: center;
	color: #7f8285;
	user-select: none;
	transition: all 0.15s;
	font-size: 16px;
}
.right-icon-btn:hover {
	background: #f0f0f0;
	border-color: #888;
}
.right-icon-btn.visible {
	display: flex;
}
#shopBtn {
	top: 66px;
}
#infoBtnRight {
	top: 110px;
	font-family: Georgia, serif;
	font-style: italic;
	font-size: 18px;
}

/* Profile Panel */
#profilePanel {
	display: none;
	position: fixed;
	top: 68px;
	right: 16px;
	background: #191919;
	border-radius: 10px;
	padding: 20px;
	min-width: 220px;
	color: #ecf0f1;
	z-index: 501;
	box-shadow: 0 4px 20px rgba(0,0,0,0.4);
	font-size: 14px;
}
#profilePanel.visible {
	display: block;
}
#profilePanel .profile-row {
	margin-bottom: 8px;
}
#profilePanel .profile-username {
	margin-bottom: 8px;
	font-size: 30px;
}
#profilePanel .profile-label {
	color: #95a5a6;
	font-size: 12px;
}
#profilePanel .profile-value {
	font-weight: bold;
}

/* Zoom Controls */
#zoomControls {
	position: fixed;
	bottom: 20px;
	left: 20px;
	display: flex;
	flex-direction: column;
	gap: 4px;
	z-index: 400;
}
#zoomControls button {
	width: 38px;
	height: 38px;
	background: #ffffff;
	border: 2px solid #d0d0d0;
	border-radius: 6px;
	font-size: 20px;
	font-weight: bold;
	color: #333;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	user-select: none;
	transition: background 0.15s;
	line-height: 1;
	padding: 0;
}
#zoomControls button:hover {
	background: #f0f0f0;
}
#zoomControls button:active {
	background: #e0e0e0;
}

/* Hover tooltip */
#pieceTooltip {
	display: none;
	position: fixed;
	background: #141414;
	color: #ecf0f1;
	padding: 4px 10px;
	border-radius: 6px;
	font-size: 12px;
	pointer-events: none;
	z-index: 400;
	white-space: nowrap;
	box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

/* Move error toast */
#moveError {
	display: none;
	position: fixed;
	bottom: 30px;
	left: 50%;
	transform: translateX(-50%);
	background: #c0392b;
	color: white;
	padding: 10px 24px;
	border-radius: 8px;
	font-size: 14px;
	z-index: 600;
	box-shadow: 0 2px 12px rgba(0,0,0,0.3);
	pointer-events: none;
}

/* Info Modal */
#infoModal {
	display: none;
	position: fixed;
	top: 0; left: 0; right: 0; bottom: 0;
	background: rgba(0,0,0,0.6);
	z-index: 1002;
	justify-content: center;
	align-items: center;
}
#infoModal.visible {
	display: flex;
}
#infoModalContent {
	background: #191919;
	border-radius: 12px;
	padding: 32px;
	max-width: 480px;
	width: 90%;
	max-height: 85vh;
	overflow-y: auto;
	color: #ecf0f1;
	text-align: left;
	box-shadow: 0 8px 32px rgba(0,0,0,0.5);
	position: relative;
}
#infoModalContent::-webkit-scrollbar {
	width: 6px;
}
#infoModalContent::-webkit-scrollbar-track {
	background: #141414;
	border-radius: 3px;
}
#infoModalContent::-webkit-scrollbar-thumb {
	background: #7f8c8d;
	border-radius: 3px;
}
#infoModalContent h2 {
	text-align: center;
	font-size: 22px;
	margin-bottom: 20px;
}
#infoCloseBtn {
	position: absolute;
	top: 12px;
	right: 16px;
	background: none;
	border: 1px solid #7f8c8d;
	color: #bdc3c7;
	font-size: 16px;
	cursor: pointer;
	padding: 2px 8px;
	border-radius: 6px;
	line-height: 1;
	transition: all 0.2s;
}
#infoCloseBtn:hover {
	background: #7f8c8d;
	color: #fff;
}
.info-section {
	margin-bottom: 18px;
}
.info-section h3 {
	color: #ecf0f1;
	font-size: 15px;
	margin-bottom: 4px;
}
.info-section p {
	color: #bdc3c7;
	font-size: 14px;
	line-height: 1.6;
}
.info-section strong {
	color: #ecf0f1;
}
.team-white {
	color: #ffffff;
	font-weight: bold;
}
.team-black {
	color: #95a5a6;
	font-weight: bold;
}
.info-demo {
	display: flex;
	justify-content: center;
	margin-top: 12px;
	position: relative;
}
#demoBoardCanvas {
	border-radius: 8px;
	border: 1px solid #7f8c8d;
	background: #141414;
}
#demoCursorCanvas {
	position: absolute;
	top: 0;
	left: 0;
	pointer-events: none;
	width: 240px;
	height: 240px;
}

/* Game Over Modal */
#gameOverModal {
	display: none;
	position: fixed;
	top: 0; left: 0; right: 0; bottom: 0;
	background: rgba(0,0,0,0.7);
	z-index: 2000;
	justify-content: center;
	align-items: center;
}
#gameOverModal.visible {
	display: flex;
}
#gameOverModalContent {
	background: #191919;
	border-radius: 14px;
	padding: 40px;
	min-width: 360px;
	max-width: 440px;
	color: #ecf0f1;
	text-align: center;
	box-shadow: 0 12px 40px rgba(0,0,0,0.6);
}
#gameOverModalContent h2 {
	font-size: 28px;
	margin-bottom: 12px;
}
#gameOverMessage {
	color: #bdc3c7;
	font-size: 16px;
	line-height: 1.6;
	margin-bottom: 20px;
}
#gameOverTrophy {
	font-size: 64px;
	margin-bottom: 8px;
}
#gameOverCloseBtn {
	margin-top: 16px;
	background: none;
	border: 1px solid #7f8c8d;
	color: #bdc3c7;
	padding: 8px 24px;
	border-radius: 6px;
	cursor: pointer;
	font-size: 14px;
	transition: all 0.2s;
}
#gameOverCloseBtn:hover {
	background: #7f8c8d;
	color: #fff;
}
#logoutBtn {
	width: 100%;
	background: none;
	border: 1px solid #7f8c8d;
	color: #bdc3c7;
	padding: 8px;
	border-radius: 6px;
	cursor: pointer;
	font-size: 13px;
	transition: all 0.2s;
}
#logoutBtn:hover {
	background: #c0392b;
	border-color: #c0392b;
	color: #fff;
}

/* Loading Overlay */
#loadingOverlay {
	position: fixed;
	top: 0; left: 0; right: 0; bottom: 0;
	background: #141414;
	z-index: 3000;
	display: flex;
	justify-content: center;
	align-items: center;
	transition: opacity 0.4s ease;
}
#loadingOverlay.hidden {
	opacity: 0;
	pointer-events: none;
}
#loadingContent {
	text-align: center;
}
#loadingSpinner {
	width: 48px;
	height: 48px;
	border: 4px solid #7f8c8d;
	border-top: 4px solid #ecf0f1;
	border-radius: 50%;
	margin: 0 auto 16px auto;
	animation: spin 0.8s linear infinite;
}
@keyframes spin {
	to { transform: rotate(360deg); }
}
#loadingText {
	color: #bdc3c7;
	font-size: 16px;
	font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

/* Flag Menu */
#flagMenu {
	display: none;
	position: fixed;
	z-index: 700;
	background: #1e1e1e;
	border: 1px solid #444;
	border-radius: 10px;
	padding: 12px 14px;
	box-shadow: 0 6px 24px rgba(0,0,0,0.5);
	color: #ecf0f1;
	font-size: 13px;
	min-width: 180px;
}
#flagMenu.visible {
	display: block;
}
#flagMenuTitle {
	font-weight: bold;
	font-size: 13px;
	margin-bottom: 8px;
	text-align: center;
	color: #bdc3c7;
}
#flagColorPicker {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
	justify-content: center;
	margin-bottom: 10px;
}
.flag-color-swatch {
	width: 22px;
	height: 22px;
	border-radius: 50%;
	cursor: pointer;
	border: 2px solid transparent;
	transition: border-color 0.15s, transform 0.15s;
}
.flag-color-swatch:hover {
	transform: scale(1.15);
}
.flag-color-swatch.selected {
	border-color: #ffffff;
}
#flagLabelInput {
	width: 100%;
	padding: 6px 8px;
	border-radius: 5px;
	border: 1px solid #555;
	background: #141414;
	color: #ecf0f1;
	font-size: 12px;
	margin-bottom: 8px;
	outline: none;
}
#flagLabelInput:focus {
	border-color: #7f8c8d;
}
#flagPlaceBtn {
	width: 100%;
	padding: 7px;
	background: #27ae60;
	color: white;
	border: none;
	border-radius: 6px;
	cursor: pointer;
	font-size: 13px;
	font-weight: bold;
	transition: background 0.15s;
}
#flagPlaceBtn:hover {
	background: #2ecc71;
}

/* Flag list in profile panel */
#flagListSection {
	margin-top: 12px;
	border-top: 1px solid #333;
	padding-top: 10px;
}
#flagListSection .profile-label {
	margin-bottom: 6px;
}
#flagList {
	max-height: 160px;
	overflow-y: auto;
	font-size: 12px;
}
#flagList::-webkit-scrollbar {
	width: 4px;
}
#flagList::-webkit-scrollbar-track {
	background: #141414;
}
#flagList::-webkit-scrollbar-thumb {
	background: #555;
	border-radius: 2px;
}
.flag-list-item {
	display: flex;
	align-items: center;
	gap: 6px;
	padding: 4px 2px;
	cursor: pointer;
	border-radius: 4px;
	transition: background 0.15s;
}
.flag-list-item:hover {
	background: #2a2a2a;
}
.flag-list-dot {
	width: 10px;
	height: 10px;
	border-radius: 50%;
	flex-shrink: 0;
}
.flag-list-label {
	flex: 1;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
	color: #ccc;
}
.flag-list-delete {
	color: #888;
	cursor: pointer;
	font-size: 14px;
	padding: 0 2px;
	flex-shrink: 0;
	transition: color 0.15s;
}
.flag-list-delete:hover {
	color: #e74c3c;
}
.flag-list-empty {
	color: #666;
	font-style: italic;
	padding: 4px 2px;
}

/* Shop Modal */
#shopModal {
	display: none;
	position: fixed;
	top: 0; left: 0; right: 0; bottom: 0;
	background: rgba(0,0,0,0.6);
	z-index: 1003;
	justify-content: center;
	align-items: center;
}
#shopModal.visible {
	display: flex;
}
#shopModalContent {
	background: #191919;
	border-radius: 12px;
	padding: 32px;
	max-width: 420px;
	width: 90%;
	max-height: 85vh;
	overflow-y: auto;
	color: #ecf0f1;
	text-align: left;
	box-shadow: 0 8px 32px rgba(0,0,0,0.5);
	position: relative;
}
#shopModalContent h2 {
	text-align: center;
	font-size: 22px;
	margin-bottom: 6px;
}
#shopCurrency {
	text-align: center;
	font-size: 18px;
	font-weight: bold;
	color: #f1c40f;
	margin-bottom: 20px;
}
#shopCloseBtn {
	position: absolute;
	top: 12px;
	right: 16px;
	background: none;
	border: 1px solid #7f8c8d;
	color: #bdc3c7;
	font-size: 16px;
	cursor: pointer;
	padding: 2px 8px;
	border-radius: 6px;
	line-height: 1;
	transition: all 0.2s;
}
#shopCloseBtn:hover {
	background: #7f8c8d;
	color: #fff;
}
.shop-item {
	background: #222;
	border: 1px solid #333;
	border-radius: 10px;
	padding: 16px;
	margin-bottom: 14px;
}
.shop-item-header {
	display: flex;
	justify-content: space-between;
	align-items: center;
	margin-bottom: 6px;
}
.shop-item-name {
	font-weight: bold;
	font-size: 15px;
}
.shop-item-cost {
	color: #f1c40f;
	font-weight: bold;
	font-size: 14px;
}
.shop-item-desc {
	color: #95a5a6;
	font-size: 13px;
	margin-bottom: 10px;
	line-height: 1.4;
}
.shop-item-status {
	color: #7f8c8d;
	font-size: 12px;
	margin-bottom: 8px;
}
.shop-buy-btn {
	width: 100%;
	padding: 8px;
	background: #2980b9;
	color: white;
	border: none;
	border-radius: 6px;
	cursor: pointer;
	font-size: 13px;
	font-weight: bold;
	transition: background 0.15s;
}
.shop-buy-btn:hover {
	background: #3498db;
}
.shop-buy-btn:disabled {
	background: #555;
	cursor: not-allowed;
	color: #999;
}
#shopError {
	color: #e74c3c;
	font-size: 13px;
	text-align: center;
	min-height: 18px;
	margin-top: 4px;
}

/* Name color picker in shop */
#nameColorPickerSection {
	margin-top: 8px;
}
#nameColorInput {
	width: 100%;
	height: 36px;
	border: 1px solid #555;
	border-radius: 6px;
	background: #141414;
	cursor: pointer;
	margin-bottom: 8px;
	padding: 2px;
}
#nameColorPreview {
	text-align: center;
	font-weight: bold;
	font-size: 14px;
	margin-bottom: 8px;
	min-height: 20px;
}
/* Mobile fixes */
@media (max-width: 768px) {
	#loginPromptBtn {
		bottom: 20px;
		width: calc(100% - 40px);
		max-width: 320px;
    	}

	#loginPromptButton {
		width: 100%;
		padding: 18px 24px;
		font-size: 16px;
		border-radius: 12px;
    	}
	#profileIcon {
		top: 10px;
		right: 10px;
		width: 38px;
		height: 38px;
	}
	
	.right-icon-btn {
		right: 10px;
		width: 38px;
		height: 38px;
	}
	
	#shopBtn {
		top: 56px;
	}
	
	#infoBtnRight {
		top: 96px;
	}
	
	#zoomControls {
		bottom: 14px;
		left: 14px;
	}
	
	#zoomControls button {
		width: 44px;
		height: 44px;
		font-size: 22px;
	}
	
	#profilePanel {
		top: 54px;
		right: 10px;
		max-width: calc(100vw - 20px);
		max-height: calc(100vh - 70px);
		overflow-y: auto;
	}
	
	#loginModalContent,
	#usernameModalContent,
	#gameOverModalContent {
		min-width: unset;
		width: 90%;
		max-width: 400px;
		padding: 24px;
	}
	
	#shopModalContent,
	#infoModalContent {
		width: 94%;
		max-height: 80vh;
		padding: 24px;
	}
	
	#flagMenu {
		max-width: calc(100vw - 24px);
	}
	
	#moveError {
		bottom: 70px;
		max-width: 90vw;
		font-size: 13px;
	}
}

/* Prevent iOS tap highlight */
canvas, button, div {
	-webkit-tap-highlight-color: transparent;
}

/* Fix buttons not being tappable on mobile */
#profileIcon,
.right-icon-btn,
#zoomControls button,
#loginPromptButton {
	touch-action: manipulation;
}

/* Safe area insets for notched phones */
@supports (padding: env(safe-area-inset-top)) {
	#loginPromptBtn {
		bottom: calc(24px + env(safe-area-inset-bottom, 0px));
    	}
	#profileIcon {
		top: calc(16px + env(safe-area-inset-top, 0px));
	}
	.right-icon-btn {
		right: calc(16px + env(safe-area-inset-right, 0px));
	}
	#shopBtn {
		top: calc(66px + env(safe-area-inset-top, 0px));
	}
	#infoBtnRight {
		top: calc(110px + env(safe-area-inset-top, 0px));
	}
	#profilePanel {
		top: calc(68px + env(safe-area-inset-top, 0px));
	}
	#zoomControls {
		bottom: calc(20px + env(safe-area-inset-bottom, 0px));
		left: calc(20px + env(safe-area-inset-left, 0px));
	}
	#moveError {
		bottom: calc(30px + env(safe-area-inset-bottom, 0px));
	}
	
	@media (max-width: 768px) {
		#profileIcon {
			top: calc(10px + env(safe-area-inset-top, 0px));
		}
		#shopBtn {
			top: calc(56px + env(safe-area-inset-top, 0px));
		}
		#infoBtnRight {
			top: calc(96px + env(safe-area-inset-top, 0px));
		}
		#profilePanel {
			top: calc(54px + env(safe-area-inset-top, 0px));
		}
	}
}
html, body {
	height: 100%;
	overflow: hidden;
	position: fixed;
	width: 100%;
}
