/* ========================================
	 CSS Variables & Reset
	 ======================================== */

:root {
	/* Colors */
	--background: #fdfdf8;
	--foreground: #2d3319;
	--green-forest: #1e3a0f;
	--green-mid: #2d5016;
	--green-light: #d4e8c8;
	--green-mint: #e8ede0;
	--yellow-warm: #fbbf24;
	--yellow-bright: #fde047;
	--health-green: #22c55e;
	--attack-amber: #f59e0b;
	--defense-gray: #78716c;
	--danger-red: #dc2626;
	--warning-orange: #f59e0b;
	--white: #ffffff;
	--text-muted: #5d6b3e;
	--text-light: #cbd5b0;
	--border-color: rgba(45, 80, 22, 0.15);

	/* Spacing */
	--radius: 0.75rem;
	--radius-lg: 1rem;
	--radius-xl: 1.5rem;
}

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

body {
	font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
	background: linear-gradient(to bottom, var(--green-mint), var(--green-light));
	color: var(--foreground);
	line-height: 1.6;
}

/* ========================================
	 Screen Management
	 ======================================== */

.screen {
	display: none;
	min-height: 100vh;
}

.screen.active {
	display: block;
}

.screen-container {
	min-height: 100vh;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	padding: 2rem;
}

.main-content {
	max-width: 1400px;
	margin: 0 auto;
	padding: 2rem;
}

/* ========================================
	 STATE 1: Initial Screen
	 ======================================== */

.initial-content {
	max-width: 800px;
	width: 100%;
	text-align: center;
}

.logo-section {
	margin-bottom: 2rem;
}

/* .logo-box {
	display: inline-flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	width: 192px;
	height: 192px;
	background: linear-gradient(135deg, var(--green-mid), var(--green-forest));
	border-radius: var(--radius-xl);
	box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
	margin-bottom: 2rem;
	color: var(--white);
	position: relative;
}

.logo-icon {
	font-size: 4rem;
} */

.logo-text-large {
	font-size: 1.5rem;
	font-weight: 700;
	letter-spacing: 0.05em;
	margin-top: 0.5rem;
}

.logo-text-small {
	font-size: 1.25rem;
	font-weight: 700;
	letter-spacing: 0.05em;
}

.main-title {
	font-size: 3rem;
	font-weight: 700;
	color: var(--green-forest);
	margin-bottom: 1rem;
}

.main-subtitle {
	font-size: 1.25rem;
	color: var(--text-muted);
}

.button-section {
	margin: 2rem 0;
}

.btn-primary {
	padding: 1rem 3rem;
	background: linear-gradient(to right, var(--yellow-warm), var(--yellow-bright));
	color: var(--green-forest);
	border: none;
	border-radius: var(--radius-lg);
	font-size: 1.25rem;
	font-weight: 700;
	cursor: pointer;
	box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
	transition: all 0.2s;
}

.btn-primary:hover {
	box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.15);
	transform: scale(1.05);
}

.btn-primary:disabled {
	opacity: 0.5;
	cursor: not-allowed;
}

.btn-primary:disabled:hover {
	transform: scale(1);
}

.btn-primary.btn-full {
	width: 100%;
}

.btn-secondary {
	padding: 0.75rem 2rem;
	background: transparent;
	color: var(--green-mid);
	border: 2px solid var(--green-mid);
	border-radius: var(--radius-lg);
	font-size: 1rem;
	font-weight: 700;
	cursor: pointer;
	transition: all 0.2s;
}

.btn-secondary:hover {
	background: var(--green-mint);
}

.btn-secondary.btn-full {
	width: 100%;
}

.btn-wallet {
	margin: 0px 5px;
}

.nav-links {
	display: flex;
	gap: 1.5rem;
	justify-content: center;
	align-items: center;
	color: var(--text-muted);
}

.nav-links a {
	color: var(--text-muted);
	text-decoration: none;
	transition: color 0.2s;
}

.nav-links a:hover {
	color: var(--green-mid);
}

.nav-links .separator {
	color: var(--text-light);
}

/* ========================================
	 STATE 2: Connected Screen - Header
	 ======================================== */

