@font-face {
	font-family: "Chelsea Market";
	src: url("../Chelsea_Market/ChelseaMarket-Regular.ttf");
	font-weight: 400;
	font-style: normal;
}

* {
	box-sizing: border-box;
}

html,
body {
	width: 100%;
	height: 100%;
	margin: 0;
	overflow: hidden;
}

body {
	font-family: "Chelsea Market", system-ui, sans-serif;
	background: #202020;
	color: #ffffff;
	letter-spacing: 0;
}

button,
input {
	font: inherit;
	letter-spacing: 0;
}

.memory-shell {
	position: fixed;
	inset: 0;
	min-width: 320px;
	background-image: url("../games_assets/backgrounds/horizontal.png");
	background-size: cover;
	background-position: center;
	overflow: hidden;
	--card-gap: 18px;
}

.game-tools {
	position: fixed;
	top: 20px;
	right: 20px;
	z-index: 20;
	display: flex;
	gap: 10px;
}

.share-game {
	position: fixed;
	right: 26px;
	bottom: 26px;
	z-index: 22;
	width: 56px;
	height: 56px;
	border: 0;
	border-radius: 50%;
	padding: 0;
	background: transparent;
	box-shadow: 0 8px 18px rgba(0, 0, 0, 0.24);
	cursor: pointer;
	transition: transform 160ms ease, filter 160ms ease;
}

.share-game:hover {
	transform: translateY(-1px);
	filter: brightness(1.03);
}

.share-game:active {
	transform: translateY(1px) scale(0.98);
}

.share-game img {
	display: block;
	width: 100%;
	height: 100%;
}

.share-status {
	position: fixed;
	right: 26px;
	bottom: 92px;
	z-index: 23;
	max-width: min(280px, calc(100vw - 52px));
	border-radius: 999px;
	padding: 9px 14px;
	background: rgba(0, 0, 0, 0.74);
	color: #ffffff;
	font-family: system-ui, sans-serif;
	font-size: 14px;
	font-weight: 700;
	line-height: 1.2;
	box-shadow: 0 8px 22px rgba(0, 0, 0, 0.24);
}

.share-status[hidden] {
	display: none;
}

.close-game,
.dev-finish-game {
	display: grid;
	place-items: center;
	width: 32px;
	height: 32px;
	border: 0;
	border-radius: 50%;
	background: rgba(0, 0, 0, 0.45);
	color: #ffffff;
	font-size: 25px;
	line-height: 1;
	cursor: pointer;
}

.dev-finish-game {
	font-size: 22px;
	color: var(--accent);
}

.game-heading {
	position: relative;
	z-index: 2;
	text-align: center;
	padding-top: 42px;
	pointer-events: none;
}

.game-heading h1 {
	margin: 0;
	color: var(--accent);
	font-size: 64px;
	font-weight: 400;
	line-height: 1.05;
	text-shadow: 0 3px 3px rgba(0, 0, 0, 0.28);
}

.game-heading p {
	margin: 4px 0 0;
	color: rgba(255, 255, 255, 0.88);
	font-family: system-ui, sans-serif;
	font-size: 17px;
	font-weight: 700;
}

.board-wrap {
	position: absolute;
	inset: 145px 6vw 50px;
	display: block;
	perspective: 1400px;
}

.memory-board {
	position: absolute;
	left: 50%;
	top: 50%;
	display: grid;
	grid-template-columns: repeat(6, 1fr);
	grid-template-rows: repeat(4, 1fr);
	gap: var(--card-gap);
	width: min(1080px, calc(100vw - 12vw), calc((100vh - 195px) * 1.5));
	aspect-ratio: 6 / 4;
	transform: translate(-50%, -50%);
}

.memory-card {
	position: relative;
	display: block;
	width: 100%;
	height: 100%;
	min-width: 0;
	min-height: 0;
	border: 0;
	padding: 0;
	background: transparent;
	cursor: pointer;
	perspective: 900px;
	opacity: 0;
	transform: scale(0.05) rotate(0deg);
	animation: intro-card 720ms cubic-bezier(0.2, 0.84, 0.19, 1.12) forwards;
}

.memory-card.is-disabled {
	cursor: default;
}

.memory-card.is-outro {
	animation: outro-card 850ms ease-in both;
}

.memory-card-inner {
	position: absolute;
	inset: 0;
	transform-style: preserve-3d;
	transition: transform 460ms cubic-bezier(0.2, 0.76, 0.24, 1);
}

.memory-card.is-face-up .memory-card-inner {
	transform: rotateY(180deg);
}

.memory-card-face {
	position: absolute;
	inset: 0;
	display: grid;
	place-items: center;
	border-radius: 14px;
	backface-visibility: hidden;
	overflow: hidden;
	box-shadow: 0 8px 0 rgba(0, 0, 0, 0.26), 0 15px 18px rgba(0, 0, 0, 0.20);
}

