/* Newton Community Mahjong — scoped front-end styles.
 *
 * Everything is scoped under #newton-mahjong. No bare element selector is styled
 * outside that root, so the theme, the header, the footer, Newton Five and every
 * other plugin keep their own rules. There is no Preflight, no reset and no utility
 * framework.
 *
 * Tokens follow the project's editorial system (games.css): navy #15263a, cream
 * #f7f3ea, gold #caa85e, blue #61b4ce, Georgia for display, Arial for text.
 *
 * Board geometry: a tile occupies two half-units. --x and --y arrive from PHP in
 * half units, so position is a multiplication and the whole board scales from one
 * declaration (--tile). Tile depth and shadows are derived from the same unit, so a
 * tile keeps its proportions at every zoom level.
 */

#newton-mahjong {
	--mjn-navy: #15263a;
	--mjn-navy-soft: #24445e;
	--mjn-gold: #caa85e;
	--mjn-gold-deep: #b4923f;
	--mjn-cream: #f7f3ea;
	--mjn-paper: #fff;
	--mjn-ink: #202a31;
	--mjn-muted: #566069;
	--mjn-line: rgba(21, 38, 58, 0.13);
	--mjn-focus: #caa85e;
	--mjn-body: Arial, Helvetica, sans-serif;
	--mjn-display: Georgia, "Times New Roman", serif;
	--mjn-radius: 16px;
	--mjn-target: 44px;
	--mjn-ease: cubic-bezier(0.22, 1, 0.36, 1);

	/* Felt surface. */
	--mjn-felt-1: #1d3a34;
	--mjn-felt-2: #142823;
	--mjn-felt-edge: rgba(202, 168, 94, 0.28);

	/* Tile size drives everything on the board. */
	/* A Mahjong tile is a portrait rectangle, not a square: 3:4, like the real thing.
	 * --tile is the WIDTH; every vertical measurement comes from --tile-h. */
	--tile: clamp(19px, calc((100vw - 48px) / 15), 54px);
	--tile-h: calc(var(--tile) * 4 / 3);
	--u: calc(var(--tile) / 2);
	--u-h: calc(var(--tile-h) / 2);
	--edge: clamp(2px, calc(var(--u) * 0.30), 7px);

	container-type: inline-size;

	box-sizing: border-box;
	width: min(100% - 32px, 1180px);
	margin: clamp(20px, 3vw, 40px) auto 64px;
	color: var(--mjn-ink);
	font-family: var(--mjn-body);
	font-size: 17px;
	line-height: 1.7;
	text-align: left;
	overflow-wrap: anywhere;
	-webkit-text-size-adjust: 100%;
	text-size-adjust: 100%;
}

#newton-mahjong *,
#newton-mahjong *::before,
#newton-mahjong *::after {
	box-sizing: border-box;
}

/*
 * Room for fourteen readable tiles.
 *
 * The theme puts the shortcode in a content column about 645 px wide and sets its own
 * left/right margins on it at wide sizes. A tile that can show the delivered artwork's
 * numeral and illustration needs ~58 px, so the game — and only the game — is centred on
 * the viewport above 900 px: its own offset does the centring, and the theme's margins
 * are zeroed because they would otherwise push the wider box off centre. Nothing outside
 * `#newton-mahjong` is restyled.
 */
@media (min-width: 900px) {
	#newton-mahjong {
		--mj-width: min(calc(100vw - 48px), 1180px);
		--mjn-shell: min(calc(100vw - 48px), 1480px);
		width: var(--mj-width);
		max-width: none;
		/* Centred with margins, not with a transform: a transformed ancestor would make
		 * every `position: fixed` drawer inside the game fixed to the game box instead
		 * of the viewport. */
		margin-left: calc((100% - var(--mj-width)) / 2) !important;
		margin-right: calc((100% - var(--mj-width)) / 2) !important;
		position: relative;
	}
}

#newton-mahjong h1,
#newton-mahjong h2,
#newton-mahjong h3,
#newton-mahjong h4,
#newton-mahjong p,
#newton-mahjong dl,
#newton-mahjong dd,
#newton-mahjong ul {
	margin: 0;
}

#newton-mahjong ul {
	padding: 0;
	list-style: none;
}

#newton-mahjong p {
	max-width: 70ch;
}

#newton-mahjong [hidden] {
	display: none !important;
}

#newton-mahjong :focus-visible {
	outline: 3px solid var(--mjn-focus);
	outline-offset: 3px;
	border-radius: 4px;
}

/* --- Masthead --------------------------------------------------------- */

#newton-mahjong .ntc-mj__masthead {
	display: flex;
	flex-wrap: wrap;
	gap: 14px 24px;
	align-items: flex-end;
	justify-content: space-between;
	padding-bottom: 14px;
	border-bottom: 1px solid var(--mjn-line);
}

#newton-mahjong .ntc-mj__eyebrow {
	font-size: 0.68rem;
	font-weight: 700;
	letter-spacing: 0.09em;
	text-transform: uppercase;
	color: var(--mjn-gold-deep);
}

#newton-mahjong .ntc-mj__title {
	margin-top: 4px;
	font-family: var(--mjn-display);
	font-size: clamp(1.6rem, 3.2vw, 2.2rem);
	font-weight: 400;
	line-height: 1.1;
	letter-spacing: -0.01em;
	color: var(--mjn-navy);
}

#newton-mahjong .ntc-mj__sub {
	margin-top: 4px;
	color: var(--mjn-muted);
	font-size: 0.95rem;
}

#newton-mahjong .ntc-mj__crumbs {
	display: flex;
	gap: 8px;
	align-items: center;
	font-size: 0.82rem;
}

#newton-mahjong .ntc-mj__crumb,
#newton-mahjong .ntc-mj__crumb-link {
	display: inline-flex;
	min-height: 34px;
	align-items: center;
	padding: 6px 12px;
	border: 1px solid var(--mjn-line);
	border-radius: 999px;
	background: var(--mjn-paper);
	color: var(--mjn-navy);
	font: inherit;
	font-size: 0.82rem;
	font-weight: 700;
	text-decoration: none;
	cursor: pointer;
}

#newton-mahjong .ntc-mj__crumb:hover,
#newton-mahjong .ntc-mj__crumb-link:hover {
	border-color: var(--mjn-gold);
	background: var(--mjn-cream);
	color: var(--mjn-navy);
}

/* --- Home ------------------------------------------------------------- */

#newton-mahjong .ntc-mj__home {
	padding-top: 20px;
}

#newton-mahjong .ntc-mj__group-title {
	font-family: var(--mjn-display);
	font-size: 1.15rem;
	font-weight: 400;
	color: var(--mjn-navy);
}

#newton-mahjong .ntc-mj__group-title--second {
	margin-top: 28px;
}

#newton-mahjong .ntc-mj__group-note {
	margin-top: 4px;
	color: var(--mjn-muted);
	font-size: 0.88rem;
}

#newton-mahjong .ntc-mj__mode-grid {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(min(210px, 100%), 1fr));
	gap: 16px;
	margin-top: 14px;
}

#newton-mahjong .ntc-mj__mode-card {
	display: flex;
	flex-direction: column;
	gap: 8px;
	padding: 20px;
	border: 1px solid var(--mjn-line);
	border-radius: var(--mjn-radius);
	background: var(--mjn-paper);
	box-shadow: 0 1px 2px rgba(21, 38, 58, 0.04);
}

#newton-mahjong .ntc-mj__mode-card--quiet {
	background: var(--mjn-cream);
}

#newton-mahjong .ntc-mj__mode-eyebrow {
	font-size: 0.66rem;
	font-weight: 700;
	letter-spacing: 0.09em;
	text-transform: uppercase;
	color: var(--mjn-muted);
}

#newton-mahjong .ntc-mj__mode-name {
	font-family: var(--mjn-display);
	font-size: 1.3rem;
	font-weight: 400;
	line-height: 1.15;
	color: var(--mjn-navy);
}

#newton-mahjong .ntc-mj__mode-text {
	color: var(--mjn-muted);
	font-size: 0.9rem;
	line-height: 1.55;
}

#newton-mahjong .ntc-mj__button {
	margin-top: auto;
	display: inline-flex;
	min-height: var(--mjn-target);
	align-items: center;
	justify-content: center;
	gap: 8px;
	padding: 10px 20px;
	border: 1px solid var(--mjn-navy);
	border-radius: 9px;
	background: var(--mjn-navy);
	color: #fff;
	font: inherit;
	font-size: 0.9rem;
	font-weight: 700;
	text-align: center;
	cursor: pointer;
	transition: background-color 200ms var(--mjn-ease), border-color 200ms var(--mjn-ease);
}

#newton-mahjong .ntc-mj__button:hover:not(:disabled),
#newton-mahjong .ntc-mj__button:focus-visible:not(:disabled) {
	background: var(--mjn-navy-soft);
	border-color: var(--mjn-navy-soft);
	color: #fff;
}

#newton-mahjong .ntc-mj__button--quiet {
	background: var(--mjn-paper);
	border-color: var(--mjn-line);
	color: var(--mjn-navy);
}

#newton-mahjong .ntc-mj__button--quiet:hover:not(:disabled) {
	background: var(--mjn-cream);
	border-color: var(--mjn-gold);
	color: var(--mjn-navy);
}

#newton-mahjong .ntc-mj__button--disabled,
#newton-mahjong .ntc-mj__button:disabled {
	background: rgba(21, 38, 58, 0.04);
	border-color: var(--mjn-line);
	color: var(--mjn-muted);
	cursor: not-allowed;
}

#newton-mahjong .ntc-mj__button-meta {
	display: block;
	font-size: 0.74rem;
	font-weight: 400;
	opacity: 0.85;
}

#newton-mahjong .ntc-mj__soon {
	display: grid;
	gap: 6px;
	margin-top: 6px;
	font-size: 0.85rem;
	color: var(--mjn-muted);
}

#newton-mahjong .ntc-mj__soon li {
	display: flex;
	justify-content: space-between;
	gap: 10px;
	padding: 6px 0;
	border-top: 1px solid var(--mjn-line);
}

