/* Merge Defense — cinematic dark futuristic shell */
.md-screen {
  --md-bg: #070b16;
  --md-panel: rgba(18, 26, 46, 0.88);
  --md-cyan: #22d3ee;
  --md-violet: #8b5cf6;
  --md-gold: #fbbf24;
  --md-danger: #ef4444;
  --md-cw: #38bdf8;
  position: relative;
  min-height: 100vh;
  padding: 10px 10px 92px;
  overflow: hidden;
  color: #f8fafc;
  background:
    radial-gradient(ellipse at 50% 0%, rgba(139, 92, 246, 0.22), transparent 42%),
    radial-gradient(ellipse at 80% 60%, rgba(34, 211, 238, 0.12), transparent 40%),
    linear-gradient(180deg, #0a1020 0%, #05070f 55%, #0b0618 100%);
}

.md-screen.hidden {
  display: none !important;
}

.md-particles {
  pointer-events: none;
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(circle at 20% 30%, rgba(34, 211, 238, 0.2) 0 1px, transparent 2px),
    radial-gradient(circle at 70% 60%, rgba(251, 191, 36, 0.18) 0 1px, transparent 2px),
    radial-gradient(circle at 40% 80%, rgba(139, 92, 246, 0.2) 0 1px, transparent 2px);
  background-size: 120px 120px;
  animation: mdDrift 18s linear infinite;
  opacity: 0.55;
}

@keyframes mdDrift {
  from {
    transform: translateY(0);
  }
  to {
    transform: translateY(-40px);
  }
}

.md-view.hidden,
.md-overlay.hidden {
  display: none !important;
}

.md-boot {
  position: absolute;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 50% 40%, rgba(34, 211, 238, 0.12), #05070f 60%);
}

.md-boot-inner {
  width: min(320px, 90vw);
  text-align: center;
}

.md-logo {
  margin: 0;
  font-size: 1.7rem;
  font-weight: 900;
  letter-spacing: 0.04em;
  text-shadow: 0 0 24px rgba(34, 211, 238, 0.45);
  animation: mdPulse 2s ease-in-out infinite;
}

.md-logo-sub {
  margin: 8px 0 22px;
  color: #94a3b8;
  font-size: 0.85rem;
}

.md-boot-bar {
  height: 8px;
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid rgba(34, 211, 238, 0.35);
  background: rgba(255, 255, 255, 0.06);
}

.md-boot-fill {
  display: block;
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #8b5cf6, #22d3ee, #fbbf24);
  background-size: 200% 100%;
  animation: mdShimmer 1.2s linear infinite;
}

@keyframes mdShimmer {
  to {
    background-position: -100% 0;
  }
}

.md-boot-pct {
  margin: 10px 0 0;
  font-weight: 800;
  color: var(--md-cyan);
}

.md-boot-tip {
  margin: 12px 0 0;
  min-height: 2.4em;
  color: #cbd5e1;
  font-size: 0.78rem;
}

@keyframes mdPulse {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.03);
  }
}

.md-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 70vh;
  text-align: center;
  gap: 10px;
  position: relative;
  z-index: 1;
}

.md-hero-title {
  margin: 0;
  font-size: 1.8rem;
  font-weight: 900;
}

.md-hero-tag {
  margin: 0;
  max-width: 280px;
  color: #cbd5e1;
  line-height: 1.55;
}

.md-btn {
  border: 0;
  border-radius: 14px;
  padding: 12px 18px;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
  width: min(300px, 86vw);
  transition: transform 0.15s ease;
}

.md-btn:active {
  transform: scale(0.96);
}

