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

:root {
	color-scheme: dark;
	--bg-deep: #101824;
	--panel-light: #f7f4ee;
	--panel-light-2: #fffaf3;
	--text-main: #f6f8fb;
	--text-dark: #1c2431;
	--accent-gold: #ffb74a;
	--accent-gold-2: #ff8f3f;
	--accent-teal: #53d7c2;
	--accent-coral: #ff7f62;
	--accent-sky: #74a8ff;
	--shadow-heavy: 0 26px 70px rgba(7, 14, 24, 0.42);
	--shadow-soft: 0 16px 40px rgba(14, 22, 35, 0.18);
}

html,
body {
	margin: 0;
	padding: 0;
	min-height: 100%;
}

body {
	font-family: Arial, Helvetica, sans-serif;
	background:
		repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.03) 0, rgba(255, 255, 255, 0.03) 1px, transparent 1px, transparent 42px),
		linear-gradient(180deg, #0e1724 0, #19293f 430px, #eef3f8 430px, #f6f8fb 100%);
	color: var(--text-main);
	line-height: 1.5;
}

button {
	font: inherit;
	cursor: pointer;
}

button:disabled {
	cursor: not-allowed;
	opacity: 0.55;
}

.asimov-juego-page {
	min-height: 100vh;
}

.game-page {
	max-width: 1280px;
	margin: 0 auto;
	min-height: 100vh;
	display: grid;
	grid-template-rows: auto 1fr;
	gap: 12px;
	padding: 12px 14px 18px;
}

.hero {
	position: relative;
	display: grid;
	grid-template-columns: minmax(0, 1fr) auto;
	align-items: center;
	gap: 12px;
	padding: 12px 16px;
	border-radius: 22px;
	background:
		linear-gradient(135deg, rgba(255, 183, 74, 0.16), transparent 26%),
		linear-gradient(160deg, #152033, #11263d 56%, #1a3650 100%);
	box-shadow: var(--shadow-heavy);
	overflow: hidden;
}

.hero::before {
	content: "";
	position: absolute;
	inset: 0;
	background:
		repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.04) 0, rgba(255, 255, 255, 0.04) 1px, transparent 1px, transparent 30px),
		linear-gradient(90deg, transparent, rgba(83, 215, 194, 0.08), transparent);
	pointer-events: none;
}

.hero::after {
	content: "";
	position: absolute;
	left: 16px;
	right: 16px;
	top: 0;
	height: 3px;
	border-radius: 999px;
	background: linear-gradient(90deg, var(--accent-gold), var(--accent-coral), var(--accent-teal), var(--accent-sky));
}

.hero__copy,
.hero__hud {
	position: relative;
	z-index: 1;
}

.hero__copy {
	display: grid;
	align-content: start;
	gap: 2px;
}

.hero__hud {
	display: grid;
	gap: 8px;
	align-content: start;
	justify-items: end;
}

.hero h1 {
	margin: 0;
	font-size: clamp(1.6rem, 2.4vw, 2.15rem);
	line-height: 1;
	text-wrap: balance;
}

.eyebrow {
	margin: 0;
	font-size: 0.72rem;
	font-weight: 700;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	color: #ffd284;
}

.lede {
	display: none;
}

.hero__stats,
.sequence-card__header,
.section-heading {
	display: flex;
	align-items: center;
	gap: 12px;
}

.hero__stats {
	flex-wrap: wrap;
}

.level-pill,
.sequence-count,
.section-badge {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	padding: 6px 10px;
	border-radius: 999px;
	font-size: 0.8rem;
	font-weight: 700;
}

.level-pill {
	background: rgba(255, 255, 255, 0.1);
	color: var(--text-main);
	border: 1px solid rgba(255, 255, 255, 0.08);
}

.level-pill--warm {
	background: rgba(255, 183, 74, 0.16);
	color: #ffe1b0;
	border-color: rgba(255, 183, 74, 0.24);
}

