/**
 * Burn Rate — presentation.
 *
 * One dark palette, shared with the canvas so the DOM chrome and the game
 * itself read as one thing. Every screen is positioned over the canvas rather
 * than replacing it, and the ones that fully cover it are opaque, because the
 * canvas keeps whatever it last drew.
 */

:root {
	--ink: #edf1f7;
	--ink-dim: #8a97ab;
	--bg: #0b1017;
	--panel: rgba(18, 26, 36, 0.96);
	--line: rgba(120, 140, 170, 0.18);

	--blue: #5b8def;
	--green: #5bbfa8;
	--gold: #e0a83e;
	--red: #e0554f;
	--violet: #c98ae0;

	--safe-t: env(safe-area-inset-top, 0px);
	--safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

html, body {
	margin: 0;
	padding: 0;
	height: 100%;
	overflow: hidden;
	background: var(--bg);
	color: var(--ink);
	font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
	-webkit-font-smoothing: antialiased;
	overscroll-behavior: none;
	touch-action: none;
}

#stage {
	position: fixed;
	inset: 0;
	display: block;
	touch-action: none;
}

h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -0.015em; }

/* --------------------------------------------------------------- buttons */

.btn {
	appearance: none;
	border: 1px solid rgba(140, 165, 200, 0.28);
	background: linear-gradient(180deg, #22304a, #18222f);
	color: var(--ink);
	font: inherit;
	font-weight: 600;
	padding: 12px 20px;
	min-height: 46px;
	border-radius: 11px;
	cursor: pointer;
	transition: transform 0.08s ease, filter 0.15s ease, border-color 0.15s ease;
}

.btn:hover:not(:disabled) { filter: brightness(1.16); border-color: rgba(140, 165, 200, 0.45); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.btn:disabled { opacity: 0.4; cursor: default; }

.btn--lg { font-size: 17px; padding: 15px 30px; min-height: 54px; }
.btn--small { font-size: 13px; padding: 9px 14px; min-height: 40px; }

.btn--ghost {
	background: rgba(255, 255, 255, 0.04);
	border-color: rgba(140, 165, 200, 0.2);
	color: var(--ink-dim);
}

.iconbtn {
	appearance: none;
	border: 1px solid rgba(140, 165, 200, 0.24);
	background: rgba(10, 15, 22, 0.6);
	color: var(--ink);
	width: 44px;
	height: 44px;
	border-radius: 11px;
	font-size: 13px;
	cursor: pointer;
}

/* --------------------------------------------------------------- screens */

.screen {
	position: fixed;
	z-index: 10;
	display: flex;
	flex-direction: column;
}

.screen[hidden] { display: none; }

/*
 * Full-cover screens are opaque on purpose: the canvas underneath still holds
 * the last frame of the previous run, and a translucent menu over a frozen
 * death screen looks like a bug.
 */
.screen--title,
.screen--menu {
	inset: 0;
	background:
		radial-gradient(1100px 620px at 50% -10%, #1a2740 0%, transparent 70%),
		linear-gradient(180deg, #0c121b, #070a10);
	overflow-y: auto;
	overscroll-behavior: contain;
	-webkit-overflow-scrolling: touch;
	touch-action: pan-y;
}

.screen--title { align-items: center; justify-content: center; text-align: center; }

.title__inner {
	padding: calc(28px + var(--safe-t)) 22px calc(28px + var(--safe-b));
	max-width: 520px;
	width: 100%;
}

.screen--title h1 {
	font-size: clamp(44px, 13vw, 76px);
	line-height: 1;
	letter-spacing: -0.035em;
	background: linear-gradient(180deg, #ffffff, #7d95c0);
	-webkit-background-clip: text;
	background-clip: text;
	color: transparent;
}

.lede { color: var(--ink-dim); margin: 14px auto 26px; max-width: 34ch; }
.best { color: var(--green); font-size: 13px; margin: 22px 0 2px; min-height: 1em; }
.capital { color: var(--gold); font-size: 13px; margin: 0; font-variant-numeric: tabular-nums; }
.controls { color: rgba(138, 151, 171, 0.65); font-size: 12px; margin: 20px auto 0; max-width: 40ch; }

.stack { display: flex; flex-direction: column; gap: 10px; }
.stack--wide { max-width: 320px; margin: 0 auto; }

/* Bottom sheets: level-up, chest, pause, end. */
.screen--sheet {
	left: 0;
	right: 0;
	bottom: 0;
	top: auto;
	max-height: 88vh;
	overflow-y: auto;
	overscroll-behavior: contain;
	padding: 22px 18px calc(22px + var(--safe-b));
	background: var(--panel);
	backdrop-filter: blur(14px);
	border-top: 1px solid var(--line);
	border-radius: 20px 20px 0 0;
	box-shadow: 0 -20px 60px rgba(0, 0, 0, 0.5);
	animation: rise 0.18s ease-out;
}

@keyframes rise { from { transform: translateY(18px); opacity: 0; } }

.screen--sheet h2 { font-size: 20px; }
.sub { color: var(--ink-dim); margin: 4px 0 16px; font-size: 14px; }

@media (min-width: 720px) {
	.screen--sheet {
		left: 50%;
		right: auto;
		transform: translateX(-50%);
		width: 680px;
	}
}

/* ------------------------------------------------------------------- hud */

.hud {
	position: fixed;
	inset: 0;
	z-index: 5;
	pointer-events: none;
	padding: calc(10px + var(--safe-t)) 12px calc(10px + var(--safe-b));
	display: flex;
	flex-direction: column;
	gap: 8px;
}

.hud[hidden] { display: none; }
.hud button { pointer-events: auto; }

.hud__top { display: flex; align-items: flex-start; gap: 12px; }

.hp { flex: 1 1 0; max-width: 260px; }

.hp__bar {
	height: 12px;
	border-radius: 7px;
	background: rgba(8, 12, 18, 0.7);
	border: 1px solid rgba(140, 165, 200, 0.22);
	overflow: hidden;
}

.hp__fill {
	display: block;
	height: 100%;
	width: 100%;
	background: linear-gradient(90deg, #4fc08d, #7ee0b0);
	transition: width 0.14s linear, background 0.3s ease;
}

.hp__fill.is-low { background: linear-gradient(90deg, #e0554f, #ff8a7d); }

.hp__text {
	display: block;
	font-size: 11px;
	color: var(--ink-dim);
	margin-top: 3px;
	font-variant-numeric: tabular-nums;
}

.hud__mid { flex: 0 0 auto; text-align: center; }

.timer {
	font-size: 24px;
	font-weight: 700;
	font-variant-numeric: tabular-nums;
	text-shadow: 0 2px 10px rgba(0, 0, 0, 0.6);
}

.timer.is-boss { color: var(--red); }

.hud__right { flex: 1 1 0; display: flex; align-items: center; justify-content: flex-end; gap: 10px; }

.revenue {
	font-size: 13px;
	color: var(--gold);
	font-variant-numeric: tabular-nums;
	text-shadow: 0 2px 8px rgba(0, 0, 0, 0.6);
}

.hud__xp { display: flex; align-items: center; gap: 8px; }

.level { font-size: 11px; color: var(--ink-dim); min-width: 42px; }

.xp__bar {
	flex: 1;
	height: 5px;
	border-radius: 3px;
	background: rgba(8, 12, 18, 0.7);
	overflow: hidden;
}

.xp__fill {
	display: block;
	height: 100%;
	background: linear-gradient(90deg, var(--blue), #9dc0ff);
	transition: width 0.1s linear;
}

.bossbar { margin: 2px auto 0; width: min(560px, 92%); text-align: center; }
.bossbar[hidden] { display: none; }

.bossbar__name {
	display: block;
	font-size: 11px;
	letter-spacing: 0.14em;
	text-transform: uppercase;
	color: var(--red);
	margin-bottom: 3px;
}

.bossbar__track {
	height: 9px;
	border-radius: 5px;
	background: rgba(8, 12, 18, 0.8);
	border: 1px solid rgba(224, 85, 79, 0.4);
	overflow: hidden;
}

.bossbar__fill {
	display: block;
	height: 100%;
	background: linear-gradient(90deg, #8d1f1a, var(--red));
	transition: width 0.12s linear;
}

.bossbar.is-shielded .bossbar__fill { background: linear-gradient(90deg, #2b4a86, var(--blue)); }
.bossbar.is-enraged .bossbar__track { animation: pulseline 0.7s ease-in-out infinite; }

@keyframes pulseline {
	50% { border-color: rgba(255, 255, 255, 0.8); }
}

.eventchip {
	align-self: center;
	margin: 0;
	padding: 5px 13px;
	border-radius: 999px;
	background: rgba(201, 138, 224, 0.16);
	border: 1px solid rgba(201, 138, 224, 0.45);
	color: var(--violet);
	font-size: 12px;
	font-weight: 600;
}

.eventchip[hidden] { display: none; }

.weapons { margin-top: auto; display: flex; flex-wrap: wrap; gap: 6px; }

.wchip {
	display: inline-flex;
	align-items: center;
	gap: 5px;
	padding: 4px 9px 4px 7px;
	border-radius: 9px;
	background: rgba(10, 15, 22, 0.68);
	border: 1px solid rgba(140, 165, 200, 0.22);
	font-size: 12px;
}

.wchip b { font-size: 14px; line-height: 1; }
.wchip i { font-style: normal; color: var(--ink-dim); font-variant-numeric: tabular-nums; }
.wchip.is-max i { color: var(--gold); font-weight: 700; }
.wchip.is-evolved { border-color: rgba(224, 168, 62, 0.6); background: rgba(224, 168, 62, 0.12); }
.wchip.is-merged { border-color: rgba(91, 141, 239, 0.6); background: rgba(91, 141, 239, 0.12); }

/* --------------------------------------------------------- level-up cards */

.choices { display: grid; gap: 10px; }

@media (min-width: 720px) {
	.choices { grid-template-columns: 1fr 1fr; }
}

.choice {
	appearance: none;
	text-align: left;
	font: inherit;
	color: var(--ink);
	background: linear-gradient(180deg, rgba(38, 50, 70, 0.85), rgba(22, 30, 42, 0.85));
	border: 1px solid var(--line);
	border-left: 3px solid var(--ink-dim);
	border-radius: 12px;
	padding: 13px 14px;
	cursor: pointer;
	transition: transform 0.08s ease, filter 0.15s ease;
}

.choice:hover { filter: brightness(1.14); }
.choice:active { transform: translateY(1px); }
.choice:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }

.choice--common { border-left-color: #8a97ab; }
.choice--rare { border-left-color: var(--blue); }
.choice--epic { border-left-color: var(--violet); }
.choice--legendary { border-left-color: var(--gold); }

/*
 * Evolutions and mergers get their own treatment. They are the payoff the
 * whole build has been aiming at and they must not look like a fourth damage
 * upgrade.
 */
.choice--payoff {
	background: linear-gradient(180deg, rgba(224, 168, 62, 0.22), rgba(30, 26, 18, 0.9));
	border-color: rgba(224, 168, 62, 0.5);
	animation: glowcard 1.6s ease-in-out infinite;
}

@keyframes glowcard {
	50% { border-color: rgba(255, 220, 150, 0.9); }
}

.choice__head { display: flex; align-items: center; gap: 10px; }
.choice__icon { font-size: 22px; line-height: 1; flex: 0 0 auto; }
.choice__head h3 { font-size: 15px; }
.choice__note { margin: 1px 0 0; font-size: 11px; color: var(--ink-dim); }
.choice__text { margin: 9px 0 0; font-size: 13px; color: #c3cddd; }

.choice kbd {
	margin-left: auto;
	font: 600 11px/1 ui-monospace, Menlo, monospace;
	padding: 4px 7px;
	border-radius: 6px;
	background: rgba(0, 0, 0, 0.4);
	border: 1px solid var(--line);
	color: var(--ink-dim);
}

.offeractions { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }

.is-banishing .choice {
	border-left-color: var(--red);
	filter: saturate(0.5);
}

.is-banishing .choice:hover { filter: saturate(1) brightness(1.1); }

/* ------------------------------------------------------------------ chest */

.chest__title { color: var(--gold); }
.chestitems { display: grid; gap: 8px; margin-bottom: 16px; }

.chestitem {
	display: flex;
	align-items: center;
	gap: 11px;
	padding: 10px 12px;
	border-radius: 11px;
	background: rgba(224, 168, 62, 0.1);
	border: 1px solid rgba(224, 168, 62, 0.32);
	animation: pop 0.32s ease-out backwards;
}

@keyframes pop {
	from { transform: scale(0.9) translateY(8px); opacity: 0; }
}

.chestitem__icon { font-size: 22px; }
.chestitem strong { display: block; font-size: 14px; }
.chestitem span { font-size: 12px; color: var(--ink-dim); }

/* ------------------------------------------------------- banner & toasts */

.banner {
	position: fixed;
	top: calc(24% + var(--safe-t));
	left: 0;
	right: 0;
	z-index: 8;
	text-align: center;
	pointer-events: none;
	padding: 0 18px;
}

.banner[hidden] { display: none; }

.banner strong {
	display: block;
	font-size: clamp(26px, 8vw, 42px);
	font-weight: 750;
	letter-spacing: -0.03em;
	color: var(--red);
	text-shadow: 0 3px 22px rgba(0, 0, 0, 0.85);
}

.banner span { display: block; font-size: 14px; color: var(--ink); opacity: 0.85; margin-top: 4px; }
.banner.is-event strong { color: var(--violet); }
.banner.is-in { animation: bannerin 0.4s cubic-bezier(0.2, 1.3, 0.4, 1); }

@keyframes bannerin {
	from { transform: scale(0.82); opacity: 0; }
}

.toasts {
	position: fixed;
	right: 12px;
	bottom: calc(78px + var(--safe-b));
	z-index: 8;
	display: flex;
	flex-direction: column;
	gap: 6px;
	align-items: flex-end;
	pointer-events: none;
}

.toast {
	margin: 0;
	padding: 7px 13px;
	border-radius: 999px;
	background: rgba(14, 20, 29, 0.92);
	border: 1px solid var(--line);
	font-size: 12px;
	animation: toastin 0.25s ease-out;
	transition: opacity 0.4s ease, transform 0.4s ease;
}

.toast.is-out { opacity: 0; transform: translateX(14px); }

@keyframes toastin {
	from { opacity: 0; transform: translateX(18px); }
}

/* ------------------------------------------------------------- the menu */

.menu {
	width: min(760px, 100%);
	margin: 0 auto;
	padding: calc(20px + var(--safe-t)) 16px calc(20px + var(--safe-b));
	display: flex;
	flex-direction: column;
	min-height: 100%;
}

.menu__head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.menu__head h2 { font-size: 24px; }
.menu__capital { margin: 0; color: var(--gold); font-size: 14px; font-variant-numeric: tabular-nums; }

.tabs {
	display: flex;
	gap: 6px;
	margin: 16px 0 14px;
	padding: 4px;
	background: rgba(8, 12, 18, 0.6);
	border: 1px solid var(--line);
	border-radius: 12px;
}

.tab {
	appearance: none;
	flex: 1;
	border: 0;
	background: transparent;
	color: var(--ink-dim);
	font: inherit;
	font-weight: 600;
	font-size: 13px;
	padding: 9px 6px;
	min-height: 42px;
	border-radius: 9px;
	cursor: pointer;
}

.tab.is-on { background: rgba(91, 141, 239, 0.2); color: var(--ink); }
.tab:focus-visible { outline: 2px solid var(--blue); outline-offset: -2px; }

.panel { display: grid; gap: 9px; }
.panel[hidden] { display: none; }

.panel__head {
	font-size: 11px;
	letter-spacing: 0.15em;
	text-transform: uppercase;
	color: var(--ink-dim);
	margin: 12px 0 0;
}

.panel__note { margin: 0 0 4px; font-size: 12px; color: var(--ink-dim); }

.card {
	display: grid;
	gap: 8px;
	padding: 13px 14px;
	border-radius: 12px;
	background: rgba(20, 28, 40, 0.8);
	border: 1px solid var(--line);
	border-left: 3px solid transparent;
}

.card.is-on { border-color: rgba(91, 141, 239, 0.5); background: rgba(91, 141, 239, 0.1); }
.card.is-locked { opacity: 0.72; }
.card--common { border-left-color: #8a97ab; }
.card--rare { border-left-color: var(--blue); }
.card--epic { border-left-color: var(--violet); }
.card--legendary { border-left-color: var(--gold); }

.card__head { display: flex; align-items: center; gap: 10px; }
.card__icon { font-size: 24px; }
.card__head strong { display: block; font-size: 15px; }
.card__sub { font-size: 11px; color: var(--ink-dim); }
.card p { margin: 0; font-size: 13px; color: #c3cddd; }
.card .btn { justify-self: start; }

.menu__foot { margin-top: auto; padding-top: 18px; }
.menu__foot .btn { width: 100%; }

.records { display: grid; gap: 2px; margin-bottom: 6px; }

.stat {
	display: flex;
	justify-content: space-between;
	gap: 12px;
	margin: 0;
	padding: 7px 0;
	border-bottom: 1px solid rgba(120, 140, 170, 0.1);
	font-size: 14px;
}

.stat span { color: var(--ink-dim); }
.stat strong { font-variant-numeric: tabular-nums; }
.stat--total { border-bottom: 0; border-top: 1px solid var(--line); margin-top: 6px; }
.stat--total strong { color: var(--gold); }

.ach {
	display: grid;
	grid-template-columns: 20px 1fr;
	gap: 2px 8px;
	margin: 0;
	padding: 8px 0;
	border-bottom: 1px solid rgba(120, 140, 170, 0.1);
	opacity: 0.5;
}

.ach.is-got { opacity: 1; }
.ach b { grid-row: span 2; color: var(--green); text-align: center; }
.ach span { font-size: 14px; font-weight: 600; }
.ach em { grid-column: 2; font-style: normal; font-size: 12px; color: var(--ink-dim); }

/* --------------------------------------------------------------- settings */

.settings { display: grid; gap: 12px; margin-bottom: 18px; }

.setting {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 14px;
	font-size: 14px;
	color: var(--ink-dim);
}

.setting input[type="range"] { flex: 1; max-width: 60%; accent-color: var(--blue); }
.setting--check { justify-content: flex-start; }
.setting--check input { width: 20px; height: 20px; accent-color: var(--blue); }

/*
 * Respect a system-level preference for less motion. The looping decorative
 * animations are the ones that cause trouble; the short transitions that tell
 * you a button was pressed are worth keeping.
 */
@media (prefers-reduced-motion: reduce) {
	.choice--payoff,
	.bossbar.is-enraged .bossbar__track {
		animation: none;
	}

	.screen--sheet,
	.chestitem,
	.banner.is-in,
	.toast {
		animation-duration: 0.01s;
	}
}
