/* Shared game shell: HUD, overlays, full-screen canvas. Works with css/style.css tokens. */
html, body { height: 100%; overflow: hidden; }
body { background: var(--bg); overscroll-behavior: none; -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent; }
.mg-stage { position: fixed; inset: 0; touch-action: none; }
.mg-stage canvas { display: block; width: 100%; height: 100%; }

.mg-hud {
  position: fixed; top: 0; left: 0; right: 0; z-index: 5; pointer-events: none;
  display: flex; align-items: flex-start; justify-content: space-between; gap: 10px;
  padding: max(12px, env(safe-area-inset-top)) 14px 0;
}
.mg-hud > * { pointer-events: auto; }
.mg-hud .icon-btn { width: 42px; height: 42px; text-decoration: none; font-size: 18px; }
.mg-score { text-align: center; pointer-events: none; }
.mg-score-val {
  font-family: var(--font-pixel); font-size: clamp(28px, 7vw, 44px); color: #fff;
  text-shadow: 0 0 14px var(--accent), 0 3px 0 rgba(0,0,0,.4);
  display: inline-block; transition: transform .12s;
}
.mg-score-val.bump { transform: scale(1.25); }
.mg-score-best { font-family: var(--font-pixel); font-size: 9px; color: var(--yellow); margin-top: 6px; opacity: .85; }

