/* ===========================================================================
   ArbeeStudios — Minigames
   The Playground theme applied to a page you can actually play. Inherits every
   token, the topline and the footer from playground.css; this file only adds
   the game furniture: panel, screens, question rows, phone-friendly inputs
   and the leaderboard.
   =========================================================================== */

/* ---- shared page furniture --------------------------------------------- */
.mg-home { text-decoration: none; color: inherit; }

.mg-hero {
  padding: clamp(26px, 6vh, 60px) var(--pad) clamp(22px, 4vh, 38px);
  text-align: center;
  display: flex; flex-direction: column; align-items: center;
}
.mg-hero .pg-kick { margin-bottom: 22px; background: var(--c-blue); color: var(--ink); }
.mg-title {
  font-family: "Fredoka", system-ui, sans-serif;
  margin: 0; font-weight: 700; letter-spacing: -0.03em; line-height: 0.95;
  font-size: clamp(40px, 9vw, 92px);
}
.mg-title .one { color: var(--c-orange); display: inline-block; }
.mg-title .two { color: var(--ink); display: inline-block; }
.mg-hero .pg-sub { margin-top: 20px; max-width: 480px; font-size: clamp(16px, 2vw, 20px); }

.mg-stage { padding: 0 var(--pad) clamp(50px, 8vh, 100px); }

/* ---- the panel ---------------------------------------------------------- */
.mg-panel {
  max-width: 620px; margin: 0 auto;
  background: #fff;
  border: 2.5px solid var(--ink);
  border-radius: 26px;
  box-shadow: 0 10px 0 var(--ink);
  padding: clamp(22px, 4.5vw, 38px);
}

/* Screens are swapped by data-screen on the panel. Every screen is in the DOM
   from the start, so nothing has to be built mid-run. */
.mg-screen { display: none; }
.mg-panel[data-screen="start"]     #mgStart,
.mg-panel[data-screen="countdown"] #mgCountdown,
.mg-panel[data-screen="play"]      #mgPlay,
.mg-panel[data-screen="done"]      #mgDone { display: block; }

/* ---- start screen ------------------------------------------------------- */
.mg-rules {
  list-style: none; margin: 0 0 26px; padding: 0;
  display: flex; flex-direction: column; gap: 12px;
}
.mg-rules li {
  display: flex; align-items: flex-start; gap: 12px;
  font-weight: 700; font-size: 15.5px; line-height: 1.45; color: var(--ink-soft);
}
.mg-rules b { color: var(--ink); }
.mg-rules .n {
  flex: none; width: 26px; height: 26px; border-radius: 50%;
  display: grid; place-items: center;
  font-family: "Fredoka", system-ui, sans-serif; font-size: 14px; font-weight: 600;
  color: var(--ink); border: 2.5px solid var(--ink);
}
.mg-rules li:nth-child(1) .n { background: var(--c-yellow); }
.mg-rules li:nth-child(2) .n { background: var(--c-blue); }
.mg-rules li:nth-child(3) .n { background: var(--c-green); }

