/* SharpLab HQ — Math 24 (build an expression from 4 numbers that equals 24).
   Builds on hqstyle.css (shared vars/header/nav/.btn/.card). Only page-specific styling here.
   Structured to mirror sequence.css (its arcade-guesser sibling) but with its own visual
   identity: numbers read as a dealt "hand" of cards, and a standing "= 24" target badge
   anchors the whole page instead of a mystery tile. */

/* ── Page intro ── */
.m24-head { margin: 4px 0 20px; text-align: center; }
.m24-head h1 { font-size: 26px; margin: 0 0 4px; }
.m24-head p { color: var(--muted); margin: 0 auto; font-size: 14px; max-width: 520px; }

.balancechip {
  display: inline-flex; align-items: center; gap: 6px; margin-left: 10px;
  font-size: 13px; font-weight: 700; color: var(--gold);
  background: var(--panel2); border: 1px solid var(--line);
  border-radius: var(--r-pill); padding: 3px 11px; vertical-align: middle;
}

/* ── Game card ── */
.m24-wrap { max-width: 560px; margin: 0 auto; }
.m24-card { display: flex; flex-direction: column; gap: var(--s-4); align-items: center; text-align: center; }

/* ── Target badge — the fixed "make this" anchor of the whole page ── */
.m24-target {
  display: inline-flex; align-items: baseline; gap: 8px;
  font-variant-numeric: tabular-nums; padding: 6px 0 2px;
}
.m24-target .tlabel { font-size: 12px; font-weight: 700; letter-spacing: .6px; text-transform: uppercase; color: var(--muted); }
.m24-target .tnum {
  font-size: 40px; font-weight: 900; color: var(--gold);
  text-shadow: 0 0 22px color-mix(in srgb, var(--gold) 45%, transparent);
}
@media (prefers-reduced-motion: no-preference) {
  .m24-target .tnum { animation: m24-glow 2.6s ease-in-out infinite; }
}
@keyframes m24-glow {
  0%, 100% { text-shadow: 0 0 14px color-mix(in srgb, var(--gold) 30%, transparent); }
  50% { text-shadow: 0 0 26px color-mix(in srgb, var(--gold) 55%, transparent); }
}

/* ── Dealt "hand" of number cards ── */
.m24-hand { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; align-items: center; padding: 4px 0; }
.m24-card-num {
  position: relative; width: 62px; height: 84px; border-radius: var(--r);
  background: linear-gradient(160deg, var(--panel2), var(--panel));
  border: 1px solid var(--line); display: flex; align-items: center; justify-content: center;
  font-size: 30px; font-weight: 800; color: var(--fg); font-variant-numeric: tabular-nums;
  cursor: pointer; user-select: none; transition: transform .12s ease, border-color .12s ease, box-shadow .12s ease;
  box-shadow: 0 2px 0 var(--line);
}
.m24-card-num::before, .m24-card-num::after {
  content: attr(data-n); position: absolute; font-size: 10px; font-weight: 700; color: var(--muted);
  line-height: 1;
}
.m24-card-num::before { top: 6px; left: 7px; }
.m24-card-num::after { bottom: 6px; right: 7px; transform: rotate(180deg); }
.m24-card-num:hover { border-color: var(--accent); transform: translateY(-2px); box-shadow: 0 4px 0 var(--accent-soft); }
.m24-card-num:active { transform: translateY(0); box-shadow: 0 1px 0 var(--line); }
.m24-card-num.used { opacity: .45; }

/* ── Expression input ── */
.m24-input {
  width: 100%; max-width: 360px; font-family: inherit; font-size: 22px; font-weight: 700; color: var(--fg);
  background: var(--panel2); border: 1px solid var(--line); border-radius: var(--r);
  padding: 12px 14px; text-align: center; font-variant-numeric: tabular-nums;
}
.m24-input:focus { outline: none; border-color: var(--accent); }
.m24-input:disabled { opacity: .55; }
.m24-input.shake { animation: m24-shake .4s ease; border-color: var(--red); }
@keyframes m24-shake {
  0%,100% { transform: translateX(0); }
  20% { transform: translateX(-8px); }
  40% { transform: translateX(7px); }
  60% { transform: translateX(-5px); }
  80% { transform: translateX(4px); }
}

/* ── Operator keypad — quick-insert so mobile keyboards aren't a barrier ── */
.m24-keypad { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; }
.m24-key {
  min-width: 40px; font-family: inherit; font-size: 17px; font-weight: 700; color: var(--accent2);
  background: var(--panel2); border: 1px solid var(--line); border-radius: var(--r-sm);
  padding: 8px 12px; cursor: pointer; transition: border-color .12s, background .12s;
}
.m24-key:hover { border-color: var(--accent2); background: var(--panel); }
.m24-key.wide { color: var(--muted); font-size: 13px; }

/* ── Result line ── */
.m24-result { min-height: 22px; font-size: 15px; font-weight: 600; }
.m24-result b { font-variant-numeric: tabular-nums; }
.m24-result.hit { color: var(--green); font-size: 18px; font-weight: 800; }
.m24-result.bad { color: var(--red); }
.m24-reward { color: var(--gold); font-weight: 800; }
.m24-cap { color: var(--muted); font-weight: 600; font-size: 14px; }

/* ── Buttons ── */
.m24-btns { display: flex; gap: 8px; width: 100%; justify-content: center; flex-wrap: wrap; }
.m24-btns .btn { flex: 1; min-width: 130px; max-width: 220px; text-align: center; }
.btn.big { font-size: 16px; padding: 12px 18px; }

.m24-counter { font-size: 12px; color: var(--muted); }
.m24-counter b { color: var(--fg); font-variant-numeric: tabular-nums; }

