/* Hold the Line. Cream cards, dark outlines, hard shadows: drawn like the sprites. */
:root {
  --ink: #2a1d14;
  --cream: #f6e7c4;
  --cream2: #ead3a2;
  --paper: #fff6dd;
  --gold: #f2b631;
  --gold2: #c9861b;
  --green: #5c9c33;
  --green2: #3b6d20;
  --red: #d8432f;
  --red2: #962819;
  --blue: #3f86c8;
  --sky: #9fd3ef;
  --mute: #7a6249;
  --shadow: 0 4px 0 var(--ink);
  --r: 14px;
  --display: "Lilita One", "Trebuchet MS", system-ui, sans-serif;
  --body: "Nunito", system-ui, -apple-system, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: #2b4a1f; color: var(--ink); font-family: var(--body); font-weight: 800; }
body { overflow: hidden; overscroll-behavior: none; -webkit-tap-highlight-color: transparent; }
button { font: inherit; color: inherit; cursor: pointer; }
a { color: var(--blue); }
[hidden] { display: none !important; }

#stage { position: fixed; inset: 0; overflow: hidden; touch-action: none; user-select: none; -webkit-user-select: none; }
#view { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }

/* ---------- shared pieces */
.card {
  background: var(--cream); border: 3px solid var(--ink); border-radius: var(--r); box-shadow: 0 6px 0 var(--ink);
  padding: 22px 26px; max-width: min(560px, 94vw); max-height: 92vh; overflow: auto; position: relative;
}
.card.wide { max-width: min(980px, 96vw); }
.card h1, .card h2, .card h3 { font-family: var(--display); font-weight: 400; margin: 0 0 10px; letter-spacing: .5px; }
.card h2 { font-size: 30px; }
.card h3 { font-size: 20px; margin-top: 14px; }
.sub { margin: 0 0 12px; color: var(--mute); font-weight: 800; }
.small { font-size: 14px; margin: 12px 0 0; text-align: center; }
.screen { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; padding: 12px; z-index: 20; }
.screen.dim { background: rgba(23, 16, 10, .55); }
.btns { display: flex; gap: 12px; justify-content: center; align-items: center; flex-wrap: wrap; margin-top: 16px; }
.btns.col { flex-direction: column; align-items: stretch; }
.btn {
  font-family: var(--display); font-size: 20px; letter-spacing: .4px; padding: 10px 20px; border: 3px solid var(--ink);
  border-radius: 12px; background: var(--paper); box-shadow: var(--shadow); transition: transform .06s, box-shadow .06s;
}
.btn:hover { background: #fffaf0; }
.btn:active, .btn.down { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
.btn.gold { background: var(--gold); }
.btn.gold:hover { background: #ffc94a; }
.btn.small { font-size: 16px; padding: 6px 12px; }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; box-shadow: var(--shadow); }
.btn:focus-visible, .sq:focus-visible, .ab:focus-visible, .pick:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; }
.price::before, .coin {
  content: ""; display: inline-block; width: 14px; height: 14px; border-radius: 50%; background: var(--gold);
  border: 2px solid var(--ink); vertical-align: -2px; margin: 0 4px 0 6px; box-shadow: inset -2px -2px 0 var(--gold2);
}
.coin { width: 18px; height: 18px; margin: 0 6px 0 0; }
.valor { font-family: var(--display); color: #7b3fb0; }
.valor:not(:empty)::before { content: "\2726  "; }
.valor.big { font-size: 22px; }
.icon { display: inline-block; background-repeat: no-repeat; border-radius: 10px; border: 2px solid var(--ink); flex: none; }

/* ---------- title */
.title { text-align: center; padding: 30px 36px 22px; }
.title h1 { font-size: clamp(44px, 8vw, 76px); line-height: .95; color: var(--gold); -webkit-text-stroke: 3px var(--ink); paint-order: stroke fill; text-shadow: 0 5px 0 var(--ink); }
.title .tag { font-size: 20px; margin: 8px 0 6px; }
#scrTitle { background: linear-gradient(180deg, rgba(20, 30, 10, .1), rgba(20, 30, 10, .45)); }

/* ---------- site menu (site/assets/menu.js) on the title card and in the pause card */
.titlemenu, .pausesettings { --vm-accent: var(--gold2); --vm-gap: 10px; --vm-muted: var(--mute); --vm-danger: var(--red2); }
.titlemenu { --vm-width: 330px; margin-top: 14px; }
.titlemenu[data-vm-view="load"], .titlemenu[data-vm-view="replace"] { --vm-width: 440px; }
.titlemenu .btn { font-size: 20px; padding: 6px 16px; }
.vm-menu .btn .vm-sub { font-family: var(--body); font-weight: 800; font-size: 12.5px; letter-spacing: 0; color: var(--mute); opacity: 1; }
.vm-menu a.btn { color: var(--ink); }
.vm-menu .vm-list [data-vm="continue"]:not([disabled]),
.vm-menu .vm-list:has([data-vm="continue"][disabled]) [data-vm="new"] { background: var(--gold); }
.vm-menu .vm-list [data-vm="continue"]:not([disabled]):hover,
.vm-menu .vm-list:has([data-vm="continue"][disabled]) [data-vm="new"]:hover { background: #ffc94a; }
.vm-menu .vm-list .btn:disabled { box-shadow: 0 2px 0 var(--ink); }
.vm-menu .vm-h { font-family: var(--display); font-weight: 400; font-size: 26px; letter-spacing: .5px; }
.vm-menu .vm-note { font-weight: 800; }
.vm-menu .vm-note a { color: var(--blue); }
.vm-menu .vm-slot-btn .vm-label { font-size: 18px; }
.vm-menu .vm-del { font-family: var(--display); border: 3px solid currentColor; border-radius: 12px; background: var(--paper); }
.vm-menu .vm-slider label, .vm-menu .vm-slider output { font-family: var(--display); font-size: 18px; }
.vm-menu .vm-credits .vm-maker { font-family: var(--display); font-weight: 400; font-size: 28px; }
.vm-menu .vm-credits .vm-role { color: var(--mute); }
.vm-menu .vm-back { margin-top: 8px; }
.pausesettings { min-width: min(320px, 80vw); }
.pausesettings .vm-panel { max-width: 340px; margin: 0 auto; }

/* ---------- hero select */
.herolist { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.hero {
  background: var(--paper); border: 3px solid var(--ink); border-radius: 12px; padding: 10px; text-align: center; cursor: pointer;
  box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 6px; min-width: 0;
}
.hero[aria-checked="true"] { background: #fff1b8; outline: 4px solid var(--gold); }
.hero canvas { width: 100%; max-width: 120px; aspect-ratio: 1; margin: 0 auto; display: block; }
.hero h3 { margin: 0; font-size: 22px; }
.hero .role { font-size: 13px; color: var(--mute); margin: 0; }
.hero .paths { display: flex; gap: 4px; justify-content: center; flex-wrap: wrap; }
.hero .paths button { font-size: 12px; padding: 3px 7px; border: 2px solid var(--ink); border-radius: 8px; background: var(--cream2); }
.hero .paths button[aria-pressed="true"] { background: var(--gold); }
.hero .paths button:disabled { opacity: .45; cursor: not-allowed; }
.hero .desc { font-size: 13px; margin: 0; min-height: 3.6em; }
.row { display: flex; align-items: center; gap: 8px; justify-content: center; margin-top: 14px; flex-wrap: wrap; }
.row .lbl { font-family: var(--display); font-size: 18px; }
.diff button { border: 3px solid var(--ink); border-radius: 10px; background: var(--paper); padding: 5px 14px; font-family: var(--display); font-size: 17px; }
.diff button[aria-checked="true"] { background: var(--gold); }

/* ---------- perks */
.perklist { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; }
.perk { display: flex; gap: 10px; align-items: center; background: var(--paper); border: 3px solid var(--ink); border-radius: 12px; padding: 8px; }
.perk .txt { flex: 1; min-width: 0; }
.perk b { font-family: var(--display); font-weight: 400; font-size: 17px; display: block; }
.perk small { display: block; color: var(--mute); font-size: 12.5px; }
.pips { display: flex; gap: 3px; margin-top: 3px; }
.pips i { width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--ink); background: var(--cream2); }
.pips i.on { background: #9a5bd0; }
.perk .btn { font-size: 15px; padding: 5px 10px; white-space: nowrap; }

/* ---------- how */
.how { padding-left: 20px; margin: 0; line-height: 1.45; }
.how li { margin-bottom: 6px; }

/* ---------- HUD */
#hud { position: absolute; inset: 0; pointer-events: none; z-index: 10; }
#hud button, #hud .inv, #hud .herobox { pointer-events: auto; }
.topbar {
  position: absolute; top: max(8px, env(safe-area-inset-top)); left: 50%; transform: translateX(-50%);
  display: flex; gap: 10px; align-items: center; padding: 6px 10px; background: var(--cream); border: 3px solid var(--ink);
  border-radius: 14px; box-shadow: var(--shadow); max-width: calc(100vw - 16px);
}
.topbar .lbl { font-family: var(--display); font-size: 15px; color: var(--mute); }
.wavebox { font-family: var(--display); font-size: 22px; white-space: nowrap; }
.wavebox small { font-size: 15px; color: var(--mute); }
.mod { margin-left: 6px; font-size: 13px; background: var(--red); color: #fff; border: 2px solid var(--ink); border-radius: 8px; padding: 1px 6px; vertical-align: 3px; font-family: var(--body); }
.mod:empty { display: none; }
.corebox { display: flex; align-items: center; gap: 6px; }
.goldbox { font-family: var(--display); font-size: 22px; display: flex; align-items: center; white-space: nowrap; }
.goldbox.big { font-size: 28px; }
.tools { display: flex; gap: 6px; }
.sq { width: 38px; height: 38px; border: 3px solid var(--ink); border-radius: 10px; background: var(--paper); box-shadow: 0 3px 0 var(--ink); font-family: var(--display); font-size: 17px; padding: 0; }
.sq[aria-pressed="false"] { background: var(--cream2); color: var(--mute); text-decoration: line-through; }
.bar { position: relative; height: 18px; border: 3px solid var(--ink); border-radius: 9px; background: #4a3426; overflow: hidden; }
.bar i { position: absolute; inset: 0 auto 0 0; width: 100%; background: var(--green); box-shadow: inset 0 -4px 0 var(--green2); transition: width .15s; }
.bar span { position: relative; display: block; text-align: center; font-size: 11.5px; line-height: 12px; color: #fff; text-shadow: 0 1px 0 #000, 0 0 3px #000; }
.bar.core { width: clamp(110px, 18vw, 220px); }
.bar.core i { background: #6db2e6; box-shadow: inset 0 -4px 0 #3a78ad; }
.bar.xp { height: 10px; border-width: 2px; margin-top: 3px; }
.bar.xp i { background: #b36be0; box-shadow: none; }
.banner {
  position: absolute; top: 112px; left: 50%; transform: translateX(-50%); font-family: var(--display); font-size: clamp(26px, 4vw, 44px);
  color: var(--gold); -webkit-text-stroke: 2.5px var(--ink); paint-order: stroke fill; text-shadow: 0 4px 0 var(--ink); white-space: nowrap;
  animation: pop .35s ease-out;
}
.banner.red { color: #ff7b5c; }
@keyframes pop { from { transform: translateX(-50%) scale(.6); opacity: 0; } to { transform: translateX(-50%) scale(1); opacity: 1; } }

.herobox {
  position: absolute; left: max(10px, env(safe-area-inset-left)); bottom: max(10px, env(safe-area-inset-bottom)); display: flex; gap: 8px; align-items: flex-end;
  background: var(--cream); border: 3px solid var(--ink); border-radius: 14px; box-shadow: var(--shadow); padding: 6px 10px 6px 6px;
}
.portrait { width: 56px; height: 56px; border: 3px solid var(--ink); border-radius: 12px; background: var(--sky); overflow: hidden; flex: none; }
.portrait canvas { width: 100%; height: 100%; display: block; }
.herobars { width: clamp(130px, 16vw, 200px); }
.heroname { font-family: var(--display); font-size: 17px; display: flex; justify-content: space-between; margin-bottom: 2px; }
.heroname span { color: var(--mute); font-size: 15px; }
.syn { display: flex; flex-direction: column; gap: 3px; }
.syn .chip { display: flex; align-items: center; gap: 3px; font-family: var(--display); font-size: 14px; }
.syn .chip .icon { width: 24px; height: 24px; border-radius: 7px; }
.syn .chip.on { color: #7b3fb0; }

.abilities { position: absolute; right: max(12px, env(safe-area-inset-right)); bottom: max(12px, env(safe-area-inset-bottom)); display: flex; gap: 10px; align-items: flex-end; }
.ab {
  position: relative; width: 64px; height: 64px; padding: 0; border: 3px solid var(--ink); border-radius: 14px; background: var(--paper);
  box-shadow: var(--shadow); overflow: hidden; touch-action: none;
}
.ab.big { width: 76px; height: 76px; }
.ab .ic { position: absolute; inset: 0; background-repeat: no-repeat; }
.ab .cd { position: absolute; inset: 0; background: rgba(20, 14, 8, .62); color: #fff; font-family: var(--display); font-size: 22px; display: flex; align-items: center; justify-content: center; }
.ab .cd:empty { display: none; }
.ab .key { position: absolute; right: 3px; bottom: 1px; font-family: var(--display); font-size: 14px; color: #fff; text-shadow: 0 0 3px #000, 0 1px 0 #000; }
.ab.ready { animation: ready .4s ease-out; }
@keyframes ready { 50% { transform: scale(1.12); } }
.inv { position: absolute; right: max(12px, env(safe-area-inset-right)); bottom: 104px; display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; max-width: 240px; }
.inv .icon { width: 34px; height: 34px; border-radius: 8px; background-color: var(--paper); }
.stick { position: absolute; width: 120px; height: 120px; margin: -60px 0 0 -60px; border-radius: 50%; border: 3px solid rgba(42, 29, 20, .7); background: rgba(255, 246, 221, .25); pointer-events: none; }
.stick i { position: absolute; left: 50%; top: 50%; width: 52px; height: 52px; margin: -26px 0 0 -26px; border-radius: 50%; background: var(--cream); border: 3px solid var(--ink); }
.respawn { position: absolute; left: 50%; top: 40%; transform: translate(-50%, -50%); font-family: var(--display); font-size: 28px; color: #fff; -webkit-text-stroke: 2px var(--ink); paint-order: stroke fill; text-shadow: 0 3px 0 var(--ink); }

/* ---------- level up cards */
.cards3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.pick {
  display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; background: var(--paper);
  border: 3px solid var(--ink); border-radius: 12px; box-shadow: var(--shadow); padding: 12px 10px;
}
.pick:hover { background: #fff1b8; }
.pick:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
.pick .icon { width: 64px; height: 64px; }
.pick b { font-family: var(--display); font-weight: 400; font-size: 19px; }
.pick small { font-size: 13.5px; color: var(--mute); }
.pick .kind { font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: #7b3fb0; }
.pick.rare { background: #f1e3ff; }

/* ---------- camp */
.card.camp { max-width: min(1000px, 97vw); width: 100%; }
.camphead { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.camphead .right { display: flex; align-items: center; gap: 14px; }
.campcols { display: grid; grid-template-columns: 1.2fr 1fr; gap: 18px; }
.shop { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; margin-bottom: 8px; }
.item {
  display: flex; gap: 8px; align-items: flex-start; text-align: left; background: var(--paper); border: 3px solid var(--ink);
  border-radius: 12px; padding: 7px; box-shadow: 0 3px 0 var(--ink);
}
.item .icon { width: 44px; height: 44px; border-radius: 8px; }
.item .txt { min-width: 0; }
.item b { font-family: var(--display); font-weight: 400; font-size: 15.5px; display: block; line-height: 1.1; }
.item small { display: block; font-size: 12px; color: var(--mute); line-height: 1.25; }
.item .tags { display: flex; gap: 3px; margin-top: 3px; flex-wrap: wrap; }
.item .tags span { font-size: 10.5px; border: 2px solid var(--ink); border-radius: 6px; padding: 0 4px; background: var(--cream2); }
.item.sold { opacity: .35; pointer-events: none; }
.item:disabled { opacity: .55; cursor: not-allowed; }
.pack { display: flex; gap: 6px; flex-wrap: wrap; min-height: 54px; }
.pack .slot { width: 50px; height: 50px; border: 3px dashed var(--mute); border-radius: 10px; padding: 0; background: transparent; }
.pack .slot.full { border-style: solid; border-color: var(--ink); background: var(--paper); }
.pack .slot .icon { width: 100%; height: 100%; border: 0; }
.pack .slot { position: relative; }
.pack .slot.sel { outline: 4px solid var(--gold); }
.pack .stars { position: absolute; left: 0; right: 0; bottom: -2px; font-size: 12px; color: var(--gold); -webkit-text-stroke: 1px var(--ink); text-align: center; line-height: 1; }
.packact { margin-top: 6px; min-height: 40px; font-size: 13px; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; }
.packact b { font-family: var(--display); font-weight: 400; font-size: 16px; }
.packact small { color: var(--mute); }
.packact .acts { display: flex; gap: 6px; margin-left: auto; }
.towers { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.tw { background: var(--paper); border: 3px solid var(--ink); border-radius: 12px; padding: 6px; display: flex; flex-direction: column; gap: 4px; }
.tw .name { font-family: var(--display); font-size: 15px; }
.tw .opts { display: flex; gap: 4px; flex-wrap: wrap; }
.tw .opts .btn { font-size: 13px; padding: 3px 7px; border-width: 2px; box-shadow: 0 2px 0 var(--ink); }
.repair { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 10px; font-family: var(--display); }
.synlist { display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
.synlist .s { display: flex; gap: 6px; align-items: center; }
.synlist .s .icon { width: 30px; height: 30px; border-radius: 8px; }
.synlist .s.dim { opacity: .5; }
.synlist .s b { font-family: var(--display); font-weight: 400; font-size: 15px; }
.next { margin: 2px 0 10px; color: var(--mute); font-size: 14px; }

/* ---------- end */
.stats { list-style: none; padding: 0; margin: 10px 0; display: grid; grid-template-columns: 1fr 1fr; gap: 4px 16px; }
.stats li { display: flex; justify-content: space-between; border-bottom: 2px dotted var(--cream2); }

/* ---------- misc */
.loading { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: #2b4a1f; color: var(--cream); font-family: var(--display); font-size: 26px; z-index: 50; }
.tip {
  position: fixed; z-index: 60; max-width: 260px; background: var(--paper); border: 3px solid var(--ink); border-radius: 10px;
  box-shadow: var(--shadow); padding: 7px 9px; font-size: 13px; pointer-events: none;
}
.tip b { font-family: var(--display); font-weight: 400; font-size: 16px; display: block; }
.portrait-hint { display: none; }
.legal { position: fixed; left: 0; right: 0; bottom: 0; display: flex; gap: 14px; justify-content: center; font-size: 11px; padding: 2px; z-index: 5; pointer-events: none; }
.legal a { color: rgba(255, 246, 221, .75); pointer-events: auto; text-decoration: none; }
body.playing .legal { display: none; }
/* (2026-10-13: footer on the main menu only) */
body:has(#scrTitle[hidden]) .legal { display: none; }

@media (max-width: 760px), (max-height: 480px) {
  .card { padding: 14px 16px; }
  .card h2 { font-size: 24px; }
  .herolist { grid-template-columns: repeat(2, 1fr); }
  .hero .desc { display: none; }
  .cards3 { grid-template-columns: 1fr 1fr 1fr; gap: 6px; }
  .pick { padding: 8px 5px; }
  .pick .icon { width: 44px; height: 44px; }
  .pick small { font-size: 11.5px; }
  .campcols { grid-template-columns: 1fr; }
  .topbar { gap: 6px; padding: 4px 6px; top: 4px; }
  .topbar .lbl { display: none; }
  .wavebox, .goldbox { font-size: 18px; }
  .sq { width: 32px; height: 32px; font-size: 14px; }
  .herobox { padding: 4px 6px 4px 4px; }
  .portrait { width: 42px; height: 42px; }
  .herobars { width: 120px; }
  .syn { display: none; }
  .ab { width: 56px; height: 56px; }
  .ab.big { width: 64px; height: 64px; }
  .inv { bottom: 86px; max-width: 160px; }
  .inv .icon { width: 26px; height: 26px; }
}
@media (max-height: 480px) {
  .herolist { grid-template-columns: repeat(4, 1fr); gap: 8px; }
  .hero { padding: 6px; gap: 3px; }
  .hero canvas { max-width: 70px; }
  .hero h3 { font-size: 17px; }
  .hero .role { display: none; }
  .hero .paths button { font-size: 10.5px; padding: 2px 5px; }
  .card { max-height: 96vh; }
  .card h2 { font-size: 22px; margin-bottom: 6px; }
  .btns { margin-top: 10px; }
  .banner { top: 84px; font-size: 26px; }
  .shop { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
  .item b { font-size: 14px; }
}
@media (orientation: portrait) and (max-width: 600px) {
  .portrait-hint { display: flex; position: absolute; inset: 0; z-index: 70; background: rgba(23, 16, 10, .8); color: var(--cream); align-items: center; justify-content: center; text-align: center; padding: 30px; font-family: var(--display); font-size: 24px; }
  body:not(.playing) .portrait-hint { display: none; }
}
/* short landscape screens (phones on their side): title smaller, menu in two columns */
@media (max-height: 500px) {
  .title { padding: 14px 20px 14px; }
  .title h1 { font-size: 40px; text-shadow: 0 3px 0 var(--ink); -webkit-text-stroke: 2px var(--ink); }
  .title .tag { font-size: 16px; margin: 4px 0 0; }
  .titlemenu { --vm-width: 560px; --vm-gap: 8px; margin-top: 10px; }
  .titlemenu .vm-list { display: grid; grid-template-columns: 1fr 1fr; }
  .titlemenu .btn { font-size: 18px; padding: 4px 12px; }
  .titlemenu .vm-item { min-height: 2.6rem; }
}
@media (prefers-reduced-motion: reduce) {
  .banner, .ab.ready { animation: none; }
}

/* ---------- 2026-10-01 round 2: five skills, rarities, build mode, minimap */
.ab .lock { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-family: var(--display); font-size: 15px; color: #fff; text-shadow: 0 0 3px #000, 0 1px 0 #000; }
.ab .lock:empty { display: none; }
.ab.locked .ic { filter: grayscale(1) brightness(.55); }
.ab { width: 58px; height: 58px; }
.ab.big { width: 72px; height: 72px; }
.abilities { gap: 8px; }
.inv { display: grid; grid-template-columns: repeat(10, 26px); gap: 3px; max-width: none; bottom: 98px; }
.inv .icon { width: 26px; height: 26px; border-radius: 6px; }
.r0 { --rc: #9a8f80; } .r1 { --rc: #4f9d3a; } .r2 { --rc: #3a7fd0; } .r3 { --rc: #9b4fd6; } .r4 { --rc: #e08a1a; }
.inv .icon[class*=" r"], .pack .slot.full[class*=" r"] { border-color: var(--rc); box-shadow: inset 0 0 0 2px var(--rc); }
.item[class*=" r"] { border-color: var(--rc); box-shadow: 0 3px 0 var(--rc); }
.item.r4 { background: #fff1d6; }
.item.r3 { background: #f6ecff; }
.item .rar { font-size: 10.5px; text-transform: uppercase; letter-spacing: .8px; color: var(--rc); display: block; }
.odds { display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: 12px; margin: -4px 0 8px; }
.odds span { color: var(--rc); }
.pack { display: grid; grid-template-columns: repeat(10, 1fr); gap: 4px; }
.pack .slot { width: auto; aspect-ratio: 1; height: auto; }
.towerinfo { font-size: 13.5px; margin: 0 0 8px; }
.buildbar {
  position: absolute; top: max(8px, env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); z-index: 15; display: flex; gap: 10px; align-items: center;
  background: var(--cream); border: 3px solid var(--ink); border-radius: 14px; box-shadow: var(--shadow); padding: 6px 10px; max-width: calc(100vw - 16px); flex-wrap: wrap; justify-content: center; white-space: nowrap;
}
@media (min-width: 900px) { .buildbar { flex-wrap: nowrap; } }
.buildbar .t { font-size: 14px; }
.plotpop {
  position: absolute; z-index: 16; width: 230px; background: var(--cream); border: 3px solid var(--ink); border-radius: 12px; box-shadow: var(--shadow);
  padding: 8px; display: flex; flex-direction: column; gap: 6px;
}
.plotpop b { font-family: var(--display); font-weight: 400; font-size: 18px; }
.plotpop .ring { margin: 0; font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: var(--mute); }
.plotpop > small { color: var(--mute); font-size: 12.5px; }
.plotpop .btn { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; text-align: left; gap: 2px 6px; }
.plotpop .btn small { flex-basis: 100%; font-family: var(--body); font-size: 11.5px; color: var(--mute); }
@media (max-width: 760px), (max-height: 480px) {
  .ab { width: 48px; height: 48px; }
  .ab.big { width: 56px; height: 56px; }
  .ab .key { font-size: 12px; }
  .abilities { gap: 5px; }
  .inv { display: none; }
  .pack { grid-template-columns: repeat(10, 1fr); }
  .plotpop { width: 210px; padding: 6px; gap: 4px; }
  .buildbar .t { display: none; }
}
body.building #abilities, body.building .herobox, body.building .inv { display: none; }

/* ---------- round 3: locks, aiming, modes */
.ware { position: relative; display: flex; }
.ware .item { flex: 1; width: 100%; padding-bottom: 26px; }
.lockbtn { position: absolute; bottom: 6px; right: 6px; font-size: 11px; padding: 1px 6px; border: 2px solid var(--ink); border-radius: 7px; background: var(--cream2); font-family: var(--display); letter-spacing: .3px; }
.lockbtn.on { background: var(--gold); }
.ware.locked .item { outline: 3px dashed var(--gold2); outline-offset: -7px; }
.shoprow { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.lockinfo { font-size: 12.5px; color: var(--mute); }
.ab.aiming { outline: 4px solid var(--gold); outline-offset: 1px; transform: translateY(-4px); }
.aimhint { position: absolute; left: 50%; bottom: 96px; transform: translateX(-50%); background: var(--cream); border: 3px solid var(--ink); border-radius: 10px; box-shadow: var(--shadow); padding: 4px 10px; font-size: 13.5px; white-space: nowrap; max-width: 92vw; overflow: hidden; text-overflow: ellipsis; }
.modesel button { border: 3px solid var(--ink); border-radius: 10px; background: var(--paper); padding: 5px 14px; font-family: var(--display); font-size: 17px; }
.modesel button[aria-checked="true"] { background: var(--gold); }
.center { text-align: center; }
#endlessBest { margin: 6px 0 0; min-height: 1em; }
@media (max-width: 760px), (max-height: 480px) {
  .aimhint { bottom: 70px; font-size: 12px; }
  .modesel button { font-size: 15px; padding: 3px 10px; }
}

/* ---------- round 5 (2026-10-03): the camp as a binder, item popups, skill levels in the middle */
/* skill bar: bottom middle, each button says its level first */
.abilities { left: 50%; right: auto; transform: translateX(-50%); }
.ab .slv { position: absolute; left: 0; top: 0; padding: 1px 5px 2px; border-bottom-right-radius: 8px; background: rgba(42, 29, 20, .78); color: var(--paper); font-family: var(--display); font-size: 12.5px; line-height: 1.1; letter-spacing: .3px; }
.ab .slv:empty { display: none; }
.ab.maxed .slv { color: var(--gold); }
.ab .lock { flex-direction: column; line-height: 1; }
.ab .lock small { font-size: 10px; letter-spacing: .4px; opacity: .85; }
.aimhint { bottom: 104px; }
.inv { bottom: max(12px, env(safe-area-inset-bottom)); }

/* the camp card is a binder page; tabs stick up from its top edge over the right-hand pages */
.card.camp {
  --gear: 296px; --pad: 22px;
  width: min(1060px, 96vw); max-width: none; height: min(660px, calc(100vh - 64px)); max-height: none; margin-top: 36px;
  padding: 16px var(--pad) 18px; overflow: visible; display: flex; flex-direction: column; gap: 12px;
}
.binder { position: absolute; bottom: 100%; left: calc(var(--pad) + var(--gear) + 18px); display: flex; gap: 4px; margin-bottom: -3px; }
.binder .tab {
  position: relative; font-family: var(--display); font-size: 18px; letter-spacing: .4px; color: var(--mute);
  padding: 6px 18px 7px; margin-top: 6px; background: var(--cream2); border: 3px solid var(--ink); border-bottom: 0; border-radius: 12px 12px 0 0;
  transition: margin-top .12s ease-out, padding .12s ease-out, color .12s;
}
.binder .tab:hover { color: var(--ink); }
.binder .tab[aria-selected="true"] { background: var(--cream); color: var(--ink); margin-top: 0; padding: 9px 22px 10px; z-index: 1; }
.binder .tab[aria-selected="true"]::after { content: ""; position: absolute; left: 0; right: 0; bottom: -3px; height: 6px; background: var(--cream); }
.binder .tab:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; }

.camp .camphead { flex-wrap: nowrap; align-items: center; }
.camp .camphead h2 { margin: 0; line-height: 1; }
.camp .camphead .next { margin: 4px 0 0; font-size: 13.5px; color: var(--mute); }
.camp .camphead .right { flex: none; }
.campbody { flex: 1; min-height: 0; display: grid; grid-template-columns: var(--gear) 1fr; gap: 18px; }
.camp h3 { font-size: 19px; margin: 0 0 8px; }
.camp h3 small { font-family: var(--body); font-size: 13px; color: var(--mute); }

/* equipment: always in view */
.gear { background: var(--cream2); border: 3px solid var(--ink); border-radius: 12px; padding: 10px 12px; display: flex; flex-direction: column; min-height: 0; }
.camp .pack { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; min-height: 0; }
.camp .pack .slot { width: auto; height: auto; aspect-ratio: 1; border-radius: 10px; border-color: rgba(122, 98, 73, .55); background: rgba(255, 246, 221, .35); }
.camp .pack .slot.full { background: var(--paper); cursor: pointer; transition: transform .08s ease-out; }
.camp .pack .slot.full:hover { transform: translateY(-2px); }
.camp .pack .slot.sel { outline: 3px solid var(--gold); outline-offset: 2px; }
.camp .pack .stars { bottom: 1px; font-size: 10px; letter-spacing: -1px; }
.gear .hint { margin: 8px 0 6px; font-size: 12.5px; color: var(--mute); line-height: 1.3; }
.herostats { list-style: none; margin: auto 0 0; padding: 8px 0 0; border-top: 2px dashed rgba(122, 98, 73, .5); display: grid; grid-template-columns: 1fr 1fr; gap: 2px 14px; font-size: 13px; }
.herostats li { display: flex; justify-content: space-between; gap: 6px; cursor: help; }
.herostats span { color: var(--mute); }
.herostats b { font-variant-numeric: tabular-nums; }

/* pages behind the tabs */
.pages { min-height: 0; display: flex; flex-direction: column; }
.page { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 10px; }
.page[hidden] { display: none !important; }
.camp .odds { margin: 0; font-size: 12.5px; }
.camp .shop { flex: 1; min-height: 0; display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(2, 1fr); gap: 10px; margin: 0; }
.ware.item {
  position: relative; display: grid; grid-template-columns: 48px 1fr; grid-template-rows: 1fr auto; gap: 4px 10px; align-content: start; text-align: left;
  padding: 10px 10px 8px; border: 3px solid var(--rc, var(--ink)); border-radius: 12px; background: var(--paper); box-shadow: 0 3px 0 var(--rc, var(--ink));
  min-height: 0; overflow: hidden; transition: transform .08s ease-out, box-shadow .08s;
}
.ware.item:hover { transform: translateY(-2px); box-shadow: 0 5px 0 var(--rc, var(--ink)); }
.ware.item .icon { width: 48px; height: 48px; border-radius: 9px; grid-row: 1 / span 2; }
.ware.item .txt { min-width: 0; }
.ware.item b { font-size: 16px; }
.ware.item small { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; margin-top: 2px; }
.ware.item .price { grid-column: 2; justify-self: end; align-self: end; font-family: var(--display); font-size: 16px; }
.ware.item.cant .price { color: var(--red2); }
.ware.item.locked { outline: 3px dashed var(--gold2); outline-offset: -8px; }
.ware.item.open { outline: 3px solid var(--gold); outline-offset: 2px; }
.ware.item.sold { opacity: .35; }
.ware.item.sold .price::before { display: none; }
.camp .shoprow { gap: 10px; flex-wrap: nowrap; }
.shoprow .grow { flex: 1; }

.defrow { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; align-content: start; }
.def { background: var(--paper); border: 3px solid var(--ink); border-radius: 12px; padding: 12px 14px; display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.def h4 { font-family: var(--display); font-weight: 400; font-size: 18px; margin: 0; letter-spacing: .4px; }
.def .towerinfo { margin: 0; }
.def .repair { margin: 0; width: 100%; }
.camp .synlist { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 18px; align-content: start; }
.camp .synlist .s { align-items: flex-start; }

/* the item popup */
.itempop {
  position: absolute; z-index: 30; width: 290px; background: var(--paper); border: 3px solid var(--ink); border-radius: 12px;
  box-shadow: 0 5px 0 var(--ink), 0 14px 28px rgba(23, 16, 10, .35); overflow: hidden; font-size: 13.5px;
  animation: popin .14s ease-out;
}
@keyframes popin { from { opacity: 0; transform: translateY(4px) scale(.97); } to { opacity: 1; transform: none; } }
.itempop header {
  display: grid; grid-template-columns: 52px 1fr auto; gap: 10px; align-items: center; padding: 10px 12px;
  background: color-mix(in srgb, var(--rc) 22%, var(--paper)); border-bottom: 3px solid var(--rc);
}
.itempop header .icon { width: 52px; height: 52px; border-radius: 10px; border: 3px solid var(--rc); }
.itempop header b { font-family: var(--display); font-weight: 400; font-size: 20px; line-height: 1.05; display: block; }
.itempop .rar { font-size: 11px; text-transform: uppercase; letter-spacing: .9px; color: color-mix(in srgb, var(--rc) 70%, var(--ink)); }
.itempop .rar .stars { color: var(--gold2); letter-spacing: 0; }
.itempop .cost { font-family: var(--display); font-size: 18px; align-self: start; }
.itempop .st { list-style: none; margin: 0; padding: 10px 14px 4px; display: flex; flex-direction: column; gap: 3px; }
.itempop .st li::before { content: ""; display: inline-block; width: 7px; height: 7px; margin-right: 8px; transform: rotate(45deg) translateY(-1px); background: var(--rc); border: 1.5px solid var(--ink); }
.itempop .sp { margin: 6px 12px 0; padding: 7px 9px; border-radius: 8px; background: color-mix(in srgb, var(--rc) 16%, var(--paper)); line-height: 1.35; }
.itempop .sp b { font-family: var(--display); font-weight: 400; color: color-mix(in srgb, var(--rc) 70%, var(--ink)); }
.itempop .tags { margin: 8px 14px 0; display: flex; gap: 6px; flex-wrap: wrap; }
.itempop .tags span { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; padding: 1px 7px 1px 2px; border: 2px solid var(--ink); border-radius: 8px; background: var(--cream2); }
.itempop .tags .icon { width: 18px; height: 18px; border-radius: 5px; }
.itempop .acts { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 10px 12px 12px; margin-top: 8px; border-top: 2px dashed var(--cream2); }
.itempop .acts .why { flex-basis: 100%; margin: 0; font-size: 12px; color: var(--mute); line-height: 1.3; }
.itempop .maxed { font-family: var(--display); color: var(--gold2); }

/* phones on their side */
@media (max-width: 760px), (max-height: 500px) {
  .abilities { left: auto; right: max(10px, env(safe-area-inset-right)); transform: none; }
  .ab .slv { font-size: 10.5px; padding: 0 4px 1px; }
  .aimhint { bottom: 70px; }
  .card.camp { --gear: 220px; --pad: 12px; width: 98vw; height: calc(100vh - 40px); margin-top: 30px; padding: 8px var(--pad) 10px; gap: 6px; }
  .screen.dim:has(.camp) { padding: 4px; align-items: flex-end; }
  .binder .tab { font-size: 14px; padding: 4px 11px 4px; margin-top: 4px; }
  .binder .tab[aria-selected="true"] { padding: 6px 13px 6px; }
  .camp .camphead h2 { font-size: 19px; }
  .camp .camphead .next { font-size: 11px; margin-top: 2px; }
  .camp .camphead .btn { font-size: 16px; padding: 5px 12px; }
  .camp .goldbox.big { font-size: 18px; }
  .campbody { gap: 8px; }
  .camp h3 { font-size: 15px; margin-bottom: 4px; }
  .gear { padding: 6px 8px; }
  .camp .pack { gap: 4px; }
  .camp .pack .slot { border-width: 2px; border-radius: 7px; }
  .gear .hint { display: none; }
  .herostats { font-size: 10.5px; gap: 0 8px; padding-top: 4px; }
  .camp .odds { font-size: 10.5px; gap: 2px 8px; }
  .camp .shop { gap: 6px; }
  .ware.item { grid-template-columns: 34px 1fr; padding: 5px 6px 4px; gap: 2px 6px; border-width: 2px; }
  .ware.item .icon { width: 34px; height: 34px; }
  .ware.item b { font-size: 13px; }
  .ware.item small { display: none; }
  .ware.item .rar { font-size: 9px; }
  .ware.item .price { font-size: 13px; }
  .page { gap: 6px; }
  .camp .shoprow .btn { font-size: 13px; padding: 4px 8px; }
  .camp .lockinfo { font-size: 10.5px; }
  .defrow { gap: 8px; }
  .def { padding: 6px 8px; gap: 4px; }
  .def h4 { font-size: 15px; }
  .def .towerinfo, .camp .synlist { font-size: 11px; }
  .camp .synlist { gap: 4px 10px; }
  .camp .synlist .s .icon { width: 22px; height: 22px; }
  .itempop { width: 250px; font-size: 12px; }
  .itempop header { grid-template-columns: 40px 1fr auto; padding: 6px 8px; }
  .itempop header .icon { width: 40px; height: 40px; }
  .itempop header b { font-size: 16px; }
  .itempop .st { padding: 6px 10px 2px; }
  .itempop .tags { margin: 4px 10px 0; }
  .itempop .acts { padding: 6px 8px 8px; margin-top: 4px; }
}
@media (prefers-reduced-motion: reduce) { .itempop { animation: none; } .binder .tab { transition: none; } }
::selection { background: var(--gold); color: var(--ink); }
/* round 5 fixes */
.camp .pack { grid-template-columns: repeat(5, minmax(0, 1fr)); flex: none; }
.ware.item { grid-template-columns: 56px minmax(0, 1fr); grid-template-rows: auto 1fr auto; }
.ware.item .icon { width: 56px; height: 56px; grid-row: 1 / span 3; align-self: start; }
.ware.item small { -webkit-line-clamp: 4; font-size: 12.5px; }
.ware.item .tags { grid-column: 2; align-self: end; margin: 0; }
.ware.item .price { grid-column: 2; }
.camp .repair { flex-wrap: nowrap; }
.camp .repair .btn, .camp .shoprow .btn { white-space: nowrap; }
.itempop { width: 300px; }
.itempop .acts .btn { font-size: 15px; padding: 5px 11px; }
@media (max-width: 760px), (max-height: 500px) {
  .ware.item { grid-template-columns: 34px minmax(0, 1fr); }
  .ware.item .icon { width: 34px; height: 34px; }
  .ware.item .tags { display: none; }
  .itempop { width: 250px; }
  .itempop .acts .btn { font-size: 13px; padding: 3px 8px; }
}

/* Build popups never taller than the screen (2026-10-09 bug test: on phones held sideways the barricade popup ran
   off the bottom and Crystal Spikes could not be reached). Short screens get two columns; anything left scrolls. */
.plotpop { max-height: calc(100vh - 68px); max-height: calc(100dvh - 68px); overflow-y: auto; overscroll-behavior: contain; touch-action: pan-y; }
@media (max-height: 480px) {
  .plotpop { width: 400px; max-width: calc(100vw - 16px); display: grid; grid-template-columns: 1fr 1fr; align-content: start; }
  .plotpop > .ring, .plotpop > b, .plotpop > small { grid-column: 1 / -1; }
}

/* The build bar stays one short row, centred (2026-10-09 bug test: with left:50% and wrapping it squeezed into half
   the width and grew into a tall block over the top build spots on phones narrower than about 790 px). */
.buildbar { left: 0; right: 0; margin: 0 auto; width: max-content; transform: none; }
@media (max-width: 760px), (max-height: 480px) { .buildbar { flex-wrap: nowrap; padding: 4px 8px; gap: 8px; } }

/* Build popup (2026-10-09 bug test): Upgrade / Max level and Repair are always two lines tall, so nothing moves when
   the popup redraws after an action; Tear down sits apart on its own last row and fills up while held. */
.plotpop .btn.slot > span { flex-basis: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.plotpop .btn.sell { margin-top: 6px; background: #f6d9cf; position: relative; overflow: hidden; -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }
.plotpop .btn.sell:hover { background: #fbe6de; }
.plotpop .btn.sell::before { content: ''; position: absolute; inset: 0; background: rgba(216, 67, 47, .45); transform: scaleX(0); transform-origin: left; }
.plotpop .btn.sell.holding::before { transform: scaleX(1); transition: transform .6s linear; }
.plotpop .btn.sell > span { position: relative; }
@media (max-height: 480px) { .plotpop > .sell { grid-column: 1 / -1; } }
