/* ============================================================
   Slime Idle — Entry Screens Design System
   Login / Register / Character Selection / Creation / Boot
   Pixel-art medieval. Live animated map stays visible behind.
   ============================================================ */

:root {
	--si-ink: #f3e6c4;
	--si-ink-dim: #cdb892;
	--si-gold: #e8c558;
	--si-gold-deep: #b98a2e;
	--si-parch: #e9d6a8;
	--si-parch-2: #d9c08a;
	--si-parch-line: #b9985b;
	--si-wood: #3c2a18;
	--si-wood-2: #271a0e;
	--si-blurple: #5865f2;
	--si-blurple-2: #4752c4;
	--si-frame: #6b4f2a;
	--si-frame-light: #8a6a38;
	--si-shadow: 0 6px 0 rgba(0, 0, 0, 0.45);
	--si-radius: 6px;
}

/* Edge darkening so text stays readable over the live map */
.si-vignette {
	position: fixed;
	inset: 0;
	z-index: 4;
	pointer-events: none;
	background:
		radial-gradient(120% 120% at 50% 38%, rgba(0, 0, 0, 0) 42%, rgba(0, 0, 0, 0.55) 100%),
		linear-gradient(to bottom, rgba(7, 4, 14, 0.35), rgba(7, 4, 14, 0.12) 30%, rgba(7, 4, 14, 0.12) 70%, rgba(7, 4, 14, 0.45));
}

/* ===================== ENTRY SHELL (grid) ===================== */
.medieval-entry.si-entry-shell {
	position: relative;
	z-index: 5;
	width: min(1040px, 100%);
	margin: 0 auto;
	padding: clamp(14px, 3vw, 38px);
	box-sizing: border-box;
	display: grid;
	grid-template-columns: 1.45fr 1fr;
	grid-template-rows: auto auto auto;
	grid-template-areas:
		"head head"
		"main side"
		"foot foot";
	gap: clamp(14px, 2.4vw, 26px);
	background: transparent;
}

/* Login variant: centered in the middle of the screen */
.medieval-entry.si-entry-shell.si-login {
	display: flex;
	flex-direction: column;
	align-items: center;
	text-align: center;
	gap: clamp(16px, 2.6vw, 28px);
	margin: 0 auto;
	padding: clamp(16px, 3vw, 40px) clamp(14px, 3vw, 38px) calc(20px + env(safe-area-inset-bottom));
}
.si-login-head {
	display: flex;
	flex-direction: column;
	align-items: center;
	text-align: center;
	gap: 10px;
}
.si-login-row {
	display: flex;
	flex-wrap: wrap;
	align-items: flex-start;
	gap: clamp(14px, 2vw, 22px);
	width: 100%;
}
.si-card {
	flex: 1 1 300px;
	min-width: 260px;
	background:
		linear-gradient(180deg, rgba(255, 255, 255, 0.05), rgba(0, 0, 0, 0.1)),
		var(--si-parch);
	border: 4px solid var(--si-frame);
	border-radius: var(--si-radius);
	box-shadow: var(--si-shadow), inset 0 0 0 2px rgba(255, 255, 255, 0.22);
	padding: 16px 18px 14px;
	position: relative;
	color: #2c1d0d;
}
.si-login-card .si-discord-btn { margin-top: 4px; }
.si-login-card .si-trust-list { margin-top: 14px; }
.si-card-lead {
	margin: 2px 0 14px;
	font-family: Pixel, monospace;
	font-size: 12px;
	line-height: 1.45;
	color: #5a3d1d;
}
.si-entry-utilities {
	display: flex;
	align-items: center;
	justify-content: center;
	flex-wrap: wrap;
	gap: 10px 18px;
}
.si-community-link,
.si-quiet-link {
	min-height: 44px;
	box-sizing: border-box;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 9px;
	font-family: Pixel, monospace;
	font-size: 12px;
	text-decoration: none;
}
.si-community-link {
	padding: 8px 14px;
	color: #f5efff;
	background: rgba(30, 23, 50, 0.88);
	border: 2px solid #8176dc;
	box-shadow: 0 3px 0 #21193e;
}
.si-community-link .si-discord-glyph { width: 18px; height: 18px; }
.si-quiet-link { color: var(--si-ink); padding: 8px; text-shadow: 0 2px #140a04; }
.si-community-link:hover,
.si-quiet-link:hover { filter: brightness(1.16); }

.si-area-head { grid-area: head; }
.si-area-main { grid-area: main; }
.si-area-side { grid-area: side; align-self: start; }
.si-area-foot { grid-area: foot; }

/* ===================== HEADER / WORDMARK ===================== */
.medieval-entry-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 14px;
	flex-wrap: wrap;
}

.medieval-wordmark {
	font-family: Pixel, monospace;
	font-weight: 700;
	line-height: 0.86;
	letter-spacing: 2px;
	display: flex;
	flex-direction: column;
	text-shadow: 0 3px 0 #1a0f06, 0 0 14px rgba(232, 197, 88, 0.35);
}
.medieval-wordmark-main {
	font-size: clamp(34px, 6vw, 60px);
	color: var(--si-gold);
	background: linear-gradient(180deg, #ffe9a8 0%, #e8c558 45%, #b98a2e 100%);
	-webkit-background-clip: text;
	background-clip: text;
	-webkit-text-fill-color: transparent;
	filter: drop-shadow(0 3px 0 #1a0f06);
}
.medieval-wordmark-sub {
	font-size: clamp(18px, 3vw, 30px);
	color: #f3e6c4;
	letter-spacing: 8px;
	margin-top: 2px;
}

.medieval-entry-links {
	display: flex;
	gap: 16px;
	align-items: center;
}
.medieval-entry-link {
	font-family: Pixel, monospace;
	font-size: 13px;
	color: var(--si-ink-dim);
	text-decoration: none;
	padding: 4px 2px;
	border-bottom: 2px solid transparent;
	transition: color 0.15s, border-color 0.15s;
}
.medieval-entry-link:hover {
	color: var(--si-gold);
	border-bottom-color: var(--si-gold);
}

/* ===================== HERO / TAGLINE ===================== */
.medieval-entry-hero {
	display: flex;
	flex-direction: column;
	justify-content: center;
	gap: 14px;
	min-height: 180px;
}
.medieval-entry-tagline {
	font-family: Pixel, monospace;
	font-size: clamp(18px, 2.6vw, 28px);
	line-height: 1.25;
	color: var(--si-ink);
	margin: 0;
	text-shadow: 0 2px 0 #140a04, 0 0 12px rgba(0, 0, 0, 0.6);
}
.medieval-entry-subtitle {
	font-family: Pixel, monospace;
	font-size: clamp(12px, 1.6vw, 15px);
	line-height: 1.5;
	color: var(--si-ink-dim);
	margin: 0;
	max-width: 46ch;
	text-shadow: 0 2px 0 #140a04;
}

.medieval-entry-statuses {
	display: flex;
	gap: 10px;
	flex-wrap: wrap;
	margin-top: 6px;
}
.medieval-status-pill {
	font-family: Pixel, monospace;
	font-size: 12px;
	color: var(--si-ink);
	padding: 6px 12px;
	border-radius: 999px;
	background: rgba(20, 12, 6, 0.6);
	border: 2px solid var(--si-frame-light);
	box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.5);
	display: inline-flex;
	align-items: center;
	gap: 8px;
}
.si-pill-online .si-dot {
	width: 9px;
	height: 9px;
	border-radius: 50%;
	background: #5fd06a;
	box-shadow: 0 0 8px #5fd06a;
	animation: si-pulse 1.8s ease-in-out infinite;
}
@keyframes si-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }
.si-pill-load { letter-spacing: 1px; }

