body.title-screen-active #top-header,
body.title-screen-active .container,
body.title-screen-active .journal-bar,
body.title-screen-active #achievementsDialog,
body.title-screen-active #metaProgressDialog,
body.title-screen-active #gameOverDialog {
	visibility: hidden;
}

.title-screen {
	position: fixed;
	inset: 0;
	z-index: 4000;
	display: none;
	align-items: center;
	justify-content: center;
	padding: 24px;
	background:
		radial-gradient(circle at 18% 22%, rgba(204, 122, 53, 0.35) 0%, rgba(204, 122, 53, 0) 45%),
		radial-gradient(circle at 82% 75%, rgba(48, 126, 140, 0.42) 0%, rgba(48, 126, 140, 0) 50%),
		linear-gradient(145deg, #0f1a24 0%, #182939 45%, #1d2f3f 100%);
}

body.title-screen-active .title-screen {
	display: flex;
}

.title-screen-card {
	width: min(1080px, 100%);
	max-height: calc(100vh - 48px);
	padding: clamp(24px, 4vw, 42px);
	border-radius: 20px;
	border: 1px solid rgba(255, 255, 255, 0.24);
	background: rgba(12, 19, 28, 0.84);
	box-shadow: 0 20px 48px rgba(2, 7, 14, 0.55);
	backdrop-filter: blur(6px);
	text-align: left;
	overflow: auto;
	box-sizing: border-box;
}

.title-screen-kicker {
	margin: 0;
	color: #98d2de;
	text-transform: uppercase;
	letter-spacing: 0.08em;
	font-size: 0.76rem;
	font-weight: 700;
}

.title-screen-card h1 {
	margin: 8px 0 6px;
	font-size: clamp(2rem, 6vw, 3.3rem);
	line-height: 1.05;
	color: #f3f7ff;
}

.title-screen-subtitle {
	margin: 0;
	max-width: 52ch;
	color: #c8d3e5;
	line-height: 1.5;
}


.title-save-preview {
	display: block;
	width: 100%;
	margin-top: 14px;
	padding: 14px 16px;
	box-sizing: border-box;
	border-radius: 14px;
	border: 1px solid rgba(255, 255, 255, 0.12);
	background: rgba(255, 255, 255, 0.05);
	color: #e7eef9;
}

.title-save-preview.is-empty {
	opacity: 0.92;
}

.title-save-preview.has-save {
	border-color: rgba(152, 210, 222, 0.24);
	background: rgba(152, 210, 222, 0.08);
}

.title-save-preview-actions {
	display: flex;
	flex-wrap: wrap;
	gap: 10px;
	margin-top: 14px;
	width: 100%;
	min-width: 0;
	box-sizing: border-box;
}

.title-save-preview.is-empty .title-save-preview-actions {
	justify-content: center;
}

.title-save-preview-action {
	flex: 1 1 130px;
	min-width: 130px;
	max-width: 100%;
	box-sizing: border-box;
}

.title-save-preview-action--primary {
	flex-basis: 180px;
	min-width: 180px;
}

.title-save-preview-action--icon {
	min-width: 0;
	min-width: 38px;
	width: 38px;
	height: 36px;
	padding: 0;
	flex: 0 0 38px;
}

.title-save-preview.has-save .title-save-preview-action--icon {
	margin-left: 0;
}

.title-save-preview-action--icon .menu-btn-icon {
	width: 28px;
	height: 28px;
}

.title-save-preview-action--danger {
	background: rgba(149, 34, 34, 0.28);
	border-color: rgba(214, 102, 102, 0.4);
}

.title-save-preview-action--danger:hover,
.title-save-preview-action--danger:focus-visible {
	background: rgba(173, 49, 49, 0.4);
}

.title-save-preview-headline {
	font-size: 1.05rem;
	font-weight: 700;
}

.title-save-preview-detail {
	margin-top: 4px;
	color: #b9cade;
	font-size: 0.88rem;
}

.title-save-preview-grid {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
	gap: 10px;
	margin-top: 14px;
	width: 100%;
	min-width: 0;
}

.title-save-preview-stat {
	display: grid;
	gap: 4px;
	padding: 10px;
	min-width: 0;
	box-sizing: border-box;
	border-radius: 10px;
	background: rgba(11, 18, 26, 0.45);
}

.title-save-preview-stat span,
.title-save-preview-empty span {
	font-size: 0.75rem;
	text-transform: uppercase;
	letter-spacing: 0.04em;
	color: #9fb5cb;
}

.title-save-preview-stat strong,
.title-save-preview-empty strong {
	font-size: 0.98rem;
	color: #f3f7ff;
}

.title-save-preview-empty {
	display: grid;
	gap: 6px;
}

.title-pack-panel {
	margin-top: 18px;
	padding: 14px 16px;
	border-radius: 14px;
	border: 1px solid rgba(255, 255, 255, 0.12);
	background: rgba(255, 255, 255, 0.04);
}

.title-content-pack-grid {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
	gap: 14px;
	align-items: stretch;
}

.title-pack-card {
	display: grid;
	grid-template-rows: auto auto minmax(0, 1fr);
	gap: 12px;
	padding: 16px;
	border-radius: 16px;
	border: 1px solid rgba(255, 255, 255, 0.14);
	background:
		linear-gradient(180deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.02)),
		rgba(10, 16, 24, 0.82);
	color: #edf5ff;
	min-height: 100%;
	min-width: 0;
	box-sizing: border-box;
}

.title-pack-card-header {
	display: grid;
	gap: 4px;
}

.title-pack-card-eyebrow {
	font-size: 0.72rem;
	font-weight: 700;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	color: #98d2de;
}

.title-pack-card-title {
	margin: 0;
	font-size: 1.25rem;
	color: #f4f8ff;
}

.title-pack-card-meta {
	font-size: 0.78rem;
	color: #9fb5cb;
}

.title-pack-card-description {
	margin: 0;
	min-height: 3.6em;
	color: #c8d3e5;
	line-height: 1.45;
	overflow-wrap: anywhere;
}

.title-pack-panel-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	margin-bottom: 10px;
}

.title-pack-panel-header h2 {
	margin: 0;
	font-size: 0.92rem;
	color: #e9efff;
}

.title-pack-hint {
	font-size: 0.75rem;
	color: #9fb5cb;
	text-align: right;
}

.title-save-preview-content {
	min-width: 0;
	width: 100%;
}

.title-screen-actions {
	display: grid;
	grid-template-columns: repeat(3, minmax(0, 1fr));
	gap: 10px;
	margin-top: 24px;
}

.title-screen-btn {
	margin-top: 0;
	min-height: 44px;
}

.title-screen-btn[disabled] {
	opacity: 0.56;
	cursor: not-allowed;
}

.title-screen-btn:focus-visible,
.title-setting-row:has(input:focus-visible),
.title-pack-card:has(button:focus-visible) {
	outline: 2px solid #9ee1ef;
	outline-offset: 3px;
	box-shadow: 0 0 0 4px rgba(110, 192, 208, 0.22);
}

.title-screen-hint {
	margin: 12px 0 0;
	color: #adc0d8;
	font-size: 0.84rem;
	line-height: 1.45;
}

.title-settings-panel {
	margin-top: 22px;
	padding-top: 18px;
	border-top: 1px solid rgba(255, 255, 255, 0.12);
	display: grid;
	gap: 10px;
}

.title-settings-panel h2 {
	margin: 0;
	font-size: 0.92rem;
	color: #e9efff;
}

.title-setting-row {
	display: flex;
	align-items: center;
	gap: 10px;
	color: #c8d3e5;
	font-size: 0.88rem;
}

.title-setting-row input {
	width: 16px;
	height: 16px;
	accent-color: #77b9c7;
}

body.pref-large-text {
	font-size: 18px;
}

body.pref-reduced-motion *,
body.pref-reduced-motion *::before,
body.pref-reduced-motion *::after {
	animation-duration: 0.01ms !important;
	animation-iteration-count: 1 !important;
	transition-duration: 0.01ms !important;
	scroll-behavior: auto !important;
}

.tutorial-overlay {
	position: fixed;
	inset: 0;
	z-index: 4500;
	pointer-events: none;
	display: grid;
	place-items: end center;
	padding: 18px;
	box-sizing: border-box;
}

.tutorial-overlay[hidden] {
	display: none;
}

.tutorial-overlay-backdrop {
	position: absolute;
	inset: 0;
	background: rgba(6, 12, 19, 0.32);
	opacity: 0;
	transition: opacity 140ms ease;
}

.tutorial-overlay.is-blocking {
	pointer-events: auto;
}

.tutorial-overlay.is-blocking .tutorial-overlay-backdrop {
	opacity: 1;
}

