/*!
 * MBG Puzzles - home screen, subscription screen and the "free game used" card.
 * Builds on game.css (colours, fonts, buttons, dialogs); nothing here redefines a colour.
 * Home layout: one column, thumb-first. Plan status on top, the 2-for-1 note, then the
 * two games as large cards with a row of clue tiles in their own colours.
 */

/* ------------------------------------------------------------ home */
body.home-page { overflow-y: auto; }
.home {
  margin: 0 auto; width: 100%; max-width: 640px; min-height: 100%;
  display: flex; flex-direction: column; gap: 14px;
  padding-block: max(10px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-bottom));
  padding-inline: max(16px, env(safe-area-inset-left)) max(16px, env(safe-area-inset-right));
}
.home .brandtext { display: flex; }
.home .appname { font-size: 18px; }

.plancard {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 14px 16px; border-radius: var(--radius);
  background: var(--card); border: 1px solid var(--line);
}
.plancard .pc-text { display: grid; gap: 2px; min-width: 0; flex: 1 1 14rem; }
.pc-k { font-size: .78em; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.pc-title { font: 700 1.05em/1.25 var(--font-display); }
.pc-sub { color: var(--muted); font-size: .92em; }
.plancard.is-sub .pc-title { color: var(--hit); }

.promo {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 16px; border-radius: var(--radius);
  background: var(--accent-soft); color: var(--ink);
}
.promo-mark { position: relative; flex: none; width: 52px; height: 44px; }
.promo-mark .mt { position: absolute; width: 30px; height: 34px; font-size: 16px; border-radius: 8px; box-shadow: 0 2px 0 rgba(0, 0, 0, .12); }
.promo-mark .mt:first-child { left: 0; top: 0; transform: rotate(-8deg); }
.promo-mark .mt:last-child { right: 0; bottom: 0; transform: rotate(7deg); }
.promo-text { display: grid; gap: 2px; min-width: 0; }
.promo-text strong { font: 700 1em/1.25 var(--font-display); text-wrap: balance; }
.promo-text span { font-size: .9em; }

.games { display: grid; gap: 12px; }
.gamecard {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 10px 14px;
  padding: 16px; border-radius: 16px;
  background: var(--card); border: 1px solid var(--line); color: var(--ink);
  text-decoration: none; text-align: start; width: 100%;
  box-shadow: 0 1px 0 rgba(0, 0, 0, .04);
  transition: transform .1s, border-color .15s;
}
.gamecard:active { transform: scale(.985); }
@media (hover: hover) { .gamecard:hover { border-color: var(--accent); } }
.gc-tiles { grid-column: 1 / -1; display: flex; gap: 6px; }
.gc-tiles .mt { width: 40px; height: 44px; font-size: 20px; border-radius: 9px; }
.gc-body { display: grid; gap: 4px; min-width: 0; }
.gc-body h2 { margin: 0; font: 700 1.25em/1.2 var(--font-display); }
.gc-body p { margin: 0; color: var(--muted); font-size: .95em; }
.gc-play {
  align-self: end; display: inline-flex; align-items: center; gap: 4px;
  min-height: 44px; padding: 0 18px; border-radius: var(--radius);
  background: var(--accent); color: var(--on-accent); font-weight: 700; white-space: nowrap;
}
.gc-play svg { width: 18px; height: 18px; }
.chip {
  justify-self: start; display: inline-flex; align-items: center; gap: 6px; margin-top: 4px;
  padding: 3px 10px; border-radius: 999px; font-size: .8em; font-weight: 700;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink); font-variant-numeric: tabular-nums;
}
.chip::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.chip.ready::before, .chip.sub::before { background: var(--hit); }
.chip.trial::before { background: var(--accent); }
.chip.wait::before { background: var(--near); }

.homefoot {
  margin-top: auto; display: flex; flex-wrap: wrap; gap: 6px 14px; justify-content: center;
  padding-top: 8px; font-size: .85em; color: var(--muted);
}
.homefoot a { color: var(--accent); font-weight: 700; text-underline-offset: 3px; }

/* --------------------------------------- home button in the game top bar */
.brand.homebtn {
  border: 0; background: none; padding: 0; padding-inline-end: 6px; margin: 0; color: inherit; text-align: start;
  min-height: 44px; border-radius: 12px; cursor: pointer;
}
.brand.homebtn .back { width: 20px; height: 20px; color: var(--muted); margin-inline-end: -4px; }
@media (hover: hover) { .brand.homebtn:hover .back { color: var(--ink); } }

