/* Mushroom Detectives (/mushrooms): a kids' page, so big touch targets, big friendly type, high contrast. */
:root {
  --mm-ink: #1f3320;
  --mm-ink-soft: #3f5640;
  --mm-paper: #fff8ec;
  --mm-paper-2: #fdeed3;
  --mm-line: #e6d3b0;
  --mm-red: #c8202a;
  --mm-red-deep: #9e1820;
  --mm-sun: #f5b51a;
  --mm-moss: #2f5d3a;
  --mm-sky: #bfe3d0;
  --mm-nav-h: 76px;
  --mm-radius: 22px;
  --mm-font: ui-rounded, "SF Pro Rounded", "Nunito", "Varela Round", "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body.mm {
  margin: 0;
  overflow: hidden;
  background: var(--mm-sky);
  color: var(--mm-ink);
  font: 500 18px/1.45 var(--mm-font);
  -webkit-tap-highlight-color: transparent;
}
button { font: inherit; color: inherit; }
img { display: block; max-width: 100%; }

#mm-scene { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; cursor: grab; }
#mm-scene:active { cursor: grabbing; }
.no-3d #mm-scene, body:not(.has-3d) .mm-in-3d, .has-3d .mm-in-pictures { display: none; }
.no-3d { background: linear-gradient(180deg, var(--mm-sky), #9fcfb2); }

.mm-visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Header */
.mm-top {
  position: fixed; top: 0; left: 0; right: 0; z-index: 5;
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: max(10px, env(safe-area-inset-top)) 16px 10px;
  pointer-events: none;
}
.mm-top > * { pointer-events: auto; }
.mm-top > .mm-title { pointer-events: none; }
.mm-home {
  font-weight: 800; font-size: 15px; color: var(--mm-paper); text-decoration: none;
  background: rgba(31, 51, 32, 0.78); padding: 8px 14px; border-radius: 999px;
}
.mm-title {
  margin: 0; font-size: clamp(24px, 4.2vw, 38px); font-weight: 900; letter-spacing: 0.01em; line-height: 1.05;
  color: var(--mm-paper); text-shadow: 0 3px 0 var(--mm-red-deep), 0 6px 18px rgba(0, 0, 0, 0.25);
  -webkit-text-stroke: 1px var(--mm-red-deep);
}
.mm-title span { color: var(--mm-sun); }
.mm-top-actions { margin-left: auto; display: flex; gap: 8px; }
.mm-pill {
  min-height: 44px; padding: 8px 16px; border: 0; border-radius: 999px; cursor: pointer;
  background: var(--mm-paper); color: var(--mm-ink); font-weight: 800; font-size: 15px;
  box-shadow: 0 3px 0 var(--mm-line), 0 6px 16px rgba(0, 0, 0, 0.12);
}
.mm-pill[aria-pressed="true"] { background: var(--mm-sun); }

.mm-status { position: fixed; top: 74px; left: 16px; right: 16px; z-index: 4; margin: 0; font-weight: 700; }
.mm-status:empty { display: none; }

/* Card sheet: right-hand card on wide screens, bottom sheet on phones */
.mm-sheet {
  position: fixed; z-index: 4; right: 16px; top: 84px; bottom: calc(var(--mm-nav-h) + 20px); width: min(430px, calc(100vw - 32px));
  display: flex; flex-direction: column;
  background: var(--mm-paper); border-radius: var(--mm-radius);
  box-shadow: 0 6px 0 var(--mm-line), 0 20px 50px rgba(20, 40, 20, 0.28);
  transition: transform 0.35s cubic-bezier(.2, .9, .3, 1.2);
}
.mm-sheet-toggle { display: none; }
.mm-panel { overflow-y: auto; padding: 22px 22px 26px; overscroll-behavior: contain; flex: 1; }
.mm-panel h2 { margin: 0 0 8px; font-size: 27px; line-height: 1.15; font-weight: 900; color: var(--mm-moss); }
.mm-panel h2:focus { outline: none; }
.mm-panel h3 { margin: 18px 0 4px; font-size: 19px; font-weight: 900; color: var(--mm-red-deep); }
.mm-panel p { margin: 0 0 8px; }
.mm-small { font-size: 16px; color: var(--mm-ink-soft); }

/* Buttons */
.mm-actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 12px 0 4px; }
.mm-btn {
  min-height: 52px; padding: 10px 18px; border: 0; border-radius: 16px; cursor: pointer;
  background: var(--mm-paper-2); color: var(--mm-ink); font-weight: 800; font-size: 17px;
  box-shadow: 0 4px 0 var(--mm-line);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.mm-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--mm-line); }