/* ===================== DISCORD FRAME ===================== */
.si-discord-frame {
	background:
		linear-gradient(180deg, rgba(255, 255, 255, 0.06), rgba(0, 0, 0, 0.12)),
		var(--si-parch);
	color: #2c1d0d;
	border: 4px solid var(--si-frame);
	border-radius: var(--si-radius);
	box-shadow: var(--si-shadow), inset 0 0 0 2px rgba(255, 255, 255, 0.25);
	padding: 18px;
	position: relative;
}
.si-discord-frame::before {
	content: "";
	position: absolute;
	inset: 4px;
	border: 2px dashed rgba(120, 84, 36, 0.5);
	border-radius: 3px;
	pointer-events: none;
}
.si-discord-head {
	display: flex;
	align-items: center;
	gap: 12px;
	margin-bottom: 14px;
}
.si-discord-seal {
	width: 42px;
	height: 42px;
	border-radius: 8px;
	image-rendering: pixelated;
	border: 3px solid var(--si-frame);
	background: #1c130a;
}
.si-discord-head-text { line-height: 1.2; }
.si-discord-title {
	font-family: Pixel, monospace;
	font-size: 18px;
	color: #3a2510;
}
.si-discord-sub {
	font-family: Pixel, monospace;
	font-size: 11px;
	color: #6a4a24;
}

.si-discord-btn {
	width: 100%;
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 12px;
	font-family: Pixel, monospace;
	font-size: 16px;
	color: #fff;
	padding: 14px 16px;
	border: 3px solid #2c2f6b;
	border-radius: var(--si-radius);
	background: linear-gradient(180deg, var(--si-blurple) 0%, var(--si-blurple-2) 100%);
	box-shadow: 0 4px 0 #2c2f6b, inset 0 1px 0 rgba(255, 255, 255, 0.2);
	cursor: pointer;
	transition: transform 0.08s, box-shadow 0.08s, filter 0.15s;
}
.si-discord-btn:hover { filter: brightness(1.08); }
.si-discord-btn:active {
	transform: translateY(3px);
	box-shadow: 0 1px 0 #2c2f6b, inset 0 1px 0 rgba(255, 255, 255, 0.2);
}
.si-discord-glyph {
	width: 22px;
	height: 22px;
	background: #fff;
	-webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='%23000' d='M20.3 4.4A19.8 19.8 0 0 0 15.4 3l-.3.5a14.6 14.6 0 0 1 4.2 1.3 14 14 0 0 0-12.6 0A14.6 14.6 0 0 1 10.9 3.5L10.6 3a19.8 19.8 0 0 0-4.9 1.4C2.3 9.2 1.4 13.9 1.8 18.5a19.9 19.9 0 0 0 6 3l.8-1.2a13 13 0 0 1-2-1l.5-.4a14.2 14.2 0 0 0 12.2 0l.5.4a13 13 0 0 1-2 1l.8 1.2a19.9 19.9 0 0 0 6-3c.5-5.3-.8-9.9-3.4-14.1zM8.5 15.3c-1 0-1.8-1-1.8-2.1 0-1.2.8-2.1 1.8-2.1s1.9 1 1.8 2.1c0 1.1-.8 2.1-1.8 2.1zm7 0c-1 0-1.8-1-1.8-2.1 0-1.2.8-2.1 1.8-2.1s1.9 1 1.8 2.1c0 1.1-.8 2.1-1.8 2.1z'/%3E%3C/svg%3E") center / contain no-repeat;
	mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='%23000' d='M20.3 4.4A19.8 19.8 0 0 0 15.4 3l-.3.5a14.6 14.6 0 0 1 4.2 1.3 14 14 0 0 0-12.6 0A14.6 14.6 0 0 1 10.9 3.5L10.6 3a19.8 19.8 0 0 0-4.9 1.4C2.3 9.2 1.4 13.9 1.8 18.5a19.9 19.9 0 0 0 6 3l.8-1.2a13 13 0 0 1-2-1l.5-.4a14.2 14.2 0 0 0 12.2 0l.5.4a13 13 0 0 1-2 1l.8 1.2a19.9 19.9 0 0 0 6-3c.5-5.3-.8-9.9-3.4-14.1zM8.5 15.3c-1 0-1.8-1-1.8-2.1 0-1.2.8-2.1 1.8-2.1s1.9 1 1.8 2.1c0 1.1-.8 2.1-1.8 2.1zm7 0c-1 0-1.8-1-1.8-2.1 0-1.2.8-2.1 1.8-2.1s1.9 1 1.8 2.1c0 1.1-.8 2.1-1.8 2.1z'/%3E%3C/svg%3E") center / contain no-repeat;
}

.si-trust-list {
	list-style: none;
	margin: 14px 0 0;
	padding: 0;
	display: flex;
	flex-direction: column;
	gap: 7px;
}
.si-trust-list li {
	font-family: Pixel, monospace;
	font-size: 11px;
	color: #5a3d1d;
	display: flex;
	align-items: center;
	gap: 8px;
}
.si-trust-ico { color: var(--si-gold-deep); }

