/* Beat the Phone: a group game for one phone. Its colour (olive) is set in logicers.css ([data-g="beat"]).
   Four views (start, passing the phone, a stop, the end) and windows for the names, the journey, the table's best.
   Everything fits a 320 by 568 phone without scrolling; if a view is still too high, the script steps it down
   (fit1 to fit3). A game's own classes carry the prefix b-, so that the frame's names never reach into it. */

.b-view { margin-top: 6px; }

/* ---------- the start ---------- */
.b-title { font-family: var(--display); font-weight: 800; font-size: clamp(1.6rem, 7.4vw, 2.2rem); line-height: 1.04; letter-spacing: -0.035em; margin-top: 6px; text-wrap: balance; }
.b-lede { margin-top: 10px; color: var(--soft); font-size: 1.02rem; line-height: 1.4; }
.b-friend { margin: 12px 0 0; padding: 10px 14px; border-radius: 16px; background: var(--card); box-shadow: var(--shadow); line-height: 1.3; font-weight: 500; }
.b-players { display: flex; align-items: center; gap: 8px; margin-top: 16px; padding: 8px 8px 8px 16px; border-radius: 999px; background: var(--card); box-shadow: var(--shadow); }
.b-players-label { font-weight: 700; margin-right: auto; }
.b-step { appearance: none; border: 0; width: 42px; height: 42px; border-radius: 50%; background: var(--tint); color: var(--c); font-weight: 800; font-size: 1.4rem; line-height: 1; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; -webkit-tap-highlight-color: transparent; }
.b-step[disabled] { opacity: .35; cursor: default; }
.b-count { min-width: 1.6ch; text-align: center; font-family: var(--display); font-weight: 800; font-size: 1.6rem; font-variant-numeric: tabular-nums; }
.b-names-btn { appearance: none; border: 0; height: 42px; padding: 0 16px; border-radius: 999px; background: var(--c); color: var(--on-c); font-weight: 700; font-size: 0.92rem; cursor: pointer; margin-left: 4px; -webkit-tap-highlight-color: transparent; }
.b-names { margin: 8px 4px 0; color: var(--soft); font-size: 0.9rem; font-weight: 600; line-height: 1.35; min-height: 1.35em; }
/* balanced lines: on a phone a small line splits in the middle, instead of leaving "· no map" alone on the second line
   (each "·" is tied to the word before it, so that a line never starts with one) */
.b-small { margin-top: 10px; color: var(--soft); font-size: 0.88rem; line-height: 1.35; text-wrap: balance; }
#v-start .actions { margin-top: 14px; }