/* ── Mode toggle (practice ⇄ sprint) ── */
.m24-modetoggle { display: flex; gap: 8px; justify-content: center; margin: 0 0 14px; }

/* ── Sprint mode (120s batch run) — copied verbatim from zetamac.css so math24.html
   doesn't need to load a second stylesheet. "zm" prefix kept for a 1:1 mirror. ── */
.zmbig { font-size: 46px; font-weight: 800; letter-spacing: .5px; }

.zmtimebar {
  width: 100%; height: 10px; background: var(--panel2); border: 1px solid var(--line);
  border-radius: var(--r-pill); overflow: hidden;
}
.zmtimefill {
  height: 100%; width: 100%; transform-origin: left center; transform: scaleX(1);
  background: linear-gradient(90deg, var(--accent), var(--accent2));
}
@media (prefers-reduced-motion: no-preference) {
  .zmtimefill { transition: transform .12s linear; }
}
.zmtimefill.hot { background: linear-gradient(90deg, var(--gold), var(--red)); }

.zmmeta {
  display: flex; align-items: center; justify-content: space-between; width: 100%;
  font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums;
}
.zmsecs { font-weight: 800; color: var(--accent2); font-size: 15px; }
.zmsecs.hot { color: var(--red); }
.zmsolved b { color: var(--fg); }

.zmresult .zmbig { font-size: 36px; }
.zmreward { font-size: 22px; font-weight: 800; color: var(--gold); font-variant-numeric: tabular-nums; }
.zmbest { font-size: 14px; color: var(--muted); }
.zmbest b { color: var(--fg); font-variant-numeric: tabular-nums; }
.zmrank { font-size: 13px; color: var(--accent2); font-weight: 700; }
.zmnewbest { font-size: 15px; font-weight: 800; color: var(--gold); }
@keyframes zm-pop { 0% { transform: scale(.85); } 60% { transform: scale(1.12); } 100% { transform: scale(1); } }
.zmnewbest.pop, .zmreward.pop { animation: zm-pop .5s ease; }
@media (prefers-reduced-motion: reduce) {
  .zmnewbest.pop, .zmreward.pop { animation: none; }
}

/* ── Sprint leaderboard ── */
.zmleaderboard { max-width: 460px; margin: 22px auto 0; }
.zmlbhead {
  font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .6px;
  color: var(--accent2); text-align: center; margin-bottom: 12px;
}
.zmlbempty { text-align: center; color: var(--muted); font-size: 13px; }
.zmlblist { display: flex; flex-direction: column; gap: 6px; }
.zmlbrow {
  display: flex; align-items: center; gap: 10px;
  background: var(--panel2); border: 1px solid var(--line); border-radius: var(--r);
  padding: 8px 12px; font-size: 14px;
}
.zmlbrow.me { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold); }
.zmlbrank { font-size: 12px; color: var(--muted); width: 32px; font-variant-numeric: tabular-nums; }
.zmlbname { font-weight: 600; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.zmlbruns { font-size: 12px; color: var(--muted); }
.zmlbscore { font-weight: 800; color: var(--gold); font-variant-numeric: tabular-nums; }

/* ── Confetti burst on a correct guess ── */
.m24-confetti { position: fixed; inset: 0; pointer-events: none; z-index: 320; overflow: hidden; }
.m24-confetti i {
  position: absolute; top: -12px; width: 9px; height: 14px; border-radius: 2px;
  animation: m24-fall 1.4s ease-in forwards;
}
@keyframes m24-fall {
  to { transform: translateY(105vh) rotate(540deg); opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .m24-input.shake { animation: none; }
  .m24-confetti { display: none; }
  .m24-target .tnum { animation: none; }
}

/* ═══════════════════════════════════════════════════════════════════════════
   Copied verbatim from countdown.css so the coins hub + toasts are styled here too.
   ═══════════════════════════════════════════════════════════════════════════ */
.coinschip { font-weight: 700; color: var(--gold); background: var(--panel2); border: 1px solid var(--line); border-radius: 999px; padding: 3px 11px; font-size: 13px; white-space: nowrap; cursor: pointer; transition: border-color .15s, transform .15s; }
.coinschip:hover { border-color: var(--gold); transform: translateY(-1px); }

/* Coins hub modal */
.hubov { position: fixed; inset: 0; z-index: 250; display: grid; place-items: center; padding: 20px; background: rgba(5,7,11,.6); backdrop-filter: blur(3px); animation: m24-scrim-in .18s ease both; }
@keyframes m24-scrim-in { from { opacity: 0; } to { opacity: 1; } }
.hubcard { width: min(460px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 18px 20px 20px; box-shadow: 0 24px 60px -20px #000; }
.hubhead { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.hubhead h3 { margin: 0; font-size: 17px; }
.hubx { background: none; border: 0; color: var(--muted); font-size: 18px; cursor: pointer; line-height: 1; padding: 4px 8px; border-radius: 8px; }
.hubx:hover { color: var(--fg); background: var(--panel2); }
.hubrow { display: flex; gap: 12px; align-items: flex-start; padding: 10px 0; border-top: 1px solid var(--line); }
.hubrow:first-of-type { border-top: 0; }
.hubicon { font-size: 20px; width: 30px; text-align: center; flex: 0 0 auto; }
.hubt { font-weight: 700; font-size: 14px; }
.hubd { color: var(--muted); font-size: 12.5px; line-height: 1.45; margin-top: 2px; }
.hubfoot { margin: 14px 0 0; padding-top: 12px; border-top: 1px solid var(--line); color: var(--muted); font-size: 13px; text-align: right; }
.hubfoot b { color: var(--gold); }

.cardtoast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); z-index: 300;
  background: var(--panel2); color: var(--fg); border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 18px; font-size: 14px; box-shadow: 0 10px 30px rgba(0,0,0,.5);
}
