/* Herding Cats: the track is one three.js canvas filling the screen; on top, the bar, the count over the clowder, the
   number pops, a tip line and the end card. The title screen and the sheets are shared/mainmenu.js (menu.css, loaded
   after this); only their colors are set here (--sg-*). */
:root {
  --bg: #2b6a8f; --bg-hi: #4fa3c9; --ink: #ffffff; --ink-soft: #dcefff; --line: rgba(255, 255, 255, 0.22);
  --accent: #ffbf2f; --accent-ink: #3a2300; --sheet: #fffaf0; --sheet-ink: #2f2a3a; --sheet-soft: #6e6880;
  --blue: #3c8dff; --red: #ff4f5e;
  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: #bfe6f5; overflow: hidden; overscroll-behavior: none; }
button { font: inherit; color: inherit; }
.app { position: fixed; inset: 0; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
#view { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }

/* ---- the bar ---- */
.bar {
  position: absolute; left: 0; right: 0; top: 0; z-index: 4; display: grid; grid-template-columns: 76px 1fr 76px; align-items: center; gap: 6px;
  min-height: calc(var(--sg-corner-top) + 50px); padding: calc(var(--sg-corner-top) - 6px) 8px 0; pointer-events: none; /* a 56px row under the padding: the corner's button sits in its middle */
}
.bar > * { pointer-events: auto; }
.bar > .sg-corner-slot { margin-left: calc(var(--sg-corner-left) - 8px); }
.where { text-align: center; line-height: 1.05; pointer-events: none; }
.where b { display: block; font-weight: 800; font-size: 20px; text-shadow: 0 2px 0 rgba(0, 0, 0, 0.35); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.trip { height: 8px; margin: 5px auto 0; max-width: 190px; border-radius: 999px; background: rgba(0, 0, 0, 0.25); overflow: hidden; box-shadow: inset 0 0 0 1.5px rgba(255, 255, 255, 0.35); }
.trip i { display: block; height: 100%; width: 100%; transform-origin: left; transform: scaleX(0); background: var(--accent); border-radius: inherit; }
.jays {
  justify-self: end; display: flex; align-items: center; gap: 4px; min-width: 64px; padding: 4px 10px 2px 6px; border-radius: 999px;
  background: rgba(0, 0, 0, 0.3); font-weight: 800; font-size: 16px; box-shadow: inset 0 0 0 1.5px var(--line); pointer-events: none; white-space: nowrap;
}
.jays svg { flex: none; width: 18px; height: 18px; margin-top: -2px; }
.jays span { flex: 1; text-align: right; }

/* ---- the clowder's stats, along the bottom ---- */
.stats {
  position: absolute; left: 50%; bottom: calc(env(safe-area-inset-bottom, 0px) + 10px); z-index: 4; transform: translateX(-50%);
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; width: min(360px, calc(100vw - 32px)); pointer-events: none;
}
.stats span { display: grid; justify-items: center; padding: 3px 2px 1px; border-radius: 12px; background: rgba(20, 30, 50, 0.55); line-height: 1.05; }
.stats small { font-size: 11px; font-weight: 800; letter-spacing: 0.04em; color: var(--ink-soft); }
.stats b { font-size: 17px; font-weight: 800; }
.stats.up span { animation: statup 0.7s ease-out; }
.banner {
  position: absolute; left: 50%; top: calc(var(--sg-corner-top) + 70px); z-index: 4; transform: translateX(-50%); display: grid; justify-items: center;
  padding: 8px 20px 6px; border-radius: 18px; background: rgba(20, 30, 50, 0.72); text-align: center; pointer-events: none; white-space: nowrap;
}
.banner b { font-size: 30px; font-weight: 800; line-height: 1.05; color: #ffe27a; text-shadow: 0 2px 0 rgba(0, 0, 0, 0.35); }
.banner small { font-size: 16px; font-weight: 800; }
.banner.go { animation: banner 2.6s ease-out forwards; }
.meet {
  position: absolute; left: 0; right: 0; margin: 0 auto; top: calc(var(--sg-corner-top) + 150px); z-index: 5; display: flex; gap: 10px; align-items: center;
  width: min(360px, calc(100vw - 32px)); min-height: 72px; padding: 8px 12px 6px 8px; border: 0; border-radius: 18px; text-align: left; cursor: pointer;
  background: rgba(20, 30, 50, 0.86); color: #fff; box-shadow: 0 8px 22px -8px rgba(0, 0, 0, 0.6); -webkit-tap-highlight-color: transparent;
}
.meet.go { animation: rise 0.3s ease-out; }
.meet-img { flex: none; width: 56px; height: 56px; display: grid; place-items: center; border-radius: 12px; background: rgba(255, 255, 255, 0.1); }
.meet-img svg { display: block; width: 52px; height: 52px; }
.meet-words { display: grid; gap: 1px; line-height: 1.2; }
.meet-words small { font-size: 11px; font-weight: 800; letter-spacing: 0.14em; text-transform: uppercase; color: #ffd9a6; }
.meet-words b { font-size: 18px; font-weight: 800; }
.meet-words span { font-size: 14px; font-weight: 700; color: var(--ink-soft); }

/* ---- the count over the clowder ---- */
.bubble {
  position: absolute; left: 0; top: 0; z-index: 3; transform: translate(-50%, -100%); padding: 2px 12px 0; min-width: 44px; border-radius: 14px;
  background: var(--blue); color: #fff; font-weight: 800; font-size: 24px; text-align: center; line-height: 1.15; white-space: nowrap;
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.3); pointer-events: none; will-change: transform;
}
.bubble::after { content: ""; position: absolute; left: 50%; bottom: -7px; margin-left: -7px; border: 7px solid transparent; border-bottom: 0; border-top-color: var(--blue); }
.bubble.ghost { background: rgba(233, 244, 255, 0.85); color: #2b4f7a; font-size: 18px; }
.bubble.ghost::after { border-top-color: rgba(233, 244, 255, 0.85); }
.bubble.ghost small { display: block; font-size: 12px; line-height: 1; padding-bottom: 3px; font-weight: 700; }
.bubble.bump { animation: bump 0.25s ease-out; }
.pops { position: absolute; inset: 0; z-index: 3; pointer-events: none; overflow: hidden; }
.pop {
  position: absolute; left: 0; top: 0; transform: translate(-50%, -50%); font-weight: 800; font-size: 26px; color: #fff; white-space: nowrap;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.45); animation: float 0.9s ease-out forwards;
}
.pop.bad { color: #ffd0d4; }
.pop.gold { color: #ffe27a; }
.cheer {
  position: absolute; left: 50%; top: 34%; z-index: 4; margin: 0; transform: translate(-50%, -50%); pointer-events: none; white-space: nowrap;
  font-weight: 800; font-size: 46px; color: #ffe27a; text-shadow: 0 3px 0 #7a4a00, 0 6px 18px rgba(0, 0, 0, 0.35);
}
.flash { position: absolute; inset: 0; z-index: 3; pointer-events: none; opacity: 0; background: radial-gradient(circle at 50% 34%, rgba(255, 248, 210, 0.8), rgba(255, 248, 210, 0) 65%); }
.cheer.go { animation: cheer 1.5s ease-out forwards; }
.flash.go { animation: flash 0.6s ease-out; }
@keyframes cheer { 0% { opacity: 0; transform: translate(-50%, -50%) scale(0.4); } 14% { opacity: 1; transform: translate(-50%, -50%) scale(1.12); } 24% { transform: translate(-50%, -50%) scale(1); } 80% { opacity: 1; } 100% { opacity: 0; transform: translate(-50%, -62%) scale(1); } }
@keyframes flash { 0% { opacity: 1; } 100% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .cheer.go { animation: fade 1.5s linear forwards; } .flash.go { animation: none; } }
.tip, .hint {
  position: absolute; left: 50%; z-index: 4; transform: translateX(-50%); margin: 0; padding: 8px 16px 6px; border-radius: 16px;
  max-width: calc(100vw - 32px); width: max-content; background: rgba(20, 30, 50, 0.78); font-weight: 800; font-size: 17px; text-align: center;
  line-height: 1.25; pointer-events: none;
}
.tip { bottom: calc(env(safe-area-inset-bottom, 0px) + 72px); }
.hint { bottom: calc(env(safe-area-inset-bottom, 0px) + 84px); animation: breathe 1.6s ease-in-out infinite; }

/* ---- the end card ---- */
.over { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; padding: 16px; background: rgba(10, 24, 40, 0.55); }
.over-card {
  width: min(350px, 100%); max-height: calc(100vh - 32px); overflow: auto; padding: 18px 18px 14px; 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;
}
.over-kicker { margin: 0; font-weight: 800; font-size: 30px; line-height: 1.1; }
.over-big { margin: 4px 0 0; font-size: 26px; font-weight: 800; line-height: 1.15; color: #2b3a67; }
.over-lines { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 2px; font-weight: 700; font-size: 16px; }
.over-lines b { font-weight: 800; }
.over-coins { margin: 8px 0 0; font-weight: 800; font-size: 26px; color: #a26b00; }
.over-new { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 6px; }
.over-new li { padding: 7px 12px 5px; border-radius: 12px; background: #fff0c9; font-weight: 700; font-size: 15px; line-height: 1.25; }
.over-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 14px; }
.over-btns .primary, .over-btns .wide { grid-column: 1 / -1; }
.pill {
  min-height: 50px; border: 0; border-radius: 999px; padding: 4px 14px 2px; cursor: pointer; background: rgba(47, 42, 58, 0.1);
  color: var(--sheet-ink); font-weight: 800; font-size: 17px; -webkit-tap-highlight-color: transparent;
}
.pill.primary { background: var(--accent); color: var(--accent-ink); box-shadow: 0 3px 0 #b98a1a; }
.pill:active { transform: scale(0.97); }
.pill:disabled { opacity: 0.45; }
.toast {
  position: fixed; left: 50%; top: calc(env(safe-area-inset-top, 0px) + 70px); 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: #fffaf0; 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 ---- */
.hc h3 { margin: 12px 0 6px; font-size: 17px; }
.hc h3:first-child { margin-top: 0; }
.hc p { margin: 0 0 8px; font-weight: 600; line-height: 1.35; }
.hc .soft { color: var(--sheet-soft); font-weight: 700; font-size: 14px; }
.hc-levels { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; margin-bottom: 8px; }
.hc-lv {
  min-height: 52px; border: 0; border-radius: 12px; padding: 4px 0 2px; cursor: pointer; display: grid; place-items: center; gap: 0;
  background: #e6f2ff; color: #1d4f86; font-weight: 800; font-size: 17px; line-height: 1; -webkit-tap-highlight-color: transparent;
}
.hc-lv small { font-size: 11px; color: #4d6a8f; min-height: 12px; font-weight: 800; }
.hc-lv.done { background: #dff3e4; color: #23643a; }
.hc-lv.done small { color: #2f8a55; }
.hc-lv.boss { background: #ffe3e6; color: #9a2236; }
.hc-lv.now { box-shadow: inset 0 0 0 3px var(--accent); }
.hc-lv:disabled { background: rgba(47, 42, 58, 0.07); color: rgba(47, 42, 58, 0.35); }
.hc-row { display: flex; gap: 10px; align-items: center; padding: 10px 12px 8px; border-radius: 16px; background: rgba(47, 42, 58, 0.06); margin-bottom: 8px; }
.hc-row .face { flex: none; width: 58px; height: 58px; }
.hc-row .face svg { display: block; width: 100%; height: 100%; overflow: visible; }
.hc-row .words { flex: 1; min-width: 0; line-height: 1.25; }
.hc-row .words b { display: block; font-size: 17px; }
.hc-row .words span { display: block; font-weight: 600; font-size: 14px; }
.hc-row .words small { display: block; font-weight: 700; font-size: 13px; color: var(--sheet-soft); }
.hc-row button {
  flex: none; min-width: 84px; min-height: 46px; border: 0; border-radius: 999px; padding: 4px 12px 2px; cursor: pointer;
  background: #3a5f9a; color: #fff; font-weight: 800; font-size: 15px; line-height: 1.1; -webkit-tap-highlight-color: transparent;
}
.hc-row button:disabled { background: rgba(47, 42, 58, 0.14); color: rgba(47, 42, 58, 0.55); }
.hc-row button.on { background: #2f8a55; }
.hc-row.locked { opacity: 0.6; }
.hc-coins { text-align: center; font-weight: 800; font-size: 22px; color: #a26b00; margin: 0 0 10px; }
.hc-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 8px; }
.hc-pick {
  min-height: 78px; border: 0; border-radius: 14px; padding: 6px 2px 4px; cursor: pointer; display: grid; justify-items: center; gap: 2px;
  background: rgba(47, 42, 58, 0.07); color: var(--sheet-ink); font-weight: 800; font-size: 12px; line-height: 1.1; -webkit-tap-highlight-color: transparent;
}
.hc-pick.on { box-shadow: inset 0 0 0 3px #3a5f9a; background: #e6f0ff; }
.hc-pick:disabled { opacity: 0.5; }
.hc-pick small { font-weight: 700; font-size: 11px; color: var(--sheet-soft); }
.hc-pick .ball { width: 34px; height: 34px; border-radius: 50%; margin: 2px 0; box-shadow: inset -5px -6px 0 rgba(0, 0, 0, 0.18); }
.hc-pick .face { width: 46px; height: 46px; }
.hc-pick .face svg { display: block; width: 100%; height: 100%; overflow: visible; }
.hc-shelter { display: flex; flex-wrap: wrap; gap: 2px; justify-content: center; padding: 10px; border-radius: 16px; background: #fff0c9; margin-bottom: 8px; min-height: 60px; }
.hc-shelter img { width: 34px; height: 34px; }
.hc-list { list-style: none; margin: 0 0 8px; padding: 0; display: grid; gap: 6px; }
.hc-list li { display: flex; gap: 10px; align-items: center; padding: 8px 12px 6px; border-radius: 14px; background: rgba(47, 42, 58, 0.06); font-weight: 700; font-size: 15px; line-height: 1.25; }
.hc-list li b { display: block; font-size: 16px; }
.hc-list li.no { opacity: 0.55; }
.hc-list .medal { flex: none; width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: #f4c44e; color: #6b4a0c; font-weight: 800; }
.hc-list li.no .medal { background: rgba(47, 42, 58, 0.14); color: transparent; }
.hc-big { text-align: center; }
.hc-big .num { display: block; font-weight: 800; font-size: 40px; line-height: 1.1; }
.hc-play { display: block; width: 100%; margin-top: 12px; }
.hc .pb { margin: 4px 0 12px; }

/* ---- the title screen's colors (the layout is shared/mainmenu.js) ---- */
#mm {
  --sg-bg: radial-gradient(ellipse 100% 70% at 50% 25%, var(--bg-hi), transparent 75%), var(--bg);
  --sg-ink: var(--ink); --sg-ink-soft: var(--ink-soft);
  --sg-title: #ffe27a; --sg-title-shadow: 0 3px 0 rgba(0, 0, 0, 0.35);
  --sg-accent: var(--accent); --sg-accent-ink: var(--accent-ink);
  --sg-card: #fffaf0; --sg-card-ink: var(--sheet-ink); --sg-line: rgba(255, 255, 255, 0.24);
}
/* no taller than the art box (menu.css .sg-bigart .sg-art), so it never spills over the line under it */
#mm .hc-title-art { width: min(300px, 82vw, clamp(170px, 27dvh, 250px) * 1.48); aspect-ratio: 720 / 485; }
@media (max-height: 700px) { #mm .hc-title-art { width: min(300px, 82vw, clamp(140px, 24dvh, 200px) * 1.48); } }
#mm .hc-title-art img { display: block; width: 100%; height: 100%; border-radius: 18px; box-shadow: 0 6px 18px rgba(40, 24, 8, 0.35); -webkit-mask-image: radial-gradient(ellipse 72% 70% at 50% 50%, #000 62%, transparent 100%); mask-image: radial-gradient(ellipse 72% 70% at 50% 50%, #000 62%, transparent 100%); }
.sg-sheet { --sg-sheet-bg: var(--sheet); --sg-sheet-ink: var(--sheet-ink); --sg-accent: #3a5f9a; --sg-accent-ink: #fff; --sg-ink-soft: var(--sheet-soft); }

@keyframes bump { 0% { transform: translate(-50%, -100%) scale(1); } 40% { transform: translate(-50%, -100%) scale(1.2); } 100% { transform: translate(-50%, -100%) scale(1); } }
@keyframes float { 0% { opacity: 0; margin-top: 0; } 15% { opacity: 1; } 100% { opacity: 0; margin-top: -60px; } }
@keyframes fade { 0%, 80% { opacity: 1; } 100% { opacity: 0; } }
@keyframes rise { from { transform: translateY(16px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes breathe { 0%, 100% { opacity: 1; } 50% { opacity: 0.65; } }
@keyframes statup { 0% { background: rgba(255, 191, 47, 0.95); color: #3a2300; } 100% { background: rgba(20, 30, 50, 0.55); } }
@keyframes banner { 0% { opacity: 0; transform: translate(-50%, -10px) scale(0.94); } 12% { opacity: 1; transform: translate(-50%, 0) scale(1); } 80% { opacity: 1; } 100% { opacity: 0; } }
@media (max-width: 370px) { .where b { font-size: 18px; } .hc-levels { grid-template-columns: repeat(4, 1fr); } }
@media (prefers-reduced-motion: reduce) {
  .over-card, .hint, .bubble.bump, .meet.go, .stats.up span { animation: none; }
  .banner.go { animation-duration: 2.6s; animation-name: fade; }
  .pop { animation-duration: 0.6s; }
  .toast { transition: none; }
}