.md-btn-primary {
  background: linear-gradient(180deg, #fde047, #f59e0b 60%, #d97706);
  color: #111827;
  box-shadow: 0 0 22px rgba(251, 191, 36, 0.35);
}

.md-btn-ghost {
  background: rgba(255, 255, 255, 0.06);
  color: #e2e8f0;
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.md-story-card {
  width: min(340px, 92vw);
  padding: 22px 18px;
  border-radius: 18px;
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid rgba(139, 92, 246, 0.35);
  text-align: center;
}

.md-story-card p {
  margin: 0 0 16px;
  line-height: 1.6;
  color: #e2e8f0;
}

.md-lobby {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.md-topbar {
  position: relative;
  z-index: 4;
  padding: 3px 1px 5px;
  border-bottom: 1px solid rgba(150, 121, 69, 0.28);
  background: linear-gradient(180deg, rgba(3, 10, 14, 0.93), rgba(7, 15, 18, 0.75));
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.55);
}

.md-top-row {
  display: grid;
  grid-template-columns: minmax(116px, 1.25fr) minmax(92px, 0.88fr) auto;
  gap: 6px;
  align-items: center;
}

.md-back {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  border: 1px solid rgba(129, 140, 248, 0.4);
  background: rgba(49, 46, 129, 0.35);
  color: #e2e8f0;
  display: grid;
  place-items: center;
  cursor: pointer;
}

.md-back svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.md-user {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.md-user-card {
  position: relative;
  min-height: 53px;
  padding: 4px 7px 4px 4px;
  border: 1px solid #5d4b32;
  border-radius: 5px;
  background:
    linear-gradient(145deg, rgba(25, 37, 41, 0.98), rgba(5, 13, 18, 0.98));
  box-shadow:
    inset 0 0 0 1px rgba(173, 145, 86, 0.13),
    0 3px 8px rgba(0, 0, 0, 0.65);
}

.md-user-card::before,
.md-user-card::after {
  content: "";
  position: absolute;
  width: 7px;
  height: 7px;
  border-color: #b18a45;
}

.md-user-card::before {
  top: 2px;
  left: 2px;
  border-top: 1px solid;
  border-left: 1px solid;
}

.md-user-card::after {
  right: 2px;
  bottom: 2px;
  border-right: 1px solid;
  border-bottom: 1px solid;
}

.md-avatar {
  width: 43px;
  height: 43px;
  border-radius: 7px 4px 7px 4px;
  border: 1px solid #a8762e;
  display: grid;
  place-items: center;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 30%, #25394d, #090f17 70%);
  flex-shrink: 0;
  font-size: 1.42rem;
  box-shadow:
    inset 0 0 9px rgba(251, 191, 36, 0.12),
    0 0 0 2px #091017;
}

.md-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.md-user-copy {
  min-width: 0;
  flex: 1;
}

.md-name {
  margin: 0;
  font-weight: 900;
  font-size: clamp(0.68rem, 2.8vw, 0.82rem);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: #f5f2e8;
  text-shadow: 0 2px 2px #000;
}

.md-level {
  margin: 1px 0 0;
  font-size: 0.62rem;
  font-weight: 800;
  color: #d5d9d5;
}

.md-xp {
  position: relative;
  height: 8px;
  border: 1px solid #101618;
  border-radius: 2px;
  background: #212c2c;
  overflow: hidden;
  margin-top: 2px;
  box-shadow: inset 0 1px 2px #000;
}

.md-xp > i {
  display: block;
  height: 100%;
  background: linear-gradient(180deg, #ffca2f, #c77a04);
  box-shadow: inset 0 1px 0 #ffe98b;
}

.md-xp > b {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #fff5d0;
  font: 700 0.38rem/1 Arial, sans-serif;
  text-shadow: 0 1px 1px #000;
}

.md-top-actions {
  display: flex;
  gap: 5px;
}

.md-top-action {
  width: 41px;
  height: 45px;
  border: 1px solid #536169;
  border-radius: 6px 6px 9px 9px;
  background:
    linear-gradient(145deg, #26343c, #0c151b 68%);
  color: #d7d9d5;
  cursor: pointer;
  position: relative;
  display: grid;
  place-items: center;
  font: 900 1.45rem/1 Arial, sans-serif;
  box-shadow:
    inset 0 0 0 2px #111d23,
    inset 0 1px 0 rgba(255, 255, 255, 0.13),
    0 3px 6px rgba(0, 0, 0, 0.65);
  text-shadow: 0 2px 2px #000;
}

.md-wallets {
  display: grid;
  grid-template-columns: 1fr;
  gap: 3px;
}

.md-chip {
  display: grid;
  grid-template-columns: 21px minmax(34px, 1fr) 21px;
  align-items: center;
  gap: 2px;
  height: 25px;
  padding: 1px;
  border: 1px solid #35454c;
  border-radius: 4px;
  background: linear-gradient(180deg, #111d23, #050b0f);
  font-size: clamp(0.61rem, 2.7vw, 0.76rem);
  font-weight: 900;
  cursor: pointer;
  color: #f2f1e8;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.md-chip strong {
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.md-chip-gold {
  border-color: #6e572f;
}
.md-chip-gem {
  border-color: #51456e;
}

.md-currency-icon {
  display: grid;
  place-items: center;
  font-size: 0.9rem;
  filter: drop-shadow(0 1px 2px #000);
}

.md-currency-plus {
  display: grid;
  width: 19px;
  height: 19px;
  place-items: center;
  border: 1px solid #bd7a2b;
  border-radius: 3px;
  background: linear-gradient(180deg, #d9912d, #77400e);
  color: #fff5ce;
  font: 900 1rem/1 Arial, sans-serif;
  box-shadow: inset 0 1px 0 rgba(255, 229, 146, 0.4);
}

.md-close-x {
  position: relative;
  width: 18px;
  height: 18px;
}

.md-close-x::before,
.md-close-x::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 20px;
  height: 3px;
  border-radius: 1px;
  background: #e8ebe8;
  box-shadow: 0 1px 1px #000;
}

.md-close-x::before {
  transform: translate(-50%, -50%) rotate(45deg);
}

.md-close-x::after {
  transform: translate(-50%, -50%) rotate(-45deg);
}

@media (max-width: 350px) {
  .md-top-row {
    grid-template-columns: minmax(105px, 1.15fr) minmax(82px, 0.82fr) auto;
    gap: 3px;
  }

  .md-top-actions {
    gap: 3px;
  }

  .md-top-action {
    width: 34px;
    height: 42px;
  }

  .md-avatar {
    width: 38px;
    height: 38px;
  }
}

.md-stage {
  position: relative;
  min-height: 250px;
  border-radius: 20px;
  padding: 14px;
  border: 1px solid rgba(139, 92, 246, 0.3);
  background:
    radial-gradient(ellipse at 50% 70%, rgba(34, 211, 238, 0.16), transparent 55%),
    linear-gradient(180deg, rgba(15, 23, 42, 0.55), rgba(2, 6, 23, 0.85));
  overflow: hidden;
  text-align: center;
}

.md-core {
  font-size: 4.2rem;
  margin: 18px 0 8px;
  filter: drop-shadow(0 12px 28px rgba(34, 211, 238, 0.45));
  animation: mdPulse 2.4s ease-in-out infinite;
}

.md-stage h2 {
  margin: 0;
  font-size: 1.05rem;
}

.md-stage p {
  margin: 6px 0 14px;
  color: #94a3b8;
  font-size: 0.8rem;
}

.md-battle-cta {
  width: min(280px, 100%);
  margin: 0 auto;
  display: block;
  border: 0;
  border-radius: 16px;
  padding: 14px 16px;
  font: inherit;
  font-weight: 900;
  font-size: 1.1rem;
  cursor: pointer;
  color: #111827;
  background: linear-gradient(180deg, #fde047, #f59e0b 55%, #d97706);
  box-shadow: 0 0 26px rgba(251, 191, 36, 0.4);
  animation: mdBounce 2s ease-in-out infinite;
}

@keyframes mdBounce {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-3px);
  }
}

.md-quick {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}

.md-quick button {
  border: 0;
  border-radius: 12px;
  padding: 10px 4px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: inherit;
  font: inherit;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 3px;
  align-items: center;
}

.md-quick span {
  font-size: 1.1rem;
}
.md-quick small {
  font-size: 0.55rem;
  font-weight: 800;
  color: #94a3b8;
}

.md-bottom-nav {
  position: fixed;
  bottom: max(4px, env(safe-area-inset-bottom));
  left: 7px;
  right: 7px;
  z-index: 30;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  direction: ltr;
  gap: 5px;
  padding: 7px 6px 6px;
  border: 2px solid #101b23;
  border-radius: 8px 8px 0 0;
  background:
    linear-gradient(180deg, rgba(20, 33, 41, 0.99), rgba(5, 13, 18, 0.99));
  box-shadow:
    0 -2px 0 rgba(91, 111, 113, 0.25),
    0 -12px 30px rgba(0, 0, 0, 0.72),
    inset 0 1px 0 rgba(156, 175, 164, 0.13);
}

.md-nav-btn {
  position: relative;
  border: 1px solid #243640;
  border-radius: 5px;
  background:
    linear-gradient(145deg, rgba(29, 44, 54, 0.98), rgba(8, 19, 26, 0.98));
  color: #c9d0cc;
  font: inherit;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  min-width: 0;
  min-height: 68px;
  padding: 5px 1px 4px;
  box-shadow:
    inset 0 1px 0 rgba(190, 207, 198, 0.14),
    inset 0 -2px 0 rgba(0, 0, 0, 0.45),
    0 1px 3px rgba(0, 0, 0, 0.5);
  text-shadow: 0 2px 2px #000;
}

.md-nav-btn small {
  direction: rtl;
  max-width: 100%;
  overflow: hidden;
  font-size: clamp(0.52rem, 2.2vw, 0.66rem);
  font-weight: 900;
  line-height: 1.15;
  white-space: nowrap;
}

.md-nav-btn.is-active {
  border-color: #8f6322;
  color: #fff4c6;
  background:
    radial-gradient(circle at 50% 20%, rgba(255, 192, 73, 0.3), transparent 47%),
    linear-gradient(145deg, #7f501b, #3b230d);
  box-shadow:
    inset 0 0 0 1px rgba(255, 204, 101, 0.2),
    inset 0 2px 0 rgba(255, 220, 145, 0.18),
    0 0 10px rgba(224, 144, 35, 0.2);
}

.md-nav-ico {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  font-size: 1.65rem;
  line-height: 1;
  filter: drop-shadow(0 2px 2px #000);
}

.md-nav-btn.is-active .md-nav-ico {
  filter:
    drop-shadow(0 2px 2px #000)
    drop-shadow(0 0 5px rgba(255, 188, 63, 0.7));
}

.md-nav-alert {
  position: absolute;
  top: -5px;
  right: -3px;
  z-index: 2;
  display: grid;
  width: 18px;
  height: 18px;
  place-items: center;
  border: 1px solid #ffb4a8;
  border-radius: 50%;
  background: linear-gradient(#ed3b2f, #9d110d);
  color: #fff;
  font: 900 12px/1 Arial, sans-serif;
  box-shadow: 0 2px 4px #000;
  text-shadow: 0 1px 1px #5b0000;
}

.md-panel {
  position: relative;
  z-index: 1;
  padding: 12px;
  border-radius: 16px;
  background: rgba(15, 23, 42, 0.75);
  border: 1px solid rgba(139, 92, 246, 0.25);
}

.md-panel h2 {
  margin: 0 0 10px;
  font-size: 1.05rem;
}

.md-weapon-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.md-weapon-card {
  text-align: right;
  padding: 10px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(0, 0, 0, 0.25);
  color: inherit;
  font: inherit;
  cursor: pointer;
}

.md-weapon-card.is-owned {
  border-color: rgba(34, 211, 238, 0.4);
}

.md-weapon-card strong {
  display: block;
}
.md-weapon-card small {
  color: #94a3b8;
}

.md-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 12px 0;
}

.md-slot {
  aspect-ratio: 1;
  border-radius: 14px;
  border: 1px dashed rgba(34, 211, 238, 0.35);
  background: rgba(0, 0, 0, 0.28);
  display: grid;
  place-items: center;
  font-size: 1.6rem;
  cursor: pointer;
  color: #64748b;
}

.md-slot.is-filled {
  border-style: solid;
  border-color: rgba(251, 191, 36, 0.5);
  color: #f8fafc;
  box-shadow: inset 0 0 16px rgba(251, 191, 36, 0.12);
}

.md-battle-hud {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  font-weight: 800;
  font-size: 0.85rem;
}

.md-arena {
  position: relative;
  height: 320px;
  border-radius: 16px;
  border: 1px solid rgba(34, 211, 238, 0.25);
  background:
    radial-gradient(circle at 50% 85%, rgba(34, 211, 238, 0.2), transparent 40%),
    repeating-linear-gradient(
      0deg,
      transparent 0 28px,
      rgba(255, 255, 255, 0.03) 28px 29px
    ),
    repeating-linear-gradient(
      90deg,
      transparent 0 28px,
      rgba(255, 255, 255, 0.03) 28px 29px
    ),
    #0b1224;
  overflow: hidden;
}

.md-core-base {
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 2.4rem;
  filter: drop-shadow(0 0 16px rgba(34, 211, 238, 0.5));
}

.md-enemy {
  position: absolute;
  font-size: 1.3rem;
  transition: top 0.9s linear;
  filter: drop-shadow(0 0 8px rgba(239, 68, 68, 0.5));
}

.md-dmg {
  position: absolute;
  font-weight: 900;
  color: #fdba74;
  animation: mdFloat 0.8s ease forwards;
  pointer-events: none;
}

@keyframes mdFloat {
  to {
    transform: translateY(-28px);
    opacity: 0;
  }
}

.md-overlay {
  position: absolute;
  inset: 0;
  z-index: 35;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(2, 6, 23, 0.78);
  backdrop-filter: blur(6px);
}

.md-modal {
  width: min(340px, 92vw);
  padding: 18px;
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(30, 27, 75, 0.95), rgba(15, 23, 42, 0.98));
  border: 1px solid rgba(139, 92, 246, 0.4);
  text-align: center;
}

.md-modal h3 {
  margin: 0 0 8px;
}

.md-modal p {
  margin: 0 0 12px;
  color: #cbd5e1;
  font-size: 0.88rem;
}

.md-stars {
  color: #fbbf24;
  font-size: 1.4rem;
  letter-spacing: 2px;
  margin-bottom: 10px;
}

.md-row-btns {
  display: grid;
  gap: 8px;
}

.md-status {
  min-height: 1.2em;
  text-align: center;
  color: #fdba74;
  font-weight: 700;
  font-size: 0.8rem;
}