#newton-mahjong .ntc-mj__soon em {
	font-style: normal;
	font-weight: 700;
	color: var(--mjn-gold-deep);
	white-space: nowrap;
}

/* Saved games */

#newton-mahjong .ntc-mj__continue {
	margin-top: 20px;
	padding: 16px 18px;
	border: 1px solid var(--mjn-line);
	border-radius: var(--mjn-radius);
	background: var(--mjn-cream);
}

#newton-mahjong .ntc-mj__continue-title {
	font-size: 0.7rem;
	font-weight: 700;
	letter-spacing: 0.09em;
	text-transform: uppercase;
	color: var(--mjn-muted);
}

#newton-mahjong .ntc-mj__continue-list {
	display: grid;
	gap: 8px;
	margin-top: 10px;
}

#newton-mahjong .ntc-mj__continue-button {
	display: flex;
	width: 100%;
	min-height: var(--mjn-target);
	flex-wrap: wrap;
	gap: 4px 12px;
	align-items: baseline;
	justify-content: space-between;
	padding: 10px 14px;
	border: 1px solid var(--mjn-line);
	border-radius: 9px;
	background: var(--mjn-paper);
	color: var(--mjn-navy);
	font: inherit;
	text-align: left;
	cursor: pointer;
}

#newton-mahjong .ntc-mj__continue-button:hover,
#newton-mahjong .ntc-mj__continue-button:focus-visible {
	border-color: var(--mjn-gold);
	background: #fffdf7;
}

#newton-mahjong .ntc-mj__continue-name {
	font-weight: 700;
	font-size: 0.92rem;
}

#newton-mahjong .ntc-mj__continue-meta {
	font-size: 0.8rem;
	color: var(--mjn-muted);
}

/* An explicit verb: the row has to look like an action, not a status line. */
#newton-mahjong .ntc-mj__continue-action {
	margin-left: auto;
	padding: 3px 10px;
	border: 1px solid var(--mjn-navy);
	border-radius: 999px;
	font-size: 0.74rem;
	font-weight: 700;
	letter-spacing: 0.04em;
	text-transform: uppercase;
	color: var(--mjn-navy);
	white-space: nowrap;
}

#newton-mahjong .ntc-mj__continue-action::after {
	content: " \203A";
}

#newton-mahjong .ntc-mj__continue-empty {
	margin-top: 8px;
	font-size: 0.88rem;
	color: var(--mjn-muted);
}

/* Tile collections: one row per collection, with artwork thumbnail. */
#newton-mahjong .ntc-mj__packs {
	margin-top: 18px;
	padding: 16px 18px;
	border: 1px solid var(--mjn-line);
	border-radius: var(--mjn-radius);
	background: var(--mjn-cream);
}

#newton-mahjong .ntc-mj__pack-list {
	display: grid;
	gap: 8px;
	margin-top: 10px;
}

#newton-mahjong .ntc-mj__pack {
	display: flex;
	flex-wrap: wrap;
	gap: 10px 14px;
	align-items: center;
	padding: 8px 10px;
	border: 1px solid var(--mjn-line);
	border-radius: 10px;
	background: var(--mjn-paper);
}

#newton-mahjong .ntc-mj__pack-thumb {
	display: inline-flex;
	width: 44px;
	height: 44px;
	flex: 0 0 44px;
	align-items: center;
	justify-content: center;
	border-radius: 7px;
	border: 1px solid var(--mjn-line);
	background:
		linear-gradient(180deg, #fffef9, #ece2ca);
	font-size: 1.3rem;
	color: var(--mjn-navy);
	object-fit: cover;
	overflow: hidden;
}

#newton-mahjong .ntc-mj__pack-body {
	display: grid;
	gap: 2px;
	min-width: 0;
	flex: 1 1 220px;
}

#newton-mahjong .ntc-mj__pack-name {
	font-weight: 700;
	font-size: 0.92rem;
	color: var(--mjn-navy);
}

#newton-mahjong .ntc-mj__pack-name em {
	margin-left: 8px;
	font-style: normal;
	font-weight: 400;
	font-size: 0.76rem;
	color: var(--mjn-muted);
}

#newton-mahjong .ntc-mj__pack-text {
	font-size: 0.84rem;
	color: var(--mjn-muted);
}

#newton-mahjong .ntc-mj__pack-status {
	font-size: 0.78rem;
	font-weight: 700;
	color: var(--mjn-gold-deep);
}

#newton-mahjong .ntc-mj__pack .ntc-mj__button {
	margin-top: 0;
}

/* Tile collection: one quiet line under the two play cards. */
#newton-mahjong .ntc-mj__collection {
	display: flex;
	flex-wrap: wrap;
	gap: 4px 10px;
	align-items: baseline;
	margin-top: 14px;
	padding: 12px 16px;
	border: 1px dashed var(--mjn-line);
	border-radius: 12px;
	font-size: 0.86rem;
	color: var(--mjn-muted);
}

#newton-mahjong .ntc-mj__collection-label {
	font-size: 0.66rem;
	font-weight: 700;
	letter-spacing: 0.09em;
	text-transform: uppercase;
	color: var(--mjn-gold-deep);
}

#newton-mahjong .ntc-mj__collection-body strong {
	color: var(--mjn-navy);
}

#newton-mahjong .ntc-mj__collection-note {
	color: var(--mjn-muted);
}

/* --- Board chrome ----------------------------------------------------- */

#newton-mahjong .ntc-mj__table {
	padding-top: 16px;
}

#newton-mahjong .ntc-mj__bar {
	display: flex;
	flex-wrap: wrap;
	gap: 10px 18px;
	align-items: center;
	justify-content: space-between;
}

#newton-mahjong .ntc-mj__bar-group {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
}

#newton-mahjong .ntc-mj__tool {
	display: inline-flex;
	min-height: 36px;
	align-items: center;
	justify-content: center;
	padding: 6px 12px;
	border: 1px solid var(--mjn-line);
	border-radius: 8px;
	background: var(--mjn-paper);
	color: var(--mjn-navy);
	font: inherit;
	font-size: 0.83rem;
	font-weight: 700;
	cursor: pointer;
}

#newton-mahjong .ntc-mj__tool:hover:not(:disabled),
#newton-mahjong .ntc-mj__tool:focus-visible:not(:disabled) {
	border-color: var(--mjn-gold);
	background: var(--mjn-cream);
}

#newton-mahjong .ntc-mj__tool:disabled {
	color: var(--mjn-muted);
	cursor: not-allowed;
}

/* The faces switch is a link so it works with JavaScript off; it must read as one of the
 * controls beside it, not as body copy. */
#newton-mahjong .ntc-mj__tool--link {
	text-decoration: none;
	border-style: dashed;
}

#newton-mahjong .ntc-mj__tool--link:hover,
#newton-mahjong .ntc-mj__tool--link:focus-visible {
	text-decoration: none;
}

#newton-mahjong .ntc-mj__status {
	color: var(--mjn-muted);
	font-size: 0.85rem;
}

#newton-mahjong .ntc-mj__feedback {
	min-height: 1.2em;
	margin-top: 10px;
	font-size: 0.9rem;
	font-weight: 700;
	color: var(--mjn-navy);
}

#newton-mahjong .ntc-mj__feedback.is-error {
	color: #8d2f22;
}

#newton-mahjong .ntc-mj__feedback.is-win {
	color: #226b46;
}

/* --- The felt table --------------------------------------------------- */

#newton-mahjong .ntc-mj__surface {
	position: relative;
	margin-top: 12px;
	padding: clamp(18px, 2.4vw, 30px) clamp(12px, 2vw, 26px);
	border: 1px solid var(--mjn-felt-edge);
	border-radius: 20px;
	background:
		radial-gradient(120% 90% at 50% 0%, rgba(255, 255, 255, 0.07), rgba(0, 0, 0, 0) 60%),
		radial-gradient(90% 70% at 50% 55%, rgba(0, 0, 0, 0) 45%, rgba(0, 0, 0, 0.28) 100%),
		repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.014) 0 2px, rgba(0, 0, 0, 0.012) 2px 4px),
		linear-gradient(160deg, var(--mjn-felt-1), var(--mjn-felt-2));
	box-shadow:
		inset 0 0 0 1px rgba(255, 255, 255, 0.05),
		inset 0 18px 40px rgba(0, 0, 0, 0.28),
		0 18px 40px rgba(15, 27, 24, 0.22);
}

#newton-mahjong .ntc-mj__viewport {
	position: relative;
	overflow: auto;
	max-height: min(74vh, 760px);
	padding: 4px;
	scrollbar-width: thin;
	scrollbar-color: rgba(202, 168, 94, 0.45) rgba(0, 0, 0, 0.2);
}

#newton-mahjong .ntc-mj__board-scroll {
	--tile: clamp(19px, calc((100cqi - 20px) / 15), 54px);
	/* Resolved here so a changed --tile also changes the units derived from it. JS sets
	 * --tile (the width) on this element, which keeps both units in step. */
	--tile-h: calc(var(--tile) * 4 / 3);
	--u: calc(var(--tile) / 2);
	--u-h: calc(var(--tile-h) / 2);
	--edge: clamp(2px, calc(var(--u) * 0.30), 7px);
	display: flex;
	justify-content: center;
	min-width: min-content;
	padding: 6px 2px 12px;
}

#newton-mahjong .ntc-mj__board {
	position: relative;
	width: calc(2 * var(--cols) * var(--u) + 18px);
	height: calc(2 * var(--rows) * var(--u-h) + 26px);
	flex: 0 0 auto;
}

#newton-mahjong .ntc-mj__brandline {
	margin-top: 10px;
	text-align: center;
	font-size: 0.68rem;
	letter-spacing: 0.14em;
	text-transform: uppercase;
	color: rgba(247, 243, 234, 0.42);
}

/* --- Tiles: 2.5D ----------------------------------------------------- */