.mg-field { display: block; margin-bottom: 18px; }
.mg-field .lbl {
  display: block; margin-bottom: 9px;
  font-family: "Fredoka", system-ui, sans-serif; font-weight: 500; font-size: 15px;
}
.mg-text {
  width: 100%; font-family: "Nunito", system-ui, sans-serif;
  font-size: 17px; font-weight: 700; color: var(--ink);
  background: #FFF9EF; border: 2.5px solid var(--ink); border-radius: 999px;
  padding: 13px 20px; min-height: 52px;
  box-shadow: 0 4px 0 var(--ink);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.mg-text::placeholder { color: #b0a8bd; font-weight: 600; }
.mg-text:focus { outline: none; transform: translateY(-2px); box-shadow: 0 6px 0 var(--ink); }
.mg-text:focus-visible { outline: 3px solid var(--c-violet-deep); outline-offset: 3px; }

.mg-note {
  margin: 0 0 16px; min-height: 22px;
  font-weight: 700; font-size: 14.5px; color: #D6336C;
}

/* ---- buttons ------------------------------------------------------------ */
.mg-btn {
  font-family: "Fredoka", system-ui, sans-serif;
  font-size: 17px; font-weight: 600; color: var(--ink);
  background: var(--c-yellow);
  border: 2.5px solid var(--ink); border-radius: 999px;
  padding: 13px 26px; min-height: 52px;
  box-shadow: 0 5px 0 var(--ink); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 9px;
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.25s;
}
.mg-btn:hover { transform: translateY(-2px); box-shadow: 0 7px 0 var(--ink); }
.mg-btn:active { transform: translateY(2px); box-shadow: 0 3px 0 var(--ink); }
.mg-btn--go { width: 100%; font-size: 19px; padding: 15px 26px; min-height: 58px; background: var(--c-orange); }
.mg-btn--ghost { background: #fff; }
.mg-btn--blue { background: var(--c-blue); }

/* Turnstile only takes up room on the rare run where it wants an interaction. */
.mg-turnstile:not(:empty) { display: flex; justify-content: center; margin-top: 16px; }

.mg-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 26px; }
.mg-actions .mg-btn { flex: 1 1 190px; }

/* ---- countdown ---------------------------------------------------------- */
#mgCountdown { text-align: center; padding: clamp(20px, 6vw, 48px) 0; }
.mg-count {
  font-family: "Fredoka", system-ui, sans-serif;
  font-size: clamp(72px, 20vw, 132px); font-weight: 700; line-height: 1;
  letter-spacing: -0.04em; color: var(--c-orange);
  animation: mgPop 0.85s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.mg-count.go { color: #4A8420; font-size: clamp(48px, 13vw, 92px); }
@keyframes mgPop {
  0%   { transform: scale(0.4) rotate(-8deg); opacity: 0; }
  55%  { transform: scale(1.08) rotate(2deg); opacity: 1; }
  100% { transform: scale(1) rotate(0); opacity: 1; }
}
.mg-count-sub { margin: 14px 0 0; font-weight: 700; color: var(--ink-soft); }

/* ---- play screen -------------------------------------------------------- */
.mg-hud {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap; margin-bottom: 22px;
}
.mg-timer {
  font-family: "Fredoka", system-ui, sans-serif;
  font-size: 19px; font-weight: 600; font-variant-numeric: tabular-nums;
  background: var(--c-yellow); border: 2.5px solid var(--ink); border-radius: 999px;
  box-shadow: 0 4px 0 var(--ink); padding: 9px 18px; white-space: nowrap;
}
.mg-progress { display: inline-flex; gap: 7px; }
.mg-progress i {
  width: 13px; height: 13px; border-radius: 50%;
  border: 2.5px solid var(--ink); background: #fff;
  transition: background 0.25s ease, transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.mg-progress i.on { background: var(--c-green); transform: scale(1.15); }

.mg-rows { display: flex; flex-direction: column; gap: 12px; margin: 0; padding: 0; border: 0; }

.mg-row {
  display: grid; grid-template-columns: 1fr auto auto;
  align-items: center; gap: 12px;
  background: #FFF9EF; border: 2.5px solid var(--ink); border-radius: 18px;
  padding: 11px 13px 11px 18px;
  transition: background 0.2s ease, border-color 0.2s ease;
}
.mg-sum {
  font-family: "Fredoka", system-ui, sans-serif;
  font-size: clamp(20px, 5vw, 26px); font-weight: 600; letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
.mg-sum .x { color: var(--c-violet-deep); margin: 0 3px; }
.mg-answer {
  width: 108px; min-height: 48px;
  font-family: "Fredoka", system-ui, sans-serif;
  font-size: 20px; font-weight: 600; text-align: center;
  font-variant-numeric: tabular-nums; color: var(--ink);
  background: #fff; border: 2.5px solid var(--ink); border-radius: 13px;
  padding: 8px 6px;
  -moz-appearance: textfield;
  appearance: textfield;
}
.mg-answer::-webkit-outer-spin-button,
.mg-answer::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.mg-answer:focus { outline: none; border-color: var(--c-violet-deep); }
.mg-answer:focus-visible { outline: 3px solid var(--c-violet-deep); outline-offset: 2px; }

.mg-mark {
  width: 30px; text-align: center;
  font-family: "Fredoka", system-ui, sans-serif; font-size: 21px; font-weight: 600;
}
.mg-row.is-right { background: #EEFBE4; border-color: #5FA22B; }
.mg-row.is-right .mg-answer { border-color: #5FA22B; }
.mg-row.is-right .mg-mark { color: #4A8420; }
.mg-row.is-wrong { background: #FFF0F4; border-color: #D6336C; }
.mg-row.is-wrong .mg-answer { border-color: #D6336C; }
.mg-row.is-wrong .mg-mark { color: #C22A5D; }

.mg-hint { margin: 20px 0 0; text-align: center; font-weight: 700; font-size: 14px; color: var(--ink-soft); }

/* ---- done screen -------------------------------------------------------- */
.mg-result { text-align: center; margin-bottom: 24px; }
.mg-result .cap {
  font-family: "Fredoka", system-ui, sans-serif; font-size: 15px; font-weight: 500;
  color: var(--ink-soft); display: block; margin-bottom: 4px;
}
.mg-result .big {
  font-family: "Fredoka", system-ui, sans-serif;
  font-size: clamp(46px, 12vw, 74px); font-weight: 700; line-height: 1;
  letter-spacing: -0.03em; color: var(--c-orange); font-variant-numeric: tabular-nums;
  display: block;
}
.mg-result .big i { font-style: normal; font-size: 0.42em; color: var(--ink-soft); margin-left: 4px; }
.mg-cheer {
  display: inline-block; margin-top: 16px;
  font-family: "Fredoka", system-ui, sans-serif; font-size: 15px; font-weight: 500;
  background: var(--c-green); color: var(--ink);
  border: 2.5px solid var(--ink); border-radius: 999px; box-shadow: 0 4px 0 var(--ink);
  padding: 9px 18px; transform: rotate(-2deg);
}
.mg-cheer:empty { display: none; }
.mg-standing {
  margin: 14px auto 0; max-width: 340px;
  font-weight: 700; font-size: 14.5px; line-height: 1.45; color: var(--ink-soft);
}
.mg-standing:empty { display: none; }

/* ---- leaderboard -------------------------------------------------------- */
/* Its own panel below the game, so the times to beat are visible before you
   start rather than only after you finish. */
.mg-panel--board { margin-top: 20px; padding: clamp(20px, 4vw, 30px); }
.mg-panel--board h2 {
  font-family: "Fredoka", system-ui, sans-serif;
  text-align: center; font-size: 21px; font-weight: 600; margin: 0 0 4px;
}
.mg-panel--board .sub {
  text-align: center; margin: 0 0 16px;
  font-weight: 700; font-size: 13.5px; color: var(--ink-soft);
}
.mg-board ol { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.mg-place {
  display: grid; grid-template-columns: 34px 1fr auto;
  align-items: center; gap: 12px;
  background: #FFF9EF; border: 2.5px solid var(--ink); border-radius: 14px;
  padding: 10px 14px; font-weight: 800; font-size: 15px;
}
.mg-place .rank {
  font-family: "Fredoka", system-ui, sans-serif; font-size: 17px; font-weight: 600;
  text-align: center;
}
.mg-place .who { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mg-place .t { font-variant-numeric: tabular-nums; white-space: nowrap; }
.mg-place .t .diff { color: var(--ink-soft); font-weight: 700; margin-left: 7px; font-size: 13.5px; }
.mg-place.p1 { background: #FFF4D2; border-color: #A8760A; }
.mg-place.p2 { background: #F3F3F7; }
.mg-place.p3 { background: #FBEEE2; }
.mg-place.mine { box-shadow: 0 0 0 3px var(--c-violet); }
.mg-board .mg-empty { text-align: center; font-weight: 700; color: var(--ink-soft); margin: 0; }

/* The break between the top ten and your own row when you placed below it. */
.mg-gap {
  text-align: center; letter-spacing: 0.3em; line-height: 1;
  color: var(--ink-soft); padding: 10px 0 8px;
}
.mg-board ol + .mg-gap { margin-top: 0; }
.mg-board-note, .mg-best {
  text-align: center; margin: 14px 0 0;
  font-weight: 700; font-size: 13.5px; color: var(--ink-soft);
}
.mg-board-note:empty, .mg-best:empty { display: none; }
.mg-best { margin-top: 6px; color: var(--ink); }

/* ---- responsive --------------------------------------------------------- */
@media (max-width: 460px) {
  .mg-panel { border-radius: 20px; padding: 20px 16px; }
  .mg-row { gap: 8px; padding: 10px 10px 10px 14px; }
  .mg-answer { width: 92px; font-size: 19px; }
  .mg-mark { width: 22px; font-size: 19px; }
  .mg-hud { justify-content: center; }
  .mg-actions .mg-btn { flex: 1 1 100%; }
}

@media (prefers-reduced-motion: reduce) {
  .mg-count { animation: none; }
  .mg-btn:hover, .mg-text:focus { transform: none; }
}
