:root {
  --text: #f5edd6;
  --muted: #c4b998;
  --cartoon-green: #2d6e1e;
  --cartoon-brown: #5c3a1e;
  --cartoon-gold: #ffcf33;
  --cartoon-red: #e83030;
  --cartoon-blue: #1e7ae8;
  --cartoon-dark: #1a2e0c;
  --panel-bg: rgba(18, 40, 8, 0.88);
  --panel-border: #7a5230;
  --wood-light: #a67c52;
  --wood-dark: #4a2a10;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: 'Trebuchet MS', 'Segoe UI', sans-serif;
  color: var(--text);
  background: linear-gradient(170deg, #0d1f05 0%, #1a3a0b 40%, #2a4f15 100%);
}

body {
  overflow-x: hidden;
}

.aurora {
  position: fixed;
  z-index: -1;
  border-radius: 999px;
  filter: blur(60px);
  opacity: 0.15;
}

.aurora-a {
  width: 380px;
  height: 380px;
  left: -120px;
  top: -100px;
  background: #3d8a20;
  animation: drift 11s ease-in-out infinite;
}

.aurora-b {
  width: 420px;
  height: 420px;
  right: -140px;
  bottom: -130px;
  background: #1a5c10;
  animation: drift 13s ease-in-out infinite reverse;
}

@keyframes drift {
  0%,
  100% { transform: translate(0, 0); }
  50% { transform: translate(36px, -30px); }
}

.game-shell {
  max-width: 1400px;
  margin: 0 auto;
  padding: 14px;
  display: grid;
  gap: 12px;
}

.glass {
  background: var(--panel-bg);
  border: 4px solid var(--panel-border);
  backdrop-filter: none;
  box-shadow: 0 6px 0 rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.hud-top {
  border-radius: 18px;
  padding: 12px 14px;
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.hud-top h1 {
  margin: 0;
  font-family: 'Bungee', 'Trebuchet MS', sans-serif;
  font-size: clamp(24px, 3vw, 36px);
  color: var(--cartoon-gold);
  text-shadow: 0 3px 0 #8a5a00, 0 0 12px rgba(255, 200, 0, 0.3);
}

.hud-top p {
  margin: 3px 0 0;
  color: var(--muted);
}

.top-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.icon-btn,
.pill-btn,
.cta {
  border: 3px solid rgba(0, 0, 0, 0.3);
  border-radius: 14px;
  color: #fff;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 5px 0 rgba(0, 0, 0, 0.4), 0 8px 16px rgba(0, 0, 0, 0.2);
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.35);
  transition: transform 0.08s, box-shadow 0.08s;
}

.icon-btn:active,
.pill-btn:active,
.cta:active {
  transform: translateY(3px);
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.4), 0 4px 8px rgba(0, 0, 0, 0.2);
}

.icon-btn {
  width: 44px;
  height: 44px;
  font-size: 20px;
  background: linear-gradient(180deg, #4a9e32, #2d6e1e);
  border-color: #1a4a0e;
}

.pill-btn {
  padding: 10px 16px;
  font-size: 14px;
  background: linear-gradient(180deg, #f5a623, #d4841a);
  border-color: #8a5510;
}

.lang-btn {
  min-width: 58px;
}

.pill-btn.danger {
  background: linear-gradient(180deg, #e84040, #b02020);
  border-color: #6e1010;
}

.cta {
  padding: 12px 22px;
  font-size: 18px;
  background: linear-gradient(180deg, #5ec43e, #38a020);
  border-color: #1e6a10;
  color: #fff;
}

.friend-banner {
  border-radius: 16px;
  padding: 10px 12px;
  color: var(--cartoon-gold);
}

.main-grid {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 12px;
}

.left-panel {
  border-radius: 18px;
  padding: 12px;
  display: grid;
  gap: 10px;
  align-content: start;
}

.panel-title {
  font-size: 12px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--cartoon-gold);
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.5);
}

.turn-pill {
  border-radius: 14px;
  padding: 10px;
  font-weight: 900;
  font-size: 20px;
  text-align: center;
  background: linear-gradient(180deg, #f5a623, #c47a10);
  color: #fff;
  border: 3px solid #8a5510;
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.2);
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.35);
}

.stats {
  border-radius: 14px;
  background: rgba(20, 45, 10, 0.8);
  border: 3px solid var(--panel-border);
  padding: 10px;
  font-size: 14px;
  line-height: 1.5;
  color: var(--muted);
}

.weapon-list {
  display: grid;
  gap: 8px;
}

.weapon-item {
  border: 3px solid var(--wood-light);
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(40, 65, 20, 0.9), rgba(25, 50, 12, 0.95));
  padding: 8px;
  text-align: left;
  color: var(--text);
  cursor: pointer;
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.3);
  transition: transform 0.08s, box-shadow 0.08s;
}

