:root {
	--color-bg-primary: #0f172a;
	--color-bg-secondary: #1e293b;
	--color-bg-tertiary: #334155;
	--color-text-primary: #f1f5f9;
	--color-text-secondary: #cbd5e1;
	--color-accent: #38bdf8;
	--color-success: #10b981;
	--color-warning: #f59e0b;
	--color-danger: #ef4444;
	--color-border: rgba(148, 163, 184, 0.3);
}

* {
	margin: 0;
	padding: 0;
	box-sizing: border-box;
}

body {
	font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
	background: var(--color-bg-primary);
	color: var(--color-text-primary);
	padding: 20px;
	line-height: 1.6;
}

.container {
	max-width: 1400px;
	margin: 0 auto;
}

h1, h2, h3 {
	margin-bottom: 1rem;
	color: var(--color-accent);
}

.visually-hidden {
	position: absolute;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border-width: 0;
}

.stats-panel {
	background: var(--color-bg-secondary);
	border: 2px solid var(--color-border);
	border-radius: 8px;
	padding: 20px;
	margin-bottom: 20px;
}

.stat-item {
	display: flex;
	justify-content: space-between;
	align-items: center;
	padding: 10px 0;
	border-bottom: 1px solid var(--color-border);
	flex-wrap: nowrap;
	gap: 10px;
}

.stat-item:last-child {
	border-bottom: none;
}

.stat-label {
	font-weight: 600;
	color: var(--color-text-secondary);
	white-space: nowrap;
	flex-shrink: 0;
}

.stat-value {
	font-size: 1.2rem;
	font-weight: 700;
	color: var(--color-accent);
	white-space: nowrap;
	text-align: right;
}

.section {
	background: var(--color-bg-secondary);
	border: 2px solid var(--color-border);
	border-radius: 8px;
	padding: 20px;
	margin-bottom: 20px;
}

.btn {
	background: var(--color-accent);
	color: var(--color-bg-primary);
	border: none;
	border-radius: 6px;
	padding: 12px 24px;
	font-size: 1rem;
	font-weight: 600;
	cursor: pointer;
	transition: all 0.2s;
	width: 100%;
	margin-bottom: 10px;
}

.btn:hover {
	background: #0ea5e9;
	transform: translateY(-2px);
}

.btn:active {
	transform: translateY(0);
}

.btn:disabled {
	background: #334155;
	color: #64748b;
	cursor: not-allowed;
	transform: none;
}

.btn:focus {
	outline: 3px solid var(--color-warning);
	outline-offset: 2px;
}

.btn-small {
	padding: 8px 16px;
	font-size: 0.9rem;
}

.building-item, .upgrade-item, .planet-item {
	background: rgba(56, 189, 248, 0.1);
	border: 1px solid var(--color-border);
	border-radius: 6px;
	padding: 15px;
	margin-bottom: 10px;
}

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

.item-name {
	font-weight: 600;
	font-size: 1.1rem;
}

.item-count {
	color: var(--color-success);
	font-weight: 700;
}

.item-description {
	color: var(--color-text-secondary);
	font-size: 0.9rem;
	margin-bottom: 8px;
}

.item-stats {
	display: flex;
	gap: 15px;
	font-size: 0.9rem;
	margin-bottom: 10px;
	flex-wrap: wrap;
}

.warning-message {
	background: rgba(239, 68, 68, 0.2);
	border: 1px solid var(--color-danger);
	border-radius: 4px;
	padding: 10px;
	margin: 10px 0;
	color: var(--color-danger);
	font-weight: 600;
}

.success-message {
	background: rgba(16, 185, 129, 0.2);
	border: 1px solid var(--color-success);
	border-radius: 4px;
	padding: 10px;
	margin: 10px 0;
	color: var(--color-success);
	font-weight: 600;
}

.achievement-item {
	background: rgba(16, 185, 129, 0.1);
	border: 2px solid var(--color-success);
	border-radius: 6px;
	padding: 15px;
	margin-bottom: 10px;
}

.achievement-locked {
	background: rgba(148, 163, 184, 0.1);
	border-color: var(--color-border);
	opacity: 0.6;
}

.tabs {
	display: flex;
	gap: 10px;
	margin-bottom: 20px;
	flex-wrap: wrap;
}

.tab-btn {
	background: var(--color-bg-secondary);
	border: 2px solid var(--color-border);
	color: var(--color-text-primary);
	padding: 10px 20px;
	border-radius: 6px;
	cursor: pointer;
	font-size: 1rem;
	transition: all 0.2s;
}

.tab-btn:hover {
	border-color: var(--color-accent);
}

.tab-btn.active {
	background: var(--color-accent);
	color: var(--color-bg-primary);
	border-color: var(--color-accent);
}

.tab-btn:focus {
	outline: 3px solid var(--color-warning);
	outline-offset: 2px;
}

.supply-chain {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
	gap: 10px;
	margin-top: 15px;
}

