/*
 * HAND DUEL COMPETITIONS: THE DUEL LAYER (js/md_handduel.js, 2026-11-30). Its own layer over a full page blur, z 99500: over
 * the popup, the guided quest card (99400) and every game dialog; never the popup's one slot.
 *   THE SPIN: .mdhd-strip is three frames in a row (art/handduel/strip.webp: rock, paper, scissors), three times as wide as
 *   its window .mdhd-hand; steps(3) moves it one frame every 80 ms. No timer in JavaScript. A hand that stands (is-h1..3) is
 *   the same strip held on its frame. The other player's hand is the same drawing mirrored.
 *   prefers-reduced-motion: the hands change slowly with a cross-fade and nothing slams.
 *   THE TRACK (.mdhd-track, a duel of more than one throw): at the foot of the picture, across its three columns: each side's
 *   throws won at the ends, between them a tile a finished throw (both hands; GOLD = this player won it, PLAIN = lost, a
 *   greyer plain = a tie, with a small mark at its corner; a hand not shown in time is a dashed ring with a clock's hands,
 *   never a hand) and a dashed slot a throw the duel can still take. Drawn by paintTrack().
 *   THE COLOURS (owner, 2026-11-30): gold is the win, the normal ink and paper are the loss. No green, no red for a result.
 * A window at most 640 px wide gets the layer full screen.
 */
.mdhd-veil { position: fixed; inset: 0; z-index: 99500; display: flex; align-items: center; justify-content: center; padding: 16px; box-sizing: border-box;
  background: rgba(24, 17, 9, .58); -webkit-backdrop-filter: blur(5px); backdrop-filter: blur(5px); opacity: 0; transition: opacity .18s ease; font-family: 'Jost', Georgia, serif; }
.mdhd-veil.is-in { opacity: 1; }
.mdhd-veil button, .mdhd-veil a { -webkit-tap-highlight-color: transparent; }
.mdhd-card { position: relative; width: 100%; max-width: 720px; max-height: 100%; overflow: auto; box-sizing: border-box; background: #f6efdc; color: #463320; border: 1px solid #b8a67a; border-radius: 12px;
  box-shadow: 0 18px 60px rgba(0, 0, 0, .5), 0 0 0 1px rgba(255, 253, 245, .5) inset; outline: none; }