/* ===================== FOOT: NOTES + LEGAL ===================== */
.si-area-foot {
	display: flex;
	flex-direction: column;
	gap: 12px;
}
.si-notes {
	background:
		linear-gradient(180deg, rgba(255, 255, 255, 0.05), rgba(0, 0, 0, 0.1)),
		var(--si-parch);
	border: 4px solid var(--si-frame);
	border-radius: var(--si-radius);
	box-shadow: var(--si-shadow), inset 0 0 0 2px rgba(255, 255, 255, 0.22);
	padding: 16px 18px 14px;
	position: relative;
	color: #2c1d0d;
}
.si-notes-head { margin: -28px 0 6px; }
.si-notes-ribbon {
	font-family: Pixel, monospace;
	font-size: 13px;
	color: #fff;
	background: linear-gradient(180deg, #8a6a38, #5e4422);
	border: 3px solid #3c2a18;
	border-radius: 4px;
	padding: 5px 14px;
	box-shadow: 0 3px 0 #1a0f06;
	display: inline-block;
}
.si-notes-body {
	max-height: 120px;
	overflow-y: auto;
	font-family: Pixel, monospace;
	font-size: 12px;
	line-height: 1.6;
	color: #3a2510;
}
.si-note-entry { padding: 1px 0; }
.si-foot-legal {
	display: flex;
	align-items: center;
	gap: 16px;
	flex-wrap: wrap;
}

/* ===================== BOOT / LOADING SCREEN ===================== */
.si-boot {
	position: fixed;
	inset: 0;
	z-index: 60;
	display: none;
	align-items: center;
	justify-content: center;
	background:
		radial-gradient(80% 80% at 50% 40%, #1a1230 0%, #0a0716 70%, #05030c 100%);
	opacity: 0;
	transition: opacity 0.5s ease;
}
.si-boot.si-active { display: flex; opacity: 1; }
.si-boot.si-done { opacity: 0; pointer-events: none; }
.si-boot-inner {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 14px;
	text-align: center;
	padding: 24px;
}
.si-boot-logo {
	width: 84px;
	height: 84px;
	image-rendering: pixelated;
	animation: si-float 2.4s ease-in-out infinite;
	filter: drop-shadow(0 6px 10px rgba(0, 0, 0, 0.6));
}
@keyframes si-float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }
.si-boot-title {
	font-family: Pixel, monospace;
	font-size: 34px;
	letter-spacing: 4px;
	color: var(--si-gold);
	text-shadow: 0 3px 0 #1a0f06;
}
.si-boot-sub {
	font-family: Pixel, monospace;
	font-size: 13px;
	color: var(--si-ink-dim);
}
.si-boot-bar {
	width: min(320px, 70vw);
	height: 16px;
	border: 3px solid var(--si-frame-light);
	border-radius: 999px;
	background: rgba(0, 0, 0, 0.5);
	overflow: hidden;
	box-shadow: inset 0 0 0 2px rgba(0, 0, 0, 0.5);
}
.si-boot-fill {
	height: 100%;
	width: 0%;
	background: linear-gradient(90deg, #e8c558, #b98a2e);
	transition: width 0.25s ease;
}
.si-boot-pct {
	font-family: Pixel, monospace;
	font-size: 13px;
	color: var(--si-ink);
}
.si-boot-tap {
	font-family: Pixel, monospace;
	font-size: 12px;
	color: var(--si-ink-dim);
	opacity: 0.85;
	margin-top: 6px;
	animation: si-blink 1.6s steps(2, start) infinite;
}
@keyframes si-blink { 50% { opacity: 0.25; } }

/* ===================== RESPONSIVE ===================== */
@media (max-width: 860px) {
	.medieval-entry.si-entry-shell {
		grid-template-columns: 1fr;
		grid-template-areas:
			"head"
			"main"
			"side"
			"foot";
		padding: 16px 14px calc(16px + env(safe-area-inset-bottom));
	}
	.medieval-entry-header { justify-content: center; text-align: center; }
	.medieval-entry-hero { min-height: 120px; text-align: center; align-items: center; }
	.medieval-entry-subtitle { max-width: 38ch; }
	.medieval-entry-links { justify-content: center; }
}

@media (max-width: 560px) {
	.medieval-wordmark-main { font-size: 38px; letter-spacing: 1px; }
	.medieval-wordmark-sub { font-size: 18px; letter-spacing: 5px; }
	.medieval-entry-tagline { font-size: 17px; }
	.si-boot-title { font-size: 26px; }
	.si-discord-btn { font-size: 14px; padding: 12px; }
}

/* Landscape phones: keep compact, avoid vertical overflow */
@media (max-height: 520px) and (orientation: landscape) {
	.medieval-entry.si-entry-shell { gap: 12px; padding: 12px; }
	.medieval-entry-hero { min-height: 90px; }
	.si-notes-body { max-height: 70px; }
}

/* Portrait phone layout: one thumb-friendly medieval card, without desktop overflow. */
@media (max-width: 520px) and (orientation: portrait) {
	body.selection-mode {
		background: #090603;
		overflow-y: auto !important;
	}
	body.selection-mode #pagewrapper {
		padding: 0 !important;
		min-height: 100dvh;
	}
	#si-creation-panel {
		width: 100%;
		max-width: none;
		min-height: 100dvh;
		margin: 0;
		border-width: 0 0 3px;
		box-shadow: inset 0 0 0 2px #5c3a22;
		grid-template-rows: auto auto auto 1fr auto;
		gap: 8px;
		padding-bottom: env(safe-area-inset-bottom);
	}
	#si-creation-panel > .medieval-selection-header {
		padding: calc(10px + env(safe-area-inset-top)) 10px 9px;
		gap: 8px;
	}
	#si-creation-panel .selection-title {
		font-size: clamp(18px, 6vw, 24px) !important;
		margin-bottom: 3px;
	}
	#si-creation-panel .selection-subtitle {
		font-size: 9px !important;
		line-height: 1.35;
	}
	#si-creation-panel .medieval-selection-actions {
		display: grid;
		grid-template-columns: repeat(2, minmax(0, 1fr));
		gap: 7px;
	}
	#si-creation-panel .medieval-selection-actions .gamebutton {
		min-height: 38px;
		height: 38px;
		padding: 7px 6px;
		font-size: 9px;
	}
	#si-creation-panel > .si-stepper {
		margin: 0 10px;
		grid-template-columns: repeat(4, minmax(0, 1fr));
		gap: 5px;
		overflow: visible;
	}
	#si-creation-panel .si-step-dot {
		min-width: 0;
		min-height: 46px;
		padding: 5px 2px;
		flex-direction: column;
		gap: 3px;
		font-size: 7px;
		white-space: normal;
	}
	#si-creation-panel .si-step-num {
		width: 19px;
		height: 19px;
		flex-basis: 19px;
	}
	#si-creation-panel > .si-persistent-preview {
		margin: 0 10px;
		padding: 8px;
		grid-template-columns: 78px minmax(0, 1fr);
		grid-template-rows: auto 1fr;
		min-height: 92px;
	}
	.si-persistent-preview .panel-section-title {
		grid-column: 2;
		font-size: 11px !important;
		text-align: left;
		white-space: nowrap;
	}
	.si-persistent-preview .class-preview-stage {
		grid-column: 1;
		grid-row: 1 / 3;
		min-height: 74px;
	}
	.si-persistent-preview .preview-sprite { transform: scale(1.05); }
	.si-persistent-preview > .preview-card {
		grid-column: 2;
		grid-row: 2;
		padding: 6px 7px;
		font-size: 8px;
		overflow: hidden;
	}
	.si-persistent-preview .class-preview-name { font-size: 11px; }
	.si-persistent-preview .class-preview-desc {
		display: -webkit-box;
		-webkit-line-clamp: 2;
		-webkit-box-orient: vertical;
		overflow: hidden;
	}
	#si-creation-panel > .si-wizard { margin: 0 10px; }
	#si-creation-panel .si-step:not(.hidden) {
		min-height: 0;
		padding: 14px 12px;
	}
	#si-creation-panel .panel-section-title {
		font-size: clamp(15px, 4.8vw, 19px);
		margin: 5px 0 13px;
	}
	#si-creation-panel .selectioninput.charactername {
		height: 50px;
		font-size: 14px;
	}
	#si-creation-panel .class-grid {
		grid-template-columns: repeat(2, minmax(0, 1fr));
		gap: 8px;
	}
	#si-creation-panel .chartype {
		min-height: 60px;
		padding: 7px 5px !important;
		font-size: 10px;
	}
	#si-creation-panel .chartype small {
		font-size: 7px;
		color: #b8a17c;
	}
	#si-creation-panel .looks-grid {
		grid-template-columns: repeat(2, minmax(0, 1fr));
		gap: 8px;
	}
	#si-creation-panel .lookstype {
		min-height: 90px;
		padding: 6px !important;
	}
	.si-look-portrait { width: 48px; height: 48px; }
	#si-creation-panel .character-creation-grid { grid-template-columns: 1fr; }
	#si-creation-panel .creation-panel { padding: 0; }
	#si-creation-panel .si-summary-row { min-height: 34px; }
	#si-creation-panel .create-action-row {
		align-items: stretch;
		flex-direction: column;
	}
	#si-creation-panel .create-action-row .gamebutton {
		width: 100%;
		text-align: center;
	}
	#si-creation-panel > .si-wizard-nav {
		margin: 0 10px;
		padding: 8px 0 calc(8px + env(safe-area-inset-bottom));
		height: auto;
		gap: 8px;
		z-index: 8;
	}
	#si-creation-panel > .si-wizard-nav .gamebutton {
		flex: 1 1 0;
		min-height: 48px;
		height: 48px;
		padding: 10px 7px;
	}
}

