:root {
	/* Palette (existing colors) */
	--bg: #0a192f;
	--bg-2: #112240;
	--panel: #0f253a;
	--panel-2: #071428;
	--text: #e6f1ff;
	--muted: #cfeef0;
	--accent: #64ffda;

	/* Hero palette (keeps your existing theme, adds a modern gradient) */
	--hero-a: #6d28d9;
	--hero-b: #2563eb;
	--hero-c: #22c55e;
	--glass: rgba(255, 255, 255, 0.10);
	--glass-2: rgba(255, 255, 255, 0.14);
	--glass-border: rgba(255, 255, 255, 0.16);
	--ring: rgba(255, 255, 255, 0.22);

	/* Responsive sizing */
	--tile: 44px;
	--grid-cell: 52px;
	--grid-gap: 6px;

	/* Radii / shadows (reused existing values) */
	--r-sm: 6px;
	--r-md: 10px;
	--r-lg: 12px;
	--shadow-lg: 0 10px 30px rgba(0,0,0,0.6);
	--shadow-lg-2: 0 10px 30px rgba(0,0,0,0.7);
}

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

body {
	background-color: var(--bg);
	background-image: linear-gradient(180deg, var(--bg) 0%, var(--bg-2) 120%);
	color: var(--text);
	font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
	line-height: 1.45;
	margin: 0;
}

/* Intro page: fill viewport so no empty bottom area */
body.page-intro {
	min-height: 100vh;
	display: flex;
	flex-direction: column;
	background:
		radial-gradient(900px 450px at 12% 35%, rgba(109, 40, 217, 0.55), transparent 60%),
		radial-gradient(700px 380px at 78% 30%, rgba(37, 99, 235, 0.55), transparent 55%),
		radial-gradient(520px 420px at 78% 82%, rgba(34, 197, 94, 0.38), transparent 55%),
		linear-gradient(110deg, rgba(16, 24, 64, 0.95), rgba(10, 25, 47, 0.90));
}

/* Game page: match intro background + remove bottom empty space */
body.page-game {
	min-height: 100vh;
	display: flex;
	flex-direction: column;
	background:
		radial-gradient(900px 450px at 12% 35%, rgba(109, 40, 217, 0.40), transparent 60%),
		radial-gradient(700px 380px at 78% 30%, rgba(37, 99, 235, 0.40), transparent 55%),
		radial-gradient(520px 420px at 78% 82%, rgba(34, 197, 94, 0.26), transparent 55%),
		linear-gradient(110deg, rgba(16, 24, 64, 0.92), rgba(10, 25, 47, 0.90));
}

body.page-game .site-main {
	flex: 1;
}

body.page-game .site-footer {
	margin-top: auto;
}

body.page-intro .site-hero {
	flex: 1;
	padding-bottom: 40px;
}

body.page-intro .site-footer {
	margin-top: auto;
}

/* --- Modern hero + nav (reference-like look) --- */
.site-hero {
	position: relative;
	overflow: hidden;
	padding: 18px 0 110px;
	background:
		radial-gradient(900px 450px at 12% 35%, rgba(109, 40, 217, 0.55), transparent 60%),
		radial-gradient(700px 380px at 78% 30%, rgba(37, 99, 235, 0.55), transparent 55%),
		radial-gradient(520px 420px at 78% 82%, rgba(34, 197, 94, 0.38), transparent 55%),
		linear-gradient(110deg, rgba(16, 24, 64, 0.95), rgba(10, 25, 47, 0.90));
}

.site-hero::after {
	content: "";
	position: absolute;
	left: -8vw;
	right: -8vw;
	bottom: -1px;
	height: 120px;
	background: linear-gradient(180deg, rgba(10, 25, 47, 0) 0%, rgba(10, 25, 47, 0.85) 45%, rgba(10, 25, 47, 1) 100%);
	transform: skewY(-7deg);
	transform-origin: bottom left;
}