.memory-card-back {
	background: var(--accent);
}

.memory-card-back img {
	width: 100%;
	height: 100%;
	object-fit: cover;
}

.memory-card-front {
	background:
		linear-gradient(rgba(255, 255, 255, 0.68), rgba(255, 255, 255, 0.68)),
		url("../games_assets/front_texture.png"),
		#ffffff;
	background-size: cover;
	transform: rotateY(180deg);
}

.memory-card-front img {
	position: absolute;
	z-index: 1;
	right: -6%;
	bottom: -7%;
	width: 62%;
	max-height: 72%;
	object-fit: contain;
	opacity: 0.88;
}

.memory-card-text {
	position: absolute;
	inset: 10% 12%;
	z-index: 2;
	display: flex;
	align-items: center;
	justify-content: center;
	color: #070707;
	font-size: var(--card-text-size, 76px);
	line-height: 0.92;
	text-align: center;
	white-space: normal;
	box-sizing: border-box;
	overflow-wrap: normal;
	word-break: normal;
	text-shadow: 0 1px 0 rgba(0, 0, 0, 0.10);
}

.memory-card.has-no-graphic .memory-card-text {
	inset: 9% 12%;
}

.score-screen {
	position: absolute;
	inset: 205px 7vw 44px;
	z-index: 10;
	display: grid;
	grid-template-rows: auto auto minmax(0, 1fr) auto;
	row-gap: 18px;
	align-items: start;
	justify-items: center;
	color: #ffffff;
	text-shadow: 0 2px 3px rgba(0, 0, 0, 0.36);
}

.score-screen[hidden],
.name-dialog[hidden],
.guest-trial-dialog[hidden] {
	display: none;
}

.score-stats {
	display: grid;
	grid-template-columns: repeat(3, minmax(150px, 1fr));
	width: min(1040px, 100%);
	gap: 26px;
	margin: 0 0 42px;
}

.score-stats div {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 12px;
	font-size: 48px;
	line-height: 1;
}

.score-icon {
	font-family: system-ui, sans-serif;
	color: #ffffff;
}

.score-screen h2 {
	margin: 0;
	color: var(--accent);
	font-size: 46px;
	font-weight: 400;
}

.highscores {
	display: grid;
	grid-template-columns: minmax(0, 1fr);
	gap: 8px;
	align-self: stretch;
	align-content: start;
	width: min(760px, 100%);
	height: 100%;
	max-height: none;
	min-height: 0;
	margin: 0;
	padding: 0 22px;
	overflow-x: hidden;
	overflow-y: auto;
	overscroll-behavior: contain;
	color: var(--accent);
	font-size: 25px;
	list-style-position: inside;
	scrollbar-color: rgba(255, 205, 0, 0.75) rgba(255, 255, 255, 0.10);
}

.highscores li {
	display: grid;
	grid-template-columns: 56px minmax(120px, 1fr) 90px 90px 90px;
	align-items: center;
	gap: 10px;
}

.highscores li::marker {
	color: var(--accent);
}

.highscores .score-name {
	color: #ffffff;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.score-actions {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	align-self: end;
	gap: 20px;
	margin-top: 22px;
}

.score-actions button,
.score-actions a,
.name-dialog button {
	border: 0;
	background: transparent;
	color: var(--accent);
	font: inherit;
	font-size: 54px;
	line-height: 1;
	text-decoration: none;
	text-shadow: 0 3px 3px rgba(0, 0, 0, 0.30);
	cursor: pointer;
}

.score-actions a {
	font-size: 34px;
	color: #ffffff;
}

.name-dialog {
	position: fixed;
	left: 50%;
	top: 50%;
	z-index: 30;
	width: min(520px, calc(100% - 36px));
	transform: translate(-50%, -50%);
	padding: 26px;
	border-radius: 8px;
	background: rgba(20, 20, 20, 0.92);
	box-shadow: 0 22px 80px rgba(0, 0, 0, 0.46);
	color: #ffffff;
}

.name-dialog label {
	display: block;
	margin-bottom: 14px;
	font-size: 24px;
	line-height: 1.2;
}

.name-dialog div {
	display: grid;
	grid-template-columns: minmax(0, 1fr) auto;
	gap: 12px;
}

.name-dialog input {
	min-width: 0;
	border: 3px solid var(--accent);
	border-radius: 8px;
	padding: 10px 12px;
	font-family: system-ui, sans-serif;
	font-size: 22px;
}

.name-dialog button {
	font-size: 26px;
}

.guest-trial-dialog {
	position: fixed;
	inset: 0;
	z-index: 45;
	display: grid;
	place-items: center;
	padding: 24px;
	background: rgba(11, 21, 51, 0.44);
	backdrop-filter: blur(3px);
}

