/* Web3 tap game theme */
:root {
  --mg-bg-a: #f5f9ff;
  --mg-bg-b: #eaf3ff;
  --mg-bg-c: #dbe9ff;
  --mg-accent: #2f78dc;
  --mg-accent-2: #0f5ec8;
  --mg-warning: #f5c451;
  --mg-text: #ffffff;
  --mg-text-white: #ffffff;
  --mg-muted: #e4e4e4;
  --mg-card: rgba(255, 255, 255, 0.9);
  --mg-border: rgba(85, 131, 206, 0.25);
  --mg-card-bg: linear-gradient(165deg, rgba(22, 38, 65, 0.8), rgba(42, 72, 113, 0.8));
  --mg-card-bg-hover: linear-gradient(165deg, rgba(15, 57, 117, 0.74), rgba(12, 60, 133, 0.7));
  --mg-card-bg-active: linear-gradient(165deg, rgba(45, 99, 175, 0.8), rgba(8, 51, 116, 0.76));
  --mg-orb-axis-x-base: -5px;
  --mg-orb-axis-y-base: -50px;
  --mg-orb-axis-x: clamp(-5px, calc(var(--mg-orb-axis-x-base) + (100vw - 1800px) * 0.02), 140px);
  --mg-orb-axis-y: clamp(-50px, calc(var(--mg-orb-axis-y-base) + (100vh - 1009px) * 0.12), 180px);
    background: linear-gradient(165deg, rgba(17, 78, 164, 0.95), rgba(12, 52, 113, 0.94));
}
* {
  box-sizing: border-box;
}

body.minigame-body {
  height: 100dvh;
  min-height: 100dvh;
  color: var(--mg-text);
  background:
    radial-gradient(circle at 12% 18%, rgba(68, 132, 237, 0.25), transparent 42%),
    radial-gradient(circle at 86% 6%, rgba(108, 165, 255, 0.26), transparent 36%),
    linear-gradient(135deg, var(--mg-bg-a), var(--mg-bg-b) 46%, var(--mg-bg-c));
  font-family: "Oxanium", "Space Grotesk", "Segoe UI", sans-serif;
  overflow: hidden;
}

body.minigame-body[data-mg-page="login"] {
  background: #020611 url("../img/bg_cover.jpg") center center / cover no-repeat;
}

@media (max-width: 768px) {
  body.minigame-body[data-mg-page="login"] {
    background: #020611 url("../img/bg_cover_portrait.jpg") center top / contain no-repeat;
  }
}

body.minigame-body[data-mg-page="game"] {
  --mg-game-bg-image: url("../img/at_earth2.png");
  background:
    linear-gradient(180deg, rgba(9, 22, 45, 0.02) 0%, rgba(9, 22, 45, 0.08) 100%),
    var(--mg-game-bg-image) center bottom / cover no-repeat;
}

body.minigame-body[data-mg-page="login"]::before,
body.minigame-body[data-mg-page="login"]::after,
body.minigame-body[data-mg-page="game"]::before,
body.minigame-body[data-mg-page="game"]::after {
  display: none;
}

.minigame-body::before,
.minigame-body::after {
  content: "";
  position: fixed;
  width: 40vw;
  height: 40vw;
  border-radius: 50%;
  filter: blur(42px);
  z-index: 0;
  pointer-events: none;
  opacity: 0.28;
}

.minigame-body::before {
  top: -12vw;
  left: -8vw;
  background: #9fc3ff;
}

.minigame-body::after {
  bottom: -10vw;
  right: -10vw;
  background: #d5e6ff;
}

.minigame-shell {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: none;
  height: 100dvh;
  min-height: 100dvh;
  padding-inline: 1.4rem;
}

.minigame-panel {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr);
  grid-template-areas:
    "side main"
    "tabs main";
  gap: 0.9rem;
  height: 100%;
  min-height: 0;
  overflow: hidden;
  /* padding: 0.95rem; */
}

.tab-card-title {
  color: var(--mg-text);
  font-weight: 700;
  font-size: 1.78rem;
}

.mg-side-hud {
  grid-area: side;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}

.mg-main-stage {
  grid-area: main;
}

.mg-nav-tabs-side {
  grid-area: tabs;
  align-self: start;
}

.mg-side-hud .mg-top-profile-card {
  height: auto;
  min-height: 0;
  padding: 0.68rem 0.72rem;
  background: var(--mg-card-bg);
  border: 1px solid rgba(86, 136, 212, 0.58);
  border-radius: 0.95rem;
  backdrop-filter: none;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.15),
    0 8px 16px rgba(41, 91, 165, 0.22);
}

.mg-side-hud .mg-profile-header-card {
  height: auto;
  min-height: 0;
}

.mg-side-hud .mg-profile-header {
  align-items: stretch;
  justify-content: flex-start;
  text-align: left;
  gap: 0.6rem;
}

.mg-profile-main {
  display: flex;
  align-items: center;
  gap: 0.62rem;
}