.mm-btn-main { background: var(--mm-red); color: #fff; box-shadow: 0 4px 0 var(--mm-red-deep); }
.mm-btn-main:active { box-shadow: 0 1px 0 var(--mm-red-deep); }
.mm-btn-say { background: var(--mm-sun); box-shadow: 0 4px 0 #c98f0c; }
.mm-btn-puff { background: #dff1e4; box-shadow: 0 4px 0 #a9cdb3; }
.mm-btn-quiet { background: transparent; box-shadow: none; text-decoration: underline; font-weight: 700; min-height: 44px; }
:focus-visible { outline: 4px solid #1d6fd6; outline-offset: 3px; }

/* Pictures */
.mm-pic {
  width: 100%; height: auto; aspect-ratio: 1; border-radius: 18px; object-fit: cover;
  background: radial-gradient(circle at 50% 40%, #fffdf6 0%, #f1e4c8 70%, #e7d4ae 100%);
}
.mm-specimen {
  display: block; background-color: #f4ead6;
  background-image: url('/app/static/mushroom-clue-pictures.png');
  background-size: 500% 500%; background-repeat: no-repeat;
}
.mm-silhouette { filter: brightness(0) opacity(0.22); }

/* Detective key */
.mm-step { margin: 0 0 4px !important; font-weight: 900; font-size: 15px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--mm-red); }
.mm-hint { font-size: 16px; color: var(--mm-ink-soft); }
.mm-options { display: grid; gap: 12px; margin-top: 14px; }
.mm-options-few { grid-template-columns: repeat(2, 1fr); }
.mm-options-many { grid-template-columns: repeat(3, 1fr); }
.mm-option {
  display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 8px 8px 12px; cursor: pointer;
  background: #fff; border: 3px solid var(--mm-line); border-radius: 20px; text-align: center;
  box-shadow: 0 4px 0 var(--mm-line); transition: transform 0.12s ease, border-color 0.12s ease;
}
.mm-option:hover { border-color: var(--mm-sun); transform: translateY(-2px); }
.mm-option:active { transform: translateY(2px); }
.mm-option-label { font-weight: 900; font-size: 17px; line-height: 1.15; }
.mm-option-hint { font-size: 13.5px; line-height: 1.25; color: var(--mm-ink-soft); }

/* Group card */
.mm-found-banner { font-weight: 900; color: var(--mm-red); font-size: 18px; }
.mm-card-head { display: grid; grid-template-columns: 120px 1fr; gap: 14px; align-items: center; }
.mm-science { font-size: 15px; color: var(--mm-ink-soft); }
.mm-team, .mm-new { display: inline-block; margin: 2px 6px 0 0; padding: 4px 10px; border-radius: 999px; font-size: 14px; font-weight: 800; }
.mm-team-club { background: #e2efe0; color: #24502c; }
.mm-team-sac { background: #f5e1f0; color: #6a2a5c; }
.mm-new { background: var(--mm-sun); color: var(--mm-ink); animation: mm-pop 0.6s ease; }
@keyframes mm-pop { 0% { transform: scale(0.4); } 70% { transform: scale(1.15); } 100% { transform: scale(1); } }
.mm-wow { margin-top: 16px; padding: 4px 16px 10px; border-radius: 18px; background: #fff3c9; }
.mm-warning { margin-top: 14px !important; padding: 12px 14px; border-radius: 16px; background: #ffe1df; color: #7a1016; border-left: 6px solid var(--mm-red); }
.mm-examples { list-style: none; margin: 6px 0 0; padding: 0; display: grid; gap: 8px; }
.mm-example { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 8px 12px; background: #fff; border-radius: 14px; border: 2px solid var(--mm-line); }
.mm-example em { color: var(--mm-ink-soft); font-size: 15px; }
.mm-danger { flex: none; padding: 3px 10px; border-radius: 999px; font-size: 13.5px; font-weight: 900; }
.mm-danger-safe-to-look { background: #ebe7e1; color: #3d3a36; }
.mm-danger-sick { background: #ffe9b0; color: #6b4300; }
.mm-danger-poison { background: #ffe0b8; color: #7a3b00; }
.mm-danger-deadly { background: var(--mm-red); color: #fff; }
.mm-danger-note { margin-top: 8px !important; font-size: 15px; font-weight: 700; color: var(--mm-ink-soft); }
.mm-team-note { margin-top: 14px !important; font-size: 16px; }
.mm-rule { margin-top: 10px !important; font-weight: 800; color: var(--mm-red-deep); }

/* Lessons */
.mm-progress { font-weight: 900; color: var(--mm-moss); }
.mm-rules { margin: 6px 0 0; padding-left: 0; list-style: none; counter-reset: rule; display: grid; gap: 10px; }
.mm-rules li { counter-increment: rule; display: grid; grid-template-columns: 40px 1fr; column-gap: 10px; }
.mm-rules li::before {
  content: counter(rule); grid-row: span 2; width: 40px; height: 40px; border-radius: 50%;
  display: grid; place-items: center; background: var(--mm-red); color: #fff; font-weight: 900;
}
.mm-rules strong { display: block; }
.mm-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.mm-chip { min-height: 48px; padding: 8px 16px; border-radius: 999px; border: 3px solid var(--mm-line); background: #fff; font-weight: 800; cursor: pointer; }
.mm-chip.is-on { background: var(--mm-sun); border-color: #c98f0c; }
.mm-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 8px; }
.mm-tile {
  display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 6px 6px 10px;
  background: #fff; border: 3px solid var(--mm-line); border-radius: 18px; font-weight: 800; font-size: 14px; line-height: 1.2; text-align: center; cursor: pointer;
}
.mm-tile-locked { cursor: default; color: var(--mm-ink-soft); font-size: 22px; }
.mm-kingdom { font-weight: 800; margin-top: 12px !important; padding: 10px 14px; background: #e9f3ea; border-radius: 14px; }
.mm-branch { margin-top: 14px; padding: 4px 14px 14px; border-radius: 18px; }
.mm-branch-club { background: #f0f7ee; }
.mm-branch-sac { background: #fbf0f8; }
.mm-branch h3 small, .mm-order-name small { font-weight: 600; color: var(--mm-ink-soft); }
.mm-order { margin-top: 10px; }
.mm-order-name { margin-bottom: 0 !important; }
.mm-cousins { list-style: none; padding: 0; margin: 8px 0 0; display: grid; gap: 10px; }
.mm-cousins li { display: grid; grid-template-columns: 112px 1fr; gap: 12px; align-items: center; background: #fff; border-radius: 16px; padding: 8px; border: 2px solid var(--mm-line); }
.mm-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; }

/* Bottom navigation */
.mm-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 6;
  display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px;
  min-height: var(--mm-nav-h); padding: 8px max(10px, env(safe-area-inset-left)) max(8px, env(safe-area-inset-bottom));
  background: var(--mm-moss); box-shadow: 0 -6px 24px rgba(0, 0, 0, 0.18);
}
.mm-nav button {
  border: 0; border-radius: 16px; background: transparent; color: #f3ecd8; font-weight: 900; font-size: 16px; cursor: pointer;
  min-height: 56px; padding: 4px; line-height: 1.1;
}
.mm-nav button[aria-current="page"] { background: var(--mm-paper); color: var(--mm-moss); box-shadow: 0 4px 0 var(--mm-sun); }
.mm-count { display: inline-block; min-width: 26px; padding: 1px 7px; border-radius: 999px; background: var(--mm-sun); color: var(--mm-ink); font-size: 14px; }

/* Floating labels and hover tip */
.mm-labels { position: fixed; inset: 0; z-index: 3; pointer-events: none; }
.mm-label {
  position: absolute; left: 0; top: 0; pointer-events: auto; cursor: pointer;
  padding: 6px 14px; min-height: 40px; border: 3px solid #fff; border-radius: 999px;
  background: var(--mm-moss); color: #fff; font-weight: 900; font-size: 16px; white-space: nowrap;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.25);
}
.mm-label.is-on { background: var(--mm-sun); color: var(--mm-ink); }
.mm-tip {
  position: fixed; left: 0; top: 0; z-index: 7; pointer-events: none;
  padding: 6px 12px; border-radius: 12px; background: var(--mm-ink); color: #fff; font-weight: 800; font-size: 15px;
}

/* Game dialogs */
.mm-safety:not([open]), .mm-restart:not([open]) { display: none; }
.mm-safety, .mm-restart {
  position: fixed; inset: 0; margin: auto; z-index: 10; height: fit-content;
  max-height: calc(100vh - 32px);
  width: min(520px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); overflow-y: auto;
  border: 0; border-radius: 26px; padding: 26px; background: var(--mm-paper); color: var(--mm-ink);
  box-shadow: 0 8px 0 var(--mm-line), 0 30px 80px rgba(0, 0, 0, 0.35);
}
.mm-safety::backdrop, .mm-restart::backdrop { background: rgba(20, 40, 20, 0.55); }
.mm-safety h2 { margin: 0 0 6px; font-size: 30px; font-weight: 900; color: var(--mm-red); }
.mm-safety .mm-btn-main { width: 100%; margin-top: 18px; font-size: 20px; min-height: 58px; }
.mm-restart { width: min(420px, calc(100vw - 32px)); text-align: center; }
.mm-restart-sticker { width: 72px; height: 72px; margin: 0 auto 12px; background-position: 0 0; border: 4px solid white; border-radius: 50%; box-shadow: 0 3px 0 var(--mm-line); }
.mm-restart h2 { margin: 0; color: var(--mm-moss); font-size: clamp(24px, 5vw, 30px); line-height: 1.15; }
.mm-restart p { margin: 10px 0 20px; }
.mm-restart-actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(130px, 100%), 1fr)); gap: 12px; }

.mm-noscript { position: fixed; inset: 80px 16px auto; z-index: 9; background: var(--mm-paper); padding: 20px; border-radius: var(--mm-radius); }

/* Phones: the card becomes a bottom sheet that can be tucked away to see the forest */
@media (max-width: 760px) {
  body.mm { font-size: 17px; }
  .mm-top { gap: 8px; padding-left: 16px; padding-right: 16px; }
  .mm-home { display: none; }
  .mm-title { font-size: 23px; }
  .mm-top-actions { gap: 6px; }
  .mm-pill { padding: 4px 10px; font-size: 13px; min-height: 36px; }
  .mm-sheet {
    left: 0; right: 0; top: auto; width: auto; bottom: var(--mm-nav-h);
    max-height: 47vh; max-height: min(47dvh, 520px); border-radius: var(--mm-radius) var(--mm-radius) 0 0;
    box-shadow: 0 -10px 30px rgba(20, 40, 20, 0.22);
  }
  .no-3d .mm-sheet { top: 76px; max-height: none; }
  .mm-sheet.is-collapsed { transform: translateY(calc(100% - 34px)); }
  .mm-sheet-toggle {
    display: block; flex: none; height: 34px; width: 100%; border: 0; background: transparent; cursor: pointer; position: relative;
  }
  .mm-sheet-toggle { font-weight: 750; color: var(--mm-moss); font-size: 13px; }
  .mm-sheet-toggle[aria-expanded="true"] .mm-show-card,
  .mm-sheet-toggle[aria-expanded="false"] .mm-hide-card { display: none; }
  .mm-panel { padding: 0 16px 20px; }
  .mm-panel h2 { font-size: 23px; }
  .mm-card-head { grid-template-columns: 92px 1fr; }
  .mm-nav { gap: 2px; padding-left: 6px; padding-right: 6px; }
  .mm-nav button { font-size: 13.5px; }
  .mm-options-many { gap: 8px; }
  .mm-option { padding: 6px 4px 8px; border-radius: 16px; }
  .mm-option-hint { display: none; }
  .mm-label { font-size: 14px; min-height: 34px; padding: 4px 10px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

.mm-foot { position: fixed; left: 16px; bottom: calc(var(--mm-nav-h) + 6px); z-index: 2; display: flex; gap: 12px; font-size: 13px; font-weight: 700; }
.mm-foot a { color: var(--mm-ink); background: rgba(255, 248, 236, 0.85); padding: 2px 8px; border-radius: 8px; }
@media (max-width: 760px) { .mm-foot { display: none; } }

.mm-start { width: 100%; margin: 4px 0 14px; }
.mm-meter { width: 100%; height: 10px; accent-color: var(--mm-moss); }
.mm-list { margin: 8px 0; }
.mm-list summary { padding: 12px; border-radius: 12px; background: var(--mm-paper-2); font-weight: 800; cursor: pointer; }
.mm-evidence { display: flex; align-items: center; gap: 12px; margin: 12px 0; padding: 10px; border-radius: 16px; background: #e7efdf; }
.mm-evidence .mm-pic { flex: none; width: 70px; }
.mm-evidence p { margin: 0; font-weight: 650; }
.mm-answers { display: grid; gap: 9px; }
.mm-answer { background: white; border: 2px solid var(--mm-line); text-align: left; }
.mm-answer:hover, .mm-answer:focus-visible { border-color: var(--mm-moss); }
.mm-retry:not(:empty) { margin-top: 12px; padding: 8px 12px; border-left: 4px solid var(--mm-sun); background: #fff3c9; }
.mm-next { margin-bottom: 18px; }
.no-3d .mm-status { position: static; margin: 78px auto 6px; padding: 0 16px; text-align: center; font-size: 15px; }
.no-3d .mm-sheet { left: 50%; right: auto; top: 112px; width: min(520px, calc(100vw - 24px)); transform: translateX(-50%); }
.no-3d .mm-sheet-toggle { display: none; }
@media (max-width: 760px) {
  .mm-sheet:has(.mm-mystery) { max-height: 56dvh; }
  .no-3d .mm-sheet { max-height: none; }
  .no-3d .mm-panel { padding-top: 16px; }
  .mm-evidence .mm-pic { width: 52px; }
  .mm-answer { min-height: 44px; padding: 7px 12px; }
}