/* v3 compact creation shell: fixed tracks prevent the step rail from stretching. */
body.entry-mode .pixel-menu-frame,
body.entry-mode #features,
body.entry-mode .selection-features,
body.entry-mode .menu.disableclicks {
	display: none !important;
	visibility: hidden !important;
	pointer-events: none !important;
}

#si-creation-panel {
	width: min(880px, calc(100vw - 32px)) !important;
	height: min(570px, calc(100dvh - 32px));
	min-height: 0 !important;
	max-height: calc(100dvh - 32px) !important;
	grid-template-columns: minmax(0, 1fr) 230px !important;
	grid-template-rows: auto 46px minmax(0, 1fr) 50px !important;
	grid-template-areas:
		"header header"
		"steps preview"
		"wizard preview"
		"nav preview" !important;
	overflow: hidden !important;
}
#si-creation-panel > .medieval-selection-header {
	min-height: 78px;
	box-sizing: border-box;
	padding: 11px 16px !important;
}
#si-creation-panel .selection-title { font-size: 22px !important; margin-bottom: 3px; }
#si-creation-panel .selection-subtitle { font-size: 9px !important; }
#si-creation-panel .medieval-selection-actions {
	flex: 0 0 auto;
	width: auto;
	flex-wrap: nowrap;
}
#si-creation-panel .medieval-selection-actions .gamebutton {
	min-width: 104px !important;
	width: auto !important;
	height: 38px !important;
	min-height: 38px !important;
	padding: 7px 11px !important;
}
#si-creation-panel > .si-stepper {
	height: 38px !important;
	min-height: 38px !important;
	align-self: center;
	margin: 4px 0 4px 12px !important;
	display: grid !important;
	grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
	grid-auto-rows: 38px !important;
	align-items: stretch !important;
}
#si-creation-panel .si-step-dot {
	height: 38px !important;
	min-height: 38px !important;
	max-height: 38px !important;
	box-sizing: border-box !important;
	align-self: start !important;
	padding: 5px 4px !important;
	font-size: 8px !important;
}
#si-creation-panel > .si-wizard {
	min-height: 0;
	height: 100%;
	margin: 0 0 0 12px !important;
	overflow: hidden;
}
#si-creation-panel .si-step:not(.hidden) {
	height: 100% !important;
	min-height: 0 !important;
	max-height: 100% !important;
	padding: 16px 20px !important;
	overflow-y: auto;
}
#si-creation-panel .panel-section-title {
	font-size: 17px !important;
	margin: 5px 0 13px !important;
}
#si-creation-panel .selectioninput.charactername { height: 46px; font-size: 13px; }
#si-creation-panel .creation-help-text { margin-top: 12px; }
#si-creation-panel > .si-persistent-preview {
	height: auto !important;
	min-height: 0 !important;
	margin: 4px 12px 12px 0 !important;
	padding: 10px !important;
	overflow-y: auto;
}
.si-persistent-preview .class-preview-stage { min-height: 132px !important; flex: 0 0 132px; }
.si-persistent-preview .preview-sprite { transform: scale(1.2); }
.si-persistent-preview .preview-card { padding: 6px 7px; font-size: 8px; }
.si-persistent-preview .class-preview-name { font-size: 11px; }
.si-persistent-preview .class-preview-meta { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.si-persistent-preview .preview-card:has(.class-stat-list),
.si-persistent-preview .si-resource-card { display: none; }
#si-creation-panel > .si-wizard-nav {
	height: 42px !important;
	min-height: 42px;
	margin: 4px 0 8px 12px !important;
	padding: 0 !important;
	position: static !important;
	align-self: center;
}
#si-creation-panel > .si-wizard-nav .gamebutton {
	height: 38px !important;
	min-height: 38px !important;
	padding: 7px 12px !important;
}
#si-creation-panel .class-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
#si-creation-panel .chartype { min-height: 52px; padding: 7px 5px !important; font-size: 9px; }
#si-creation-panel .looks-grid { gap: 8px; }
#si-creation-panel .lookstype { min-height: 94px; padding: 7px 5px !important; }
.si-look-portrait { width: 50px; height: 50px; }

/* Installed PWA only: portrait is blocked until the device is rotated. */
.pwa-landscape-lock {
	position: fixed;
	inset: 0;
	z-index: 30000;
	display: grid;
	place-items: center;
	padding: max(20px, env(safe-area-inset-top)) max(20px, env(safe-area-inset-right)) max(20px, env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left));
	box-sizing: border-box;
	background: #090604;
}
.pwa-landscape-lock[hidden] { display: none !important; }
.pwa-landscape-card {
	width: min(330px, 90vw);
	padding: 24px;
	box-sizing: border-box;
	display: grid;
	justify-items: center;
	gap: 12px;
	text-align: center;
	font-family: Pixel, monospace;
	color: #f5d48d;
	background: linear-gradient(180deg, #3f2817, #160e08);
	border: 3px solid #160b05;
	box-shadow: 0 0 0 3px #8d5826;
}
.pwa-landscape-card span { color: #c5af8b; font-size: 10px; line-height: 1.5; }
.pwa-rotate-phone { font-size: 46px; animation: si-phone-turn 1.5s steps(4) infinite; }
@keyframes si-phone-turn { 50% { transform: rotate(90deg); } }
body.pwa-portrait-blocked { overflow: hidden !important; }

@media (max-width: 760px) and (orientation: landscape) {
	#si-creation-panel {
		width: calc(100vw - 20px) !important;
		height: calc(100dvh - 20px) !important;
		max-height: calc(100dvh - 20px) !important;
		grid-template-columns: minmax(0, 1fr) 190px !important;
	}
	#si-creation-panel > .medieval-selection-header { min-height: 62px; padding: 7px 12px !important; }
	#si-creation-panel .selection-title { font-size: 17px !important; }
	#si-creation-panel .selection-subtitle { display: none; }
	#si-creation-panel > .si-stepper { margin-left: 8px !important; }
	#si-creation-panel > .si-wizard { margin-left: 8px !important; }
	#si-creation-panel .si-step:not(.hidden) { padding: 10px 12px !important; }
	#si-creation-panel > .si-persistent-preview { margin-right: 8px !important; padding: 7px !important; display: flex; }
	.si-persistent-preview .class-preview-stage { min-height: 96px !important; flex-basis: 96px; }
	.si-persistent-preview .class-preview-meta { display: none; }
	#si-creation-panel > .si-wizard-nav { margin-left: 8px !important; }
}

@media (max-width: 760px) and (orientation: portrait) {
	#si-creation-panel {
		width: calc(100vw - 20px) !important;
		height: auto !important;
		min-height: calc(100dvh - 20px) !important;
		max-height: none !important;
		grid-template-columns: 1fr !important;
		grid-template-rows: auto 46px auto minmax(280px, auto) 50px !important;
		grid-template-areas: "header" "steps" "preview" "wizard" "nav" !important;
		overflow-y: auto !important;
	}
	#si-creation-panel > .si-stepper { margin: 4px 10px !important; overflow-x: auto; }
	#si-creation-panel > .si-persistent-preview {
		margin: 0 10px 6px !important;
		display: grid;
		grid-template-columns: 100px minmax(0,1fr);
		grid-template-rows: auto auto;
		overflow: hidden;
	}
	.si-persistent-preview .panel-section-title { grid-column: 1 / -1; }
	.si-persistent-preview .class-preview-stage { min-height: 92px !important; height: 92px; grid-row: 2 / 4; }
	.si-persistent-preview .class-preview-meta { display: none; }
	#si-creation-panel > .si-wizard { margin: 0 10px !important; min-height: 280px; }
	#si-creation-panel > .si-wizard-nav { margin: 4px 10px 10px !important; }
	#si-creation-panel .class-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
}