.mg-profile-identity {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.mg-side-hud .mg-profile-avatar {
  width: 60px;
  height: 60px;
  border: 2px solid rgba(133, 184, 255, 0.72);
  box-shadow: 0 8px 20px rgba(4, 24, 58, 0.45);
}

.mg-side-hud .mg-profile-name {
  font-size: 1.02rem;
  line-height: 1.2;
  color: #f4f8ff;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mg-profile-rank {
  font-size: 0.78rem;
  color: rgba(216, 232, 255, 0.95);
  font-weight: 600;
}

.mg-profile-level-row {
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

.mg-profile-level-label {
  font-size: 0.76rem;
  font-weight: 800;
  color: #ffd84c;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.mg-profile-level-track {
  flex: 1;
  height: 14px;
  border-radius: 999px;
  background: rgba(6, 24, 53, 0.72);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.35);
  overflow: hidden;
  border: 1px solid rgba(109, 154, 230, 0.25);
}

.mg-profile-level-track > span {
  display: block;
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, #ffe654 0%, #ffd739 45%, #ffbf1d 100%);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.24);
  transition: width 0.2s ease;
}

.mg-profile-referral {
  border: 1px solid rgba(137, 182, 244, 0.42);
  background: linear-gradient(170deg, rgba(35, 98, 191, 0.28), rgba(18, 61, 129, 0.26));
  border-radius: 0.72rem;
  padding: 0.62rem;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.14),
    0 8px 16px rgba(41, 91, 165, 0.16);
}

.mg-profile-referral-label {
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  color: rgba(211, 230, 255, 0.94);
  text-transform: uppercase;
  margin-bottom: 0.3rem;
}

.mg-profile-referral-code {
  font-size: 1.18rem;
  font-weight: 800;
  color: #f2f8ff;
  letter-spacing: 0.08em;
  margin-bottom: 0.45rem;
}

.mg-profile-referral-actions {
  display: flex;
  align-items: center;
  gap: 0.42rem;
}

.mg-profile-referral-actions .mg-referral-input {
  min-width: 0;
  height: 32px;
  font-size: 0.78rem;
  background: rgba(245, 250, 255, 0.96);
  border-color: rgba(137, 177, 238, 0.6);
}

.mg-profile-referral-actions .btn {
  min-width: 58px;
  height: 32px;
  padding-inline: 0.62rem;
}

.mg-main-stage {
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}

.mg-hud-top {
  display: inline-flex;
  align-items: stretch;
  gap: 0.7rem;
  width: fit-content;
  max-width: 100%;
  margin-left: auto;
}

.mg-stat-compact {
  min-height: 58px;
  padding: 0.7rem 0.85rem;
  width: fit-content;
}

.mg-stat-inline {
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

.mg-stat-icon {
  width: 26px;
  height: 26px;
  object-fit: contain;
  flex: 0 0 auto;
}

.mg-rank-icon {
  width: 20px;
  height: 20px;
  object-fit: contain;
  flex: 0 0 auto;
}

.mg-power-logout-btn {
  border: 1px solid rgba(86, 136, 212, 0.58);
  background: var(--mg-card-bg);
  border-radius: 0.65rem;
  width: 58px;
  min-height: 58px;
  height: auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  align-self: stretch;
  padding: 0;
  transition: background-color 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease, transform 0.12s ease;
}

.mg-hud-top .mg-stat {
  border: 1px solid rgba(86, 136, 212, 0.58);
  background: var(--mg-card-bg);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.15),
    0 8px 16px rgba(41, 91, 165, 0.22);
}

.mg-hud-top .mg-stat .mg-stat-value,
.mg-hud-top .mg-energy-value {
  color: #f4f8ff;
}

.mg-power-logout-btn:hover {
  background: var(--mg-card-bg-hover);
  border-color: rgba(98, 147, 223, 0.68);
  box-shadow: 0 6px 14px rgba(46, 96, 170, 0.2);
}

.mg-power-logout-btn:focus-visible {
  outline: none;
  background: var(--mg-card-bg-active);
  border-color: rgba(98, 147, 223, 0.72);
  box-shadow: 0 0 0 0.16rem rgba(68, 122, 208, 0.24);
}

.mg-power-logout-btn:active {
  transform: translateY(1px);
}

.mg-logout-icon {
  width: 22px;
  height: 22px;
  object-fit: contain;
}

.mg-stat-compact .mg-stat-value {
  font-size: 1.15rem;
  line-height: 1.1;
}

.mg-stat-compact.is-score .mg-stat-value {
  font-size: clamp(1.65rem, 2.2vw, 2.45rem);
  font-weight: 900;
  line-height: 1;
  letter-spacing: 0.02em;
}

.mg-energy-inline {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  width: auto;
}

.mg-energy-inline .mg-energy-progress {
  flex: 0 1 auto;
  width: clamp(130px, 18vw, 220px);
  min-width: 120px;
}

.mg-energy-value {
  white-space: nowrap;
  font-size: 1.2rem;
  font-weight: 800;
}

.mg-stat-energy {
  display: flex;
  align-items: center;
}

