
/* ===== v61: roadside minigames ===== */
/* a board is as wide as the window's height allows (its aspect is 640 x 300; 100 * --hvh is the window's height in page units, --mg-chrome is what sits around the board), never past --mg-max, and never below 560px */
.mg { --mg-chrome: 380px; --mg-max: 1500px; margin: 6px auto 0; max-width: min(100%, var(--mg-max), max(560px, calc((100 * var(--hvh) - var(--mg-chrome)) * 640 / 300))); }
.mg-top { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; justify-content: center; margin-bottom: 8px; text-align: center; }
.mg-top b { font-family: var(--font-display); font-size: 20px; color: var(--gold-2); }
.mg-tip { color: #e9e0cb; font-size: 14px; }
.mg-score { color: #959dbe; font-size: 13px; } .mg-score b { color: var(--ivory); }
.mg-board { position: relative; border: 3px solid var(--royal-night); border-radius: 8px; overflow: hidden; background: var(--ivory); box-shadow: inset 0 0 0 2px var(--gilt-dark), 0 8px 22px var(--shade-45); min-height: 120px; }
.mg-svg { display: block; width: 100%; height: auto; user-select: none; }
.mg-svgtext { font: 700 16px var(--font-body); fill: var(--ink); }
.mg-ctl { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin: 12px 0 2px; min-height: 42px; }
.mg-ctl .btn { min-width: 120px; touch-action: manipulation; user-select: none; }
.mg-ctl .btn.mg-opt { min-width: 0; padding: 6px 10px; } .mg-ctl .btn.mg-opt img { width: 44px; height: 44px; display: block; }
.mg-dot { display: inline-block; width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--ink); margin-right: 6px; vertical-align: -1px; }
.mg-banner { position: absolute; left: 50%; top: 14px; transform: translate(-50%, -10px); padding: 6px 16px; border-radius: 6px; background: var(--ink); color: var(--ivory); font: 800 15px var(--font-body); opacity: 0; transition: opacity .15s, transform .15s; pointer-events: none; white-space: nowrap; z-index: 5; }
.mg-banner.show { opacity: 1; transform: translate(-50%, 0); } .mg-banner.good { box-shadow: 0 0 0 2px var(--gilt-aged); } .mg-banner.bad { box-shadow: 0 0 0 2px var(--claw); color: #ffb3a6; }
.mg-banner.big { top: 50%; transform: translate(-50%, -50%) scale(1.25); font: 800 26px var(--font-display); padding: 10px 26px; }
.mg-board.shake { animation: shake .3s; }
.mg-stakes { text-align: center; color: #7882ac; font-size: 12.5px; margin: 6px 0 0; }
.mg-cup:hover path:first-child { filter: brightness(1.1); }
.mg-stone:hover path:first-child { filter: brightness(1.12); }
/* fortune teller cards */
.mg-cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; padding: 16px; background: #5a3a4a; background-image: repeating-linear-gradient(-35deg, rgba(0,0,0,.12) 0 1px, transparent 1px 6px); }
.mg-card { position: relative; aspect-ratio: 3 / 4; border: 0; padding: 0; background: none; cursor: pointer; perspective: 600px; }
.mg-card span { position: absolute; inset: 0; border: 3px solid var(--ink); border-radius: 6px; display: grid; place-items: center; backface-visibility: hidden; transition: transform .35s; }
.mg-back { background: #2e1a38; background-image: repeating-linear-gradient(45deg, rgba(201,161,59,.25) 0 2px, transparent 2px 9px), repeating-linear-gradient(-45deg, rgba(201,161,59,.25) 0 2px, transparent 2px 9px); }
.mg-face { background: var(--ivory); transform: rotateY(180deg); } .mg-face img { width: 62%; }
.mg-card.show .mg-back { transform: rotateY(180deg); } .mg-card.show .mg-face { transform: rotateY(0); }
.mg-card.got .mg-face { box-shadow: 0 0 0 3px var(--gilt-aged), 0 0 14px rgba(201,161,59,.6); }
/* double or nothing */
.mg-coinstage { height: 260px; display: grid; place-items: center; gap: 4px; background: #22378a; background-image: repeating-linear-gradient(90deg, rgba(0,0,0,.18) 0 2px, transparent 2px 40px); perspective: 800px; }
.mg-coin { position: relative; width: 120px; height: 120px; transform-style: preserve-3d; transition: transform 1.2s cubic-bezier(.2,.7,.25,1); }
.mg-coin.toss { animation: coinHop 1.2s ease-out; }
@keyframes coinHop { 0% { translate: 0 0; } 45% { translate: 0 -90px; } 100% { translate: 0 0; } }
.mg-coin .f { position: absolute; inset: 0; border-radius: 50%; background: radial-gradient(circle at 40% 35%, var(--gilt-light), #c29a35 70%); border: 4px solid var(--ink); display: grid; place-items: center; backface-visibility: hidden; box-shadow: inset 0 0 0 6px var(--ink-25); }
.mg-coin .f img { width: 54%; } .mg-coin .f em { position: absolute; bottom: 12px; font: 800 11px var(--font-body); font-style: normal; color: var(--ink); letter-spacing: .1em; text-transform: uppercase; }
.mg-coin .f.t { transform: rotateY(180deg); }
.mg-pot { font: 700 18px var(--font-display); color: var(--ivory); } .mg-pot b { color: var(--gilt-light); font-size: 24px; }
/* riddles */
.mg-riddle { padding: 26px 12px; background: #2f3a2e; background-image: repeating-linear-gradient(-35deg, rgba(255,255,255,.04) 0 1px, transparent 1px 6px); }
.mg-seq { display: flex; gap: 10px; justify-content: center; align-items: center; flex-wrap: wrap; }
.mg-seq img { width: 64px; height: 64px; padding: 6px; border-radius: 8px; background: var(--ivory); border: 3px solid var(--ink); }
.mg-q { width: 64px; height: 64px; display: grid; place-items: center; border-radius: 8px; border: 3px dashed var(--gilt); color: var(--gilt); font: 800 34px var(--font-display); }
.mg .dice-table { margin: 0 auto; height: 220px; background: #3a5a3a; background-image: repeating-linear-gradient(-35deg, rgba(0,0,0,.15) 0 1px, transparent 1px 6px); align-items: center; }
.mg-wisp { animation: wispUp 4s ease-in-out infinite alternate; } @keyframes wispUp { to { transform: translateY(-14px); opacity: .15; } }
/* the outcome */
.mg-result { text-align: center; margin: 10px auto 0; max-width: 560px; }
.mg-result > b { display: block; font: 800 34px var(--font-display); }
.mg-result.win > b { color: var(--gold-2); text-shadow: 0 0 18px rgba(201,161,59,.55); } .mg-result.lose > b { color: #e8705a; }
.mg-result p { color: var(--ivory); margin: 6px 0; font-size: 16px; }
.mg-line { display: block; font-weight: 800; color: #bfe9a0; } .mg-result.lose .mg-line { color: #ff9b86; }
.mg-curse { display: grid; justify-items: center; gap: 6px; margin-top: 12px; }
.mg-curse small { color: #c9a2ea; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; font-size: 11px; }
.mg-curse .card { margin: 0; }
.mg-penalty-cards { display: flex; justify-content: center; align-items: flex-start; gap: 28px; flex-wrap: wrap; }   /* a lost card and a Curse sit side by side, so the result fits on one screen */
.mg-result.fresh > b { animation: diceSay .45s ease both; }
.mg-result.fresh .mg-curse .card { animation: curseIn 1s cubic-bezier(.2,.8,.2,1) .25s both; }
@keyframes curseIn { 0% { opacity: 0; transform: translateY(-60px) rotate(-14deg) scale(1.25); filter: brightness(2) hue-rotate(40deg); } 60% { opacity: 1; filter: brightness(1.3); } 100% { transform: none; filter: none; } }
@media (max-width: 680px) { .mg-cards { gap: 8px; padding: 10px; } .mg-seq img, .mg-q { width: 46px; height: 46px; } .mg-ctl .btn { min-width: 96px; } }

/* ---- Start, 3-2-1 countdown and tutorials ---- */
.mg-inst { position: relative; }
.mg-demo .mg-board, .mg-demo .mg-ctl, .mg-wait .mg-ctl { pointer-events: none; }
.mg-wait .mg-board { pointer-events: none; filter: saturate(.85) brightness(.92); }
.mg-tut-tag {
  position: absolute; top: 44px; left: 10px; z-index: 6; padding: 3px 10px; background: var(--claw); color: var(--ivory); border: 2px solid var(--ink);
  font: 800 11px var(--font-body); box-shadow: 2px 2px 0 rgba(30,27,22,.5); pointer-events: none; border-radius: 0 !important;
  font-family: var(--font-display) !important; font-weight: 400 !important; letter-spacing: .06em !important; text-transform: none !important;
  font-size: 13px !important;
}
.mg-startrow { display: flex; align-items: center; justify-content: center; gap: 14px; flex-wrap: wrap; margin: 12px 0 4px; }
.mg-startrow .mg-tut { color: #e9e0cb; font: italic 600 14px var(--font-body); }
.mg-startrow .mg-start { min-width: 150px; font-size: 17px; }
.mg-hand { position: absolute; left: 0; top: 0; width: 38px; height: 46px; z-index: 7; pointer-events: none; opacity: 0; transform: translate(-30%, -6%); transition: left .26s ease, top .26s ease, opacity .2s; filter: drop-shadow(2px 3px 0 var(--ink-45)); }
.mg-hand svg { width: 100%; height: 100%; display: block; }
.mg-hand.on { opacity: 1; }
.mg-hand.tap { animation: mgTap .22s ease-out; }
.mg-hand.down { transform: translate(-30%, 4%) scale(.9); }
@keyframes mgTap { 0% { transform: translate(-30%, -6%) scale(1); } 45% { transform: translate(-30%, 6%) scale(.86); } 100% { transform: translate(-30%, -6%) scale(1); } }
.mg-count { position: absolute; inset: 0; z-index: 8; display: grid; place-items: center; background: rgba(30,27,22,.28); pointer-events: auto; }
.mg-count b { font: 800 96px/1 var(--font-display); color: var(--ivory); -webkit-text-stroke: 3px var(--ink); text-shadow: 5px 5px 0 rgba(30,27,22,.6); animation: mgCount .75s ease-out both; }
.mg-count b.go { color: var(--gilt); font-size: 84px; }
@keyframes mgCount { 0% { transform: scale(1.6); opacity: 0; } 25% { transform: scale(1); opacity: 1; } 80% { opacity: 1; } 100% { transform: scale(.85); opacity: 0; } }
/* ---- Minigame Test Area (developer tool) ---- */
.lab-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin: 8px 0 4px; }
.lab-game { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 8px 8px 10px; border-radius: 8px; border: 2px solid var(--ink); background: #191f38; color: #e9e0cb; cursor: pointer; text-align: center; }
.lab-game:hover { border-color: var(--gilt); }
.lab-game b { font: 700 14px var(--font-display); color: var(--gold-2); } .lab-game small { color: #b9bfd6; font-size: 11px; }
.lab-pic { width: 100%; height: 70px; border-radius: 5px; background: #272e4c center / cover; display: grid; place-items: center; font-size: 34px; }
.lab-badge { display: inline-block; padding: 2px 8px; border-radius: 4px; font: 700 11px var(--font-body); background: #1d2851; color: #cfc4a6; }
.lab-badge.win { background: #2f5a22; color: #e6f5d8; } .lab-badge.lose { background: var(--claw); color: var(--ivory); }
.lab-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; } .lab-head h1 { margin: 0 !important; font-size: 26px !important; }
.lab-opts { display: flex; flex-wrap: wrap; gap: 8px 18px; margin-bottom: 10px; } .lab-opts > div { display: flex; align-items: center; gap: 4px; }
.lab-opts small { color: #b9bfd6; margin-right: 4px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; font-size: 10.5px; }
.lab-result { min-height: 24px; text-align: center; margin: 6px 0; color: #e9e0cb; } .lab-result b.win { color: #9fe0aa; } .lab-result b.lose { color: #ff9a8a; }
.lab-opts.shop-tabs { justify-content: flex-start; border: 0; padding: 0; }
/* the tutorial is one framed box: its title, board and buttons all sit inside the border */
.mg-inst.mg-demo { border: 3px solid var(--gilt-aged); border-radius: 10px; padding: 10px 10px 8px; background: var(--ink-35); box-shadow: inset 0 0 0 2px var(--ink), 0 0 0 2px var(--ink); }
.mg-inst.mg-demo .mg-tut-tag { top: -13px; left: 14px; }
.mg-play { position: absolute; inset: 0; z-index: 9; display: grid; place-items: center; background: var(--ink-45); border-radius: 8px; }
.mg-play-btn {
  display: inline-flex; align-items: center; gap: 12px; padding: 14px 26px; background: var(--ivory); color: var(--ink); font: 800 20px var(--font-display);
  cursor: pointer; box-shadow: 4px 4px 0 rgba(30,27,22,.6); border-radius: 0 !important; border: 2px solid var(--royal) !important;
  font-family: var(--font-display) !important; font-weight: 400 !important;
}
.mg-play-btn span { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; background: var(--claw); color: var(--ivory); font-size: 18px; border: 2px solid var(--ink); }
.mg-play-btn:hover { transform: translateY(-2px); }
.mg-ctl .btn.on { transform: translateY(2px); filter: brightness(1.15); box-shadow: inset 0 3px 0 var(--shade-25); }
/* board art: live puppets on the board, a front layer drawn over them, ink bursts, lantern flicker */
.mg-actor { position: absolute; pointer-events: none; z-index: 1; transform-origin: 50% 100%; transition: transform .12s linear; }
.mg-actor .sprite { position: absolute; inset: 0; }
.mg-actor .pp-canvas { filter: drop-shadow(0 4px 5px var(--shade-45)); }
.mg-front { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 2; }
.mg-front [style*="cursor"] { pointer-events: auto; }
.mg-burst circle { animation: mgBurst .8s ease-out forwards; }
@keyframes mgBurst { from { transform: translate(0,0); opacity: 1; } to { transform: translate(var(--dx), var(--dy)); opacity: 0; } }
.mg-flicker { animation: mgFlicker 2.6s ease-in-out infinite; }
@keyframes mgFlicker { 0%,100% { opacity: 1; } 30% { opacity: .82; } 55% { opacity: .95; } 72% { opacity: .78; } }
body.no-fx .mg-flicker { animation: none; }
@keyframes mgSpin { to { transform: rotate(360deg); } }
.mg-flow { animation: mgFlow .6s linear infinite; } @keyframes mgFlow { to { stroke-dashoffset: -22; } }
.mg-ripple { animation: mgRipple .9s ease-out forwards; transform-box: fill-box; transform-origin: center; } @keyframes mgRipple { to { transform: scale(7); opacity: 0; } }
.mg-spark { transform-box: fill-box; transform-origin: center; animation: mgSpark 1.2s ease-out forwards; } @keyframes mgSpark { to { transform: translate(6px, -60px); opacity: 0; } }
body.no-fx .mg-flow, body.no-fx .mg-spark { animation: none; }
.mg-dust { transform-box: fill-box; transform-origin: center; animation: mgDust .7s ease-out forwards; } @keyframes mgDust { to { transform: translate(-14px, -6px) scale(2.2); opacity: 0; } }
body.no-fx .mg-dust { animation: none; opacity: 0; }
/* ---- premium finish for the games drawn with page elements ---- */
/* High or Low: a felt tray in a carved wooden rim, on the roadside */
.mg .dice-table.mg-felt { width: min(440px, 86%); height: 200px; margin: 22px auto; border-radius: 22px; align-items: center;
  background: radial-gradient(ellipse at 50% 40%, #4a7a4a, #24442a 75%), #2e4a2e;
  border: 12px solid #213686; box-shadow: 0 0 0 3px var(--ink), inset 0 0 0 3px var(--ink), inset 0 10px 24px var(--shade-55), 0 14px 26px var(--shade-50);
  outline: 2px solid #c39b35; outline-offset: -8px; }
.mg .dice-table.mg-felt::before { content: ""; position: absolute; inset: 0; border-radius: 10px; background: repeating-linear-gradient(-35deg, rgba(0,0,0,.12) 0 1px, transparent 1px 6px); pointer-events: none; }
.mg .mg-felt .df { background: radial-gradient(circle at 35% 30%, #f5efe2, #e2d2ac 70%); box-shadow: inset -3px -4px 0 rgba(0,0,0,.12), inset 2px 2px 0 rgba(255,255,255,.5); }
/* Double or Nothing: an inn wall in lamplight, a table edge, a heavier coin */
.mg-coinstage.mg-inn { background: radial-gradient(ellipse at 50% 30%, rgba(224,200,141,.38), transparent 60%), linear-gradient(transparent 76%, #947528 76%, #213686 88%, #121d48 100%), repeating-linear-gradient(90deg, rgba(0,0,0,.28) 0 3px, transparent 3px 46px), linear-gradient(#1d2e73, #0f183c); box-shadow: inset 0 0 60px var(--shade-60); position: relative; }
.mg-coinstage.mg-inn::after { content: ""; position: absolute; left: 0; right: 0; top: 76%; height: 3px; background: var(--ink); }
.mg-inn .mg-coin { filter: drop-shadow(0 10px 8px var(--shade-50)); }
.mg-inn .mg-coin .f { background: radial-gradient(circle at 36% 30%, #f0e7d3, #d7b86b 34%, #a5832d 72%, #203380); box-shadow: inset 0 0 0 5px var(--ink-35), inset 0 0 0 9px #cda747, inset 0 0 0 11px var(--ink-35); }
.mg-inn .mg-coin .f::before { content: ""; position: absolute; inset: 3px; border-radius: 50%; background: repeating-conic-gradient(var(--ink-35) 0 2deg, transparent 2deg 8deg); -webkit-mask: radial-gradient(circle, transparent 66%, var(--black) 67%); mask: radial-gradient(circle, transparent 66%, var(--black) 67%); }
.mg-inn .mg-coin .f img { filter: drop-shadow(0 1px 0 rgba(255,255,255,.5)); }
.mg-inn .mg-pot { z-index: 1; text-shadow: 0 2px 4px rgba(0,0,0,.7); }
/* The Fortune Teller: a velvet cloth with a gold fringe, ornate card backs */
.mg-cards.mg-velvet { background: radial-gradient(ellipse at 50% 40%, #6a3a5e, #2e1428 80%); box-shadow: inset 0 0 0 4px var(--ink), inset 0 0 0 7px var(--gilt-aged), inset 0 0 50px var(--shade-60); padding: 20px 22px; }
.mg-velvet .mg-back { background: radial-gradient(circle at 50% 50%, var(--gilt) 0 7%, transparent 8%), radial-gradient(circle at 50% 50%, transparent 0 16%, var(--gilt) 17% 19%, transparent 20%),
  repeating-linear-gradient(45deg, rgba(201,161,59,.22) 0 2px, transparent 2px 9px), repeating-linear-gradient(-45deg, rgba(201,161,59,.22) 0 2px, transparent 2px 9px), linear-gradient(#3a1e48, #1e0e28);
  box-shadow: inset 0 0 0 4px #1e0e28, inset 0 0 0 6px var(--gilt-aged), 0 6px 10px var(--shade-45); }
.mg-velvet .mg-face { background: radial-gradient(circle at 50% 40%, #f2e9d6, #e2cc94); box-shadow: inset 0 0 0 4px var(--ivory), inset 0 0 0 6px var(--gilt-aged), 0 6px 10px var(--shade-45); }
.mg-velvet .mg-face img { filter: drop-shadow(0 2px 2px var(--shade-35)); }
/* The Scholar's Riddles: fireside at night, symbols on parchment tiles */
.mg-riddle.mg-fireside { position: relative; padding: 40px 12px 46px; }
.mg-riddle.mg-fireside::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 60%; background: radial-gradient(ellipse at 50% 100%, rgba(211,178,94,.45), transparent 70%); pointer-events: none; animation: mgFlicker 2.6s ease-in-out infinite; }
.mg-fireside .mg-seq { position: relative; z-index: 1; }
.mg-fireside .mg-seq img { background: radial-gradient(circle at 40% 35%, #f2e9d6, #dfc789); box-shadow: inset 0 0 0 3px var(--ivory), inset 0 0 0 5px var(--gilt-aged), 0 6px 10px var(--shade-50); }
.mg-fireside .mg-q { background: rgba(30,27,22,.55); box-shadow: 0 0 18px rgba(201,161,59,.45); animation: mgFlicker 1.8s ease-in-out infinite; }

/* a lost game: pick the Curse or the HP */
.mg-choose { display: grid; justify-items: center; gap: 8px; margin-top: 12px; }
.mg-choose > small { color: #e1ca91; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; font-size: 12px; }
.mg-choose-row { display: flex; gap: 22px; justify-content: center; align-items: stretch; flex-wrap: wrap; }
.mg-opt { display: grid; justify-items: center; align-content: start; gap: 8px; padding: 10px 12px; border-radius: 12px; cursor: pointer;
  background: rgba(14,20,41,.55); border: 1px solid rgba(206,170,77,.45); color: #ece0c5; font: inherit; transition: transform .12s, border-color .12s; }
.mg-opt:hover { transform: translateY(-3px); border-color: var(--gold, var(--gilt)); }
.mg-opt > span { font-weight: 800; }
.mg-opt .card { margin: 0; pointer-events: none; }
.mg-opt-hp { min-width: 170px; align-content: center; }
.mg-hp { font-size: 46px; line-height: 1; color: #e0584a; font-family: var(--font-display, serif); }
.mg-opt-hp em { font-style: normal; font-size: 12px; color: #9ca4c3; max-width: 150px; text-align: center; }
.mg-opt-curse { min-width: 170px; align-content: center; }
.mg-cardback { display: grid; place-items: center; width: 92px; height: 128px; border-radius: 10px; font: 700 54px/1 var(--font-display, serif); color: #d9b8f2;
  background: radial-gradient(circle at 50% 40%, #4a2a5e, #1f1229 75%); border: 2px solid #8e5cb3; box-shadow: inset 0 0 18px var(--shade-60); }
.mg-opt-curse em { font-style: normal; font-size: 12px; color: #9ca4c3; max-width: 160px; text-align: center; }

/* a board drawn with page elements (dice, cards, riddles, the coin) keeps its own 700px design and is scaled up with zoom (--mgk, set by the engine) to the size of the drawn boards */
.mg-board.mg-html { width: min(700px, 100%); margin: 0 auto; zoom: var(--mgk, 1); }