/* Intro mobile layout */
@media (max-width: 640px) {
	body.page-intro .hero-inner {
		padding: 0 14px;
	}

	body.page-intro .site-hero {
		padding: 14px 0 64px;
	}

	body.page-intro .top-nav {
		border-radius: 22px;
		padding: 10px 12px;
		gap: 10px;
		flex-wrap: wrap;
	}

	body.page-intro .brand {
		min-width: 0;
		flex: 1 1 auto;
	}

	body.page-intro .brand-text {
		font-size: 14px;
	}

	body.page-intro .pill--status {
		display: none;
	}

	body.page-intro .nav-actions {
		width: 100%;
		justify-content: flex-end;
	}

	body.page-intro .hero-grid {
		grid-template-columns: 1fr;
		padding: 26px 0 0;
		gap: 16px;
	}

	body.page-intro .hero-title {
		font-size: 40px;
	}

	body.page-intro .hero-subtitle {
		font-size: 15px;
		margin-bottom: 18px;
	}

	body.page-intro .hero-ctas {
		gap: 10px;
	}

	body.page-intro .cta {
		width: 100%;
	}

	body.page-intro .hero-art {
		min-height: 180px;
		opacity: 0.92;
	}

	body.page-intro .ring--1 {
		width: 190px;
		height: 190px;
		top: 18px;
		right: 10px;
	}

	body.page-intro .ring--2 {
		display: none;
	}

	body.page-intro .orb--1 {
		left: 16px;
		top: 20px;
		width: 52px;
		height: 52px;
	}

	body.page-intro .orb--2 {
		left: auto;
		right: 18px;
		bottom: 26px;
	}

	body.page-intro .sticks {
		right: 12px;
		bottom: 18px;
		transform: rotate(-10deg);
	}

	body.page-intro .stick {
		width: 56px;
		height: 5px;
	}

	body.page-intro .intro-ownership {
		width: 100%;
		justify-content: center;
	}

	body.page-intro .site-footer {
		margin: 10px auto 14px;
		padding: 10px 14px;
	}
}

@media (max-width: 380px) {
	body.page-intro .hero-title {
		font-size: 34px;
	}
}

.hero-inner {
	max-width: 1400px;
	width: min(96vw, 1400px);
	margin: 0 auto;
	padding: 0 28px;
	position: relative;
	z-index: 1;
}

.top-nav {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 16px;
	padding: 10px 12px;
	border-radius: 999px;
	border: 1px solid var(--glass-border);
	background: rgba(255, 255, 255, 0.06);
	backdrop-filter: blur(10px);
}

.brand {
	display: inline-flex;
	align-items: center;
	gap: 10px;
	min-width: 200px;
}

.brand-mark {
	width: 28px;
	height: 28px;
	border-radius: 10px;
	background: linear-gradient(135deg, rgba(100, 255, 218, 0.95), rgba(37, 99, 235, 0.95));
	box-shadow: 0 12px 30px rgba(0, 0, 0, 0.35);
	position: relative;
	overflow: hidden;
	display: grid;
	place-items: center;
	border: 1px solid rgba(255, 255, 255, 0.18);
}

/* Custom logo mark (license-safe, generated in CSS) */
.brand-mark::before {
	content: "";
	position: absolute;
	inset: -30%;
	background:
		radial-gradient(circle at 35% 35%, rgba(255, 255, 255, 0.65), rgba(255, 255, 255, 0) 55%),
		radial-gradient(circle at 75% 75%, rgba(255, 255, 255, 0.35), rgba(255, 255, 255, 0) 60%);
	opacity: 0.75;
	transform: rotate(18deg);
}

.brand-mark::after {
	content: "P";
	position: relative;
	font-weight: 900;
	font-size: 15px;
	line-height: 1;
	letter-spacing: -0.04em;
	color: rgba(10, 25, 47, 0.92);
	text-shadow: 0 1px 0 rgba(255, 255, 255, 0.25);
}

.brand-text {
	font-weight: 800;
	letter-spacing: 0.2px;
}

.nav-actions {
	display: inline-flex;
	align-items: center;
	gap: 10px;
	flex-wrap: wrap;
	justify-content: flex-end;
}

.nav-link {
	color: rgba(230, 241, 255, 0.88);
	text-decoration: none;
	font-weight: 600;
	font-size: 14px;
	padding: 8px 10px;
	border-radius: 999px;
	border: 1px solid transparent;
	transition: background-color 180ms ease, border-color 180ms ease, transform 180ms ease;
}

.nav-link:hover {
	background: rgba(255, 255, 255, 0.08);
	border-color: rgba(255, 255, 255, 0.14);
	transform: translateY(-1px);
}

.pill {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	padding: 8px 12px;
	border-radius: 999px;
	font-size: 13px;
	font-weight: 700;
	text-decoration: none;
	border: 1px solid var(--glass-border);
	background: rgba(255, 255, 255, 0.08);
	color: rgba(230, 241, 255, 0.95);
}

.pill--status {
	padding: 6px 10px;
	font-size: 12px;
	border-color: rgba(34, 197, 94, 0.45);
	background: rgba(34, 197, 94, 0.10);
}

