:root {
  --ink: #22160f;
  --parch: #f6e7c4;
  --parch-dark: #e5cf9c;
  --wood: #6b4325;
  --gold: #f5c431;
  --red: #c62f24;
  --green: #3f9a3a;
  --blue: #2f6fd6;
  --display: "Luckiest Guy", Impact, "Arial Black", sans-serif;
  --body: "Nunito", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: #140c08; overflow: hidden; font-family: var(--body); color: var(--ink); -webkit-tap-highlight-color: transparent; }
#stage { position: absolute; left: 50%; top: 50%; width: 1280px; height: 720px; transform-origin: center; user-select: none; -webkit-user-select: none; }
#canvas { position: absolute; inset: 0; width: 1280px; height: 720px; }
#ui { position: absolute; inset: 0; }
#ui > * { animation: fade-in 0.25s ease-out; }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop-in { 0% { transform: scale(0.4); opacity: 0; } 70% { transform: scale(1.08); } 100% { transform: scale(1); opacity: 1; } }
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
@keyframes pulse { 0%, 100% { box-shadow: 0 5px 0 var(--ink), 0 0 0 0 rgba(245, 196, 49, 0.9); } 50% { box-shadow: 0 5px 0 var(--ink), 0 0 0 10px rgba(245, 196, 49, 0); } }

/* ---------- primitives ---------- */
.abs { position: absolute; }
.panel {
  background: linear-gradient(180deg, var(--parch), var(--parch-dark));
  border: 4px solid var(--ink);
  border-radius: 18px;
  box-shadow: 0 8px 0 rgba(0, 0, 0, 0.45), inset 0 0 0 3px rgba(255, 255, 255, 0.5);
  padding: 18px 22px;
}
.panel.dark { background: linear-gradient(180deg, #4a2e1b, #2e1c10); color: #f6e7c4; box-shadow: 0 8px 0 rgba(0, 0, 0, 0.45), inset 0 0 0 3px rgba(255, 255, 255, 0.08); }
.display { font-family: var(--display); letter-spacing: 1px; font-weight: 400; }
.outlined { color: #fff; -webkit-text-stroke: 2px var(--ink); paint-order: stroke fill; text-shadow: 0 4px 0 var(--ink); }
h1, h2, h3 { margin: 0; font-family: var(--display); font-weight: 400; letter-spacing: 1px; }
h2 { font-size: 34px; }
h3 { font-size: 22px; }
.muted { opacity: 0.7; }
.row { display: flex; align-items: center; gap: 10px; }
.col { display: flex; flex-direction: column; gap: 10px; }
.grow { flex: 1; }

.btn {
  font-family: var(--display);
  font-size: 22px;
  letter-spacing: 1px;
  color: var(--ink);
  background: linear-gradient(180deg, #ffe48a, var(--gold) 55%, #d89c14);
  border: 4px solid var(--ink);
  border-radius: 14px;
  padding: 10px 20px 7px;
  box-shadow: 0 5px 0 var(--ink);
  cursor: pointer;
  transition: transform 0.08s, box-shadow 0.08s, filter 0.1s;
  position: relative;
  line-height: 1.1;
}
.btn:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 7px 0 var(--ink); filter: brightness(1.06); }
.btn:active:not(:disabled) { transform: translateY(4px); box-shadow: 0 1px 0 var(--ink); }
.btn:disabled { filter: grayscale(0.85) brightness(0.8); cursor: not-allowed; opacity: 0.75; }
.btn.red { background: linear-gradient(180deg, #ff8a72, var(--red) 55%, #8f1d14); color: #fff; text-shadow: 0 2px 0 var(--ink); }
.btn.green { background: linear-gradient(180deg, #9be27a, var(--green) 55%, #23661f); color: #fff; text-shadow: 0 2px 0 var(--ink); }
.btn.blue { background: linear-gradient(180deg, #8fc0ff, var(--blue) 55%, #1d4590); color: #fff; text-shadow: 0 2px 0 var(--ink); }
.btn.wood { background: linear-gradient(180deg, #a8754a, var(--wood) 55%, #43280f); color: #fff3d6; text-shadow: 0 2px 0 var(--ink); }
.btn.small { font-size: 16px; padding: 6px 12px 4px; border-width: 3px; border-radius: 10px; box-shadow: 0 3px 0 var(--ink); }
.btn.big { font-size: 34px; padding: 14px 34px 10px; }
.btn.pulse { animation: pulse 1.6s infinite; }
.btn .sub { display: block; font-family: var(--body); font-weight: 800; font-size: 12px; letter-spacing: 0; opacity: 0.85; text-shadow: none; }
.btn .key { position: absolute; top: -9px; left: -9px; width: 22px; height: 22px; border-radius: 50%; background: var(--ink); color: #fff; font: 800 12px/22px var(--body); text-align: center; text-shadow: none; }

.icon-btn { width: 48px; height: 48px; padding: 0; font-size: 22px; display: grid; place-items: center; }

.bar { height: 22px; background: #3a2418; border: 3px solid var(--ink); border-radius: 12px; overflow: hidden; position: relative; }
.bar > i { position: absolute; inset: 0; width: 100%; transform-origin: left; transition: transform 0.35s ease-out; }
.bar > b { position: absolute; inset: 0; display: grid; place-items: center; font: 900 13px var(--body); color: #fff; text-shadow: 0 1px 0 var(--ink), 0 0 3px var(--ink); }
.bar.hp > i { background: linear-gradient(180deg, #ff7a6a, #d3271b); }
.bar.hp > i.ghost { background: #ffe9a8; transition-delay: 0.35s; transition-duration: 0.6s; }
.bar.en > i { background: linear-gradient(180deg, #8fd8ff, #2a86d6); }
.bar.xp > i { background: linear-gradient(180deg, #d8f58a, #6aa82a); }
.bar.hype > i { background: linear-gradient(90deg, #f5c431, #ff6a3a); }

input[type="text"] {
  font: 900 22px var(--body);
  border: 3px solid var(--ink);
  border-radius: 10px;
  padding: 6px 12px;
  background: #fffaf0;
  color: var(--ink);
  width: 100%;
  outline: none;
}
input[type="text"]:focus { box-shadow: 0 0 0 3px var(--gold); }

.tooltip { position: absolute; pointer-events: none; z-index: 50; max-width: 300px; font-size: 14px; padding: 10px 12px; border-radius: 12px; }

/* ---------- title ---------- */
.title-logo { position: absolute; left: 0; right: 0; top: 40px; text-align: center; }
.title-logo h1 { font-size: 112px; line-height: 0.95; color: var(--gold); -webkit-text-stroke: 4px var(--ink); paint-order: stroke fill; text-shadow: 0 8px 0 var(--ink), 0 14px 24px rgba(0, 0, 0, 0.4); animation: pop-in 0.7s ease-out; }
.title-logo .tag { font-family: var(--display); font-size: 28px; color: #fff; -webkit-text-stroke: 1.5px var(--ink); paint-order: stroke fill; text-shadow: 0 3px 0 var(--ink); margin-top: 6px; }
.title-menu { position: absolute; right: 90px; top: 300px; width: 330px; display: flex; flex-direction: column; gap: 16px; }
.title-menu .btn { font-size: 30px; }
.corner { position: absolute; top: 16px; right: 16px; display: flex; gap: 10px; z-index: 40; }
.corner.center { right: auto; left: 50%; transform: translateX(-50%); }
.credit { position: absolute; bottom: 12px; left: 0; right: 0; text-align: center; color: #fff; font-weight: 800; font-size: 14px; text-shadow: 0 1px 2px #000; opacity: 0.85; }

/* ---------- dialog / cutscene ---------- */
.dialog { position: absolute; left: 60px; right: 60px; bottom: 34px; min-height: 150px; padding: 26px 34px 22px; font-size: 26px; font-weight: 800; line-height: 1.35; cursor: pointer; }
.dialog .who { position: absolute; top: -24px; left: 26px; padding: 6px 18px 3px; font-family: var(--display); font-size: 24px; background: var(--gold); border: 4px solid var(--ink); border-radius: 12px; }
.dialog .who.narrator { background: #d9c7a0; }
.dialog .who.enemy { left: auto; right: 26px; background: #ff8a72; }
.dialog .next { position: absolute; right: 22px; bottom: 10px; font-size: 14px; font-weight: 900; opacity: 0.6; animation: bob 1s infinite; }
.dialog.narration { font-style: italic; text-align: center; }
.chapter-card { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; background: rgba(20, 12, 8, 0.75); }
.chapter-card .num { font-family: var(--display); font-size: 40px; color: var(--gold); -webkit-text-stroke: 2px var(--ink); paint-order: stroke fill; animation: pop-in 0.5s ease-out; }
.chapter-card .name { font-family: var(--display); font-size: 84px; color: #fff; -webkit-text-stroke: 3px var(--ink); paint-order: stroke fill; text-shadow: 0 6px 0 var(--ink); animation: pop-in 0.6s ease-out 0.1s both; }
.chapter-card .region { font-size: 24px; font-weight: 900; color: #f6e7c4; margin-top: 10px; }
.skip { position: absolute; top: 16px; right: 80px; }

/* ---------- creator ---------- */
.creator { position: absolute; right: 80px; top: 20px; bottom: 20px; width: 640px; display: flex; flex-direction: column; gap: 6px; padding: 16px 22px; }
.creator h2 { font-size: 32px; }
.opt { display: grid; grid-template-columns: 130px 1fr; align-items: center; gap: 10px; min-height: 36px; }
.opt > label { font-weight: 900; font-size: 15px; text-transform: uppercase; letter-spacing: 0.5px; }
.swatches { display: flex; flex-wrap: wrap; gap: 5px; }
.swatch { width: 26px; height: 26px; border-radius: 50%; border: 3px solid var(--ink); cursor: pointer; transition: transform 0.1s; padding: 0; }
.swatch:hover { transform: scale(1.15); }
.swatch.on { box-shadow: 0 0 0 3px #fff, 0 0 0 6px var(--ink); transform: scale(1.12); }
.picker { display: flex; align-items: center; gap: 8px; }
.picker .val { flex: 1; min-width: 0; text-align: center; font-family: var(--display); font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; background: #fffaf0; border: 3px solid var(--ink); border-radius: 10px; padding: 5px 4px 2px; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 20px; }
.two .opt { grid-template-columns: 82px 1fr; }
.preview-label { position: absolute; left: 0; width: 560px; top: 26px; text-align: center; }
.preview-label .name { font-family: var(--display); font-size: 48px; color: #fff; -webkit-text-stroke: 2px var(--ink); paint-order: stroke fill; text-shadow: 0 4px 0 var(--ink); }

.stats { display: flex; flex-direction: column; gap: 8px; }
.stat { display: grid; grid-template-columns: 150px 1fr 44px 120px; align-items: center; gap: 12px; padding: 6px 10px; background: rgba(255, 255, 255, 0.4); border: 2px solid rgba(34, 22, 15, 0.25); border-radius: 12px; }
.stat .name { font-family: var(--display); font-size: 20px; }
.stat .desc { font-size: 14px; font-weight: 700; opacity: 0.8; }
.stat .v { font-family: var(--display); font-size: 28px; text-align: center; }
.stat .v.up { color: var(--green); }
.stat .ctl { display: flex; gap: 8px; justify-content: flex-end; }
.points { font-family: var(--display); font-size: 26px; }
.points b { color: var(--red); font-weight: 400; font-size: 34px; }

/* ---------- hub ---------- */
.topbar { position: absolute; left: 16px; right: 84px; top: 14px; display: flex; gap: 14px; align-items: stretch; }
.topbar .panel { padding: 10px 16px; }
.hero-card { display: flex; align-items: center; gap: 14px; min-width: 400px; }
.hero-card h3 { font-size: 20px; white-space: nowrap; }
.hero-card .lvl { width: 58px; height: 58px; border-radius: 50%; background: var(--gold); border: 4px solid var(--ink); display: grid; place-items: center; font-family: var(--display); font-size: 28px; line-height: 1; padding-top: 4px; }
.gold { font-family: var(--display); font-size: 28px; display: flex; align-items: center; gap: 8px; }
.coin { display: inline-block; width: 26px; height: 26px; border-radius: 50%; background: radial-gradient(circle at 35% 35%, #fff3a8, var(--gold) 50%, #b8860b); border: 3px solid var(--ink); }
.domination { flex: 1; }
.domination .bar { height: 26px; }
.domination .bar > i { background: linear-gradient(90deg, #f5c431, #e8541f, #a3162f); }
.hub-menu { position: absolute; right: 24px; top: 128px; width: 420px; display: flex; flex-direction: column; gap: 12px; }
.hub-menu .btn { text-align: left; font-size: 24px; }
.next-fight { padding: 14px 18px; }
.next-fight .ch { font-weight: 900; font-size: 14px; text-transform: uppercase; letter-spacing: 1px; opacity: 0.7; }
.pips { display: flex; gap: 6px; margin: 6px 0 10px; }
.pip { width: 22px; height: 22px; border-radius: 50%; border: 3px solid var(--ink); background: #fff; }
.pip.done { background: var(--green); }
.pip.boss { border-radius: 4px; }
.pip.now { background: var(--gold); animation: bob 1s infinite; }
.badge { display: inline-block; min-width: 26px; padding: 2px 7px 0; border-radius: 13px; background: var(--red); color: #fff; font-family: var(--display); font-size: 16px; border: 2px solid var(--ink); margin-left: 6px; }
.arts { position: absolute; left: 24px; bottom: 20px; display: flex; gap: 8px; }
.art { padding: 6px 12px; border-radius: 10px; border: 3px solid var(--ink); background: #fff3d6; font-weight: 900; font-size: 14px; }
.art.locked { opacity: 0.45; background: #ccc; }

/* ---------- armory ---------- */
.armory { position: absolute; right: 80px; top: 20px; bottom: 20px; width: 680px; display: flex; flex-direction: column; padding: 16px 18px; }
.tabs { display: flex; gap: 6px; margin: 10px 0; }
.tab { flex: 1; font-family: var(--display); font-size: 17px; padding: 8px 0 5px; border: 3px solid var(--ink); border-radius: 10px; background: #e5cf9c; cursor: pointer; }
.tab.on { background: var(--gold); transform: translateY(-2px); box-shadow: 0 3px 0 var(--ink); }
.items { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; padding: 4px 6px 4px 0; }
.items::-webkit-scrollbar { width: 10px; }
.items::-webkit-scrollbar-thumb { background: var(--wood); border-radius: 5px; }
.item { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: center; padding: 8px 12px; background: rgba(255, 255, 255, 0.5); border: 3px solid rgba(34, 22, 15, 0.3); border-radius: 12px; }
.item.equipped { border-color: var(--green); background: rgba(160, 230, 140, 0.45); }
.item .nm { font-family: var(--display); font-size: 20px; }
.item .st { font-size: 14px; font-weight: 800; display: flex; flex-wrap: wrap; gap: 4px 10px; }
.item .st span { white-space: nowrap; }
.item .ds { font-size: 13px; font-style: italic; opacity: 0.75; }
.item .req { color: var(--red); font-weight: 900; font-size: 13px; }
.item .acts { display: flex; gap: 6px; align-items: center; }
.price { font-family: var(--display); font-size: 20px; display: flex; align-items: center; gap: 5px; min-width: 84px; justify-content: flex-end; }
.price .coin { width: 18px; height: 18px; border-width: 2px; }
.gearlist { position: absolute; left: 24px; bottom: 20px; width: 470px; padding: 12px 16px; font-size: 14px; font-weight: 800; }
.gearlist .derived { display: flex; gap: 14px; flex-wrap: wrap; font-size: 15px; }

/* ---------- battle ---------- */
.hud { position: absolute; top: 12px; width: 470px; padding: 10px 14px; }
.hud.left { left: 14px; }
.hud.right { right: 14px; }
.hud .nm { font-family: var(--display); font-size: 24px; display: flex; justify-content: space-between; align-items: baseline; }
.hud .nm small { font-family: var(--body); font-weight: 900; font-size: 14px; }
.hud .bar { margin-top: 5px; }
.hud .bar.en { height: 16px; }
.hud .bar.hype { height: 16px; }
.hud .bar.en > b, .hud .bar.hype > b { font-size: 11px; line-height: 1; }
.hud .status { font-size: 13px; font-weight: 900; min-height: 16px; margin-top: 3px; display: flex; gap: 8px; }
.hud.right .nm, .hud.right .status { flex-direction: row-reverse; }
.actions { position: absolute; left: 12px; right: 12px; bottom: 10px; display: flex; gap: 8px; justify-content: center; align-items: flex-end; flex-wrap: wrap; }
.actions .grp { display: flex; gap: 8px; padding: 8px; background: rgba(20, 12, 8, 0.55); border-radius: 16px; }
.actions .btn { font-size: 17px; padding: 8px 12px 5px; min-width: 104px; }
.log { position: absolute; left: 50%; transform: translateX(-50%); bottom: 104px; padding: 6px 18px 4px; border-radius: 14px; background: rgba(20, 12, 8, 0.72); color: #fff; font-weight: 900; font-size: 18px; white-space: nowrap; transition: opacity 0.3s; }
.vs-card { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width: 760px; text-align: center; animation: pop-in 0.45s ease-out; }
.vs-card .vs { font-family: var(--display); font-size: 80px; color: var(--red); -webkit-text-stroke: 3px var(--ink); paint-order: stroke fill; text-shadow: 0 5px 0 var(--ink); line-height: 1; }
.vs-card .sides { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 20px; }
.vs-card .who { font-family: var(--display); font-size: 30px; }
.vs-card .ttl { font-weight: 900; font-size: 15px; opacity: 0.75; }
.quote { margin: 18px auto 10px; padding: 12px 18px; font-size: 21px; font-weight: 800; font-style: italic; background: #fff; border: 3px solid var(--ink); border-radius: 16px; max-width: 620px; position: relative; }
.banner { position: absolute; left: 0; right: 0; top: 230px; text-align: center; font-family: var(--display); font-size: 150px; color: var(--gold); -webkit-text-stroke: 5px var(--ink); paint-order: stroke fill; text-shadow: 0 10px 0 var(--ink); pointer-events: none; animation: pop-in 0.5s ease-out; }
.banner.red { color: #ff6a5a; }
.result { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width: 560px; text-align: center; animation: pop-in 0.45s ease-out; }
.result h2 { font-size: 68px; color: var(--gold); -webkit-text-stroke: 3px var(--ink); paint-order: stroke fill; text-shadow: 0 5px 0 var(--ink); }
.result h2.lost { color: #ff6a5a; }
.result .lines { margin: 14px 0 20px; display: flex; flex-direction: column; gap: 8px; font-size: 21px; font-weight: 900; }
.result .lines div { display: flex; justify-content: space-between; padding: 6px 14px; background: rgba(255, 255, 255, 0.5); border-radius: 10px; }
.result .levelup { color: var(--green); font-family: var(--display); font-size: 30px; animation: bob 0.8s infinite; }

/* ---------- ending ---------- */
.ending { position: absolute; left: 0; right: 0; top: 40px; text-align: center; }
.ending h1 { font-size: 76px; color: var(--gold); -webkit-text-stroke: 3px var(--ink); paint-order: stroke fill; text-shadow: 0 6px 0 var(--ink); animation: pop-in 0.8s ease-out; }
.ending .sub { font-family: var(--display); font-size: 30px; color: #fff; -webkit-text-stroke: 1.5px var(--ink); paint-order: stroke fill; text-shadow: 0 3px 0 var(--ink); }
.ending-stats { position: absolute; left: 50%; bottom: 40px; transform: translateX(-50%); display: flex; gap: 14px; align-items: center; }

.help { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width: 860px; max-height: 640px; overflow-y: auto; font-size: 17px; font-weight: 700; line-height: 1.45; }
.help h2 { margin-bottom: 8px; }
.help ul { margin: 6px 0 12px; padding-left: 22px; }
.help b { font-weight: 900; }
.toast { position: absolute; left: 50%; top: 110px; transform: translateX(-50%); padding: 10px 22px 8px; font-family: var(--display); font-size: 24px; z-index: 60; animation: pop-in 0.3s ease-out; pointer-events: none; }