.mg-referral-card-side .mg-referral-code {
  font-size: 1.4rem;
  letter-spacing: 0.04em;
}

.mg-referral-card-side .mg-referral-link-wrap {
  flex-direction: column;
  align-items: stretch;
}

.mg-referral-card-side .btn {
  width: 100%;
}

.mg-card {
  background: var(--mg-card);
  border: 1px solid var(--mg-border);
  border-radius: 1.15rem;
  backdrop-filter: blur(6px);
  box-shadow: 0 16px 35px rgba(37, 77, 136, 0.14);
}
.mg-card-pure {
  /* background: rgba(255, 255, 255, 0.16); */
  /* border: 1px solid rgba(255, 255, 255, 0.34); */
  border-radius: 1.15rem;
  box-shadow: 0 16px 35px rgba(37, 77, 136, 0.14);
}

.mg-muted {
  color: var(--mg-muted);
}

.mg-user-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  background: rgba(246, 251, 255, 0.95);
  border: 1px solid rgba(98, 145, 223, 0.4);
  border-radius: 999px;
  padding: 0.4rem 0.9rem;
  font-size: 0.85rem;
}

.mg-user-pill img {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid rgba(85, 132, 206, 0.38);
}

.mg-profile-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 0.5rem;
}

.mg-profile-avatar-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
}

.mg-profile-avatar {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid rgba(116, 157, 225, 0.7);
  box-shadow: 0 8px 22px rgba(12, 45, 99, 0.34);
}

.mg-profile-avatar-fallback {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(140deg, #1f3f79, #1556b0);
  color: #eef4ff;
  font-weight: 700;
  font-size: 1.3rem;
}

.mg-profile-name {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--mg-text);
}

.mg-profile-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.7rem;
  flex-wrap: wrap;
}

.mg-profile-actions .btn {
  min-width: 86px;
}

.mg-top-row {
  align-items: stretch;
}

.mg-top-col-left {
  display: flex;
  justify-content: flex-start;
  flex-direction: column;
  gap: 0.65rem;
}

.mg-top-col-right {
  display: flex;
  justify-content: flex-start;
  flex-direction: column;
  gap: 0.65rem;
}

.mg-profile-header-card {
  height: 100%;
  min-height: 95px;
  justify-content: center;
}

.mg-top-profile-card {
  width: 100%;
  height: 100%;
  min-height: 100%;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(6px);
  border: 1px solid rgba(103, 148, 221, 0.3);
  border-radius: 0.85rem;
  padding: 0.85rem;
}

.mg-btn-icon {
  width: 16px;
  height: 16px;
  display: block;
}

.mg-logout-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-height: 32px;
  padding-left: 0.65rem;
  padding-right: 0.65rem;
  border-radius: 0.5rem;
}

.mg-refresh-btn {
  width: 34px;
  height: 34px;
  min-width: 34px;
  border-radius: 0.5rem;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.mg-energy-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.mg-stat-energy {
  height: 100%;
}

.mg-stat-score-energy {
  min-height: auto;
}

.mg-score-energy-divider {
  border-top: 1px solid rgba(98, 140, 208, 0.32);
  margin: 0.7rem 0;
}

@media (min-width: 768px) {
  .mg-top-row {
    min-height: 108px;
  }

  .mg-top-col-center {
    display: flex;
    justify-content: center;
  }

  .mg-top-col-center .mg-profile-header-card {
    width: 100%;
  }

  .mg-top-col-left .mg-stat,
  .mg-top-col-right .mg-stat {
    width: 100%;
  }
}

.mg-score-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.4rem 0.75rem;
  border-radius: 999px;
  border: 1px solid rgba(95, 140, 214, 0.42);
  background: rgba(255, 255, 255, 0.92);
}

.mg-score-label {
  font-size: 0.75rem;
  color: var(--mg-muted);
}

.mg-score-value {
  font-size: 0.95rem;
  font-weight: 700;
  color: #17396b;
}

.mg-stat {
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(103, 148, 221, 0.3);
  border-radius: 0.85rem;
  backdrop-filter: blur(6px);
  /* padding: 0.85rem; */
  /* min-height: 95px; */
}

.mg-stat-label {
  color: var(--mg-muted);
  font-size: 0.78rem;
  margin-bottom: 0.25rem;
}

.mg-stat-value {
  font-size: 1.45rem;
  font-weight: 700;
  color: var(--mg-text);
}

.mg-referral-card {
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(103, 148, 221, 0.3);
  border-radius: 0.85rem;
  backdrop-filter: blur(6px);
  padding: 0.85rem;
}

.mg-referral-card-top {
  padding-top: 0.75rem;
  padding-bottom: 0.75rem;
}

.mg-top-referral-card {
  width: 100%;
  height: 100%;
  margin-bottom: 0;
  display: flex;
  flex-direction: column;
}

.mg-top-referral-card .mg-referral-stack {
  flex: 1;
  justify-content: space-between;
  gap: 0.9rem;
}

.mg-top-referral-card .mg-referral-input {
  min-width: 0;
}

