/* Professor Layton and the Miracle Mask: Minigames showcase page (loaded by _minigames.html, and by home.html for the
   minigame cards). Night-blue display case with gold trim, cream placards and parchment panels. Uses the zone tokens
   from theme.css (--ml-*). Without JavaScript every panel is listed and the controls stay hidden. */
.mg { padding-bottom: 40px; }
.mg [hidden] { display: none !important; }
.mg:not(.is-ready) .mg-js { display: none !important; }
.mg-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.mg-defs { position: absolute; width: 0; height: 0; overflow: hidden; }

/* Hero */
.mg-hero { max-width: 760px; margin: 36px auto 26px; text-align: center; color: var(--ml-parchment); }
.mg-hero h1 { margin: 6px 0 12px; font-family: var(--ml-serif); font-size: clamp(1.8rem, 4vw, 2.6rem); line-height: 1.15; color: var(--ml-gold-light); }
.mg-lede { margin: 0 auto; max-width: 64ch; color: rgba(244, 230, 202, .86); line-height: 1.6; }
.mg-stats { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; list-style: none; margin: 18px 0 0; padding: 0; }
.mg-stats li { padding: 6px 14px; border: 1px solid rgba(220, 167, 68, .55); border-radius: 99px; background: rgba(12, 15, 39, .6); color: var(--ml-parchment); font-weight: 700; font-size: .9rem; }
.mg-stats strong { font-family: var(--ml-serif); color: var(--ml-gold-light); margin-right: 4px; }