/* Safe areas (notch / home indicator) */
.medieval-entry.si-entry-shell {
	padding-left: max(clamp(14px, 3vw, 38px), env(safe-area-inset-left));
	padding-right: max(clamp(14px, 3vw, 38px), env(safe-area-inset-right));
	padding-top: max(clamp(14px, 3vw, 38px), env(safe-area-inset-top));
}

/* ===================== SELECTION SCREEN ===================== */
.si-select {
	width: min(1040px, 100%);
	margin: 0 auto;
	padding: clamp(14px, 3vw, 34px);
	box-sizing: border-box;
	display: flex;
	flex-direction: column;
	gap: clamp(14px, 2.4vw, 24px);
}
.medieval-selection-header {
	display: flex;
	align-items: flex-end;
	justify-content: space-between;
	gap: 14px;
	flex-wrap: wrap;
}
.medieval-selection-actions {
	display: flex;
	gap: 10px;
	flex-wrap: wrap;
}
.si-char-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(148px, 1fr));
	gap: clamp(12px, 2vw, 20px);
}
.si-char-card {
	font-family: Pixel, monospace;
	text-align: center;
	background:
		linear-gradient(180deg, rgba(255, 255, 255, 0.06), rgba(0, 0, 0, 0.12)),
		var(--si-parch);
	color: #2c1d0d;
	border: 4px solid var(--si-frame);
	border-radius: var(--si-radius);
	box-shadow: var(--si-shadow), inset 0 0 0 2px rgba(255, 255, 255, 0.25);
	padding: 14px 10px 12px;
	cursor: pointer;
	transition: transform 0.1s, box-shadow 0.1s, border-color 0.1s;
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 8px;
}
.si-char-card:hover {
	transform: translateY(-3px);
	border-color: var(--si-gold);
	box-shadow: 0 8px 0 #050308, 0 0 14px rgba(232, 197, 88, 0.4);
}
.si-char-card:active { transform: translateY(1px); }
.si-char-portrait {
	width: 72px;
	height: 72px;
	display: flex;
	align-items: center;
	justify-content: center;
	background: #1c130a;
	border: 3px solid var(--si-frame-light);
	border-radius: 6px;
	image-rendering: pixelated;
	overflow: hidden;
}
.si-char-portrait .cskin { transform: scale(1.15); }
.si-char-name {
	font-size: 14px;
	color: #3a2510;
	word-break: break-word;
	line-height: 1.2;
}
.si-char-meta {
	font-size: 11px;
	color: #6a4a24;
	display: flex;
	gap: 6px;
	align-items: center;
}
.si-char-lv { color: var(--si-gold-deep); }
.si-char-dot { opacity: 0.6; }
.si-char-card-new {
	background:
		linear-gradient(180deg, rgba(255, 255, 255, 0.04), rgba(0, 0, 0, 0.2)),
		#2a1d10;
	color: var(--si-ink);
	border-color: #4a3a22;
	border-style: dashed;
}
.si-char-card-new:hover { border-color: var(--si-gold); }
.si-new-plus {
	font-size: 34px;
	color: var(--si-gold);
	background: transparent;
	border: none;
	line-height: 1;
}
.si-select-foot {
	display: flex;
	justify-content: center;
}

/* ===================== LAUNCH OVERLAY ===================== */
.si-launch {
	position: fixed;
	inset: 0;
	z-index: 55;
	display: flex;
	align-items: center;
	justify-content: center;
	background: radial-gradient(80% 80% at 50% 45%, #1a1230 0%, #0a0716 70%, #05030c 100%);
}
.si-launch.hidden { display: none !important; }
.si-launch-inner {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 12px;
	text-align: center;
	padding: 24px;
}
.si-launch-logo {
	width: 72px;
	height: 72px;
	image-rendering: pixelated;
	animation: si-float 2.4s ease-in-out infinite;
}
.si-launch-title {
	font-family: Pixel, monospace;
	font-size: 26px;
	color: var(--si-gold);
	text-shadow: 0 3px 0 #1a0f06;
}
.si-launch-status {
	font-family: Pixel, monospace;
	font-size: 12px;
	color: var(--si-ink-dim);
}
.si-launch-bar {
	width: min(300px, 70vw);
	height: 14px;
	border: 3px solid var(--si-frame-light);
	border-radius: 999px;
	background: rgba(0, 0, 0, 0.5);
	overflow: hidden;
	box-shadow: inset 0 0 0 2px rgba(0, 0, 0, 0.5);
}
.si-launch-fill {
	height: 100%;
	width: 0%;
	background: linear-gradient(90deg, #e8c558, #b98a2e);
	transition: width 0.25s ease;
}

/* ===================== CREATION WIZARD ===================== */
#si-creation-panel {
	width: min(1040px, 100%);
	margin: 0 auto;
	padding: clamp(14px, 3vw, 34px);
	box-sizing: border-box;
	display: flex;
	flex-direction: column;
	gap: clamp(12px, 2vw, 20px);
}
.si-stepper {
	list-style: none;
	display: flex;
	gap: 8px;
	flex-wrap: wrap;
	padding: 0;
	margin: 0;
}
.si-step-dot {
	font-family: Pixel, monospace;
	font-size: 12px;
	color: var(--si-ink-dim);
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 6px 12px;
	border: 2px solid var(--si-frame-light);
	border-radius: 999px;
	background: rgba(20, 12, 6, 0.55);
}
.si-step-num {
	width: 18px;
	height: 18px;
	border-radius: 50%;
	background: #3a2a16;
	color: var(--si-ink-dim);
	display: inline-flex;
	align-items: center;
	justify-content: center;
	font-size: 11px;
	border: 1px solid var(--si-frame-light);
}
.si-step-dot.active {
	color: var(--si-ink);
	border-color: var(--si-gold);
	box-shadow: 0 0 10px rgba(232, 197, 88, 0.3);
}
.si-step-dot.active .si-step-num {
	background: var(--si-gold);
	color: #2a1c0c;
}
.si-step-dot.done {
	color: #9bdc8f;
	border-color: #4f7a3e;
}
.si-step-dot.done .si-step-num {
	background: #4f7a3e;
	color: #eafbe6;
}
.si-wizard { display: block; }
.si-step:not(.hidden) {
	background:
		linear-gradient(180deg, rgba(255, 255, 255, 0.05), rgba(0, 0, 0, 0.1)),
		var(--si-parch);
	border: 4px solid var(--si-frame);
	border-radius: var(--si-radius);
	box-shadow: var(--si-shadow), inset 0 0 0 2px rgba(255, 255, 255, 0.22);
	padding: 18px;
}
.si-summary {
	display: flex;
	flex-direction: column;
	gap: 6px;
	margin: 8px 0 12px;
}
.si-summary-row {
	display: flex;
	justify-content: space-between;
	font-family: Pixel, monospace;
	font-size: 13px;
	color: #3a2510;
	border-bottom: 1px dashed rgba(120, 84, 36, 0.4);
	padding-bottom: 4px;
}
.si-summary-row span { color: #6a4a24; }
.si-wizard-nav {
	display: flex;
	justify-content: space-between;
	gap: 12px;
}

/* ===================== SELECTION RESPONSIVE ===================== */
@media (max-width: 860px) {
	.si-select,
	#si-creation-panel {
		padding: 16px 14px calc(16px + env(safe-area-inset-bottom));
	}
	.medieval-selection-header { justify-content: center; text-align: center; }
	.medieval-selection-actions { justify-content: center; }
	.si-char-grid { grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); }
}
@media (max-width: 560px) {
	.si-char-grid { grid-template-columns: repeat(2, 1fr); }
	.si-char-portrait { width: 60px; height: 60px; }
	.si-step-dot { font-size: 11px; padding: 5px 9px; }
}
@media (max-height: 520px) and (orientation: landscape) {
	.si-select, #si-creation-panel { gap: 10px; padding: 12px; }
	.si-char-grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
}