.guest-trial-card {
	width: min(560px, 100%);
	border: 1px solid rgba(255, 255, 255, 0.78);
	border-radius: 24px;
	padding: clamp(28px, 5vw, 46px);
	background: rgba(255, 255, 255, 0.97);
	color: #0b1533;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
	box-shadow: 0 28px 90px rgba(31, 41, 55, 0.28);
	text-align: left;
}

.guest-trial-card h2 {
	margin: 0 0 12px;
	color: #0b1533;
	font-size: clamp(30px, 4vw, 42px);
	font-weight: 850;
	line-height: 1.08;
}

.guest-trial-card p {
	margin: 0;
	color: #25304f;
	font-size: 18px;
	font-weight: 500;
	line-height: 1.55;
}

.guest-trial-actions {
	display: flex;
	flex-wrap: wrap;
	gap: 12px;
	margin-top: 28px;
}

.guest-trial-actions a,
.guest-trial-actions button {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-height: 52px;
	border: 1px solid #7146c6;
	border-radius: 10px;
	padding: 0 22px;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
	font-size: 16px;
	font-weight: 850;
	line-height: 1;
	text-decoration: none;
	cursor: pointer;
}

.guest-trial-actions a {
	background: linear-gradient(135deg, #7146c6, #8a5cf6);
	color: #ffffff;
	box-shadow: 0 12px 22px rgba(113, 70, 198, 0.25);
}

.guest-trial-actions button {
	background: #ffffff;
	color: #0b1533;
	border-color: #d0d5dd;
}

@keyframes intro-card {
	0% {
		opacity: 0;
		transform: scale(0.05) rotate(-90deg);
	}
	72% {
		opacity: 1;
		transform: scale(1.05) rotate(6deg);
	}
	100% {
		opacity: 1;
		transform: scale(1) rotate(0deg);
	}
}

@keyframes outro-card {
	0% {
		opacity: 1;
		transform: scale(1) rotate(0deg);
	}
	100% {
		opacity: 0;
		transform: scale(0.10) rotate(-180deg);
	}
}

@media (orientation: portrait) {
	.memory-shell {
		background-image: url("../games_assets/backgrounds/vertical.png");
	}

	.board-wrap {
		inset: 138px 5vw 42px;
	}

	.memory-board {
		grid-template-columns: repeat(4, 1fr);
		grid-template-rows: repeat(6, 1fr);
		width: min(720px, calc(100vw - 10vw), calc((100vh - 180px) * 0.6667));
		aspect-ratio: 4 / 6;
	}
}

@media (max-width: 700px) {
	.memory-shell {
		background-image: url("../games_assets/backgrounds/smartphone.png");
		--card-gap: 10px;
	}

	.game-tools {
		top: 10px;
		right: 10px;
	}

	.share-game {
		right: 16px;
		bottom: 16px;
		width: 52px;
		height: 52px;
	}

	.share-status {
		right: 16px;
		bottom: 78px;
	}

	.game-heading {
		padding-top: 30px;
	}

	.game-heading h1 {
		font-size: 39px;
	}

	.game-heading p {
		font-size: 14px;
	}

	.board-wrap {
		inset: 104px 14px 20px;
	}

	.memory-card-face {
		border-radius: 12px;
		box-shadow: 0 5px 0 rgba(0, 0, 0, 0.24), 0 8px 12px rgba(0, 0, 0, 0.22);
	}

	.memory-card-text {
		inset: 10% 14%;
		font-size: var(--card-text-size, 44px);
	}

	.memory-card.has-no-graphic .memory-card-text {
		inset: 9% 14%;
	}

	.score-screen {
		inset: clamp(174px, 31vh, 230px) 16px 20px;
		row-gap: 10px;
	}

	.score-stats {
		grid-template-columns: repeat(3, 1fr);
		gap: 8px;
		margin-bottom: 10px;
	}

	.score-stats div {
		gap: 6px;
		font-size: 28px;
	}

	.score-screen h2 {
		font-size: 33px;
	}

	.highscores {
		width: 100%;
		height: 100%;
		max-height: none;
		padding: 0;
		font-size: 17px;
	}

	.highscores li {
		grid-template-columns: 32px minmax(70px, 1fr) 52px 52px 52px;
		gap: 5px;
	}

	.score-actions {
		flex-direction: column;
		gap: 14px;
		margin-top: 10px;
	}

	.score-actions button {
		font-size: 37px;
	}

	.score-actions a {
		font-size: 23px;
	}

	.name-dialog {
		padding: 20px;
	}

	.name-dialog label {
		font-size: 19px;
	}

	.name-dialog div {
		grid-template-columns: 1fr;
	}

	.guest-trial-dialog {
		padding: 18px;
	}

	.guest-trial-card {
		border-radius: 20px;
		padding: 26px;
	}

	.guest-trial-card p {
		font-size: 16px;
	}

	.guest-trial-actions {
		display: grid;
		grid-template-columns: 1fr;
	}
}
