/* Mud Hut (it was Fort Floof): a dusky meadow, the sunken hut on one canvas, the HUD on top and the squad's shop below. The title
   screen and the sheets are shared/mainmenu.js (menu.css, loaded after this); only their colors are set here. */
:root {
  --bg: #17221c; --bg-hi: #2c4335; --ink: #fff7ea; --ink-soft: #c9d8c8; --line: rgba(255, 247, 234, 0.16);
  --panel: #213027; --panel-hi: #2b3d32; --row: #2a3a30; --row-hi: #33473a;
  --gold: #f2c14e; --gold-ink: #3a2608; --cash: #9be37a; --coin: #ffd34e;
  --kento: #f08a3c; --honey: #f2c14e; --mack: #5b8fd6; --tyler: #c9a26b; --danger: #ff4f6d;
  --sheet: #fff8ec; --sheet-ink: #2c2a22; --sheet-soft: #6d6a58;
  color-scheme: light;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
* { touch-action: manipulation; }
html, body { margin: 0; height: 100%; }
body {
  font-family: "Baloo 2", ui-rounded, system-ui, sans-serif; color: var(--ink); background: var(--bg);
  overflow: hidden; overscroll-behavior: none;
}
button { font: inherit; color: inherit; -webkit-tap-highlight-color: transparent; }
.app {
  position: fixed; inset: 0; display: flex; flex-direction: column;
  padding: 0;
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
}

/* ---- the HUD ---- */
.hud {
  display: grid; grid-template-columns: 48px 1fr auto auto; align-items: center; gap: 8px;
  padding: calc(var(--sg-corner-top) - 2px) 10px 6px var(--sg-corner-left); min-height: 56px; /* the corner's menu button heads the row (shared/menu.css) */
}
.icon-btn {
  width: 46px; height: 46px; display: grid; place-items: center; border: 0; border-radius: 14px;
  background: rgba(255, 255, 255, 0.12); box-shadow: 0 2px 0 rgba(0, 0, 0, 0.3); cursor: pointer;
}
.icon-btn svg { width: 24px; height: 24px; fill: none; stroke: var(--ink); stroke-width: 2.8; stroke-linecap: round; }
.icon-btn:active { transform: scale(0.94); }
.wave { min-width: 0; }
.wave-top { display: flex; align-items: baseline; gap: 8px; line-height: 1.1; }
.wave-top b { font-size: 22px; font-weight: 800; white-space: nowrap; }
.tier { font-size: 14px; font-weight: 800; color: var(--ink-soft); white-space: nowrap; }
.wave-bar { height: 6px; margin-top: 3px; border-radius: 99px; background: rgba(0, 0, 0, 0.35); overflow: hidden; }
.wave-bar i { display: block; height: 100%; width: 100%; transform-origin: left; transform: scaleX(0); background: linear-gradient(90deg, #8fd16f, #f2c14e); }
.money { display: grid; justify-items: end; line-height: 1.1; font-weight: 800; font-variant-numeric: tabular-nums; }
.cash { color: var(--cash); font-size: 18px; }
.coins { color: var(--coin); font-size: 16px; }
.coins::before { content: ''; display: inline-block; width: 0.78em; height: 0.78em; margin-right: 4px; border-radius: 50%; vertical-align: -0.08em; background: radial-gradient(circle at 35% 35%, #fff3b8, #f2c14e 55%, #b07b1c); box-shadow: 0 0 0 1.5px #5a3c0a; }
.coins.big { font-size: 20px; }
.speed {
  min-width: 52px; height: 46px; border: 0; border-radius: 14px; padding: 2px 8px 0; cursor: pointer;
  background: rgba(255, 255, 255, 0.12); font-weight: 800; font-size: 18px; box-shadow: 0 2px 0 rgba(0, 0, 0, 0.3);
}
.speed.on { background: var(--gold); color: var(--gold-ink); }
.speed.x4 { background: #ff9a4a; color: #3a1a06; }
.speed:active { transform: scale(0.94); }

/* ---- the field ---- */
.stage { position: relative; flex: 1; min-height: 0; }
#field { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
.fort-hp {
  position: absolute; left: 50%; bottom: 8px; transform: translateX(-50%); width: min(240px, 64%);
  display: grid; justify-items: center; gap: 2px; pointer-events: none;
}
.hp-bar { position: relative; width: 100%; height: 10px; border-radius: 99px; background: rgba(0, 0, 0, 0.5); overflow: hidden; box-shadow: 0 0 0 1.5px rgba(0, 0, 0, 0.5); }
.hp-bar i { position: absolute; left: 0; top: 0; bottom: 0; width: 100%; transform-origin: left; transform: scaleX(1); }
.hp-fill { background: linear-gradient(90deg, #e9566a, #ff8f6b); }
.wall-fill { background: rgba(159, 208, 255, 0.85); height: 4px; top: auto !important; }
.fort-hp span { font-size: 14px; font-weight: 800; text-shadow: 0 1px 0 rgba(0, 0, 0, 0.6); font-variant-numeric: tabular-nums; }
.banner {
  position: absolute; left: 50%; top: 14px; transform: translate(-50%, -6px); margin: 0; padding: 6px 16px 4px;
  border-radius: 999px; background: rgba(12, 18, 14, 0.8); font-weight: 800; font-size: 18px; white-space: nowrap;
  opacity: 0; pointer-events: none; transition: opacity 0.25s, transform 0.25s;
}
.banner.on { opacity: 1; transform: translate(-50%, 0); }
.banner.boss { background: rgba(120, 20, 40, 0.88); }
.banner.gold { background: var(--gold); color: var(--gold-ink); }

/* ---- the shop (in a run) and the Workshop share their pieces ---- */
.shop {
  display: flex; flex-direction: column; background: var(--panel); border-radius: 18px 18px 0 0;
  box-shadow: 0 -6px 18px -8px rgba(0, 0, 0, 0.6);
  /* Bri: a bigger panel, and the list kept well off the bottom edge so a swipe through it never starts on the
     phone's home bar (an upward swipe from there leaves the app) */
  padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 14px);
  height: clamp(260px, 47vh, 440px);
}
.tabs { display: grid; grid-template-columns: repeat(4, 1fr); gap: 5px; padding: 8px 8px 4px; }
.tab {
  position: relative; min-height: 50px; border: 0; border-radius: 14px; padding: 3px 2px 1px; cursor: pointer; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 0; background: rgba(255, 255, 255, 0.06); font-weight: 800; font-size: 13.5px; line-height: 1.05;
  box-shadow: inset 0 -3px 0 transparent; min-width: 0;
}
.tab img { width: 36px; height: 31px; flex: none; object-fit: cover; object-position: 50% 30%; margin: -2px 0 -1px; }
.tab span { display: block; text-align: center; white-space: nowrap; }
.tab small { display: none; }
.tab.locked img { filter: grayscale(1) brightness(0.8); opacity: 0.7; }
.tab .badge { position: absolute; top: 3px; right: 6px; width: 10px; height: 10px; border-radius: 50%; background: var(--danger); box-shadow: 0 0 0 2px var(--panel); }
.tab.on { background: var(--panel-hi); box-shadow: inset 0 -3px 0 var(--tc, var(--gold)); }
.tab .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--danger); margin-left: -2px; align-self: flex-start; margin-top: 6px; }
.shop-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 2px 10px 4px; min-height: 50px; font-size: 13px; font-weight: 700; color: var(--ink-soft); }
.mult { display: flex; gap: 4px; }
.mult button {
  min-width: 48px; min-height: 44px; border: 0; border-radius: 10px; padding: 2px 8px 0; cursor: pointer;
  background: rgba(255, 255, 255, 0.08); font-weight: 800; font-size: 14px; color: var(--ink-soft);
}
.mult button.on { background: var(--ink); color: var(--panel); }
.rows { flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; padding: 0 8px 10px; display: grid; align-content: start; grid-auto-rows: max-content; gap: 5px; }
.row {
  display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 8px; min-height: 52px; padding: 4px 4px 4px 12px;
  border-radius: 14px; background: var(--row); box-shadow: inset 3px 0 0 var(--tc, transparent);
}
.row .name { font-weight: 800; font-size: 16px; line-height: 1.1; }
.row .name em { font-style: normal; font-size: 11px; font-weight: 800; padding: 1px 6px 0; margin-left: 6px; border-radius: 99px; background: var(--gold); color: var(--gold-ink); vertical-align: 2px; }
.row .val { font-size: 13.5px; font-weight: 700; color: var(--ink-soft); line-height: 1.15; font-variant-numeric: tabular-nums; }
.row .val b { color: var(--ink); }
.row .desc { font-size: 12.5px; font-weight: 600; color: var(--ink-soft); opacity: 0.85; line-height: 1.2; margin: 2px 0 2px; }
.row .info { cursor: help; }
.buy {
  min-width: 96px; min-height: 44px; border: 0; border-radius: 12px; padding: 3px 10px 0; cursor: pointer;
  background: var(--cash); color: #17300d; font-weight: 800; font-size: 16px; box-shadow: 0 3px 0 #4f8f36;
  font-variant-numeric: tabular-nums; line-height: 1.05;
}
.buy small { display: block; font-size: 11px; font-weight: 800; opacity: 0.75; }
.buy.coin { background: var(--coin); color: #3d2a05; box-shadow: 0 3px 0 #b8891c; }
.buy:disabled, .buy.off { background: rgba(255, 255, 255, 0.1); color: rgba(255, 247, 234, 0.45); box-shadow: none; }
.buy:active:not(:disabled):not(.off) { transform: translateY(2px); box-shadow: none; }
.buy.max { background: transparent; color: var(--gold); box-shadow: inset 0 0 0 2px var(--gold); }
.row.flash { animation: flash 0.35s ease-out; }

/* a locked node at the foot of a Workshop tab */
.node {
  margin-top: 6px; padding: 12px 12px 10px; border-radius: 16px; background: rgba(0, 0, 0, 0.22);
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.08); display: grid; gap: 6px;
}
.node h3 { margin: 0; font-size: 18px; line-height: 1.1; display: flex; justify-content: space-between; gap: 8px; }
.node h3 small { font-size: 13px; color: var(--ink-soft); white-space: nowrap; }
.node p { margin: 0; font-size: 14px; font-weight: 600; color: var(--ink-soft); line-height: 1.25; }
.node .gate { color: #ffb0a0; font-weight: 800; }
.node .pace { font-size: 13px; }
.node .buy { justify-self: start; min-width: 140px; }
.node .pb { --pb-fill: var(--gold); --pb-track: rgba(255, 255, 255, 0.1); --pb-ink: var(--ink-soft); }
.node.done { box-shadow: inset 0 0 0 2px var(--gold); }
.node-done { margin: 8px 4px 0; font-size: 14px; font-weight: 700; color: var(--ink-soft); text-align: center; }

/* ---- Tyler's super weapons: cards in his tab and the pick ---- */
.sw-card {
  display: grid; grid-template-columns: 52px 1fr; gap: 4px 10px; align-items: center; padding: 10px 12px 8px; border-radius: 16px;
  background: rgba(0, 0, 0, 0.22); box-shadow: inset 0 0 0 2px rgba(201, 162, 107, 0.35);
}
.sw-card img { width: 52px; height: 52px; grid-row: span 2; }
.sw-card h3 { margin: 0; font-size: 17px; line-height: 1.1; }
.sw-card h3 small { display: block; font-size: 12.5px; font-weight: 700; color: var(--ink-soft); }
.sw-card p { margin: 0; font-size: 13.5px; font-weight: 600; color: var(--ink-soft); line-height: 1.25; }
.sw-card .pb, .sw-card .sw-wide { grid-column: 1 / -1; }
.sw-card .pb { --pb-fill: var(--tyler); --pb-track: rgba(255, 255, 255, 0.1); --pb-ink: var(--ink-soft); }
.sw-card.locked img { filter: grayscale(1) brightness(0.75); opacity: 0.6; }
.sw-card.on { box-shadow: inset 0 0 0 2px var(--tyler); }
.sw-note { margin: 4px 4px 2px; font-size: 13.5px; font-weight: 700; color: var(--ink-soft); line-height: 1.3; }
.sw-note b { color: var(--ink); }
.kp-pick { display: grid; gap: 10px; }
.kp-pick p { margin: 0; }
.kp-pick-card {
  width: 100%; border: 0; border-radius: 18px; padding: 10px 12px 8px; cursor: pointer; text-align: left; display: grid;
  grid-template-columns: 56px 1fr; gap: 2px 12px; align-items: center; background: #f6ead2; color: var(--sheet-ink);
  box-shadow: 0 3px 0 #c9a26b; min-height: 72px;
}
.kp-pick-card img { width: 56px; height: 56px; grid-row: span 2; }
.kp-pick-card b { font-size: 18px; line-height: 1.1; }
.kp-pick-card span { font-size: 13.5px; font-weight: 600; color: var(--sheet-soft); line-height: 1.25; }
.kp-pick-card:active { transform: translateY(2px); box-shadow: none; }
/* ---- the hut's looks ---- */
.kp-looks { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-bottom: 14px; }
.kp-look {
  border: 0; border-radius: 16px; padding: 6px 6px 8px; cursor: pointer; display: grid; gap: 4px; justify-items: center; text-align: center;
  background: rgba(44, 42, 34, 0.07); color: var(--sheet-ink); font-weight: 800; font-size: 14.5px; line-height: 1.15; min-height: 44px;
}
.kp-look img { width: 100%; max-width: 140px; aspect-ratio: 1; border-radius: 12px; }
.kp-look.on { box-shadow: inset 0 0 0 3px #3f8f55; background: #e7f5e6; }
.kp-look.locked img { filter: grayscale(0.85) brightness(0.8); opacity: 0.55; }
.kp-look small { font-size: 12px; font-weight: 700; color: var(--sheet-soft); }
.kp-look .pb { width: 100%; }

/* ---- the Workshop screen ---- */
.ws {
  position: fixed; inset: 0; z-index: 15; display: flex; flex-direction: column; background: var(--bg);
  padding: calc(var(--sg-corner-top) - 4px) 0 env(safe-area-inset-bottom, 0px);
}
.ws-top { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 8px; padding: 0 12px 0 var(--sg-corner-left); min-height: 52px; }
.ws-top h2 { margin: 0; font-size: 24px; text-align: center; }
.ws-note { margin: 2px 14px 2px; font-size: 13.5px; font-weight: 700; color: var(--ink-soft); text-align: center; line-height: 1.25; }
.ws .tabs { padding-top: 6px; }
.ws-rows { padding-bottom: 20px; }

/* ---- the hut fell ---- */
.over { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; padding: 16px; background: rgba(8, 14, 10, 0.62); }
.over-card {
  width: min(350px, 100%); padding: 18px 18px 16px; border-radius: 24px; text-align: center;
  background: var(--sheet); color: var(--sheet-ink); box-shadow: 0 16px 40px -12px rgba(0, 0, 0, 0.7); animation: rise 0.32s ease-out;
  max-height: calc(100vh - 32px); overflow-y: auto;
}
.over-kicker { margin: 0; font-weight: 800; font-size: 18px; color: var(--sheet-soft); }
.over-wave { margin: 0; font-weight: 800; font-size: 44px; line-height: 1.05; }
.over-cause { margin: 2px 0 0; font-weight: 700; font-size: 15px; color: var(--sheet-soft); }
.over-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-top: 10px; }
.over-stats div { padding: 6px 8px 4px; border-radius: 12px; background: rgba(44, 42, 34, 0.07); font-weight: 800; font-size: 18px; line-height: 1.1; }
.over-stats small { display: block; font-size: 12px; font-weight: 700; color: var(--sheet-soft); }
.over-new { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 6px; }
.over-new li { padding: 7px 12px 5px; border-radius: 12px; background: #fff0c4; font-weight: 700; font-size: 15px; line-height: 1.25; }
.over-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 14px; }
.pill {
  min-height: 50px; border: 0; border-radius: 999px; padding: 4px 14px 2px; cursor: pointer;
  background: rgba(44, 42, 34, 0.1); color: var(--sheet-ink); font-weight: 800; font-size: 17px;
}
.pill.gold { background: var(--gold); color: var(--gold-ink); box-shadow: 0 3px 0 #b8891c; }
.pill.primary { background: #3f8f55; color: #fff; box-shadow: 0 3px 0 #23603a; }
.pill.wide { width: 100%; margin-top: 10px; }
.kp-end { background: #b8434f; color: #fff; box-shadow: 0 3px 0 #7d2732; }
.pill:active { transform: scale(0.97); }

.toast {
  position: fixed; left: 50%; top: calc(env(safe-area-inset-top, 0px) + 66px); z-index: 30; transform: translate(-50%, -8px);
  margin: 0; padding: 8px 16px 6px; border-radius: 14px; max-width: calc(100vw - 32px); width: max-content;
  background: var(--sheet); color: var(--sheet-ink); font-weight: 800; font-size: 16px; text-align: center;
  box-shadow: 0 6px 18px -6px rgba(0, 0, 0, 0.6); opacity: 0; pointer-events: none; transition: opacity 0.2s, transform 0.2s;
}
.toast.on { opacity: 1; transform: translate(-50%, 0); }

/* ---- sheets: tiers, the squad, welcome back ---- */
.kp-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.kp-tier {
  width: 100%; min-height: 56px; border: 0; border-radius: 16px; padding: 8px 14px 6px; cursor: pointer; text-align: left;
  display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 8px; background: rgba(44, 42, 34, 0.07);
  color: var(--sheet-ink); font-weight: 800; font-size: 17px;
}
.kp-tier small { display: block; font-size: 13px; font-weight: 700; color: var(--sheet-soft); }
.kp-tier.on { box-shadow: inset 0 0 0 3px #3f8f55; background: #e7f5e6; }
.kp-tier:disabled { opacity: 0.55; }
.kp-squad { display: grid; gap: 10px; margin-bottom: 14px; }
.kp-cat { display: grid; grid-template-columns: 64px 1fr; gap: 10px; align-items: center; padding: 8px 10px; border-radius: 16px; background: rgba(44, 42, 34, 0.06); }
.kp-cat img { width: 64px; height: 74px; object-fit: contain; }
.kp-cat b { font-size: 17px; display: block; line-height: 1.1; }
.kp-cat p { margin: 2px 0 0; font-size: 14px; font-weight: 600; color: var(--sheet-soft); line-height: 1.25; }
.kp-h { margin: 6px 0 8px; font-size: 17px; }
.kp-rec { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-bottom: 14px; }
.kp-rec div { padding: 6px 4px 4px; border-radius: 12px; background: rgba(44, 42, 34, 0.06); text-align: center; font-weight: 800; font-size: 16px; line-height: 1.1; }
.kp-rec small { display: block; font-size: 11.5px; color: var(--sheet-soft); font-weight: 700; }
.kp-ach { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.kp-ach li { display: flex; gap: 10px; align-items: center; padding: 8px 12px 6px; border-radius: 14px; background: rgba(44, 42, 34, 0.06); font-weight: 700; font-size: 15px; line-height: 1.25; }
.kp-ach li b { display: block; font-size: 16px; }
.kp-ach li.no { opacity: 0.55; }
.kp-ach .medal { flex: none; width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: var(--gold); color: var(--gold-ink); font-weight: 800; }
.kp-ach li.no .medal { background: rgba(44, 42, 34, 0.14); color: transparent; }
.kp-howto p { margin: 0 0 10px; }
.kp-howto .jays { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 10px; }
.kp-howto .jays span { display: grid; justify-items: center; width: 72px; font-size: 12px; font-weight: 800; line-height: 1.1; text-align: center; }
.kp-howto .jays img { width: 56px; height: 56px; }
.kp-kinds { margin: 0 0 10px; padding-left: 18px; font-size: 14px; line-height: 1.35; }
.kp-kinds li { margin-bottom: 3px; }
.kp-away { text-align: center; }
.kp-away .coins { font-size: 34px; color: #9a6a06; display: block; margin: 6px 0; }
.kp-away p { margin: 0 0 4px; line-height: 1.3; }
.kp-away .kp-away-time { font-weight: 800; margin-bottom: 8px; }

/* ---- the title screen's colors (the layout is shared/mainmenu.js) ---- */
#mm {
  --sg-bg: radial-gradient(ellipse 100% 70% at 50% 28%, var(--bg-hi), transparent 75%), var(--bg);
  --sg-ink: var(--ink); --sg-ink-soft: var(--ink-soft);
  --sg-title: #ffd86b; --sg-title-shadow: 0 3px 0 rgba(0, 0, 0, 0.45);
  --sg-accent: var(--gold); --sg-accent-ink: var(--gold-ink);
  --sg-card: #fff8ec; --sg-card-ink: var(--sheet-ink); --sg-line: rgba(255, 247, 234, 0.2);
}
#mm .kp-title-art { display: block; width: 300px; height: 150px; border-radius: 22px; }
#mm.sg-scened .kp-title-art { border-radius: 0; }
.sg-sheet { --sg-sheet-bg: var(--sheet); --sg-sheet-ink: var(--sheet-ink); --sg-accent: #3f8f55; --sg-accent-ink: #fff; --sg-ink-soft: var(--sheet-soft); }

@keyframes rise { from { transform: translateY(16px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes flash { 0% { background: var(--row-hi); } 100% { background: var(--row); } }
@media (max-height: 700px) {
  .hud { min-height: 50px; }
  .wave-top b { font-size: 19px; }
  .shop { height: clamp(240px, 45vh, 320px); }
  .row { min-height: 48px; }
  .tab { min-height: 44px; }
  .tab img { width: 32px; height: 26px; }
}
@media (max-width: 370px) {
  .tab { font-size: 12.5px; }
  .buy { min-width: 86px; }
}
@media (prefers-reduced-motion: reduce) {
  .over-card, .row.flash { animation: none; }
  .toast, .banner { transition: none; }
}