.tutorial-overlay-card {
	position: relative;
	width: min(460px, calc(100vw - 24px));
	padding: 16px 16px 14px;
	border-radius: 14px;
	border: 1px solid rgba(160, 208, 219, 0.42);
	background: rgba(11, 19, 29, 0.94);
	box-shadow: 0 18px 40px rgba(2, 9, 16, 0.5);
	pointer-events: auto;
	color: #e6efff;
}

.tutorial-overlay-card h2 {
	margin: 0;
	font-size: 1rem;
	line-height: 1.2;
}

.tutorial-overlay-card p {
	margin: 8px 0 0;
	line-height: 1.45;
	font-size: 0.9rem;
	color: #c7d6ec;
}

.tutorial-overlay-hint {
	font-size: 0.8rem !important;
	color: #96afcb !important;
}

.tutorial-overlay-actions {
	margin-top: 12px;
	display: flex;
	gap: 8px;
	flex-wrap: wrap;
}

.tutorial-overlay-actions .menu-btn {
	margin-top: 0;
	flex: 1 1 120px;
}

.tutorial-overlay-continue {
	background: rgba(66, 129, 151, 0.35);
	border-color: rgba(124, 187, 209, 0.6);
}

.tutorial-target-highlight {
	position: relative;
	z-index: 4510;
	outline: 3px solid #ffd36b !important;
	outline-offset: 3px;
	box-shadow:
		0 0 0 5px rgba(255, 211, 107, 0.38),
		0 0 0 10px rgba(255, 211, 107, 0.2),
		0 0 24px rgba(255, 211, 107, 0.42);
	border-radius: 8px;
	animation: tutorial-highlight-pulse 1.35s ease-in-out infinite;
}

@keyframes tutorial-highlight-pulse {
	0%, 100% {
		box-shadow:
			0 0 0 5px rgba(255, 211, 107, 0.34),
			0 0 0 10px rgba(255, 211, 107, 0.18),
			0 0 20px rgba(255, 211, 107, 0.35);
	}
	50% {
		box-shadow:
			0 0 0 6px rgba(255, 211, 107, 0.5),
			0 0 0 12px rgba(255, 211, 107, 0.26),
			0 0 28px rgba(255, 211, 107, 0.5);
	}
}

body.pref-reduced-motion .tutorial-overlay-backdrop,
body.pref-reduced-motion .tutorial-target-highlight {
	transition: none;
}

@media (prefers-reduced-motion: reduce) {
	.tutorial-overlay-backdrop,
	.tutorial-target-highlight {
		transition: none !important;
		animation: none !important;
	}
}

/* Screen-reader-only utility used by the tutorial announce region */
.visually-hidden {
	position: absolute;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0 0 0 0);
	white-space: nowrap;
	border: 0;
}

@media (max-width: 720px) {
	.title-screen-actions {
		grid-template-columns: 1fr;
	}

	.tutorial-overlay {
		place-items: end stretch;
		padding: 10px;
	}

	.tutorial-overlay-card {
		width: 100%;
	}

	.title-content-pack-grid {
		grid-template-columns: 1fr;
	}
}

@media (max-width: 960px) {
	.title-screen {
		align-items: flex-start;
		overflow-y: auto;
		padding: 14px;
	}

	.title-screen-card {
		max-height: none;
		margin: 0 auto;
		padding: 20px;
	}

	.title-pack-panel-header {
		align-items: flex-start;
		flex-direction: column;
	}

	.title-pack-hint {
		text-align: left;
	}

	.title-save-preview-grid {
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}
}

@media (max-width: 560px) {
	.title-screen-card {
		padding: 16px;
		border-radius: 16px;
	}

	.title-pack-card {
		padding: 14px;
	}

	.title-save-preview-grid {
		grid-template-columns: 1fr;
	}

	.title-save-preview-actions {
		flex-direction: column;
	}

	.title-save-preview-action,
	.title-save-preview-action--primary {
		width: 100%;
		min-width: 0;
	}

	.title-save-preview-action--icon {
		width: 100%;
		height: 42px;
	}
}

/* Fixed Journal Bar */
.journal-bar {
	position: fixed;
	left: 0;
	right: 0;
	bottom: 0;
	min-height: 40px;
	width: 100vw;
	background: #232b36;
	border-top: 1px solid rgba(255,255,255,.2);
	z-index: 101;
	box-shadow: 0 -2px 12px rgba(0,0,0,0.18);
	transition: min-height 0.2s ease;
}

.journal-toggle-btn {
	position: absolute;
	right: 10px;
	top: 6px;
	width: 28px;
	height: 28px;
	padding: 0;
	border-radius: 999px;
	border: 1px solid rgba(255,255,255,0.24);
	background: rgba(255,255,255,0.08);
	cursor: pointer;
	z-index: 2;
	display: inline-flex;
	align-items: center;
	justify-content: center;
}

.journal-toggle-btn:hover {
	background: rgba(255,255,255,0.14);
}

.journal-toggle-icon {
	width: 16px;
	height: 16px;
	display: block;
	transform: rotate(0deg);
	transition: transform 0.18s ease;
}

.journal-toggle-btn.is-collapsed .journal-toggle-icon {
	transform: rotate(180deg);
}

body.journal-collapsed .journal-bar {
	min-height: 40px;
}

body.journal-collapsed .journal-content {
	display: none;
}

.journal-collapsed-progress {
	display: none;
	width: min(1200px, calc(100% - 70px));
	margin: 0 auto;
	padding: 7px 0 8px;
}

body.journal-collapsed .journal-collapsed-progress {
	display: block;
}

.journal-collapsed-progress-row {
	display: flex;
	align-items: center;
	justify-content: space-between;
	margin-bottom: 4px;
}

.journal-collapsed-progress-label {
	font-size: 0.8rem;
	color: #dbe7ff;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
	max-width: 100%;
}

.journal-collapsed-progress-track {
	background: #3f4754;
	border-radius: 999px;
	width: 100%;
	height: 6px;
	overflow: hidden;
	border: 1px solid rgba(255,255,255,0.12);
}

.journal-collapsed-progress-fill {
	background: linear-gradient(90deg, #5fcf7f 0%, #46b86d 100%);
	width: 0%;
	height: 100%;
	transition: width 0.2s;
}
.journal-bar h2 {
	margin-bottom: .4rem;
	color: #fff;
}

.section-title {
	display: inline-flex;
	align-items: center;
	gap: 8px;
}

.panel-title {
	display: inline-flex;
	align-items: center;
	gap: 7px;
}

.panel-title-icon {
	width: 14px;
	height: 14px;
	border-radius: 3px;
	flex: 0 0 auto;
	object-fit: contain;
}

.section-title-icon {
	width: 16px;
	height: 16px;
	border-radius: 4px;
	flex: 0 0 auto;
}
.journal-bar .log {
	margin-bottom: 0;
	flex: 1;
	min-height: 60px;
	overflow-y: auto;
}
.journal-content {
	width: min(1200px, 100%);
	margin: 0 auto;
	padding: 0.7rem 1.5rem 0.3rem 1.5rem;
}

/*
 * Responsive footer layout
 *
 * Three-column grid (map | journal | queue). `align-items: stretch` forces all
 * columns to the same height, which is driven by the tallest column (the
 * Explore Map). Journal and Queue columns are flex containers so their
 * scrollable content areas fill all available vertical space automatically.
 *
 * Dynamic body.paddingBottom is kept in sync at runtime by the ResizeObserver
 * in js/footerController.js. The static fallback below is only active until
 * the game initialises.
 */
.journal-layout {
	display: grid;
	grid-template-columns: 270px minmax(0, 1fr) 340px;
	gap: 12px;
	align-items: stretch;
}

.journal-map-column {
	display: grid;
	align-content: start;
}

.journal-mini-panel {
	padding: 0.55rem;
	border-radius: 10px;
	background: rgba(255,255,255,0.03);
}

.journal-mini-panel h3 {
	margin: 0 0 6px;
	font-size: 0.9rem;
}

.journal-mini-panel .small-text {
	margin-bottom: 6px !important;
	font-size: 0.76rem;
	color: #aebbd0;
}

.journal-mini-panel .explore-map-legend {
	display: none;
}

.journal-mini-panel .explore-map-grid {
	max-width: 100%;
	width: 100%;
}

.journal-mini-panel .explore-map-cell {
	height: 24px;
}

.journal-mini-panel .explore-map-cell-icon {
	filter: saturate(0.95) brightness(0.95);
}

/* Journal column fills its grid cell height; .log gets flex:1 to fill remaining space. */
.journal-column {
	display: flex;
	flex-direction: column;
	min-height: 0;
}

.journal-column h2 {
	margin-top: 0;
}

/* Action column fills its grid cell height; .action-queue-panel gets flex:1. */
.action-column {
	display: flex;
	flex-direction: column;
	gap: 10px;
	min-height: 0;
}

/* Static fallback; overridden at runtime by ResizeObserver in main.js */
body { padding-bottom: 320px; }

body.journal-collapsed {
	padding-bottom: 46px !important;
}
/* Action panel progress bar */
.action-progressbar {
	margin-top: 0;
}
.action-progressbar-bg {
	background: #51565f;
	border-radius: 8px;
	width: 100%;
	height: 18px;
	overflow: hidden;
}
.action-progressbar-fill {
	background: #4caf50;
	width: 0%;
	height: 100%;
	transition: width 0.2s;
}

.action-queue-panel {
	flex: 1;
	display: flex;
	flex-direction: column;
	min-height: 0;
	background: rgba(255,255,255,0.03);
	border: 1px solid rgba(255,255,255,0.2);
	border-radius: 8px;
	padding: 8px;
}

.action-queue-panel h3 {
	margin: 0 0 6px 0;
	font-size: 0.95rem;
	font-weight: 700;
	color: #e9efff;
}

.action-queue-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 8px;
	margin-bottom: 6px;
}