#newton-mahjong .ntc-mj__tile {
	position: absolute;
	left: calc(var(--x) * var(--u) + 7px);
	top: calc((var(--y) * var(--u-h)) + 7px - var(--tile) * 0.045 - var(--z) * 1.8px);
	z-index: calc(var(--z) * 100 + var(--y) + 5);
	width: calc(2 * var(--u) - 2px);
	height: calc(2 * var(--u-h) - 2px);
	padding: 0;
	border: 0;
	border-radius: calc(var(--u) * 0.15);
	background:
		/* a bevel: bright top-left face rolling into a warmer lower-right */
		linear-gradient(152deg, #fffdf6 0%, #fbf6ea 46%, #f2e9d6 74%, #e9dec6 100%);
	color: var(--mjn-navy);
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	-webkit-tap-highlight-color: transparent;
	touch-action: manipulation;
	/* The side walls are painted as two hard-edged shadows, not a blur: that is what
	 * makes a ceramic tile look like it has a millimetre of body. */
	box-shadow:
		/* bevel highlight */ inset 0 1px 0 rgba(255, 255, 255, 0.98),
		inset 1px 0 0 rgba(255, 255, 255, 0.7),
		/* face rim: separates two touching tiles */ inset 0 0 0 1px rgba(21, 38, 58, 0.22),
		inset 0 -2px 3px rgba(21, 38, 58, 0.09),
		/* right extrusion */ var(--edge) calc(var(--edge) * 0.62) 0 #ab9466,
		/* bottom extrusion */ 0 var(--edge) 0 #c2b083,
		/* contact shadow */ calc(var(--edge) * 0.5) calc(var(--edge) * 1.7) calc(var(--edge) * 2.6) rgba(4, 16, 12, 0.55);
	transition:
		transform 130ms var(--mjn-ease),
		box-shadow 130ms var(--mjn-ease),
		opacity 150ms linear,
		filter 130ms linear;
}

/* A layer sits fractionally higher and lands a fraction lower, which is what reads
 * as elevation without moving the board's geometry. */
#newton-mahjong .ntc-mj__tile--layer1 { box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.98), inset 0 0 0 1px rgba(21, 38, 58, 0.22), inset 0 -2px 3px rgba(21, 38, 58, 0.1), var(--edge) calc(var(--edge) * 0.6) 0 #b39a6b, 0 calc(var(--edge) * 1.2) 0 #c7b68a, calc(var(--edge) * 0.5) calc(var(--edge) * 1.8) calc(var(--edge) * 2.8) rgba(4, 16, 12, 0.58); }
#newton-mahjong .ntc-mj__tile--layer2 { box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.98), inset 0 0 0 1px rgba(21, 38, 58, 0.18), inset 0 -2px 3px rgba(21, 38, 58, 0.11), var(--edge) calc(var(--edge) * 0.7) 0 #ac9265, 0 calc(var(--edge) * 1.45) 0 #c1ad7f, calc(var(--edge) * 0.6) calc(var(--edge) * 2.2) calc(var(--edge) * 3.2) rgba(4, 16, 12, 0.62); }
#newton-mahjong .ntc-mj__tile--layer3 { box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.98), inset 0 0 0 1px rgba(21, 38, 58, 0.2), inset 0 -2px 3px rgba(21, 38, 58, 0.12), var(--edge) calc(var(--edge) * 0.8) 0 #a68d60, 0 calc(var(--edge) * 1.7) 0 #bba677, calc(var(--edge) * 0.7) calc(var(--edge) * 2.5) calc(var(--edge) * 3.6) rgba(4, 16, 12, 0.66); }
#newton-mahjong .ntc-mj__tile--layer4 { box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.98), inset 0 0 0 1px rgba(21, 38, 58, 0.22), inset 0 -2px 3px rgba(21, 38, 58, 0.13), var(--edge) calc(var(--edge) * 0.9) 0 #9f8659, 0 calc(var(--edge) * 1.95) 0 #b39d6f, calc(var(--edge) * 0.95) calc(var(--edge) * 2.9) calc(var(--edge) * 4.2) rgba(4, 16, 12, 0.72); }

/* The crown is the one tile that must read as the top of the pile. */
#newton-mahjong .ntc-mj__tile--layer4.is-free::after {
	content: "";
	position: absolute;
	inset: -2px;
	border-radius: inherit;
	border: 1px solid rgba(202, 168, 94, 0.5);
	pointer-events: none;
}

#newton-mahjong .ntc-mj__tile:disabled,
#newton-mahjong .ntc-mj__tile.is-blocked {
	cursor: default;
	filter: brightness(0.965) saturate(0.95);
}

#newton-mahjong .ntc-mj__tile.is-free:hover,
#newton-mahjong .ntc-mj__tile.is-free:focus-visible {
	transform: translateY(-2px);
	z-index: 900;
}

#newton-mahjong .ntc-mj__tile.is-selected {
	transform: translateY(-3px);
	z-index: 901;
	box-shadow:
		inset 0 1px 0 rgba(255, 255, 255, 0.95),
		0 0 0 3px rgba(202, 168, 94, 0.85),
		var(--edge) calc(var(--edge) * 0.55) 0 #c9b992,
		0 calc(var(--edge) * 1.4) 0 #d3c5a4,
		calc(var(--edge) * 0.5) calc(var(--edge) * 2) calc(var(--edge) * 3) rgba(6, 20, 15, 0.55);
}

#newton-mahjong .ntc-mj__tile.is-hint {
	box-shadow:
		inset 0 1px 0 rgba(255, 255, 255, 0.95),
		0 0 0 3px rgba(97, 180, 206, 0.85),
		var(--edge) calc(var(--edge) * 0.55) 0 #c9b992,
		0 calc(var(--edge) * 1.2) 0 #d3c5a4,
		calc(var(--edge) * 0.5) calc(var(--edge) * 1.8) calc(var(--edge) * 2.8) rgba(6, 20, 15, 0.5);
}

#newton-mahjong .ntc-mj__tile.is-wrong {
	animation: ntc-mj-nudge 260ms ease-in-out;
}

#newton-mahjong .ntc-mj__tile.is-removing {
	opacity: 0;
	transform: translateY(-6px) scale(0.9);
	pointer-events: none;
}

@keyframes ntc-mj-nudge {
	0%, 100% { transform: translateX(0); }
	30% { transform: translateX(-2px); }
	70% { transform: translateX(2px); }
}

/* The artwork */

#newton-mahjong .ntc-mj__face {
	display: block;
	width: 100%;
	height: 100%;
	padding: 2% 3%;
	/* The face is a portrait rectangle now, so a suit glyph is sized by the smaller
	 * side and centred, which is how a real tile reads. */
	display: flex;
	align-items: center;
	justify-content: center;
}

#newton-mahjong .ntc-mj__art {
	display: block;
	width: 100%;
	height: 100%;
	overflow: visible;
}

/* The shipped deck faces are PNGs, drawn with the same box as the SVG artwork. */
#newton-mahjong img.ntc-mj__art {
	object-fit: contain;
	user-select: none;
	-webkit-user-drag: none;
}

/* Artwork collections: the image sits inside the same ivory tile, never instead
 * of it. Four physical tiles share one attachment, so the browser fetches one file. */
#newton-mahjong .ntc-mj__face--art {
	position: relative;
	padding: 5%;
	border-radius: calc(var(--u) * 0.1);
	background: #fffdf7;
	box-shadow: inset 0 0 0 1px rgba(21, 38, 58, 0.18);
	overflow: hidden;
}

#newton-mahjong .ntc-mj__img {
	display: block;
	width: 100%;
	height: 100%;
}

#newton-mahjong .ntc-mj__face--contain .ntc-mj__img {
	object-fit: contain;
}

#newton-mahjong .ntc-mj__face--cover .ntc-mj__img {
	object-fit: cover;
}

#newton-mahjong .ntc-mj__face--portrait .ntc-mj__img {
	object-fit: cover;
	object-position: 50% 12%;
}

#newton-mahjong .ntc-mj__art-tag {
	position: absolute;
	right: 4%;
	bottom: 3%;
	padding: 0 3px;
	border-radius: 3px;
	background: rgba(21, 38, 58, 0.72);
	color: #fff;
	font-size: calc(var(--u) * 0.42);
	line-height: 1.4;
}

/* --- Zoom ------------------------------------------------------------- */

#newton-mahjong .ntc-mj__bar-end {
	display: flex;
	flex-wrap: wrap;
	gap: 8px 14px;
	align-items: center;
	margin-left: auto;
}

/* The zoom strip sits above the felt, never over it: a control that covers tiles is
 * a control that hides a move. */
#newton-mahjong .ntc-mj__zoom {
	display: flex;
	gap: 3px;
	padding: 3px;
	border: 1px solid var(--mjn-line);
	border-radius: 999px;
	background: var(--mjn-paper);
}

#newton-mahjong .ntc-mj__zoom-button {
	min-width: 34px;
	min-height: 30px;
	padding: 2px 9px;
	border: 0;
	border-radius: 999px;
	background: transparent;
	color: var(--mjn-navy);
	font: inherit;
	font-size: 0.86rem;
	font-weight: 700;
	cursor: pointer;
}

#newton-mahjong .ntc-mj__zoom-button:hover,
#newton-mahjong .ntc-mj__zoom-button:focus-visible {
	background: var(--mjn-cream);
	color: var(--mjn-navy);
}


/* --- Intro animation controls ----------------------------------------- */

#newton-mahjong .ntc-mj__skip {
	position: absolute;
	top: 10px;
	left: 10px;
	z-index: 960;
	min-height: 30px;
	padding: 4px 12px;
	border: 1px solid rgba(202, 168, 94, 0.45);
	border-radius: 999px;
	background: rgba(10, 24, 21, 0.78);
	color: #f7f3ea;
	font: inherit;
	font-size: 0.78rem;
	font-weight: 700;
	cursor: pointer;
	backdrop-filter: blur(3px);
}

#newton-mahjong .ntc-mj__skip:hover,
#newton-mahjong .ntc-mj__skip:focus-visible {
	background: rgba(202, 168, 94, 0.9);
	color: #142823;
}

/* --- Result kicker ----------------------------------------------------- */

#newton-mahjong .ntc-mj__result-kicker {
	font-size: 0.68rem;
	font-weight: 700;
	letter-spacing: 0.09em;
	text-transform: uppercase;
	color: var(--mjn-gold-deep);
}

/* --- Results ---------------------------------------------------------- */