.weapon-item:hover {
  background: linear-gradient(180deg, rgba(55, 85, 30, 0.9), rgba(35, 60, 18, 0.95));
}

.weapon-item.active {
  border-color: var(--cartoon-gold);
  box-shadow: 0 0 12px rgba(255, 207, 51, 0.5), 0 3px 0 rgba(0, 0, 0, 0.3);
  background: linear-gradient(180deg, rgba(60, 90, 25, 0.95), rgba(40, 65, 15, 0.95));
}

.weapon-item strong {
  display: block;
}

.weapon-item span {
  font-size: 12px;
  color: var(--muted);
}

.tips {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  font-size: 13px;
}

.arena-wrap {
  border-radius: 18px;
  padding: 10px;
  position: relative;
}

.arena-stage {
  position: relative;
  border-radius: 14px;
  overflow: hidden;
  border: 4px solid var(--wood-dark);
  box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.4);
}

.cheese-map-layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 2;
  overflow: visible;
}

#arena {
  position: relative;
  z-index: 1;
  background: transparent;
}

.worm-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 3;
}

.speech-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 4;
}

.combat-hud {
  position: absolute;
  left: 18px;
  right: 18px;
  top: 12px;
  z-index: 6;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 16px;
  pointer-events: none;
}

.mk-side {
  display: grid;
  gap: 6px;
}

.mk-side.bot {
  justify-items: end;
}

.mk-label {
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 1.2px;
  color: #fff;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.9), 0 0 8px rgba(0, 0, 0, 0.5);
}

.mk-bar-shell {
  width: min(410px, 35vw);
  height: 18px;
  border-radius: 999px;
  border: 3px solid var(--wood-dark);
  background: rgba(10, 10, 10, 0.7);
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.4), inset 0 2px 4px rgba(0, 0, 0, 0.5);
  overflow: hidden;
}

.mk-bar-fill {
  height: 100%;
  width: 100%;
  transition: width 160ms linear;
}

.mk-bar-fill.player {
  background: linear-gradient(180deg, #4ac4ff, #1a7ae8);
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.2), inset 0 2px 0 rgba(255, 255, 255, 0.25);
}

.mk-bar-fill.bot {
  background: linear-gradient(180deg, #ff6040, #e82020);
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.2), inset 0 2px 0 rgba(255, 255, 255, 0.25);
}

.mk-value {
  font-size: 12px;
  font-weight: 900;
  color: #ffffff;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.9);
}

.mk-vs {
  align-self: center;
  border-radius: 14px;
  padding: 6px 11px;
  background: linear-gradient(180deg, var(--cartoon-gold), #d4a010);
  border: 3px solid var(--wood-dark);
  font-family: 'Bungee', 'Trebuchet MS', sans-serif;
  font-weight: 900;
  color: #3a1f00;
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.4);
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.3);
}

.worm-sprite {
  position: absolute;
  width: 88px;
  height: 88px;
  transform: translate(-50%, -82%);
}

.worm-sprite svg {
  width: 100%;
  height: 100%;
  overflow: visible;
}

.worm-hp {
  position: absolute;
  left: 50%;
  top: -8px;
  width: 44px;
  height: 6px;
  transform: translateX(-50%);
  border-radius: 999px;
  background: rgba(10, 10, 10, 0.7);
  border: 2px solid var(--wood-dark);
  overflow: hidden;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.4);
}

.worm-hp-fill {
  height: 100%;
  width: 100%;
  background: #22c55e;
}

.worm-sprite .wiggle {
  transform-origin: 50% 75%;
  animation: wormBob 1.2s ease-in-out infinite;
}

.worm-sprite .smoke {
  animation: smokeRise 2s ease-out infinite;
}