.action-queue-clear-btn,
.action-queue-remove-btn {
	margin-top: 0;
	padding: 3px 8px;
	font-size: 0.75rem;
	border-radius: 6px;
}

.action-queue-list {
	display: grid;
	gap: 4px;
	flex: 1;
	min-height: 0;
	max-height: none;
	overflow-y: auto;
}

.action-queue-item {
	display: flex;
	justify-content: space-between;
	align-items: center;
	font-size: 0.85rem;
	padding: 4px 6px;
	border-radius: 6px;
	background: rgba(255,255,255,0.04);
	color: #ecf8ff;
}

.action-queue-controls {
	display: flex;
	align-items: center;
	gap: 8px;
}

.action-queue-empty {
	font-size: 0.85rem;
	color: #9aa5ba;
	padding: 2px 4px;
}

.custom-tooltip {
	position: fixed;
	z-index: 2500;
	max-width: 320px;
	padding: 8px 10px;
	border-radius: 8px;
	border: 1px solid rgba(255,255,255,0.28);
	background: rgba(20, 25, 34, 0.96);
	color: #ecf8ff;
	font-size: 0.8rem;
	line-height: 1.35;
	box-shadow: 0 10px 22px rgba(0,0,0,0.32);
	pointer-events: none;
	opacity: 0;
	transform: translateY(2px);
	transition: opacity 120ms ease, transform 120ms ease;
	white-space: pre-line;
}

.custom-tooltip.visible {
	opacity: 1;
	transform: translateY(0);
}

@media (max-width: 1024px) {
	.journal-layout {
		grid-template-columns: 1fr;
	}

	.journal-map-column {
		order: 1;
	}

	.journal-column {
		order: 2;
	}

	.action-column {
		order: 3;
	}

	.action-column {
		gap: 8px;
	}

	body {
		padding-bottom: 380px;
	}

	body.journal-collapsed {
		padding-bottom: 44px !important;
	}
}
/* Single fixed header wrapper containing menu bar + tab bar */
#top-header {
	position: fixed;
	top: 0;
	left: 0;
	right: 0;
	z-index: 100;
	width: 100%;
}

/* Top Menu Bar */
.menu-bar {
	width: 100%;
	background: #232b36;
	border-bottom: 1px solid rgba(255,255,255,.15);
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 0.5rem 1.5rem;
	box-sizing: border-box;
	min-height: 56px;
	gap: 1.5rem;
	box-sizing: border-box;
}

.header-time-container {
	flex: 0 0 auto;
	display: flex;
	align-items: center;
	gap: 8px;
	min-width: 0;
}
.header-menu-btns {
	flex: 1 1 auto;
	display: flex;
	align-items: center;
	justify-content: flex-end;
	gap: 0.45rem;
	min-width: 0;
}
.header-vitals-stack {
	flex: 0 0 auto;
	display: grid;
	grid-template-columns: 1fr;
	gap: 4px;
	min-width: 156px;
}
.header-energy-container {
	flex: 0 0 auto;
	display: flex;
	align-items: center;
}
.header-hp-container {
	flex: 0 0 auto;
	display: flex;
	align-items: center;
}
.time-bar, .energy-bar {
	width: 180px;
	height: 22px;
	background: #51565f;
	border: 1px solid #a3a7b3;
	border-radius: 999px;
	overflow: hidden;
	position: relative;
}

.hp-bar {
	width: 180px;
	height: 22px;
	background: #51565f;
	border: 1px solid #a3a7b3;
	border-radius: 999px;
	overflow: hidden;
	position: relative;
}