.level-pill--muted {
	background: rgba(255, 255, 255, 0.08);
	color: #d9e3f3;
}

.level-pill--success {
	background: rgba(83, 215, 194, 0.18);
	color: #c7fff6;
	border-color: rgba(83, 215, 194, 0.28);
}

.level-pill--warning {
	background: rgba(255, 183, 74, 0.18);
	color: #ffe2b5;
	border-color: rgba(255, 183, 74, 0.28);
}

.level-track {
	display: grid;
	grid-template-columns: repeat(5, minmax(0, 1fr));
	gap: 6px;
	margin: 0;
	padding: 0;
	list-style: none;
	width: min(100%, 320px);
}

.level-track__item {
	display: grid;
	justify-items: center;
	gap: 4px;
	padding: 6px 4px;
	border-radius: 16px;
	background: rgba(255, 255, 255, 0.05);
	border: 1px solid rgba(255, 255, 255, 0.06);
	color: rgba(246, 248, 251, 0.72);
}

.level-track__dot {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 28px;
	height: 28px;
	border-radius: 50%;
	background: rgba(255, 255, 255, 0.08);
	font-weight: 700;
	font-size: 0.84rem;
}

.level-track__label {
	font-size: 0.62rem;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.04em;
}

.level-track__item--active {
	background: rgba(255, 183, 74, 0.16);
	border-color: rgba(255, 183, 74, 0.3);
	color: #fff0d7;
}

.level-track__item--active .level-track__dot {
	background: linear-gradient(135deg, var(--accent-gold), var(--accent-gold-2));
	color: #36210d;
}

.level-track__item--completed {
	background: rgba(83, 215, 194, 0.14);
	border-color: rgba(83, 215, 194, 0.24);
	color: #d5fff8;
}