.chain-step {
	background: var(--color-bg-tertiary);
	border: 1px solid var(--color-border);
	border-radius: 6px;
	padding: 12px;
	text-align: center;
}

.chain-step-name {
	font-weight: 600;
	color: var(--color-accent);
	margin-bottom: 5px;
}

.chain-step-value {
	font-size: 1.1rem;
	color: var(--color-success);
}

.chain-step-rates {
	margin-top: 5px;
	font-size: 0.85rem;
}

.rate-supply {
	color: var(--color-success);
}

.rate-demand {
	color: var(--color-warning);
}

.planet-role {
	display: inline-block;
	padding: 4px 12px;
	border-radius: 12px;
	font-size: 0.85rem;
	font-weight: 600;
	margin-left: 10px;
}

.role-rubber {
	background: rgba(245, 158, 11, 0.2);
	color: var(--color-warning);
	border: 1px solid var(--color-warning);
}

.role-ball {
	background: rgba(56, 189, 248, 0.2);
	color: var(--color-accent);
	border: 1px solid var(--color-accent);
}

.role-hybrid {
	background: rgba(16, 185, 129, 0.2);
	color: var(--color-success);
	border: 1px solid var(--color-success);
}

#toast-container {
	position: fixed;
	top: 20px;
	right: 20px;
	z-index: 1000;
	display: flex;
	flex-direction: column;
	gap: 10px;
	pointer-events: none;
}

.toast {
	background: var(--color-bg-secondary);
	border: 2px solid var(--color-accent);
	border-radius: 8px;
	padding: 15px 20px;
	color: var(--color-text-primary);
	font-weight: 600;
	animation: toastIn 0.3s ease, toastOut 0.3s ease 3.7s forwards;
	max-width: 350px;
	pointer-events: auto;
}

.toast-desc {
	font-weight: normal;
	font-size: 0.9em;
	color: var(--color-text-secondary);
}

@keyframes toastIn {
	from { transform: translateX(100%); opacity: 0; }
	to { transform: translateX(0); opacity: 1; }
}

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

.upgrade-category {
	font-size: 0.75rem;
	text-transform: uppercase;
	letter-spacing: 0.05em;
	color: var(--color-text-secondary);
	margin-bottom: 4px;
}

.buy-toggle {
	display: flex;
	gap: 6px;
	margin-bottom: 15px;
}

.buy-toggle-btn {
	background: var(--color-bg-tertiary);
	border: 2px solid var(--color-border);
	color: var(--color-text-primary);
	padding: 6px 14px;
	border-radius: 6px;
	cursor: pointer;
	font-size: 0.9rem;
	font-weight: 600;
	transition: all 0.2s;
}

.buy-toggle-btn:hover {
	border-color: var(--color-accent);
}

.buy-toggle-btn.active {
	background: var(--color-accent);
	color: var(--color-bg-primary);
	border-color: var(--color-accent);
}

.buy-toggle-btn:focus {
	outline: 3px solid var(--color-warning);
	outline-offset: 2px;
}

.panel-toggle {
	background: none;
	border: none;
	color: var(--color-accent);
	cursor: pointer;
	font-size: 1.2rem;
	padding: 4px 8px;
	border-radius: 4px;
	float: right;
}

.panel-toggle:hover {
	background: var(--color-bg-tertiary);
}

.panel-toggle:focus {
	outline: 3px solid var(--color-warning);
	outline-offset: 2px;
}

.panel-header {
	display: flex;
	justify-content: space-between;
	align-items: center;
	cursor: pointer;
}

.panel-summary {
	color: var(--color-text-secondary);
	font-size: 0.9rem;
	margin-left: 10px;
}

.upgrade-tabs {
	display: flex;
	gap: 6px;
	margin-bottom: 15px;
	flex-wrap: wrap;
}

.upgrade-tab-btn {
	background: var(--color-bg-tertiary);
	border: 2px solid var(--color-border);
	color: var(--color-text-primary);
	padding: 6px 14px;
	border-radius: 6px;
	cursor: pointer;
	font-size: 0.85rem;
	font-weight: 600;
	transition: all 0.2s;
	position: relative;
}

.upgrade-tab-btn:hover {
	border-color: var(--color-accent);
}

.upgrade-tab-btn.active {
	background: var(--color-accent);
	color: var(--color-bg-primary);
	border-color: var(--color-accent);
}

.upgrade-tab-btn:focus {
	outline: 3px solid var(--color-warning);
	outline-offset: 2px;
}

.tab-badge {
	display: inline-block;
	background: var(--color-success);
	color: var(--color-bg-primary);
	border-radius: 50%;
	min-width: 18px;
	height: 18px;
	font-size: 0.7rem;
	font-weight: 700;
	text-align: center;
	line-height: 18px;
	margin-left: 6px;
}

@media (max-width: 768px) {
	body {
		padding: 10px;
	}

	.item-header {
		flex-direction: column;
		align-items: flex-start;
	}

	.item-stats {
		flex-direction: column;
		gap: 5px;
	}

	.supply-chain {
		grid-template-columns: 1fr;
	}
}