.mg-top-referral-card .mg-referral-link-wrap {
  flex-direction: column;
  align-items: stretch;
}

.mg-top-referral-card .mg-referral-link-wrap .btn {
  width: 100%;
}

.mg-referral-stack {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.5rem;
}

.mg-referral-link-wrap {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.mg-referral-code {
  font-size: 2.3rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--mg-text);
}

.mg-title{
  color: var(--mg-text-white);
}
.mg-brand {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--mg-text-white);
}

.mg-referral-input {
  width: 100%;
  /* min-width: min(56vw, 420px); */
  background: #f6faff;
  border: 1px solid rgba(116, 151, 214, 0.48);
  color: #1a3762;
}

#refreshStateBtn {
  min-width: 34px;
}

.mg-referral-input:focus {
  border-color: rgba(133, 175, 244, 0.7);
  box-shadow: 0 0 0 0.16rem rgba(68, 122, 208, 0.25);
}

.mg-energy-progress {
  --mg-energy-segments: 10;
  position: relative;
  height: 18px;
  background: linear-gradient(180deg, #dbe7fb, #cbdcf7);
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid rgba(102, 137, 198, 0.4);
  box-shadow: inset 0 1px 2px rgba(255, 255, 255, 0.75);
}

.mg-energy-progress > span {
  display: block;
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #2f78dc 0%, #3d89f5 55%, #5aa7ff 100%);
  transition: width 0.25s ease;
}

.mg-energy-progress::after {
  content: "";
  position: absolute;
  inset: 0px;
  border-radius: 999px;
  pointer-events: none;
  background-image: linear-gradient(
    to right,
    transparent calc(100% - 1px),
    rgba(236, 244, 255, 0.96) calc(100% - 1px),
    rgba(236, 244, 255, 0.96) 100%
  );
  background-size: calc(100% / var(--mg-energy-segments)) 100%;
}

.mg-game-zone {
  position: relative;
  min-height: 300px;
  width: 100%;
  height: 100%;
  padding: 0.45rem !important;
  border-radius: 1rem;
  /* border: 1px dashed rgba(80, 120, 194, 0.32); */
  /* background: linear-gradient(145deg, rgba(245, 250, 255, 0.88), rgba(224, 237, 255, 0.9)); */
  display: grid;
  place-items: center;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.mg-orb {
  --mg-orb-size: min(54vmin, 400px);
  width: var(--mg-orb-size);
  height: var(--mg-orb-size);
  border: 0;
  border-radius: 1.4rem;
  position: relative;
  isolation: isolate;
  color: #eff5ff;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0;
  background: transparent;
  box-shadow: none;
  transition: transform 0.12s ease;
}
.tap-text{
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: clamp(1.2rem, 2vw, 1.8rem);
  font-weight: 700;
  color: #ffffff;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 0.5rem;
  padding: 0.3rem 0.6rem;
  max-width: 200px;
}
.tap-text-shadow{
  font-size: clamp(0.4rem, 2vw, 0.8rem);
  font-weight: 700;
  color: #ffffff;
  display: block;
}
@media (min-width: 993px) {
  .mg-orb {
    --mg-orb-size: clamp(600px, 28vw, 740px);
  }
}

#home-tab-pane.tab-pane.active .mg-orb {
  position: fixed;
  left: calc(50% + var(--mg-orb-axis-x));
  top: calc(50% + var(--mg-orb-axis-y));
  z-index: 6;
  margin-left: calc(var(--mg-orb-size) * -0.5);
  margin-top: calc(var(--mg-orb-size) * -0.5);
}

.mg-orb,
.mg-orb * {
  user-select: none;
  -webkit-user-select: none;
  -webkit-user-drag: none;
}

.mg-orb::before,
.mg-orb::after {
  content: "";
  position: absolute;
  pointer-events: none;
  z-index: -1;
}

.mg-orb::before {
  width: 86%;
  height: 64%;
  background: radial-gradient(ellipse at 52% 48%, rgba(109, 166, 255, 0.35) 0%, rgba(58, 120, 218, 0.2) 42%, rgba(12, 45, 99, 0) 76%);
  border-radius: 55% 45% 50% 50% / 45% 55% 52% 48%;
  filter: blur(10px);
}

.mg-orb::after {
  width: 72%;
  height: 44%;
  background: radial-gradient(ellipse at 50% 50%, rgba(176, 212, 255, 0.2) 0%, rgba(65, 118, 198, 0.08) 48%, rgba(65, 118, 198, 0) 78%);
  border-radius: 58% 42% 44% 56% / 46% 54% 50% 50%;
  filter: blur(15px);
}

.mg-orb-face {
  position: relative;
  width: 98%;
  height: 98%;
  transform: translateY(0);
}

.mg-orb-face-layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  left: 0;
  object-fit: contain;
  transition: opacity 0.32s ease, transform 0.32s ease;
}

.mg-orb-face-layer.is-init {
  opacity: 1;
  transform: scale(1);
}

