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

:root {
	--bg: #1a1a2e;
	--surface: #16213e;
	--surface2: #0f3460;
	--accent: #e94560;
	--text: #eee;
	--text-dim: #999;
	--cell-size: 32px;
	--cell-hidden: #2d3a5c;
	--cell-hidden-hover: #3d4a6c;
	--cell-revealed: #0d1b36;
	--cell-border: #1a2744;
}

body {
	font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
	background: var(--bg);
	color: var(--text);
	min-height: 100vh;
	display: flex;
	justify-content: center;
	align-items: center;
}

.hidden {
	display: none !important;
}

/* Lobby */
#lobby {
	text-align: center;
	padding: 2rem;
}

#lobby h1 {
	font-size: 2.5rem;
	font-weight: 800;
	letter-spacing: -1px;
	margin-bottom: 0.25rem;
}

.subtitle {
	color: var(--text-dim);
	margin-bottom: 2rem;
	font-size: 1.1rem;
}

.lobby-form {
	background: var(--surface);
	padding: 2rem;
	border-radius: 16px;
	display: flex;
	flex-direction: column;
	gap: 0.75rem;
	width: 360px;
	margin: 0 auto;
}

.lobby-form label {
	text-align: left;
	font-size: 0.85rem;
	color: var(--text-dim);
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: 0.5px;
}

.lobby-form input {
	padding: 0.7rem 1rem;
	border-radius: 8px;
	border: 2px solid var(--surface2);
	background: var(--bg);
	color: var(--text);
	font-size: 1rem;
	outline: none;
	transition: border-color 0.2s;
}

.lobby-form input:focus {
	border-color: var(--accent);
}

.difficulty-select {
	margin-top: 0.25rem;
}

.difficulty-options {
	display: flex;
	gap: 0.5rem;
	margin-top: 0.5rem;
}

.diff-btn {
	flex: 1;
	padding: 0.6rem 0.5rem;
	border-radius: 8px;
	border: 2px solid var(--surface2);
	background: var(--bg);
	color: var(--text);
	cursor: pointer;
	font-size: 0.85rem;
	font-weight: 600;
	transition: all 0.2s;
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 0.2rem;
}

.diff-btn span {
	font-size: 0.65rem;
	font-weight: 400;
	color: var(--text-dim);
}

.diff-btn:hover {
	border-color: var(--accent);
}

.diff-btn.active {
	border-color: var(--accent);
	background: rgba(233, 69, 96, 0.15);
}

#joinBtn {
	padding: 0.8rem;
	border-radius: 8px;
	border: none;
	background: var(--accent);
	color: white;
	font-size: 1rem;
	font-weight: 700;
	cursor: pointer;
	margin-top: 0.5rem;
	transition: opacity 0.2s;
}

#joinBtn:hover {
	opacity: 0.9;
}

/* Game */
#game {
	display: flex;
	flex-direction: column;
	align-items: center;
	padding: 1rem;
	width: 100%;
}

header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	width: 100%;
	max-width: 1100px;
	padding: 0.75rem 1rem;
	margin-bottom: 1rem;
	background: var(--surface);
	border-radius: 12px;
	gap: 1rem;
}

.header-left {
	display: flex;
	flex-direction: column;
	gap: 0.2rem;
	min-width: 0;
}

#roomTitle {
	font-size: 1rem;
	font-weight: 700;
	white-space: nowrap;
}

#gameStatus {
	font-size: 0.8rem;
	color: var(--text-dim);
}

.header-center {
	display: flex;
	align-items: center;
	gap: 1rem;
}

.counter {
	display: flex;
	align-items: center;
	gap: 0.4rem;
	font-size: 1.2rem;
	font-weight: 700;
	font-variant-numeric: tabular-nums;
	min-width: 60px;
}

#newGameBtn {
	padding: 0.4rem 1rem;
	border-radius: 8px;
	border: 2px solid var(--surface2);
	background: var(--bg);
	color: var(--text);
	font-weight: 600;
	font-size: 0.8rem;
	cursor: pointer;
	transition: all 0.2s;
	white-space: nowrap;
}

