/* Gladiator: dark leather, parchment text, gold trim. Tokens first, then layout, then components. */

:root {
	color-scheme: dark;
	--bg: #120c08;
	--bg-2: #1a120c;
	--panel: #24180f;
	--panel-2: #2e1f14;
	--inset: #150e09;
	--border: #4d331d;
	--border-hi: #7a5530;
	--text: #ecdcc2;
	--muted: #a38c70;
	--gold: #e0b35a;
	--gold-dim: #9b7535;
	--red: #d04a3c;
	--green: #6cc160;
	--ruby: #e2507f;
	--blue: #5b8fe0;
	--hp: #b8322a;
	--xp: #c9952f;
	--cell: 52px;
	--radius: 6px;
	--font-title: 'Cinzel', 'Times New Roman', serif;
	--font-body: 'Alegreya Sans', 'Segoe UI', system-ui, sans-serif;
	--shadow: 0 6px 24px rgb(0 0 0 / 45%);
}

* { box-sizing: border-box; }

html, body { margin: 0; min-height: 100%; }

body {
	background: var(--bg);
	background-image:
		radial-gradient(ellipse at top, rgb(122 70 30 / 22%), transparent 60%),
		radial-gradient(ellipse at bottom, rgb(60 20 10 / 30%), transparent 60%);
	background-attachment: fixed;
	color: var(--text);
	font: 16px/1.45 var(--font-body);
	-webkit-font-smoothing: antialiased;
}