#newton-mahjong .ntc-mj__result {
	margin-top: 18px;
	padding: clamp(20px, 3vw, 30px);
	border: 1px solid var(--mjn-line);
	border-radius: var(--mjn-radius);
	background: var(--mjn-cream);
}

#newton-mahjong .ntc-mj__result-title {
	font-family: var(--mjn-display);
	font-size: clamp(1.4rem, 3vw, 1.9rem);
	font-weight: 400;
	color: var(--mjn-navy);
}

#newton-mahjong .ntc-mj__result-stats {
	display: flex;
	flex-wrap: wrap;
	gap: 12px 28px;
	margin-top: 14px;
}

#newton-mahjong .ntc-mj__result-stats dt {
	font-size: 0.68rem;
	font-weight: 700;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	color: var(--mjn-muted);
}

#newton-mahjong .ntc-mj__result-stats dd {
	font-family: var(--mjn-display);
	font-size: 1.5rem;
	color: var(--mjn-navy);
}

#newton-mahjong .ntc-mj__result-note {
	margin-top: 10px;
	font-size: 0.8rem;
	color: var(--mjn-muted);
}

#newton-mahjong .ntc-mj__result-actions {
	display: flex;
	flex-wrap: wrap;
	gap: 10px;
	margin-top: 18px;
}

#newton-mahjong .ntc-mj__result-actions .ntc-mj__button {
	margin-top: 0;
}

/* --- Help and privacy ------------------------------------------------- */

#newton-mahjong .ntc-mj__help {
	margin-top: 26px;
	padding: 14px 18px;
	border: 1px solid var(--mjn-line);
	border-radius: var(--mjn-radius);
	background: var(--mjn-paper);
}

#newton-mahjong .ntc-mj__help summary {
	cursor: pointer;
	font-weight: 700;
	color: var(--mjn-navy);
}

#newton-mahjong .ntc-mj__help-body p {
	margin: 10px 0 0;
	color: var(--mjn-muted);
	font-size: 0.92rem;
	line-height: 1.65;
}

#newton-mahjong .ntc-mj__help-body strong {
	color: var(--mjn-navy);
}

#newton-mahjong .ntc-mj__privacy {
	margin-top: 16px;
	color: var(--mjn-muted);
	font-size: 0.78rem;
}

/* --- Narrow screens --------------------------------------------------- */

@media (max-width: 720px) {
	#newton-mahjong {
		width: min(100% - 20px, 1180px);
		font-size: 16px;
	}

	#newton-mahjong .ntc-mj__board-scroll {
		/* Readability wins over fitting: the tiles keep a usable size and the
		 * viewport scrolls. The page itself never scrolls horizontally. */
		--tile: clamp(26px, calc((100cqi - 16px) / 15), 46px);
	}

	#newton-mahjong .ntc-mj__bar {
		gap: 8px;
	}

	#newton-mahjong .ntc-mj__bar-group {
		order: 2;
	}

	#newton-mahjong .ntc-mj__status {
		order: 1;
		width: 100%;
	}

	#newton-mahjong .ntc-mj__tool {
		flex: 1 1 auto;
		padding: 8px 10px;
	}

	#newton-mahjong .ntc-mj__viewport {
		max-height: 66vh;
	}

	#newton-mahjong .ntc-mj__surface {
		padding: 14px 8px 10px;
	}

	#newton-mahjong .ntc-mj__zoom {
		top: 6px;
		right: 6px;
	}
}

@media (max-width: 380px) {
	#newton-mahjong .ntc-mj__board-scroll {
		--tile: clamp(24px, calc((100cqi - 12px) / 15), 40px);
	}

	#newton-mahjong .ntc-mj__mode-card {
		padding: 16px;
	}
}

/* --- Preferences ------------------------------------------------------ */

@media (prefers-reduced-motion: reduce) {
	#newton-mahjong *,
	#newton-mahjong *::before,
	#newton-mahjong *::after {
		transition: none !important;
		animation: none !important;
		scroll-behavior: auto !important;
	}
}

@media (forced-colors: active) {
	#newton-mahjong .ntc-mj__tile,
	#newton-mahjong .ntc-mj__button,
	#newton-mahjong .ntc-mj__tool {
		background: Canvas;
		color: CanvasText;
		border: 1px solid CanvasText;
	}

	#newton-mahjong .ntc-mj__tile.is-selected {
		outline: 3px solid Highlight;
	}

	#newton-mahjong .ntc-mj__zoom-button {
		background: ButtonFace;
		color: ButtonText;
	}
}

/* --- American Mahjong table -------------------------------------------- */

/*
 * One size for a tile face. Hand tiles, discards, melds and the House Card chips all
 * read these, so the table scales in one place. They live on the panel, not on
 * `.ntc-am`, because the reference rail is a sibling of the table and has to inherit
 * the same size.
 */
#newton-mahjong .ntc-mj__panel--american {
	/* Gutter floor. The panel used to break out of the theme column with negative
	 * margins, which put its text hard against the page edge on a narrower column. */
	padding-inline: clamp(14px, 2.5vw, 26px);
	--am-tile: 58px;
	--am-tile-small: 38px;
	--am-back: 40px;
	/* The side seats are narrow and vertical. A smaller back there is what keeps the
	 * table near the reference's 2:1 proportions instead of growing a tall side column. */
	--am-back-side: 28px;
	--am-tile-ratio: 136 / 177;
	--am-felt: #143d30;
	--am-felt-deep: #0d2820;
	--am-wood: #6b4726;
	--am-wood-light: #8a5f34;

	/*
	 * The American surface needs a table and a reference rail side by side. It asks for
	 * the wide shell, but never at the cost of a gutter: when the theme column is the
	 * narrower of the two, the panel keeps that column and the rail moves under the
	 * table (see the max-width query below) rather than the text running to the edge.
	 */
	width: 100%;
	max-width: var(--mjn-shell, 100%);
	margin-inline: auto;
}

@media (max-width: 1100px) {
	#newton-mahjong .ntc-am__shell {
		grid-template-columns: minmax(0, 1fr);
	}
}

#newton-mahjong .ntc-am__shell {
	display: grid;
	grid-template-columns: minmax(0, 1fr) 288px;
	gap: 18px;
	align-items: start;
}

#newton-mahjong .ntc-am__main {
	min-width: 0;
}

/* --- Game heading ------------------------------------------------------ */

#newton-mahjong .ntc-am__heading {
	display: flex;
	flex-wrap: wrap;
	align-items: flex-end;
	justify-content: space-between;
	gap: 10px 18px;
	padding: 2px 2px 12px;
	margin-bottom: 12px;
	border-bottom: 1px solid var(--mjn-line);
}

#newton-mahjong .ntc-am__heading-title {
	margin: 2px 0 0;
	font-family: var(--mjn-display);
	font-size: 2.1rem;
	line-height: 1.05;
	font-weight: 700;
	color: var(--mjn-navy);
}

#newton-mahjong .ntc-am__heading-sub {
	margin: 5px 0 0;
	font-size: 0.9rem;
	color: var(--mjn-muted);
}

#newton-mahjong .ntc-am__card-button {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	min-height: 44px;
}

#newton-mahjong .ntc-am__card-icon {
	width: 18px;
	height: 18px;
	flex: 0 0 auto;
	color: var(--mjn-gold-deep);
}

/* --- Status strip ------------------------------------------------------ */

#newton-mahjong .ntc-am__status {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 8px 18px;
	min-height: 46px;
	padding: 8px 14px;
	border: 1px solid var(--mjn-line);
	border-radius: 10px;
	background: var(--mjn-paper);
	box-shadow: 0 1px 0 rgba(255, 255, 255, 0.7) inset;
	font-size: 0.8rem;
	color: var(--mjn-muted);
}

#newton-mahjong .ntc-am__status-main {
	display: flex;
	align-items: center;
	gap: 10px;
}

#newton-mahjong .ntc-am__phase {
	padding: 4px 10px;
	border-radius: 999px;
	background: var(--mjn-gold);
	color: #2a2313;
	font-size: 0.66rem;
	font-weight: 700;
	letter-spacing: 0.1em;
	text-transform: uppercase;
}

#newton-mahjong .ntc-am__round {
	font-size: 0.72rem;
	font-weight: 700;
	letter-spacing: 0.05em;
	text-transform: uppercase;
	color: var(--mjn-navy);
}

#newton-mahjong .ntc-am__status-meta {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 4px 16px;
}

#newton-mahjong .ntc-am__status-item {
	position: relative;
	font-variant-numeric: tabular-nums;
}

#newton-mahjong .ntc-am__status-item + .ntc-am__status-item {
	padding-left: 16px;
}

#newton-mahjong .ntc-am__status-item + .ntc-am__status-item::before {
	content: "";
	position: absolute;
	left: 0;
	top: 50%;
	width: 3px;
	height: 3px;
	margin-top: -1.5px;
	border-radius: 50%;
	background: currentColor;
	opacity: 0.45;
}

#newton-mahjong .ntc-am__status-seat {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	margin-left: auto;
	font-weight: 600;
	color: var(--mjn-navy);
}

#newton-mahjong .ntc-am__status-wind {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 22px;
	height: 22px;
	border: 1px solid var(--mjn-gold-dark, #a88742);
	border-radius: 5px;
	font-size: 0.64rem;
	font-weight: 700;
	color: var(--mjn-gold-deep);
	box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.6);
}

/* --- Felt and frame ---------------------------------------------------- */

#newton-mahjong .ntc-am {
	display: grid;
	gap: 12px;
	margin-top: 0;
}

#newton-mahjong .ntc-am__table {
	padding: 10px;
	border-radius: 18px;
	background: linear-gradient(158deg, #7d5530 0%, #5f4023 52%, #46301a 100%);
	box-shadow:
		inset 0 1px 0 rgba(255, 255, 255, 0.18),
		inset 0 -1px 0 rgba(0, 0, 0, 0.45),
		0 18px 38px rgba(12, 22, 17, 0.26);
}