/* ===================== HIDE IN-GAME HUD ON ENTRY SCREENS ===================== */
body.entry-mode #toprightcorner,
body.entry-mode #bottomrightcorner,
body.entry-mode #bottomrightcodecorner,
body.entry-mode #bottomleftcorner,
body.entry-mode #bottomleftcorner2,
body.entry-mode #bottommid,
body.entry-mode #topmid,
body.entry-mode #targetframe,
body.entry-mode #cooldown-tracker,
body.entry-mode #action-notice-anchor,
body.entry-mode #chat-box-container,
body.entry-mode .medieval-skillbar-row,
body.entry-mode .top-menu-buttons,
body.entry-mode .settings,
body.entry-mode .chat-toggle-btn,
body.entry-mode .menu.disableclicks,
body.entry-mode #medieval-menu-bar {
	display: none !important;
}

body.entry-mode .pixel-menu-frame,
body.entry-mode #topui.hidden,
body.entry-mode #backbutton.hidden,
body.entry-mode .onback-hide.hidden {
	display: none !important;
}

/* ===================== SELECTION / CREATION: FIT & SCROLL ===================== */
body.selection-mode #pagewrapper {
	align-items: start;
	max-height: 100vh;
	overflow-y: auto;
	padding: 12px 0;
}
#si-creation-panel {
	max-height: calc(100vh - 24px);
	overflow-y: auto;
}
.character-creation-grid {
	grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr);
	align-items: start;
}
@media (max-width: 760px) {
	.character-creation-grid { grid-template-columns: 1fr; }
}

/* ============================================================
   Entry UI v2 — mirrors the compact wood-and-gold gameplay HUD
   ============================================================ */
body.selection-mode #pagewrapper {
	background: rgba(5, 4, 3, 0.3) !important;
	padding: max(14px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(14px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
	box-sizing: border-box;
}
body.selection-mode #pagewrapped.loginorselection {
	width: min(1040px, 100%) !important;
	margin: 0 auto !important;
	padding: 0 !important;
	background: transparent !important;
	border: 0 !important;
	box-shadow: none !important;
}

#si-creation-panel,
.si-select {
	width: min(1000px, 100%);
	padding: 0;
	gap: 14px;
}
#si-creation-panel {
	display: grid;
	grid-template-columns: minmax(0, 1fr) 270px;
	grid-template-areas:
		"header header"
		"steps preview"
		"wizard preview"
		"nav preview";
	background:
		linear-gradient(180deg, rgba(42, 27, 16, 0.98), rgba(13, 9, 6, 0.98)),
		repeating-linear-gradient(0deg, #26180f 0 4px, #2c1d13 4px 8px);
	border: 3px solid #160b05;
	box-shadow: 0 0 0 3px #8d5826, 0 0 0 6px #211006, 0 18px 40px rgba(0,0,0,.58);
	clip-path: polygon(10px 0, calc(100% - 10px) 0, 100% 10px, 100% calc(100% - 10px), calc(100% - 10px) 100%, 10px 100%, 0 calc(100% - 10px), 0 10px);
	max-height: calc(100dvh - 28px);
	overflow: auto;
	box-sizing: border-box;
}
#si-creation-panel > .medieval-selection-header {
	grid-area: header;
	margin: 0;
	padding: 18px 20px 15px;
	align-items: center;
	background: linear-gradient(180deg, rgba(71,45,25,.96), rgba(36,22,13,.98));
	border-bottom: 3px solid #120905;
	box-shadow: inset 0 -2px 0 #8d5826;
}
#si-creation-panel .selection-title,
.si-select .selection-title {
	font-size: clamp(22px, 3vw, 32px) !important;
	line-height: 1.15;
	margin: 2px 0 6px;
	color: #f5d48d !important;
	text-shadow: 3px 3px 0 #160b05;
}
#si-creation-panel .selection-subtitle,
.si-select .selection-subtitle {
	font-size: 11px !important;
	line-height: 1.45;
	margin: 0;
	color: #c6ae87 !important;
}
.medieval-entry-kicker,
.si-step-kicker {
	font-family: Pixel, monospace;
	font-size: 9px;
	letter-spacing: 2px;
	text-transform: uppercase;
	color: #c68b3f;
}

#si-creation-panel > .si-stepper {
	grid-area: steps;
	margin: 4px 0 0 18px;
	padding: 0;
	display: grid;
	grid-template-columns: repeat(4, minmax(0, 1fr));
	gap: 7px;
}
#si-creation-panel .si-step-dot {
	min-width: 0;
	justify-content: center;
	padding: 8px 6px;
	border: 2px solid #2a1509;
	border-radius: 0;
	background: linear-gradient(180deg, #51331d, #2b1a0f);
	box-shadow: 0 0 0 1px #8d5826;
	color: #c8b18c;
	font-size: 10px;
	white-space: nowrap;
}
#si-creation-panel .si-step-dot.active {
	background: linear-gradient(180deg, #a76d32, #70431e);
	box-shadow: 0 0 0 2px #d5a24c, inset 0 2px 0 rgba(255,255,255,.14);
	color: #fff0c6;
}
#si-creation-panel .si-step-dot.done {
	background: linear-gradient(180deg, #3f6635, #294522);
	box-shadow: 0 0 0 1px #78a55f;
}
#si-creation-panel .si-step-num {
	width: 18px;
	height: 18px;
	flex: 0 0 18px;
	border-radius: 0;
	border: 1px solid #120905;
	background: #1b1009;
	color: #f0ce83;
}

#si-creation-panel > .si-wizard {
	grid-area: wizard;
	margin-left: 18px;
}
#si-creation-panel .si-step:not(.hidden) {
	min-height: 250px;
	box-sizing: border-box;
	padding: clamp(18px, 3vw, 30px);
	background: linear-gradient(180deg, rgba(31,20,12,.98), rgba(14,9,6,.98));
	border: 2px solid #160b05;
	border-radius: 0;
	box-shadow: inset 0 0 0 2px #5c3a22;
	color: #ead9b8;
}
#si-creation-panel .panel-section-title {
	font-family: Pixel, monospace;
	font-size: clamp(17px, 2.3vw, 23px);
	line-height: 1.25;
	color: #f5d48d;
	text-shadow: 2px 2px #100804;
	margin: 7px 0 20px;
}
.si-name-field {
	display: grid;
	gap: 8px;
	max-width: 470px;
	font-family: Pixel, monospace;
	font-size: 10px;
	color: #bfa88a;
	text-transform: uppercase;
	letter-spacing: 1px;
}
#si-creation-panel .selectioninput.charactername {
	box-sizing: border-box;
	width: 100%;
	height: 52px;
	padding: 0 14px;
	font-family: Pixel, monospace;
	font-size: 16px;
	color: #fff0cb;
	background: #0c0805;
	border: 3px solid #2a1509;
	box-shadow: 0 0 0 2px #8d5826, inset 0 3px 0 rgba(0,0,0,.55);
	outline: none;
}
#si-creation-panel .selectioninput.charactername:focus {
	box-shadow: 0 0 0 2px #d5a24c, 0 0 16px rgba(213,162,76,.2);
}
#si-creation-panel .creation-help-text,
#si-creation-panel .preview-muted {
	font-family: Pixel, monospace;
	font-size: 10px;
	line-height: 1.55;
	color: #9f8a6e !important;
	margin-top: 16px;
}