/* ---------- a stop ---------- */
.b-top { display: flex; align-items: center; gap: 12px; margin-top: 4px; }
.b-route { appearance: none; border: 0; background: none; padding: 7px 4px; margin: 0 0 0 -4px; flex: 1 1 auto; min-width: 0; cursor: pointer; border-radius: 12px; -webkit-tap-highlight-color: transparent; }
.b-strip { list-style: none; margin: 0; padding: 0; position: relative; display: flex; align-items: center; justify-content: space-between; height: 18px; }
.b-strip::before { content: ""; position: absolute; left: 6px; right: 6px; top: 50%; height: 2px; margin-top: -1px; border-radius: 2px; background: color-mix(in srgb, var(--c) 30%, transparent); }
.b-dot { position: relative; width: 11px; height: 11px; border-radius: 50%; background: var(--tint); box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--soft) 55%, transparent); flex: none; }
.b-dot.done { background: var(--c); box-shadow: none; }
.b-dot.now { width: 17px; height: 17px; background: var(--card); box-shadow: inset 0 0 0 4px var(--c), 0 0 0 3px color-mix(in srgb, var(--c) 22%, transparent); }
.b-dot.end { width: 17px; height: 17px; background: var(--miss); box-shadow: inset 0 0 0 2px #15172B; }
.b-dot.lost::after { content: ""; position: absolute; left: 50%; bottom: -8px; width: 5px; height: 5px; margin-left: -2.5px; border-radius: 50%; background: var(--miss); }
.b-lives { display: flex; gap: 3px; flex: none; }
.b-heart { width: 22px; height: 22px; }
.b-heart path { fill: var(--c); }
.b-heart.lost path { fill: none; stroke: #C98A06; stroke-width: 1.8; }
.b-heart.now { animation: b-pop .5s ease; }
@keyframes b-pop { 0% { transform: scale(1); } 40% { transform: scale(1.35); } 100% { transform: scale(1); } }

.b-kicker { margin-top: 6px; color: var(--soft); font-size: 0.86rem; font-weight: 700; line-height: 1.2; }
.b-stop { font-family: var(--display); font-weight: 800; font-size: 2.1rem; line-height: 1.02; letter-spacing: -0.035em; margin-top: 1px; overflow-wrap: anywhere; text-wrap: balance; }
.b-stop.long { font-size: 1.62rem; }
.b-q { margin-top: 9px; padding: 10px 16px 11px; border-radius: 22px; background: var(--c); color: #fff; box-shadow: 0 10px 26px rgba(21, 23, 43, .14); }
.b-head { font-family: var(--display); font-weight: 800; font-size: 1.42rem; line-height: 1.08; letter-spacing: -0.03em; margin: 0; text-wrap: balance; }
.b-line { margin-top: 3px; font-size: 0.86rem; line-height: 1.25; font-weight: 500; opacity: .92; }
.b-who { font-size: 0.86rem; font-weight: 600; line-height: 1.2; opacity: .94; margin-bottom: 2px; overflow-wrap: anywhere; }
.b-who b { font-weight: 800; }
.b-ask { appearance: none; border: 0; width: 100%; display: flex; align-items: center; gap: 8px; min-height: 40px; margin-top: 8px; padding: 0 14px 0 11px; border-radius: 14px; background: var(--card); color: var(--ink); box-shadow: var(--shadow); font: inherit; font-weight: 700; font-size: 0.92rem; text-align: left; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.b-ask svg { width: 22px; height: 22px; color: var(--c); flex: none; }
.b-ask-t { flex: 1 1 auto; min-width: 0; }
.b-ask-n { flex: none; color: var(--soft); font-weight: 700; font-size: 0.82rem; }
.b-ask[disabled] { cursor: default; box-shadow: inset 0 0 0 1px var(--line); background: transparent; color: var(--soft); }
.b-ask[disabled] svg { color: var(--soft); }
.b-ask:active { transform: scale(0.97); }
.b-ask[disabled]:active { transform: none; }

.b-pair { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: 6px; }
.b-ans { appearance: none; border: 0; min-height: 88px; padding: 8px 8px; border-radius: 18px; background: var(--card); color: var(--ink); box-shadow: var(--shadow); cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; text-align: center; -webkit-tap-highlight-color: transparent; transition: background-color .2s ease, color .2s ease, transform .12s ease; }
.b-ans-n { font-weight: 800; font-size: 1.08rem; line-height: 1.12; overflow-wrap: anywhere; hyphens: auto; }
.b-ans-n.long { font-size: 0.94rem; }
.b-ans-v { font-size: 0.86rem; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; white-space: nowrap; }
@media (max-width: 379px) { .b-ans-v.is-area { font-size: 0.76rem; } }      /* "17,125,190 km²" fits a narrow answer */
.b-ans:active { transform: scale(0.97); }
.b-ans.on { background: var(--c); color: #fff; box-shadow: 0 6px 16px color-mix(in srgb, var(--c) 35%, transparent); }
.b-ans.right { background: color-mix(in srgb, var(--c) 16%, var(--card)); color: var(--ink); box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--c) 55%, transparent); cursor: default; }
.b-ans.right .b-ans-v { color: var(--c); }
.b-ans.wrong { background: var(--miss); color: #15172B; box-shadow: none; cursor: default; }
.b-ans.other { cursor: default; }
.b-ans.other .b-ans-v { color: var(--soft); }
.b-ans.right:active, .b-ans.wrong:active, .b-ans.other:active { transform: none; }
.b-ans.flip { animation: b-flip .42s ease; }
@keyframes b-flip { 0% { transform: rotateY(0); } 45% { transform: rotateY(90deg); } 100% { transform: rotateY(0); } }

.b-say { margin-top: 8px; padding: 7px 12px; border-radius: 14px; background: var(--card); box-shadow: var(--shadow); font-size: 0.9rem; line-height: 1.3; font-weight: 500; }
.b-say b { font-weight: 800; }
.b-ok { color: var(--c); }
.b-no { display: inline-block; padding: 0 .4em; border-radius: 7px; background: var(--miss); color: #15172B; }
.b-say-tail { font-weight: 700; }
.b-src { margin-top: 5px; color: var(--soft); font-size: 0.76rem; line-height: 1.3; }
.b-src a { color: inherit; text-underline-offset: 2px; }
.b-play-actions { margin-top: 8px; }

/* ---------- passing the phone: a whole screen in the game's colour ---------- */
.b-hand { margin-top: 4px; min-height: min(27rem, calc(100vh - 150px)); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px;
  padding: 22px 18px 24px; border-radius: 28px; background: var(--c); color: #fff; text-align: center; box-shadow: 0 14px 34px rgba(21, 23, 43, .18);
  animation: b-hand-in .28s ease-out both; }
@keyframes b-hand-in { from { opacity: 0; transform: translateY(18px) scale(.985); } }
.b-hand-res { max-width: 25rem; margin: 0; padding: 10px 14px; border-radius: 16px; background: rgba(255, 255, 255, .15); font-size: 0.95rem; line-height: 1.35; font-weight: 500; }
.b-hand-res b { font-weight: 800; }
.b-hand-ok { color: #fff; }
.b-hand-ico { width: 76px; height: 48px; margin-top: 4px; }
.b-hand-t { margin: 0; display: flex; flex-direction: column; align-items: center; gap: 2px; width: 100%; }
.b-hand-k { font-size: 1.12rem; font-weight: 600; opacity: .94; }
.b-hand-name { display: block; max-width: 100%; overflow: hidden; white-space: nowrap; font-family: var(--display); font-weight: 800; font-size: 3.2rem; line-height: 1.08; letter-spacing: -0.025em; }
.b-hand-line { max-width: 24rem; font-size: 0.98rem; font-weight: 600; line-height: 1.3; opacity: .95; }
.b-hand-go { margin-top: 6px; min-height: 56px; min-width: min(100%, 17rem); padding: 0 24px; border: 0; border-radius: 999px; background: #fff; color: var(--c); font-weight: 800; font-size: 1.05rem; box-shadow: 0 6px 16px rgba(21, 23, 43, .16); }
.b-hand-go:focus-visible { outline: 3px solid #fff; outline-offset: 3px; }
.b-hand-small { text-align: center; }

/* ---------- the end ---------- */
.b-reveal { padding: 14px 18px 15px; margin-top: 4px; }
.b-end-k { font-weight: 700; font-size: 0.9rem; opacity: .9; }
.b-end-head { font-family: var(--display); font-weight: 800; font-size: 2.1rem; line-height: 1.02; letter-spacing: -0.035em; margin-top: 2px; text-wrap: balance; }
.b-end-line { margin-top: 6px; font-weight: 600; font-size: 1rem; line-height: 1.25; }
.b-trip { list-style: none; margin: 10px 0 0; padding: 6px 10px; border-radius: 16px; background: var(--card); box-shadow: var(--shadow);
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); grid-template-rows: repeat(5, auto); grid-auto-flow: column; column-gap: 10px; }
.b-trip-i { display: flex; align-items: center; gap: 6px; min-height: 27px; font-size: 0.88rem; line-height: 1.15; min-width: 0; }
.b-trip-n { flex: none; width: 1.45em; height: 1.45em; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: 0.72rem; font-weight: 800; background: var(--c); color: var(--on-c); }
.b-trip-c { font-weight: 700; min-width: 0; overflow-wrap: break-word; }
@media (max-width: 419px) { .b-trip-c.long { font-size: 0.78rem; line-height: 1.1; } }
.b-trip-m { margin-left: auto; flex: none; display: inline-flex; align-items: center; gap: 3px; font-size: 0.8rem; font-weight: 800; }
.b-trip-m i { font-style: normal; }
.b-x { width: 8px; height: 8px; border-radius: 50%; background: var(--miss); box-shadow: inset 0 0 0 1px rgba(21, 23, 43, .25); }
.b-v { color: var(--c); }
.b-trip-i.ahead { color: var(--soft); }
.b-trip-i.ahead .b-trip-n { background: transparent; color: var(--soft); box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--soft) 60%, transparent); }
.b-trip-i.end .b-trip-n { background: var(--miss); color: #15172B; }
.b-best { margin: 9px 2px 0; color: var(--soft); font-weight: 600; font-size: 0.9rem; line-height: 1.3; min-height: 1.3em; }
#v-end .actions { margin-top: 10px; }
.b-end-small { margin-top: 8px; }
.b-link { appearance: none; border: 0; background: none; padding: 4px 2px; color: var(--soft); font: inherit; font-weight: 600; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; border-radius: 6px; }

/* ---------- windows: names, the journey, the table's best, sources ---------- */
.b-name-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: 14px; }
.b-name-field { display: flex; align-items: center; gap: 8px; padding: 0 10px; border-radius: 12px; background: var(--bg); box-shadow: inset 0 0 0 1px var(--line); }
.b-name-n { color: var(--soft); font-weight: 800; font-size: 0.86rem; min-width: 1ch; }
.b-name-field input { flex: 1 1 auto; width: 100%; min-width: 0; height: 42px; border: 0; padding: 0; background: transparent; color: var(--ink); font: inherit; font-weight: 600; outline: none; }
.b-name-field:focus-within { box-shadow: inset 0 0 0 2px var(--c); }
.sheet .b-jroute { list-style: none; margin: 12px 0 0; padding: 0; }
.sheet .b-jr { margin: 0; display: flex; align-items: center; gap: 7px; padding: 5px 0; border-top: 1px solid var(--line); font-size: 0.92rem; min-width: 0; }
.b-jr-n { flex: none; width: 1.5em; height: 1.5em; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: 0.74rem; font-weight: 800; background: var(--c); color: var(--on-c); }
.b-jr-c { font-weight: 700; min-width: 0; overflow-wrap: anywhere; }
.b-jr-s { margin-left: auto; color: var(--c); font-weight: 800; font-size: 0.8rem; white-space: nowrap; }
.b-jr.ahead { color: var(--soft); }
.b-jr.ahead .b-jr-n { background: transparent; color: var(--soft); box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--soft) 60%, transparent); }
.b-jr.now .b-jr-n { background: var(--card); color: var(--c); box-shadow: inset 0 0 0 2.5px var(--c); }
.b-jr.end .b-jr-n { background: var(--miss); color: #15172B; }
.b-jr.end .b-jr-s { color: var(--soft); }
.sheet .b-jqs { list-style: none; margin: 8px 0 0; padding: 0; }
.sheet .b-jq { margin: 0; padding: 9px 0 10px; border-top: 1px solid var(--line); }
.sheet .b-jq p { margin: 0; }
.b-jq-k { color: var(--soft); font-size: 0.8rem; font-weight: 700; }
.b-jq-h { margin-top: 2px; font-size: 0.98rem; line-height: 1.3; }
.b-jq-h b { font-weight: 800; }
.b-jq-h .b-ok { font-weight: 800; }
.b-jq-f { margin-top: 3px; font-size: 0.9rem; line-height: 1.35; }
.b-jq-s { margin-top: 3px; color: var(--soft); font-size: 0.8rem; line-height: 1.3; }
.b-jq-s a { color: inherit; }
.b-best-body { margin-top: 12px; font-family: var(--display); font-weight: 700; font-size: 1.2rem; line-height: 1.25; }
.b-sources { margin: 8px 0 0; padding-left: 1.1em; color: var(--soft); font-size: 0.88rem; line-height: 1.35; }
.b-sources li { margin-top: 4px; }
.b-sources a { color: inherit; text-underline-offset: 2px; }
#dlg-quit .actions { flex-wrap: wrap; }
#dlg-quit .actions .btn { flex: 1 1 auto; }

/* ---------- dark ---------- */
@media (prefers-color-scheme: dark) {
  .b-friend, .b-players, .b-ans, .b-say, .b-trip, .b-ask { background: rgba(255, 255, 255, .055); box-shadow: inset 0 0 0 1px var(--line); }
  .b-ask[disabled] { background: transparent; box-shadow: inset 0 0 0 1px var(--line); }
  .b-step { background: rgba(255, 255, 255, .08); }
  .b-names-btn { color: #0A0C1A; }
  .b-q { background: linear-gradient(180deg, color-mix(in srgb, var(--c) 26%, #0D1022), #0D1022 92%); color: var(--ink); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--c) 50%, transparent), 0 0 36px color-mix(in srgb, var(--c) 14%, transparent); }
  .b-q .b-head { color: #fff; }
  .b-dot { background: var(--bg); }
  .b-dot.now { background: var(--bg); box-shadow: inset 0 0 0 4px var(--c), 0 0 12px color-mix(in srgb, var(--c) 45%, transparent); }
  .b-heart.lost path { stroke: var(--miss); }
  .b-ans.on { background: var(--c); color: #0A0C1A; box-shadow: 0 0 18px color-mix(in srgb, var(--c) 40%, transparent); }
  .b-ans.right { background: color-mix(in srgb, var(--c) 18%, #12152A); color: var(--ink); box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--c) 60%, transparent); }
  .b-ans.wrong { background: var(--miss); color: #15172B; }
  .b-name-field { background: rgba(255, 255, 255, .06); }
  .b-jr.now .b-jr-n { background: transparent; }
  .b-hand { background: linear-gradient(180deg, color-mix(in srgb, var(--c) 30%, #0D1022), #0D1022 94%); color: var(--ink); box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--c) 55%, transparent), 0 0 40px color-mix(in srgb, var(--c) 16%, transparent); }
  .b-hand-name { color: #fff; }
  .b-hand-res { background: rgba(255, 255, 255, .07); }
  .b-hand-ok { color: var(--c); }
  .b-hand-ico { color: var(--c); }
  .b-hand-go { background: var(--c); color: #0A0C1A; box-shadow: 0 0 22px color-mix(in srgb, var(--c) 35%, transparent); }
  .b-hand-go:focus-visible { outline-color: var(--c); }
}

/* ---------- small and short screens: a little tighter, so that nothing scrolls ---------- */
@media (max-height: 37.5rem) {
  body[data-view="play"] .meta, body[data-view="hand"] .meta { display: none; }      /* a small phone: the stop (or the hand-off) is the heading */
  .b-hand { gap: 9px; padding: 16px 14px 18px; }
  .b-hand-name { font-size: 2.7rem; }
  .b-title { font-size: 1.5rem; }
  .b-lede { font-size: 0.95rem; margin-top: 8px; }
  .b-players { margin-top: 12px; }
  .b-stop { font-size: 1.85rem; }
  .b-stop.long { font-size: 1.45rem; }
  .b-q { padding: 9px 14px 10px; margin-top: 7px; }
  .b-head { font-size: 1.28rem; }
  .b-line { font-size: 0.8rem; }
  .b-ans { min-height: 78px; }
  .b-say { font-size: 0.85rem; padding: 6px 11px; margin-top: 6px; }
  .b-reveal { padding: 10px 14px 11px; }
  .b-end-head { font-size: 1.8rem; }
}
@media (min-width: 56rem) {
  .b-title { font-size: 2.4rem; }
  .b-stop { font-size: 2.5rem; }
  .b-head { font-size: 1.6rem; }
  .b-ans { min-height: 96px; }
  .b-ans-n { font-size: 1.18rem; }
}
@media (prefers-reduced-motion: reduce) {
  .b-hand { animation: none; }
  .b-ans { transition: none; }
  .b-ans:active, .b-ask:active { transform: none; }
  .b-ans.flip { animation: none; }
  .b-heart.now { animation: none; }
}

/* a view must fit without scrolling: if it does not, the script steps down (fit1 to fit3) */
body.fit1 .b-title { font-size: 1.32rem; }
body.fit1 .b-lede { font-size: 0.88rem; margin-top: 6px; line-height: 1.32; }
body.fit1 .b-friend { margin-top: 8px; padding: 7px 12px; font-size: 0.88rem; }
body.fit1 .b-players { margin-top: 10px; padding-top: 5px; padding-bottom: 5px; }
body.fit2 #v-start .b-small { display: none; }
body.fit2 .b-names { font-size: 0.8rem; }
body.fit3 .b-names { display: none; }
body.fit1 .b-stop { font-size: 1.6rem; }
body.fit1 .b-stop.long { font-size: 1.3rem; }
body.fit1 .b-q { padding: 8px 13px 9px; margin-top: 6px; }
body.fit1 .b-head { font-size: 1.18rem; }
body.fit1 .b-ans { min-height: 70px; padding: 6px; }
body.fit1 .b-say { font-size: 0.8rem; padding: 5px 10px; }
body.fit1 .b-ask { min-height: 36px; margin-top: 6px; }
body.fit1 .b-reveal { padding: 8px 14px 9px; }
body.fit1 .b-end-head { font-size: 1.5rem; }
body.fit1 .b-trip-i { min-height: 24px; font-size: 0.82rem; }
body.fit1 #v-end .actions .btn, body.fit1 .b-play-actions .btn { min-height: 48px; }
body.fit2 .meta { display: none; }
body.fit2 .b-kicker { font-size: 0.78rem; margin-top: 3px; }
body.fit2 .b-src { font-size: 0.7rem; margin-top: 3px; }
body.fit2 .b-ans { min-height: 62px; }
body.fit2 .b-end-line { font-size: 0.88rem; margin-top: 3px; }
body.fit2 .b-best { font-size: 0.82rem; margin-top: 6px; }
body.fit3 .b-line { display: none; }
body.fit3 .b-end-k { display: none; }
body.fit3 .b-ans { min-height: 56px; }
body.fit3 .b-ans-n { font-size: 0.98rem; }
body.fit3 .b-trip-i { min-height: 22px; font-size: 0.78rem; }
body.fit1 .b-hand { min-height: 0; gap: 8px; padding: 14px 12px 16px; }
body.fit2 .b-hand-ico { display: none; }
body.fit3 .b-hand-res { font-size: 0.84rem; padding: 7px 10px; }