.pill--cta {
	border: none;
	background: linear-gradient(135deg, rgba(34, 197, 94, 0.92), rgba(100, 255, 218, 0.92));
	color: rgba(10, 25, 47, 0.95);
	box-shadow: 0 16px 36px rgba(0, 0, 0, 0.35);
}

.hero-grid {
	display: grid;
	grid-template-columns: 1.15fr 0.85fr;
	gap: 18px;
	align-items: center;
	padding: 52px 6px 0;
}

.hero-kicker {
	margin: 0 0 10px;
	font-weight: 700;
	letter-spacing: 0.22em;
	text-transform: uppercase;
	color: rgba(230, 241, 255, 0.80);
	font-size: 12px;
}

.hero-title {
	margin: 0 0 12px;
	font-size: clamp(34px, 4vw, 54px);
	line-height: 1.05;
	letter-spacing: -0.02em;
}

.hero-subtitle {
	margin: 0 0 22px;
	max-width: 56ch;
	color: rgba(230, 241, 255, 0.86);
	font-size: 16px;
}

.hero-ctas {
	display: flex;
	gap: 12px;
	flex-wrap: wrap;
}

.cta {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-height: 44px;
	padding: 10px 16px;
	border-radius: 999px;
	text-decoration: none;
	font-weight: 800;
	border: 1px solid transparent;
	transition: transform 180ms ease, filter 180ms ease, background-color 180ms ease, border-color 180ms ease;
}

.cta--primary {
	color: rgba(10, 25, 47, 0.95);
	background: linear-gradient(135deg, rgba(34, 197, 94, 0.95), rgba(100, 255, 218, 0.95));
	box-shadow: 0 18px 40px rgba(0, 0, 0, 0.35);
}

.cta--secondary {
	color: rgba(230, 241, 255, 0.92);
	background: rgba(255, 255, 255, 0.06);
	border-color: rgba(255, 255, 255, 0.16);
	backdrop-filter: blur(10px);
}

.cta:hover {
	transform: translateY(-1px);
	filter: brightness(1.05);
}

.hero-art {
	position: relative;
	min-height: 280px;
}

.ring {
	position: absolute;
	border-radius: 999px;
	border: 12px solid var(--ring);
	filter: blur(0.2px);
	opacity: 0.95;
}

.ring--1 {
	width: 220px;
	height: 220px;
	top: 12px;
	right: 36px;
	transform: rotate(18deg);
	border-color: rgba(255, 255, 255, 0.18);
}

.ring--2 {
	width: 130px;
	height: 130px;
	bottom: 26px;
	right: 140px;
	transform: rotate(-12deg);
	border-color: rgba(100, 255, 218, 0.22);
}

.orb {
	position: absolute;
	border-radius: 999px;
	filter: blur(0.1px);
	box-shadow: 0 18px 60px rgba(0, 0, 0, 0.35);
}

.orb--1 {
	width: 64px;
	height: 64px;
	top: 26px;
	left: 40px;
	background: radial-gradient(circle at 30% 30%, rgba(255, 255, 255, 0.90), rgba(37, 99, 235, 0.90));
}

.orb--2 {
	width: 44px;
	height: 44px;
	bottom: 46px;
	left: 120px;
	background: radial-gradient(circle at 30% 30%, rgba(255, 255, 255, 0.86), rgba(34, 197, 94, 0.92));
}

.sticks {
	position: absolute;
	bottom: 38px;
	right: 42px;
	display: flex;
	gap: 10px;
	transform: rotate(-14deg);
}

.stick {
	display: inline-block;
	width: 72px;
	height: 6px;
	border-radius: 999px;
	opacity: 0.92;
}

.stick--1 { background: rgba(56, 189, 248, 0.85); }
.stick--2 { background: rgba(168, 85, 247, 0.85); }
.stick--3 { background: rgba(34, 197, 94, 0.85); }

.site-main {
	position: relative;
	margin-top: 0;
}

/* The intro hero can overlap its own next section (not used on game page). */
.page-intro .site-main {
	margin-top: -72px;
}

/* Touch devices: avoid sticky hover zoom */
@media (hover: none) and (pointer: coarse) {
	.element-box:hover {
		transform: none;
		background-color: #f0f0f05e;
	}
	.element-box {
		touch-action: none;
	}
	.button:hover {
		transform: none;
	}
}