#si-creation-panel .class-grid {
	display: grid;
	grid-template-columns: repeat(3, minmax(0, 1fr));
	gap: 10px;
}
#si-creation-panel .chartype,
#si-creation-panel .lookstype {
	position: relative;
	min-height: 66px;
	box-sizing: border-box;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 10px 8px !important;
	margin: 0 !important;
	font-family: Pixel, monospace;
	font-size: 11px;
	line-height: 1.25;
	text-align: center;
	text-decoration: none;
	color: #e8d6b4 !important;
	background: linear-gradient(180deg, #634124 0 12%, #3d2515 12% 78%, #26160c 78% 100%);
	border: 3px solid #120905 !important;
	box-shadow: 0 0 0 2px #8d5826, inset 0 2px 0 rgba(255,255,255,.08);
	cursor: pointer;
}
#si-creation-panel .chartype::before {
	content: "◆";
	margin-right: 7px;
	color: #d5a24c;
}
#si-creation-panel .chartype:hover,
#si-creation-panel .lookstype:hover {
	filter: brightness(1.14);
	transform: translateY(-2px);
}
#si-creation-panel .chartype.selected,
#si-creation-panel .lookstype.selected {
	color: #fff4d6 !important;
	background: linear-gradient(180deg, #a5682e 0 12%, #71421e 12% 78%, #43240f 78% 100%);
	box-shadow: 0 0 0 3px #e0b157, 0 0 14px rgba(224,177,87,.28);
}
#si-creation-panel .looks-grid {
	display: grid;
	grid-template-columns: repeat(4, minmax(0, 1fr));
	gap: 10px;
}
#si-creation-panel .lookstype {
	min-height: 108px;
	flex-direction: column;
	gap: 7px;
}
.si-look-portrait {
	width: 58px;
	height: 58px;
	display: flex;
	align-items: center;
	justify-content: center;
	overflow: hidden;
	background: #100a06;
	border: 2px solid #211006;
	box-shadow: inset 0 0 0 2px #6b4324;
	image-rendering: pixelated;
}

