/* zahuuu — tối giản, hiện đại; dark-first, auto light */
:root {
	--bg: #0e1116;
	--panel: #151a21;
	--panel-2: #1b212b;
	--line: #232b36;
	--text: #e8edf4;
	--muted: #8b96a5;
	--accent: #4da3ff;
	--good: #3ecf8e;
	--warn: #ffb454;
	--p0: #ff7a76;
	--p1: #61d0ff;
	--radius: 12px;
}
@media (prefers-color-scheme: light) {
	:root {
		--bg: #f5f7fa;
		--panel: #ffffff;
		--panel-2: #eef2f7;
		--line: #dde4ec;
		--text: #17202a;
		--muted: #66707c;
	}
}

* {
	box-sizing: border-box;
}
html,
body,
#root {
	height: 100%;
	margin: 0;
}
body {
	background: var(--bg);
	color: var(--text);
	font:
		15px/1.45 ui-rounded,
		system-ui,
		-apple-system,
		"Segoe UI",
		Roboto,
		sans-serif;
}
button {
	font: inherit;
	color: inherit;
	cursor: pointer;
	border: none;
	background: none;
}
input {
	font: inherit;
	color: inherit;
	background: var(--panel-2);
	border: 1px solid var(--line);
	border-radius: 10px;
	padding: 9px 12px;
	outline-color: var(--accent);
}
.mono {
	font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.muted {
	color: var(--muted);
}
.tiny {
	font-size: 12.5px;
}
.center {
	text-align: center;
}

.btn {
	background: var(--panel-2);
	border: 1px solid var(--line);
	border-radius: 10px;
	padding: 8px 14px;
	transition:
		transform 0.06s ease,
		filter 0.15s ease;
}
.btn:hover:not(:disabled) {
	filter: brightness(1.12);
}
.btn:active:not(:disabled) {
	transform: scale(0.97);
}
.btn.primary {
	background: var(--accent);
	border-color: transparent;
	color: #041018;
	font-weight: 650;
}
.btn.tiny {
	padding: 5px 10px;
	font-size: 13px;
	border-radius: 8px;
}
.btn.big {
	font-size: 34px;
	padding: 10px 18px;
	border-radius: 16px;
}
.btn.ghost {
	background: transparent;
}
.btn:disabled {
	opacity: 0.45;
	cursor: not-allowed;
}

/* ---------- landing ---------- */
.landing {
	min-height: 100%;
	display: grid;
	place-items: center;
	padding: 24px;
}
.card {
	background: var(--panel);
	border: 1px solid var(--line);
	border-radius: var(--radius);
}
.hero {
	max-width: 430px;
	width: 100%;
	padding: 30px 30px 22px;
	display: flex;
	flex-direction: column;
	gap: 15px;
}
.hero h1 {
	margin: 0;
	font-size: 44px;
	letter-spacing: -0.03em;
}
.accent {
	color: var(--accent);
}
.field {
	display: flex;
	flex-direction: column;
	gap: 6px;
	font-size: 13px;
	color: var(--muted);
}
.joinrow {
	display: flex;
	gap: 8px;
}
.joinrow input {
	flex: 1;
	min-width: 0;
}

/* ---------- app frame ---------- */
.app {
	display: grid;
	height: 100dvh;
	grid-template-rows: 52px 1fr;
	grid-template-columns: minmax(340px, 1fr) minmax(340px, 1fr);
	grid-template-areas:
		"top top"
		"chat game";
}
.top {
	grid-area: top;
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 0 14px;
	border-bottom: 1px solid var(--line);
	background: var(--panel);
}
.brand {
	font-weight: 800;
	font-size: 20px;
	text-decoration: none;
	color: var(--text);
	letter-spacing: -0.02em;
}
.dot {
	width: 9px;
	height: 9px;
	border-radius: 50%;
	background: var(--muted);
}
.dot.ok {
	background: var(--good);
}
.room-chip {
	background: var(--panel-2);
	padding: 4px 9px;
	border-radius: 8px;
	font-size: 13.5px;
}
.presence {
	display: flex;
	margin-left: auto;
}
.avatar {
	width: 27px;
	height: 27px;
	border-radius: 50%;
	display: inline-grid;
	place-items: center;
	font-size: 12.5px;
	font-weight: 700;
	color: #fff;
	margin-left: -6px;
	border: 2px solid var(--panel);
}
.avatar.sm {
	width: 24px;
	height: 24px;
	margin: 0 8px 0 0;
	border: none;
	flex: none;
}
.avatar.self {
	box-shadow: 0 0 0 2px var(--accent);
}
.nametag {
	width: 130px;
	padding: 4px 9px;
	font-size: 13.5px;
	text-align: right;
}

.chatcol {
	grid-area: chat;
	min-height: 0;
	display: flex;
}
.gamecol {
	grid-area: game;
	min-height: 0;
	border-left: 1px solid var(--line);
	background: color-mix(in srgb, var(--panel) 65%, var(--bg));
	display: flex;
}

/* ---------- chat ---------- */
.chatpane {
	flex: 1;
	display: grid;
	grid-template-rows: 1fr auto auto;
	min-height: 0;
}
.msglist {
	overflow-y: auto;
	padding: 14px 16px 6px;
	scrollbar-width: thin;
}
.row {
	margin: 0 0 10px;
}
.msg {
	display: flex;
	align-items: flex-start;
}
.bubble {
	max-width: 78%;
	background: var(--panel);
	border: 1px solid var(--line);
	border-radius: 12px;
	padding: 7px 11px 8px;
}
.msg.mine .bubble {
	background: color-mix(in srgb, var(--accent) 14%, var(--panel));
}
.bubble .who {
	display: block;
	font-size: 12px;
	font-weight: 700;
	margin-bottom: 2px;
	color: var(--accent);
}
.bubble p {
	margin: 0;
	white-space: pre-wrap;
	word-break: break-word;
}
.row.sys {
	text-align: center;
	color: var(--muted);
	font-size: 12.5px;
	margin: 14px 0;
}
.row.gamemsg {
	max-width: 82%;
	margin-inline: auto;
	border: 1px dashed color-mix(in srgb, var(--accent) 55%, transparent);
	border-radius: 12px;
	padding: 8px 12px;
	background: color-mix(in srgb, var(--accent) 9%, transparent);
}
.gamemsg .gtext {
	white-space: pre-wrap;
	font-weight: 600;
}
.gamemsg .who {
	float: right;
	font-size: 11.5px;
	color: var(--muted);
}
.typingbar {
	min-height: 18px;
	padding: 0 18px;
}
.typingbar span {
	animation: pulse 1.4s ease infinite;
}
@keyframes pulse {
	50% {
		opacity: 0.45;
	}
}
.composer {
	display: flex;
	gap: 8px;
	padding: 10px 14px 14px;
}
.composer input {
	flex: 1;
	min-width: 0;
}

/* ---------- game pane ---------- */
.gpane {
	flex: 1;
	display: flex;
	flex-direction: column;
	min-height: 0;
	overflow-y: auto;
	padding: 12px 14px 16px;
	gap: 10px;
	scrollbar-width: thin;
}
.ghead {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 8px;
}
.banner {
	font-size: 13px;
	color: var(--muted);
}
.banner.done {
	color: var(--good);
	font-weight: 700;
}
.seats {
	display: flex;
	gap: 8px;
}
.chip {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	background: var(--panel);
	border: 1px solid var(--line);
	border-radius: 999px;
	padding: 4px 11px 4px 5px;
	font-size: 13px;
}
.chip.open {
	padding: 3px 6px;
	color: var(--muted);
}
.chip.live {
	border-color: var(--accent);
	box-shadow: 0 0 0 1px var(--accent);
}
.mini-avatar {
	width: 22px;
	height: 22px;
	border-radius: 50%;
	display: inline-grid;
	place-items: center;
	font-style: normal;
	font-size: 11px;
	font-weight: 700;
	color: #fff;
}
.boardwrap {
	flex: none;
	display: grid;
	place-items: start center;
}

.picker {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
	gap: 9px;
}
.pick {
	text-align: left;
	padding: 11px 12px;
	display: flex;
	flex-direction: column;
	gap: 3px;
	transition: border-color 0.15s ease;
}
.pick:hover {
	border-color: var(--accent);
}
.pick strong {
	font-size: 14.5px;
}
.pick em {
	font-style: normal;
	font-size: 11.5px;
	color: var(--accent);
}
.pick.pick-aviator {
	border-color: color-mix(in srgb, var(--accent) 70%, transparent);
	background:
		radial-gradient(90% 120% at 90% -20%, rgb(255 178 84 / 14%), transparent 55%),
		var(--panel);
	grid-column: 1 / -1;
	flex-direction: row;
	align-items: center;
	gap: 10px;
}
.pick.pick-aviator strong {
	font-size: 16px;
	color: var(--warn);
}
.pick.pick-aviator span {
	flex: 1;
}
.pick .cnt {
	font-size: 11.5px;
	font-weight: 700;
	color: var(--good);
	background: color-mix(in srgb, var(--good) 14%, transparent);
	border-radius: 999px;
	padding: 2px 8px;
	align-self: flex-start;
}
.pick .live-cnt {
	color: var(--warn);
	background: color-mix(in srgb, var(--warn) 14%, transparent);
}
.pick.locked {
	opacity: 0.62;
	cursor: not-allowed;
}
.pick.locked:hover {
	border-color: var(--line);
}
.pick span {
	font-size: 12px;
	color: var(--muted);
	line-height: 1.35;
}
.gfoot {
	display: flex;
	justify-content: space-between;
	align-items: center;
	gap: 8px;
}

/* ---------- boards ---------- */
.grid {
	display: grid;
	gap: 0;
	user-select: none;
	touch-action: manipulation;
	border: 1px solid var(--line);
	border-radius: 10px;
	overflow: hidden;
}
.cell {
	width: 100%;
	aspect-ratio: 1;
	display: grid;
	place-items: center;
	padding: 0;
	background: var(--panel-2);
	position: relative;
	font-size: calc(var(--sz, 38px) * 0.62);
	line-height: 1;
	border-radius: 0;
}
.cell.dark {
	background: color-mix(in srgb, var(--panel) 55%, #000 12%);
}
.cell.light {
	background: var(--panel-2);
}
.cell.sel {
	background: color-mix(in srgb, var(--accent) 30%, var(--panel-2)) !important;
}
.cell.hint::after {
	content: "";
	position: absolute;
	inset: 0;
	box-shadow: inset 0 0 0 2.5px var(--accent);
	border-radius: 2px;
}
.hintdot {
	width: 26%;
	height: 26%;
	border-radius: 50%;
	background: var(--accent);
	opacity: 0.85;
}
.s0 {
	color: var(--p0);
}
.s1 {
	color: var(--p1);
}
.t0 {
	color: var(--p0);
	font-size: calc(var(--cell, 38px) * 0.6);
}
.t1 {
	color: var(--p1);
	font-size: calc(var(--cell, 38px) * 0.6);
}
.stone {
	font-size: calc(var(--cell, 38px) * 0.68);
}
.disc {
	width: 72%;
	height: 72%;
	border-radius: 50%;
	display: grid;
	place-items: center;
	font-size: 0;
}
.disc.fill.s0 {
	background: radial-gradient(circle at 34% 30%, #ffb0ad, var(--p0));
}
.disc.fill.s1 {
	background: radial-gradient(circle at 34% 30%, #a8e4ff, var(--p1));
}
.oth {
	font-size: calc(var(--cell, 38px) * 0.6);
}
.chk {
	width: 74%;
	height: 74%;
	border-radius: 50%;
	display: grid;
	place-items: center;
	font-size: calc(var(--cell, 38px) * 0.42);
	color: #fff;
}
.chk.s0 {
	background: linear-gradient(#ffe1df, var(--p0));
}
.chk.s1 {
	background: linear-gradient(#cdeeff, #1793cf);
}

/* ---------- dots & boxes ---------- */
.dgrid {
	display: grid;
	grid-template-columns: repeat(7, 30px);
	grid-auto-rows: 30px;
	gap: 0;
	user-select: none;
}
.ddot {
	width: 9px;
	height: 9px;
	border-radius: 50%;
	background: var(--muted);
	place-self: center;
}
.dedge {
	border-radius: 6px;
	background: transparent;
	position: relative;
}
.dedge.horiz {
	height: 10px;
	align-self: center;
	width: 100%;
}
.dedge.vert {
	width: 10px;
	align-self: center;
	height: 100%;
	justify-self: center;
}
.dedge:not(:disabled):hover {
	background: color-mix(in srgb, var(--accent) 35%, transparent);
}
.dedge.e0 {
	background: var(--p0);
}
.dedge.e1 {
	background: var(--p1);
}
.dbox {
	border-radius: 8px;
	place-self: center;
	width: 88%;
	height: 88%;
}
.dbox.box0 {
	background: color-mix(in srgb, var(--p0) 40%, transparent);
}
.dbox.box1 {
	background: color-mix(in srgb, var(--p1) 40%, transparent);
}

/* ---------- rps ---------- */
.rps {
	display: flex;
	flex-direction: column;
	gap: 12px;
	align-items: center;
}
.scoreline {
	display: flex;
	gap: 14px;
	align-items: baseline;
	font-size: 15px;
}
.scoreline strong {
	font-size: 26px;
}
.scoreline .lead {
	color: var(--good);
	font-weight: 700;
}
.rpsbtns {
	display: flex;
	gap: 14px;
}
.avstage {
	position: relative;
	height: 230px;
	overflow: hidden;
	border-radius: var(--radius);
	background: #10151c;
	box-shadow: inset 0 0 0 1px var(--line);
}
.rpslog {
	list-style: none;
	margin: 4px 0 0;
	padding: 8px 16px;
	background: var(--panel);
	border-radius: 10px;
	border: 1px solid var(--line);
	font-size: 13px;
	max-width: 240px;
}

/* ---------- minesweeper / memory ---------- */
.msbar {
	display: flex;
	gap: 14px;
	align-items: center;
	justify-content: center;
}
.msgrid {
	display: grid;
	gap: 3px;
	justify-content: center;
}
.mscell {
	width: 32px;
	height: 32px;
	border-radius: 7px;
	background: var(--panel-2);
	border: 1px solid var(--line);
	display: grid;
	place-items: center;
	font-weight: 800;
	font-size: 14px;
}
.mscell.open {
	background: color-mix(in srgb, var(--panel) 70%, var(--bg));
	border-color: transparent;
}
.n1 {
	color: #6db3ff;
}
.n2 {
	color: var(--good);
}
.n3 {
	color: var(--warn);
}
.n4 {
	color: var(--p0);
}
.memgrid {
	display: grid;
	grid-template-columns: repeat(4, 64px);
	gap: 8px;
	justify-content: center;
}
.memcard {
	width: 64px;
	height: 64px;
	border-radius: 12px;
	background: var(--panel-2);
	border: 1px solid var(--line);
	display: grid;
	place-items: center;
	font-size: 30px;
	transition:
		transform 0.12s ease,
		background 0.2s ease;
}
.memcard.up {
	background: #fff8;
	transform: rotateY(180deg) scaleY(-1);
}
.memcard.up span,
.memcard.done span {
	transform: scaleY(-1);
}
.memcard.done {
	background: color-mix(in srgb, var(--good) 22%, var(--panel-2));
	border-color: transparent;
	opacity: 0.8;
}

/* ---------- aviator ---------- */
.avhist {
	display: flex;
	gap: 7px;
	overflow-x: auto;
	font-size: 12.5px;
	font-weight: 700;
	padding-bottom: 2px;
}
.avstage {
	position: relative;
	height: 230px;
	overflow: hidden;
	border-radius: var(--radius);
	background:
		radial-gradient(120% 90% at 78% -10%, rgb(77 163 255 / 16%), transparent 60%),
		var(--panel);
	box-shadow: inset 0 0 0 1px var(--line);
}
.avpixi {
	width: 100%;
	height: 100%;
	display: block;
}
.avctl {
	display: flex;
	flex-direction: column;
	gap: 8px;
	align-items: stretch;
}
.avbal strong {
	color: var(--text);
}
.rowbtns {
	display: flex;
	gap: 6px;
	align-items: center;
}
.rowbtns .btn.selamt {
	border-color: var(--accent);
	color: var(--accent);
}
.avamtv {
	width: 90px;
	padding: 5px 8px;
	margin-left: auto;
}
.averr {
	margin: 0;
	color: var(--p0);
	font-size: 13px;
	text-align: center;
}
.avplayers {
	list-style: none;
	margin: 0;
	padding: 8px 12px;
	background: var(--panel);
	border-radius: 10px;
	border: 1px solid var(--line);
	max-height: 150px;
	overflow-y: auto;
	font-size: 13px;
	display: flex;
	flex-direction: column;
	gap: 4px;
	scrollbar-width: thin;
}
.good {
	color: var(--good);
}
.lost {
	color: var(--p0);
}
@keyframes cashPulse {
	0%,
	100% {
		transform: scale(1);
		box-shadow: 0 0 0 0 rgb(62 207 142 / 55%);
	}
	50% {
		transform: scale(1.03);
		box-shadow: 0 0 0 8px rgb(62 207 142 / 0%);
	}
}
.pulsing {
	animation: cashPulse 1.1s ease infinite;
	background: var(--good) !important;
	color: #04170f !important;
}

/* ---------- toast & fab ---------- */
.toast {
	position: fixed;
	left: 18px;
	bottom: 18px;
	background: var(--panel);
	border: 1px solid var(--line);
	border-left: 3px solid var(--accent);
	border-radius: 10px;
	padding: 10px 16px;
	box-shadow: 0 6px 24px rgb(0 0 0 / 25%);
	animation: rise 0.18s ease;
	z-index: 60;
}
@keyframes rise {
	from {
		translate: 0 8px;
		opacity: 0;
	}
}
.fabs {
	display: none;
	position: fixed;
	right: 16px;
	bottom: 16px;
	width: 54px;
	height: 54px;
	border-radius: 50%;
	background: var(--accent);
	color: #041018;
	font-size: 23px;
	box-shadow: 0 8px 22px rgb(0 0 0 / 35%);
	z-index: 55;
}
.fabs .badge {
	position: absolute;
	top: 4px;
	right: 4px;
	width: 11px;
	height: 11px;
	border-radius: 50%;
	background: var(--p0);
	border: 2px solid var(--bg);
}

/* ---------- mobile ---------- */
@media (max-width: 900px) {
	.app {
		grid-template-columns: 1fr;
		grid-template-areas:
			"top"
			"chat";
	}
	.gamecol {
		position: fixed;
		inset: 52px 0 0 0;
		z-index: 50;
		background: var(--bg);
		border-left: none;
		display: none;
		padding-top: 8px;
	}
	.app.mobile-game .gamecol {
		display: flex;
	}
	.fabs {
		display: block;
	}
	.nametag {
		width: 96px;
	}
	.grid {
		max-width: 100vw;
	}
}