#newton-mahjong .ntc-am__felt {
	position: relative;
	display: grid;
	grid-template-rows: auto minmax(250px, 1fr) auto;
	gap: 8px;
	min-height: 480px;
	padding: 14px;
	border-radius: 12px;
	background:
		radial-gradient(115% 130% at 50% -10%, #20503d 0%, #143d30 46%, #0d2820 100%);
	box-shadow:
		inset 0 0 0 1px rgba(202, 168, 94, 0.32),
		inset 0 16px 44px rgba(0, 0, 0, 0.34);
}

/* A felt has a nap. One very low-contrast hatch is enough: it should be felt at a
 * glance and never read as a pattern. */
#newton-mahjong .ntc-am__felt::before {
	content: "";
	position: absolute;
	inset: 0;
	border-radius: inherit;
	pointer-events: none;
	opacity: 0.5;
	background-image:
		repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.022) 0 1px, transparent 1px 3px),
		repeating-linear-gradient(-45deg, rgba(0, 0, 0, 0.05) 0 1px, transparent 1px 4px);
}

#newton-mahjong .ntc-am__middle {
	display: grid;
	grid-template-columns: minmax(115px, 145px) minmax(0, 1fr) minmax(115px, 145px);
	gap: 8px;
	min-height: 0;
}

/* --- Seats ------------------------------------------------------------- */

#newton-mahjong .ntc-am__seat {
	position: relative;
	display: grid;
	align-content: start;
	gap: 6px;
	min-width: 0;
	padding: 8px 10px;
	border: 1px solid rgba(202, 168, 94, 0.16);
	border-radius: 10px;
	background: rgba(6, 18, 14, 0.3);
}

#newton-mahjong .ntc-am__seat--top {
	justify-self: center;
	width: min(100%, 640px);
}

#newton-mahjong .ntc-am__seat.is-active {
	border-color: rgba(202, 168, 94, 0.8);
	box-shadow:
		0 0 0 1px rgba(202, 168, 94, 0.4),
		0 0 26px rgba(202, 168, 94, 0.16);
}

#newton-mahjong .ntc-am__seat-head {
	display: flex;
	align-items: center;
	gap: 8px;
	font-size: 0.78rem;
	color: #f2ecdd;
}

#newton-mahjong .ntc-am__wind {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 24px;
	height: 24px;
	flex: 0 0 auto;
	border-radius: 50%;
	background: rgba(202, 168, 94, 0.9);
	color: #142823;
	font-size: 0.72rem;
	font-weight: 700;
}

#newton-mahjong .ntc-am__seat.is-active .ntc-am__wind {
	background: var(--mjn-gold);
	box-shadow: 0 0 0 3px rgba(202, 168, 94, 0.22);
}

#newton-mahjong .ntc-am__name {
	font-weight: 600;
	letter-spacing: 0.01em;
}

#newton-mahjong .ntc-am__name-short {
	display: none;
}

#newton-mahjong .ntc-am__seat--mine .ntc-am__name {
	font-family: var(--mjn-display);
	font-size: 0.92rem;
	letter-spacing: 0;
}

#newton-mahjong .ntc-am__seat-tag {
	padding: 2px 7px;
	border: 1px solid rgba(202, 168, 94, 0.6);
	border-radius: 999px;
	font-size: 0.6rem;
	font-weight: 700;
	letter-spacing: 0.12em;
	text-transform: uppercase;
	color: #eedfba;
}

#newton-mahjong .ntc-am__dealer {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 18px;
	height: 18px;
	border: 1px solid rgba(202, 168, 94, 0.75);
	border-radius: 50%;
	font-size: 0.6rem;
	font-weight: 700;
	color: #eedfba;
}

#newton-mahjong .ntc-am__count {
	margin-left: auto;
	font-variant-numeric: tabular-nums;
	opacity: 0.72;
	white-space: nowrap;
}

/* --- Racks ------------------------------------------------------------- */

#newton-mahjong .ntc-am__rack,
#newton-mahjong .ntc-am__melds {
	display: flex;
	flex-wrap: wrap;
	gap: 3px;
	align-items: flex-end;
}

#newton-mahjong .ntc-am__melds {
	gap: 6px;
}

#newton-mahjong .ntc-am__meld {
	display: flex;
	gap: 2px;
	padding: 2px;
	border-radius: 6px;
	background: rgba(202, 168, 94, 0.16);
	box-shadow: inset 0 0 0 1px rgba(202, 168, 94, 0.2);
}

/* Side seats are narrow: four columns of small backs, four rows, no wider than the seat. */
#newton-mahjong .ntc-am__seat--left .ntc-am__rack--hidden,
#newton-mahjong .ntc-am__seat--right .ntc-am__rack--hidden {
	max-width: calc(var(--am-back-side, 28px) * 4 + 12px);
}

#newton-mahjong .ntc-am__seat--left .ntc-am__back,
#newton-mahjong .ntc-am__seat--right .ntc-am__back {
	width: var(--am-back-side, 28px);
}

#newton-mahjong .ntc-am__seat--top .ntc-am__rack--hidden {
	justify-content: center;
	max-width: 100%;
}

/* Side seats are narrow: the header puts the count on its own line instead of squeezing
 * the name into "Compu / ter 4". */
#newton-mahjong .ntc-am__seat--left .ntc-am__seat-head,
#newton-mahjong .ntc-am__seat--right .ntc-am__seat-head {
	flex-wrap: wrap;
}

#newton-mahjong .ntc-am__seat--left .ntc-am__name,
#newton-mahjong .ntc-am__seat--right .ntc-am__name {
	flex: 1 1 auto;
	min-width: 0;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

#newton-mahjong .ntc-am__seat--left .ntc-am__count,
#newton-mahjong .ntc-am__seat--right .ntc-am__count {
	flex: 0 0 100%;
	margin-left: 0;
	padding-left: 29px;
	font-size: 0.68rem;
	opacity: 0.6;
}

/* The human hand sits in a shallow wooden tray, which is the strongest single cue that
 * this is a table and not a dashboard. */
#newton-mahjong .ntc-am__seat--bottom {
	gap: 8px;
	padding: 10px 12px 12px;
	border: 1px solid rgba(202, 168, 94, 0.4);
	border-radius: 12px;
	background: linear-gradient(180deg, var(--am-wood-light) 0%, var(--am-wood) 38%, #4b3017 100%);
	box-shadow:
		inset 0 1px 0 rgba(255, 255, 255, 0.24),
		inset 0 -10px 20px rgba(0, 0, 0, 0.32),
		0 10px 22px rgba(6, 14, 10, 0.28);
}

#newton-mahjong .ntc-am__rack--mine {
	padding: 8px;
	border-radius: 8px;
	background: linear-gradient(180deg, rgba(18, 10, 4, 0.55), rgba(18, 10, 4, 0.28));
	box-shadow: inset 0 3px 9px rgba(0, 0, 0, 0.5);
	flex-wrap: nowrap;
	overflow-x: auto;
	overflow-y: hidden;
	scrollbar-width: thin;
	-webkit-overflow-scrolling: touch;
}

/* --- Tiles ------------------------------------------------------------- */

#newton-mahjong .ntc-am__tile {
	position: relative;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: var(--am-tile, 58px);
	height: auto;
	aspect-ratio: var(--am-tile-ratio, 136 / 177);
	padding: 0;
	border: 0;
	border-radius: 7px;
	background: linear-gradient(160deg, #fffdf6 0%, #f6efdf 70%, #ece1c8 100%);
	color: #16283a;
	box-shadow:
		inset 0 1px 0 rgba(255, 255, 255, 0.9),
		inset 0 0 0 1px rgba(21, 38, 58, 0.2),
		2px 3px 0 #c2b083,
		3px 5px 6px rgba(4, 16, 12, 0.45);
	font: inherit;
	cursor: default;
	overflow: hidden;
	transition: transform 140ms var(--mjn-ease), box-shadow 140ms var(--mjn-ease);
}

#newton-mahjong .ntc-am__tile--small {
	width: var(--am-tile-small, 38px);
	box-shadow:
		inset 0 0 0 1px rgba(21, 38, 58, 0.18),
		1px 2px 0 #c2b083;
}

#newton-mahjong .ntc-am__tile--pickable {
	cursor: pointer;
}

#newton-mahjong .ntc-am__tile--pickable:hover {
	transform: translateY(-2px);
}

#newton-mahjong .ntc-am__tile.is-selected {
	transform: translateY(-6px);
	box-shadow:
		0 0 0 2px var(--mjn-gold),
		0 0 0 4px rgba(20, 40, 32, 0.45),
		2px 6px 0 #c2b083,
		3px 9px 12px rgba(4, 16, 12, 0.5);
}

#newton-mahjong .ntc-am__rack--mine .ntc-am__tile.is-selected {
	z-index: 2;
}

#newton-mahjong .ntc-am__face {
	font-size: 0.9rem;
	font-weight: 700;
	line-height: 1;
}

/* The deck artwork fills the ivory tile. It arrives with a transparent ground, so the
 * tile's own gradient, edge and shadow stay visible around and behind it. */
#newton-mahjong .ntc-am__art {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: contain;
}

#newton-mahjong .ntc-am__face--c { color: #17324f; }
#newton-mahjong .ntc-am__face--b { color: #1f6b3a; }
#newton-mahjong .ntc-am__face--d { color: #9c2b2b; }
#newton-mahjong .ntc-am__face--honour { font-size: 1.1rem; color: #1d3a6b; }
#newton-mahjong .ntc-am__face--joker { font-size: 0.7rem; color: #8a5a12; }
#newton-mahjong .ntc-am__face--flower { font-size: 0.75rem; color: #6b3f7a; }

#newton-mahjong .ntc-am__back {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: var(--am-back, 40px);
	aspect-ratio: var(--am-tile-ratio, 136 / 177);
	border-radius: 5px;
	/* A tan ground, not a dark one: the wordmark is re-inked navy at import time, so the
	 * back reads as a printed tile rather than a logo floating on black. */
	background: linear-gradient(160deg, #f2e7cb 0%, #e4d5b1 62%, #d6c299 100%);
	box-shadow:
		inset 0 1px 0 rgba(255, 255, 255, 0.7),
		inset 0 0 0 1px rgba(21, 38, 58, 0.22),
		1px 2px 0 #b9a578,
		2px 4px 5px rgba(4, 16, 12, 0.4);
	overflow: hidden;
}