/* ------------------------------------------- free game used (board card) */
.card.locked { display: grid; gap: 10px; justify-items: start; }
.locked-title { margin: 0; font: 700 clamp(15px, 4.6vw, 21px)/1.2 var(--font-display); color: var(--ink); text-wrap: balance; }
.locked .count { font-family: var(--font-mono); font-weight: 700; font-variant-numeric: tabular-nums; color: var(--accent); }
.locked p { margin: 0; }
.btn.reveal.is-plans { background: var(--accent); color: var(--on-accent); border-style: solid; border-color: var(--accent); }

/* ---------------------------------------------------- plan row in Settings */
.srow-plan .srow-value { white-space: normal; text-align: end; }

/* ------------------------------------------------------- subscription sheet */
.paywall .sheet-scroll { display: grid; gap: 14px; }
.paywall h2 { margin: 0; font: 700 20px/1.2 var(--font-display); }
.pw-reason { margin: 0; color: var(--ink); }
.pw-pick { margin: 2px 0 -4px; font: 700 13px/1.3 var(--font-body); letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.pw-plans { display: grid; gap: 8px; }
.plan {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 2px 12px;
  width: 100%; min-height: 64px; padding: 10px 16px;
  border: 2px solid var(--line); border-radius: 14px; background: var(--surface); color: var(--ink);
  text-align: start;
}
.plan-name { font: 700 1.05em/1.2 var(--font-display); }
.plan-price { grid-row: span 2; font: 700 1.15em/1 var(--font-mono); font-variant-numeric: tabular-nums; white-space: nowrap; }
.plan-per { color: var(--muted); font-size: .88em; }
.plan:active:not(:disabled) { transform: scale(.985); }
.plan:disabled { opacity: .55; }
@media (hover: hover) { .plan:hover:not(:disabled) { border-color: var(--accent); } }
.pw-msg { margin: 0; padding: 10px 12px; border-radius: 10px; background: var(--warn-bg); color: var(--warn-ink); border: 1px solid var(--warn-line); font-size: .92em; }
.pw-msg.ok { background: var(--accent-soft); color: var(--ink); border-color: var(--accent); }
.pw-terms { margin: 0; font-size: min(.8em, 14px); color: var(--muted); line-height: 1.4; }
.pw-links { display: flex; flex-wrap: wrap; gap: 0 18px; }
.pw-links a.linkbtn { display: inline-flex; align-items: center; }
.pw-foot { padding: 10px 18px 16px; border-top: 1px solid var(--line); display: grid; gap: 10px; }
.btn.wide { width: 100%; }
.paywall .promo { padding: 10px 12px; gap: 12px; }
.paywall .promo-mark { width: 44px; height: 38px; }
.paywall .promo-mark .mt { width: 26px; height: 30px; font-size: 14px; }
.paywall .promo-text strong { font-size: .95em; }
.paywall .promo-text span { font-size: .84em; }
.paywall .sheet-scroll { gap: 12px; padding-bottom: 12px; }
.paywall .plan { min-height: 54px; padding: 7px 14px; }
/* short phone screens: keep all three plans and the terms in view without scrolling */
@media (max-height: 820px) {
  .paywall .promo-text span { display: none; }
  .paywall .sheet-head { padding-top: 12px; padding-bottom: 6px; }
  .paywall .pw-pick { display: none; }
}

/* ------------------------------------------------------------ privacy page */
.doc {
  margin: 0 auto; max-width: 42rem;
  padding-block: max(16px, env(safe-area-inset-top)) max(24px, env(safe-area-inset-bottom));
  padding-inline: max(16px, env(safe-area-inset-left)) max(16px, env(safe-area-inset-right));
}
.doc h1 { font: 700 clamp(22px, 6vw, 30px)/1.15 var(--font-display); margin: 12px 0 4px; text-wrap: balance; }
.doc h2 { font: 700 17px/1.3 var(--font-display); margin: 26px 0 6px; }
.doc p, .doc li { line-height: 1.6; }
.doc .muted { color: var(--muted); }
.doc a { color: var(--accent); }
.doc hr { border: 0; border-top: 1px solid var(--line); margin: 36px 0 10px; }
.doc nav { display: flex; gap: 14px; flex-wrap: wrap; }

@media (prefers-reduced-motion: reduce) {
  .gamecard, .plan, .promo-mark .mt { transition: none; transform: none !important; }
}

/* free edition: the plan card becomes "free · no ads · no limits" */
.plancard.is-free { background: var(--accent-soft); border-color: transparent; }
.plancard.is-free .pc-k { color: var(--accent); }

/* very narrow phones: the MBG tiles alone carry the name, so the flags and the power
   button keep their full size */
@media (max-width: 379px) {
  .home .brandtext { display: none; }
}

/* ------------------------------------------------------------ contact */
.contactcard {
  display: grid; gap: 10px; padding: 14px 16px; border-radius: 16px;
  background: var(--card); border: 1px solid var(--line);
}
.cc-text { display: grid; gap: 2px; }
.cc-text strong { font: 700 1.05em/1.2 var(--font-display); }
.cc-text span { color: var(--muted); font-size: .92em; }
.cc-links { display: flex; flex-wrap: wrap; gap: 8px; }
.cc-link {
  display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 14px; flex: 1 1 auto;
  border-radius: 12px; border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  font-weight: 700; text-decoration: none; min-width: 0; overflow-wrap: anywhere;
}
.cc-link svg { flex: none; width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.cc-wa svg { color: #1FA855; }
@media (hover: hover) { .cc-link:hover { border-color: var(--accent); } }

/* ------------------------------------------------------- world top 20 */
.worldcard {
  display: flex; align-items: center; gap: 14px; width: 100%;
  padding: 14px 16px; border-radius: 16px; text-align: start;
  background: var(--card); border: 1px solid var(--line); color: var(--ink);
  transition: transform .1s, border-color .15s;
}
.worldcard:active { transform: scale(.985); }
@media (hover: hover) { .worldcard:hover { border-color: var(--accent); } }
.wc-icon { flex: none; font-size: 30px; line-height: 1; }
.wc-text { display: grid; gap: 2px; flex: 1; min-width: 0; }
.wc-text strong { font: 700 1.05em/1.2 var(--font-display); }
.wc-text span { color: var(--muted); font-size: .92em; }
.worldcard > svg { flex: none; width: 20px; height: 20px; color: var(--muted); }

.worldsheet { height: min(88dvh, 780px); }
.worldsheet .sheet-scroll { flex: 1 1 auto; min-height: 0; }
.wl-filters { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; padding: 0 18px 10px; }
.wl-seg { display: flex; width: 100%; }
.wl-seg .seg-btn { flex: 1 1 0; min-width: 0; min-height: 38px; padding: 0 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wl-coin { display: inline-block; width: 22px; height: 22px; border-radius: 50%; overflow: hidden; vertical-align: middle;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, .15); }
.wl-coin svg { display: block; width: 100%; height: 100%; stroke: none; }
.wl-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.wl-row {
  display: grid; grid-template-columns: 34px minmax(0, 1fr) auto auto; align-items: center; gap: 8px;
  padding-block: 8px; padding-inline: 8px 4px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line);
}
.wl-row.me { border-color: var(--accent); background: var(--accent-soft); grid-template-columns: 34px minmax(0, 1fr) auto; padding-inline-end: 12px; }
.wl-rank { font: 700 1em/1 var(--font-display); text-align: center; font-variant-numeric: tabular-nums; }
.wl-row.top1 .wl-rank, .wl-row.top2 .wl-rank, .wl-row.top3 .wl-rank { font-size: 1.4em; }
.wl-who { display: grid; gap: 1px; min-width: 0; }
.wl-name { display: flex; align-items: center; gap: 7px; min-width: 0; font-weight: 700; }
.wl-n { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wl-flag { flex: none; font-size: 1.2em; line-height: 1; }
.wl-flag.svg { display: inline-block; width: 1.4em; height: 1.05em; }
.wl-flag.svg svg { display: block; width: 100%; height: 100%; border-radius: 2px; stroke: none; }
.wl-detail { color: var(--muted); font-size: .8em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wl-country { font-size: .82em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wl-len .seg-btn:first-child, .wl-lang .seg-btn:first-child { flex: 2.2 1 auto; }
/* ten flags and "All" in one row, also on a 320 px phone */
.wl-lang .seg-btn { padding: 0 1px; }
.wl-lang .seg-btn:first-child { flex: 1.6 1 auto; padding: 0 6px; }
.wl-lang .wl-coin { width: 20px; height: 20px; }
.wl-score { font: 700 1.02em/1 var(--font-mono); font-variant-numeric: tabular-nums; }
.ib.wl-more { width: 34px; height: 40px; border: 0; background: transparent; color: var(--muted); }
.wl-note { padding: 22px 8px; text-align: center; color: var(--muted); }
.wl-foot {
  display: flex; align-items: center; justify-content: space-between; gap: 8px 12px; flex-wrap: wrap;
  padding: 10px 18px 16px; border-top: 1px solid var(--line);
}
.wl-count { color: var(--muted); font-size: .85em; }
.wl-me { font-weight: 700; }
.worldjoin .wj { display: grid; gap: 10px; }
.worldjoin h3 { margin: 4px 0 0; font: 700 1em/1.3 var(--font-body); }
.wj-rules { margin: 0; padding-inline-start: 1.2em; display: grid; gap: 4px; }
.wj-agree { display: flex; gap: 10px; align-items: center; font-weight: 700; min-height: 44px; }
.wj-agree input { width: 22px; height: 22px; accent-color: var(--accent); }
.worldjoin select.textfield { appearance: auto; }

/* the line under a win: rank on the world list, or how to get on it */
.world-line { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 14px; margin-top: 8px; font-weight: 700; }
.world-line .linkbtn { padding: 0; min-height: 36px; }

/* Word Puzzle card: Expert level badge */
.gamecard .lvl { display: inline-block; margin: -2px 0 4px; padding: 2px 8px; border-radius: 999px;
  font-size: .8em; font-weight: 700; background: var(--warn-bg); color: var(--warn-ink); }

/* ------------------------------------------------------- puzzles of the day (home) */
.dailycard {
  display: grid; gap: 8px; padding: 14px 16px; border-radius: 16px;
  background: var(--card); border: 1px solid var(--line);
}
.dc-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.dc-head strong { font: 700 1.05em/1.25 var(--font-display); }
.dc-no { color: var(--muted); font: 700 .9em/1 var(--font-mono); font-variant-numeric: tabular-nums; }
.dc-row {
  display: flex; align-items: center; gap: 12px; min-height: 56px; padding: 8px 10px; border-radius: 12px;
  background: var(--surface); border: 1px solid var(--line); color: var(--ink); text-decoration: none;
  transition: transform .1s, border-color .15s;
}
.dc-row:active { transform: scale(.985); }
@media (hover: hover) { .dc-row:hover { border-color: var(--accent); } }
.dc-ic.mt { flex: none; width: 36px; height: 40px; font-size: 18px; border-radius: 9px; }
.dc-text { display: grid; gap: 1px; flex: 1; min-width: 0; }
.dc-text strong { font-weight: 700; line-height: 1.25; overflow-wrap: anywhere; }
.dc-text span { color: var(--muted); font-size: .88em; }
.dc-go {
  flex: none; display: inline-flex; align-items: center; min-height: 36px; padding: 0 14px; border-radius: 999px;
  background: var(--accent); color: var(--on-accent); font-weight: 700; font-size: .92em; white-space: nowrap;
}
.dc-row.done .dc-go { background: transparent; color: var(--accent); box-shadow: inset 0 0 0 2px var(--accent); }
.dc-row.done .dc-text span { color: var(--hit); font-weight: 700; }
.dc-foot { margin: 0; color: var(--muted); font-size: .85em; }
.dc-reward { margin: 0; padding: 8px 10px; border-radius: 10px; background: var(--accent-soft); color: var(--ink); font-size: .86em; font-weight: 700; line-height: 1.35; }

/* ---------------------------------------------------------------- statistics */
.statsheet { height: min(88dvh, 760px); }
.statsheet .sheet-scroll { flex: 1 1 auto; min-height: 0; }
.st-body { display: grid; gap: 12px; align-content: start; }
.st-body h3 { margin: 4px 0 0; font: 700 1em/1.3 var(--font-body); }
.st-body p { margin: 0; }
.st-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.st-tile {
  display: grid; gap: 2px; align-content: center; justify-items: center; text-align: center;
  min-height: 72px; padding: 8px 4px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line);
}
.st-num { font: 700 1.45em/1.1 var(--font-display); font-variant-numeric: tabular-nums; }
.st-lbl { color: var(--muted); font-size: .78em; line-height: 1.2; overflow-wrap: anywhere; }
.st-best { font-weight: 700; }
.st-empty { color: var(--muted); }
.st-chart { display: grid; gap: 5px; }
.st-row { display: grid; grid-template-columns: 2.6em minmax(0, 1fr); align-items: center; gap: 8px; }
.st-k { text-align: end; font: 700 .95em/1 var(--font-mono); font-variant-numeric: tabular-nums; color: var(--muted); }
.st-bar {
  position: relative; display: flex; align-items: center; justify-content: flex-end;
  width: var(--w, 0%); min-width: 2.2em; height: 26px; padding-inline: 8px; border-radius: 7px;
  background: var(--hit); color: var(--on-hit);
}
.st-bar.zero { background: transparent; color: var(--muted); padding-inline: 2px; justify-content: flex-start; }
.st-n { font: 700 .88em/1 var(--font-mono); font-variant-numeric: tabular-nums; }
.st-daily { padding: 10px 12px; border-radius: 12px; background: var(--accent-soft); font-weight: 700; font-size: .92em; }
@media (max-width: 360px) { .st-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* ------------------------------------------------------- move to a new phone */
.transfersheet .tf { display: grid; gap: 10px; }
.transfersheet h3 { margin: 6px 0 0; font: 700 1em/1.3 var(--font-body); }
.transfersheet p { margin: 0; }
.tf-code {
  height: auto; min-height: 96px; padding: 10px 12px; resize: vertical; font: 600 .82em/1.4 var(--font-mono);
  word-break: break-all; text-align: left; direction: ltr;
}
.transfersheet .dlg-actions { justify-content: flex-start; }

/* sharing (a daily result, the code) */
.share-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 2px; }
.share-row .btn { text-decoration: none; }
.share-wa { color: #1A8F48; }

/* the daily puzzle's box on the result card in a game */
.daily-box {
  display: grid; gap: 4px; margin-top: 10px; padding: 10px 12px; border-radius: 12px;
  background: var(--accent-soft); color: var(--ink);
}
.daily-box p { margin: 0; }
.daily-head { font-weight: 700; }
.daily-streak { font-weight: 700; }
.daily-reward { font-weight: 700; color: var(--accent); }
.daily-reward.bonus { color: var(--ink); font-size: 1.05em; }
.daily-nextbonus { color: var(--muted); font-size: .9em; }
.daily-next { color: var(--muted); font-size: .9em; }
.daily-box .share-row { margin-top: 6px; }
.statline { margin: 6px 0 0; font-size: .9em; }
.statline .linkbtn { padding: 0; min-height: 32px; }

/* rules: "Don't show this at the start" under the help text */
.sheet-foot.intro-opt {
  display: flex; align-items: center; gap: 10px; min-height: 52px; padding: 8px 18px 12px;
  border-top: 1px solid var(--line); font-weight: 700; cursor: pointer;
}
.intro-opt input { flex: none; width: 22px; height: 22px; margin: 0; accent-color: var(--accent); }
@media (prefers-reduced-motion: reduce) { .dc-row { transition: none; transform: none !important; } }

/* "Share via": the game's own list of apps, where the phone's share sheet is not available */
.sharesheet .sh { display: grid; gap: 14px; }
.sh-apps { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px 6px; }
.sh-app {
  display: flex; flex-direction: column; align-items: center; gap: 6px; min-width: 0; padding: 4px 2px;
  border: 0; background: transparent; color: var(--ink); text-decoration: none; font: inherit; cursor: pointer;
}
.sh-ic { display: grid; place-items: center; width: 52px; height: 52px; border-radius: 50%; color: #fff; }
.sh-ic svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.sh-app:active .sh-ic { transform: scale(.94); }
@media (hover: hover) { .sh-app:hover .sh-ic { filter: brightness(1.08); } }
.sh-name { font-size: .82em; font-weight: 700; text-align: center; overflow-wrap: anywhere; line-height: 1.2; }
.sh-text {
  margin: 0; max-height: 34vh; overflow: auto; padding: 10px 12px; border-radius: 12px;
  background: var(--surface); border: 1px solid var(--line); white-space: pre-wrap; word-break: break-word;
  font: 500 .82em/1.45 var(--font-body); color: var(--ink);
}
.srow.srow-keys { flex-direction: column; align-items: stretch; flex-wrap: nowrap; gap: 8px; padding-block: 10px; }
.srow-keys .srow-label { flex: none; }
.srow-keys .seg { display: flex; width: 100%; }
.srow-keys .seg-btn { flex: 1 1 0; min-width: 0; padding: 0 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.share-btn { display: inline-flex; align-items: center; gap: 6px; }
.share-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