a { color: var(--gold); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { font-family: var(--font-title); font-weight: 600; margin: 0; letter-spacing: 0.03em; }
h1 { font-size: 1.7rem; color: var(--gold); }
h2 { font-size: 1.3rem; }
h3 { font-size: 1.05rem; color: var(--gold); margin-bottom: 0.6rem; }
h3 .muted { font-family: var(--font-body); font-size: 0.85rem; letter-spacing: 0; }
p { margin: 0.3rem 0; }
table { border-collapse: collapse; width: 100%; }
button, input, select { font: inherit; color: inherit; }

.muted { color: var(--muted); }
.up { color: var(--green); }
.down, .bad { color: var(--red); }
.gold-text { color: var(--gold); }
.ruby-text { color: var(--ruby); }
.right { text-align: right; }
.row { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; }

/* ---------- Buttons ---------- */

.btn {
	display: inline-flex; align-items: center; justify-content: center; gap: 0.35rem;
	padding: 0.5rem 1rem; border-radius: var(--radius); cursor: pointer;
	border: 1px solid var(--border-hi); background: var(--panel-2); color: var(--text);
	transition: background 0.15s, border-color 0.15s, transform 0.05s;
	white-space: nowrap;
}
.btn:hover:not(:disabled) { border-color: var(--gold); background: #3a2818; text-decoration: none; }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.primary { background: linear-gradient(#8a5a26, #5e3a16); border-color: var(--gold-dim); color: #fff3dc; font-weight: 700; }
.btn.primary:hover:not(:disabled) { background: linear-gradient(#a06a2e, #6e451b); }
.btn.ruby { background: #4a1a2a; border-color: #8a3352; }
.btn.ruby:hover:not(:disabled) { background: #5e2236; border-color: var(--ruby); }
.btn.ghost { background: transparent; }
.btn.small { padding: 0.3rem 0.7rem; font-size: 0.9rem; }

.icon-btn { background: none; border: 0; padding: 0.35rem; cursor: pointer; color: var(--muted); border-radius: var(--radius); display: inline-flex; }
.icon-btn:hover { color: var(--gold); background: rgb(255 255 255 / 5%); }

.tabs { display: inline-flex; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.tabs button { background: transparent; border: 0; padding: 0.45rem 1rem; cursor: pointer; color: var(--muted); }
.tabs button.active { background: var(--panel-2); color: var(--gold); }

input, select {
	background: var(--inset); border: 1px solid var(--border); border-radius: var(--radius);
	padding: 0.55rem 0.7rem; outline: none;
}
input:focus, select:focus { border-color: var(--gold-dim); }
label { display: grid; gap: 0.3rem; color: var(--muted); font-size: 0.9rem; }
label.inline { display: inline-flex; align-items: center; gap: 0.5rem; }

/* ---------- Shell ---------- */

.shell { max-width: 1320px; margin: 0 auto; padding: 0 16px 48px; }

.top { position: sticky; top: 0; z-index: 20; background: rgb(18 12 8 / 92%); backdrop-filter: blur(6px); border-bottom: 1px solid var(--border); margin: 0 -16px 16px; padding: 0 16px; }
.top-row { display: flex; align-items: center; gap: 1rem; padding: 0.5rem 0; }
.logo { font-family: var(--font-title); font-weight: 800; font-size: 1.5rem; letter-spacing: 0.18em; color: var(--gold); text-shadow: 0 2px 0 #000, 0 0 18px rgb(224 179 90 / 25%); }
.logo:hover { text-decoration: none; }
.logo.big { font-size: clamp(2.4rem, 7vw, 4rem); }
.top-meta { margin-left: auto; display: flex; align-items: center; gap: 0.8rem; color: var(--muted); font-size: 0.9rem; }
.speed { border: 1px solid var(--border); border-radius: 99px; padding: 0.05rem 0.6rem; color: var(--gold); }
.menu-btn { display: none; }

.resources { display: flex; flex-wrap: wrap; align-items: center; gap: 0.6rem 1.1rem; padding: 0.35rem 0 0.55rem; }
.res { display: inline-flex; align-items: center; gap: 0.3rem; font-weight: 500; color: var(--text); }
.res.big { font-size: 1.4rem; }
.who { display: inline-flex; align-items: center; gap: 0.35rem; }

.meter { position: relative; display: inline-block; width: 150px; height: 18px; border-radius: 99px; background: var(--inset); border: 1px solid var(--border); overflow: hidden; vertical-align: middle; }
.meter.wide { width: 100%; height: 22px; margin: 0.6rem 0; }
.meter-fill { position: absolute; inset: 0 auto 0 0; transition: width 0.4s ease; }
.meter.hp .meter-fill { background: linear-gradient(#d9473c, var(--hp)); }
.meter.xp .meter-fill { background: linear-gradient(#e3b04a, var(--xp)); }
.meter-text { position: relative; display: block; text-align: center; font-size: 0.78rem; line-height: 16px; font-weight: 700; text-shadow: 0 1px 2px #000; }
.meter.wide .meter-text { line-height: 20px; }

.timers { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.5rem; padding-bottom: 0.6rem; }
.timer {
	display: flex; justify-content: space-between; gap: 0.5rem; align-items: center;
	padding: 0.4rem 0.8rem; border-radius: var(--radius); cursor: pointer;
	background: var(--panel); border: 1px solid var(--border); color: var(--text);
}
.timer.ready { border-color: var(--gold-dim); box-shadow: inset 0 0 12px rgb(224 179 90 / 12%); }
.timer.ready .timer-state { color: var(--gold); font-weight: 700; }
.timer.cooling .timer-state { color: var(--muted); font-variant-numeric: tabular-nums; }
.timer:hover { border-color: var(--gold); }

.frame { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 20px; align-items: start; }

.side { position: sticky; top: 150px; display: grid; gap: 1rem; }
.nav-group { display: grid; gap: 2px; }
.nav-group h4 { font-size: 0.75rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.15em; padding: 0 0.6rem 0.3rem; border-bottom: 1px solid var(--border); margin-bottom: 0.3rem; }
.nav-link { display: flex; align-items: center; gap: 0.55rem; padding: 0.38rem 0.6rem; border-radius: var(--radius); color: var(--text); }
.nav-link:hover { background: var(--panel); text-decoration: none; color: var(--gold); }
.nav-link.active { background: var(--panel-2); color: var(--gold); box-shadow: inset 3px 0 0 var(--gold); }
.nav-link.locked { color: #6d5c48; cursor: default; }
.nav-link.locked small { margin-left: auto; font-size: 0.75rem; }
.nav-link > span:first-of-type { flex: 1; }
.badge { background: var(--red); color: #fff; border-radius: 99px; font-size: 0.72rem; padding: 0 0.45rem; font-weight: 700; }

.page { min-width: 0; animation: page-in 0.18s ease-out; }
@keyframes page-in { from { opacity: 0; transform: translateY(4px); } }

.page-title { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.section { margin: 1.5rem 0 0.8rem; color: var(--gold); }
.notice { background: var(--panel); border: 1px dashed var(--border-hi); border-radius: var(--radius); padding: 0.6rem 0.9rem; color: var(--muted); }

.panel {
	background: linear-gradient(180deg, var(--panel-2), var(--panel));
	border: 1px solid var(--border); border-radius: 8px; padding: 1rem;
	box-shadow: var(--shadow), inset 0 1px 0 rgb(255 220 160 / 6%);
}

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.cards .panel { display: grid; gap: 0.4rem; align-content: start; }
.cards .panel .btn { margin-top: 0.4rem; }
.panel.locked { opacity: 0.55; }

.table th { text-align: left; color: var(--muted); font-weight: 500; font-size: 0.85rem; padding: 0.4rem 0.6rem; border-bottom: 1px solid var(--border); }
.table td { padding: 0.5rem 0.6rem; border-bottom: 1px solid rgb(77 51 29 / 50%); }
.table tr:hover td { background: rgb(255 255 255 / 2%); }
.table tr.me td, .table tr.unread td { background: rgb(224 179 90 / 7%); }
.table tr.unread td:first-child { box-shadow: inset 3px 0 0 var(--gold); }
.pager { display: flex; justify-content: center; align-items: center; gap: 1rem; margin-top: 0.8rem; }

/* ---------- Overview ---------- */

.overview { display: grid; grid-template-columns: auto minmax(260px, 1fr); gap: 16px; }
.bag-panel { grid-column: 1 / -1; }

.stats th { text-align: left; font-weight: 500; color: var(--muted); padding: 0.3rem 0.4rem; }
.stats td { padding: 0.3rem 0.4rem; font-variant-numeric: tabular-nums; }
.stats td:nth-child(2) { font-weight: 700; color: var(--text); }
.stats tr + tr { border-top: 1px solid rgb(77 51 29 / 40%); }
.stats.values { margin-top: 0.8rem; border-top: 1px solid var(--border); }

.doll {
	display: grid; gap: 10px; justify-content: center;
	grid-template-columns: repeat(3, var(--cell));
	grid-template-areas: "amulet helmet ring1" "weapon chest shield" "gloves . ring2" ". boots .";
	padding: 0.5rem 1rem;
	background: radial-gradient(ellipse at center, rgb(224 179 90 / 7%), transparent 70%);
}
.slot-helmet { grid-area: helmet; } .slot-amulet { grid-area: amulet; } .slot-weapon { grid-area: weapon; }
.slot-chest { grid-area: chest; } .slot-shield { grid-area: shield; } .slot-gloves { grid-area: gloves; }
.slot-ring1 { grid-area: ring1; } .slot-ring2 { grid-area: ring2; } .slot-boots { grid-area: boots; }

.bag { display: grid; gap: 4px; justify-content: start; overflow-x: auto; }

.item {
	--quality: var(--text);
	width: var(--cell); height: var(--cell); border-radius: 5px; padding: 0;
	display: grid; place-items: center; position: relative;
	background: radial-gradient(circle at 50% 40%, color-mix(in srgb, var(--quality) 14%, var(--inset)), var(--inset));
	border: 1px solid color-mix(in srgb, var(--quality) 55%, var(--border));
	color: var(--quality); cursor: pointer;
	transition: transform 0.1s, box-shadow 0.15s;
}
.item:hover { box-shadow: 0 0 0 1px var(--quality), 0 0 12px color-mix(in srgb, var(--quality) 40%, transparent); }
.item.selected { box-shadow: 0 0 0 2px var(--gold); }
.item.too-low::after { content: ''; position: absolute; inset: 0; background: rgb(160 30 20 / 30%); border-radius: inherit; }
.item.empty { cursor: default; background: var(--inset); border: 1px dashed var(--border); color: #5f4a35; font-size: 0.65rem; text-align: center; }
.item.empty.over { border-color: var(--gold); background: rgb(224 179 90 / 10%); }
.item.q4 { animation: legendary 2.5s ease-in-out infinite; }
.item.q5 { animation: mythic 4s linear infinite; }
@keyframes mythic { 0%, 100% { box-shadow: 0 0 12px rgb(255 107 107 / 45%); } 33% { box-shadow: 0 0 12px rgb(107 203 119 / 45%); } 66% { box-shadow: 0 0 12px rgb(77 150 255 / 45%); } }
@keyframes legendary { 50% { box-shadow: 0 0 14px rgb(240 144 42 / 45%); } }
.item[draggable="true"] { cursor: grab; }

.item-actions { margin-top: 0.8rem; display: grid; gap: 0.5rem; padding: 0.7rem; border: 1px solid var(--border); border-radius: var(--radius); background: var(--inset); }

.tooltip {
	--quality: var(--text);
	position: fixed; z-index: 100; width: 250px; pointer-events: none;
	background: rgb(16 10 6 / 97%); border: 1px solid color-mix(in srgb, var(--quality) 60%, var(--border));
	border-radius: 6px; padding: 0.65rem 0.75rem; box-shadow: var(--shadow); font-size: 0.9rem;
}
.tooltip-name { color: var(--quality); font-weight: 800; font-size: 1.12rem; letter-spacing: 0.02em; line-height: 1.25; }
.tooltip .item-level { font-size: 0.8rem; color: var(--gold); margin-top: 0.2rem; }
.tooltip-sub { color: var(--muted); font-size: 0.8rem; text-transform: capitalize; }
.tooltip .req { font-size: 0.85rem; margin: 0.25rem 0; }
.tooltip-lines { display: grid; gap: 1px; padding: 0.35rem 0; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.tooltip .bonus { color: #9fd38f; }
.tooltip .bonus.lost { color: var(--muted); }
.tooltip-compare { font-size: 0.75rem; color: var(--muted); margin-top: 0.3rem; }
.tooltip-value { display: flex; align-items: center; gap: 0.3rem; margin-top: 0.35rem; color: var(--gold); }
.tooltip-hint { font-size: 0.75rem; color: var(--muted); margin-top: 0.2rem; font-style: italic; }

/* ---------- Training, work ---------- */

.train-value { font-family: var(--font-title); font-size: 2rem; color: var(--text); }
.working { max-width: 520px; display: grid; gap: 0.4rem; justify-items: start; }

/* ---------- Expedition, arena, fights ---------- */

.enemies { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 14px; margin-bottom: 18px; }
.enemy { display: grid; justify-items: center; text-align: center; gap: 0.3rem; }
.enemy h3 { margin: 0; }
.enemy .btn { width: 100%; margin-top: 0.4rem; }
.enemy-portrait { width: 84px; height: 84px; border-radius: 50%; display: grid; place-items: center; color: var(--muted); background: radial-gradient(circle, #3a2717, var(--inset)); border: 2px solid var(--border-hi); }
.enemy.boss { border-color: #8a3a2a; background: linear-gradient(180deg, #3a1d14, var(--panel)); }
.enemy.boss .enemy-portrait { color: var(--gold); border-color: var(--gold-dim); }

.fight { margin-top: 18px; }
.fight-head { display: flex; justify-content: space-between; align-items: baseline; flex-direction: row-reverse; gap: 1rem; flex-wrap: wrap; margin-bottom: 0.8rem; }
.fighters { display: grid; grid-template-columns: 1fr auto 1fr; gap: 1rem; align-items: center; }
.fighter { background: var(--panel); border: 1px solid var(--border); border-radius: 8px; padding: 0.8rem; display: grid; gap: 0.3rem; transition: border-color 0.3s, box-shadow 0.3s; }
.fighter .meter { width: 100%; }
.fighter.winner { border-color: var(--gold); box-shadow: 0 0 18px rgb(224 179 90 / 20%); }
.fighter-name { font-family: var(--font-title); font-size: 1.1rem; color: var(--text); }
.versus { font-family: var(--font-title); color: var(--gold); font-size: 1.3rem; }
.strikes { list-style: none; margin: 0.8rem 0 0; padding: 0.5rem; max-height: 280px; overflow-y: auto; background: var(--inset); border: 1px solid var(--border); border-radius: var(--radius); font-size: 0.92rem; }
.strike { padding: 0.18rem 0.3rem; animation: strike-in 0.2s ease-out; }
.strike.side1 { color: #e7b9a8; }
.strike.crit { font-weight: 700; color: #ffcf6e; }
.strike.miss { color: var(--muted); font-style: italic; }
.strike .round { display: inline-block; width: 2.6rem; color: var(--muted); font-size: 0.8rem; }
@keyframes strike-in { from { opacity: 0; transform: translateX(-6px); } }
.fight-result { margin-top: 0.8rem; padding: 0.9rem 1rem; border-radius: 8px; border: 1px solid var(--border); background: var(--panel); }
.fight-result.won { border-color: var(--gold-dim); }
.fight-result.won h3 { color: var(--gold); }
.fight-result.lost h3 { color: var(--red); }
.rewards { display: flex; flex-wrap: wrap; gap: 0.5rem 1.2rem; }
.rewards span { display: inline-flex; align-items: center; gap: 0.3rem; }
.skip { margin-top: 0.6rem; }

/* ---------- Shop ---------- */

.shop { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 16px; align-items: start; }
.shop-stock.over { border-color: var(--gold); }
.stock { display: grid; grid-template-columns: repeat(auto-fill, minmax(70px, 1fr)); gap: 10px; }
.stock-cell { display: grid; justify-items: center; gap: 0.2rem; }
.price { display: inline-flex; align-items: center; gap: 0.2rem; font-size: 0.8rem; color: var(--gold); }
.price.bad { color: var(--red); }

/* ---------- Premium ---------- */

.pack, .perk { justify-items: center; text-align: center; }
.pack h3 { margin: 0; font-size: 1.3rem; }

/* ---------- Landing ---------- */

.landing { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(300px, 400px); gap: 48px; align-items: center; max-width: 1100px; margin: 0 auto; padding: 32px 16px; }
.tagline { font-size: 1.3rem; color: var(--text); max-width: 32ch; }
.features { list-style: none; padding: 0; display: grid; gap: 0.6rem; margin-top: 1.5rem; color: var(--muted); }
.features li { display: flex; align-items: center; gap: 0.6rem; }
.features svg { color: var(--gold); flex: none; }
.landing-form { display: grid; gap: 1rem; padding: 1.5rem; }
.landing-form .tabs { width: 100%; }
.landing-form .tabs button { flex: 1; }
.form-error { color: var(--red); }

.splash { min-height: 100vh; display: grid; place-items: center; font-family: var(--font-title); font-size: 2rem; letter-spacing: 0.2em; color: var(--gold-dim); animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.4; } }

.toasts { position: fixed; right: 16px; bottom: 16px; z-index: 200; display: grid; gap: 8px; max-width: min(380px, calc(100vw - 32px)); }
.toast { background: #2b3a1e; border: 1px solid #5d7d3a; color: #e6f2d8; padding: 0.6rem 0.9rem; border-radius: var(--radius); box-shadow: var(--shadow); animation: toast-in 0.2s ease-out; }
.toast.error { background: #3d1712; border-color: #8a3226; color: #ffd9d2; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

/* ---------- Narrow screens ---------- */

@media (max-width: 900px) {
	.frame { grid-template-columns: minmax(0, 1fr); }
	.menu-btn { display: inline-flex; }
	.side {
		position: fixed; inset: 0 auto 0 0; z-index: 30; width: 260px; overflow-y: auto;
		background: var(--bg-2); border-right: 1px solid var(--border); padding: 1rem;
		transform: translateX(-100%); transition: transform 0.2s;
	}
	.side.open { transform: none; box-shadow: var(--shadow); }
	.overview, .shop { grid-template-columns: minmax(0, 1fr); }
	.landing { grid-template-columns: minmax(0, 1fr); gap: 24px; }
	.meter { width: 110px; }
	.clock { display: none; }
}

@media (max-width: 560px) {
	:root { --cell: 40px; }
	.timers { grid-template-columns: minmax(0, 1fr); }
	.fighters { grid-template-columns: minmax(0, 1fr); }
	.versus { text-align: center; }
	.top { position: static; }
}

/* Rooms, enemy pictures, item pictures (mock-up art falls back to the SVG icons). */
.enemy-portrait img { width: 64px; height: 64px; object-fit: contain; image-rendering: pixelated; }
.room { margin-bottom: 6px; }
.room-title { margin: 0 0 8px; }
.map-loot { display: flex; align-items: center; gap: 0.35rem; margin: -6px 0 14px; font-size: 0.85rem; }
.loot-chance { display: flex; align-items: center; gap: 0.25rem; font-size: 0.8rem; margin: 0; }
.strike .stolen { color: #9fd38f; }
.strike .returned { color: #e0905a; }
.item-picture { width: 100%; height: 100%; padding: 4px; object-fit: contain; image-rendering: pixelated; pointer-events: none; }

/* Item names by quality: tint gradient as text (Shared/Data QUALITIES.tint), golden shine and prismatic shift for the top two. */
.quality-name {
	color: var(--quality);
	background: var(--quality-gradient);
	-webkit-background-clip: text; background-clip: text;
	-webkit-text-fill-color: transparent;
	filter: drop-shadow(0 1px 0 rgb(0 0 0 / 85%));
}
.quality-name.shine {
	background: linear-gradient(105deg, transparent 40%, rgb(255 255 240 / 95%) 50%, transparent 60%) 0 0 / 250% 100% no-repeat, var(--quality-gradient);
	-webkit-background-clip: text; background-clip: text;
	filter: drop-shadow(0 1px 0 rgb(0 0 0 / 85%)) drop-shadow(0 0 6px rgb(255 200 60 / 35%));
	animation: quality-shine 3.2s ease-in-out infinite;
}
@keyframes quality-shine { 0% { background-position: 120% 0, 0 0; } 55%, 100% { background-position: -120% 0, 0 0; } }
.quality-name.prismatic {
	background: linear-gradient(90deg, #ff6b6b, #ffd93d, #6bcb77, #4d96ff, #c77dff, #ff6b6b) 0 0 / 300% 100%;
	-webkit-background-clip: text; background-clip: text;
	filter: drop-shadow(0 1px 0 rgb(0 0 0 / 85%)) drop-shadow(0 0 7px rgb(199 125 255 / 40%));
	animation: quality-prismatic 6s linear infinite;
}
@keyframes quality-prismatic { to { background-position: 300% 0; } }
@media (prefers-reduced-motion: reduce) {
	.quality-name.shine, .quality-name.prismatic, .item.q4, .item.q5 { animation: none; }
}
.spoils-hint { display: flex; align-items: center; gap: 0.35rem; margin: -8px 0 14px; font-size: 0.85rem; color: var(--muted); }
.spoils-hint.ready { color: var(--gold); }