#newGameBtn:hover {
	border-color: var(--accent);
	background: rgba(233, 69, 96, 0.1);
}

.header-right {
	display: flex;
	align-items: center;
}

#playerList {
	display: flex;
	gap: 0.5rem;
	flex-wrap: wrap;
	justify-content: flex-end;
}

.player-tag {
	display: flex;
	align-items: center;
	gap: 0.35rem;
	padding: 0.25rem 0.6rem;
	border-radius: 20px;
	font-size: 0.75rem;
	font-weight: 600;
	background: rgba(255,255,255,0.07);
	white-space: nowrap;
}

.player-dot {
	width: 8px;
	height: 8px;
	border-radius: 50%;
	flex-shrink: 0;
}

/* Board */
#boardWrapper {
	position: relative;
	display: inline-block;
}

#board {
	display: grid;
	gap: 1px;
	background: var(--cell-border);
	border: 2px solid var(--cell-border);
	border-radius: 8px;
	overflow: hidden;
	user-select: none;
}

.cell {
	width: var(--cell-size);
	height: var(--cell-size);
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 0.85rem;
	font-weight: 800;
	cursor: pointer;
	background: var(--cell-hidden);
	transition: background 0.1s;
	position: relative;
}

.cell:hover:not(.revealed):not(.game-over) {
	background: var(--cell-hidden-hover);
}

.cell.revealed {
	background: var(--cell-revealed);
	cursor: default;
}

.cell.mine-hit {
	background: rgba(233, 69, 96, 0.4);
}

.cell.flagged::after {
	content: '\25B6';
	font-size: 0.9rem;
}

/* Number colors */
.cell[data-num="1"] { color: #3498db; }
.cell[data-num="2"] { color: #2ecc71; }
.cell[data-num="3"] { color: #e74c3c; }
.cell[data-num="4"] { color: #9b59b6; }
.cell[data-num="5"] { color: #e67e22; }
.cell[data-num="6"] { color: #1abc9c; }
.cell[data-num="7"] { color: #ecf0f1; }
.cell[data-num="8"] { color: #95a5a6; }

/* Cursors */
#cursors {
	position: absolute;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	pointer-events: none;
	overflow: hidden;
}

.remote-cursor {
	position: absolute;
	pointer-events: none;
	transition: left 0.08s linear, top 0.08s linear;
	z-index: 10;
}

.cursor-pointer {
	width: 0;
	height: 0;
	border-left: 6px solid currentColor;
	border-right: 6px solid transparent;
	border-top: 10px solid currentColor;
	border-bottom: 2px solid transparent;
	filter: drop-shadow(0 1px 2px rgba(0,0,0,0.5));
}

.cursor-label {
	position: absolute;
	top: 14px;
	left: 8px;
	padding: 1px 6px;
	border-radius: 4px;
	font-size: 0.65rem;
	font-weight: 700;
	color: white;
	white-space: nowrap;
}

/* Game over overlay */
.game-over-overlay {
	position: absolute;
	inset: 0;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	background: rgba(0,0,0,0.6);
	border-radius: 8px;
	z-index: 20;
	backdrop-filter: blur(2px);
}

.game-over-overlay h2 {
	font-size: 2rem;
	margin-bottom: 0.5rem;
}

.game-over-overlay p {
	color: var(--text-dim);
	margin-bottom: 1rem;
}

.game-over-overlay button {
	padding: 0.6rem 1.5rem;
	border-radius: 8px;
	border: none;
	background: var(--accent);
	color: white;
	font-weight: 700;
	font-size: 0.9rem;
	cursor: pointer;
}

/* Win */
.win-text { color: #2ecc71; }
.lose-text { color: var(--accent); }

/* Responsive */
@media (max-width: 700px) {
	:root { --cell-size: 26px; }
	header { flex-direction: column; align-items: stretch; }
	.header-center { justify-content: center; }
	#playerList { justify-content: center; }
}