/* Display case */
.mg-case { position: relative; padding: 26px 22px 10px; border: 3px solid var(--ml-gold-dark); border-radius: 14px;
  background: linear-gradient(180deg, #1d2450 0%, var(--ml-night) 55%, var(--ml-night-deep) 100%);
  box-shadow: inset 0 0 0 6px #2e1c10, inset 0 0 0 8px rgba(220, 167, 68, .45), 0 18px 40px rgba(0, 0, 0, .45); overflow: hidden; }
.mg-case::before { content: ""; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(115deg, rgba(255, 255, 255, .09) 0%, rgba(255, 255, 255, 0) 32%, rgba(255, 255, 255, 0) 60%, rgba(255, 255, 255, .05) 72%, rgba(255, 255, 255, 0) 80%); }
.mg-shelf { position: relative; display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 30px 22px; list-style: none; margin: 0; padding: 0; }
.mg-tile { grid-column: span 2; position: relative; padding-bottom: 18px; }
.mg-tile:nth-child(4) { grid-column: 2 / span 2; }
.mg-tile::after { content: ""; position: absolute; left: -11px; right: -11px; bottom: 0; height: 12px; border-radius: 2px;
  background: linear-gradient(#7a5230, #4c311e 60%, #2e1c10); box-shadow: 0 8px 14px rgba(0, 0, 0, .55); }
.mg-tile a { display: flex; flex-direction: column; height: 100%; color: var(--ml-ink); text-decoration: none; border-radius: 10px; transition: transform .2s ease; }
.mg-tile a:hover, .mg-tile a:focus-visible { transform: translateY(-4px); }
.mg-tile a:focus-visible { outline: 3px solid var(--ml-teal); outline-offset: 4px; }
.mg-tile.is-open .mg-glass { border-color: var(--ml-gold-light); box-shadow: 0 0 0 3px rgba(246, 212, 128, .55), 0 0 26px rgba(246, 212, 128, .35); }
.mg-glass { position: relative; display: block; aspect-ratio: 4 / 3; border: 3px solid var(--ml-gold); border-radius: 10px 10px 4px 4px; overflow: hidden; background: #0c0f27; box-shadow: 0 10px 22px rgba(0, 0, 0, .45); }
.mg-glass::after { content: ""; position: absolute; inset: 0; background: radial-gradient(120% 70% at 50% -10%, rgba(255, 244, 214, .28), rgba(255, 244, 214, 0) 60%), linear-gradient(120deg, rgba(255, 255, 255, .16), rgba(255, 255, 255, 0) 40%); }
.mg-glass img { width: 100%; height: 100%; object-fit: cover; display: block; }
.mg-placard { flex: 1; display: grid; align-content: start; gap: 6px; margin: -2px 10px 0; padding: 12px 14px 12px; border: 1px solid var(--ml-gold-dark); border-top: 0; border-radius: 0 0 8px 8px; background: var(--ml-parchment); color-scheme: light; }
.mg-placard strong { font-family: var(--ml-serif); font-size: 1.1rem; color: var(--ml-wood-deep); line-height: 1.2; }
.mg-line { font-size: .9rem; color: var(--ml-ink-2); line-height: 1.4; }
.mg-tags { display: flex; flex-wrap: wrap; gap: 5px; }
.mg-tag { padding: 2px 8px; border-radius: 4px; background: var(--ml-wood); color: var(--ml-gold-light); font-size: .74rem; font-weight: 800; }
.mg-tprog { display: flex; align-items: center; gap: 8px; }
.mg-tprog small { font-weight: 800; color: var(--ml-ink-2); white-space: nowrap; }
.mg-bar { position: relative; flex: 1 1 120px; height: 9px; border-radius: 99px; background: rgba(167, 108, 18, .2); overflow: hidden; }
.mg-bar > span { position: absolute; inset: 0 auto 0 0; width: 0; border-radius: inherit; background: linear-gradient(90deg, var(--ml-gold-dark), var(--ml-gold)); transition: width .25s ease; }
.mg-pickhint { margin: 22px 0 0; text-align: center; color: rgba(244, 230, 202, .8); font-weight: 700; }

/* Panels */
.mg-panels { display: grid; gap: 28px; margin-top: 28px; }
.mg-panel { padding: 22px 24px 24px; color: var(--ml-ink); color-scheme: light; overflow-wrap: anywhere; scroll-margin-top: 90px; }
.mg-panel-top { display: grid; grid-template-columns: minmax(0, 260px) minmax(0, 1fr); gap: 20px; align-items: center; }
.mg-panel-art { margin: 0; border: 3px solid var(--ml-gold); border-radius: 8px; overflow: hidden; background: #0c0f27; }
.mg-panel-art img { display: block; width: 100%; height: auto; }
.mg-eyebrow { margin: 0; font-size: .75rem; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; color: var(--ml-gold-dark); }
.mg-panel h2 { margin: 2px 0 6px; font-family: var(--ml-serif); font-size: clamp(1.5rem, 3vw, 2rem); color: var(--ml-wood-deep); }
.mg-uk { margin: 0 0 6px; font-size: .88rem; color: var(--ml-ink-2); }
.mg-panel-intro p { line-height: 1.6; }
.mg-facts { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin: 18px 0 14px; }
.mg-facts div { padding: 10px 12px; border: 1px solid rgba(167, 108, 18, .45); border-radius: 8px; background: rgba(255, 255, 255, .45); }
.mg-facts dt { font-size: .72rem; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; color: var(--ml-gold-dark); }
.mg-facts dd { margin: 3px 0 0; font-size: .9rem; line-height: 1.4; }
.mg-panel details > summary { cursor: pointer; font-weight: 800; }
.mg-rules { margin: 0 0 14px; padding: 10px 14px; border-radius: 8px; background: rgba(76, 49, 30, .07); }
.mg-rules ul { margin: 8px 0 2px; padding-left: 20px; line-height: 1.55; }
.mg-progress { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; margin: 0 0 14px; }
.mg-progress p { margin: 0; font-weight: 700; }
.mg-progress strong { font-family: var(--ml-serif); font-size: 1.15rem; color: var(--ml-gold-dark); }
.mg-reset { min-height: 36px; padding: 4px 14px; border: 1px solid rgba(112, 88, 72, .5); border-radius: 99px; background: transparent; color: var(--ml-ink-2); font: 700 .82rem var(--ml-sans); cursor: pointer; }
.mg-back { margin: 18px 0 0; text-align: right; font-weight: 800; }
.mg-back a { color: var(--ml-wood); }

/* Stage picker */
.mg-picker { margin: 0 0 16px; }
.mg-picker-label { margin: 10px 0 6px; font-size: .78rem; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; color: var(--ml-ink-2); }
.mg-picker-row { display: flex; flex-wrap: wrap; gap: 6px; }
.mg-pick { position: relative; display: inline-flex; align-items: center; gap: 6px; min-height: 40px; max-width: 100%; padding: 4px 12px 4px 6px; border: 1px solid rgba(167, 108, 18, .6); border-radius: 8px; background: rgba(255, 255, 255, .55); color: var(--ml-ink); font: 700 .84rem var(--ml-sans); cursor: pointer; }
.mg-pick-n { display: grid; place-items: center; min-width: 28px; height: 28px; padding: 0 4px; border-radius: 6px; background: var(--ml-wood); color: var(--ml-gold-light); font-size: .8rem; }
.mg-pick-t { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 15ch; }
.mg-tick { display: none; color: var(--ml-teal); font-weight: 900; }
.mg-pick.is-done .mg-tick { display: inline; }
.mg-pick.is-done { border-color: rgba(13, 146, 152, .7); }
.mg-pick[aria-pressed="true"] { background: var(--ml-night); border-color: var(--ml-gold); color: var(--ml-gold-light); }
.mg-pick[aria-pressed="true"] .mg-pick-n { background: var(--ml-gold); color: var(--ml-night); }
.mg-pick:focus-visible, .mg-btn:focus-visible, .mg-reset:focus-visible, .mg-panel summary:focus-visible { outline: 3px solid var(--ml-teal); outline-offset: 2px; }
.mg-legend { display: flex; flex-wrap: wrap; gap: 6px 14px; list-style: none; margin: 0 0 14px; padding: 0; font-size: .82rem; font-weight: 700; color: var(--ml-ink-2); }
.mg-legend li { display: inline-flex; align-items: center; gap: 5px; }
.mg-legend svg { width: 20px; height: 20px; }

/* Stages */
.mg-stages { display: grid; gap: 18px; }
.mg.is-ready .mg-stage:not(.is-active) { display: none; }
.mg-stage { padding: 16px 18px; border: 1px solid rgba(167, 108, 18, .45); border-radius: 10px; background: rgba(255, 255, 255, .5); scroll-margin-top: 90px; }
.mg-stage.is-done { border-color: rgba(13, 146, 152, .6); background: rgba(13, 146, 152, .07); }
.mg-stage-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-start; gap: 8px 16px; margin-bottom: 10px; }
.mg-stage-num { margin: 0; font-size: .75rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; color: var(--ml-gold-dark); }
.mg-stage h3 { margin: 2px 0 4px; font-family: var(--ml-serif); font-size: 1.3rem; color: var(--ml-wood-deep); }
.mg-meta { margin: 0; font-size: .86rem; color: var(--ml-ink-2); }
.mg-meta a, .mg-plist a, .mg-facts a { color: #0a6e72; font-weight: 700; }
.mg-done { display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px; border: 1px solid rgba(13, 146, 152, .55); border-radius: 99px; background: rgba(255, 255, 255, .7); font-weight: 800; font-size: .88rem; cursor: pointer; }
.mg-done input { width: 18px; height: 18px; margin: 0; accent-color: var(--ml-teal); }
.mg-blurb { margin: 0 0 10px; font-style: italic; color: var(--ml-ink-2); }
.mg-fig { margin: 8px 0 12px; }
.mg-fig figcaption { margin-top: 6px; font-size: .82rem; color: var(--ml-ink-2); }
.mg-svg { display: block; width: 100%; max-width: 460px; height: auto; }
.mg-shop-svg { max-width: 380px; }
.mg-ruin-svg { max-width: 420px; }
.mg-split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.mg-sub { margin: 4px 0 6px; font-weight: 800; color: var(--ml-wood); }
.mg-tray { display: grid; gap: 6px; list-style: none; margin: 0; padding: 0; }
.mg-tray li { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: 6px; background: rgba(76, 49, 30, .06); }
.mg-tray .mg-ico { flex: none; width: auto; height: 26px; }
.mg-tray span { display: grid; }
.mg-tray small, .mg-plist small, .mg-chain small { color: var(--ml-ink-2); }
.mg-plist { margin: 0 0 8px; padding-left: 18px; line-height: 1.6; }
.mg-map img { display: block; width: 100%; max-width: 300px; height: auto; border: 2px solid var(--ml-gold-dark); border-radius: 6px; }
.mg-hint, .mg-sol { margin: 8px 0; border: 1px solid rgba(167, 108, 18, .45); border-radius: 8px; background: rgba(255, 255, 255, .6); }
.mg-hint > summary, .mg-sol > summary { padding: 10px 14px; list-style-position: inside; }
.mg-sol > summary { color: var(--ml-wood-deep); }
.mg-hint[open] > summary, .mg-sol[open] > summary { border-bottom: 1px dashed rgba(167, 108, 18, .5); }
.mg-reveal { padding: 10px 14px 12px; line-height: 1.55; }
.mg-reveal > :first-child { margin-top: 0; }
.mg-reveal > :last-child { margin-bottom: 0; }
.mg-mini { margin: 6px 0 0; font-size: .85rem; }
.mg-mini > summary { padding: 4px 10px; }
.mg-arrows { font-weight: 800; }
.mg-seq { display: flex; flex-wrap: wrap; gap: 6px; }
.mg-seq span { display: inline-flex; align-items: center; gap: 4px; padding: 3px 8px 3px 6px; border-radius: 6px; background: var(--ml-night); color: rgba(244, 230, 202, .75); font-size: .74rem; }
.mg-seq b { color: var(--ml-gold-light); font-size: 1.05rem; }
.mg-n { display: inline-grid; place-items: center; min-width: 20px; height: 20px; border-radius: 99px; background: var(--ml-night); color: var(--ml-gold-light); font-size: .74rem; }
.mg-note { font-size: .86rem; color: var(--ml-ink-2); }
.mg-warn { padding: 8px 10px; border-left: 4px solid var(--ml-gold-dark); background: rgba(220, 167, 68, .14); color: var(--ml-ink); }
.mg-replay { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.mg-btn { min-height: 38px; min-width: 42px; padding: 4px 12px; border: 1px solid var(--ml-gold-dark); border-radius: 8px; background: var(--ml-wood); color: var(--ml-gold-light); font: 800 .88rem var(--ml-sans); cursor: pointer; }
.mg-btn-ghost { background: rgba(255, 255, 255, .6); color: var(--ml-wood-deep); }
.mg-replay [data-mg-rp-label] { min-width: 9ch; font-weight: 800; color: var(--ml-ink); }
.mg-stage-nav { display: flex; justify-content: space-between; gap: 10px; margin-top: 14px; }
.mg-route { margin: 0 0 8px; padding-left: 22px; line-height: 1.9; }
.mg-room { margin-top: 14px; padding-top: 10px; border-top: 1px dashed rgba(167, 108, 18, .45); }
.mg-room h4 { margin: 0 0 4px; font-family: var(--ml-serif); font-size: 1.05rem; color: var(--ml-wood); }
.mg-table { overflow-x: auto; margin: 0 0 8px; }
.mg-table table { width: 100%; border-collapse: collapse; font-size: .88rem; }
.mg-table th, .mg-table td { padding: 7px 8px; border-bottom: 1px solid rgba(167, 108, 18, .3); text-align: left; vertical-align: top; }
.mg-table th { font-size: .74rem; letter-spacing: .08em; text-transform: uppercase; color: var(--ml-gold-dark); }
.mg-acts { margin-top: 22px; }
.mg-acts h3 { font-family: var(--ml-serif); color: var(--ml-wood-deep); }
.mg-tips { padding-left: 20px; }
.mg-chain { padding-left: 22px; margin: 6px 0 0; }
.mg-gallery { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin: 0 0 16px; }
.mg-gallery figure { margin: 0; }
.mg-gallery img { display: block; width: 100%; height: auto; border: 2px solid var(--ml-gold-dark); border-radius: 6px; }
.mg-gallery figcaption { margin-top: 4px; font-size: .8rem; color: var(--ml-ink-2); font-weight: 700; }
.mg-about { margin-top: 32px; padding: 22px 26px; color: var(--ml-ink); color-scheme: light; }
.mg-about .prose { max-width: 78ch; margin: 0 auto; line-height: 1.65; }
.mg-about h2 { font-family: var(--ml-serif); color: var(--ml-wood-deep); }
.mg-about a { color: #0a6e72; font-weight: 700; }
.mg-about table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.mg-about th, .mg-about td { padding: 7px 8px; border-bottom: 1px solid rgba(167, 108, 18, .3); text-align: left; vertical-align: top; }
.mg-about details { margin: 8px 0; padding: 8px 12px; border: 1px solid rgba(167, 108, 18, .45); border-radius: 8px; background: rgba(255, 255, 255, .55); }
.mg-about summary { cursor: pointer; font-weight: 800; }

/* Home cards */
.mgh-cards { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 14px; list-style: none; margin: 0; padding: 0; }
.mgh-card a { display: flex; flex-direction: column; height: 100%; border: 2px solid var(--ml-gold-dark); border-radius: 10px; overflow: hidden; background: var(--ml-parchment); color: var(--ml-ink); text-decoration: none; color-scheme: light; transition: transform .2s ease, box-shadow .2s ease; }
.mgh-card a:hover, .mgh-card a:focus-visible { transform: translateY(-3px); box-shadow: 0 10px 22px rgba(0, 0, 0, .4); }
.mgh-card a:focus-visible { outline: 3px solid var(--ml-teal); outline-offset: 3px; }
.mgh-card img { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-bottom: 2px solid var(--ml-gold); background: #0c0f27; }
.mgh-card span { display: grid; gap: 4px; padding: 10px 12px 12px; }
.mgh-card strong { font-family: var(--ml-serif); font-size: 1rem; color: var(--ml-wood-deep); line-height: 1.2; }
.mgh-card small { color: var(--ml-ink-2); font-size: .82rem; line-height: 1.35; }
.mgh-card em { justify-self: start; margin-top: 2px; padding: 2px 8px; border-radius: 4px; background: var(--ml-wood); color: var(--ml-gold-light); font-style: normal; font-size: .74rem; font-weight: 800; }
.mgh-more { margin: 16px 0 0; text-align: center; }

@media (max-width: 980px) {
  .mg-shelf { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .mg-tile, .mg-tile:nth-child(4) { grid-column: auto; }
  .mg-tile:nth-child(5) { grid-column: 1 / -1; width: calc(50% - 11px); justify-self: center; }
  .mg-facts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .mg-gallery { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .mgh-cards { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
  .mg-case { padding: 18px 14px 6px; }
  .mg-shelf { grid-template-columns: minmax(0, 1fr); gap: 24px; }
  .mg-tile:nth-child(5) { width: auto; }
  .mg-panel { padding: 16px 14px 18px; }
  .mg-panel-top, .mg-split { grid-template-columns: minmax(0, 1fr); }
  .mg-panel-art { max-width: 320px; }
  .mg-facts { grid-template-columns: minmax(0, 1fr); }
  .mg-stage { padding: 12px; }
  .mg-pick-t { display: none; }
  .mg-pick { padding-right: 8px; }
  .mg-about { padding: 16px 14px; }
  .mgh-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .mgh-card:last-child { grid-column: 1 / -1; }
}
.mg-about .prose table { display: block; max-width: 100%; overflow-x: auto; }
@media (max-width: 640px) {
  .mg-table table { min-width: 500px; }
  .mgh-card:last-child img { aspect-ratio: 2 / 1; object-position: center 30%; }
}
.mg-panels, .mg-stages { grid-template-columns: minmax(0, 1fr); }
.mg-panel, .mg-stage, .mg-reveal, .mg-acts, .mg-table { min-width: 0; max-width: 100%; }

/* Homepage: Minigames now has its own full-width section, so a Collection section left alone in .ml-duo spans the row. */
.ml-duo > .ml-section:only-child { grid-column: 1 / -1; }
