/* Midnight Snack: the house at night on one canvas that follows Kento, a few DOM pieces on top (the bar, the dock with
   the kibble left and the things found, 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: #07080f; --bg-hi: #1a1b34; --ink: #fff6ea; --ink-soft: #b9c0ea; --line: rgba(255, 246, 234, 0.18);
  --accent: #ffcf4a; --accent-ink: #231a3a; --sheet: #fbf6ee; --sheet-ink: #242044; --sheet-soft: #6b6890;
  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: radial-gradient(ellipse 120% 45% at 50% 0%, var(--bg-hi), transparent 70%), var(--bg);
  overflow: hidden; overscroll-behavior: none;
}
button { font: inherit; color: inherit; }
.app {
  position: fixed; inset: 0; display: flex; flex-direction: column; align-items: center;
  padding: calc(var(--sg-corner-top) - 6px) 6px calc(env(safe-area-inset-bottom, 0px) + 10px);
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
}

/* ---- the bar ---- */
.bar { width: 100%; max-width: 520px; display: grid; grid-template-columns: 112px 1fr 112px; align-items: center; gap: 4px; min-height: 56px; }
.bar > .sg-corner-slot { margin-left: calc(var(--sg-corner-left) - 6px); }
.score { text-align: center; line-height: 1; }
.score b { display: block; font-weight: 800; font-size: 32px; letter-spacing: 0.5px; text-shadow: 0 2px 0 rgba(0, 0, 0, 0.4); font-variant-numeric: tabular-nums; }
.score small { display: block; margin-top: 2px; font-weight: 700; font-size: 14px; color: var(--ink-soft); }
.side { justify-self: end; display: grid; justify-items: end; gap: 4px; }
.pill { padding: 3px 10px 1px; border-radius: 999px; background: rgba(0, 0, 0, 0.3); font-weight: 800; font-size: 14px; white-space: nowrap; box-shadow: inset 0 0 0 1.5px var(--line); max-width: 112px; overflow: hidden; text-overflow: ellipsis; }
.lives { display: flex; gap: 3px; min-height: 14px; }
.life { width: 14px; height: 14px; border-radius: 50% 50% 45% 45%; background: #f6ead9; box-shadow: inset -2px -2px 0 #d48d58; position: relative; }
.life::before, .life::after { content: ""; position: absolute; top: -4px; width: 0; height: 0; border-left: 3.5px solid transparent; border-right: 3.5px solid transparent; border-bottom: 6px solid #e7a774; }
.life::before { left: 0; } .life::after { right: 0; }

/* ---- the house: one canvas that follows Kento, the dock under it ---- */
.stage { position: relative; flex: 1; width: 100%; max-width: 640px; min-height: 0; touch-action: none; border-radius: 14px; overflow: hidden; background: #000; box-shadow: 0 0 0 2px #05060e, 0 12px 30px -10px rgba(0, 0, 0, 0.8); }
#field { position: absolute; inset: 0; display: block; width: 100%; height: 100%; touch-action: none; }
.hint {
  position: absolute; left: 50%; bottom: 96px; transform: translateX(-50%); margin: 0; padding: 8px 16px 6px;
  border-radius: 999px; background: rgba(8, 10, 30, 0.82); font-weight: 800; font-size: 18px; white-space: nowrap;
  pointer-events: none; animation: breathe 1.6s ease-in-out infinite;
}
.dock { position: absolute; left: 0; right: 0; bottom: 0; display: flex; align-items: flex-end; justify-content: space-between; gap: 10px; padding: 0 12px 12px; pointer-events: none; }
.found { pointer-events: none; display: flex; align-items: center; gap: 8px; padding: 6px 14px 4px; border-radius: 999px; background: rgba(4, 6, 18, 0.72); box-shadow: inset 0 0 0 1.5px var(--line); font-weight: 800; font-size: 17px; font-variant-numeric: tabular-nums; }
.found.home { background: rgba(60, 40, 8, 0.85); color: #ffe39a; box-shadow: inset 0 0 0 2px #ffcf4a; }
.found i { display: inline-block; width: 12px; height: 12px; border-radius: 50%; background: #ffcf4a; box-shadow: 0 0 8px #ffcf4a; }
.dock .found b { color: #ffe0a8; }
.dock .things { gap: 6px; }
.dock .things i { background: #9ad4ff; box-shadow: 0 0 8px #9ad4ff; }
.dock .things.all { color: #ffe39a; box-shadow: inset 0 0 0 2px #ffcf4a; }

/* ---- the end card ---- */
.over { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; padding: 16px; background: rgba(6, 8, 24, 0.62); }
.over-card {
  width: min(340px, 100%); padding: 20px 20px 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; color: var(--sheet-soft); }
.over-stars { display: flex; justify-content: center; gap: 6px; margin: 6px 0 0; }
.over-stars .star svg { width: 44px; height: 44px; fill: #d9d4e8; stroke: #b8b2cc; stroke-width: 1.4; }
.over-stars .star.on.pop svg { fill: #ffc93a; stroke: #b0780a; animation: pop 0.35s ease-out; }
.over-score { margin: 2px 0 0; font-weight: 800; font-size: 50px; line-height: 1; font-variant-numeric: tabular-nums; }
.over-line { margin: 6px 0 0; font-weight: 700; font-size: 17px; }
.over-best { margin: 4px 0 0; font-weight: 800; font-size: 15px; color: #7a5a10; min-height: 20px; }
.over-best.new { color: #2f8a55; }
.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: #eef0ff; font-weight: 700; font-size: 15px; }
.over-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 16px; }
.btn { min-height: 50px; border: 0; border-radius: 999px; padding: 4px 12px 2px; cursor: pointer; background: rgba(36, 32, 68, 0.1); color: var(--sheet-ink); font-weight: 800; font-size: 17px; -webkit-tap-highlight-color: transparent; }
.btn.primary { background: var(--accent); color: var(--accent-ink); box-shadow: 0 3px 0 #b98a1a; }
.btn:active { transform: scale(0.97); }

.toast {
  position: fixed; left: 50%; top: calc(env(safe-area-inset-top, 0px) + 72px); 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: #fbf6ee; 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 ---- */
.ms-how p, .ms-jays p { margin: 0 0 10px; }
.ms-how h3 { margin: 12px 0 6px; font-size: 17px; }
.ms-jay { display: flex; gap: 10px; align-items: center; margin-bottom: 8px; }
.ms-jay canvas { flex: none; }
.ms-jay p { margin: 0; line-height: 1.3; }
.ms-meet { font-size: 17px; line-height: 1.4; margin: 0; }
.ms-stages { display: grid; gap: 8px; }
.ms-stage {
  display: grid; grid-template-columns: 36px 1fr auto; align-items: center; gap: 10px; min-height: 58px; padding: 6px 12px; border: 0; border-radius: 16px;
  background: rgba(36, 32, 68, 0.07); color: var(--sheet-ink); text-align: left; cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.ms-stage:active { transform: scale(0.98); }
.ms-stage.locked { opacity: 0.5; cursor: default; }
.ms-stage .n { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; background: #2b2f6b; color: #fff; font-weight: 800; }
.ms-stage .what { display: grid; line-height: 1.2; }
.ms-stage .what b { font-size: 16px; }
.ms-stage .what small { font-size: 13px; font-weight: 700; color: var(--sheet-soft); }
.ms-stage .stars { display: flex; gap: 1px; }
.ms-stage .stars svg { width: 20px; height: 20px; fill: #d9d4e8; stroke: #b8b2cc; stroke-width: 1.4; }
.ms-stage .stars .on svg { fill: #ffc93a; stroke: #b0780a; }
.ms-looks h3 { margin: 4px 0 8px; font-size: 17px; }
.ms-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 14px; }
.ms-pick {
  min-height: 96px; border: 0; border-radius: 16px; padding: 6px 4px 4px; cursor: pointer; display: grid; justify-items: center; gap: 2px;
  background: rgba(36, 32, 68, 0.07); color: var(--sheet-ink); font-weight: 800; font-size: 14px; line-height: 1.15; -webkit-tap-highlight-color: transparent;
}
.ms-pick.on { box-shadow: inset 0 0 0 3px #4a52a8; background: #e9ebff; }
.ms-pick.locked { opacity: 0.55; }
.ms-pick small { font-weight: 700; font-size: 12px; color: var(--sheet-soft); }
.ms-pick .face { width: 56px; height: 56px; }
.ms-pick .face svg { display: block; width: 100%; height: 100%; }
.ms-pick .swatch { width: 48px; height: 48px; margin: 4px 0; border-radius: 12px; box-shadow: inset 0 0 0 2px rgba(0, 0, 0, 0.2); }
.ms-medals { margin: 0; font-weight: 700; color: var(--sheet-soft); }
.ms-ach { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.ms-ach li { display: flex; gap: 10px; align-items: center; padding: 8px 12px 6px; border-radius: 14px; background: rgba(36, 32, 68, 0.06); font-weight: 700; font-size: 15px; line-height: 1.25; }
.ms-ach li b { display: block; font-size: 16px; }
.ms-ach li.no { opacity: 0.55; }
.ms-ach .medal { flex: none; width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: #f4c44e; color: #6b4a0c; font-weight: 800; }
.ms-ach li.no .medal { background: rgba(36, 32, 68, 0.14); color: transparent; }

/* ---- 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: #ffd86b; --sg-title-shadow: 0 3px 0 rgba(0, 0, 0, 0.45);
  --sg-accent: var(--accent); --sg-accent-ink: var(--accent-ink);
  --sg-card: #fbf6ee; --sg-card-ink: var(--sheet-ink); --sg-line: rgba(255, 246, 234, 0.22);
}
#mm .ms-title-art { display: block; width: 300px; max-width: 86vw; height: auto; aspect-ratio: 300 / 170; border-radius: 18px; box-shadow: 0 10px 26px -12px rgba(0, 0, 0, 0.8); }
.sg-sheet { --sg-sheet-bg: var(--sheet); --sg-sheet-ink: var(--sheet-ink); --sg-accent: #2b2f6b; --sg-accent-ink: #fff; --sg-ink-soft: var(--sheet-soft); }

@keyframes pop { 0% { transform: scale(0.6); } 55% { transform: scale(1.2); } 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.6; } }
@media (max-height: 700px) {
  .bar { min-height: 50px; }
  .score b { font-size: 28px; }
}
@media (prefers-reduced-motion: reduce) {
  .over-card, .hint, .over-stars .star.on.pop svg { animation: none; }
  .toast { transition: none; }
}
#mm.sg-scened .ms-title-art { border-radius: 0; box-shadow: none; }
