/* Moto Stunt Racing: the canvas fills the stage; HUD, drive buttons and menus are HTML over it */
.ms { display: flex; flex-direction: column; color: #dfe9ff; }
.ms-stage { position: relative; width: 100%; height: min(78vh, 700px); min-height: 380px; background: #070b18; overflow: hidden;
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent; touch-action: none; }
@media (max-width: 600px) { .ms-stage { height: min(76vh, 640px); min-height: 420px; } }
@media (max-height: 520px) and (orientation: landscape) { .ms-stage { height: min(86vh, 440px); min-height: 250px; } }
.stage.is-immersive .stage-body > .ms { min-height: 0; flex: 1 1 auto; }
.stage.is-immersive .ms-stage { flex: 1 1 auto; height: auto; max-height: none; min-height: 0; }
.stage.is-immersive .ms-help { display: none; }
#ms-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; outline: none; }
.ms-stage.is-panel, .ms-stage.is-panel #ms-canvas { touch-action: pan-y; }
.ms [hidden] { display: none !important; }
.ms-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* HUD */
.ms-hud { position: absolute; left: 0; right: 0; top: 0; display: flex; align-items: center; gap: 8px; padding: 8px 8px 0 12px; z-index: 6; pointer-events: none; }
.ms-hud > * { pointer-events: auto; }
.ms-run { visibility: hidden; }
.ms.is-run .ms-run { visibility: visible; }
.ms-stat { display: flex; flex: none; flex-direction: column; line-height: 1.05; min-width: 62px; padding: 5px 10px 6px; border-radius: 12px; background: rgba(6,10,24,0.62); border: 1px solid rgba(120,160,220,0.18); }
.ms-k { font-size: 10px; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; color: #9db4d6; white-space: nowrap; }
.ms-stat b { font-size: 21px; font-weight: 800; color: #fff; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.ms-goal b { color: #ffd166; font-size: 17px; margin-top: 3px; }
.ms-goal.is-late b { color: #8aa3c4; }
.ms-flipstat { min-width: 46px; }
.ms-flipstat b { color: #7df0c0; font-size: 17px; margin-top: 3px; }
.ms-flipstat b.ms-bump { animation: ms-bump .35s cubic-bezier(.3,1.6,.5,1); }
@keyframes ms-bump { 40% { transform: scale(1.5); } }
.ms-sp { flex: 1 1 auto; }
.ms-tool { display: grid; place-items: center; width: 44px; height: 44px; flex: none; border-radius: 12px; border: 1px solid rgba(120,160,220,0.28); background: rgba(8,13,30,0.72);
  color: #cfe4ff; cursor: pointer; touch-action: manipulation; padding: 0; transition: border-color .15s, color .15s, background .15s; }
.ms-tool svg { width: 20px; height: 20px; }
@media (hover: hover) { .ms-tool:hover { border-color: #55d6ff; color: #fff; } }
.ms :focus-visible { outline: 2px solid #55d6ff; outline-offset: 2px; }
#ms-sound .ms-off { display: none; }
#ms-sound[aria-pressed="true"] { color: #7f93b3; }
#ms-sound[aria-pressed="true"] .ms-on { display: none; }
#ms-sound[aria-pressed="true"] .ms-off { display: block; }

/* progress along the track */
.ms-track { position: absolute; left: 14px; right: 14px; top: 62px; height: 5px; border-radius: 3px; background: rgba(8,13,30,0.6); z-index: 2; pointer-events: none; }
.ms-track i { position: absolute; left: 0; top: 0; bottom: 0; width: 0; border-radius: 3px; background: linear-gradient(90deg, #55d6ff, #7df0c0); }
.ms-track b { position: absolute; top: -2px; width: 2px; height: 9px; background: rgba(255,255,255,0.55); border-radius: 1px; }
.ms-track b.is-got { background: #7df0c0; }
.ms-track em { position: absolute; top: -4px; width: 13px; height: 13px; margin-left: -6px; border-radius: 50%; background: #fff; box-shadow: 0 0 0 2px rgba(8,13,30,0.8); left: 0; }
.ms-track span { position: absolute; top: -3px; width: 11px; height: 11px; margin-left: -5px; border-radius: 50%; background: rgba(255,255,255,0.25); border: 1.5px dashed rgba(255,255,255,0.75); left: 0; display: none; }
.ms-track.has-ghost span { display: block; }
.ms-track.is-endless i, .ms-track.is-endless em { display: none; }

/* pop-ups for flips and checkpoints */
.ms-pops { position: absolute; left: 0; right: 0; top: 24%; height: 0; z-index: 2; pointer-events: none; text-align: center; }
.ms-pop { position: absolute; left: 50%; transform: translateX(-50%); white-space: nowrap; font-weight: 900; font-size: 24px; letter-spacing: 0.02em; color: #fff;
  text-shadow: 0 2px 0 rgba(8,12,28,0.8), 0 0 4px rgba(8,12,28,0.95), 0 0 16px rgba(8,12,28,0.6); animation: ms-pop 1.15s ease-out forwards; }
.ms-pop small { display: block; font-size: 15px; font-weight: 800; color: #7df0c0; text-shadow: 0 1px 0 rgba(8,12,28,0.9), 0 0 4px rgba(8,12,28,0.95), 0 0 10px rgba(8,12,28,0.7); }
.ms-pop.is-cp { color: #7df0c0; font-size: 18px; }
.ms-pop.is-bad { color: #ff8fa0; font-size: 18px; }
@keyframes ms-pop { 0% { opacity: 0; transform: translate(-50%, 14px) scale(.7); } 14% { opacity: 1; transform: translate(-50%, 0) scale(1.12); } 24% { transform: translate(-50%, 0) scale(1); } 75% { opacity: 1; } 100% { opacity: 0; transform: translate(-50%, -34px) scale(1); } }
.ms-hint { position: absolute; left: 50%; bottom: 22%; transform: translateX(-50%); z-index: 2; pointer-events: none; padding: 9px 16px; border-radius: 999px; white-space: nowrap;
  background: rgba(6,10,24,0.78); border: 1px solid rgba(255,209,102,0.5); color: #ffe7ad; font-weight: 700; font-size: 15px; animation: ms-breathe 1.6s ease-in-out infinite; }
@keyframes ms-breathe { 50% { transform: translateX(-50%) scale(1.05); } }

/* drive buttons (touch) */
.ms-pad { position: absolute; left: 0; right: 0; bottom: 0; z-index: 3; display: flex; justify-content: space-between; align-items: flex-end; padding: 0 10px 12px; pointer-events: none; }
.ms-pad-l, .ms-pad-r { display: flex; gap: 10px; align-items: flex-end; pointer-events: auto; touch-action: none; }
.ms-drive { width: 74px; height: 74px; border-radius: 22px; border: 2px solid rgba(160,200,255,0.4); background: rgba(8,13,30,0.5); color: #e6f1ff; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 1px; padding: 0; font: inherit; font-size: 11px; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; cursor: pointer;
  touch-action: none; -webkit-tap-highlight-color: transparent; transition: transform .07s, background .07s, border-color .07s; }
.ms-drive svg { width: 30px; height: 30px; }
.ms-drive.is-down { transform: scale(.93); background: rgba(85,214,255,0.32); border-color: #55d6ff; }
.ms-gas { width: 88px; height: 88px; border-radius: 28px; border-color: rgba(125,240,192,0.7); background: rgba(20,70,52,0.55); font-size: 15px; }
.ms-gas.is-down { background: rgba(125,240,192,0.42); border-color: #7df0c0; }
.ms-brake { border-color: rgba(255,143,160,0.6); background: rgba(70,20,32,0.5); font-size: 13px; }
.ms-brake.is-down { background: rgba(255,107,129,0.4); border-color: #ff8fa0; }
.ms.is-short .ms-drive { width: 64px; height: 64px; border-radius: 18px; }
.ms.is-short .ms-gas { width: 76px; height: 76px; }
.ms.is-narrow .ms-pad { padding: 0 6px 10px; }
.ms.is-narrow .ms-pad-l, .ms.is-narrow .ms-pad-r { gap: 6px; }
.ms.is-narrow .ms-drive { width: 58px; height: 58px; font-size: 11px; }
.ms.is-narrow .ms-gas { width: 66px; height: 66px; font-size: 13px; }

.ms-toast { position: absolute; left: 50%; top: 84px; transform: translate(-50%, -8px); z-index: 6; padding: 8px 14px; border-radius: 12px; background: rgba(6,10,24,0.92); border: 1px solid #1c2b4a;
  color: #dfe9ff; font-size: 14px; font-weight: 600; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; max-width: calc(100% - 24px); text-align: center; }
.ms-toast.is-on { opacity: 1; transform: translate(-50%, 0); }

/* menus */
.ms-overlay { position: absolute; inset: 0; z-index: 5; display: flex; align-items: center; justify-content: center; padding: 60px 10px 10px; background: rgba(4,6,15,0.5); }
.ms.is-short:not(.is-narrow) .ms-overlay { padding: 8px 60px; }
.ms-overlay.is-clear { background: rgba(4,6,15,0.28); }
.ms-panel { width: min(430px, 100%); max-height: 100%; overflow: auto; overscroll-behavior: contain; padding: 20px 20px 16px; border-radius: 20px; background: rgba(11,19,40,0.94);
  border: 1px solid #25375e; box-shadow: 0 18px 60px rgba(0,0,0,0.55); text-align: center; touch-action: pan-y; animation: ms-in .22s ease-out; }
@keyframes ms-in { from { opacity: 0; transform: translateY(10px) scale(.98); } }
.ms-panel-wide { width: min(720px, 100%); }
.ms-eyebrow { margin: 0 0 4px; font-size: 11px; font-weight: 800; letter-spacing: 0.18em; text-transform: uppercase; color: #8aa3c4; }
.ms-logo { margin: 0; font-size: clamp(30px, 8vw, 44px); line-height: 1; font-weight: 900; letter-spacing: -0.03em; color: #fff; font-style: italic; }
.ms-logo span { background: linear-gradient(180deg, #ffe08a, #ff8a3c); -webkit-background-clip: text; background-clip: text; color: transparent; padding-right: 0.08em; }
.ms-h { margin: 0 0 4px; font-size: 24px; font-weight: 900; letter-spacing: -0.02em; color: #fff; }
.ms-sub { margin: 8px 0 14px; color: #a9bfdf; font-size: 15px; font-weight: 600; }
.ms-sub b { color: #ffd166; }
.ms-note { margin: 10px 0 2px; min-height: 18px; font-size: 13px; color: #8aa3c4; }
.ms-btn { min-height: 46px; padding: 0 14px; border-radius: 14px; border: 1px solid #2b4070; background: #121d3b; color: #e4eeff; font: inherit; font-size: 15px; font-weight: 700; cursor: pointer;
  touch-action: manipulation; transition: border-color .15s, background .15s, transform .08s; }
@media (hover: hover) { .ms-btn:hover:not(:disabled) { border-color: #55d6ff; background: #17264d; } }
.ms-btn:active:not(:disabled) { transform: scale(.97); }
.ms-btn:disabled { opacity: 0.45; cursor: default; }
.ms-primary { display: block; width: 100%; min-height: 68px; border: 0; border-radius: 18px; font-size: 24px; font-weight: 900; letter-spacing: 0.02em; color: #231400;
  background: linear-gradient(180deg, #ffe08a, #ffab3d); box-shadow: 0 5px 0 #b86a12, 0 12px 26px rgba(255,160,50,0.3); margin: 0 0 14px; }
@media (hover: hover) { .ms-primary:hover:not(:disabled) { background: linear-gradient(180deg, #ffeaa8, #ffb955); } }
.ms-primary:active { transform: translateY(3px); box-shadow: 0 2px 0 #b86a12; }
.ms-primary small { display: block; font-size: 12px; font-weight: 800; letter-spacing: 0.06em; opacity: 0.75; margin-top: -2px; }
.ms-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.ms-row3 { grid-template-columns: 1fr 1fr 1fr; }
.ms-link { margin-top: 6px; min-height: 40px; padding: 0 12px; background: none; border: 0; color: #8fd9ff; font: inherit; font-size: 14px; font-weight: 700; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.ms-head { display: flex; align-items: center; gap: 10px; margin: -4px 0 12px; text-align: left; }
.ms-head .ms-h { flex: 1 1 auto; margin: 0; font-size: 20px; }
.ms-head .ms-btn { min-height: 42px; }
.ms-total { font-weight: 800; color: #ffd166; white-space: nowrap; font-size: 15px; display: inline-flex; align-items: center; gap: 4px; }
.ms-star { width: 1em; height: 1em; display: inline-block; vertical-align: -0.12em; fill: #2a3a5e; }
.ms-star.is-on { fill: #ffd166; }

/* level select */
.ms-worlds { display: flex; gap: 6px; overflow-x: auto; padding: 2px 2px 8px; margin: 0 -4px 6px; scrollbar-width: thin; touch-action: pan-x; }
.ms-world { flex: none; min-height: 44px; padding: 4px 12px; border-radius: 12px; border: 1px solid #2b4070; background: #101a36; color: #c9dcf8; font: inherit; font-size: 13px; font-weight: 700; cursor: pointer; line-height: 1.15; }
.ms-world small { display: block; font-size: 11px; font-weight: 700; color: #8aa3c4; }
.ms-world[aria-pressed="true"] { background: #55d6ff; border-color: #55d6ff; color: #04121a; }
.ms-world[aria-pressed="true"] small { color: #0b3a4a; }
.ms-world.is-locked { opacity: 0.6; }
.ms-wname { margin: 2px 0 8px; text-align: left; font-size: 13px; color: #a9bfdf; min-height: 18px; }
.ms-levels { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.ms-lv { min-height: 64px; padding: 6px 2px 5px; border-radius: 14px; border: 1px solid #2b4070; background: #121d3b; color: #fff; font: inherit; cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; }
.ms-lv b { font-size: 19px; font-weight: 900; line-height: 1; }
.ms-lv i { font-style: normal; font-size: 12px; line-height: 1; display: flex; gap: 1px; }
.ms-lv small { font-size: 10.5px; color: #8aa3c4; font-variant-numeric: tabular-nums; line-height: 1; }
.ms-lv.is-next { border-color: #ffd166; box-shadow: 0 0 0 2px rgba(255,209,102,0.25) inset; }
.ms-lv:disabled { opacity: 0.4; cursor: default; }
@media (hover: hover) { .ms-lv:hover:not(:disabled), .ms-world:hover { border-color: #55d6ff; } }

/* garage */
.ms-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(124px, 1fr)); gap: 8px; margin-bottom: 12px; }
.ms-cards-r { grid-template-columns: repeat(auto-fill, minmax(102px, 1fr)); }
.ms-card { position: relative; padding: 6px 6px 8px; border-radius: 14px; border: 1px solid #2b4070; background: #101a36; color: #dfe9ff; font: inherit; cursor: pointer; text-align: center; min-height: 64px; }
.ms-card canvas { display: block; width: 100%; height: auto; aspect-ratio: 16 / 10; border-radius: 9px; background: #0a1226; }
.ms-card b { display: block; margin-top: 5px; font-size: 13.5px; font-weight: 800; }
.ms-card small { display: block; font-size: 11.5px; color: #8aa3c4; line-height: 1.25; min-height: 14px; }
.ms-card[aria-pressed="true"] { border-color: #7df0c0; box-shadow: 0 0 0 2px rgba(125,240,192,0.3) inset; }
.ms-card[aria-pressed="true"] small { color: #7df0c0; font-weight: 700; }
.ms-card.is-locked canvas { filter: grayscale(0.8) brightness(0.85); }
.ms-card.is-locked small { color: #ffd166; }
.ms-sech { margin: 4px 0 8px; text-align: left; font-size: 12px; font-weight: 800; letter-spacing: 0.14em; text-transform: uppercase; color: #8aa3c4; }

/* finish */
.ms-stars { display: flex; justify-content: center; gap: 10px; margin: 6px 0 8px; font-size: 58px; line-height: 1; }
.ms-stars .ms-star.is-on { animation: ms-star .5s cubic-bezier(.3,1.7,.5,1) backwards; filter: drop-shadow(0 0 12px rgba(255,209,102,0.55)); }
.ms-stars .ms-star:nth-child(2) { animation-delay: .22s; transform: translateY(-8px); } .ms-stars .ms-star:nth-child(3) { animation-delay: .44s; }
@keyframes ms-star { from { transform: scale(0) rotate(-40deg); opacity: 0; } }
.ms-big { font-size: 44px; font-weight: 900; color: #fff; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; line-height: 1.05; }
.ms-big small { font-size: 18px; color: #8aa3c4; font-weight: 800; margin-left: 2px; }
.ms-tag { display: inline-block; margin: 4px 0 2px; padding: 3px 10px; border-radius: 999px; background: rgba(125,240,192,0.16); color: #7df0c0; font-size: 12.5px; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase; }
.ms-list { margin: 10px 0 14px; padding: 0; list-style: none; text-align: left; font-size: 14.5px; }
.ms-list li { display: flex; justify-content: space-between; gap: 12px; padding: 6px 2px; border-bottom: 1px solid rgba(120,160,220,0.14); color: #a9bfdf; }
.ms-list li b { color: #fff; font-variant-numeric: tabular-nums; text-align: right; }
.ms-list li.is-gold b { color: #ffd166; }
.ms-howto { margin: 6px 0 12px; padding: 0 0 0 20px; text-align: left; font-size: 14.5px; line-height: 1.5; color: #c4d6f2; }
.ms-howto li { margin-bottom: 5px; }
.ms-howto b { color: #fff; }

.ms-help { text-align: center; color: #8aa3c4; font-size: 12.5px; padding: 8px 14px 10px; margin: 0; user-select: none; }
.ms-help kbd { background: #16213a; color: #bfe9ff; border-radius: 3px; padding: 1px 5px; font-family: inherit; }
@media (max-width: 600px) { .ms-help { display: none; } .ms-stat { min-width: 54px; padding: 4px 8px 5px; } .ms-stat b { font-size: 19px; } .ms-panel { padding: 16px 14px 12px; } .ms-levels { gap: 6px; } .ms-stars { font-size: 50px; } }
@media (max-height: 520px) { .ms-panel { padding: 12px 14px 10px; } .ms-primary { min-height: 60px; margin-bottom: 10px; } .ms-stars { font-size: 40px; margin: 2px 0; } .ms-big { font-size: 34px; } .ms-sub { margin: 4px 0 8px; } .ms-list { margin: 6px 0 8px; } .ms-list li { padding: 3px 2px; } }
@media (prefers-reduced-motion: reduce) { .ms-panel, .ms-pop, .ms-hint, .ms-stars .ms-star.is-on, .ms-flipstat b.ms-bump { animation-duration: .01s; } .ms-pop { opacity: 0; animation: ms-fade 1.1s linear; } }
@keyframes ms-fade { 0%, 80% { opacity: 1; } 100% { opacity: 0; } }
.ms-lv.is-locked { opacity: 0.4; cursor: default; }
@media (max-width: 600px) { .ms-hud { gap: 5px; padding: 8px 6px 0; } .ms-stat { min-width: 0; padding: 4px 7px 5px; } .ms-stat b { font-size: 18px; } .ms-goal b, .ms-flipstat b { font-size: 15px; } .ms-k { font-size: 9px; letter-spacing: 0.08em; } .ms-tool { width: 42px; height: 42px; } }
.ms.is-narrow .ms-flipstat { display: none; }
.ms-note:has(span:empty) { display: none; }
.ms.is-short .ms-panel-title { width: min(540px, 100%); }
.ms.is-short .ms-logo { font-size: 30px; }
.ms.is-short .ms-sub { margin: 4px 0 8px; }
.ms.is-short .ms-note { margin: 4px 0 0; min-height: 0; }
@media (min-width: 700px) and (min-height: 521px) { .ms-worlds { flex-wrap: wrap; overflow: visible; } .ms-world { flex: 1 1 22%; } }