.game-header {
	display: flex;
	justify-content: space-between;
	align-items: center;
	gap: 20px;
	margin-bottom: 20px;
	padding: 12px 14px;
	border: 1px solid rgba(255, 255, 255, 0.16);
	border-radius: 22px;
	background: rgba(255, 255, 255, 0.06);
	backdrop-filter: blur(10px);
}

.header-left {
	display: flex;
	align-items: center;
	gap: 30px;
}

.header-right {
	justify-content: end;
	display: flex;
	align-items: center;
	gap: 8px;
	flex-wrap: wrap;
}

.game-title {
	font-size: 24px;
	font-weight: bold;
	color: var(--accent);
	letter-spacing: 0.2px;
}

.game-container {
	max-width: 1400px;
	width: min(96vw, 1400px);
	margin: 0 auto;
	padding: 22px 28px;
}

.elements-container {
	display: flex;
	flex-wrap: wrap;
	justify-content: center;
	align-items: center;
	gap: 6px;
	padding: 14px 10px;
	min-height: 50px;
	border: 1px solid rgba(255, 255, 255, 0.12);
	border-radius: 18px;
	background: rgba(255, 255, 255, 0.05);
}

.element-box {
	color: var(--text);
	width: var(--tile);
	height: var(--tile);
	border: 1px solid rgba(0, 0, 0, 0.35);
	padding: 3px;
	display: grid;
	grid-template-rows: 20% 40% 20% 20%;
	cursor: move;
	-webkit-user-select: none;
	-ms-user-select: none;
	user-select: none;
	background-color: #f0f0f05e;
	border-radius: var(--r-sm);
	transition: transform 150ms ease-in, background-color 150ms ease, border-color 150ms ease;
}

.element-box:hover {
	transform: scale(1.5);
	z-index: 1;
	background-color: #f0f0f0ab;
}

/* Prevent hover effect on placed elements */
.drop-zone .element-box:hover {
	transform: none;
	background: unset;
}

.element-box .atomic-number {
	font-size: 10px;
	text-align: left;
	align-self: start;
}

.element-box .symbol {
	font-size: 14px;
	font-weight: bold;
	text-align: center;
	align-self: center;
}

.element-box .name {
	font-size: 10px;
	text-align: center;
	align-self: center;
	text-overflow: ellipsis;
	overflow: hidden;
	white-space: nowrap;
}

.element-box:hover .name {
	/* Make the name readable on hover (previously shrank to 6px which was unintended). */
	font-size: 12px;
}

/* Responsive layout + scalable table sizing */
@media (max-width: 900px) {
	:root {
		--tile: 36px;
		--grid-cell: 40px;
		--grid-gap: 4px;
	}
	.game-header {
		flex-direction: column;
		align-items: stretch;
	}
	.header-left {
		flex-wrap: wrap;
		gap: 12px;
		justify-content: space-between;
	}
	.header-right {
		justify-content: flex-start;
	}
	.stats-container {
		flex-wrap: wrap;
		gap: 10px;
	}
	.game-container {
		padding: 16px 14px;
	}
	.periodic-table-container {
		padding: 8px;
	}
}

@media (max-width: 600px) {
	:root {
		--tile: 34px;
		--grid-cell: 38px;
		--grid-gap: 4px;
	}
	.game-title {
		font-size: 20px;
	}
	.button {
		padding: 10px 12px;
		font-size: 14px;
		min-height: 38px;
	}
	.score-display,
	.level-display,
	.timer-display {
		min-width: 92px;
		font-size: 15px;
		padding: 8px 10px;
	}
}

@media (max-width: 420px) {
	:root {
		--tile: 32px;
		--grid-cell: 36px;
		--grid-gap: 3px;
	}
}

.element-box .mass {
	font-size: 8px;
	text-align: center;
	align-self: center;
}

.element-box.dragging {
	opacity: 0.5;
}

.periodic-table-container {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 20px;
	padding: 10px;
	max-width: 100%;
	overflow-x: auto;
	-webkit-overflow-scrolling: touch;
	border: 1px solid rgba(255, 255, 255, 0.12);
	border-radius: 18px;
	background: rgba(255, 255, 255, 0.04);
}

.periodic-grid {
	display: grid;
	grid-template-columns: repeat(18, var(--grid-cell));
	gap: var(--grid-gap);
	width: max-content;
}

.drop-zone {
	width: calc(var(--grid-cell) - 2px);
	height: calc(var(--grid-cell) - 2px);
	border: 1px dashed rgba(230, 241, 255, 0.30);
	display: flex;
	align-items: center;
	justify-content: center;
	opacity: 1;
	border-radius: var(--r-sm);
	background-color: rgba(255, 255, 255, 0.035);
}

