/* Fling Cats: the yard fills the screen on one canvas; the bar floats over the sky. The title screen and the sheets are
   shared/mainmenu.js (menu.css, loaded after this); only their colors are set here (--sg-*). */
:root {
  --bg: #2b4a7a; --bg-hi: #4f86c6; --ink: #ffffff; --ink-soft: #dcecff; --line: rgba(255, 255, 255, 0.22);
  --accent: #ffcf4a; --accent-ink: #3a2412; --sheet: #fffaf0; --sheet-ink: #2f2a3d; --sheet-soft: #6f6880;
  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; }
.app { position: fixed; inset: 0; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
#field {
  position: absolute; inset: 0; width: 100%; height: 100%; display: block;
  touch-action: none; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
}

/* ---- the bar, over the sky ---- */
.bar {
  position: absolute; left: 0; right: 0; top: 0; z-index: 5; display: grid; grid-template-columns: auto 1fr auto; align-items: start; gap: 10px;
  padding: var(--sg-corner-top) calc(env(safe-area-inset-right, 0px) + 12px) 0 var(--sg-corner-left); min-height: 56px; pointer-events: none;
}
.bar > * { pointer-events: auto; }
.lvl { line-height: 1; text-shadow: 0 0 3px rgba(20, 30, 60, 0.7), 0 2px 0 rgba(20, 30, 60, 0.55); min-width: 0; padding-top: 4px; }
.lvl b { display: block; font-weight: 800; font-size: 22px; }
.lvl small { display: block; font-weight: 700; font-size: 14px; color: var(--ink-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.queue { display: flex; gap: 2px; margin-top: 5px; min-height: 30px; }
.queue img { width: 28px; height: 32px; filter: drop-shadow(0 2px 0 rgba(20, 30, 60, 0.35)); }
.queue img.go { animation: pop 0.25s ease-out reverse; opacity: 0.25; }
.score { text-align: right; line-height: 1; padding-top: 4px; }
.score b { display: block; font-weight: 800; font-size: 28px; text-shadow: 0 0 3px rgba(20, 30, 60, 0.7), 0 2px 0 rgba(20, 30, 60, 0.55); font-variant-numeric: tabular-nums; }
.score b.pop { animation: pop 0.18s ease-out; }
.meter { position: relative; display: block; width: 112px; height: 9px; margin: 4px 0 0 auto; border-radius: 99px; background: rgba(20, 30, 60, 0.35); box-shadow: inset 0 0 0 1.5px rgba(255, 255, 255, 0.5); overflow: visible; }
.meter i { position: absolute; left: 0; top: 0; bottom: 0; width: 0; border-radius: 99px; background: linear-gradient(90deg, #ffe58a, #ffb830); transition: width 0.25s; }
.meter em { position: absolute; top: -4px; width: 13px; height: 13px; margin-left: -6.5px; transform: rotate(45deg); background: rgba(255, 255, 255, 0.35); border: 1.5px solid rgba(255, 255, 255, 0.85); border-radius: 2px; }
.meter em.on { background: #ffcf4a; border-color: #fff4c4; }
.hint {
  position: absolute; left: 50%; top: 22%; transform: translate(-50%, -50%); margin: 0; padding: 8px 16px 6px; z-index: 4;
  border-radius: 999px; background: rgba(20, 30, 60, 0.72); font-weight: 800; font-size: 18px; white-space: nowrap;
  pointer-events: none; animation: breathe 1.6s ease-in-out infinite;
}

/* ---- the level-clear stamp: a kraft label slapped onto the sky ---- */
.banner {
  position: absolute; left: 50%; top: 30%; z-index: 6; margin: 0; padding: 10px 26px 6px; pointer-events: none;
  transform: translate(-50%, -50%) rotate(-4deg) scale(0.4); opacity: 0;
  border-radius: 8px; color: #3a2412; font-weight: 800; font-size: 34px; line-height: 1.1; white-space: nowrap;
  background: linear-gradient(rgba(255, 216, 102, 0.9), rgba(255, 196, 50, 0.9)), url(assets/kraft.webp) 0 0 / 180px, #ffcf4a;
  box-shadow: 3px 4px 0 rgba(120, 70, 10, 0.45), 0 14px 30px -10px rgba(0, 0, 0, 0.55);
}
.banner.on { animation: stamp 2.2s cubic-bezier(.2, 1.4, .4, 1) forwards; }
@keyframes stamp {
  0% { opacity: 0; transform: translate(-50%, -50%) rotate(-12deg) scale(2.2); }
  14% { opacity: 1; transform: translate(-50%, -50%) rotate(-4deg) scale(0.94); }
  22% { transform: translate(-50%, -50%) rotate(-4deg) scale(1.03); }
  30%, 86% { opacity: 1; transform: translate(-50%, -50%) rotate(-4deg) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -62%) rotate(-4deg) scale(1); }
}
.fl-thing .pic { position: relative; }
.fl-thing .zz { position: absolute; right: -2px; top: -2px; font-weight: 800; font-size: 15px; color: #fff; text-shadow: 0 0 2px #2c2136, 0 1px 0 #2c2136; }

/* ---- the level map ---- */
.screen {
  position: fixed; inset: 0; z-index: 12; overflow-y: auto; -webkit-overflow-scrolling: touch;
  background: radial-gradient(ellipse 110% 60% at 50% 0%, var(--bg-hi), transparent 75%), var(--bg);
  padding: 0 16px calc(env(safe-area-inset-bottom, 0px) + 24px);
}
.map-top { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 10px; padding-top: calc(var(--sg-corner-top) - 6px); padding-left: calc(var(--sg-corner-left) - 16px); min-height: 56px; }
.map-top h1 { margin: 0; font-size: 24px; font-weight: 800; text-align: center; text-shadow: 0 2px 0 rgba(0, 0, 0, 0.3); }
.map-stars { margin: 0; font-weight: 800; font-size: 17px; white-space: nowrap; }
.map-list { max-width: 520px; margin: 8px auto 0; display: grid; gap: 18px; }
.world { border-radius: 22px; padding: 12px 12px 14px; background: rgba(255, 255, 255, 0.1); box-shadow: inset 0 0 0 1.5px var(--line); }
.world h2 { margin: 0 4px; font-size: 20px; font-weight: 800; }
.world p { margin: 0 4px 10px; font-size: 14px; font-weight: 700; color: var(--ink-soft); }
.world .tiles { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.tile {
  min-height: 62px; border: 0; border-radius: 16px; padding: 6px 2px 4px; display: grid; justify-items: center; align-content: center; gap: 2px;
  background: #fffaf0; color: var(--sheet-ink); font-weight: 800; font-size: 19px; line-height: 1; cursor: pointer;
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.25); -webkit-tap-highlight-color: transparent;
}
.tile:active { transform: scale(0.95); }
.tile.next { box-shadow: 0 0 0 3px #ffcf4a, 0 3px 0 rgba(0, 0, 0, 0.25); }
.tile.boss { background: #ffe9c4; }
.tile.locked { background: rgba(255, 255, 255, 0.18); color: rgba(255, 255, 255, 0.7); box-shadow: none; }
.tile .st { display: flex; gap: 1px; height: 14px; }
.tile .st svg { width: 14px; height: 14px; }
.tile .lock { width: 18px; height: 18px; }

/* ---- the end card ---- */
.over { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; padding: 16px; background: rgba(16, 24, 48, 0.5); -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.over-card {
  width: min(340px, 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;
}
.over-kicker { margin: 0; font-weight: 800; font-size: 22px; }
.over-stars { display: flex; justify-content: center; align-items: flex-end; gap: 6px; height: 70px; margin: 6px 0 2px; }
.over-stars svg { width: 54px; height: 54px; }
.over-stars svg:nth-child(2) { width: 66px; height: 66px; }
.over-stars svg.on { animation: star 0.42s cubic-bezier(.3, 1.6, .5, 1) both; }
.over-score { margin: 0; font-weight: 800; font-size: 44px; line-height: 1; font-variant-numeric: tabular-nums; }
.over-best { margin: 4px 0 0; font-weight: 800; font-size: 16px; color: var(--sheet-soft); min-height: 22px; }
.over-best.new { color: #2f8a55; }
.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: #eaf3ff; font-weight: 700; font-size: 15px; line-height: 1.25; }
.over-btns { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; margin-top: 16px; }
.over-btns.two { grid-template-columns: 1fr 1fr; }
.pill {
  min-height: 50px; border: 0; border-radius: 999px; padding: 4px 10px 2px; cursor: pointer;
  background: rgba(47, 42, 61, 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); }

.toast {
  position: fixed; left: 50%; top: calc(env(safe-area-inset-top, 0px) + 74px); 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: meet cards, looks, how to play ---- */
.fl-meet { display: grid; gap: 10px; }
.fl-thing { display: flex; gap: 12px; align-items: center; padding: 10px 12px 8px; border-radius: 16px; background: rgba(47, 42, 61, 0.06); }
.fl-thing .pic { flex: none; width: 64px; height: 64px; display: grid; place-items: center; }
.fl-thing .pic img, .fl-thing .pic canvas, .fl-thing .pic svg { max-width: 64px; max-height: 64px; display: block; }
.fl-thing b { display: block; font-size: 18px; }
.fl-thing p { margin: 2px 0 0; font-size: 15px; font-weight: 600; line-height: 1.3; }
.fl-thing small { display: block; margin-top: 2px; color: var(--sheet-soft); font-weight: 700; font-size: 14px; }
.fl-looks h3 { margin: 6px 0 8px; font-size: 17px; }
.fl-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 14px; }
.fl-pick {
  min-height: 100px; border: 0; border-radius: 16px; padding: 6px 4px 4px; cursor: pointer; display: grid; justify-items: center; align-content: start; gap: 2px;
  background: rgba(47, 42, 61, 0.07); color: var(--sheet-ink); font-weight: 800; font-size: 14px; line-height: 1.15;
  -webkit-tap-highlight-color: transparent;
}
.fl-pick.on { box-shadow: inset 0 0 0 3px #4b7fe0; background: #e8f0ff; }
.fl-pick.locked { opacity: 0.55; }
.fl-pick small { font-weight: 700; font-size: 12px; color: var(--sheet-soft); }
.fl-pick .face { width: 58px; height: 62px; }
.fl-pick .face svg, .fl-pick .face img { display: block; width: 100%; height: 100%; }
.fl-pick .swatch { width: 56px; height: 62px; display: grid; place-items: center; }
.fl-how p { margin: 0 0 10px; }

/* ---- paper and card (ART.md): cards, tiles and labels cut from kraft paper ---- */
.over-card {
  border-radius: 8px; transform: rotate(-0.6deg);
  background: linear-gradient(rgba(255, 250, 238, 0.84), rgba(255, 250, 238, 0.84)), url(assets/kraft.webp) 0 0 / 200px, var(--sheet);
  box-shadow: 3px 4px 0 rgba(70, 42, 20, 0.28), 0 16px 40px -12px rgba(0, 0, 0, 0.7);
}
.over-new li { border-radius: 4px; background: rgba(214, 232, 255, 0.85); box-shadow: 1px 2px 0 rgba(70, 42, 20, 0.16); }
.pill { border-radius: 10px; }
.pill.primary { background: linear-gradient(rgba(255, 207, 74, 0.86), rgba(255, 196, 50, 0.86)), url(assets/kraft.webp) 0 0 / 160px, var(--accent); box-shadow: 2px 3px 0 #a87512; }
.hint { border-radius: 8px; background: linear-gradient(rgba(70, 46, 28, 0.82), rgba(70, 46, 28, 0.82)), url(assets/kraft.webp) 0 0 / 180px; box-shadow: 2px 3px 0 rgba(30, 18, 8, 0.3); }
.screen { background: linear-gradient(rgba(43, 74, 122, 0.88), rgba(32, 52, 92, 0.94)), url(assets/kraft.webp) 0 0 / 220px, var(--bg); }
.world { border-radius: 10px; background: rgba(255, 250, 238, 0.12); }
.tile { border-radius: 8px; background: linear-gradient(rgba(255, 250, 238, 0.82), rgba(255, 250, 238, 0.82)), url(assets/kraft.webp) 0 0 / 140px, #fffaf0; box-shadow: 2px 3px 0 rgba(30, 18, 8, 0.3); }
.tile:nth-child(3n) { transform: rotate(0.8deg); }
.tile:nth-child(4n) { transform: rotate(-0.7deg); }
.tile.tile:active { transform: scale(0.95); }
.tile.boss { background: linear-gradient(rgba(255, 226, 180, 0.82), rgba(255, 226, 180, 0.82)), url(assets/kraft.webp) 0 0 / 140px, #ffe9c4; }
.tile.locked { background: rgba(255, 255, 255, 0.16); }
.toast { border-radius: 6px; background: linear-gradient(rgba(255, 250, 238, 0.88), rgba(255, 250, 238, 0.88)), url(assets/kraft.webp) 0 0 / 180px, #fffaf0; }
.queue img { filter: drop-shadow(0 0 1.2px #fffaf0) drop-shadow(0 0 1px #fffaf0) drop-shadow(1px 2px 0 rgba(20, 30, 60, 0.35)); }

/* ---- the title screen's colors (the layout is shared/mainmenu.js) ---- */
#mm {
  --sg-bg: linear-gradient(rgba(24, 44, 84, 0.42), rgba(24, 44, 84, 0.12) 40%, rgba(24, 44, 84, 0.5)), url(/fling/assets/title.webp) 50% 100% / cover, var(--bg); /* absolute: a url in a custom property resolves where it's used */
  --sg-ink: var(--ink); --sg-ink-soft: var(--ink-soft);
  --sg-title: #ffe07a; --sg-title-shadow: 0 3px 0 rgba(20, 30, 60, 0.5);
  --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);
}
#mm .fl-title-art { width: 290px; max-width: 100%; aspect-ratio: 320 / 220; }
#mm .fl-title-art canvas { display: block; box-sizing: border-box; width: 100%; height: 100%; border-radius: 4px; border: 5px solid #fffaf0; transform: rotate(-1.2deg); box-shadow: 2px 4px 0 rgba(60, 35, 15, 0.28), 0 12px 26px -10px rgba(0, 0, 0, 0.6); }
.sg-sheet { --sg-sheet-bg: var(--sheet); --sg-sheet-ink: var(--sheet-ink); --sg-accent: #2f5ea8; --sg-accent-ink: #fff; --sg-ink-soft: var(--sheet-soft); }

@keyframes pop { 0% { transform: scale(1); } 45% { transform: scale(1.14); } 100% { transform: scale(1); } }
@keyframes rise { from { transform: translateY(16px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes breathe { 0%, 100% { opacity: 1; } 50% { opacity: 0.65; } }
@keyframes star { from { transform: scale(0.2) rotate(-40deg); opacity: 0; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
  .score b.pop, .over-card, .hint, .over-stars svg.on { animation: none; }
  .banner.on { animation: none; opacity: 1; transform: translate(-50%, -50%) rotate(-4deg); }
  .toast, .meter i { transition: none; }
}

/* title over the painted scene: no photo frame, the fort stands on a strip of grass */
#mm.sg-scened .fl-title-art canvas { border: 0; border-radius: 0; transform: none; box-shadow: none; }

/* the Levels screen sits outside .app, so it needs the same no-select rule */
.screen, .toast, .over { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }

/* sheets (Levels, looks, how to play, meet cards) hang off <body>, outside .app: no text selection on a long press */
.sg-sheet, .sg-sheet * { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.sg-sheet input, .sg-sheet textarea { -webkit-user-select: text; user-select: text; }