.mg-orb-face-layer.is-active {
  opacity: 0;
  transform: scale(0.94);
}

.mg-orb.is-expression-active .mg-orb-face-layer.is-init {
  opacity: 0;
  transform: scale(1.04);
}

.mg-orb.is-expression-active .mg-orb-face-layer.is-active {
  opacity: 1;
  transform: scale(1);
}

.mg-orb:active {
  transform: scale(0.96);
}

.mg-orb.is-empty {
  filter: grayscale(0.3) brightness(0.92);
  opacity: 0.78;
}

.mg-orb-pulse {
  animation: mgPulse 0.35s ease;
}

@keyframes mgPulse {
  0% { transform: scale(1); }
  35% { transform: scale(0.94); }
  65% { transform: scale(1.06); }
  100% { transform: scale(1); }
}

.mg-shake {
  animation: mgShake 0.25s linear;
}

@keyframes mgShake {
  0% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  50% { transform: translateX(4px); }
  75% { transform: translateX(-3px); }
  100% { transform: translateX(0); }
}

.mg-float-score {
  position: absolute;
  font-weight: 800;
  font-size: clamp(1.35rem, 2vw, 1.85rem);
  letter-spacing: 0.03em;
  color: var(--mg-text);
  text-shadow:
    0 0 10px rgba(239, 234, 226, 0.85),
    0 0 24px rgba(239, 234, 226, 0.45),
    0 4px 10px rgba(0, 0, 0, 0.35);
  pointer-events: none;
  transform: translate(-50%, -50%);
  animation: scoreFloat 0.8s ease forwards;
  z-index: 10;
}

.mg-tap-ambience {
  position: absolute;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  pointer-events: none;
  transform: translate(-50%, -50%);
  background:
    radial-gradient(circle, rgba(124, 178, 255, 0.42) 0%, rgba(76, 137, 227, 0.22) 34%, rgba(21, 86, 176, 0.12) 58%, rgba(21, 86, 176, 0) 74%);
  box-shadow:
    0 0 24px rgba(116, 170, 255, 0.22),
    0 0 54px rgba(37, 108, 212, 0.14);
  animation: mgAmbienceBurst 0.85s ease-out forwards;
  z-index: 2;
}

@keyframes scoreFloat {
  from { opacity: 1; transform: translateY(0) scale(1); }
  to { opacity: 0; transform: translateY(-60px) scale(1.12); }
}

@keyframes mgAmbienceBurst {
  0% {
    opacity: 0.7;
    transform: translate(-50%, -50%) scale(0.4);
  }
  55% {
    opacity: 0.32;
    transform: translate(-50%, -50%) scale(8.5);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(12);
  }
}

.btn-mg-primary {
  border: 0;
  color: #f5fbff;
  background: linear-gradient(90deg, #1a5fca, #2f78dc 55%, #4894ff);
  font-weight: 600;
}

.btn-mg-primary.js-claim-boost {
  min-width: 108px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
}

.btn-mg-primary.js-claim-boost.is-loading {
  opacity: 0.92;
  cursor: wait;
}

.mg-btn-spinner {
  width: 0.85rem;
  height: 0.85rem;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: rgba(255, 255, 255, 0.98);
  border-radius: 50%;
  animation: mgSpin 0.65s linear infinite;
}

@keyframes mgSpin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.btn-mg-outline {
  border: 1px solid rgba(104, 147, 218, 0.46);
  color: var(--mg-text);
  background: var(--mg-tab-bg);
}

.mg-note {
  font-size: 0.94rem;
  color: var(--mg-muted);
}

.mg-nav-tabs {
  margin: 0 0 1rem;
  /* border: 1px solid rgba(103, 148, 221, 0.36); */
  /* border-radius: 0.9rem; */
  /* background: rgba(255, 255, 255, 0.92); */
  /* backdrop-filter: blur(6px); */
  /* box-shadow: inset 0 0 0 1px rgba(116, 158, 224, 0.12); */
  display: flex;
  justify-content: stretch;
  gap: 0.35rem;
  border:0px !important;
  padding: 0;
}

.mg-nav-tabs-side {
  margin: 0;
  flex-direction: column;
  gap: 0.45rem;
}

.mg-nav-tabs-side .nav-item {
  flex: 0 0 auto;
}

.mg-nav-tabs-side .nav-item .nav-link {
  height: 112px;
}


.mg-nav-tabs-side .nav-link {
  text-align: center;
  padding: 0.58rem 0.5rem;
  font-size: 0.83rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
}

.mg-tab-link {
  text-decoration: none;
}

.mg-tab-icon {
  width: 52px;
  height: 52px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.mg-tab-icon-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  filter: saturate(1.12);
}

.mg-tab-text {
  line-height: 1;
}

.mg-nav-tabs .nav-item {
  display: flex;
  flex: 1;
}

/* Keep sidebar tabs compact on desktop; mobile overrides this in media query. */
.mg-nav-tabs-side .nav-item {
  flex: 0 0 auto;
}

.mg-nav-tabs .nav-link {
  color: #cad9ef;
  border: 1px solid rgba(86, 136, 212, 0.58);
  background: var(--mg-card-bg);
  border-radius: 0.65rem;
  font-weight: 600;
  width: 100%;
  padding: 0.52rem 1.15rem;
  text-align: center;
  line-height: 1;
  transition: all 0.2s ease;
  backdrop-filter: blur(2px);
}

.mg-nav-tabs .nav-link:hover {
  color: #f5f7f9;
  border-color: rgba(100, 143, 215, 0.42);
  background: var(--mg-card-bg-hover);
}

.mg-nav-tabs .nav-link.active,
.mg-nav-tabs .nav-link.active:hover {
  color: #f7fbff;
  border-color: rgba(86, 136, 212, 0.58);
  background: var(--mg-card-bg-active);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.15),
    0 8px 16px rgba(41, 91, 165, 0.22);
}

