:root {
  --ink: #f4e9d8;
  --muted: #b9a98f;
  --gold: #f2c14e;
  --panel: rgba(20, 16, 24, 0.86);
  --edge: #6b4f3a;
  --accent: #e0703a;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: #0d0b10; overflow: hidden; }
body { color: var(--ink); font-family: "VT323", monospace; font-size: 22px; user-select: none; -webkit-user-select: none; touch-action: none; }
#wrap { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; }
#screen { display: block; image-rendering: pixelated; image-rendering: crisp-edges; }
#screen.nocursor { cursor: none; }

.overlay {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: safe center;
  gap: 12px; padding: 16px; text-align: center; background: rgba(8, 6, 12, 0.72); overflow-y: auto;
}
.hidden { display: none !important; }
h1, h2 { font-family: "Silkscreen", monospace; font-weight: 400; margin: 0; letter-spacing: 2px; }
h1 { font-size: clamp(40px, 9vw, 84px); color: var(--gold); text-shadow: 0 4px 0 #7a3b17, 0 0 24px rgba(242, 120, 60, 0.5); }
h2 { font-size: clamp(26px, 5vw, 44px); color: var(--gold); text-shadow: 0 3px 0 #7a3b17; }
.sub { margin: 0; color: var(--muted); font-size: 24px; }
.best { color: var(--muted); margin: 0; min-height: 1em; }
.help { color: var(--muted); font-size: 20px; line-height: 1.4; max-width: 680px; }
.help b { color: var(--ink); font-weight: 400; }

.btn {
  font-family: "Silkscreen", monospace; font-size: 22px; color: var(--ink); background: #3a2a22;
  border: 3px solid var(--edge); padding: 10px 26px; cursor: pointer; box-shadow: 0 4px 0 #1c130e; min-width: 220px;
}
.btn:hover, .btn:focus-visible { background: #5a3c2a; outline: none; border-color: var(--gold); }
.btn.small { font-size: 16px; padding: 6px 16px; min-width: 0; }
.btn:disabled { opacity: 0.4; cursor: default; }
.row { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; }

.cards { display: flex; gap: 14px; flex-wrap: wrap; justify-content: center; max-width: 980px; }
.card {
  width: 280px; background: var(--panel); border: 3px solid var(--edge); padding: 12px 14px; cursor: pointer;
  text-align: left; color: var(--ink); font-family: inherit; font-size: 20px; line-height: 1.15; box-shadow: 0 5px 0 #1c130e;
}
.card:hover, .card:focus-visible, .card.sel { border-color: var(--gold); outline: none; transform: translateY(-3px); }
.card h3 { font-family: "Silkscreen", monospace; font-weight: 400; margin: 0 0 4px; font-size: 20px; color: var(--gold); }
.card .key { float: right; color: var(--muted); font-size: 18px; }
.card canvas { display: block; margin: 0 auto 6px; image-rendering: pixelated; width: 240px; height: 192px; }
.card .ab { margin: 6px 0 0; }
.card .ab span { color: var(--accent); }
.card .tag { color: var(--muted); font-size: 17px; }
.card .stack { color: var(--gold); }

.settings-grid { display: flex; gap: 14px; flex-wrap: wrap; justify-content: center; align-items: flex-start; max-width: 980px; }
.panel { background: var(--panel); border: 3px solid var(--edge); padding: 12px 16px; text-align: left; box-shadow: 0 5px 0 #1c130e; }
.panel h3 { font-family: "Silkscreen", monospace; font-weight: 400; margin: 0 0 8px; font-size: 20px; color: var(--gold); }
.binds { border-collapse: collapse; margin-bottom: 8px; }
.binds th { color: var(--muted); font-weight: 400; text-align: left; padding: 0 8px 4px 0; font-size: 18px; }
.binds td { padding: 2px 8px 2px 0; }
.bind {
  font-family: inherit; font-size: 20px; color: var(--ink); background: #2a1f1a; border: 2px solid var(--edge);
  min-width: 120px; padding: 2px 8px; cursor: pointer; text-align: center;
}
.bind:hover, .bind:focus-visible { border-color: var(--gold); outline: none; }
.bind.empty { color: var(--muted); }
.bind.listening { border-color: var(--accent); color: var(--accent); }
.hint { color: var(--muted); font-size: 18px; margin: 0 0 8px; max-width: 420px; }
.opt { display: flex; align-items: center; gap: 10px; margin: 6px 0 10px; font-size: 22px; cursor: pointer; }
.opt input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--accent); }
.opt input[type=range] { accent-color: var(--accent); width: 150px; }
.opt select { font-family: inherit; font-size: 20px; background: #2a1f1a; color: var(--ink); border: 2px solid var(--edge); }

.btn.ghost { background: transparent; box-shadow: none; }
.loadbar { width: min(320px, 70vw); height: 10px; border: 2px solid var(--edge); background: #1c130e; }
#loadBar { height: 100%; width: 0; background: linear-gradient(90deg, #e0703a, #f2c14e); transition: width 0.2s; }

.cards.heroes { max-width: 1500px; }
.card.hero { width: 255px; font-size: 18px; }
.card.hero canvas { width: 160px; height: 128px; }
.card .ult { color: #ffcf5a !important; }
.cardbtns { margin-top: 10px; justify-content: flex-start; }
.cardbtns .btn { min-width: 0; }

.wardrobe { display: flex; gap: 14px; flex-wrap: wrap; justify-content: center; align-items: flex-start; }
.wpreview canvas { width: 320px; height: 256px; image-rendering: pixelated; display: block; background: radial-gradient(#3a2e3a, #1a1418); }
.wlist { max-height: 60vh; overflow-y: auto; min-width: 330px; }
.wrow { display: grid; grid-template-columns: 110px 34px 1fr 34px; align-items: center; gap: 6px; margin: 3px 0; }
.wlabel { color: var(--muted); }
.wval { text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wbtn { font-family: inherit; font-size: 18px; color: var(--ink); background: #2a1f1a; border: 2px solid var(--edge); cursor: pointer; height: 30px; }
.wbtn:hover, .wbtn:focus-visible { border-color: var(--gold); outline: none; }

.shrine { display: flex; gap: 20px; align-items: center; flex-wrap: wrap; justify-content: center; max-width: 1000px; }
.portrait { width: 192px; height: 192px; image-rendering: pixelated; border: 3px solid var(--gold); box-shadow: 0 0 40px rgba(255, 220, 140, 0.35); }
.shrine-body { display: flex; flex-direction: column; align-items: center; gap: 10px; max-width: 760px; }
.gold { color: var(--gold); margin: 0; font-size: 24px; }
.card.shop { width: 220px; }
.card.shop .cost { color: var(--gold); margin-top: 6px; }
.card:disabled { opacity: 0.45; cursor: default; transform: none; }

.stats { font-size: 24px; line-height: 1.4; margin: 0; }
.boonlist { color: var(--muted); max-width: 600px; font-size: 20px; }

#touch { position: absolute; inset: auto 0 0 0; display: flex; justify-content: space-between; padding: 10px; pointer-events: none; }
#touch .pad { display: flex; gap: 8px; pointer-events: auto; flex-wrap: wrap; align-items: flex-end; }
#touch .pad.right { max-width: 260px; justify-content: flex-end; }
#touch button {
  width: 62px; height: 62px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, 0.35);
  background: rgba(30, 20, 30, 0.45); color: var(--ink); font-size: 24px; font-family: inherit;
}
#touch button:active { background: rgba(240, 180, 80, 0.45); }

.coins { color: var(--gold); margin: 0; font-size: 24px; }
.coins::before { content: "◉ "; }
.wrow { grid-template-columns: 96px 30px minmax(200px, 1fr) 30px 86px; }
.wval { white-space: normal; line-height: 1.05; }
.wval .wname { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wval small { display: block; color: var(--muted); font-size: 15px; min-height: 15px; }
.wstat { text-align: center; }
.wstat .owned { color: #7fbf6a; font-size: 16px; }
.buy { font-family: inherit; font-size: 17px; color: #1c130e; background: var(--gold); border: 2px solid #7a5a20; cursor: pointer; padding: 1px 6px; width: 100%; }
.buy:disabled { opacity: 0.4; cursor: default; }
.wlist { min-width: min(560px, 92vw); }
.wstats { margin-top: 10px; font-size: 18px; color: #bfe8a8; max-width: 320px; }
.wstats h3 { font-family: "Silkscreen", monospace; font-weight: 400; font-size: 16px; color: var(--gold); margin: 0 0 4px; }
.wstats .muted { color: var(--muted); }
.legendary { color: #ffb340; text-shadow: 0 0 18px rgba(255, 170, 60, 0.6), 0 3px 0 #7a3b17; }
.legendary-tag { color: #ffcf8a; }
.spoilstats { font-size: 24px; color: #bfe8a8; line-height: 1.3; }
.banked { color: var(--gold); }
.lost { color: #c99; }
#cashLine { max-width: 560px; color: var(--ink); }
.overlay { overflow-x: hidden; }
.wlist { min-width: 0; width: min(560px, 100%); }
@media (max-width: 600px) { .wrow { grid-template-columns: 70px 28px minmax(0, 1fr) 28px 70px; } }

/* ---------------------------------------------------------------- armory */
.armory { width: min(1180px, 100%); display: flex; flex-direction: column; align-items: center; gap: 10px; }
.ar-top { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; justify-content: center; }
.ar-heroes { display: flex; gap: 6px; }
.ar-hero { display: flex; flex-direction: column; align-items: center; gap: 2px; background: #2a1f1a; border: 2px solid var(--edge);
  color: var(--muted); font-family: inherit; font-size: 16px; padding: 3px 6px; cursor: pointer; }
.ar-hero canvas { width: 40px; height: 40px; image-rendering: pixelated; }
.ar-hero.active, .ar-hero:hover { border-color: var(--gold); color: var(--ink); }
.ar-body { display: grid; grid-template-columns: minmax(330px, 1.15fr) minmax(250px, 1fr) minmax(250px, 0.95fr); gap: 10px; width: 100%; align-items: stretch; }
.ar-doll { display: grid; grid-template-columns: 64px 1fr 64px; gap: 6px; align-items: center; }
.ar-slots { display: flex; flex-direction: column; gap: 5px; }
.ar-slot { position: relative; width: 60px; height: 60px; padding: 0; background: radial-gradient(#3a2b26, #1e1612); border: 2px solid; cursor: pointer; }
.ar-slot canvas { width: 40px; height: 40px; image-rendering: pixelated; margin-top: 2px; }
.ar-slot .ar-slotname { position: absolute; left: 0; right: 0; bottom: 1px; font-size: 12px; line-height: 1; color: var(--muted); }
.ar-slot.active { outline: 2px solid var(--gold); outline-offset: 2px; box-shadow: 0 0 14px rgba(242, 193, 78, 0.45); }
.ar-slot.tryon::after { content: "try-on"; position: absolute; top: -8px; left: 50%; transform: translateX(-50%); font-size: 11px; background: #7a3b17; color: #fff; padding: 0 3px; }
.ar-center { display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; }
.ar-center h3, .ar-items h3, .ar-side h3 { font-family: "Silkscreen", monospace; font-weight: 400; font-size: 16px; color: var(--gold); margin: 0; }
.ar-center canvas { width: 100%; max-width: 260px; aspect-ratio: 5 / 4; image-rendering: pixelated; background: radial-gradient(ellipse at 50% 80%, #4a3830, #1a1418 70%); border: 2px solid var(--edge); }
.ar-score { font-size: 20px; color: var(--muted); }
.ar-score b { color: var(--gold); font-size: 24px; }
.ar-items { display: flex; flex-direction: column; min-height: 0; }
.ar-itemhead { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.ar-itemhead .opt { margin: 0; font-size: 17px; }
.ar-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(54px, 1fr)); gap: 5px; overflow-y: auto; max-height: 52vh; padding: 2px; align-content: start; }
.ar-item { position: relative; aspect-ratio: 1; padding: 0; background: radial-gradient(#3a2b26, #1e1612); border: 2px solid; cursor: pointer; }
.ar-item canvas { width: 80%; height: 80%; image-rendering: pixelated; }
.ar-item:hover, .ar-item:focus-visible { transform: translateY(-2px); box-shadow: 0 0 10px rgba(255, 220, 150, 0.3); outline: none; }
.ar-item.locked canvas { opacity: 0.55; filter: saturate(0.6); }
.ar-item.equipped { box-shadow: inset 0 0 0 2px var(--gold); }
.ar-item .price { position: absolute; bottom: 0; left: 0; right: 0; font-size: 12px; line-height: 13px; background: rgba(20, 14, 10, 0.85); color: var(--gold); }
.ar-item .tick { position: absolute; top: 1px; right: 3px; color: var(--gold); font-size: 14px; line-height: 1; }
.ar-side { display: flex; flex-direction: column; gap: 10px; }
.ar-detail { min-height: 150px; }
.ar-dhead { display: flex; gap: 10px; align-items: center; margin-bottom: 6px; }
.ar-dicon { width: 56px; height: 56px; border: 2px solid; display: flex; align-items: center; justify-content: center; background: radial-gradient(#3a2b26, #1e1612); flex: none; }
.ar-dicon canvas { width: 48px; height: 48px; image-rendering: pixelated; }
.ar-dstats { color: #bfe8a8; font-size: 19px; line-height: 1.2; margin-bottom: 8px; }
.ar-owned { color: #7fbf6a; }
.muted { color: var(--muted); }
.ar-statgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 1px 14px; font-size: 17px; margin-top: 4px; }
.ar-stat { display: flex; justify-content: space-between; gap: 6px; border-bottom: 1px solid rgba(107, 79, 58, 0.35); }
.ar-stat span { color: var(--muted); }
.ar-stat b { font-weight: 400; color: var(--ink); white-space: nowrap; }
.up { color: #7dff8a; margin-left: 4px; font-size: 15px; }
.down { color: #ff7a6a; margin-left: 4px; font-size: 15px; }
@media (max-width: 980px) { .ar-body { grid-template-columns: 1fr; } .ar-grid { max-height: 34vh; } }
#wardrobe { background: rgba(10, 7, 12, 0.94); }

.card .role { color: var(--accent); font-family: "Silkscreen", monospace; font-size: 13px; letter-spacing: 1px; margin: -2px 0 4px; }
.herostats { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; font-size: 16px; color: var(--muted); margin-bottom: 4px; }
.herostats b { color: var(--ink); font-weight: 400; }

/* ---------------------------------------------------------------- blessings, accessibility */
.card.duo { border-color: #ffb340; box-shadow: 0 0 18px rgba(255, 179, 64, 0.35), 0 5px 0 #1c130e; }
.card.style { border-color: #8a6ad0; }
.duotag { color: #ffb340 !important; }
.styletag { color: #b89cff !important; }
.panel h3 + .opt { margin-top: 4px; }
body.large { font-size: 26px; }
body.large .card, body.large .help, body.large .hint { font-size: 22px; }
body.large .ar-stat, body.large .ar-dstats { font-size: 20px; }
body.cb .up { color: #4da3ff; }
body.cb .down { color: #ffb000; }

/* story scenes: the game stays visible; the dialogue sits along the bottom */
#story { justify-content: flex-end; background: linear-gradient(rgba(8, 6, 12, 0) 45%, rgba(8, 6, 12, 0.88)); cursor: pointer; padding-bottom: 28px; }
.dlg { display: flex; align-items: flex-end; gap: 18px; width: min(980px, 96vw); text-align: left; }
.dlg-portrait { width: 160px; height: 160px; image-rendering: pixelated; border: 4px solid var(--gold); box-shadow: 0 0 0 3px #3a220e, 0 0 26px rgba(242, 193, 78, 0.35); background: #07060b; flex: none; }
.dlg-body { flex: 1; background: var(--panel); border: 3px solid var(--edge); padding: 12px 18px 10px; min-height: 128px; display: flex; flex-direction: column; }
.dlg-name { font-family: "Silkscreen", monospace; font-size: 22px; letter-spacing: 1px; margin-bottom: 4px; }
.dlg-text { font-size: 27px; line-height: 1.25; flex: 1; }
.dlg-hint { color: var(--muted); font-size: 17px; text-align: right; margin-top: 6px; }
#story.right .dlg { flex-direction: row-reverse; }
#story.right .dlg-portrait { transform: scaleX(-1); }
#story.narr .dlg-portrait, #story.narr .dlg-name { display: none; }
#story.narr .dlg-body { background: rgba(8, 6, 12, 0.6); border-color: transparent; text-align: center; }
#story.narr .dlg-text { font-style: italic; color: #e9dcc4; }
@media (max-width: 640px) { .dlg-portrait { width: 96px; height: 96px; } .dlg-text { font-size: 22px; } }