#newton-mahjong .ntc-am__back-art {
	display: block;
	width: 72%;
	height: 72%;
	object-fit: contain;
}

/* --- The discard area -------------------------------------------------- */

#newton-mahjong .ntc-am__centre {
	position: relative;
	display: grid;
	align-content: center;
	justify-items: center;
	gap: 10px;
	min-height: 230px;
	padding: 14px;
	border: 1px solid rgba(202, 168, 94, 0.34);
	border-radius: 10px;
	background:
		radial-gradient(85% 95% at 50% 40%, rgba(32, 80, 61, 0.6) 0%, rgba(9, 26, 20, 0.6) 100%);
	box-shadow:
		inset 0 0 0 1px rgba(0, 0, 0, 0.22),
		inset 0 0 44px rgba(0, 0, 0, 0.32);
	text-align: center;
}

#newton-mahjong .ntc-am__centre-title {
	margin: 0;
	font-size: 0.66rem;
	font-weight: 700;
	letter-spacing: 0.18em;
	text-transform: uppercase;
	color: rgba(247, 243, 234, 0.6);
}

#newton-mahjong .ntc-am__empty-state {
	display: grid;
	justify-items: center;
	gap: 10px;
	padding: 4px 0 8px;
}

#newton-mahjong .ntc-am__empty-text {
	max-width: 30ch;
	margin: 0;
	font-size: 0.82rem;
	line-height: 1.45;
	color: rgba(247, 243, 234, 0.62);
}

#newton-mahjong .ntc-am__compass {
	width: 116px;
	height: 116px;
	color: var(--mjn-gold);
	opacity: 0.32;
}

#newton-mahjong .ntc-am__centre.is-active {
	align-content: start;
	justify-items: stretch;
	text-align: left;
}

#newton-mahjong .ntc-am__last {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 12px;
}

#newton-mahjong .ntc-am__last-meta {
	display: grid;
	gap: 2px;
}

#newton-mahjong .ntc-am__label {
	font-size: 0.62rem;
	letter-spacing: 0.1em;
	text-transform: uppercase;
	color: rgba(247, 243, 234, 0.55);
}

#newton-mahjong .ntc-am__last-seat {
	font-size: 0.86rem;
	font-weight: 600;
	color: #f4eeE0;
}

#newton-mahjong .ntc-am__pool {
	display: flex;
	flex-wrap: wrap;
	gap: 2px;
	max-height: 190px;
	overflow-y: auto;
	padding-top: 4px;
	border-top: 1px dashed rgba(202, 168, 94, 0.18);
}

/* --- Contextual action panel ------------------------------------------- */

#newton-mahjong .ntc-am__controls {
	display: grid;
	grid-template-columns: 170px minmax(0, 1fr) auto;
	align-items: center;
	gap: 12px 18px;
	min-height: 76px;
	padding: 12px 16px;
	border: 1px solid var(--mjn-line);
	border-radius: 12px;
	background: var(--mjn-cream);
	box-shadow: 0 1px 0 rgba(255, 255, 255, 0.8) inset;
}

#newton-mahjong .ntc-am__selection {
	display: grid;
	gap: 2px;
	padding-right: 16px;
	border-right: 1px solid var(--mjn-line);
}

#newton-mahjong .ntc-am__selection-label {
	font-size: 0.6rem;
	font-weight: 700;
	letter-spacing: 0.14em;
	text-transform: uppercase;
	color: var(--mjn-muted);
}

#newton-mahjong .ntc-am__selection-value {
	font-size: 0.92rem;
	color: var(--mjn-navy);
	font-variant-numeric: tabular-nums;
}

#newton-mahjong .ntc-am__selection-value strong {
	font-size: 1.2rem;
	font-weight: 700;
}

#newton-mahjong .ntc-am__controls.is-complete .ntc-am__selection-value {
	color: #1c6b4a;
}

#newton-mahjong .ntc-am__instruction {
	min-width: 0;
}

#newton-mahjong .ntc-am__instruction-main {
	margin: 0;
	font-family: var(--mjn-display);
	font-size: 1.04rem;
	font-weight: 700;
	color: var(--mjn-navy);
}

#newton-mahjong .ntc-am__instruction-sub {
	margin: 2px 0 0;
	font-size: 0.8rem;
	color: var(--mjn-muted);
}

#newton-mahjong .ntc-am__actions {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: flex-end;
	gap: 8px;
}

#newton-mahjong .ntc-am__actions .ntc-mj__button {
	min-height: 44px;
}

#newton-mahjong .ntc-am__primary {
	border-color: #143d30;
	background: #143d30;
	color: #f7f3ea;
}

#newton-mahjong .ntc-am__primary:hover:not(:disabled),
#newton-mahjong .ntc-am__primary:focus-visible:not(:disabled) {
	border-color: #1c5541;
	background: #1c5541;
	color: #fffdf7;
}

#newton-mahjong .ntc-am__waiting {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	margin: 0;
	font-size: 0.84rem;
	color: var(--mjn-muted);
}

#newton-mahjong .ntc-am__pulse {
	width: 8px;
	height: 8px;
	border-radius: 50%;
	background: var(--mjn-gold-deep);
	animation: ntc-am-pulse 1.8s ease-in-out infinite;
}

@keyframes ntc-am-pulse {
	0%, 100% { opacity: 0.35; transform: scale(0.9); }
	50% { opacity: 1; transform: scale(1.1); }
}

#newton-mahjong .ntc-am__feedback {
	margin: 0;
	min-height: 1.2em;
	font-size: 0.82rem;
	color: var(--mjn-muted);
}

#newton-mahjong .ntc-am__feedback[data-kind="error"] {
	color: #a02525;
	font-weight: 700;
}

#newton-mahjong .ntc-am__result {
	margin-top: 4px;
	padding: 14px 16px;
	border: 1px solid var(--mjn-line);
	border-radius: 12px;
	background: var(--mjn-paper);
}

#newton-mahjong .ntc-am__result h3 {
	margin: 2px 0 6px;
	font-family: var(--mjn-display);
	font-size: 1.3rem;
	color: var(--mjn-navy);
}

#newton-mahjong .ntc-am__result p {
	margin: 0 0 6px;
	font-size: 0.88rem;
	color: var(--mjn-ink);
}

#newton-mahjong .ntc-am__result ul {
	margin: 0;
	font-size: 0.84rem;
	color: var(--mjn-muted);
}

/* --- House Card reference rail ----------------------------------------- */

#newton-mahjong .ntc-mj__house-rail {
	width: 288px;
	max-height: calc(100vh - 40px);
	padding: 16px;
	overflow-y: auto;
	overscroll-behavior: contain;
	scrollbar-width: thin;
	border: 1px solid var(--mjn-line);
	border-radius: 14px;
	background: var(--mjn-paper);
	box-shadow: 0 14px 34px rgba(16, 28, 22, 0.1);
	position: sticky;
	top: 20px;
}

#newton-mahjong .ntc-mj__house-head {
	display: flex;
	align-items: flex-start;
	gap: 10px;
	padding-bottom: 10px;
	border-bottom: 1px solid var(--mjn-line);
}

#newton-mahjong .ntc-mj__house-icon {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 34px;
	height: 34px;
	flex: 0 0 auto;
	border: 1px solid var(--mjn-line);
	border-radius: 9px;
	background: var(--mjn-cream);
	color: var(--mjn-gold-deep);
}

#newton-mahjong .ntc-mj__house-icon svg {
	width: 18px;
	height: 18px;
}

#newton-mahjong .ntc-mj__house-title-wrap {
	display: grid;
	gap: 1px;
	min-width: 0;
}

#newton-mahjong .ntc-mj__house-title {
	font-family: var(--mjn-display);
	font-size: 1.12rem;
	font-weight: 700;
	line-height: 1.2;
	color: var(--mjn-navy);
}

#newton-mahjong .ntc-mj__house-sub {
	font-size: 0.72rem;
	color: var(--mjn-muted);
}

#newton-mahjong .ntc-mj__house-close {
	display: none;
	align-items: center;
	justify-content: center;
	width: 36px;
	height: 36px;
	margin-left: auto;
	flex: 0 0 auto;
	border: 1px solid var(--mjn-line);
	border-radius: 9px;
	background: var(--mjn-cream);
	color: var(--mjn-navy);
	font-size: 1.2rem;
	line-height: 1;
	cursor: pointer;
}

#newton-mahjong .ntc-mj__house-note {
	margin: 10px 0 4px;
	font-size: 0.7rem;
	line-height: 1.4;
	color: var(--mjn-muted);
}

#newton-mahjong .ntc-mj__house-foot {
	margin: 12px 0 0;
	padding-top: 10px;
	border-top: 1px solid var(--mjn-line);
	font-size: 0.68rem;
	line-height: 1.4;
	color: var(--mjn-muted);
}

#newton-mahjong .ntc-mj__pattern {
	border-bottom: 1px solid var(--mjn-line);
}

#newton-mahjong .ntc-mj__pattern:last-child {
	border-bottom: 0;
}

#newton-mahjong .ntc-mj__pattern-summary {
	display: flex;
	align-items: center;
	gap: 8px;
	min-height: 40px;
	padding: 8px 2px;
	list-style: none;
	cursor: pointer;
	font-size: 0.84rem;
	color: var(--mjn-navy);
}

#newton-mahjong .ntc-mj__pattern-summary::-webkit-details-marker {
	display: none;
}

#newton-mahjong .ntc-mj__pattern-summary::after {
	content: "";
	width: 7px;
	height: 7px;
	margin-left: 2px;
	border-right: 1.6px solid var(--mjn-muted);
	border-bottom: 1.6px solid var(--mjn-muted);
	transform: rotate(-45deg);
	transition: transform 160ms var(--mjn-ease);
	flex: 0 0 auto;
}

#newton-mahjong .ntc-mj__pattern[open] > .ntc-mj__pattern-summary::after {
	transform: rotate(45deg) translateY(-2px);
}