.mg-nav-tabs .nav-link.active .mg-tab-icon,
.mg-nav-tabs .nav-link.active:hover .mg-tab-icon {
  transform: translateY(-1px);
}

.mg-nav-tabs .nav-link.active .mg-tab-icon-img,
.mg-nav-tabs .nav-link.active:hover .mg-tab-icon-img {
  filter: saturate(1.2) brightness(1.05);
}

.mg-tab-card {
  min-height: calc(100vh - 20rem);
  border: 1px solid rgba(101, 146, 220, 0.26);
  border-radius: 0.9rem;
  background: var(--mg-card-bg);
  backdrop-filter: blur(2px);
  padding: 30px;
}

#minigameTabContent {
  display: flex;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  border-radius: 0.95rem;
  /* backdrop-filter: blur(3px); */
}

#minigameTabContent .tab-pane {
  width: 100%;
  min-height: 0;
}

#home-tab-pane.tab-pane.active {
  display: grid;
  grid-template-rows: minmax(0, 1fr);
  flex: 1;
  width: 100%;
  min-height: 0;
}

#boost-tab-pane.tab-pane.active,
#leaderboard-tab-pane.tab-pane.active,
#howtoplay-tab-pane.tab-pane.active {
  flex: 1;
  width: 100%;
  min-height: 0;
  overflow-y: auto;
  padding-right: 0.1rem;
}

#boost-tab-pane .mg-tab-card,
#leaderboard-tab-pane .mg-tab-card,
#howtoplay-tab-pane .mg-tab-card {
  width: 100%;
  min-height: 100%;
  height: auto;
}

#home-tab-pane #gameZone {
  flex: 1;
  height: 100%;
  width: 100%;
  min-height: 0;
  display: grid;
  place-items: center;
  place-content: center;
}

.mg-quest-card {
  border: 1px solid rgba(98, 141, 212, 0.28);
  border-radius: 0.85rem;
  padding: 0.95rem;
  background: var(--mg-card-bg);
  backdrop-filter: blur(2px);
}
.mg-quest-card h3 {
  font-size: 1.25rem;
  font-weight: 700;
  color: #ffffff;
}

.mg-quest-badge {
  font-size: 0.72rem;
  border-radius: 999px;
  padding: 0.2rem 0.6rem;
  border: 1px solid rgba(106, 151, 222, 0.55);
  color: #ffffff;
}

.mg-quest-badge.is-claimed {
  color: #d2f5d8;
  border-color: rgba(91, 189, 124, 0.6);
  background: rgba(40, 95, 56, 0.45);
}

.mg-quest-reward {
  font-weight: 700;
  color: #ffc625;
  font-size: 1.15rem;
}

.mg-leader-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border: 1px solid rgba(100, 146, 220, 0.28);
  border-radius: 0.8rem;
  padding: 0.65rem 0.8rem;
  background: linear-gradient(135deg, rgba(173, 173, 173, 0.3), rgba(114, 114, 114, 0.3) 55%, rgba(0, 0, 0, 0.3));
  backdrop-filter: blur(4px);
  margin-bottom: 0.55rem;
}

.mg-leader-rank {
  min-width: 2.3rem;
  color: #fff;
  font-weight: 700;
}

.mg-leader-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid rgba(99, 144, 216, 0.5);
}

.mg-leader-fallback {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(140deg, #1f3f79, #1556b0);
  color: #eef4ff;
  font-weight: 700;
}

.mg-leader-name {
  color: #ffffff;
}

.mg-leader-meta {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.mg-leader-subtext {
  color: rgba(255, 255, 255, 0.72);
  font-size: 0.74rem;
  line-height: 1.15;
}

.mg-leader-score {
  font-weight: 700;
  color: #f7b603;
}

.mg-leader-trophy {
  width: 28px;
  height: 28px;
  object-fit: contain;
  margin-right: 0.25rem;
}

.mg-empty {
  border: 1px dashed rgba(98, 141, 212, 0.36);
  border-radius: 0.85rem;
  padding: 1rem;
  text-align: center;
  color: var(--mg-muted);
  background: rgba(242, 248, 255, 0.9);
}

#mgToast.show {
  opacity: 1 !important;
}

#mgToast.mg-toast {
  background: rgba(255, 255, 255, 0.96);
  color: #14305a;
  border: 1px solid rgba(91, 139, 215, 0.42);
  box-shadow: 0 8px 18px rgba(41, 91, 165, 0.2);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  z-index: 1200;
  font-weight: 700;
  line-height: 1.25;
}