.top-header {
	background: var(--green-mid);
	color: var(--white);
	padding: 0.75rem 1.5rem;
	display: flex;
	align-items: center;
	justify-content: space-between;
	box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.header-left {
	display: flex;
	align-items: center;
	gap: 1rem;
}

.header-icon {
	font-size: 1.5rem;
}

.header-title {
	font-size: 1.25rem;
	font-weight: 700;
}

.header-right {
	display: flex;
	align-items: center;
	gap: 1.5rem;
}

.wallet-info {
	display: flex;
	align-items: center;
	gap: 0.5rem;
	background: var(--green-forest);
	padding: 0.5rem 1rem;
	border-radius: var(--radius);
}

.wallet-label {
	font-size: 0.875rem;
	color: var(--green-light);
}

.wallet-address {
	font-family: 'Courier New', monospace;
	font-size: 0.875rem;
}

.btn-icon {
	background: transparent;
	border: none;
	color: var(--yellow-warm);
	font-size: 1.25rem;
	cursor: pointer;
	transition: color 0.2s;
}

.btn-icon:hover {
	color: var(--yellow-bright);
}

/* ========================================
	 STATE 2: Farm Section
	 ======================================== */

.farm-section {
	margin-bottom: 2rem;
}

.farm-header {
	display: flex;
	align-items: center;
	gap: 1rem;
	margin-bottom: 1.5rem;
}

.farm-icon {
	font-size: 2.5rem;
}

.farm-name {
	font-size: 2rem;
	font-weight: 700;
	color: var(--green-forest);
}

.farm-subtitle {
	color: var(--text-muted);
}

/* Fighter Cards */
.fighters-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
	gap: 1rem;
	margin-bottom: 1.5rem;
}

.fighter-card {
	background: var(--white);
	border-radius: var(--radius-lg);
	overflow: hidden;
	box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
	border: 2px solid var(--forest-green);
	transition: border-color 0.2s;
}

.battle-fighter-card {
	/* background: var(--white);
	border-radius: var(--radius-lg);
	overflow: hidden;
	box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
	border: 2px solid var(--forest-green);
	transition: border-color 0.2s; */
	background: var(--white);
	border-radius: var(--radius-lg);
	overflow: hidden;
	box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
	border: 2px solid var(--health-green);
	transition: all 0.2s ease-in-out;
	cursor: pointer; /* Indicates clickability */
	position: relative;
}