#newton-mahjong .ntc-mj__pattern-no {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 20px;
	height: 20px;
	flex: 0 0 auto;
	border: 1px solid var(--mjn-line);
	border-radius: 50%;
	background: var(--mjn-cream);
	font-size: 0.66rem;
	font-weight: 700;
	color: var(--mjn-gold-deep);
}

#newton-mahjong .ntc-mj__pattern-name {
	font-weight: 600;
	line-height: 1.25;
}

#newton-mahjong .ntc-mj__pattern-value {
	margin-left: auto;
	font-weight: 700;
	font-variant-numeric: tabular-nums;
	white-space: nowrap;
}

#newton-mahjong .ntc-mj__pattern-pts {
	font-size: 0.66rem;
	font-weight: 400;
	color: var(--mjn-muted);
}

#newton-mahjong .ntc-mj__pattern-body {
	padding: 0 2px 12px;
}

#newton-mahjong .ntc-mj__pattern-groups {
	display: grid;
	gap: 7px;
	margin: 0 0 10px;
}

#newton-mahjong .ntc-mj__group {
	display: grid;
	gap: 4px;
	padding: 6px 8px;
	border-radius: 7px;
	background: var(--mjn-cream);
}

#newton-mahjong .ntc-mj__group-label {
	font-size: 0.76rem;
	line-height: 1.3;
	color: var(--mjn-ink);
}

#newton-mahjong .ntc-mj__group-tiles {
	display: flex;
	flex-wrap: wrap;
	gap: 2px;
}

#newton-mahjong .ntc-mj__chip {
	display: inline-flex;
	width: 24px;
	aspect-ratio: var(--am-tile-ratio, 136 / 177);
	border-radius: 3px;
	background: linear-gradient(160deg, #fffdf6 0%, #efe5cf 100%);
	box-shadow:
		inset 0 0 0 1px rgba(21, 38, 58, 0.2),
		1px 1px 0 #c2b083;
	overflow: hidden;
}

#newton-mahjong .ntc-mj__pattern-meta {
	display: grid;
	gap: 3px;
	margin: 0;
	padding-top: 8px;
	border-top: 1px dashed var(--mjn-line);
}

#newton-mahjong .ntc-mj__pattern-meta > div {
	display: flex;
	justify-content: space-between;
	gap: 10px;
	font-size: 0.74rem;
}

#newton-mahjong .ntc-mj__pattern-meta dt {
	color: var(--mjn-muted);
}

#newton-mahjong .ntc-mj__pattern-meta dd {
	margin: 0;
	font-weight: 600;
	text-align: right;
	color: var(--mjn-navy);
}

#newton-mahjong .ntc-mj__house-backdrop {
	display: none;
}

/* --- How to play and game tools ---------------------------------------- */

#newton-mahjong .ntc-am__tools {
	display: grid;
	grid-template-columns: minmax(0, 1fr) auto;
	gap: 16px 20px;
	margin-top: 14px;
	padding: 16px 18px;
	border: 1px solid var(--mjn-line);
	border-radius: 12px;
	background: linear-gradient(180deg, #f9f6ee 0%, #f1ece0 100%);
}

#newton-mahjong .ntc-am__tools-kicker {
	display: flex;
	align-items: center;
	gap: 8px;
	margin: 0 0 4px;
	font-family: var(--mjn-display);
	font-size: 1rem;
	font-weight: 700;
	color: var(--mjn-navy);
}

#newton-mahjong .ntc-am__tools-kicker svg {
	width: 18px;
	height: 18px;
	color: var(--mjn-gold-deep);
}

#newton-mahjong .ntc-am__tools-text {
	max-width: 54ch;
	margin: 0 0 8px;
	font-size: 0.82rem;
	line-height: 1.45;
	color: var(--mjn-muted);
}

#newton-mahjong .ntc-am__link {
	min-height: 32px;
	padding: 0;
	border: 0;
	background: none;
	font-size: 0.82rem;
	font-weight: 600;
	color: var(--mjn-navy);
	text-decoration: underline;
	text-underline-offset: 3px;
	cursor: pointer;
}

#newton-mahjong .ntc-am__tools-actions {
	padding-left: 20px;
	border-left: 1px solid var(--mjn-line);
}

#newton-mahjong .ntc-am__tools-buttons {
	display: flex;
	gap: 8px;
}

#newton-mahjong .ntc-am__tool {
	display: inline-flex;
	flex-direction: column;
	align-items: center;
	gap: 4px;
	min-width: 82px;
	min-height: 56px;
	padding: 8px 10px;
	border: 1px solid var(--mjn-line);
	border-radius: 9px;
	background: var(--mjn-paper);
	font-size: 0.7rem;
	color: var(--mjn-navy);
	cursor: pointer;
}

#newton-mahjong .ntc-am__tool:hover {
	border-color: var(--mjn-gold);
	background: var(--mjn-cream);
}

#newton-mahjong .ntc-am__tool svg {
	width: 18px;
	height: 18px;
	color: var(--mjn-gold-deep);
}

#newton-mahjong .ntc-am__help {
	margin-top: 14px;
	padding: 18px 20px;
	border: 1px solid var(--mjn-line);
	border-radius: 12px;
	background: var(--mjn-paper);
}

#newton-mahjong .ntc-am__help-title {
	margin: 0 0 10px;
	font-family: var(--mjn-display);
	font-size: 1.1rem;
	color: var(--mjn-navy);
}

#newton-mahjong .ntc-am__help p {
	max-width: 74ch;
	margin: 0 0 10px;
	font-size: 0.86rem;
	line-height: 1.55;
	color: var(--mjn-ink);
}

#newton-mahjong .ntc-am__help p:last-child {
	margin-bottom: 0;
}

/* --- Responsive -------------------------------------------------------- */

/* No room for a permanent reference column: the rail becomes a drawer and the table
 * keeps the whole shell. */
@media (max-width: 1279px) {
	#newton-mahjong .ntc-am__shell {
		grid-template-columns: minmax(0, 1fr);
	}

	#newton-mahjong .ntc-mj__house-rail {
		position: fixed;
		top: 0;
		right: 0;
		bottom: 0;
		left: auto;
		z-index: 80;
		width: min(360px, 90vw);
		max-height: none;
		height: 100%;
		border-radius: 14px 0 0 14px;
		box-shadow: -24px 0 60px rgba(8, 16, 12, 0.4);
		transform: translateX(103%);
		transition: transform 240ms var(--mjn-ease);
	}

	#newton-mahjong[data-house-open="true"] .ntc-mj__house-rail {
		transform: translateX(0);
	}

	#newton-mahjong .ntc-mj__house-close {
		display: inline-flex;
	}

	#newton-mahjong .ntc-mj__house-backdrop {
		display: block;
		position: fixed;
		inset: 0;
		z-index: 70;
		background: rgba(10, 20, 16, 0.45);
	}

	#newton-mahjong .ntc-mj__house-backdrop[hidden] {
		display: none;
	}
}

@media (max-width: 1100px) {
	#newton-mahjong .ntc-mj__panel--american {
		--am-tile: 52px;
		--am-tile-small: 34px;
		--am-back: 36px;
		--am-back-side: 26px;
	}

	#newton-mahjong .ntc-am__middle {
		grid-template-columns: minmax(104px, 130px) minmax(0, 1fr) minmax(104px, 130px);
	}
}

@media (max-width: 900px) {
	#newton-mahjong .ntc-am__controls {
		grid-template-columns: minmax(0, 1fr);
	}

	#newton-mahjong .ntc-am__selection {
		display: flex;
		align-items: baseline;
		gap: 8px;
		padding: 0 0 6px;
		border-right: 0;
		border-bottom: 1px solid var(--mjn-line);
	}

	#newton-mahjong .ntc-am__actions {
		justify-content: stretch;
	}

	#newton-mahjong .ntc-am__actions .ntc-mj__button {
		flex: 1 1 auto;
	}

	#newton-mahjong .ntc-am__tools {
		grid-template-columns: minmax(0, 1fr);
	}

	#newton-mahjong .ntc-am__tools-actions {
		padding: 12px 0 0;
		border-left: 0;
		border-top: 1px solid var(--mjn-line);
	}

	#newton-mahjong .ntc-am__tools-buttons .ntc-am__tool {
		flex: 1 1 0;
	}
}

/* The phone keeps the four-seat geometry: two narrow opponent columns, the discard area
 * between them, the hand across the bottom. Only the representatives of the concealed
 * racks shrink; the count in each seat header stays exact. */