.level-track__item--completed .level-track__dot {
	background: linear-gradient(135deg, var(--accent-teal), #7ff2e0);
	color: #08352d;
}

.level-track__item--locked {
	opacity: 0.65;
}

.game-shell {
	display: grid;
	grid-template-columns: minmax(0, 1.18fr) minmax(340px, 0.82fr);
	gap: 14px;
	align-items: stretch;
	min-height: 0;
}

.board-panel,
.command-panel {
	min-width: 0;
	border-radius: 24px;
	box-shadow: var(--shadow-heavy);
}

.board-panel {
	position: relative;
	display: grid;
	grid-template-rows: auto minmax(0, 1fr);
	gap: 10px;
	padding: 14px;
	background:
		linear-gradient(180deg, rgba(116, 168, 255, 0.08), transparent 24%),
		linear-gradient(180deg, #152133, #0f1825);
	overflow: hidden;
}

.board-panel::before {
	content: "";
	position: absolute;
	inset: 0;
	background: linear-gradient(135deg, rgba(83, 215, 194, 0.05), transparent 34%, rgba(255, 183, 74, 0.05));
	pointer-events: none;
}

.board-panel__top {
	position: relative;
	z-index: 1;
	display: flex;
	justify-content: space-between;
	gap: 10px;
	align-items: flex-start;
}

.mission-card {
	display: grid;
	gap: 4px;
	max-width: 28rem;
}

.level-label {
	margin: 0;
	font-size: 0.8rem;
	font-weight: 700;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	color: #ffcf86;
}

.mission-card h2 {
	margin: 0;
	font-size: clamp(1.1rem, 1.35vw, 1.45rem);
	line-height: 1.08;
}

.level-hint {
	margin: 0;
	font-size: 0.84rem;
	color: rgba(246, 248, 251, 0.82);
}

.game-status {
	margin: 0;
	max-width: 15rem;
	padding: 8px 10px;
	border-radius: 14px;
	background: rgba(255, 255, 255, 0.08);
	border: 1px solid rgba(255, 255, 255, 0.08);
	color: #f3f7fd;
	font-size: 0.82rem;
	font-weight: 700;
	box-shadow: 0 12px 24px rgba(0, 0, 0, 0.16);
}

.game-status.is-running {
	background: rgba(116, 168, 255, 0.18);
	color: #e5f0ff;
}

.game-status.is-success {
	background: rgba(83, 215, 194, 0.18);
	color: #dcfff9;
}

.game-status.is-warning {
	background: rgba(255, 183, 74, 0.18);
	color: #fff2d9;
}

.game-status.is-error {
	background: rgba(255, 127, 98, 0.18);
	color: #ffe5df;
}

.board-frame {
	position: relative;
	display: flex;
	align-items: center;
	justify-content: center;
	min-height: 0;
	padding: 8px;
	border-radius: 22px;
	background:
		linear-gradient(145deg, rgba(255, 183, 74, 0.16), rgba(116, 168, 255, 0.12)),
		linear-gradient(180deg, #0f1825, #121f31);
	box-shadow:
		inset 0 0 0 1px rgba(255, 255, 255, 0.06),
		0 18px 40px rgba(0, 0, 0, 0.28);
	overflow: hidden;
}

.board-frame::before {
	content: "";
	position: absolute;
	inset: 0;
	background: repeating-linear-gradient(180deg, rgba(255, 255, 255, 0.04) 0, rgba(255, 255, 255, 0.04) 1px, transparent 1px, transparent 22px);
	opacity: 0.18;
	pointer-events: none;
}

.game-canvas {
	position: relative;
	width: min(100%, 500px);
	margin: 0 auto;
	border-radius: 18px;
	overflow: hidden;
}

.game-canvas canvas {
	display: block;
	width: 100% !important;
	height: auto !important;
}

.command-panel {
	display: grid;
	align-content: start;
	gap: 10px;
	padding: 14px;
	background:
		linear-gradient(180deg, rgba(255, 183, 74, 0.12), transparent 28%),
		linear-gradient(180deg, var(--panel-light-2), var(--panel-light));
	color: var(--text-dark);
	box-shadow: var(--shadow-soft);
}

.command-panel__hero {
	display: grid;
	gap: 4px;
}

.command-panel__hero h2 {
	margin: 0;
	font-size: 1.1rem;
	line-height: 1;
}

.command-panel__eyebrow {
	margin: 0;
	font-size: 0.8rem;
	font-weight: 700;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	color: #a46115;
}

.command-panel__copy,
.section-copy {
	margin: 0;
	color: #6c7687;
	font-size: 0.86rem;
}

.command-section {
	padding: 12px;
	border-radius: 18px;
	background: rgba(255, 255, 255, 0.66);
	border: 1px solid rgba(28, 36, 49, 0.06);
}

.section-heading {
	justify-content: space-between;
}

.section-heading h3 {
	margin: 0;
	font-size: 0.98rem;
}

.section-heading--stacked {
	display: grid;
	gap: 4px;
	align-items: start;
}

.section-badge {
	background: rgba(116, 168, 255, 0.14);
	color: #34558c;
}

.direction-grid {
	display: grid;
	grid-template-columns: repeat(3, minmax(0, 88px));
	grid-template-areas:
		". up ."
		"left . right"
		". down .";
	gap: 12px;
	width: fit-content;
	max-width: 100%;
	margin: 10px auto 0;
}

.direction-button {
	display: inline-flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 6px;
	min-height: 64px;
	padding: 8px 8px;
	border-radius: 18px;
	border: 1px solid transparent;
	color: #102033;
	font-weight: 700;
	box-shadow: 0 16px 24px rgba(17, 29, 45, 0.08);
	transition: transform 0.16s ease, box-shadow 0.16s ease, border-color 0.16s ease;
}

.direction-button--up {
	grid-area: up;
	background: linear-gradient(180deg, #d8fff7, #aef0e0);
	border-color: rgba(83, 215, 194, 0.4);
}

.direction-button--right {
	grid-area: right;
	background: linear-gradient(180deg, #ffe4cb, #ffc788);
	border-color: rgba(255, 183, 74, 0.45);
}

.direction-button--down {
	grid-area: down;
	background: linear-gradient(180deg, #ffd8cf, #ffb09f);
	border-color: rgba(255, 127, 98, 0.45);
}

.direction-button--left {
	grid-area: left;
	background: linear-gradient(180deg, #dbe7ff, #b5ceff);
	border-color: rgba(116, 168, 255, 0.42);
}

.direction-button:hover,
.direction-button:focus-visible {
	transform: translateY(-2px) scale(1.02);
	box-shadow: 0 20px 28px rgba(17, 29, 45, 0.16);
	outline: none;
}

.direction-button:active {
	transform: translateY(0);
}

.direction-button__icon {
	font-size: 1.3rem;
	line-height: 1;
}

.sequence-card {
	min-width: 0;
	background: linear-gradient(180deg, #162132, #111928);
	color: var(--text-main);
	overflow: hidden;
}

.sequence-card__header {
	min-width: 0;
	justify-content: space-between;
}

.sequence-card__header h3 {
	color: var(--text-main);
}

.sequence-count {
	flex-shrink: 0;
	background: rgba(255, 255, 255, 0.08);
	color: #e3ebf7;
}

.empty-state {
	margin: 16px 0 0;
	padding: 14px 16px;
	border: 1px dashed rgba(255, 255, 255, 0.18);
	border-radius: 18px;
	background: rgba(255, 255, 255, 0.04);
	color: #9fb1c8;
}

.program-list {
	display: flex;
	flex-wrap: nowrap;
	gap: 12px;
	margin: 10px -12px 0;
	padding: 2px 12px 8px;
	list-style: none;
	width: auto;
	max-width: none;
	overflow-x: auto;
	overflow-y: hidden;
	scrollbar-width: thin;
	scrollbar-color: rgba(255, 255, 255, 0.24) transparent;
	-webkit-overflow-scrolling: touch;
}

.program-chip {
	display: inline-flex;
	flex: 0 0 auto;
	align-items: center;
	gap: 10px;
	min-height: 44px;
	padding: 8px 10px;
	border-radius: 999px;
	border: 1px solid rgba(255, 255, 255, 0.08);
	background: rgba(255, 255, 255, 0.06);
	color: var(--text-main);
	box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.02);
}

.program-chip--up {
	background: linear-gradient(180deg, rgba(83, 215, 194, 0.22), rgba(83, 215, 194, 0.1));
}

.program-chip--right {
	background: linear-gradient(180deg, rgba(255, 183, 74, 0.22), rgba(255, 183, 74, 0.1));
}

.program-chip--down {
	background: linear-gradient(180deg, rgba(255, 127, 98, 0.24), rgba(255, 127, 98, 0.1));
}

.program-chip--left {
	background: linear-gradient(180deg, rgba(116, 168, 255, 0.24), rgba(116, 168, 255, 0.1));
}

.program-chip.is-active {
	transform: translateY(-1px);
	box-shadow:
		0 0 0 2px rgba(255, 183, 74, 0.38),
		0 14px 22px rgba(0, 0, 0, 0.18);
}

.program-chip.is-error {
	box-shadow:
		0 0 0 2px rgba(255, 127, 98, 0.45),
		0 14px 22px rgba(0, 0, 0, 0.18);
}

.program-chip__index {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 24px;
	height: 24px;
	border-radius: 50%;
	background: rgba(8, 14, 22, 0.3);
	font-size: 0.8rem;
	font-weight: 700;
}

.program-chip__direction {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	font-weight: 700;
	white-space: nowrap;
}

.program-chip__icon {
	font-size: 1rem;
	line-height: 1;
}

.program-chip__label {
	white-space: nowrap;
}

.program-chip__delete {
	width: 30px;
	height: 30px;
	padding: 0;
	border-radius: 50%;
	border: 1px solid rgba(255, 255, 255, 0.12);
	background: rgba(8, 14, 22, 0.22);
	color: var(--text-main);
}

.program-chip__delete:hover,
.program-chip__delete:focus-visible {
	background: rgba(255, 127, 98, 0.2);
	border-color: rgba(255, 127, 98, 0.32);
	outline: none;
}

.command-budget {
	margin: 10px 0 0;
	font-size: 0.84rem;
	font-weight: 700;
	color: #b8c7da;
}

.command-budget.is-warning {
	color: #ffe0b0;
}

.command-budget.is-success {
	color: #bcfff5;
}

.action-grid {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: 10px;
}

.action-grid--compact {
	grid-template-columns: repeat(3, minmax(0, 1fr));
}

.primary-button,
.secondary-button {
	min-height: 44px;
	padding: 8px 12px;
	border-radius: 14px;
	border: 1px solid transparent;
	font-weight: 700;
	font-size: 0.9rem;
}

.primary-button {
	background: linear-gradient(135deg, var(--accent-gold), var(--accent-gold-2));
	border-color: rgba(255, 183, 74, 0.42);
	color: #37210d;
	box-shadow: 0 16px 28px rgba(255, 143, 63, 0.2);
}

.primary-button:hover,
.primary-button:focus-visible {
	transform: translateY(-1px);
	box-shadow: 0 20px 30px rgba(255, 143, 63, 0.26);
	outline: none;
}

.primary-button--ghost {
	background: rgba(255, 255, 255, 0.7);
	border-color: rgba(28, 36, 49, 0.08);
	color: #7c4b1b;
	box-shadow: none;
}

.primary-button--ready {
	background: linear-gradient(135deg, var(--accent-teal), #a6fff1);
	border-color: rgba(83, 215, 194, 0.36);
	color: #0d3a33;
	box-shadow: 0 16px 28px rgba(83, 215, 194, 0.2);
}

.secondary-button {
	background: rgba(255, 255, 255, 0.72);
	border-color: rgba(28, 36, 49, 0.08);
	color: #4b5565;
}

.secondary-button:hover,
.secondary-button:focus-visible {
	background: #ffffff;
	outline: none;
}

.secondary-button--danger:hover,
.secondary-button--danger:focus-visible {
	border-color: rgba(255, 127, 98, 0.3);
	color: #9d3620;
}

@media (max-width: 1080px) {
	.hero {
		grid-template-columns: 1fr;
	}

	.game-shell {
		grid-template-columns: 1fr;
	}

	.game-canvas {
		width: min(100%, 440px);
	}
}

@media (max-height: 920px) and (min-width: 761px) {
	.game-page {
		padding: 12px 14px 18px;
		gap: 12px;
	}

	.hero {
		padding: 14px 18px;
		gap: 12px;
		border-radius: 24px;
	}

	.hero h1 {
		font-size: clamp(1.85rem, 3vw, 2.5rem);
	}

	.lede,
	.command-panel__copy {
		display: none;
	}

	.hero__hud {
		gap: 8px;
	}

	.level-track__item {
		padding: 6px 5px;
	}

	.board-panel,
	.command-panel {
		padding: 14px;
	}

	.command-panel__hero h2 {
		font-size: 1.15rem;
	}

	.command-section {
		padding: 12px;
		border-radius: 20px;
	}

	.game-canvas {
		width: min(100%, 400px);
	}
}

@media (max-width: 760px) {
	.game-page {
		padding: 10px 10px 20px;
		gap: 10px;
	}

	.hero,
	.board-panel,
	.command-panel {
		border-radius: 20px;
		box-shadow: 0 14px 34px rgba(7, 14, 24, 0.24);
	}

	.hero {
		grid-template-columns: 1fr;
		justify-items: start;
		gap: 10px;
		padding: 10px 10px 12px;
	}

	.hero::after {
		left: 10px;
		right: 10px;
	}

	.hero h1 {
		font-size: clamp(1.45rem, 7vw, 1.9rem);
	}

	.eyebrow {
		font-size: 0.72rem;
	}

	.lede {
		display: none;
	}

	.level-track {
		width: 100%;
		gap: 5px;
	}

	.level-pill,
	.sequence-count,
	.section-badge {
		padding: 6px 10px;
		font-size: 0.82rem;
	}

	.level-track__item {
		gap: 4px;
		padding: 7px 4px 8px;
		border-radius: 16px;
	}

	.level-track__dot {
		width: 28px;
		height: 28px;
		font-size: 0.92rem;
	}

	.level-track__label {
		font-size: 0.68rem;
	}

	.board-panel__top {
		flex-direction: column;
		gap: 12px;
	}

	.board-panel {
		gap: 14px;
		padding: 14px;
	}

	.mission-card {
		gap: 6px;
	}

	.mission-card h2 {
		font-size: 1.15rem;
	}

	.level-label {
		font-size: 0.72rem;
	}

	.level-hint {
		font-size: 0.82rem;
	}

	.game-status {
		max-width: none;
		padding: 12px 14px;
		border-radius: 16px;
		font-size: 0.88rem;
	}

	.board-frame {
		padding: 8px;
		border-radius: 22px;
	}

	.game-canvas {
		width: min(100%, 280px);
	}

	.command-panel {
		gap: 12px;
		padding: 14px;
	}

	.command-panel__hero {
		gap: 4px;
	}

	.command-panel__hero h2 {
		font-size: 1.12rem;
	}

	.command-panel__eyebrow {
		font-size: 0.72rem;
	}

	.command-panel__copy,
	.section-copy {
		font-size: 0.8rem;
	}

	.command-panel__copy {
		display: none;
	}

	.sequence-card__header {
		flex-direction: column;
		align-items: flex-start;
		gap: 8px;
	}

	.sequence-count {
		align-self: flex-start;
	}

	.command-section {
		padding: 12px;
		border-radius: 18px;
	}

	.section-heading h3 {
		font-size: 0.95rem;
	}

	.program-list {
		gap: 8px;
		margin-top: 10px;
		padding: 2px 8px 8px;
		margin-inline: -8px;
	}

	.program-chip {
		min-height: 42px;
		padding: 7px 9px;
		gap: 7px;
	}

	.empty-state {
		margin-top: 10px;
		padding: 10px 12px;
		border-radius: 14px;
		font-size: 0.82rem;
	}

	.command-budget {
		margin-top: 10px;
		font-size: 0.82rem;
	}

	.program-chip__index {
		width: 22px;
		height: 22px;
		font-size: 0.72rem;
	}

	.program-chip__direction {
		gap: 5px;
	}

	.program-chip__label {
		display: none;
	}

	.program-chip__delete {
		width: 22px;
		height: 22px;
		font-size: 0.84rem;
	}

	.direction-grid {
		grid-template-columns: repeat(3, minmax(0, 68px));
		gap: 6px;
		margin-top: 12px;
	}

	.direction-button {
		min-height: 58px;
		padding: 6px 6px;
		border-radius: 15px;
		gap: 4px;
		box-shadow: 0 10px 18px rgba(17, 29, 45, 0.1);
		font-size: 0.74rem;
	}

	.direction-button__icon {
		font-size: 1.05rem;
	}

	.primary-button,
	.secondary-button {
		min-height: 46px;
		padding: 10px 14px;
		border-radius: 15px;
		font-size: 0.92rem;
	}

	.action-grid {
		gap: 8px;
	}

	.action-grid,
	.action-grid--compact {
		grid-template-columns: 1fr;
	}
}