.hp-fill {
	width: 0%;
	height: 100%;
	background: linear-gradient(90deg, #ff8f8f 0%, #cf3f3f 100%);
	transition: width 0.1s linear;
}

.hp-text {
	position: absolute;
	inset: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 4px;
	color: #fff;
	font-size: 0.78rem;
	font-weight: 700;
	pointer-events: none;
}

.energy-text {
	position: absolute;
	inset: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 4px;
	font-size: 0.78rem;
	font-weight: 700;
	pointer-events: none;
}

.bar-inline-icon {
	width: 12px;
	height: 12px;
	flex: 0 0 auto;
	object-fit: contain;
}

.hp-text.filled {
	color: #1d1f24;
}

.hp-text.empty {
	color: #fff;
}

.time-phase-badge {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 0.4rem 0.65rem;
	border-radius: 999px;
	border: 1px solid rgba(138, 160, 192, 0.6);
	background: rgba(73, 92, 119, 0.28);
	color: #dfe8ff;
	font-weight: 700;
	font-size: 0.78rem;
	line-height: 1;
	white-space: nowrap;
}

.time-phase-icon {
	width: 15px;
	height: 15px;
	border-radius: 4px;
	flex: 0 0 auto;
}
.menu-btn {
	background: #2e3744;
	color: #f0f8ff;
	border: none;
	border-radius: 8px;
	padding: 0.55rem 1.2rem;
	font-weight: 700;
	font-size: 1rem;
	margin-right: 0;
	cursor: pointer;
	transition: all .2s ease;
}
.menu-btn:hover {
	background: #313b4a;
}

.menu-btn--icon {
	width: 38px;
	min-width: 38px;
	height: 36px;
	padding: 0;
	display: inline-flex;
	align-items: center;
	justify-content: center;
}

.menu-btn-icon {
	width: 18px;
	height: 18px;
	border-radius: 5px;
	flex: 0 0 auto;
}

.menu-dropdown-wrapper {
	position: relative;
	display: inline-flex;
	align-items: center;
}

.menu-dropdown {
	position: absolute;
	top: calc(100% + 6px);
	right: 0;
	min-width: 230px;
	padding: 6px;
	display: grid;
	gap: 4px;
	background: rgba(30, 38, 52, 0.98);
	border: 1px solid rgba(255,255,255,0.22);
	border-radius: 10px;
	box-shadow: 0 10px 24px rgba(0,0,0,0.32);
	z-index: 2300;
}

.menu-dropdown[hidden] {
	display: none !important;
}

.menu-dropdown-item {
	appearance: none;
	border: 1px solid rgba(255,255,255,0.16);
	background: rgba(255,255,255,0.05);
	color: #f0f8ff;
	border-radius: 8px;
	padding: 0.5rem 0.65rem;
	font-size: 0.85rem;
	font-weight: 700;
	text-align: left;
	cursor: pointer;
	transition: background 160ms ease, border-color 160ms ease;
}

.menu-dropdown-item:hover {
	background: rgba(255,255,255,0.1);
	border-color: rgba(255,255,255,0.32);
}

.menu-dropdown-group-label {
	padding: 0.35rem 0.35rem 0.15rem 0.35rem;
	font-size: 0.68rem;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	font-weight: 700;
	color: #9fb1c9;
	border-top: 1px solid rgba(255,255,255,0.12);
	margin-top: 2px;
}

.menu-dropdown .menu-dropdown-group-label:first-child {
	border-top: 0;
	margin-top: 0;
}

.header-resource-summary {
	flex: 1 1 auto;
	min-width: 0;
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	align-content: center;
	gap: 0.42rem;
	overflow: hidden;
	padding: 0;
}

.header-resource-chip {
	display: inline-flex;
	align-items: center;
	gap: 0.4rem;
	flex: 0 0 auto;
	padding: 0.2rem 0.45rem;
	border-radius: 999px;
	border: 1px solid rgba(255,255,255,0.2);
	background: rgba(255,255,255,0.07);
	font-size: 0.74rem;
	line-height: 1;
	color: #e8f1ff;
	white-space: nowrap;
}

.header-resource-chip strong {
	font-size: 0.74rem;
	color: #d7e6ff;
	font-weight: 700;
}

.header-resource-chip-value {
	font-weight: 700;
	color: #ffffff;
}

.header-resource-chip-net {
	font-size: 0.72rem;
	font-weight: 700;
	padding-left: 0.1rem;
}

.header-resource-chip-net.positive {
	color: #8ce1ad;
}

.header-resource-chip-net.negative {
	color: #ff9a9a;
}

.header-resource-chip-net.neutral {
	color: #d6deea;
}

.header-resource-chip.is-critical {
	border-color: rgba(255, 123, 123, 0.58);
	background: rgba(176, 66, 66, 0.16);
}

.condition-header-badge {
	display: inline-flex;
	align-items: center;
	padding: 0.4rem 0.65rem;
	border-radius: 999px;
	border: 1px solid rgba(226, 140, 91, 0.7);
	background: rgba(207, 140, 100, 0.2);
	color: #ffd8c2;
	font-weight: 700;
	font-size: 0.8rem;
	line-height: 1;
	white-space: nowrap;
}

.time-bar.phase-night .time-fill {
	background: linear-gradient(90deg, #37517c 0%, #182235 100%);
}

.time-bar.phase-sunrise .time-fill {
	background: linear-gradient(90deg, #ffc26b 0%, #ff8a5c 100%);
}

.time-bar.phase-day .time-fill {
	background: linear-gradient(90deg, #8ed0ff 0%, #52a8e6 100%);
}

.time-bar.phase-sunset .time-fill {
	background: linear-gradient(90deg, #ff9f7f 0%, #8a5a88 100%);
}
/* Achievements Dialog */
.dialog-overlay {
	position: fixed;
	top: 0; left: 0; right: 0; bottom: 0;
	background: rgba(0,0,0,0.55);
	display: flex;
	align-items: center;
	justify-content: center;
	z-index: 1000;
}
.dialog-box {
	background: #232b36;
	border: 1px solid rgba(255,255,255,.3);
	border-radius: 12px;
	padding: 2rem 2.5rem 1.5rem 2.5rem;
	color: #f0f8ff;
	min-width: 340px;
	max-width: 95vw;
	max-height: 90vh;
	overflow-y: auto;
	box-shadow: 0 8px 32px rgba(0,0,0,0.25);
}
#achievementsDialogContent .stat {
	margin-bottom: 0.5em;
	padding: 0.5em 0.5em 0.5em 1em;
	border-left: 4px solid #888;
	background: rgba(255,255,255,0.03);
	border-radius: 4px;
	transition: opacity 0.3s;
}
#achievementsDialogContent .stat strong {
	color: #ffd700;
}
#achievementsDialogContent .stat span {
	color: #ccc;
}
/* (reverted custom tooltip styles) */
@import url('https://fonts.googleapis.com/css2?family=Roboto:wght@400;500;700&display=swap');

:root {
	--panel-stack-gap: 1rem;
	--mobile-journal-height: 240px;
}

body { margin: 0; font-family: 'Roboto', Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif; background: #232b36; color: #f0f8ff; }
.container { width: min(1500px, 100%); padding: 1rem; margin: 0 auto; padding-top: var(--header-h, 120px); }

/* Tab navigation bar */
.tab-bar {
	width: 100%;
	background: #1b2230;
	border-bottom: 2px solid rgba(255,255,255,.12);
	display: flex;
	align-items: stretch;
	min-height: 48px;
	padding: 0 1.5rem;
	box-sizing: border-box;
	gap: 0;
	flex-wrap: nowrap;
}

.tab-btn {
	flex: 1 1 0;
	border: none;
	border-bottom: 2px solid transparent;
	background: transparent;
	color: #c8d3e8;
	font-size: 0.96rem;
	font-weight: 700;
	letter-spacing: 0.01em;
	cursor: pointer;
	transition: color 0.18s, border-color 0.18s, background 0.18s;
	margin-top: 0;
	height: 100%;
	white-space: nowrap;
	position: relative;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	min-width: 0;
}

@media (max-width: 1180px) {
	.menu-bar {
		flex-wrap: wrap;
		gap: 0.8rem 1rem;
		padding: 0.6rem 1rem;
	}

	.header-time-container {
		flex: 1 1 320px;
		flex-wrap: wrap;
	}

	.header-resource-summary {
		order: 3;
		flex: 1 1 100%;
		overflow: visible;
	}

	.header-menu-btns {
		flex: 1 1 auto;
		justify-content: flex-end;
		flex-wrap: wrap;
	}

	.header-vitals-stack {
		flex: 1 1 220px;
		min-width: 180px;
	}

	.tab-bar {
		height: auto;
		min-height: 0;
		padding: 0;
		flex-wrap: wrap;
	}

	.tab-btn {
		flex: 1 1 25%;
		min-height: 46px;
		padding: 0.4rem 0.7rem;
	}
}

/* Achievements dialog large tile-grid layout */
.achievements-dialog-box {
	width: min(1260px, 96vw);
	height: min(880px, 92vh);
	max-width: none;
	max-height: none;
	min-width: min(720px, 96vw);
	padding: 0;
	display: grid;
	grid-template-rows: auto 1fr auto;
	overflow: hidden;
}

.dialog-header {
	padding: 1rem 1.3rem 0.6rem 1.3rem;
	border-bottom: 1px solid rgba(255,255,255,0.12);
}

.dialog-header h2 {
	margin: 0;
}

.achievements-grid {
	padding: 1rem 1.3rem;
	overflow-y: auto;
	overflow-x: hidden;
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
	gap: 10px;
	align-content: start;
}

.achievement-tile {
	height: 142px;
	border-radius: 10px;
	border: 1px solid rgba(255,255,255,0.2);
	background: rgba(255,255,255,0.04);
	padding: 0.7rem;
	display: grid;
	grid-template-rows: auto 1fr auto;
	gap: 0.4rem;
	transition: opacity 0.25s ease, transform 0.2s ease, border-color 0.2s ease;
}

.achievement-tile.unlocked {
	opacity: 1;
	border-color: rgba(255, 215, 120, 0.6);
	box-shadow: inset 0 0 0 1px rgba(255, 215, 120, 0.28);
}

.achievement-tile.locked {
	opacity: 0.52;
}

.achievement-tile-title {
	font-size: 0.95rem;
	font-weight: 700;
	color: #ffd76a;
	line-height: 1.15;
	overflow: hidden;
	display: -webkit-box;
	-webkit-line-clamp: 2;
	line-clamp: 2;
	-webkit-box-orient: vertical;
}

.achievement-tile-desc {
	font-size: 0.8rem;
	color: #d6dbe8;
	line-height: 1.3;
	overflow: hidden;
	display: -webkit-box;
	-webkit-line-clamp: 3;
	line-clamp: 3;
	-webkit-box-orient: vertical;
}

.achievement-tile-status {
	font-size: 0.76rem;
	font-weight: 700;
	color: #9db0c8;
}

.achievement-tile.unlocked .achievement-tile-status {
	color: #ffe08e;
}

.dialog-footer {
	padding: 0.7rem 1.3rem 1rem 1.3rem;
	border-top: 1px solid rgba(255,255,255,0.12);
	background: linear-gradient(180deg, rgba(35,43,54,0.12), rgba(35,43,54,0.88));
	display: flex;
	justify-content: flex-end;
	align-items: center;
	gap: 0.6rem;
}

.meta-progress-dialog-box {
	width: min(1120px, 96vw);
	height: min(860px, 92vh);
	max-width: none;
	max-height: none;
	min-width: min(720px, 96vw);
	padding: 0;
	display: grid;
	grid-template-rows: auto 1fr auto;
	overflow: hidden;
}

.meta-progress-dialog-content {
	padding: 1rem 1.3rem;
	overflow-y: auto;
	overflow-x: hidden;
	display: grid;
	gap: 0.9rem;
	align-content: start;
}

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

.meta-progress-summary > div {
	background: rgba(255,255,255,0.04);
	border: 1px solid rgba(255,255,255,0.12);
	border-radius: 10px;
	padding: 0.55rem 0.7rem;
}

.meta-progress-summary strong {
	color: #f0d9b2;
}

.meta-progress-summary span {
	color: #ffd700;
}

.meta-upgrade-preview {
	display: grid;
	gap: 6px;
	margin: 0 0 10px 0;
	padding: 0.55rem 0.65rem;
	background: rgba(255,255,255,0.04);
	border: 1px solid rgba(255,255,255,0.12);
	border-radius: 10px;
	font-size: 0.82rem;
	line-height: 1.35;
}

.meta-upgrade-preview strong {
	color: #f0d9b2;
}

.meta-upgrade-preview span {
	color: #d8e6f9;
}

.game-over-dialog-overlay {
	background: rgba(5, 8, 14, 0.82);
	z-index: 2600;
}

.game-over-dialog-box {
	width: min(560px, 94vw);
	min-width: 0;
	padding: 0;
	display: grid;
	grid-template-rows: auto 1fr auto;
	overflow: hidden;
	border-color: rgba(255, 131, 131, 0.42);
	box-shadow: 0 16px 40px rgba(0,0,0,0.52);
}

.game-over-dialog-content {
	padding: 1rem 1.3rem;
	display: grid;
	gap: 0.9rem;
}

.game-over-dialog-content p {
	margin: 0;
	color: #e9efff;
}

.game-over-summary {
	display: grid;
	gap: 0.45rem;
	max-height: 45vh;
	overflow: auto;
}

.game-over-summary-row {
	display: flex;
	justify-content: space-between;
	align-items: baseline;
	gap: 0.8rem;
	padding: 0.4rem 0.55rem;
	border: 1px solid rgba(255,255,255,0.14);
	border-radius: 8px;
	background: rgba(255,255,255,0.04);
	font-size: 0.9rem;
}

.game-over-summary-row strong {
	color: #ffd5a6;
}

body.game-over #top-header,
body.game-over .container,
body.game-over .journal-bar,
body.game-over #achievementsDialog,
body.game-over #metaProgressDialog {
	pointer-events: none;
	filter: saturate(0.55) brightness(0.75);
}

body.game-over #gameOverDialog {
	pointer-events: auto;
	filter: none;
}

@media (max-width: 600px) {
	.achievements-dialog-box {
		width: 96vw;
		height: 90vh;
		min-width: 0;
	}

	.meta-progress-dialog-box {
		width: 96vw;
		height: 90vh;
		min-width: 0;
	}

	.dialog-header {
		padding: 0.85rem 0.9rem 0.55rem 0.9rem;
	}

	.achievements-grid {
		padding: 0.8rem 0.9rem;
		grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
		gap: 8px;
	}

	.achievement-tile {
		height: 132px;
		padding: 0.6rem;
	}

	.dialog-footer {
		padding: 0.6rem 0.9rem 0.8rem 0.9rem;
	}

	.meta-progress-dialog-content {
		padding: 0.8rem 0.9rem;
	}

	.meta-progress-summary {
		grid-template-columns: 1fr;
	}
}

.tab-icon {
	width: 18px;
	height: 18px;
	border-radius: 4px;
	image-rendering: auto;
	flex: 0 0 auto;
}

.tab-btn[data-tab='character'] {
	--tab-accent: #78c26f;
}

.tab-btn[data-tab='actions'] {
	--tab-accent: #e2b64e;
}

.tab-btn[data-tab='village'] {
	--tab-accent: #58a6df;
}

.tab-btn[data-tab='craft'] {
	--tab-accent: #cf8c64;
}

.tab-btn:hover:enabled {
	color: #e0eaff;
	background: rgba(255,255,255,0.05);
	transform: none;
	box-shadow: none;
	border-bottom-color: color-mix(in srgb, var(--tab-accent, #5b9bd5) 60%, #ffffff 40%);
}

.tab-btn.active {
	color: #fff;
	border-bottom-color: var(--tab-accent, #5b9bd5);
	background: color-mix(in srgb, var(--tab-accent, #5b9bd5) 16%, transparent);
}

.tab-btn.active::after {
	content: '';
	position: absolute;
	left: 0;
	right: 0;
	top: 0;
	height: 2px;
	background: var(--tab-accent, #5b9bd5);
}

/* Tab content panes */
.tab-pane {
	display: none;
}

.tab-pane.active {
	display: block;
}

/* Two-column layout inside tabs */
.tab-grid {
display: grid;
grid-template-columns: 1fr 1fr;
gap: var(--panel-stack-gap);
align-items: start;
}

.tab-grid--village {
grid-template-columns: 1fr;
grid-template-areas: "village";
}

.tab-grid--character {
grid-template-columns: minmax(300px, 460px) minmax(0, 1fr);
grid-template-areas: "attributes equipment";
}

.tab-grid--craft {
	grid-template-columns: 1fr;
	grid-template-areas: "crafting";
}

#equipmentPanel {
grid-area: equipment;
}

#attributesPanel {
	grid-area: attributes;
	max-width: 460px;
}

#villageSetupPanel {
grid-area: village;
}

#craftingPanel {
	grid-area: crafting;
}

@media (max-width: 860px) {
.tab-grid,
.tab-grid--character,
.tab-grid--village {
grid-template-columns: 1fr;
grid-template-areas: none;
}

#attributesPanel,
#equipmentPanel,
#villageSetupPanel,
#craftingPanel {
grid-area: auto;
}

#villageSetupPanel,
#craftingPanel {
order: 1;
}
}

h1, h2, h3 { margin-bottom: .4rem; color: #fff; }
.time-header { display: flex; justify-content: space-between; align-items: center; background: rgba(0, 0, 0, .35); border: 1px solid rgba(255, 255, 255, .3); border-radius: 10px; padding: .6rem .9rem; margin-bottom: 1rem; font-weight: 700; }
.time-header span { color:#eef; }
.time-display { display: flex; align-items: center; justify-content: flex-start; }
.time-bar, .energy-bar { width: 220px; height: 28px; background: #51565f; border: 1px solid #a3a7b3; border-radius: 999px; overflow: hidden; position: relative; }
.time-bar { margin-right: 1rem; }
.time-fill { width: 0%; height: 100%; background: linear-gradient(90deg, #ff9999 0%, #d74646 100%); transition: width 0.1s linear; }
.energy-fill { width: 0%; height: 100%; background: linear-gradient(90deg, #ffdb5e 0%, #f2bc34 100%); transition: width 0.1s linear; }
.time-text, .energy-text { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: #fff; font-size: 0.94rem; font-weight: 700; text-shadow: none; pointer-events: none; }
.time-text.filled, .energy-text.filled { color: #1d1f24; }
.time-text.empty, .energy-text.empty { color: #fff; }

.header-vitals-stack .hp-bar,
.header-vitals-stack .energy-bar {
	width: 156px;
	height: 22px;
}

.header-vitals-stack .hp-text,
.header-vitals-stack .energy-text {
	font-size: 0.78rem;
	gap: 4px;
}
.panel {
--panel-accent: #5b9bd5;
background: #232b36;
border: 1px solid rgba(255,255,255,.3);
border-radius: 12px;
padding: 1rem;
margin: 0;
box-shadow: inset 0 2px 0 0 color-mix(in srgb, var(--panel-accent) 65%, transparent);
}

#villageSetupPanel {
--panel-accent: #58a6df;
}

#craftingPanel {
--panel-accent: #cf8c64;
}

.stats { display: grid; grid-template-columns: 1fr; gap: .4rem; }
.stat {
	background: rgba(255,255,255,0.03);
	border-radius: 10px;
	padding: .55rem .7rem;
	font-size: .9rem;
	display: grid;
	grid-template-columns: 40px minmax(0, 1fr);
	gap: 10px;
	align-items: start;
}

.attribute-stat-icon {
	display: flex;
	align-items: flex-start;
	justify-content: center;
	padding-top: 1px;
}

.attribute-stat-icon img {
	width: 36px;
	height: 36px;
	margin-right: 0 !important;
	flex: 0 0 auto;
}

.attribute-stat-content {
	min-width: 0;
	display: grid;
	gap: 3px;
}

.attribute-stat-header {
	display: flex;
	flex-wrap: wrap;
	align-items: baseline;
	gap: 6px;
	line-height: 1.2;
}

.attribute-stat-name {
	color: #f4f8ff;
}

.attribute-stat-level {
	color: #ffd700;
	font-weight: 700;
}

.attribute-stat-exp {
	color: #92a3bd;
	font-size: 0.78rem;
}

.attribute-stat-desc {
	color: #97a7bf;
	font-size: 0.78rem;
	line-height: 1.35;
}

.building-grid {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
gap: 10px;
align-content: start;
}

.village-workforce-summary {
display: flex;
flex-wrap: wrap;
gap: 8px;
margin-bottom: 10px;
padding: 0.5rem;
border: 1px solid rgba(88, 166, 223, 0.35);
border-radius: 10px;
background: linear-gradient(180deg, rgba(67, 120, 170, 0.14), rgba(46, 89, 130, 0.14));
}

.village-workforce-pill {
display: inline-flex;
align-items: center;
padding: 0.16rem 0.5rem;
border-radius: 999px;
font-size: 0.76rem;
font-weight: 700;
line-height: 1;
color: #dcecff;
background: rgba(255,255,255,0.08);
border: 1px solid rgba(255,255,255,0.2);
}

.village-build-slot-summary {
display: flex;
flex-wrap: wrap;
gap: 8px;
margin-bottom: 10px;
}

.village-build-slot-pill {
display: inline-flex;
align-items: center;
padding: 0.16rem 0.5rem;
border-radius: 999px;
font-size: 0.76rem;
font-weight: 700;
line-height: 1;
color: #dcecff;
background: rgba(255,255,255,0.08);
border: 1px solid rgba(255,255,255,0.2);
}

.village-build-slot-pill.is-ready {
border-color: rgba(111, 207, 151, 0.55);
background: rgba(111, 207, 151, 0.12);
}

.village-build-slot-pill.is-locked {
border-color: rgba(255, 165, 0, 0.55);
background: rgba(255, 165, 0, 0.12);
}

.building-card {
background: rgba(255,255,255,0.04);
border: 1px solid rgba(255,255,255,0.18);
border-radius: 10px;
padding: 0.65rem;
display: grid;
grid-template-rows: auto 1fr auto;
gap: 0.5rem;
box-shadow: inset 0 2px 0 0 rgba(88, 166, 223, 0.35);
}

.building-card.is-unaffordable {
border-color: rgba(255, 170, 140, 0.36);
}

.building-card-header {
display: flex;
align-items: flex-start;
justify-content: space-between;
gap: 8px;
}

.building-card-title {
font-size: 0.95rem;
font-weight: 700;
color: #e9f3ff;
line-height: 1.15;
}

.building-card-subtitle {
margin-top: 2px;
font-size: 0.76rem;
color: #9fb3d1;
line-height: 1.25;
}

.building-card-status-badges {
margin-top: 6px;
display: flex;
flex-wrap: wrap;
gap: 6px;
}

.building-card-slot-status {
margin-top: 6px;
display: flex;
flex-wrap: wrap;
gap: 6px;
}

.building-slot-pill {
display: inline-flex;
align-items: center;
padding: 0.08rem 0.45rem;
border-radius: 999px;
font-size: 0.72rem;
font-weight: 700;
letter-spacing: 0.01em;
line-height: 1;
color: #dcecff;
background: rgba(255,255,255,0.08);
border: 1px solid rgba(255,255,255,0.2);
}

.building-slot-pill.is-ready {
border-color: rgba(111, 207, 151, 0.55);
background: rgba(111, 207, 151, 0.12);
}

.building-slot-pill.is-locked {
border-color: rgba(255, 165, 0, 0.55);
background: rgba(255, 165, 0, 0.12);
}

.building-status-badge {
display: inline-flex;
align-items: center;
padding: 0.08rem 0.45rem;
border-radius: 999px;
font-size: 0.72rem;
font-weight: 700;
letter-spacing: 0.01em;
border: 1px solid transparent;
line-height: 1;
}

.building-status-badge.active {
color: #8ee0a3;
background: rgba(71, 152, 96, 0.16);
border-color: rgba(110, 198, 127, 0.55);
}

.building-status-badge.partial {
color: #f2d081;
background: rgba(153, 126, 53, 0.18);
border-color: rgba(207, 185, 100, 0.52);
}

.building-status-badge.unstaffed {
color: #f4a29f;
background: rgba(156, 74, 74, 0.18);
border-color: rgba(212, 120, 116, 0.52);
}

.building-card-count {
display: inline-flex;
align-items: center;
padding: 0.1rem 0.45rem;
border-radius: 999px;
font-size: 0.72rem;
font-weight: 700;
background: rgba(88, 166, 223, 0.15);
border: 1px solid rgba(88, 166, 223, 0.42);
color: #cde7ff;
white-space: nowrap;
}

.building-card-effects {
min-height: 76px;
}

.building-card-cost-label {
margin-top: 0.4rem;
font-size: 0.72rem;
font-weight: 700;
letter-spacing: 0.03em;
text-transform: uppercase;
color: #9fb3d1;
}

.building-card-costs {
margin-top: 0.22rem;
display: flex;
flex-wrap: wrap;
gap: 6px;
}

.building-cost-chip {
display: inline-flex;
align-items: center;
gap: 4px;
padding: 0.14rem 0.42rem;
border-radius: 999px;
font-size: 0.74rem;
font-weight: 700;
background: rgba(255,255,255,0.06);
border: 1px solid rgba(255,255,255,0.2);
color: #d9e6f7;
}

.building-cost-chip.is-missing {
background: rgba(168, 83, 61, 0.22);
border-color: rgba(210, 129, 106, 0.45);
color: #ffd2c5;
}

.building-card-assignment-row {
display: flex;
flex-direction: column;
gap: 0.6rem;
margin-top: 0.6rem;
padding-top: 0.6rem;
border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.building-assignment-status {
font-size: 0.85rem;
color: rgba(255, 255, 255, 0.8);
text-align: center;
}

.building-assignment-controls {
display: flex;
gap: 0.5rem;
align-items: center;
justify-content: center;
}

.building-assign-minus,
.building-assign-plus {
width: 32px;
height: 32px;
padding: 0;
font-size: 1.2rem;
font-weight: bold;
background: rgba(100, 150, 200, 0.15);
border: 1px solid rgba(100, 150, 200, 0.3);
border-radius: 4px;
cursor: pointer;
transition: all 0.2s ease;
color: rgba(150, 200, 255, 0.9);
}

.building-assign-minus:hover:not(:disabled),
.building-assign-plus:hover:not(:disabled) {
background: rgba(100, 150, 200, 0.3);
border-color: rgba(100, 150, 200, 0.5);
}

.building-assign-minus:disabled,
.building-assign-plus:disabled {
opacity: 0.35;
cursor: not-allowed;
}

.building-available-count {
font-size: 0.9rem;
color: rgba(255, 255, 255, 0.8);
min-width: 60px;
text-align: center;
}

.building-card-build-btn {
width: 100%;
margin-top: 0;
}

/* Craft card grid */
.craft-grid {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
gap: 10px;
align-content: start;
}

.craft-card {
background: rgba(255,255,255,0.04);
border: 1px solid rgba(255,255,255,0.18);
border-radius: 10px;
padding: 0.65rem;
display: grid;
grid-template-rows: auto 1fr auto auto auto;
gap: 0.45rem;
box-shadow: inset 0 2px 0 0 rgba(207, 140, 100, 0.3);
}

.craft-card.is-selected {
border-color: rgba(255, 215, 0, 0.55);
box-shadow: inset 0 2px 0 0 rgba(255, 215, 0, 0.25);
}

.craft-card.is-unavailable {
opacity: 0.62;
border-color: rgba(255,255,255,0.09);
}

.craft-card-header {
display: flex;
align-items: flex-start;
justify-content: space-between;
gap: 8px;
}

.craft-card-header-left {
display: flex;
align-items: flex-start;
gap: 6px;
min-width: 0;
}

.craft-card-badges {
display: inline-flex;
flex-direction: column;
align-items: flex-end;
gap: 4px;
}

.craft-card-icon {
width: 28px;
height: 28px;
flex-shrink: 0;
vertical-align: middle;
}

.craft-card-title {
font-size: 0.95rem;
font-weight: 700;
color: #e9f3ff;
line-height: 1.15;
}

.craft-card-subtitle {
margin-top: 2px;
font-size: 0.76rem;
color: #9fb3d1;
line-height: 1.25;
}

.craft-card-badge {
display: inline-flex;
align-items: center;
padding: 0.1rem 0.45rem;
border-radius: 999px;
font-size: 0.71rem;
font-weight: 700;
white-space: nowrap;
flex-shrink: 0;
}

.craft-card-badge--category {
background: rgba(207, 140, 100, 0.15);
border: 1px solid rgba(207, 140, 100, 0.4);
color: #f0c8a8;
}

.craft-card-badge--owned {
background: rgba(88, 166, 223, 0.14);
border: 1px solid rgba(88, 166, 223, 0.4);
color: #cde7ff;
}

.craft-card-progress {
background: rgba(255,255,255,0.05);
border-radius: 6px;
padding: 0.28rem 0.45rem;
display: flex;
align-items: center;
gap: 8px;
}

.craft-progress-track {
flex: 1;
height: 7px;
background: rgba(255,255,255,0.1);
border-radius: 999px;
overflow: hidden;
}

.craft-progress-fill {
height: 100%;
background: linear-gradient(90deg, #4caf50, #81c784);
border-radius: 999px;
transition: width 0.3s;
}

.craft-card-progress-label {
font-size: 0.72rem;
color: #9fb3d1;
white-space: nowrap;
}

.craft-card-effects {
display: flex;
flex-wrap: wrap;
gap: 4px;
align-content: flex-start;
min-height: 24px;
}

.craft-card-select-btn {
width: 100%;
margin-top: 0;
}

.craft-card-select-btn.is-active {
background: rgba(255, 215, 0, 0.18);
border-color: rgba(255, 215, 0, 0.55);
color: #ffd700;
}

.explore-map-grid {
	display: grid;
	gap: 0;
	max-width: 420px;
	border-radius: 10px;
	overflow: hidden;
	border: 1px solid rgba(255,255,255,0.14);
}

.explore-map-cell {
	height: 34px;
	border-radius: 0;
	border: none;
	display: flex;
	align-items: center;
	justify-content: center;
	background: rgba(255,255,255,0.03);
	position: relative;
}

.explore-map-cell-icon {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
	filter: saturate(0.92) brightness(0.9);
	opacity: 0.92;
}

.explore-map-cell.discovered {
	box-shadow: inset 0 0 0 1px rgba(88, 166, 223, 0.55);
}

.explore-map-cell.discovered .explore-map-cell-icon {
	filter: saturate(1) brightness(1);
	opacity: 1;
}

.explore-map-cell.frontier {
	box-shadow: inset 0 0 0 1px rgba(226, 182, 78, 0.82);
}

.explore-map-cell.start {
	box-shadow: inset 0 0 0 2px rgba(120, 194, 111, 0.95);
}

.explore-map-cell.start.frontier {
	box-shadow: inset 0 0 0 2px rgba(120, 194, 111, 0.95), inset 0 0 0 3px rgba(226, 182, 78, 0.65);
}

.explore-map-legend {
	display: flex;
	flex-wrap: wrap;
	gap: 6px 8px;
	margin: 0 0 8px;
}

.explore-map-legend-item {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 2px 6px;
	border-radius: 999px;
	background: rgba(255,255,255,0.04);
	font-size: 11px;
	color: #ccd5e4;
	line-height: 1;
}

.explore-map-legend-item img {
	width: 12px;
	height: 12px;
	display: block;
	object-fit: cover;
	border-radius: 2px;
}

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

.equipment-slot-card {
	--slot-accent: #6f8fb8;
	background: rgba(255,255,255,0.04);
	border: 1px solid color-mix(in srgb, var(--slot-accent) 60%, rgba(255,255,255,0.2));
	border-radius: 10px;
	padding: 8px;
	display: grid;
	gap: 6px;
	box-shadow: inset 0 2px 0 0 color-mix(in srgb, var(--slot-accent) 65%, transparent);
}

.equipment-slot-card[data-slot-type='tool'] {
	--slot-accent: #58a6df;
}

.equipment-slot-card[data-slot-type='weapon'] {
	--slot-accent: #cf8c64;
}

.equipment-slot-card[data-slot-type='defense'] {
	--slot-accent: #78c26f;
}

.equipment-slot-card[data-slot-type='utility'] {
	--slot-accent: #e2b64e;
}

.equipment-slot-card.locked {
	opacity: 0.88;
}

.equipment-slot-card.equipped-success {
	animation: equipSnap 420ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

@keyframes equipSnap {
	0% {
		transform: scale(0.985);
		box-shadow: inset 0 2px 0 0 color-mix(in srgb, var(--slot-accent) 65%, transparent), 0 0 0 0 rgba(255, 214, 79, 0);
	}
	40% {
		transform: scale(1.015);
		box-shadow: inset 0 2px 0 0 rgba(255, 214, 79, 0.9), 0 0 0 2px rgba(255, 214, 79, 0.45);
	}
	100% {
		transform: scale(1);
		box-shadow: inset 0 2px 0 0 color-mix(in srgb, var(--slot-accent) 65%, transparent), 0 0 0 0 rgba(255, 214, 79, 0);
	}
}

.equipment-slot-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 8px;
	font-size: 0.78rem;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.06em;
	color: color-mix(in srgb, var(--slot-accent) 75%, #d8e7ff 25%);
}

.equipment-slot-badge {
	font-size: 0.68rem;
	line-height: 1;
	padding: 3px 6px;
	border-radius: 999px;
	border: 1px solid rgba(255,255,255,0.3);
	color: #f7dca4;
	background: rgba(28, 34, 44, 0.75);
}

.equipment-slot-main {
	display: flex;
	align-items: center;
	gap: 8px;
}

.equipment-slot-icon {
	width: 36px;
	height: 36px;
	border-radius: 8px;
	border: 1px solid rgba(255,255,255,0.22);
	background: rgba(20,25,34,0.55);
	display: flex;
	align-items: center;
	justify-content: center;
	color: #8e9bb1;
	font-weight: 700;
	font-size: 0.9rem;
	flex: 0 0 auto;
	overflow: hidden;
}

.equipment-slot-icon img {
	width: 100%;
	height: 100%;
	object-fit: cover;
}

.equipment-slot-name {
	font-size: 0.9rem;
	font-weight: 700;
	color: #f3f8ff;
	line-height: 1.2;
}

.equipment-slot-empty {
	color: #9aa5ba;
	font-weight: 600;
}

.equipment-slot-effects {
	font-size: 0.78rem;
	color: #9ec6ff;
	line-height: 1.3;
	min-height: 1.1em;
}

.equipment-slot-actions {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
}

.equipment-slot-actions button {
	margin-top: 0;
	padding: 0.35rem 0.55rem;
	font-size: 0.76rem;
}

@media (max-width: 560px) {
	.equipment-grid {
		grid-template-columns: 1fr;
	}
}
button { margin-top: .5rem; border: none; border-radius: 8px; padding: .55rem .8rem; background: #2e3744; color: #f0f8ff; font-weight: 700; cursor: pointer; transition: all .2s ease; }
button:hover:enabled { transform: translateY(-1px); box-shadow: 0 8px 14px rgba(0,0,0,.2); }
button:disabled { opacity: 1; color: #888; background: #232b36; cursor: not-allowed; transform: none; box-shadow: none; }
.log { height: 320px; overflow-y: auto; background: #232b36; color: #ecf8ff; border:1px solid rgba(255,255,255,.2); border-radius: 8px; padding:.8rem; font-size:.86rem; line-height:1.34; }
.small-text { color:#ddf; font-size:.9rem; }

.building-process-status {
	margin-top: 6px;
	font-size: 0.86rem;
	display: grid;
	gap: 4px;
}

.building-process-status-row {
	color: #cde3ff;
	line-height: 1.25;
}

.building-process-status-pill {
	display: inline-flex;
	align-items: center;
	padding: 0.08rem 0.45rem;
	border-radius: 999px;
	font-size: 0.72rem;
	font-weight: 700;
	letter-spacing: 0.01em;
	border: 1px solid transparent;
}

.building-process-status-pill.active {
	color: #8ee0a3;
	background: rgba(71, 152, 96, 0.16);
	border-color: rgba(110, 198, 127, 0.55);
}

.building-process-status-pill.idle {
	color: #f2b281;
	background: rgba(153, 95, 53, 0.18);
	border-color: rgba(207, 140, 100, 0.52);
}

.building-process-status-pill.pending {
	color: #b9c4d9;
	background: rgba(102, 120, 149, 0.2);
	border-color: rgba(162, 179, 207, 0.45);
}

.building-effect-flavor {
	margin-top: 4px;
	font-size: 0.78rem;
	color: #9fb3d1;
}

.action-pill-group {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
	align-items: center;
}

.action-pill {
	display: inline-flex;
	align-items: center;
	gap: 4px;
	padding: 0.12rem 0.45rem;
	border-radius: 999px;
	font-size: 0.74rem;
	font-weight: 700;
	line-height: 1.2;
	border: 1px solid rgba(255,255,255,0.2);
	background: rgba(255,255,255,0.06);
	color: #d9e6f7;
}

.action-pill--cost {
	color: #ffb9b9;
	background: rgba(145, 54, 54, 0.25);
	border-color: rgba(208, 107, 107, 0.5);
}

.action-pill--gain {
	color: #b8efc7;
	background: rgba(58, 130, 76, 0.22);
	border-color: rgba(96, 171, 116, 0.5);
}

.action-pill--xp {
	color: #b9ddff;
	background: rgba(52, 98, 158, 0.22);
	border-color: rgba(108, 157, 221, 0.5);
}

.action-pill--meta {
	color: #c9d7ea;
	background: rgba(75, 94, 122, 0.2);
	border-color: rgba(134, 155, 186, 0.45);
}

.action-pill--warn {
	color: #ffd2c5;
	background: rgba(153, 95, 53, 0.24);
	border-color: rgba(207, 140, 100, 0.52);
}

.action-pill--duration {
	color: #b9c4d9;
	background: rgba(102, 120, 149, 0.2);
	border-color: rgba(162, 179, 207, 0.45);
}

.action-pill-resource-icons {
	display: inline-flex;
	align-items: center;
	gap: 3px;
}

.action-pill-lock-hint {
	display: inline-flex;
	align-items: center;
	margin-left: 2px;
	padding: 0 0.24rem;
	border-radius: 999px;
	font-size: 0.62rem;
	line-height: 1.1;
	letter-spacing: 0.02em;
	color: #f7e1cf;
	background: rgba(153, 95, 53, 0.38);
	border: 1px solid rgba(207, 140, 100, 0.58);
}

/* Reinforce disabled button style at the end for specificity */
button:disabled {
	opacity: 1;
	color: #888 !important;
	background: #232b36 !important;
	cursor: not-allowed !important;
	transform: none !important;
	box-shadow: none !important;
}

/* UI/UX polish: tab-themed backdrop + mobile responsiveness + toast feedback */
body {
	--tab-background: radial-gradient(circle at 18% 8%, #8bbf84 0%, #4f7c57 38%, #23372f 100%);
	background-color: #1f2b3a;
	background-image: var(--tab-background);
	background-repeat: no-repeat;
	background-position: center top;
	background-size: cover;
	background-attachment: fixed;
	transition: background-image 450ms ease;
}

body[data-active-tab='character'] {
	--tab-background: radial-gradient(circle at 18% 8%, #8bbf84 0%, #4f7c57 38%, #23372f 100%);
}

body[data-active-tab='actions'] {
	--tab-background: radial-gradient(circle at 18% 8%, #f0ce7a 0%, #a87a30 38%, #3b3020 100%);
}

body[data-active-tab='village'] {
	--tab-background: radial-gradient(circle at 18% 8%, #8dc2e4 0%, #4b7ba1 38%, #223749 100%);
}

body[data-active-tab='craft'] {
	--tab-background: radial-gradient(circle at 18% 8%, #d69d78 0%, #8e5f4f 38%, #32262f 100%);
}

.action-queue-item.draggable {
	cursor: grab;
	transition: transform 120ms ease, background 120ms ease, border-color 120ms ease;
	border: 1px dashed rgba(255,255,255,0.18);
}

.action-queue-item.draggable:active {
	cursor: grabbing;
}

.action-queue-item.dragging {
	opacity: 0.72;
	transform: scale(0.985);
}

.action-queue-item.drag-over {
	border-color: rgba(122, 196, 255, 0.9);
	background: rgba(122, 196, 255, 0.16);
}

.achievement-toast-container {
	position: fixed;
	right: 14px;
	top: 68px;
	z-index: 2400;
	display: grid;
	gap: 10px;
	pointer-events: none;
	max-width: min(360px, calc(100vw - 20px));
}

.achievement-toast {
	padding: 10px 12px;
	border-radius: 10px;
	border: 1px solid rgba(255, 214, 79, 0.55);
	background: linear-gradient(140deg, rgba(40, 46, 60, 0.97), rgba(32, 35, 46, 0.97));
	box-shadow: 0 12px 26px rgba(0,0,0,0.33);
	color: #fff;
	opacity: 0;
	transform: translateX(14px) scale(0.98);
	transition: opacity 220ms ease, transform 220ms ease;
}

.achievement-toast.show {
	opacity: 1;
	transform: translateX(0) scale(1);
}

.achievement-toast-title {
	font-size: 0.72rem;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	font-weight: 700;
	color: #ffd54f;
	margin-bottom: 3px;
}

.achievement-toast-name {
	font-size: 0.95rem;
	font-weight: 700;
	line-height: 1.2;
	margin-bottom: 2px;
}

.achievement-toast-desc {
	font-size: 0.8rem;
	color: #dbe6ff;
	line-height: 1.3;
}

#actions,
#buildings {
	overflow-x: auto;
}

#actions table,
#buildings table {
	min-width: 520px;
}

@media (max-width: 820px) {
	.menu-bar {
		height: auto;
		padding: 0.5rem 0.8rem;
		gap: 0.7rem;
		flex-wrap: wrap;
		align-items: stretch;
	}

	.header-time-container,
	.header-hp-container,
	.header-energy-container {
		flex: 1 1 180px;
	}

	.header-time-container {
		order: 1;
		width: 100%;
		gap: 0.45rem;
	}

	.header-resource-summary {
		order: 2;
		flex: 1 1 100%;
		padding: 0 0 2px;
		gap: 0.35rem;
		flex-wrap: nowrap;
		overflow-x: auto;
		overflow-y: hidden;
		-webkit-overflow-scrolling: touch;
		scrollbar-width: thin;
	}

	.header-resource-chip {
		font-size: 0.72rem;
		padding: 0.2rem 0.45rem;
		flex: 0 0 auto;
	}

	.header-time-container {
		flex-wrap: wrap;
		gap: 0.4rem;
	}

	.header-menu-btns {
		order: 3;
		flex: 1 1 100%;
		justify-content: space-between;
		flex-wrap: nowrap;
		gap: 0.4rem;
		align-items: center;
	}

	.header-vitals-stack {
		min-width: 0;
		flex: 1 1 auto;
	}

	.header-menu-btns .header-energy-container {
		flex: 0 0 auto;
		justify-content: stretch;
	}

	.condition-header-badge {
		font-size: 0.75rem;
		padding: 0.35rem 0.55rem;
	}

	.time-phase-badge {
		font-size: 0.75rem;
		padding: 0.35rem 0.55rem;
	}

	.menu-btn {
		margin-right: 0;
		padding: 0.45rem 0.65rem;
		font-size: 0.86rem;
	}

	.menu-dropdown {
		min-width: 210px;
	}

	.time-bar,
	.hp-bar,
	.energy-bar {
		width: 100%;
		min-width: 0;
	}

	.tab-bar {
		top: auto;
		padding: 0.2rem 0.35rem;
		gap: 0.35rem;
		flex-wrap: nowrap;
		overflow-x: auto;
		overflow-y: hidden;
		overscroll-behavior-x: contain;
		scroll-snap-type: x proximity;
		-webkit-overflow-scrolling: touch;
	}

	.tab-btn {
		flex: 0 0 auto;
		min-width: 116px;
		padding: 0.65rem 0.8rem;
		border-radius: 10px 10px 0 0;
		scroll-snap-align: start;
	}

	.tab-icon {
		width: 16px;
		height: 16px;
	}

	.container {
		padding-left: 0.65rem;
		padding-right: 0.65rem;
	}

	.panel {
		padding: 0.75rem;
	}

	button {
		padding: 0.45rem 0.62rem;
		font-size: 0.84rem;
	}

	.journal-content {
		padding: 0.55rem 0.7rem 0.25rem 0.7rem;
		max-height: calc(var(--mobile-journal-height) - 40px);
		overflow-y: auto;
		overscroll-behavior: contain;
	}

	.journal-bar {
		max-height: var(--mobile-journal-height);
	}

	.journal-layout {
		gap: 0.75rem;
	}

	body {
		padding-bottom: calc(var(--mobile-journal-height) + env(safe-area-inset-bottom, 0px));
	}
}

@media (min-width: 1650px) {
	.container,
	.journal-content {
		width: min(1700px, 100%);
	}

	.building-grid {
		grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
	}

	.craft-grid {
		grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
	}
}

@media (max-width: 560px) {
	:root {
		--mobile-journal-height: 210px;
	}

	.menu-bar {
		padding: 0.45rem 0.55rem;
		gap: 0.55rem;
	}

	.header-time-container,
	.header-menu-btns {
		flex-basis: 100%;
	}

	.header-menu-btns {
		align-items: flex-start;
	}

	.header-vitals-stack {
		gap: 0.35rem;
	}

	.time-phase-badge,
		.condition-header-badge {
		font-size: 0.7rem;
	}

	.tab-btn {
		min-width: 104px;
		font-size: 0.84rem;
		padding: 0.58rem 0.7rem;
		gap: 6px;
	}

	.panel,
		.dialog-box {
		border-radius: 10px;
	}

	.journal-content {
		padding-left: 0.55rem;
		padding-right: 0.55rem;
	}

	.time-text,
	.energy-text {
		font-size: 0.8rem;
	}

	.hp-text,
	.energy-text {
		font-size: 0.72rem;
	}

	.log {
		height: 74px;
		font-size: 0.8rem;
	}

	.achievement-toast-container {
		right: 8px;
		left: 8px;
		top: 62px;
		max-width: none;
	}
}

@media (pointer: coarse) {
	body {
		-webkit-tap-highlight-color: rgba(141, 212, 230, 0.18);
	}

	button,
	.tab-btn,
	.menu-dropdown-item,
	.title-save-preview-action,
	.action-queue-clear-btn,
	.action-queue-remove-btn,
	.building-assign-minus,
	.building-assign-plus,
	.journal-toggle-btn {
		touch-action: manipulation;
	}

	.tab-btn,
	.menu-dropdown-item,
	.title-save-preview-action,
	.action-queue-clear-btn,
	.action-queue-remove-btn {
		min-height: 44px;
	}

	.menu-btn--icon,
	.journal-toggle-btn,
	.building-assign-minus,
	.building-assign-plus {
		min-width: 44px;
		min-height: 44px;
	}

	.menu-dropdown-item {
		padding-top: 0.7rem;
		padding-bottom: 0.7rem;
	}

	.tab-btn,
	.menu-btn,
	.menu-dropdown-item,
	.building-assign-minus,
	.building-assign-plus,
	.action-queue-clear-btn,
	.action-queue-remove-btn,
	.journal-toggle-btn {
		transition: none;
	}

	button:hover:enabled,
	.tab-btn:hover:enabled,
	.menu-btn:hover,
	.menu-dropdown-item:hover,
	.building-assign-minus:hover:not(:disabled),
	.building-assign-plus:hover:not(:disabled),
	.journal-toggle-btn:hover {
		transform: none;
		box-shadow: none;
	}
}