.mg-login-wrap {
  position: absolute;
  top: 65%;
  left: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transform: translate(-50%, -50%);
}
.login-story{
  font-size: 1.35rem;
  color: var(--mg-text);
  margin-bottom: 1.25rem;
}

.mg-login-card {
  width: min(94vw, 720px);
  padding: 1.4rem;
}

.mg-google-button {
  min-height: 42px;
}

.mg-custom-google-btn {
  padding: 0.89rem 40px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.7);
  box-shadow:
    0 14px 28px rgba(0, 0, 0, 0.24),
    inset 0 1px 0 rgba(255, 255, 255, 0.85);
  background: linear-gradient(180deg, #f8fafc 0%, #e5e7eb 45%, #cfd5dd 100%);
  color: #1f2937;
}

.mg-custom-google-btn:hover,
.mg-custom-google-btn:focus,
.mg-custom-google-btn:focus-visible,
.mg-custom-google-btn:active {
  color: #111827;
  background: linear-gradient(180deg, #ffffff 0%, #e7ebef 45%, #c9d0d8 100%);
  border-color: rgba(255, 255, 255, 0.88);
  box-shadow:
    0 16px 30px rgba(0, 0, 0, 0.26),
    inset 0 1px 0 rgba(255, 255, 255, 0.95);
  text-decoration: none;
}

#googleSignInFallback[disabled] {
  opacity: 0.65;
  cursor: not-allowed;
}

@media (max-width: 992px) {
  .minigame-shell {
    padding-inline: 0.95rem;
  }

  .minigame-panel {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(0, 1fr) auto;
    grid-template-areas:
      "side"
      "main"
      "tabs";
    /* padding: 0.75rem; */
  }

  .mg-side-hud {
    display: block;
  }

  .mg-side-hud .mg-top-profile-card {
    padding: 0.62rem 0.68rem;
  }

  .mg-hud-top {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    width: 100%;
    margin-left: 0;
  }

  .mg-stat-compact {
    width: 100%;
  }

  .mg-energy-inline {
    gap: 0.55rem;
  }

  .mg-energy-inline .mg-energy-progress {
    min-width: 0;
  }

  .mg-nav-tabs-side {
    flex-direction: row;
    gap: 0.55rem;
  }

  .mg-nav-tabs-side .nav-item {
    flex: 1;
  }

  .mg-nav-tabs-side .nav-link {
    text-align: center;
  }

  .mg-tab-icon {
    width: 44px;
    height: 44px;
  }

  .mg-game-zone {
    min-height: 0;
  }

  .mg-referral-input {
    min-width: 100%;
  }

  .mg-referral-link-wrap {
    flex-direction: column;
    align-items: stretch;
  }

  .mg-referral-link-wrap .btn {
    width: 100%;
  }

  #refreshStateBtn {
    width: 34px;
  }

  .mg-tab-card {
    min-height: auto;
  }

  .mg-nav-tabs {
    width: 100%;
    justify-content: stretch;
    flex-wrap: nowrap;
    margin-bottom: 0;
  }

  #home-tab-pane.tab-pane.active {
    min-height: 0;
  }

  #home-tab-pane #gameZone {
    min-height: 0;
  }
}

@media (max-width: 576px) {
  .minigame-shell {
    padding-inline: 0.6rem;
  }

  .minigame-panel {
    gap: 0.55rem;
    /* padding: 0.55rem; */
  }

  .mg-hud-top {
    gap: 0.55rem;
  }

  .mg-stat-compact {
    padding: 0.62rem 0.72rem;
    min-height: 52px;
  }

  .mg-stat-compact.is-score .mg-stat-value {
    font-size: clamp(1.35rem, 6vw, 1.8rem);
  }

  .mg-energy-value {
    font-size: 1.02rem;
  }

  .mg-stat-icon {
    width: 22px;
    height: 22px;
  }

  .mg-power-logout-btn {
    width: 52px;
    min-height: 52px;
  }

  .mg-side-hud .mg-profile-avatar {
    width: 54px;
    height: 54px;
  }

  .mg-side-hud .mg-profile-name {
    font-size: 0.96rem;
  }

  .mg-profile-referral-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .mg-profile-referral-actions .btn,
  .mg-profile-referral-actions .mg-referral-input {
    width: 100%;
  }

  .mg-profile-level-track {
    height: 12px;
  }

  .mg-referral-card-side .mg-referral-link-wrap {
    display: none;
  }

  .mg-stat {
    min-height: auto;
  }

  .mg-orb {
    --mg-orb-size: min(76vmin, 310px);
    font-size: 0.92rem;
  }

  .mg-nav-tabs .nav-link {
    padding: 0.5rem 0.8rem;
    font-size: 0.88rem;
  }

  .mg-referral-input {
    min-width: 100%;
  }

  #mgToast.mg-toast {
    max-width: calc(100vw - 1.2rem);
    font-size: 0.83rem;
    padding: 0.44rem 0.7rem !important;
    margin-bottom: calc(env(safe-area-inset-bottom, 0px) + 0.42rem) !important;
    text-align: center;
  }

}