@keyframes wormBob {
  0%, 100% { transform: translateY(0px) rotate(0deg); }
  50% { transform: translateY(-2px) rotate(-1deg); }
}

@keyframes wormBlink {
  0%, 92%, 100% { opacity: 1; }
  94%, 96% { opacity: 0.2; }
}

@keyframes smokeRise {
  0% { opacity: 0.35; transform: translate(0, 0) scale(0.9); }
  100% { opacity: 0; transform: translate(0, -7px) scale(1.35); }
}

.speech-bubble {
  position: absolute;
  max-width: 220px;
  color: #fff;
  font-weight: 900;
  font-size: 21px;
  line-height: 1.05;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 14px 20px;
  border-radius: 18px;
  border: 4px solid var(--wood-dark);
  filter: drop-shadow(0 5px 0 rgba(0, 0, 0, 0.4));
  transform: translate(-50%, -130%) scale(0.92);
  animation: bubbleIn 0.25s ease forwards;
  white-space: nowrap;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.35);
}

.speech-bubble.pink {
  background: linear-gradient(180deg, #ff4590, #d41a6a);
}

.speech-bubble.orange {
  background: linear-gradient(180deg, #ffb020, #d48a00);
}

.speech-bubble::after {
  content: "";
  position: absolute;
  left: calc(50% - 10px);
  bottom: -14px;
  width: 28px;
  height: 20px;
  background: inherit;
  border-bottom-left-radius: 18px;
  clip-path: polygon(0 0, 100% 0, 24% 100%);
}

.speech-bubble.exit {
  animation: bubbleOut 0.25s ease forwards;
}

@keyframes bubbleIn {
  to { transform: scale(1); opacity: 1; }
}

@keyframes bubbleOut {
  to { transform: translateY(-8px) scale(0.9); opacity: 0; }
}

#arena {
  width: 100%;
  height: auto;
  border: none;
  display: block;
  background: transparent;
}

.bottom-hud {
  margin-top: 8px;
  display: grid;
  gap: 8px;
}

#statusText {
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(40, 65, 20, 0.9), rgba(25, 50, 12, 0.95));
  border: 3px solid var(--panel-border);
  padding: 8px;
  font-weight: 800;
  color: var(--cartoon-gold);
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.4);
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.3);
}

.meter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  font-size: 14px;
  color: var(--muted);
}

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(5, 15, 2, 0.6);
  display: grid;
  place-items: center;
  z-index: 20;
}

.overlay-card {
  width: min(560px, calc(100vw - 24px));
  border-radius: 20px;
  padding: 20px;
  text-align: center;
  border: 5px solid var(--panel-border);
  background: var(--panel-bg);
  box-shadow: 0 8px 0 rgba(0, 0, 0, 0.5), 0 20px 40px rgba(0, 0, 0, 0.4);
}

.victory-badge {
  width: min(360px, 90%);
  margin: 2px auto 12px;
  background: linear-gradient(180deg, #d4841a, #a05a10);
  border-radius: 20px;
  padding: 10px 16px 14px;
  border: 4px solid var(--cartoon-gold);
  box-shadow: 0 6px 0 rgba(0, 0, 0, 0.4), inset 0 2px 0 rgba(255, 255, 255, 0.15);
}

.badge-stars {
  color: var(--cartoon-gold);
  font-size: 28px;
  letter-spacing: 2px;
  text-shadow: 0 3px 0 rgba(0, 0, 0, 0.4);
}

.badge-text {
  color: #fff;
  font-family: 'Bungee', 'Trebuchet MS', sans-serif;
  font-size: 42px;
  line-height: 1;
  font-weight: 900;
  text-shadow: 0 4px 0 rgba(0, 0, 0, 0.4);
}

.mascot {
  font-size: 46px;
}

.action-row {
  margin-top: 10px;
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
}

.hidden {
  display: none !important;
}

@media (max-width: 980px) {
  .main-grid {
    grid-template-columns: 1fr;
  }

  .left-panel {
    order: 2;
  }

  .combat-hud {
    left: 10px;
    right: 10px;
    top: 8px;
    gap: 8px;
  }

  .mk-bar-shell {
    width: min(270px, 34vw);
    height: 14px;
  }

  .mk-vs {
    padding: 4px 8px;
    font-size: 12px;
  }
}