#si-creation-panel > .si-persistent-preview {
	grid-area: preview;
	margin: 4px 18px 18px 0;
	padding: 16px;
	box-sizing: border-box;
	background: linear-gradient(180deg, #21150d, #0d0906);
	border: 2px solid #160b05 !important;
	box-shadow: inset 0 0 0 2px #5c3a22 !important;
	display: flex;
	flex-direction: column;
	gap: 10px;
}
.si-persistent-preview .panel-section-title {
	font-size: 15px !important;
	text-align: center;
	margin: 0 0 2px !important;
}
.si-persistent-preview .class-preview-stage {
	min-height: 160px;
	display: flex;
	align-items: center;
	justify-content: center;
	background: radial-gradient(circle, rgba(191,132,54,.18), transparent 54%), #0b0705;
	border: 2px solid #160b05;
	box-shadow: inset 0 0 0 2px #6a4223;
	overflow: hidden;
}
.si-persistent-preview .preview-sprite {
	transform: scale(1.45);
	image-rendering: pixelated;
}
.si-persistent-preview .preview-card {
	padding: 8px 9px;
	background: #120c08 !important;
	border: 1px solid #4e301a !important;
	box-shadow: none !important;
	font-family: Pixel, monospace;
	font-size: 9px;
	line-height: 1.4;
	color: #ad9879;
}
.si-persistent-preview .class-preview-name { color: #f1cb7c; font-size: 13px; }
.si-persistent-preview .class-preview-desc { margin-top: 5px; }
.si-persistent-preview .class-preview-meta { display: grid; grid-template-columns: 1fr; gap: 8px; }
.si-persistent-preview .class-stat-list { display: grid; grid-template-columns: repeat(2, 1fr); gap: 4px; }
.si-persistent-preview .class-stat-pill { display: flex; justify-content: space-between; color: #e0c493; }

#si-creation-panel > .si-wizard-nav {
	grid-area: nav;
	margin: 0 0 18px 18px;
	height: 48px;
	align-self: start;
	align-items: center;
}
#si-creation-panel .gamebutton,
.si-select .gamebutton {
	min-height: 44px;
	height: 44px;
	box-sizing: border-box;
	padding: 10px 16px;
	font-family: Pixel, monospace;
	font-size: 11px;
	color: #f7e7c1 !important;
	background: linear-gradient(180deg, #7a522d, #4b2d18) !important;
	border: 3px solid #2a1509 !important;
	box-shadow: 0 0 0 2px #9e6a35 !important;
}

/* Character selection: same visual grammar as the top-right HUD buttons. */
.si-select {
	padding: 18px;
	background: linear-gradient(180deg, rgba(37,24,15,.98), rgba(13,9,6,.98));
	border: 3px solid #160b05;
	box-shadow: 0 0 0 3px #8d5826, 0 0 0 6px #211006, 0 18px 40px rgba(0,0,0,.58);
}
.si-select .medieval-selection-header { align-items: center; }
.si-char-grid { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
.si-char-card {
	min-height: 190px;
	padding: 12px;
	background: linear-gradient(180deg, #50321c, #24150c) !important;
	border: 3px solid #120905 !important;
	border-radius: 0;
	box-shadow: 0 0 0 2px #8d5826, inset 0 2px 0 rgba(255,255,255,.06);
	color: #ead9b8;
}
.si-char-card:hover { border-color: #120905; box-shadow: 0 0 0 3px #e0b157, 0 8px 18px rgba(0,0,0,.5); }
.si-char-portrait { width: 92px; height: 92px; border-radius: 0; border: 2px solid #160b05; box-shadow: inset 0 0 0 2px #6a4223; }
.si-char-name { color: #f5d48d; font-size: 14px; }
.si-char-meta { color: #bda883; }
.si-char-card-new { border-style: dashed !important; background: linear-gradient(180deg, #302217, #181009) !important; }

/* Login polish: preserve the existing light composition, only sharpen its HUD frame. */
.si-login-row .si-card {
	background: linear-gradient(180deg, rgba(255,255,255,.05), rgba(0,0,0,.1)), var(--si-parch);
	border: 4px solid var(--si-frame);
	border-radius: 0;
	box-shadow: 0 0 0 2px #2a1509, 0 12px 26px rgba(0,0,0,.48), inset 0 0 0 2px rgba(255,255,255,.22);
	color: #2c1d0d;
}
.si-login-row .si-card-lead,
.si-login-row .si-trust-list li,
.si-login-row .si-notes-body { color: #5a3d1d; }
.si-login-row .si-notes-ribbon { border-radius: 0; background: linear-gradient(180deg, #7a522d, #4b2d18); }

@media (max-width: 760px) {
	body.selection-mode #pagewrapper { align-items: flex-start; }
	#si-creation-panel {
		grid-template-columns: 1fr;
		grid-template-areas: "header" "steps" "preview" "wizard" "nav";
		max-height: none;
		min-height: calc(100dvh - 28px);
	}
	#si-creation-panel > .medieval-selection-header { padding: 14px; }
	#si-creation-panel .medieval-selection-actions { width: 100%; justify-content: stretch; }
	#si-creation-panel .medieval-selection-actions > * { flex: 1 1 auto; min-width: 0; }
	#si-creation-panel > .si-stepper { margin: 3px 12px 0; overflow-x: auto; grid-template-columns: repeat(4, minmax(92px, 1fr)); }
	#si-creation-panel > .si-persistent-preview {
		margin: 0 12px;
		padding: 10px;
		display: grid;
		grid-template-columns: 112px minmax(0,1fr);
		grid-template-rows: auto auto 1fr;
		gap: 7px 10px;
	}
	.si-persistent-preview .panel-section-title { grid-column: 1 / -1; text-align: left; }
	.si-persistent-preview .class-preview-stage { grid-row: 2 / 4; min-height: 116px; }
	.si-persistent-preview .preview-card { min-width: 0; }
	.si-persistent-preview .class-preview-meta,
	.si-persistent-preview .preview-card:has(.class-stat-list),
	.si-persistent-preview .si-resource-card { display: none; }
	#si-creation-panel > .si-wizard { margin: 0 12px; }
	#si-creation-panel .si-step:not(.hidden) { min-height: 280px; padding: 18px 14px; }
	#si-creation-panel > .si-wizard-nav { margin: 0 12px 14px; position: sticky; bottom: 0; padding: 10px 0; background: #140d08; }
	#si-creation-panel .class-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
	#si-creation-panel .looks-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
	.si-select { padding: 14px 12px; min-height: calc(100dvh - 28px); box-sizing: border-box; }
	.si-char-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
	.si-char-card { min-height: 162px; padding: 9px 6px; }
	.si-char-portrait { width: 70px; height: 70px; }
}

@media (max-height: 520px) and (orientation: landscape) {
	#si-creation-panel {
		grid-template-columns: minmax(0,1fr) 210px;
		grid-template-areas: "header header" "steps preview" "wizard preview" "nav preview";
		max-height: calc(100dvh - 16px);
		min-height: 0;
	}
	#si-creation-panel > .medieval-selection-header { padding: 9px 14px; }
	#si-creation-panel .selection-subtitle { display: none; }
	#si-creation-panel > .si-stepper { margin-left: 12px; }
	#si-creation-panel > .si-wizard { margin-left: 12px; }
	#si-creation-panel .si-step:not(.hidden) { min-height: 185px; padding: 13px; }
	#si-creation-panel > .si-persistent-preview { display: flex; margin: 3px 12px 12px 0; }
	.si-persistent-preview .class-preview-stage { min-height: 112px; }
	.si-persistent-preview .preview-card:has(.class-stat-list), .si-persistent-preview .si-resource-card { display: none; }
	#si-creation-panel > .si-wizard-nav { margin: 0 0 12px 12px; padding: 0; position: static; }
}

/* Final portrait overrides live last so older desktop compatibility rules cannot win. */
@media (max-width: 520px) and (orientation: portrait) {
	body.selection-mode { background: #090603; overflow-y: auto !important; }
	body.selection-mode #pagewrapper { padding: 0 !important; min-height: 100dvh; align-items: flex-start; }
	#si-creation-panel {
		width: 100%;
		max-width: none;
		min-height: 100dvh;
		margin: 0;
		border-width: 0 0 3px;
		grid-template-columns: 1fr;
		grid-template-rows: auto auto auto 1fr auto;
		grid-template-areas: "header" "steps" "preview" "wizard" "nav";
		gap: 8px;
		padding-bottom: env(safe-area-inset-bottom);
		box-shadow: inset 0 0 0 2px #5c3a22;
	}
	#si-creation-panel > .medieval-selection-header {
		min-height: 0;
		padding: calc(10px + env(safe-area-inset-top)) 10px 9px !important;
		gap: 8px;
	}
	#si-creation-panel .selection-title { font-size: clamp(18px, 6vw, 24px) !important; margin-bottom: 3px; }
	#si-creation-panel .selection-subtitle { font-size: 9px !important; line-height: 1.35; }
	#si-creation-panel .medieval-selection-actions {
		width: 100%;
		display: grid;
		grid-template-columns: repeat(2, minmax(0, 1fr));
		gap: 7px;
	}
	#si-creation-panel .medieval-selection-actions .gamebutton {
		width: 100% !important;
		min-width: 0 !important;
		min-height: 38px !important;
		height: 38px !important;
		padding: 7px 5px !important;
		font-size: 9px;
	}
	#si-creation-panel > .si-stepper {
		margin: 0 10px;
		grid-template-columns: repeat(4, minmax(0, 1fr));
		gap: 5px;
		overflow: visible;
	}
	#si-creation-panel .si-step-dot {
		min-width: 0;
		min-height: 46px;
		padding: 5px 2px;
		flex-direction: column;
		gap: 3px;
		font-size: 7px;
		white-space: normal;
	}
	#si-creation-panel .si-step-num { width: 19px; height: 19px; flex-basis: 19px; }
	#si-creation-panel > .si-persistent-preview {
		margin: 0 10px;
		padding: 8px;
		display: grid;
		grid-template-columns: 78px minmax(0, 1fr);
		grid-template-rows: auto 1fr;
		gap: 5px 8px;
		min-height: 92px;
	}
	.si-persistent-preview .panel-section-title {
		grid-column: 2;
		font-size: 11px !important;
		text-align: left;
		white-space: nowrap;
	}
	.si-persistent-preview .class-preview-stage {
		grid-column: 1;
		grid-row: 1 / 3;
		min-height: 74px;
	}
	.si-persistent-preview .preview-sprite { transform: scale(1.05); }
	.si-persistent-preview > .preview-card {
		grid-column: 2;
		grid-row: 2;
		padding: 6px 7px;
		font-size: 8px;
		min-width: 0;
		overflow: hidden;
	}
	.si-persistent-preview .class-preview-name { font-size: 11px; }
	.si-persistent-preview .class-preview-desc {
		display: -webkit-box;
		-webkit-line-clamp: 2;
		-webkit-box-orient: vertical;
		overflow: hidden;
	}
	.si-persistent-preview .class-preview-meta,
	.si-persistent-preview .preview-card:has(.class-stat-list),
	.si-persistent-preview .si-resource-card { display: none; }
	#si-creation-panel > .si-wizard { margin: 0 10px; }
	#si-creation-panel .si-step:not(.hidden) { min-height: 0; padding: 14px 12px; }
	#si-creation-panel .panel-section-title { font-size: clamp(15px, 4.8vw, 19px); margin: 5px 0 13px; }
	#si-creation-panel .selectioninput.charactername { height: 50px; font-size: 14px; }
	#si-creation-panel .class-grid,
	#si-creation-panel .looks-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
	#si-creation-panel .chartype { min-height: 60px; padding: 7px 5px !important; font-size: 10px; }
	#si-creation-panel .chartype small { font-size: 7px; color: #b8a17c; }
	#si-creation-panel .lookstype { min-height: 90px; padding: 6px !important; }
	.si-look-portrait { width: 48px; height: 48px; }
	#si-creation-panel .character-creation-grid { grid-template-columns: 1fr; }
	#si-creation-panel .creation-panel { padding: 0; }
	#si-creation-panel .create-action-row { align-items: stretch; flex-direction: column; }
	#si-creation-panel .create-action-row .gamebutton { width: 100%; text-align: center; }
	#si-creation-panel > .si-wizard-nav {
		margin: 0 10px;
		padding: 8px 0 calc(8px + env(safe-area-inset-bottom));
		height: auto;
		gap: 8px;
		position: sticky;
		bottom: 0;
		z-index: 8;
		background: #140d08;
	}
	#si-creation-panel > .si-wizard-nav .gamebutton {
		flex: 1 1 0;
		min-width: 0 !important;
		min-height: 48px;
		height: 48px;
		padding: 10px 7px;
	}
}