@supports (background-color: color-mix(in srgb, #000 10%, transparent)) {
	.drop-zone {
		background-color: color-mix(in srgb, var(--zone-color, rgba(255, 255, 255, 0.12)) 18%, transparent);
	}
}

/* Element group colors (subtle tint on empty zones) */
.drop-zone[data-group="alkali-metal"] {
	--zone-color: #ff5f56;
}
.drop-zone[data-group="alkaline-earth"] {
	--zone-color: #ffbd2e;
}
.drop-zone[data-group="transition"] {
	--zone-color: #ff9f1a;
}
.drop-zone[data-group="post-transition"] {
	--zone-color: #27c93f;
}
.drop-zone[data-group="metalloid"] {
	--zone-color: #00b4d8;
}
.drop-zone[data-group="nonmetal"] {
	--zone-color: #1e90ff;
}
.drop-zone[data-group="noble-gas"] {
	--zone-color: #9b5de5;
}
.drop-zone[data-group="lanthanide"],
.drop-zone[data-group="lanthanide-placeholder"] {
	--zone-color: #dd32f4;
}

.drop-zone[data-group="actinide"],
.drop-zone[data-group="actinide-placeholder"] {
	--zone-color: #ff66c4;
}

/* Keep placeholder opacity */
.drop-zone[data-group="lanthanide-placeholder"],
.drop-zone[data-group="actinide-placeholder"] {
	opacity: 0.65;
	font-size: 12px;
	font-style: italic;
}

.drop-zone.correct {
	opacity: 1;
	border-style: solid;
}

.drop-zone.correct-hover {
	background-color: rgba(100, 255, 218, 0.10);
	outline: 2px dashed var(--accent);
}

/* --- Tutorial modal --- */
.tutorial-box {
	max-width: 620px;
}

.tutorial-stage {
	position: relative;
	margin-top: 14px;
	height: 150px;
	border-radius: var(--r-lg);
	border: 1px solid rgba(255, 255, 255, 0.14);
	background: rgba(255, 255, 255, 0.06);
	overflow: hidden;
}

.tutorial-target {
	position: absolute;
	right: 22px;
	top: 50%;
	transform: translateY(-50%);
	width: 92px;
	height: 92px;
	border-radius: 16px;
	border: 2px dashed rgba(100, 255, 218, 0.45);
	background: rgba(100, 255, 218, 0.07);
	display: flex;
	align-items: center;
	justify-content: center;
}

.tutorial-target.is-hot {
	border-color: rgba(100, 255, 218, 0.85);
	background: rgba(100, 255, 218, 0.12);
}

.tutorial-target-label {
	font-weight: 800;
	color: rgba(230, 241, 255, 0.86);
	font-size: 14px;
}

.tutorial-tile {
	position: absolute;
	left: 22px;
	top: 50%;
	transform: translateY(-50%);
	width: 92px;
	height: 92px;
	border-radius: 16px;
	border: 1px solid rgba(255, 255, 255, 0.16);
	background: rgba(255, 255, 255, 0.10);
	backdrop-filter: blur(10px);
	box-shadow: 0 18px 44px rgba(0, 0, 0, 0.35);
	color: rgba(230, 241, 255, 0.92);
	cursor: grab;
	user-select: none;
	display: grid;
	grid-template-rows: 18px 1fr 18px;
	padding: 10px;
}

.tutorial-tile.is-dragging {
	cursor: grabbing;
	box-shadow: 0 22px 58px rgba(0, 0, 0, 0.45);
}

.tutorial-atomic {
	font-size: 12px;
	font-weight: 800;
	opacity: 0.9;
}

.tutorial-symbol {
	font-size: 26px;
	font-weight: 900;
	align-self: center;
	justify-self: center;
}

.tutorial-name {
	font-size: 12px;
	font-weight: 700;
	opacity: 0.9;
	text-align: center;
}

.tutorial-pointer {
	position: absolute;
	left: 58px;
	top: 52px;
	width: 14px;
	height: 14px;
	border-radius: 999px;
	background: rgba(255, 255, 255, 0.95);
	box-shadow: 0 14px 34px rgba(0, 0, 0, 0.35);
	opacity: 0.85;
	animation: tutorialPointer 1.6s ease-in-out infinite;
}

.tutorial-pointer::after {
	content: "";
	position: absolute;
	left: 50%;
	top: 50%;
	transform: translate(-50%, -50%);
	width: 26px;
	height: 26px;
	border-radius: 999px;
	border: 2px solid rgba(255, 255, 255, 0.35);
}

@keyframes tutorialPointer {
	0% { transform: translate(0, 0) scale(1); opacity: 0.35; }
	20% { opacity: 0.85; }
	55% { transform: translate(310px, 0) scale(1); opacity: 0.85; }
	70% { transform: translate(310px, 0) scale(0.86); opacity: 0.55; }
	100% { transform: translate(0, 0) scale(1); opacity: 0.35; }
}

/* Footer ownership */
.site-footer {
	max-width: 1400px;
	width: min(96vw, 1400px);
	margin: 10px auto 22px;
	padding: 12px 18px;
	border-radius: 999px;
	border: 1px solid rgba(255, 255, 255, 0.12);
	background: rgba(255, 255, 255, 0.05);
	backdrop-filter: blur(10px);
	color: rgba(230, 241, 255, 0.80);
	font-weight: 700;
	text-align: center;
}

/* Intro ownership animation */
.intro-ownership {
	display: inline-flex;
	align-items: baseline;
	gap: 10px;
	margin-top: 18px;
	padding: 10px 14px;
	border-radius: 999px;
	border: 1px solid rgba(255, 255, 255, 0.14);
	background: rgba(255, 255, 255, 0.06);
	backdrop-filter: blur(10px);
	animation: introOwnerIn 900ms ease-out both;
}

.intro-ownership__label {
	font-weight: 700;
	color: rgba(230, 241, 255, 0.72);
	font-size: 13px;
}

.intro-ownership__name {
	font-weight: 900;
	letter-spacing: 0.2px;
	background: linear-gradient(135deg, rgba(34, 197, 94, 0.95), rgba(100, 255, 218, 0.95));
	-webkit-background-clip: text;
	background-clip: text;
	color: transparent;
	position: relative;
}

.intro-ownership__name::after {
	content: "";
	position: absolute;
	left: 0;
	right: 0;
	bottom: -6px;
	height: 2px;
	border-radius: 999px;
	background: linear-gradient(90deg, rgba(34, 197, 94, 0), rgba(100, 255, 218, 0.95), rgba(34, 197, 94, 0));
	animation: introGlow 1.6s ease-in-out infinite;
}

@keyframes introOwnerIn {
	from { opacity: 0; transform: translateY(8px); }
	to { opacity: 1; transform: translateY(0); }
}

@keyframes introGlow {
	0%, 100% { opacity: 0.45; filter: blur(0px); }
	50% { opacity: 1; filter: blur(0.4px); }
}

.drop-zone.incorrect {
	/* Preferred: subtle tint using the indicator color. Fallback provided for older browsers. */
	background-color: var(--indicator-color, rgba(255,40,40,0.25));
	outline: 3px solid var(--indicator-color);
	box-shadow: 0 0 8px var(--indicator-color);
}

/* Use color-mix in browsers that support it for a nicer tint. */
@supports (background-color: color-mix(in srgb, var(--indicator-color) 25%, transparent)) {
	.drop-zone.incorrect {
		background-color: color-mix(in srgb, var(--indicator-color) 25%, transparent);
	}
}

.drop-zone.correct .element-box {
	border: none;
	animation: placeElement 0.5s ease-out forwards;
}

/* Short duplicate of .celebration-overlay removed (full layout defined later). */

.sub-periodic-grid {
	display: grid;
	grid-template-columns: repeat(15, calc(var(--grid-cell) - 2px));
	gap: var(--grid-gap);
	justify-content: center;
	width: max-content;
}

.drop-zone[data-group="spacer"] {
	border: none;
	background: none;
	pointer-events: none; /* Prevents any drag interactions */
}

/* Legend styling */
.legend {
	display: flex;
	flex-wrap: wrap;
	justify-content: center;
	gap: 18px;
	padding: 14px;
	border: 1px solid rgba(255, 255, 255, 0.12);
	border-radius: 18px;
	background: rgba(255, 255, 255, 0.05);
}

.legend-item {
	display: flex;
	align-items: center;
	gap: 8px;
	font-size: 15px;
}

.color-box {
	width: 20px;
	height: 20px;
	border: 1px solid rgba(230, 241, 255, 0.22);
	border-radius: var(--r-sm);
}

/* Legend colors to match */
.color-box.alkali-metal {
	background-color: #ff5f56;
}
.color-box.alkaline-earth {
	background-color: #ffbd2e;
}
.color-box.transition {
	background-color: #ff9f1a;
}
.color-box.post-transition {
	background-color: #27c93f;
}
.color-box.metalloid {
	background-color: #00b4d8;
}
.color-box.nonmetal {
	background-color: #1e90ff;
}
.color-box.noble-gas {
	background-color: #9b5de5;
}
.color-box.lanthanide {
	background-color: #dd32f4;
}
.color-box.actinide {
	background-color: #ff66c4;
}

/* Ensure placeholder boxes don't have borders */
.drop-zone[data-group="spacer"],
.drop-zone[data-group="empty"] {
	border: none;
	background: none;
}

.stats-container {
	display: flex;
	justify-content: start;
	gap: 20px;
}

.score-display,
.level-display,
.timer-display {
	font-size: 18px;
	font-weight: bold;
	color: var(--accent);
	background-color: rgba(17, 34, 64, 0.65);
	padding: 10px 12px;
	border-radius: var(--r-md);
	border: 1px solid rgba(230, 241, 255, 0.10);
	min-width: 100px;
	text-align: center;
}

.timer-warning {
	color: #ff5f56;
	animation: pulse 1s infinite;
}

.button {
	padding: 10px 14px;
	font-size: 15px;
	cursor: pointer;
	background: rgba(255, 255, 255, 0.06);
	color: rgba(230, 241, 255, 0.92);
	border: 1px solid rgba(255, 255, 255, 0.16);
	border-radius: 999px;
	backdrop-filter: blur(8px);
	transition: background-color 180ms ease, transform 180ms ease, border-color 180ms ease, filter 180ms ease;
	min-height: 40px;
}

.button:hover {
	background-color: rgba(255, 255, 255, 0.10);
	border-color: rgba(255, 255, 255, 0.22);
	transform: translateY(-1px);
	filter: brightness(1.03);
}

.button:focus-visible,
.celebration-button:focus-visible,
.modal-input:focus-visible,
.modal-textarea:focus-visible {
	outline: 2px solid rgba(100, 255, 218, 0.65);
	outline-offset: 2px;
}

.reset {
	border-color: #ff5f56;
	color: #ff5f56;
}

.reset:hover {
	background-color: rgba(255, 95, 86, 0.1);
}

.game-container.paused {
	position: relative;
}

.game-container.paused::after {
	content: "PAUSED";
	position: absolute;
	top: 50%;
	left: 50%;
	transform: translate(-50%, -50%);
	background-color: rgba(0, 0, 0, 0.82);
	color: var(--accent);
	padding: 20px 40px;
	font-size: 24px;
	border-radius: var(--r-md);
	z-index: 1000;
}

.game-container.paused .element-box {
	pointer-events: none;
	opacity: 0.5;
}

.game-container.paused .drop-zone {
	pointer-events: none;
}

.element-box.fade-out {
	animation: fadeOut 200ms ease-out forwards;
}

.element-box.fade-in {
	animation: fadeIn 200ms ease-in forwards;
}

.celebration-overlay {
	position: fixed;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
	background: rgba(10, 25, 47, 0.95);
	display: flex;
	justify-content: center;
	align-items: center;
	z-index: 1000;
	animation: fadeIn 0.5s ease-out;
}

.celebration-message {
	background: var(--bg-2);
	padding: 40px;
	border-radius: var(--r-lg);
	text-align: center;
	animation: scaleIn 0.5s ease-out;
	border: 1px solid rgba(230, 241, 255, 0.10);
}

.celebration-message h2 {
	color: var(--accent);
	font-size: 2.5em;
	margin-bottom: 20px;
}

.celebration-message p {
	color: var(--text);
	font-size: 1.2em;
	margin: 10px 0;
}

.celebration-button {
	background-color: var(--accent);
	color: var(--bg);
	border: none;
	padding: 12px 24px;
	border-radius: var(--r-sm);
	font-size: 1.1em;
	margin-top: 20px;
	cursor: pointer;
	transition: all 0.3s ease;
}

.celebration-button:hover {
	transform: scale(1.05);
	box-shadow: 0 0 20px rgba(100, 255, 218, 0.3);
}

@keyframes scaleIn {
	from {
		transform: scale(0.8);
		opacity: 0;
	}
	to {
		transform: scale(1);
		opacity: 1;
	}
}

@keyframes pulse {
	0%,
	100% {
		opacity: 1;
	}
	50% {
		opacity: 0.5;
	}
}

@keyframes fadeOut {
	from {
		opacity: 1;
	}
	to {
		opacity: 0;
	}
}

@keyframes fadeIn {
	from {
		opacity: 0;
	}
	to {
		opacity: 1;
	}
}

/* Modal styles for in-page dialogs */
.modal-overlay {
	position: fixed;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
	background: rgba(10, 25, 47, 0.85);
	display: flex;
	justify-content: center;
	align-items: center;
	z-index: 1200;
}

.modal-box {
	background: var(--panel);
	padding: 24px;
	border-radius: var(--r-lg);
	width: min(560px, 92%);
	max-width: 92vw;
	box-shadow: var(--shadow-lg);
	border: 1px solid rgba(230, 241, 255, 0.10);
	text-align: center;
}

.modal-input {
	width: 100%;
	padding: 10px 12px;
	margin: 10px 0;
	border-radius: var(--r-sm);
	border: 1px solid #223547;
	background: var(--panel-2);
	color: var(--text);
}

.modal-textarea {
	width: 100%;
	height: 90px;
	padding: 12px;
	border-radius: var(--r-sm);
	border: 1px solid #223547;
	background: var(--panel-2);
	color: var(--text);
	resize: vertical;
}

.modal-actions {
	display: flex;
	gap: 8px;
	justify-content: center;
	margin-top: 12px;
	flex-wrap: wrap;
}

.modal-note {
	color: var(--muted);
	margin-bottom: 8px;
}

.modal-status {
	margin-top: 10px;
	color: var(--accent);
	font-weight: 600;
}

@media (max-width: 600px) {
	/* Make the table start at the left edge on mobile */
	.periodic-table-container {
		align-items: flex-start;
		gap: 14px;
	}

	/* Make empty/spacer cells visible so the table shape is clear */
	.drop-zone[data-group="spacer"],
	.drop-zone[data-group="empty"] {
		border: 1px dashed rgba(230, 241, 255, 0.14);
		background: rgba(230, 241, 255, 0.03);
	}

	/* Reduce tile text clutter on small screens */
	.element-box .name,
	.element-box .mass {
		display: none;
	}
	.element-box .symbol {
		font-size: 13px;
	}
	.element-box .atomic-number {
		font-size: 9px;
	}

	/* Legend: 2-column grid */
	.legend {
		display: grid;
		grid-template-columns: repeat(2, minmax(0, 1fr));
		gap: 10px 12px;
		justify-items: start;
		padding: 12px;
	}
	.legend-item {
		font-size: 14px;
	}
	.color-box {
		width: 16px;
		height: 16px;
	}

	.modal-box { padding: 16px; }
	.modal-actions .celebration-button { padding: 8px 12px; font-size: 14px; }
}

@keyframes placeElement {
	0% {
		transform: scale(0.8);
		opacity: 0;
	}
	50% {
		transform: scale(1.1);
	}
	100% {
		transform: scale(1);
		opacity: 1;
	}
}

@keyframes shake {
	0%, 100% { transform: translateX(0); }
	25% { transform: translateX(-5px); }
	75% { transform: translateX(5px); }
}

.element-box.shake {
	animation: shake 0.2s ease-in-out;
}

/* ===========================
   Email Certificate Modal
   =========================== */

#email-modal {
	position: fixed;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	display: none;
	justify-content: center;
	align-items: center;
	background: rgba(0, 0, 0, 0.6);
	z-index: 9999;
}

#email-modal .modal-box {
	background: var(--panel);
	padding: 24px;
	border-radius: var(--r-lg);
	width: min(420px, 92%);
	box-shadow: var(--shadow-lg-2);
	border: 1px solid rgba(230, 241, 255, 0.10);
	text-align: center;
	animation: fadeIn 0.4s ease-out;
}

#email-modal h3 {
	color: var(--accent);
	margin-bottom: 12px;
}

#email-modal p {
	color: var(--text);
	font-size: 15px;
	margin-bottom: 10px;
}

#email-modal input {
	width: 100%;
	padding: 10px 12px;
	border-radius: var(--r-sm);
	border: 1px solid #223547;
	background: var(--panel-2);
	color: var(--text);
	margin-bottom: 12px;
}

#email-modal button {
	background-color: var(--accent);
	color: var(--bg);
	border: none;
	padding: 10px 16px;
	border-radius: var(--r-sm);
	cursor: pointer;
	font-weight: bold;
	transition: all 0.3s ease;
}

#email-modal button:hover {
	transform: scale(1.05);
	box-shadow: 0 0 15px rgba(100, 255, 218, 0.3);
}

#email-status {
	margin-top: 10px;
	font-size: 14px;
	color: #64ffda;
}