.battle-fighter-card:hover {
	/* border-color: #991b1b;
	border: 3px solid; */
	border-color: var(--yellow-warm);
	border-width: 3px;
	transform: translateY(-2px);
	box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

.battle-fighter-card.selected {
	border-color: #2d5016; 
	border-width: 4px;
	background: #fef2f2; 
	box-shadow: 0 0 0 4px rgba(38, 162, 75, 0.2); /* outer glow */
	transform: scale(1.02);
	z-index: 10;
}

.enemy-fighter {
	background: var(--white);border-radius: var(--radius-lg);
	overflow: hidden;
	box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
	transition: all 0.2s ease-in-out;
	cursor: pointer; 
	position: relative;
}

.enemy-fighter:hover {
	/* border-color: #991b1b;
	border: 3px solid; */
	border-color: var(--yellow-warm);
	border-width: 3px;
	transform: translateY(-2px);
	box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

.enemy-fighter.selected {
	border-color: #ef4444; 
	border-width: 4px !important;
	background: #fef2f2; 
	box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.2); 
	transform: scale(1.02);
	z-index: 10;
}

.fighter-image {
	aspect-ratio: 1;
	background: linear-gradient(135deg, var(--green-light), var(--green-mint));
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 4rem;
	/* width: 150px; */
	width: 100%;
}

.fighter-info {
	padding: 0.7rem;
}

.fighter-name {
	font-weight: 700;
	font-size: 0.9rem;
	color: var(--green-forest);
	text-align: center;
	margin-bottom: 0.75rem;
}

.fighter-stats {
	display: flex;
	flex-direction: column;
	gap: 0.5rem;
}

.stat-row {
	display: flex;
	/* justify-content: space-between; */
	gap: 0.3rem;
	/* margin: 0.6rem 0; */
}

.stat-chip {
	font-size: 0.75rem;
	font-weight: 700;
	padding: 0.2rem 0.3rem;
	border-radius: 30px;
	text-align: center;
	flex: 1;
	background: #f4f2ea;
}
.stat-chip.health { background: #e1f3e1; color: #2c6e2c; }
.stat-chip.attack { background: #fff0df; color: #ba0808; margin: 0rem 0.1rem; }
.stat-chip.defense { background: #ecebe4; color: #5a584b; }

.progress-bar {
	height: 6px;
	background: #e0ddd2;
	border-radius: 8px;
	margin-top: 4px;
	overflow: hidden;
}
.progress-fill {
	height: 6px;
	border-radius: 8px;
	width: 70%;
	background: var(--health-green);
}

.stat-label {
	color: var(--text-muted);
}


/* Farm Totals */
.farm-totals {
	background: var(--white);
	border-radius: var(--radius-lg);
	padding: 1.1rem;
	box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
	border: 2px solid #84cc16;
}

.totals-title {
	font-weight: 700;
	color: var(--green-forest);
	margin-bottom: 0.5rem;
}

.totals-grid {
	display: grid;
	grid-template-columns: repeat(3, 1fr);
	gap: 1.5rem;
	text-align: center;
}

.total-value {
	font-size: 2rem;
	font-weight: 700;
}

.total-value.health {
	color: var(--health-green);
}

.total-value.attack {
	color: var(--attack-amber);
}

.total-value.defense {
	color: var(--defense-gray);
}

.total-label {
	font-size: 0.875rem;
	color: var(--text-muted);
	margin-top: 0.1rem;
}

/* Select Victim Section */
.select-victim {
	background: var(--white);
	border-radius: var(--radius-lg);
	padding: 2rem;
	box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
	border: 2px solid var(--green-light);
}

.section-title {
	font-size: 1.5rem;
	font-weight: 700;
	color: var(--green-forest);
	margin-bottom: 1.5rem;
}

.select-form {
	display: flex;
	flex-direction: column;
	gap: 1rem;
}

.form-group {
	display: flex;
	flex-direction: column;
	gap: 0.5rem;
}

.form-group label {
	color: var(--text-muted);
	font-weight: 500;
}

.form-select {
	width: 100%;
	padding: 0.75rem 1rem;
	background: #f5f5f0;
	border: 2px solid var(--green-light);
	border-radius: var(--radius);
	font-size: 1rem;
	color: var(--foreground);
	cursor: pointer;
	transition: border-color 0.2s;
}

.form-select:focus {
	outline: none;
	border-color: #84cc16;
}

.help-text {
	font-size: 0.875rem;
	color: var(--text-muted);
	text-align: center;
}

/* ========================================
	 STATE 3: Battle Screen
	 ======================================== */

.battle-title {
	text-align: center;
	margin-bottom: 2rem;
}

.battle-heading {
	font-size: 2.5rem;
	font-weight: 700;
	color: var(--green-forest);
	margin-bottom: 0.5rem;
}

.battle-subheading {
	font-size: 1.25rem;
	color: var(--text-muted);
}

.player-name {
	color: var(--green-mid);
	font-weight: 700;
}

.enemy-name {
	color: var(--danger-red);
	font-weight: 700;
}

/* Two Farm Layout */
.battle-farms {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
	gap: 2rem;
	margin-bottom: 2rem;
}

.battle-farm {
	display: flex;
	flex-direction: column;
	gap: 1rem;
}

.battle-farm-header {
	border-radius: var(--radius-lg);
	padding: 1rem;
	display: flex;
	align-items: center;
	justify-content: space-between;
	color: var(--white);
}

.battle-farm-header.player {
	background: linear-gradient(135deg, var(--green-mid), var(--green-forest));
}

.battle-farm-header.enemy {
	background: linear-gradient(135deg, var(--danger-red), #991b1b);
}

.farm-info-left {
	display: flex;
	align-items: center;
	gap: 0.75rem;
}

.farm-icon-large {
	font-size: 2rem;
}

.battle-farm-name {
	font-weight: 700;
	font-size: 1.25rem;
}

.battle-farm-label {
	font-size: 0.875rem;
	opacity: 0.9;
}

.farm-hp {
	text-align: right;
}

.farm-hp-value {
	font-size: 1.5rem;
	font-weight: 700;
}

.farm-hp-value.player {
	color: #84cc16;
}

.farm-hp-value.enemy {
	color: var(--yellow-warm);
}

.farm-hp-label {
	font-size: 0.75rem;
	opacity: 0.9;
}


/* Battle Fighters */
.battle-fighters {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
	gap: 0.75rem;
}

.battle-fighter-card {
	background: var(--white);
	border-radius: var(--radius);
	padding: 0.75rem;
	box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
	border: 2px solid var(--green-mint);
	transition: border-color 0.2s;
}

.battle-fighter-card.player-fighter {
	border: 2px solid #84cc16;
}

.battle-fighter-card.defeated {
	opacity: 0.5;
}

.battle-fighter-icon {
	font-size: 2.5rem;
	text-align: center;
	margin-bottom: 0.5rem;
}

.battle-fighter-name {
	font-weight: 700;
	font-size: 0.9rem;
	text-align: center;
	margin-bottom: 0.5rem;
}

.battle-fighter-stats {
	display: flex;
	flex-direction: column;
	gap: 0.25rem;
}

.battle-stat-row {
	display: flex;
	justify-content: space-between;
	font-size: 0.7rem;
}

.battle-stat-label {
	color: var(--text-muted);
}

.battle-stat-value {
	font-weight: 700;
}

.battle-defender-card {
	background: var(--white);
	border-radius: var(--radius);
	padding: 0.75rem;
	box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
	border: 2px solid var(--green-mint);
	transition: border-color 0.2s;
}

.battle-defender-card.player-fighter {
	border: 2px solid #84cc16;
}

.battle-defender-card.defeated {
	opacity: 0.5;
}

.battle-fighter-card.enemy-fighter {
	border: 2px solid var(--dark-green);
}

.defeated-text {
	text-align: center;
	font-size: 0.75rem;
	font-weight: 700;
	color: var(--danger-red);
	margin-top: 0.5rem;
}

/* Battle Bottom Section */
.battle-bottom {
	display: grid;
	grid-template-columns: 2fr 1fr;
	gap: 1.5rem;
}

/* Battle Log */
.battle-log-panel {
	background: var(--white);
	border-radius: var(--radius-lg);
	padding: 1.5rem;
	box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
	border: 2px solid var(--green-light);
}

.log-title {
	font-weight: 700;
	font-size: 1.25rem;
	color: var(--green-forest);
	margin-bottom: 1rem;
	display: flex;
	align-items: center;
	gap: 0.5rem;
}

.battle-log {
	display: flex;
	flex-direction: column;
	gap: 0.5rem;
	max-height: 400px;
	overflow-y: auto;
}

.log-entry {
	font-size: 0.875rem;
	padding: 0.5rem;
	border-radius: var(--radius);
}

.log-entry.neutral {
	background: var(--green-mint);
}

.log-entry.player {
	background: var(--green-light);
}

.log-entry.enemy {
	/* background: var(--yellow-warm); */
	background: #fee2e2;
}

.log-entry.highlight {
	background: #fef3c7;
	border: 2px solid var(--yellow-warm);
}

.log-time {
	color: var(--text-muted);
}

.log-fighter.player {
	font-weight: 700;
	color: var(--green-mid);
}

.log-fighter.enemy {
	font-weight: 700;
	color: var(--danger-red);
}

.log-damage {
	color: var(--attack-amber);
	font-weight: 700;
}

.defeated-label {
	font-weight: 700;
	color: var(--danger-red);
}

/* Battle Controls */
.battle-controls-panel {
	display: flex;
	flex-direction: column;
	gap: 1rem;
}

.battle-controls {
	background: var(--white);
	border-radius: var(--radius-lg);
	padding: 1.5rem;
	box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
	border: 2px solid var(--green-light);
}

.controls-title {
	font-weight: 700;
	font-size: 1.25rem;
	color: var(--green-forest);
	margin-bottom: 1rem;
}

.battle-options {
	margin-top: 1rem;
	display: flex;
	flex-direction: column;
	gap: 0.5rem;
}

.checkbox-label {
	display: flex;
	align-items: center;
	gap: 0.5rem;
	font-size: 0.875rem;
	color: var(--text-muted);
	cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
	width: 1rem;
	height: 1rem;
	cursor: pointer;
}

.round-info {
	background: var(--white);
	border-radius: var(--radius-lg);
	padding: 1.5rem;
	box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
	border: 2px solid var(--green-light);
}

.round-info-title {
	font-weight: 700;
	color: var(--green-forest);
	margin-bottom: 0.75rem;
}

.round-stats {
	display: flex;
	flex-direction: column;
	gap: 0.5rem;
}

.round-stat-row {
	display: flex;
	justify-content: space-between;
	font-size: 0.875rem;
}

.round-stat-label {
	color: var(--text-muted);
}

.round-stat-value {
	font-weight: 700;
}

/* ========================================
	 STATE 4: End Screen
 ======================================== */

.end-content {
	max-width: 900px;
	width: 100%;
}

.end-logo-section {
	text-align: center;
	margin-bottom: 2rem;
}

.logo-box.victory {
	/* background: linear-gradient(135deg, #84cc16, var(--health-green)); */
}

.logo-box.defeat {
	/* background: linear-gradient(135deg, var(--defense-gray), var(--text-muted)); */
}

.confetti-icon {
	position: absolute;
	inset: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	margin-bottom: 8rem;
	font-size: 4rem;
	animation: bounce 1s infinite;
}

@keyframes bounce {
	0%, 100% {
		transform: translateY(0);
	}
	50% {
		transform: translateY(-10px);
	}
}

.end-title {
	font-size: 4rem;
	font-weight: 700;
	margin-bottom: 1rem;
}

.end-title.victory {
	color: var(--health-green);
}

.end-title.defeat {
	color: var(--defense-gray);
}

.end-subtitle {
	font-size: 1.5rem;
	color: var(--text-muted);
}

/* Battle Summary */
.battle-summary {
	background: var(--white);
	border-radius: var(--radius-xl);
	padding: 2rem;
	box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
	border: 2px solid var(--green-light);
	margin-bottom: 2rem;
}

.summary-title {
	font-size: 2rem;
	font-weight: 700;
	color: var(--green-forest);
	margin-bottom: 1.5rem;
	text-align: center;
}

.summary-farms {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
	gap: 2rem;
	margin-bottom: 1.5rem;
}

.summary-farm {
	padding: 1.5rem;
	border-radius: var(--radius-lg);
}

.summary-farm.victory {
	background: var(--green-light);
}

.summary-farm.defeat {
	background: var(--green-mint);
}

.summary-farm.victory-enemy {
	background: #fee2e2;
}

.summary-farm-icon {
	font-size: 2.5rem;
	margin-bottom: 0.5rem;
}

.summary-farm-name {
	font-weight: 700;
	font-size: 1.25rem;
	margin-bottom: 0.5rem;
}

.summary-stats {
	display: flex;
	flex-direction: column;
	gap: 0.25rem;
}

.summary-stat-row {
	display: flex;
	justify-content: space-between;
	font-size: 0.875rem;
}

.summary-stat-label {
	color: var(--text-muted);
}

.summary-stat-value {
	font-weight: 700;
}

/* MVP Section */
.mvp-section {
	background: linear-gradient(to right, var(--yellow-warm), var(--yellow-bright));
	border-radius: var(--radius-lg);
	padding: 1.5rem;
	margin-bottom: 1.5rem;
}

.mvp-title {
	font-weight: 700;
	font-size: 1.25rem;
	color: var(--green-forest);
	margin-bottom: 0.75rem;
	text-align: center;
}

.mvp-content {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 1rem;
}

.mvp-icon {
	font-size: 3rem;
}

.mvp-info {
	text-align: left;
}

.mvp-name {
	font-weight: 700;
	font-size: 1.5rem;
	color: var(--green-forest);
}

.mvp-stat {
	font-size: 0.875rem;
	color: var(--text-muted);
}

/* Battle Stats Grid */
.battle-stats-grid {
	display: grid;
	grid-template-columns: repeat(3, 1fr);
	gap: 1rem;
	text-align: center;
	margin-bottom: 1.5rem;
}

.battle-stat-value {
	/* font-size: 1.1rem; */
	font-weight: 700;
	color: var(--green-forest);
}

.battle-stat-label {
	font-size: 0.875rem;
	color: var(--text-muted);
}

/* End Actions */
.end-actions {
	display: flex;
	flex-direction: column;
	gap: 0.75rem;
}

/* ========================================
	 Responsive Design
	 ======================================== */

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

	.battle-farms {
		grid-template-columns: 1fr;
	}
}

@media (max-width: 768px) {
	.main-title {
		font-size: 2rem;
	}

	.main-subtitle {
		font-size: 1rem;
	}

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

	.totals-grid {
		grid-template-columns: 1fr;
	}

	.battle-heading {
		font-size: 1.75rem;
	}

	.battle-fighters {
		grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
	}

	.end-title {
		font-size: 2.5rem;
	}

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

	.header-right {
		flex-direction: column;
		align-items: flex-end;
		gap: 0.5rem;
	}
}

@media (max-width: 480px) {
	.logo-image {
		width: 128px;
	}
	.logo-box {
		width: 140px;
		height: 140px;
	}

	.logo-icon {
		font-size: 3rem;
	}

	.main-title {
		font-size: 1.5rem;
	}

	.fighters-grid {
		grid-template-columns: 1fr;
	}

	.battle-stats-grid {
		grid-template-columns: 1fr;
	}
}