.mdhd-card.mdhd-wide { max-width: 1100px; }
.mdhd-card.mdhd-narrow { max-width: 440px; }
.mdhd-top { display: flex; align-items: center; gap: 10px; padding: 9px 12px 8px 16px; border-bottom: 1px solid #d9cfb6; }
.mdhd-kicker { font-size: 11px; text-transform: uppercase; letter-spacing: 1.4px; color: #948567; }
.mdhd-roundno { font: 600 17px Georgia, serif; flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mdhd-ico { flex: none; width: 34px; height: 34px; border-radius: 50%; border: 1px solid #c9bb96; background: rgba(255, 253, 245, .8); color: #463320; font: 22px/1 Georgia, serif; cursor: pointer; padding: 0; }
.mdhd-ico:hover { background: #ffe58a; }
.mdhd-mute { background-repeat: no-repeat; background-position: center; background-size: 18px 18px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23463320' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 9v6h4l5 4V5L8 9H4z' fill='%23463320'/%3E%3Cpath d='M16.5 8.5a5 5 0 0 1 0 7M19 6a8.5 8.5 0 0 1 0 12'/%3E%3C/svg%3E"); }
.mdhd-mute.is-off { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23948567' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 9v6h4l5 4V5L8 9H4z' fill='%23948567'/%3E%3Cpath d='M17 9l5 6M22 9l-5 6'/%3E%3C/svg%3E"); }

/* the arena */
.mdhd-arena { position: relative; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 4px; padding: 14px 16px 18px; overflow: hidden;
  background: #cfc6ac url(/art/handduel/backdrop.webp) center / cover no-repeat; }
.mdhd-side { display: flex; flex-direction: column; align-items: center; min-width: 0; }
.mdhd-who { display: flex; align-items: center; gap: 8px; max-width: 100%; padding: 3px 12px 3px 4px; border-radius: 22px; background: rgba(255, 253, 245, .9); border: 1px solid #c9bb96; box-shadow: 0 2px 6px rgba(0, 0, 0, .25); }
.mdhd-av { flex: none; width: 30px; height: 40px; border-radius: 6px; overflow: hidden; background: #e7dcc0; display: flex; align-items: center; justify-content: center; }
.mdhd-av img { width: 100%; height: 100%; object-fit: cover; object-position: top center; display: block; }
.mdhd-av i { font: 600 17px Georgia, serif; font-style: normal; color: #8a7a55; }
.mdhd-name { font: 600 15px Georgia, serif; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mdhd-tag { flex: none; font-style: normal; font-size: 10px; text-transform: uppercase; letter-spacing: .8px; color: #948567; }
.mdhd-tag:empty { display: none; }
.mdhd-picked { color: #6b5226; }
.mdhd-vs { font: italic 600 22px Georgia, serif; color: #fffdf5; text-shadow: 0 0 3px #1e1408, 0 0 10px rgba(30, 20, 8, .8); padding: 0 2px; align-self: center; margin-top: 44px; }
.mdhd-hand { position: relative; width: min(220px, 34vw); aspect-ratio: 1 / 1; margin-top: 10px; overflow: hidden; filter: drop-shadow(0 6px 10px rgba(0, 0, 0, .45)); }
.mdhd-side.is-other .mdhd-hand { transform: scaleX(-1); }
.mdhd-strip { position: absolute; left: 0; top: 0; width: 300%; height: 100%; background: url(/art/handduel/strip.webp) 0 0 / 100% 100% no-repeat; will-change: transform; }
.mdhd-hand.is-spin .mdhd-strip { animation: mdhdSpin .24s steps(3) infinite; }
.mdhd-side.is-other .mdhd-hand.is-spin .mdhd-strip { animation-delay: -.08s; }
.mdhd-hand.is-h1 .mdhd-strip { transform: translateX(0); }
.mdhd-hand.is-h2 .mdhd-strip { transform: translateX(-33.3333%); }
.mdhd-hand.is-h3 .mdhd-strip { transform: translateX(-66.6667%); }
@keyframes mdhdSpin { from { transform: translateX(0); } to { transform: translateX(-100%); } }
/* a try with no result: both hands rest, open (the paper frame), never two fists */
.mdhd-hand.is-still .mdhd-strip { animation: none; transform: translateX(-33.3333%); }
.mdhd-hand.is-still { opacity: .45; filter: grayscale(1) drop-shadow(0 4px 6px rgba(0, 0, 0, .3)); }
.mdhd-hand.is-locked { filter: drop-shadow(0 0 0 #ffcc00) drop-shadow(0 0 9px rgba(255, 204, 0, .9)) drop-shadow(0 6px 10px rgba(0, 0, 0, .45)); }
/* the reveal */
.mdhd-arena.is-slam .mdhd-side.is-me .mdhd-hand { animation: mdhdSlamL .5s cubic-bezier(.5, 0, .3, 1.4) 1; }
.mdhd-arena.is-slam .mdhd-side.is-other .mdhd-hand { animation: mdhdSlamR .5s cubic-bezier(.5, 0, .3, 1.4) 1; }
@keyframes mdhdSlamL { 0% { translate: 0 0; } 45% { translate: 34% 0; scale: 1.08; } 60% { translate: 26% 0; } 100% { translate: 0 0; } }
@keyframes mdhdSlamR { 0% { translate: 0 0; } 45% { translate: -34% 0; scale: 1.08; } 60% { translate: -26% 0; } 100% { translate: 0 0; } }
.mdhd-hand.is-win { filter: drop-shadow(0 0 3px #ffe066) drop-shadow(0 0 18px rgba(255, 204, 0, 1)) drop-shadow(0 0 34px rgba(255, 190, 0, .7)); animation: mdhdWin .9s ease-out 1; }
.mdhd-hand.is-lose { opacity: .55; filter: grayscale(1) brightness(.75) drop-shadow(0 6px 8px rgba(0, 0, 0, .4)); rotate: 9deg; translate: 0 12%; transition: rotate .35s ease-in, translate .35s ease-in, opacity .35s; }
.mdhd-side.is-other .mdhd-hand.is-lose { rotate: -9deg; }
.mdhd-hand.is-lose::after { content: ''; position: absolute; inset: 0;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Cpath d='M52 8l-9 22 12 9-14 18 10 8-9 27' fill='none' stroke='%231e1408' stroke-width='2.6' stroke-linejoin='bevel'/%3E%3Cpath d='M43 30l-14 6M55 39l16-3M41 57l-13 9M51 65l15 8' fill='none' stroke='%231e1408' stroke-width='1.6'/%3E%3C/svg%3E") center / 100% 100% no-repeat; opacity: .9; }
.mdhd-hand.is-tie { animation: mdhdTie .5s ease-in-out 2; }
/* NO HAND, not shown in time: nothing on the strip, a dashed ring with a clock's hands in its place (never a hand, never the crack) */
.mdhd-hand.is-none .mdhd-strip { animation: none; opacity: 0; }
.mdhd-hand.is-none, .mdhd-hand.is-none.is-lose { opacity: .8; filter: none; rotate: 0deg; translate: 0 0; }
.mdhd-hand.is-none::after, .mdhd-hand.is-none.is-lose::after { content: ''; position: absolute; inset: 16%; border-radius: 50%; background: rgba(255, 253, 245, .5) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23463320' stroke-width='1.8' stroke-linecap='round'%3E%3Ccircle cx='12' cy='12' r='9' stroke-dasharray='3.2 3'/%3E%3Cpath d='M12 7.5V12l3 2.2'/%3E%3C/svg%3E") center / 100% 100% no-repeat; opacity: .85; }
@keyframes mdhdWin { 0% { scale: 1; } 35% { scale: 1.12; } 100% { scale: 1; } }
@keyframes mdhdTie { 0%, 100% { translate: 0 0; } 25% { translate: -5% 0; } 75% { translate: 5% 0; } }

/* the track of throws */
.mdhd-track { grid-column: 1 / -1; display: flex; align-items: center; justify-content: center; gap: 10px; margin-top: 14px; min-width: 0; }
.mdhd-track.is-off { display: none; }
.mdhd-sc { flex: none; min-width: 36px; height: 36px; box-sizing: border-box; padding: 0 8px; border-radius: 18px; border: 1px solid #c9bb96; background: rgba(255, 253, 245, .94); color: #2b1d0e;
  font: 600 20px/34px Georgia, serif; font-variant-numeric: tabular-nums; text-align: center; box-shadow: 0 2px 6px rgba(0, 0, 0, .28); }
.mdhd-tiles { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 9px 8px; min-width: 0; padding: 5px 4px; }
.mdhd-t { position: relative; flex: none; display: inline-flex; align-items: center; justify-content: center; gap: 2px; box-sizing: border-box; height: 36px; min-width: 36px; padding: 0 5px; border-radius: 9px;
  border: 2px solid #c9bb96; background: #fffdf5; box-shadow: 0 2px 6px rgba(0, 0, 0, .28); }
.mdhd-th { display: block; width: 25px; height: 25px; background: center / contain no-repeat; }
.mdhd-th.is-his { transform: scaleX(-1); }
/* a hand not shown in time: no hand at all */
.mdhd-th.is-none { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23463320' stroke-width='1.8' stroke-linecap='round'%3E%3Ccircle cx='12' cy='12' r='9' stroke-dasharray='3.2 3'/%3E%3Cpath d='M12 7.5V12l3 2.2'/%3E%3C/svg%3E"); background-size: 86% 86%; opacity: .7; }
.mdhd-t::after { content: ''; position: absolute; right: -8px; top: -8px; width: 17px; height: 17px; border-radius: 50%; border: 1.5px solid #fffdf5; background: #8a7a55 center / 11px 11px no-repeat; box-shadow: 0 1px 3px rgba(0, 0, 0, .35); }
.mdhd-t.is-won { border-color: #d9a800; background: #fff3c2; box-shadow: 0 0 0 1px rgba(255, 224, 102, .9), 0 0 10px rgba(255, 204, 0, .75), 0 2px 6px rgba(0, 0, 0, .28); }
.mdhd-t.is-won .mdhd-th.is-his, .mdhd-t.is-lost .mdhd-th:not(.is-his) { opacity: .38; filter: grayscale(1); }
.mdhd-t.is-won::after { background-color: #ffcc00; border-color: #fff6cf; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M2.2 6.4l2.5 2.6 5-5.8' fill='none' stroke='%23463320' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"); }
.mdhd-t.is-lost { border-color: #b8a67a; background: #fffdf5; }
.mdhd-t.is-lost::after { background-color: #8a7a55; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M3 3l6 6M9 3l-6 6' fill='none' stroke='%23fff' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E"); }
.mdhd-t.is-tie { border-color: #a39675; background: #efe9d8; }
.mdhd-t.is-tie::after { background-color: #b5a988; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M3 4.3h6M3 7.7h6' fill='none' stroke='%23fff' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E"); }
.mdhd-t.is-open { border-style: dashed; border-color: rgba(255, 253, 245, .85); background: rgba(255, 253, 245, .22); box-shadow: none; }
.mdhd-t.is-open::after { display: none; }
.mdhd-t.is-new { animation: mdhdTile .45s cubic-bezier(.3, 1.5, .5, 1) 1; }
@keyframes mdhdTile { 0% { scale: .3; opacity: 0; } 100% { scale: 1; opacity: 1; } }
/* a try with no result: its throws count for nothing */
.mdhd-track.is-dead .mdhd-t, .mdhd-track.is-dead .mdhd-sc { opacity: .45; filter: grayscale(1); }

/* the words, the bar, the hands to pick from */
.mdhd-line { min-height: 44px; padding: 10px 18px 4px; text-align: center; font-size: 15px; line-height: 1.4; overflow-wrap: anywhere; }
.mdhd-line.is-won { font: 600 19px/1.35 Georgia, serif; color: #9a6b00; }
.mdhd-line.is-lost { font: 600 19px/1.35 Georgia, serif; color: #463320; }
.mdhd-line.is-tie { font: 600 19px/1.35 Georgia, serif; color: #6b5226; }
.mdhd-line.is-void { color: #6b5226; }
.mdhd-line.is-err { color: #8f2a1e; }
.mdhd-bar { position: relative; height: 22px; margin: 6px 18px 4px; border-radius: 11px; background: rgba(120, 94, 58, .16); border: 1px solid #c9bb96; overflow: hidden; }
.mdhd-bar i { position: absolute; left: 0; top: 0; bottom: 0; width: 100%; border-radius: 10px; background: linear-gradient(90deg, #cc9900, #ffcc00); transition: width .2s linear; }
.mdhd-bar.is-red i { background: linear-gradient(90deg, #8f2a1e, #e0352b); }
.mdhd-secs { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font: 600 13px Georgia, serif; font-variant-numeric: tabular-nums; color: #2b1d0e; text-shadow: 0 0 3px #fffdf5, 0 0 3px #fffdf5; }
.mdhd-bar.is-red .mdhd-secs { color: #fffdf5; text-shadow: 0 0 3px #5c1a12, 0 0 3px #5c1a12; }
.mdhd-bar.is-off, .mdhd-menu.is-off { display: none; }
.mdhd-menu { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; padding: 8px 18px 6px; }
.mdhd-pick { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 4px 7px; border: 1px solid #c2a34e; border-radius: 10px; background: #fffdf5; color: #463320; cursor: pointer; min-height: 96px; font-family: inherit;
  transition: background .12s, box-shadow .12s, border-color .12s; }
/* the button itself never moves under the pointer: a lift made it leave a pointer resting on its edge, and come back, for ever */
.mdhd-pick:hover, .mdhd-pick:focus-visible { background: #fff3c2; border-color: #a8792a; box-shadow: 0 4px 12px rgba(120, 94, 58, .32); outline: none; }
.mdhd-pick:active { background: #ffe58a; box-shadow: none; }
.mdhd-pimg { display: block; width: 84px; max-width: 100%; aspect-ratio: 1 / 1; background: center / contain no-repeat; }
.mdhd-pick b { font: 600 13px Georgia, serif; text-transform: capitalize; }
.mdhd-foot { display: flex; align-items: center; justify-content: center; gap: 16px; padding: 8px 18px 14px; flex-wrap: wrap; }
.mdhd-foot:empty { padding: 0 0 12px; }
.mdhd-btn { font: 15px 'Jost', sans-serif; color: #463320; background: #ffcc00; border: 1px solid #c2a34e; border-radius: 5px; padding: 7px 22px; cursor: pointer; min-height: 38px; }
.mdhd-btn:hover { background: #ffd83d; }
.mdhd-btn.mdhd-quiet { background: rgba(255, 253, 245, .9); }
.mdhd-link { color: #a8792a; font-size: 14px; text-decoration: none; border-bottom: 1px solid #c79c47; }
.mdhd-link:hover { color: #463320; }

/* the map, the sign-up, a line of why */
.mdhd-why { margin: 12px 16px 0; padding: 8px 12px; border: 1px solid #d9cfb6; border-radius: 6px; background: rgba(255, 253, 245, .7); font-size: 14.5px; overflow-wrap: anywhere; }
.mdhd-map { margin: 12px 16px 0; --hdm-h: min(560px, calc(100vh - 240px)); }
.mdhd-wait { color: #948567; text-align: center; margin: 24px 0; }
.mdhd-body { padding: 0 16px; }
.mdhd-msg:empty { display: none; }
.mdhd-msg { margin: 12px 16px 0; padding: 8px 12px; border-radius: 6px; border: 1px solid #d9cfb6; font-size: 14.5px; }
.mdhd-msg.is-ok { color: #336633; background: rgba(214, 240, 210, .6); border-color: #a9cfa1; }
.mdhd-msg.is-err { color: #8f2a1e; background: rgba(255, 228, 222, .7); border-color: #d9a59c; }
.hds { padding: 12px 0 4px; color: #463320; font-size: 14px; line-height: 1.45; overflow-wrap: anywhere; }
.hds p { margin: 0 0 8px; }
.hds-art { display: block; width: 100%; aspect-ratio: 1536 / 432; object-fit: cover; border-radius: 8px; border: 1px solid #d9cfb6; }
.hds-title { font: 600 19px Georgia, serif; text-align: center; margin: 8px 0 6px; }
.hds-facts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin: 0 0 8px; }
.hds-facts div { border: 1px solid #ebe3cc; border-radius: 6px; padding: 4px 4px; text-align: center; background: rgba(255, 253, 245, .7); min-width: 0; }
.hds-facts span { display: block; font-size: 9.5px; text-transform: uppercase; letter-spacing: .6px; color: #948567; }
.hds-facts b { font: 600 13px Georgia, serif; }
.hds-note, .hds-muted { color: #948567; font-size: 13px; }
.hds-err { color: #8f2a1e; }
.hds-actions { text-align: center; margin: 4px 0 2px; }
.hds-btn { font: 16px 'Jost', sans-serif; color: #463320; background: #ffcc00; border: 1px solid #c2a34e; border-radius: 5px; padding: 8px 30px; cursor: pointer; min-height: 40px; }
.hds-btn:hover { background: #ffd83d; }
.hds-btn:disabled { opacity: .55; cursor: default; }

/* THE FILM (story() of js/md_handduel.js): The unavoidable anomaly, the bare page anomaly.php in a frame that fills the card under its head */
.mdhd-card.mdhd-film { max-width: 1180px; overflow: hidden; }
.mdhd-story { position: relative; height: min(700px, calc(100vh - 100px)); background: #f6eed8; }
.mdhd-story iframe { position: absolute; left: 0; top: 0; display: block; width: 100%; height: 100%; border: 0; }

/* the guide's playable duel sits in the page, not over it */
.mdhd-card.mdhd-demo { max-width: 620px; margin: 0 auto; max-height: none; box-shadow: 0 4px 16px rgba(60, 40, 10, .18); }
.mdhd-card.mdhd-demo .mdhd-hand { width: min(180px, 30vw); }

@media (max-width: 640px) {
  .mdhd-veil { padding: 0; align-items: stretch; }
  .mdhd-card, .mdhd-card.mdhd-wide, .mdhd-card.mdhd-narrow { max-width: none; width: 100%; height: 100%; max-height: none; border-radius: 0; border: 0; display: flex; flex-direction: column; }
  .mdhd-arena { flex: 1 1 auto; align-content: center; padding: 12px 8px 16px; }
  .mdhd-hand { width: min(190px, 40vw); }
  .mdhd-vs { font-size: 17px; margin-top: 40px; }
  /* a duel of five with one tie stays on one row of a 390 px phone: 6 tiles of 46 px, 5 gaps of 4 */
  .mdhd-track { gap: 6px; margin-top: 12px; }
  .mdhd-sc { min-width: 30px; height: 30px; font-size: 17px; line-height: 28px; padding: 0 5px; }
  .mdhd-tiles { gap: 9px 4px; padding: 5px 0; }
  .mdhd-t { height: 30px; min-width: 30px; padding: 0 2px; border-radius: 8px; }
  .mdhd-th { width: 18px; height: 18px; }
  .mdhd-t::after { right: -6px; top: -7px; width: 15px; height: 15px; background-size: 10px 10px; }
  .mdhd-name { font-size: 13.5px; max-width: 24vw; }
  .mdhd-menu { gap: 8px; padding: 8px 10px 6px; }
  .mdhd-pick { min-height: 104px; }
  .mdhd-line { padding: 10px 12px 4px; font-size: 14.5px; }
  .mdhd-bar { margin: 6px 12px 4px; height: 24px; }
  .mdhd-map { flex: 1 1 auto; margin: 10px 8px 0; --hdm-h: calc(100vh - 230px); }
  .mdhd-story { flex: 1 1 auto; height: auto; min-height: 0; }
  .mdhd-card.mdhd-demo { height: auto; border: 1px solid #b8a67a; border-radius: 10px; }
  .mdhd-card.mdhd-demo .mdhd-hand { width: min(150px, 36vw); }
}
@media (prefers-reduced-motion: reduce) {
  .mdhd-veil { transition: none; }
  .mdhd-hand.is-spin .mdhd-strip { animation: mdhdSpin 2.4s steps(3) infinite, mdhdFade .8s ease-in-out infinite; }
  .mdhd-arena.is-slam .mdhd-side .mdhd-hand, .mdhd-hand.is-win, .mdhd-hand.is-tie, .mdhd-t.is-new { animation: none; }
  .mdhd-hand.is-lose { transition: none; }
  .mdhd-pick { transition: none; }
}
@keyframes mdhdFade { 0%, 100% { opacity: .35; } 18%, 82% { opacity: 1; } }