@media (max-width: 700px) {
	#newton-mahjong .ntc-mj__panel--american {
		--am-tile: 46px;
		--am-tile-small: 30px;
		--am-back: 30px;
		--am-back-side: 24px;
	}

	#newton-mahjong .ntc-am__heading-title {
		font-size: 1.65rem;
	}

	#newton-mahjong .ntc-am__felt {
		grid-template-rows: auto minmax(220px, 1fr) auto;
		min-height: 0;
		padding: 8px;
		gap: 6px;
	}

	#newton-mahjong .ntc-am__table {
		padding: 7px;
		border-radius: 14px;
	}

	#newton-mahjong .ntc-am__middle {
		grid-template-columns: 64px minmax(0, 1fr) 64px;
		gap: 5px;
	}

	#newton-mahjong .ntc-am__seat {
		padding: 6px;
		gap: 4px;
	}

	#newton-mahjong .ntc-am__seat-head {
		gap: 5px;
		font-size: 0.68rem;
	}

	#newton-mahjong .ntc-am__wind {
		width: 20px;
		height: 20px;
		font-size: 0.62rem;
	}

	#newton-mahjong .ntc-am__seat--top {
		width: 100%;
	}

	/* A representative row of backs, not thirteen hairlines: the seat header carries the
	 * real count, and every back is still in the markup for a wider screen. */
	#newton-mahjong .ntc-am__seat--top .ntc-am__back:nth-child(n + 8) {
		display: none;
	}

	#newton-mahjong .ntc-am__seat--left .ntc-am__back:nth-child(n + 5),
	#newton-mahjong .ntc-am__seat--right .ntc-am__back:nth-child(n + 5) {
		display: none;
	}

	#newton-mahjong .ntc-am__seat--left .ntc-am__rack--hidden,
	#newton-mahjong .ntc-am__seat--right .ntc-am__rack--hidden {
		max-width: calc(var(--am-back-side) * 2 + 8px);
	}

	#newton-mahjong .ntc-am__seat-head .ntc-am__count {
		font-size: 0.6rem;
	}

	#newton-mahjong .ntc-am__seat-tag,
	#newton-mahjong .ntc-am__dealer {
		display: none;
	}

	/* A 64 px seat cannot hold "Computer 4": the short label takes over and the full
	 * name stays in the title and in the document. */
	#newton-mahjong .ntc-am__name-long {
		display: none;
	}

	#newton-mahjong .ntc-am__name-short {
		display: inline;
	}

	#newton-mahjong .ntc-am__seat--left .ntc-am__count,
	#newton-mahjong .ntc-am__seat--right .ntc-am__count {
		padding-left: 0;
	}

	#newton-mahjong .ntc-am__centre {
		min-height: 150px;
		padding: 10px 8px;
		gap: 6px;
	}

	#newton-mahjong .ntc-am__centre-title {
		font-size: 0.58rem;
		letter-spacing: 0.1em;
	}

	#newton-mahjong .ntc-am__empty-text {
		font-size: 0.68rem;
		line-height: 1.35;
	}

	#newton-mahjong .ntc-am__compass {
		width: 66px;
		height: 66px;
	}

	#newton-mahjong .ntc-am__last {
		gap: 8px;
		justify-content: flex-start;
	}

	#newton-mahjong .ntc-am__pool {
		max-height: 132px;
	}

	#newton-mahjong .ntc-am__controls {
		min-height: 0;
		padding: 10px 12px;
		gap: 8px;
	}

	#newton-mahjong .ntc-am__instruction-main {
		font-size: 0.98rem;
	}

	#newton-mahjong .ntc-am__instruction-sub {
		font-size: 0.76rem;
	}

	#newton-mahjong .ntc-am__rack--mine {
		flex-wrap: nowrap;
		scroll-snap-type: x proximity;
		padding-bottom: 8px;
	}

	#newton-mahjong .ntc-am__rack--mine .ntc-am__tile {
		flex: 0 0 auto;
		scroll-snap-align: start;
	}

	#newton-mahjong .ntc-am__tools {
		margin-top: 10px;
		padding: 12px;
	}

	#newton-mahjong .ntc-am__tools-text {
		display: none;
	}

	#newton-mahjong .ntc-am__help {
		padding: 14px;
	}
}

@media (max-width: 420px) {
	#newton-mahjong .ntc-mj__panel--american {
		--am-tile: 44px;
		--am-tile-small: 28px;
		--am-back: 26px;
		--am-back-side: 22px;
	}

	#newton-mahjong .ntc-am__heading-title {
		font-size: 1.5rem;
	}

	#newton-mahjong .ntc-am__middle {
		grid-template-columns: 58px minmax(0, 1fr) 58px;
	}

	#newton-mahjong .ntc-am__seat-head .ntc-am__name {
		max-width: 46px;
		overflow: hidden;
		text-overflow: ellipsis;
		white-space: nowrap;
	}

	#newton-mahjong .ntc-am__seat--left .ntc-am__back:nth-child(n + 3),
	#newton-mahjong .ntc-am__seat--right .ntc-am__back:nth-child(n + 3) {
		display: none;
	}

	#newton-mahjong .ntc-am__seat--left .ntc-am__rack--hidden,
	#newton-mahjong .ntc-am__seat--right .ntc-am__rack--hidden {
		max-width: calc(var(--am-back-side) + 6px);
	}
}

@media (prefers-reduced-motion: reduce) {
	#newton-mahjong .ntc-am__tile,
	#newton-mahjong .ntc-mj__pattern-summary::after,
	#newton-mahjong .ntc-mj__house-rail {
		transition: none;
	}

	#newton-mahjong .ntc-am__pulse {
		animation: none;
		opacity: 0.8;
	}
}

/* --- Page framing ------------------------------------------------------
 * The magazine template leaves a 70 px band above the page content and another
 * below the page title. On the game page the game IS the content, so those are
 * reduced here — and only here: every rule is scoped to the body class the
 * plugin adds for this page, so no article, archive or other page changes.
 *
 * These selectors are the block theme's. An Elementor template on the live
 * site will not match them; the live page template needs its own top spacing
 * removed (see docs/changes/2026-11-10-mahjong-v013.md).
 */
body.ntc-mahjong-page .wp-site-blocks > main.wp-block-group {
	margin-top: 0;
	padding-top: 20px;
}

body.ntc-mahjong-page .wp-block-post-title {
	margin-block: 0 6px;
}

body.ntc-mahjong-page #newton-mahjong {
	margin-top: 10px;
}

/* The newest discard is the only tile in the area with a brass ring and a label;
 * the pool beneath it stays small and unringed so the two never read alike. */
#newton-mahjong .ntc-am__last {
	padding: 8px;
	border: 1px solid rgba(202, 168, 94, 0.55);
	border-radius: 9px;
	background: rgba(202, 168, 94, 0.08);
}

#newton-mahjong .ntc-am__last .ntc-am__tile {
	box-shadow:
		0 0 0 2px rgba(202, 168, 94, 0.55),
		inset 0 1px 0 rgba(255, 255, 255, 0.9),
		inset 0 0 0 1px rgba(21, 38, 58, 0.2),
		2px 3px 0 #c2b083,
		3px 6px 8px rgba(4, 16, 12, 0.5);
}

/* --- Private-table lobby -------------------------------------------- */
#newton-mahjong .ntc-mj__room {
	margin-top: 14px;
	padding-top: 12px;
	border-top: 1px solid rgba(21, 38, 58, 0.12);
}

#newton-mahjong .ntc-mj__room-title {
	margin: 0 0 8px;
	font: 600 13px/1.3 var(--mjn-sans, system-ui, -apple-system, sans-serif);
	letter-spacing: 0.02em;
	color: var(--mjn-ink, #20352e);
}

#newton-mahjong .ntc-mj__room-row {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	align-items: center;
	margin-bottom: 8px;
}

#newton-mahjong .ntc-mj__room-row label {
	min-width: 74px;
	font-size: 12.5px;
	color: var(--mjn-muted, #5c6862);
}

#newton-mahjong .ntc-mj__room-row select,
#newton-mahjong .ntc-mj__room-row input {
	padding: 7px 9px;
	border: 1px solid rgba(21, 38, 58, 0.18);
	border-radius: 8px;
	background: var(--mjn-paper, #fffdf7);
	color: var(--mjn-navy, #15263a);
	font: inherit;
	font-size: 13px;
}

#newton-mahjong .ntc-mj__room-row input {
	flex: 1 1 190px;
	min-width: 150px;
	letter-spacing: 0.04em;
}

#newton-mahjong .ntc-mj__room-note {
	margin: 0;
	font-size: 12.5px;
	line-height: 1.4;
	color: var(--mjn-muted, #5c6862);
	overflow-wrap: anywhere;
}

#newton-mahjong .ntc-mj__room-note[data-kind="error"] {
	color: #8c2f2f;
}

/* The claim countdown is metadata, not an alarm. */
#newton-mahjong .ntc-am__countdown {
	font-variant-numeric: tabular-nums;
	font-weight: 600;
	color: var(--mjn-gold-dark, #a88742);
}

/* Room lobby ---------------------------------------------------------- */

#newton-mahjong .ntc-mj__roster {
	display: grid;
	gap: 6px;
	margin: 14px 0;
	padding: 0;
	list-style: none;
}

#newton-mahjong .ntc-mj__roster-row {
	display: flex;
	align-items: baseline;
	justify-content: space-between;
	gap: 12px;
	padding: 8px 12px;
	border: 1px dashed var(--mjn-line);
	border-radius: 8px;
	background: var(--mjn-paper);
	color: var(--mjn-muted);
	font-size: 0.9rem;
}

#newton-mahjong .ntc-mj__roster-row.is-taken {
	border-style: solid;
	color: var(--mjn-navy);
	font-weight: 700;
}

#newton-mahjong .ntc-mj__roster-seat {
	font-size: 0.78rem;
	font-weight: 700;
	letter-spacing: 0.04em;
	text-transform: uppercase;
	color: var(--mjn-muted);
}

#newton-mahjong .ntc-mj__lobby {
	max-width: 720px;
}

#newton-mahjong .ntc-mj__invite {
	margin-top: 18px;
	padding-top: 14px;
	border-top: 1px solid var(--mjn-line);
}

#newton-mahjong .ntc-mj__invite input[readonly] {
	flex: 1 1 320px;
	font-size: 0.85rem;
}

/* A [hidden] element that a theme rule gives a display value to stays visible;
   restate it for the parts of the game that are hidden per view. */
#newton-mahjong .ntc-mj__masthead[hidden],
#newton-mahjong .ntc-mj__help[hidden],
#newton-mahjong [data-panel][hidden] {
	display: none !important;
}

/* The tile-design switch: two links that must read as one choice. */
#newton-mahjong .ntc-mj__tile-style {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 8px;
	margin: 14px 0 0;
	font-size: 0.9rem;
}

#newton-mahjong .ntc-mj__tile-style-label {
	font-weight: 700;
	letter-spacing: 0.04em;
	text-transform: uppercase;
	font-size: 0.75rem;
	color: var(--mjn-muted);
}

#newton-mahjong a.ntc-mj__face-option {
	display: inline-flex;
	align-items: center;
	min-height: 36px;
	padding: 4px 14px;
	border: 1px solid var(--mjn-line);
	border-radius: 999px;
	background: var(--mjn-paper);
	color: var(--mjn-navy);
	text-decoration: none;
	font-size: 0.85rem;
	font-weight: 700;
	white-space: nowrap;
}

#newton-mahjong a.ntc-mj__face-option.is-current {
	border-color: var(--mjn-gold);
	background: var(--mjn-cream);
}

#newton-mahjong .ntc-mj__tile-style-note {
	color: var(--mjn-muted);
	font-size: 0.8rem;
}

#newton-mahjong .ntc-mj__section {
	margin: 28px 0;
}

#newton-mahjong .ntc-mj__section-head {
	margin-bottom: 14px;
}