@media (max-width: 992px) and (orientation: portrait) {
  :root {
    --mg-orb-axis-x-base: 30px;
    --mg-orb-axis-y-base: 110px;
  }

  .minigame-shell {
    padding-inline: 0.5rem;
    padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 0.45rem);
  }

  .minigame-panel {
    gap: 0.34rem;
  }

  .mg-side-hud .mg-top-profile-card {
    padding: 0.38rem 0.46rem;
    border-radius: 0.72rem;
  }

  .mg-profile-main {
    gap: 0.45rem;
  }

  .mg-side-hud .mg-profile-avatar {
    width: 38px;
    height: 38px;
  }

  .mg-side-hud .mg-profile-name {
    font-size: 0.82rem;
  }

  .mg-profile-rank {
    font-size: 0.66rem;
  }

  .mg-profile-level-track {
    height: 8px;
  }

  .mg-profile-level-label {
    font-size: 0.66rem;
  }

  .mg-profile-referral {
    padding: 0.38rem;
    border-radius: 0.56rem;
  }

  .mg-profile-referral-label {
    font-size: 0.6rem;
    margin-bottom: 0.12rem;
  }

  .mg-profile-referral-code {
    font-size: 0.9rem;
    margin-bottom: 0.2rem;
  }

  .mg-profile-referral-actions {
    flex-direction: row;
    gap: 0.28rem;
  }

  .mg-profile-referral-actions .mg-referral-input,
  .mg-profile-referral-actions .btn {
    height: 26px;
    font-size: 0.7rem;
  }

  .mg-profile-referral-actions .btn {
    width: auto;
    min-width: 50px;
    padding-inline: 0.42rem;
  }

  .mg-main-stage {
    gap: 0.34rem;
    min-height: 0;
  }

  .mg-hud-top {
    flex-direction: row;
    width: 100%;
    gap: 0.28rem;
  }

  .mg-hud-top .mg-stat {
    flex: 1;
    min-width: 0;
    min-height: 48px;
    padding: 0.34rem 0.45rem;
  }

  .mg-stat-compact.is-score {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    flex: 0 0 120px;
    max-width: 120px;
  }

  .mg-stat-compact.is-score .mg-stat-inline {
    width: 100%;
    justify-content: flex-start;
  }

  .mg-stat-compact.is-score .mg-stat-value {
    line-height: 1;
  }

  .mg-stat-energy {
    flex: 1 1 auto;
  }

  .mg-stat-icon {
    width: 16px;
    height: 16px;
  }

  .mg-stat-compact.is-score .mg-stat-value {
    font-size: clamp(0.95rem, 4.2vw, 1.15rem);
  }

  .mg-energy-inline {
    gap: 0.34rem;
  }

  .mg-energy-inline .mg-energy-progress {
    width: 100%;
    min-width: 90px;
    height: 14px;
  }

  .mg-energy-value {
    font-size: 0.74rem;
    font-weight: 700;
  }

  .mg-power-logout-btn {
    width: 40px;
    min-height: 40px;
    flex: 0 0 40px;
    border-radius: 0.5rem;
  }

  .mg-logout-icon {
    width: 16px;
    height: 16px;
  }

  #minigameTabContent {
    border-radius: 0.75rem;
  }

  .mg-game-zone {
    min-height: 0;
    padding: 0 !important;
  }

  .mg-orb {
    --mg-orb-size: min(68vmin, 292px);
  }

  .mg-nav-tabs-side {
    gap: 0.42rem;
  }

  .mg-nav-tabs-side .nav-link {
    min-height: 82px;
    height: 82px;
    padding: 0.35rem 0.3rem;
    border-radius: 0.62rem;
  }

  .mg-tab-icon {
    width: 34px;
    height: 34px;
  }

  .mg-tab-text {
    font-size: 0.88rem;
  }
}

@media (max-width: 992px) and (orientation: landscape) {
  #home-tab-pane #gameZone {
    padding: 0 !important;
  }

  .mg-orb {
    --mg-orb-size: min(48vmin, 292px);
  }
}
@media (min-height: 400px) and (orientation: portrait) {
  :root {
    --mg-orb-axis-x-base: 30px;
    --mg-orb-axis-y-base: 30px;
  }
}
@media (min-height: 700px) and (orientation: portrait) {
  :root {
    --mg-orb-axis-x-base: 30px;
    --mg-orb-axis-y-base: 100px;
  }
}
@media (min-height: 900px) and (orientation: portrait) {
  :root {
    --mg-orb-axis-x-base: 30px;
    --mg-orb-axis-y-base: 120px;
  }
}