.mg-overlay {
  position: fixed; inset: 0; z-index: 10; display: grid; place-items: center; padding: 20px;
  background: radial-gradient(circle at 50% 40%, rgba(11,8,32,.55), rgba(11,8,32,.92));
  backdrop-filter: blur(3px);
  animation: mgFade .25s both;
}
.mg-overlay[hidden] { display: none; }
@keyframes mgFade { from { opacity: 0; } }
.mg-panel {
  width: min(380px, 100%); text-align: center; padding: 28px 22px 24px; border-radius: 22px;
  background: var(--panel); border: 1px solid color-mix(in srgb, var(--accent) 50%, transparent);
  box-shadow: 0 0 60px -20px var(--accent);
  animation: mgPop .35s cubic-bezier(.2, 1.4, .4, 1) both;
}
@keyframes mgPop { from { transform: scale(.85); opacity: 0; } }
.mg-kicker { font-family: var(--font-pixel); font-size: 10px; color: var(--accent); letter-spacing: 2px; }
.mg-title { margin: 12px 0 10px; font-family: var(--font-pixel); font-size: clamp(20px, 6vw, 28px); line-height: 1.3; }
.mg-hint { color: var(--muted); margin: 0 0 20px; }
.mg-big { font-family: var(--font-pixel); font-size: 44px; color: #fff; text-shadow: 0 0 18px var(--accent); margin: 8px 0; }
.mg-row { display: flex; justify-content: center; gap: 22px; margin: 6px 0 20px; color: var(--muted); font-size: 14px; }
.mg-row b { display: block; font-family: var(--font-pixel); font-size: 14px; color: var(--yellow); margin-top: 4px; }
.mg-record {
  display: inline-block; padding: 6px 10px; border-radius: 8px; margin-bottom: 8px;
  font-family: var(--font-pixel); font-size: 10px; color: var(--bg); background: var(--yellow);
  animation: mgRec .6s ease-in-out infinite alternate;
}
.mg-record[hidden] { display: none; }
@keyframes mgRec { to { transform: scale(1.08) rotate(-2deg); box-shadow: 0 0 24px var(--yellow); } }
.mg-actions { display: flex; flex-direction: column; gap: 10px; }
.mg-actions .btn { justify-content: center; }
.mg-keys { margin-top: 14px; font-size: 12px; color: var(--muted); }

.mg-ach { display: flex; flex-direction: column; gap: 8px; margin: -6px 0 18px; }
.mg-ach[hidden] { display: none; }
.mg-ach-item {
  display: flex; align-items: center; gap: 12px; text-align: left; padding: 10px 12px; border-radius: 12px;
  background: color-mix(in srgb, var(--yellow) 12%, transparent); border: 1px solid color-mix(in srgb, var(--yellow) 50%, transparent);
  animation: mgPop .45s cubic-bezier(.2, 1.4, .4, 1) both .2s;
}
.mg-ach-item span { font-size: 26px; }
.mg-ach-item small { display: block; font-family: var(--font-pixel); font-size: 8px; color: var(--yellow); letter-spacing: 1px; }
.mg-ach-item b { font-size: 16px; }

.mg-lb { margin: -6px 0 18px; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.mg-lb[hidden] { display: none; }
.mg-lb-rank { font-size: 15px; color: var(--text); }
.mg-lb-rank b { font-family: var(--font-pixel); font-size: 13px; color: var(--cyan); }
.mg-lb-link { font-size: 13px; color: var(--cyan); text-decoration: none; }
.mg-lb-form { width: 100%; text-align: left; }
.mg-lb-form label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.mg-lb-form div { display: flex; gap: 8px; }
.mg-lb-form input, .lb-name input {
  flex: 1; min-width: 0; padding: 10px 12px; border-radius: 10px; font: 500 15px var(--font-body);
  color: var(--text); background: rgba(11,8,32,.6); border: 1px solid var(--panel-border); user-select: text; -webkit-user-select: text;
}
.mg-lb-form .btn { padding: 10px 14px; }

/* start screen scrolls to reveal the game guide (SEO content) below the Play panel */
.mg-overlay.mg-start { display: block; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
.mg-overlay.mg-start[hidden] { display: none; } /* must win over the display:block above */
.mg-start .mg-panel { margin: max(10vh, 72px) auto 18px; }
.mg-howto { display: inline-block; margin-top: 12px; font-size: 13px; color: var(--cyan); text-decoration: none; }
.mg-howto[hidden] { display: none; }
.mg-seo {
  width: min(640px, 100%); margin: 0 auto 48px; padding: 22px 22px 18px; border-radius: 20px; text-align: left;
  background: rgba(20, 15, 51, .92); border: 1px solid var(--panel-border); line-height: 1.6;
  user-select: text; -webkit-user-select: text;
}
.mg-seo h1 { font-family: var(--font-pixel); font-size: 17px; line-height: 1.5; margin: 6px 0 12px; color: #fff; }
.mg-seo h1 span { display: block; font-family: var(--font-body); font-size: 15px; color: var(--accent); margin-top: 4px; }
.mg-seo h2 { font-size: 16px; margin: 20px 0 6px; color: var(--accent); }
.mg-seo .lead { color: var(--text); }
.mg-seo p, .mg-seo li { color: var(--muted); font-size: 15px; }
.mg-seo ol, .mg-seo ul { padding-left: 20px; margin: 6px 0; }
.mg-seo a { color: var(--cyan); }
.seo-related { list-style: none; padding: 0 !important; display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 8px; }
.seo-related a { display: block; padding: 10px 12px; border-radius: 12px; text-decoration: none; background: rgba(255,255,255,.04); border: 1px solid color-mix(in srgb, var(--accent) 40%, transparent); }
.seo-related b { display: block; color: #fff; font-size: 14px; }
.seo-related span { font-size: 12px; color: var(--muted); }
.seo-more { margin-top: 14px; font-size: 14px; }

/* ads on the start / game-over screens (never during play) */
.mg-overlay.mg-scroll { display: block; overflow-y: auto; overscroll-behavior: contain; }
.mg-overlay.mg-scroll[hidden] { display: none; }
.mg-scroll .mg-panel { margin: max(10vh, 72px) auto 18px; }
.mg-ad { display: flex; justify-content: center; margin: 0 auto 18px; max-width: 100%; }
.mg-side { position: fixed; top: 50%; transform: translateY(-50%); z-index: 11; }
.mg-side-l { left: 12px; } .mg-side-r { right: 12px; }
.mg-start .mg-seo .ad-inline { margin: 10px -6px; }

.mg-ad-over { margin: 4px auto 16px; }
.mg-ad-over .ad-slot { min-height: 250px; }
.mg-actions .btn[disabled] { opacity: .55; cursor: not-allowed; transform: none; box-shadow: none; }
.mg-sponsored { display: inline-block; margin-top: 10px; font-size: 12px; color: var(--muted); }
.mg-sponsored[hidden] { display: none; }
.mg-ad-lvl { margin: 10px auto 16px; }
.mg-ad-lvl .ad-slot { min-height: 250px; }
.mg-lvl .mg-big { font-size: clamp(26px, 8vw, 44px); }
.mg-lvl-sub { color: var(--muted, #a49cc9); font-size: 14px; margin-top: 6px; }
.mg-lvl-sub b { color: #fff; }
