:root {
	--bg-0: #0c0a14;
	--bg-1: #15111f;
	--panel: rgba(32, 26, 48, 0.72);
	--panel-brd: rgba(232, 184, 109, 0.28);
	--gold: #e8b86d;
	--gold-soft: #f3d6a4;
	--ink: #ece7f5;
	--ink-dim: #a89fc0;
	--str: #e0556b;
	--dex: #4fd18b;
	--health: #5aa9ff;
	--win: #4fd18b;
	--lose: #e0556b;
	--radius: 16px;
	--cursor: url('src/cursor-sword.png') 2 2, auto;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
	margin: 0;
	font-family: 'Rubik', system-ui, sans-serif;
	color: var(--ink);
	background:
		radial-gradient(1100px 600px at 50% -10%, #2a2140 0%, transparent 60%),
		radial-gradient(900px 500px at 100% 100%, #1d2c3a 0%, transparent 55%),
		linear-gradient(160deg, var(--bg-1), var(--bg-0));
	background-attachment: fixed;
	min-height: 100vh;
	padding: clamp(12px, 3vw, 32px);
	cursor: var(--cursor);
	-webkit-user-select: none;
	-moz-user-select: none;
	-ms-user-select: none;
	user-select: none;
}

button { font-family: inherit; cursor: var(--cursor); }

h1, h2, h3, .vs, .modal__title {
	font-family: 'Cinzel', serif;
	letter-spacing: 0.04em;
}

/* ---------- Topbar ---------- */
.topbar {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 16px;
	margin-bottom: clamp(16px, 3vw, 32px);
}
.topbar__logo {
	width: clamp(38px, 6vw, 56px);
	height: auto;
	filter: drop-shadow(0 4px 10px rgba(232, 184, 109, 0.45));
}
.topbar__title {
	margin: 0;
	font-size: clamp(1.8rem, 5vw, 3rem);
	font-weight: 900;
	background: linear-gradient(180deg, var(--gold-soft), var(--gold));
	-webkit-background-clip: text;
	background-clip: text;
	color: transparent;
	text-shadow: 0 2px 18px rgba(232, 184, 109, 0.25);
}

/* ---------- Arena layout ---------- */
.arena {
	display: grid;
	grid-template-columns: 1fr minmax(160px, 220px) 1fr;
	gap: clamp(14px, 2vw, 24px);
	align-items: stretch;
	max-width: 1180px;
	margin: 0 auto;
}

.fighter {
	background: var(--panel);
	border: 1px solid var(--panel-brd);
	border-radius: var(--radius);
	padding: clamp(14px, 2vw, 22px);
	backdrop-filter: blur(10px);
	box-shadow: 0 20px 45px -20px rgba(0, 0, 0, 0.8), inset 0 1px 0 rgba(255, 255, 255, 0.05);
	display: flex;
	flex-direction: column;
	gap: 14px;
}
.fighter__name {
	margin: 0;
	text-align: center;
	font-size: 1.5rem;
	color: var(--gold-soft);
}
.fighter__art {
	position: relative;
	height: clamp(230px, 34vw, 360px);
	border-radius: 12px;
	overflow: hidden;
	background: linear-gradient(180deg, rgba(255, 255, 255, 0.04), rgba(0, 0, 0, 0.25));
	border: 1px solid rgba(255, 255, 255, 0.06);
	display: flex;
	align-items: center;
	justify-content: center;
}
.fighter__img {
	max-width: 100%;
	max-height: 100%;
	width: auto;
	height: auto;
	object-fit: contain;
	transition: transform 0.22s cubic-bezier(.34,1.56,.64,1);
	will-change: transform;
}
.fighter--warrior .fighter__img.lunge { transform: translateX(45%) scale(1.06); }
.fighter--monster .fighter__img.lunge { transform: translateX(-45%) scale(1.06); }
.art-placeholder {
	font-family: 'Cinzel', serif;
	font-size: 4rem;
	color: var(--ink-dim);
	opacity: 0.5;
}

/* ---------- Presets ---------- */
.presets {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	justify-content: center;
}
.preset {
	flex: 1 1 auto;
	border: 1px solid rgba(232, 184, 109, 0.3);
	background: linear-gradient(180deg, rgba(232, 184, 109, 0.16), rgba(232, 184, 109, 0.05));
	color: var(--gold-soft);
	padding: 8px 10px;
	border-radius: 10px;
	font-size: 0.82rem;
	font-weight: 500;
	white-space: nowrap;
	transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.2s ease;
}
.preset:hover:not(:disabled) {
	background: linear-gradient(180deg, rgba(232, 184, 109, 0.3), rgba(232, 184, 109, 0.12));
	transform: translateY(-2px);
	box-shadow: 0 8px 16px -8px rgba(232, 184, 109, 0.6);
}
.preset:active:not(:disabled) { transform: translateY(1px); }

/* ---------- Stats ---------- */
.stats { display: flex; flex-direction: column; gap: 10px; }
.stat {
	display: flex;
	align-items: center;
	gap: 10px;
}
.stat__body { flex: 1; min-width: 0; }
.stat__label {
	display: flex;
	align-items: center;
	gap: 6px;
	font-size: 0.82rem;
	color: var(--ink-dim);
	margin-bottom: 4px;
}
.stat__ic { font-size: 0.95rem; }
.stat__val {
	font-variant-numeric: tabular-nums;
	font-weight: 700;
	min-width: 1.4em;
	text-align: center;
	font-size: 1.05rem;
}
.bar {
	height: 12px;
	border-radius: 999px;
	background: rgba(0, 0, 0, 0.35);
	overflow: hidden;
	box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.6);
}
.bar__fill {
	height: 100%;
	width: 8%;
	border-radius: 999px;
	transition: width 0.35s cubic-bezier(.4,0,.2,1);
}
.stat--str .bar__fill { background: linear-gradient(90deg, #ff8aa0, var(--str)); }
.stat--dex .bar__fill { background: linear-gradient(90deg, #8af0bf, var(--dex)); }
.stat--health .bar__fill { background: linear-gradient(90deg, #9cccff, var(--health)); }
.stat--str .stat__ic { color: var(--str); }
.stat--dex .stat__ic { color: var(--dex); }
.stat--health .stat__ic { color: var(--health); }

/* +/- step buttons */
.step {
	width: 34px;
	height: 34px;
	flex: none;
	border-radius: 10px;
	border: 1px solid rgba(255, 255, 255, 0.12);
	background: linear-gradient(180deg, #3a3152, #2a2440);
	color: var(--ink);
	font-size: 1.25rem;
	line-height: 1;
	box-shadow: 0 4px 0 rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.08);
	transition: transform 0.08s ease, box-shadow 0.08s ease, opacity 0.2s ease;
}
.step:hover:not(:disabled) { background: linear-gradient(180deg, #463b63, #322a4d); }
.step:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 1px 0 rgba(0, 0, 0, 0.45); }
.step:disabled { opacity: 0.3; }

/* ---------- Free badge ---------- */
.free {
	text-align: center;
	font-weight: 500;
	color: var(--ink-dim);
	padding: 8px;
	border-radius: 10px;
	border: 1px dashed rgba(255, 255, 255, 0.15);
	transition: all 0.25s ease;
}
.free #freeVal { color: var(--gold); font-weight: 700; font-size: 1.15rem; }
.free--ready {
	color: var(--win);
	border-color: rgba(79, 209, 139, 0.5);
	background: rgba(79, 209, 139, 0.08);
}

/* ---------- Center ---------- */
.center {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 18px;
}
.vs {
	font-size: clamp(2rem, 5vw, 3.4rem);
	font-weight: 900;
	color: var(--gold);
	text-shadow: 0 0 24px rgba(232, 184, 109, 0.5);
	opacity: 0.85;
}
.fight-btn {
	border: none;
	border-radius: 14px;
	padding: 16px 26px;
	font-family: 'Cinzel', serif;
	font-weight: 700;
	font-size: 1.15rem;
	letter-spacing: 0.06em;
	color: #2a0d0d;
	background: linear-gradient(180deg, #ffd27a, #e8a04d);
	box-shadow: 0 8px 0 #9c5a1f, 0 16px 28px -10px rgba(232, 160, 77, 0.7);
	transition: transform 0.1s ease, box-shadow 0.1s ease, filter 0.2s ease;
}
.fight-btn:hover:not(:disabled) { filter: brightness(1.07); }
.fight-btn:active:not(:disabled) { transform: translateY(6px); box-shadow: 0 2px 0 #9c5a1f, 0 6px 14px -8px rgba(232, 160, 77, 0.7); }
.fight-btn:not(:disabled) { animation: pulse 1.8s ease-in-out infinite; }
.fight-btn:disabled {
	background: linear-gradient(180deg, #4a4360, #36304a);
	color: var(--ink-dim);
	box-shadow: 0 8px 0 rgba(0, 0, 0, 0.4);
	opacity: 0.8;
}
@keyframes pulse {
	0%, 100% { box-shadow: 0 8px 0 #9c5a1f, 0 16px 28px -10px rgba(232, 160, 77, 0.7); }
	50% { box-shadow: 0 8px 0 #9c5a1f, 0 16px 40px -6px rgba(255, 210, 122, 0.95); }
}
.hint {
	margin: 0;
	font-size: 0.8rem;
	color: var(--ink-dim);
	text-align: center;
	max-width: 200px;
}

/* ---------- Monster menu ---------- */
.monster-menu {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(82px, 1fr));
	gap: 8px;
}
.mon-card {
	border: 1px solid rgba(255, 255, 255, 0.12);
	background: linear-gradient(180deg, rgba(255,255,255,0.05), rgba(0,0,0,0.2));
	color: var(--ink);
	border-radius: 10px;
	padding: 8px 6px;
	font-size: 0.78rem;
	font-weight: 500;
	transition: transform 0.12s ease, border-color 0.2s ease, background 0.2s ease;
}
.mon-card:hover:not(:disabled) { transform: translateY(-2px); border-color: var(--panel-brd); }
.mon-card.is-selected {
	border-color: var(--gold);
	background: linear-gradient(180deg, rgba(232,184,109,0.28), rgba(232,184,109,0.08));
	color: var(--gold-soft);
	box-shadow: 0 0 0 1px var(--gold) inset, 0 8px 16px -8px rgba(232,184,109,0.5);
}
.mon-card__hp { display: block; font-size: 0.66rem; color: var(--ink-dim); margin-top: 2px; }

/* ---------- Damage popups ---------- */
.dmg {
	position: absolute;
	top: 12%;
	left: 50%;
	transform: translateX(-50%);
	font-family: 'Cinzel', serif;
	font-weight: 900;
	font-size: 2.1rem;
	color: #fff;
	-webkit-text-stroke: 1px rgba(0, 0, 0, 0.55);
	pointer-events: none;
	animation: floatUp 0.9s ease-out forwards;
}
.dmg--hit {
	color: #ff2e54;
	text-shadow: 0 0 10px rgba(255, 60, 90, 0.95), 0 0 22px rgba(255, 60, 90, 0.7), 0 2px 4px rgba(0, 0, 0, 0.8);
}
.dmg--miss {
	color: #66f0ff;
	font-size: 1.5rem;
	text-shadow: 0 0 10px rgba(102, 240, 255, 0.95), 0 0 22px rgba(102, 240, 255, 0.65), 0 2px 4px rgba(0, 0, 0, 0.8);
}
@keyframes floatUp {
	0% { opacity: 0; transform: translate(-50%, 10px) scale(0.7); }
	25% { opacity: 1; transform: translate(-50%, -6px) scale(1.1); }
	100% { opacity: 0; transform: translate(-50%, -46px) scale(1); }
}

/* ---------- Log ---------- */
.block-title { color: var(--gold-soft); margin: 0 0 10px; font-size: 1.1rem; }
.logpanel, .history {
	max-width: 1180px;
	margin: clamp(16px, 3vw, 28px) auto 0;
	background: var(--panel);
	border: 1px solid var(--panel-brd);
	border-radius: var(--radius);
	padding: clamp(14px, 2vw, 20px);
	backdrop-filter: blur(10px);
}
.log {
	height: 150px;
	overflow-y: auto;
	display: flex;
	flex-direction: column;
	gap: 2px;
	font-size: 0.9rem;
	padding-right: 6px;
}
.log__line {
	padding: 4px 8px;
	border-radius: 6px;
	background: rgba(0, 0, 0, 0.2);
	color: var(--ink-dim);
}
.log__line:first-child { color: var(--ink); background: rgba(232, 184, 109, 0.1); }

/* ---------- History ---------- */
.history__head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.history__head .block-title { margin: 0; }
.ghost-btn {
	border: 1px solid rgba(255, 255, 255, 0.18);
	background: transparent;
	color: var(--ink-dim);
	border-radius: 8px;
	padding: 6px 12px;
	font-size: 0.8rem;
	transition: color 0.2s, border-color 0.2s;
}
.ghost-btn:hover { color: var(--lose); border-color: var(--lose); }
.summary {
	font-size: 0.95rem;
	color: var(--ink-dim);
	margin-bottom: 12px;
	padding-bottom: 12px;
	border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.summary b { color: var(--ink); }
.history__list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.hist {
	display: grid;
	grid-template-columns: 92px 1fr auto auto;
	gap: 10px;
	align-items: center;
	padding: 8px 12px;
	border-radius: 8px;
	background: rgba(0, 0, 0, 0.22);
	border-left: 3px solid var(--ink-dim);
	font-size: 0.86rem;
}
.hist--win { border-left-color: var(--win); }
.hist--lose { border-left-color: var(--lose); }
.hist__res { font-weight: 700; }
.hist--win .hist__res { color: var(--win); }
.hist--lose .hist__res { color: var(--lose); }
.hist__mon { color: var(--ink-dim); }
.hist__build { color: var(--gold-soft); font-variant-numeric: tabular-nums; }
.hist__date { color: var(--ink-dim); font-size: 0.78rem; }

/* ---------- Modal ---------- */
.modal {
	position: fixed;
	inset: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	background: rgba(6, 4, 12, 0.72);
	backdrop-filter: blur(6px);
	z-index: 50;
	animation: fadeIn 0.25s ease;
}
.modal[hidden] { display: none; }
.modal__card {
	background: linear-gradient(180deg, var(--bg-1), var(--bg-0));
	border: 1px solid var(--panel-brd);
	border-radius: 20px;
	padding: 36px 40px;
	text-align: center;
	max-width: 380px;
	box-shadow: 0 30px 60px -20px rgba(0, 0, 0, 0.9);
	animation: popIn 0.3s cubic-bezier(.34,1.56,.64,1);
}
.modal__title { margin: 0 0 10px; font-size: 2.2rem; color: var(--lose); }
.modal--win .modal__title { color: var(--win); }
.modal__text { margin: 0 0 24px; color: var(--ink-dim); }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes popIn { from { opacity: 0; transform: scale(0.85) translateY(10px); } to { opacity: 1; transform: scale(1); } }

/* ---------- Responsive ---------- */
@media (max-width: 820px) {
	.arena { grid-template-columns: 1fr; }
	.center { order: 3; padding: 8px 0; }
	.fighter--warrior { order: 1; }
	.fighter--monster { order: 2; }
	.fight-btn { width: 100%; }
	.hist { grid-template-columns: 80px 1fr; grid-auto-rows: auto; }
	.hist__build, .hist__date { grid-column: 2; }
}
