
html,
body {
  margin: 0;
  padding: 0;
  overflow: hidden;
  height: 100vh;
  user-select: none;
  background: #87CEEB;
}

/* ── Loading overlay ─────────────────────────────────────── */
#loading-overlay {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: linear-gradient(135deg, #0a0e1a 0%, #101828 50%, #0a1220 100%);
  z-index: 2147483647;
  justify-content: center;
  align-items: center;
}
#loading-content {
  text-align: center;
  width: 70%;
  max-width: 320px;
}
#loading-title {
  font-family: 'Luckiest Guy', cursive;
  font-size: 2.4em;
  color: #e0e8f0;
  text-shadow: 0 0 16px rgba(80, 160, 240, 0.5), 2px 2px 6px rgba(0,0,0,0.9);
  margin-bottom: 28px;
}
#loading-bar-track {
  width: 100%;
  height: 14px;
  background: rgba(255,255,255,0.08);
  border-radius: 7px;
  border: 1px solid rgba(100, 160, 200, 0.3);
  overflow: hidden;
}
#loading-bar-fill {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, #2a6090, #44aadd, #66ccff);
  border-radius: 7px;
  transition: width 0.3s ease;
}
#loading-status {
  font-family: 'Patrick Hand', cursive;
  font-size: 1em;
  color: rgba(200, 220, 240, 0.6);
  margin-top: 12px;
}

#game-container {
  position: relative;
  overflow: hidden;
  user-select: none;

}

#main-menu {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  gap: clamp(2px, 0.6vmin, 6px);
}

#menu-spacer {
  flex: 1;
  max-height: 22%;
}

#menu-title {
  font-family: 'Luckiest Guy', cursive;
  font-size: clamp(2.4em, 8vmin, 4em);
  color: #e0e8f0;
  text-shadow: 0 0 16px rgba(80, 160, 240, 0.5), 2px 2px 6px rgba(0, 0, 0, 0.9);
  letter-spacing: 4px;
  margin-bottom: clamp(12px, 3vmin, 28px);
  user-select: none;
}

.menu-info-btn {
  width: clamp(40px, 10vmin, 52px);
  height: clamp(40px, 10vmin, 52px);
  border-radius: 50%;
  border: 2px solid rgba(100, 160, 200, 0.4);
  background: rgba(14, 22, 38, 0.85);
  color: #ccd8e4;
  font-family: 'Luckiest Guy', cursive;
  font-size: clamp(1.1em, 3.5vmin, 1.5em);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s ease, background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

.menu-bottom-row {
  margin-top: auto;
  padding-bottom: clamp(14px, 4vmin, 28px);
  display: flex;
  gap: clamp(14px, 4vmin, 22px);
}

.menu-info-btn:hover {
  transform: scale(1.12);
  background: rgba(22, 40, 65, 0.9);
  border-color: rgba(100, 180, 220, 0.7);
  box-shadow: 0 0 10px rgba(60, 140, 200, 0.2), 0 2px 6px rgba(0, 0, 0, 0.4);
}

.settings-delete-btn {
  display: block;
  width: 100%;
  margin-top: 10px;
  padding: 6px 0;
  font-family: 'Patrick Hand', cursive;
  font-size: 0.8em;
  color: #ff8888;
  background: rgba(60, 15, 25, 0.6);
  border: 2px solid rgba(170, 85, 102, 0.5);
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
}
.settings-delete-btn:hover {
  border-color: rgba(255, 80, 80, 0.7);
  background: rgba(80, 15, 25, 0.9);
  box-shadow: 0 0 10px rgba(200, 60, 60, 0.2);
}

/* ── Panel backdrop (click-outside-to-close) ─────────── */
.panel-backdrop {
  display: none;
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 10000;
}

.panel-backdrop.visible {
  display: flex;
  justify-content: center;
  align-items: center;
}

/* ── Sticky close button ─────────────────────────────── */
.panel-close-btn {
  position: sticky;
  bottom: 0;
  z-index: 1;
  margin-top: 12px;
  flex-shrink: 0;
  align-self: center;
}


.guide-footer {
  margin-top: 14px;
  padding-top: 10px;
  border-top: 1px solid rgba(100, 160, 200, 0.15);
  text-align: center;
}
.guide-creator {
  font-family: 'Luckiest Guy', cursive;
  font-size: 0.85em;
  color: #c0d0e0;
  letter-spacing: 0.5px;
  margin-bottom: 3px;
}
.guide-testers {
  font-size: 0.55em;
  opacity: 0.4;
  display: flex;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
}
.us-flag {
  display: inline-block;
  width: 16px;
  height: 10px;
  border-radius: 2px;
  background: repeating-linear-gradient(
    to bottom,
    #B22234 0px, #B22234 1.4px,
    #fff 1.4px, #fff 2.8px
  );
  position: relative;
  overflow: hidden;
  vertical-align: middle;
  margin-left: 2px;
}
.us-flag::before {
  content: '';
  display: block;
  position: absolute;
  top: 0;
  left: 0;
  width: 7px;
  height: 5.5px;
  background: #3C3B6E;
}
.ua-flag {
  display: inline-block;
  width: 14px;
  height: 9px;
  border-radius: 2px;
  background: linear-gradient(to bottom, #005BBB 50%, #FFD500 50%);
  vertical-align: middle;
  margin-left: 1px;
}

#settings-panel {
  position: relative;
  width: 80%;
  max-width: 360px;
  background: rgba(8, 12, 20, 0.92);
  border: 2px solid rgba(100, 160, 200, 0.5);
  border-radius: 16px;
  padding: 24px 20px;
  color: #dde4ec;
  font-family: 'Patrick Hand', cursive;
  text-align: center;
}
#settings-panel h2 {
  font-family: 'Luckiest Guy', cursive;
  font-size: 1.8em;
  color: #e0e8f0;
  text-shadow: 0 0 8px rgba(80, 160, 220, 0.4), 2px 2px 4px rgba(0, 0, 0, 0.8);
  margin: 0 0 16px 0;
}
.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 12px 0;
}
.settings-label {
  font-size: 1.1em;
}
.settings-toggle {
  display: flex;
  gap: 4px;
}
.detail-btn {
  font-family: 'Patrick Hand', cursive;
  font-size: 0.95em;
  padding: 6px 14px;
  border-radius: 8px;
  border: 2px solid rgba(100, 160, 200, 0.3);
  background: rgba(30, 40, 60, 0.8);
  color: #8899aa;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.detail-btn.active {
  background: rgba(40, 100, 200, 0.7);
  border-color: rgba(80, 160, 240, 0.7);
  color: #fff;
}

.menu-btn {
  font-family: 'Luckiest Guy', cursive;
  font-size: clamp(1em, 3.5vmin, 1.4em);
  width: min(240px, 62vw);
  padding: clamp(10px, 2.5vmin, 16px) 0;
  margin: clamp(3px, 1vmin, 8px) 0;
  border-radius: 10px;
  border: 2px solid rgba(100, 160, 200, 0.45);
  background: linear-gradient(145deg, rgba(18, 30, 52, 0.9), rgba(12, 20, 38, 0.95));
  color: #e0e8f0;
  text-shadow: 0 0 6px rgba(80, 160, 220, 0.3), 1px 1px 2px rgba(0, 0, 0, 0.9);
  -webkit-text-stroke: 0.5px rgba(0, 0, 0, 0.4);
  letter-spacing: 0.5px;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

.menu-btn:hover {
  transform: scale(1.08);
  background: linear-gradient(145deg, rgba(25, 45, 70, 0.95), rgba(18, 32, 55, 0.98));
  border-color: rgba(100, 180, 220, 0.7);
  box-shadow: 0 4px 16px rgba(60, 140, 200, 0.2), 0 2px 8px rgba(0, 0, 0, 0.5);
}

.menu-btn:active {
  transform: scale(0.97);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
}

.menu-btn-disabled {
  opacity: 0.35;
  cursor: not-allowed;
  pointer-events: none;
  filter: grayscale(0.7);
  font-size: clamp(0.7em, 2.5vmin, 1em);
}

#endless-timer {
  display: none;
  position: fixed;
  top: 8px;
  left: 50%;
  transform: translateX(-50%);
  font-family: 'Luckiest Guy', cursive;
  font-size: 2em;
  color: #fff;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.8);
  z-index: 9999;
  pointer-events: none;
  user-select: none;
  align-items: center;
  gap: 6px;
}

#ui-overlay {

  visibility: hidden;
  /* Initially hidden */
  position: fixed;
  bottom: 0;
  left: 55%;
  transform: translateX(-50%);
  z-index: 100;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
touch-action: manipulation;

}

#wipe-text {
  visibility: hidden;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  background: radial-gradient(ellipse at center, rgba(0,0,0,0.85) 0%, rgba(0,0,0,0.6) 60%, rgba(0,0,0,0.3) 100%);
  z-index: 9999;
  user-select: none;
  touch-action: manipulation;
  animation: wipe-fade-in 0.8s ease-out;
}

@keyframes wipe-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.wipe-title {
  font-family: 'Luckiest Guy', cursive;
  font-size: 72px;
  color: #ff4444;
  text-shadow: 0 0 20px rgba(255,60,60,0.6), 0 4px 8px rgba(0,0,0,0.8);
  letter-spacing: 4px;
  animation: wipe-title-in 0.6s ease-out;
}

@keyframes wipe-title-in {
  from { transform: scale(1.8); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.wipe-subtitle {
  font-family: 'Luckiest Guy', cursive;
  font-size: 36px;
  color: #dde4ec;
  text-shadow: 0 0 12px rgba(80,160,220,0.4), 0 2px 4px rgba(0,0,0,0.8);
  margin-top: 12px;
  animation: wipe-subtitle-in 0.6s ease-out 0.3s both;
}

@keyframes wipe-subtitle-in {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

#pause-text {
  visibility: hidden;
  position: fixed;
  top: 15%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-family: 'Luckiest Guy', cursive;
  color: #e0e8f0;
  text-shadow: 0 2px 4px rgba(0,0,0,0.9), 0 0 8px rgba(80,160,220,0.4);
  font-size: 64px;
  letter-spacing: 3px;
  user-select: none;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
}
#spawn-text {
  visibility: hidden;
  position: fixed;
  top: 38%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-family: 'Luckiest Guy', cursive;
  color: #fff;
  font-size: 42px;
  letter-spacing: 2px;
  text-shadow:
    0 0 8px rgba(0,0,0,0.7),
    0 2px 4px rgba(0,0,0,0.5),
    0 0 20px rgba(100,180,255,0.3);
  user-select: none;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  z-index: 100;
}

#round-text {
  visibility: hidden;
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-family: "Marker Felt",'Patrick Hand', cursive;
  color: black;
  text-shadow: 0px 0px 12px white;
  font-size: 74px;
  user-select: none;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;

}

#auto-attack-btn {
  display: none;
  position: fixed;
  top: 35%;
  left: 16px;
  width: 56px;
  height: 56px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.4);
  border: 3px solid rgba(255, 255, 255, 0.3);
  cursor: pointer;
  user-select: none;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  z-index: 10000;
  transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

#auto-attack-btn:hover {
  transform: scale(1.12);
  border-color: rgba(255, 255, 255, 0.6);
  box-shadow: 0 0 8px rgba(255, 255, 255, 0.2);
}

#auto-attack-btn:active {
  transform: scale(0.95);
}

#auto-attack-btn.active {
  border-color: rgba(80, 255, 80, 0.8);
  box-shadow: 0 0 12px rgba(50, 255, 50, 0.5);
  background: rgba(0, 60, 0, 0.5);
}

#auto-attack-btn.active:hover {
  transform: scale(1.12);
  box-shadow: 0 0 16px rgba(50, 255, 50, 0.7);
}

/* ── Item buttons (shield + bomb) ──────────────────────── */
.item-btn {
  position: fixed;
  left: 16px;
  width: 56px;
  height: 56px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.4);
  border: 3px solid rgba(100, 180, 200, 0.4);
  cursor: pointer;
  user-select: none;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  z-index: 10000;
  transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
  overflow: hidden;
}

#rage-fill {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 0%;
  background: linear-gradient(to top, rgba(255, 40, 40, 0.7), rgba(255, 100, 60, 0.3));
  border-radius: 0 0 9px 9px;
  transition: height 0.3s linear;
  pointer-events: none;
}

.rage-icon {
  position: relative;
  z-index: 1;
}

.item-btn:hover {
  transform: scale(1.12);
  border-color: rgba(130, 220, 255, 0.7);
  box-shadow: 0 0 10px rgba(80, 200, 255, 0.3);
}

.item-btn:active {
  transform: scale(0.95);
}

/* Item button positions are set dynamically by repositionItemButtons() in main.js */

.item-count {
  position: absolute;
  bottom: 2px;
  right: 4px;
  font-family: 'Luckiest Guy', cursive;
  font-size: 14px;
  color: #fff;
  text-shadow: 1px 1px 2px black;
  pointer-events: none;
}

.item-btn.active {
  border-color: rgba(80, 220, 255, 0.8);
  box-shadow: 0 0 12px rgba(50, 200, 255, 0.5);
  background: rgba(0, 40, 60, 0.5);
}

.item-btn.shield-active-glow {
  animation: shieldPulse 1.2s ease-in-out infinite;
}

@keyframes shieldPulse {
  0%, 100% {
    box-shadow: 0 0 8px rgba(0, 255, 255, 0.4);
    border-color: rgba(0, 255, 255, 0.6);
  }
  50% {
    box-shadow: 0 0 20px rgba(0, 255, 255, 0.8);
    border-color: rgba(0, 255, 255, 1);
  }
}

.item-btn.rage-active-glow {
  animation: ragePulse 1.2s ease-in-out infinite;
}

@keyframes ragePulse {
  0%, 100% {
    box-shadow: 0 0 8px rgba(255, 50, 50, 0.4);
    border-color: rgba(255, 50, 50, 0.6);
  }
  50% {
    box-shadow: 0 0 20px rgba(255, 50, 50, 0.8);
    border-color: rgba(255, 50, 50, 1);
  }
}

.item-btn.feather-active-glow {
  animation: featherPulse 1.2s ease-in-out infinite;
}

@keyframes featherPulse {
  0%, 100% {
    box-shadow: 0 0 8px rgba(255, 200, 50, 0.4);
    border-color: rgba(255, 200, 50, 0.6);
  }
  50% {
    box-shadow: 0 0 20px rgba(255, 200, 50, 0.8);
    border-color: rgba(255, 200, 50, 1);
  }
}

/* Shield HP bar overlay inside health bar */
#shield-bar-fill {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  width: 0%;
  background-color: rgba(0, 220, 255, 0.5);
  z-index: 1;
  pointer-events: none;
  transition: width 0.2s ease;
}

#potion-button {
  visibility: hidden;
  position: fixed;
  bottom: 35%;
  right: 16px;
  width: 64px;
  height: 80px;
  border-radius: 12px;
  z-index: 10000;
  background: rgba(0, 0, 0, 0.4);
  border: 3px solid rgba(255, 255, 255, 0.3);
  cursor: pointer;
  user-select: none;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

#potion-button:hover {
  transform: scale(1.1);
  border-color: rgba(100, 180, 220, 0.6);
  box-shadow: 0 0 10px rgba(60, 160, 220, 0.3);
}

#potion-button:active {
  transform: scale(0.95);
}

#potion-button.cant-afford {
  opacity: 0.35;
}

#potion-icon {
  position: relative;
  z-index: 1;
  filter: drop-shadow(1px 1px 2px rgba(0,0,0,0.6));
  display: flex;
  align-items: center;
  justify-content: center;
}

#potion-cost {
  font-family: 'Luckiest Guy', cursive;
  font-size: 13px;
  color: #cce8ff;
  text-shadow: 1px 1px 2px rgba(0,0,0,0.8);
  z-index: 1;
}


#unlock-text {
  position: fixed;
  top: 40%;
  left: 50%;
  transform: translateX(-50%);
  font-family: 'Luckiest Guy', cursive;
  font-size: 2.5em;
  color: #b8d4ea;
  visibility: hidden;
  opacity: 0;
  transition: opacity 0.5s;
  text-shadow: 0 0 10px rgba(80, 160, 220, 0.5), 2px 2px 4px black;
  z-index: 9999;
  pointer-events: none;
}

#pause-button {
  visibility: hidden;
  /* Initially hidden */
  position: fixed;
  top: 0px;
  left: -4px;
  background-image: url("https://i.imgur.com/HTeDEQJ.png");
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  width: 60px;
  height: 60px;
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  z-index: 10000;
  touch-action: manipulation;
}

#weather-icon {
  visibility: hidden;
  position: fixed;
  top: 12px;
  left: calc(50% - 60px);
  font-size: 22px;
  z-index: 9999;
  pointer-events: none;
  user-select: none;
  filter: drop-shadow(1px 1px 2px rgba(0,0,0,0.5));
}

#coffee-button {
  visibility: hidden;
  font-family: 'Luckiest Guy';
  /* Initially hidden */
  position: fixed;
  top: 0px;
  right: 0px;
  background-image: url("https://i.imgur.com/Ft63zNi.png");
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  width: 60px;
  height: 60px;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  /* Prevent text from wrapping */
  text-align: left;
  /* Include padding and border in the width */
  padding-right: 5px;
  /* Add padding to align with the right edge */
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;

}

#coffee-amount {
  position: absolute;
  font-size: 36px;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-family: 'Luckiest Guy';
  background-color: transparent;
  color: #ffffff;
  text-align: center;
  -webkit-text-stroke-width: 2px;
  -webkit-text-stroke-color: #000000;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;

}




.cooldown-overlay {
  display: none;
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  z-index: 10;
  pointer-events: none;
  animation: cooldown 3s linear;
  animation-fill-mode: forwards;
  user-select: none;
  -webkit-touch-callout: none;
  /* Disable callout on iOS devices */
  outline: none;
  touch-action: manipulation;


}

@keyframes cooldown {
  0% {
    width: 100%;
  }

  100% {
    width: 0;
  }
}



#character-level {
  position: absolute;
  bottom: 46px;
  left: -40px;
  color: rgb(255, 255, 255);
  font-family: "Fredoka One", Arial, sans-serif;
  font-weight: bold;
  text-shadow: 1px 1px .1px rgb(0, 0, 0), 0 0 .1em rgb(0, 0, 255), 0 0 0.1em rgb(255, 0, 0);
  font-size: 12px;
  user-select: none;
  touch-action: manipulation;
}

#enemy-portrait {
  width: 46px;
  height: 46px;
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  position: absolute;
  left: 200px;
  top: 0px;
  filter: grayscale(0%);
  display: none;
  user-select: none;
  touch-action: manipulation;
  /* Hide the element by default */

  /* Add the inward black outline */
 
}

#health-bar {
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;

  width: 200px;
  height: 20px;
  background-color: #53282891;
  border: 2px solid #000;
  position: relative;
  user-select: none;
  touch-action: manipulation;
}

#health-bar-fill {
  height: 100%;
  background-color: rgba(221, 24, 24, 0.849);
  user-select: none;
  touch-action: manipulation;
}

#exp-bar {
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;

  width: 200px;
  height: 20px;
  background-color: #4846a0e1;
  border: 2px solid #000;
  position: relative;
  margin-top: -2px;
  user-select: none;
  touch-action: manipulation;
}

#exp-bar-fill {
  height: 100%;
  background-color: #2797d8ec;
  width: 3%;
  /* Set the initial width to 1% */
  user-select: none;
  touch-action: manipulation;
}





#character-portrait {
  -webkit-tap-highlight-color: transparent;

  width: 46px;
  height: 46px;
  background-image: url("https://i.imgur.com/yzzwAH6.png");
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  position: absolute;
  left: -44px;
  top: 0px;
  user-select: none;
  filter: sepia(0%);
  -webkit-touch-callout: none;
  /* Disable callout on iOS devices */
  outline: none;
  cursor: pointer;
  touch-action: manipulation;

}
@keyframes pulsate {
  0% {
    border-color: transparent;
    box-shadow: 0 0 0 0 rgba(255, 0, 0, 1);
    filter: none; /* Remove the greyscale effect */
  }
  30% {
    border-color: rgba(255, 0, 0, 1);
    box-shadow: 0 0 20px 10px rgba(255, 0, 0, 1);
    filter: none; /* Remove the greyscale effect */
  }
  50% {
    border-color: transparent;
    box-shadow: 0 0 0 0 rgb(0, 127, 255);
    filter: none; /* Remove the greyscale effect */
  }
  80% {
    border-color: rgb(0, 127, 255);
    box-shadow: 0 0 20px 10px rgb(0, 127, 255);
    filter: none; /* Remove the greyscale effect */
  }
  100% {
    border-color: transparent;
    box-shadow: 0 0 0 0 rgba(255, 0, 0, 1);
    filter: none; /* Remove the greyscale effect */
  }
}

.flash {
  animation: pulsate 1s infinite;
}












#character-portrait.active {
  filter: sepia(100%);

}

#character-info.active {
  visibility: visible;
  touch-action: manipulation;
}

.bar-text {
  font-family: "Marker Felt", 'Patrick Hand', cursive;
  position: absolute;
  top: 41%;
  left: 55%;
  transform: translate(-50%, -50%);
  font-weight: bold;
  white-space: nowrap;
  /* Prevent text from wrapping */
  text-align: left;
  /* Align the text to the left */
  width: 100%;
  /* Set the width to 100% */
  box-sizing: border-box;
  /* Include padding and border in the width */
  padding-right: 5px;
  /* Add padding to align with the right edge */
  user-select: none;
  touch-action: manipulation;
}

.upgrade-box {
  outline: none;
  -webkit-tap-highlight-color: transparent;
  width: 46px;
  height: 46px;
  position: absolute;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
  background-color: rgba(0, 0, 0, 0.5);
  border: 2px solid #796011c7;
  /* Add a whimsical color for the outline */
  border-radius: 5px;
  /* Increase the border radius for a softer look */
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.4);
  /* Adjust the box shadow for a subtle effect */
  cursor: pointer;
  transition: transform 0.2s ease-in-out;
  visibility: hidden;
  touch-action: manipulation;


}

/* Animation for appearing */
/* Animation for sliding up */
@keyframes slideUp {
  0% {
    transform: translateY(100%);
  }

  100% {
    transform: translateY(0);
  }
}

.upgrade-box.spd-upgrade {
  outline: none;
  background-color: rgba(214, 214, 37, 0.719);
  top: -50px;
  left: calc(45% - 70px);
  animation: appear 0.5s ease-in-out forwards, bounce 2s infinite;
  user-select: none;
  touch-action: manipulation;
}

.upgrade-box.hp-upgrade {
  outline: none;
  background-color: rgba(187, 34, 34, 0.74);
  top: -50px;
  left: calc(45% - 10px);
  /* Reduced spacing */
  animation: appear 0.5s ease-in-out forwards, bounce 2s infinite reverse;
  user-select: none;
  touch-action: manipulation;
}

.upgrade-box.attack-upgrade {
  outline: none;
  background-color: rgba(20, 110, 39, 0.74);
  top: -50px;
  left: calc(45% + 50px);
  /* Reduced spacing */
  animation: appear 0.5s ease-in-out forwards, bounce 2s infinite;
  user-select: none;
  touch-action: manipulation;
}


.upgrade-box.character-snail {
  outline: none;
  background-color: rgba(151, 22, 112, 0.753);
  top: -50px;
  left: calc(45% - 70px);
  animation: appear 0.5s ease-in-out forwards, bounce 2s infinite;
  user-select: none;
  touch-action: manipulation;
}

.upgrade-box.character-frog {
  outline: none;
  background-color: rgba(18, 139, 39, 0.753);
  top: -50px;
  left: calc(45% - 70px);
  animation: appear 0.5s ease-in-out forwards, bounce 2s infinite;
  user-select: none;
  touch-action: manipulation;
}

.upgrade-box.character-bird {
  outline: none;
  background-color: rgba(49, 47, 202, 0.801);
  top: -50px;
  left: calc(45% - 10px);
  /* Reduced spacing */
  animation: appear 0.5s ease-in-out forwards, bounce 2s infinite reverse;
  user-select: none;
  touch-action: manipulation;
}

.upgrade-box.character-bee {
  outline: none;
  background-color: rgba(225, 247, 36, 0.74);
  top: -50px;
  left: calc(45% + 50px);
  /* Reduced spacing */
  animation: appear 0.5s ease-in-out forwards, bounce 2s infinite;
  user-select: none;
  touch-action: manipulation;
}

.hp-indicator {
  visibility: inherit;
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 10%;
  touch-action: manipulation;
  background-color: rgba(182, 10, 10, 0.9);
  /* Change the background color to red with opacity 0.5 */
  z-index: 999;
}

.upgrade-box.character-snail .hp-indicator {
  --current-health: var(--current-health-snail);
  --max-health: var(--max-health-snail);
  width: calc(100% - var(--hp-indicator-height));
  touch-action: manipulation;
}

.upgrade-box.character-bird .hp-indicator {
  --current-health: var(--current-health-bird);
  --max-health: var(--max-health-bird);
  width: calc(100% - var(--hp-indicator-height));
  touch-action: manipulation;
}

.upgrade-box.character-bee .hp-indicator {
  --current-health: var(--current-health-bee);
  --max-health: var(--max-health-bee);
  width: calc(100% - var(--hp-indicator-height));
  touch-action: manipulation;
}

.upgrade-box.character-frog .hp-indicator {
  --current-health: var(--current-health-frog);
  --max-health: var(--max-health-frog);
  width: calc(100% - var(--hp-indicator-height));
  touch-action: manipulation;
}

.exp-indicator {
  display: none;
}

.exp-indicator .level {
  position: absolute;
  bottom: -10px;
  left: 36px;
  font-size: 20px;
  font-family: "Marker Felt",'Patrick Hand', cursive;
  font-weight: bold;
  white-space: nowrap;
  /* Prevent text from wrapping */
  text-align: left;
  /* Add padding to align with the right edge */
  user-select: none;
  touch-action: manipulation;
  z-index: 10000;
}

.upgrade-box.character-snail .exp-indicator {
  --current-health: var(--current-exp-snail);
  --max-health: var(--max-exp-snail);
  width: calc(100% - var(--exp-indicator-height));
  touch-action: manipulation;
}

.upgrade-box.character-bird .exp-indicator {
  --current-health: var(--current-exp-bird);
  --max-health: var(--max-exp-bird);
  width: calc(100% - var(--exp-indicator-height));
  touch-action: manipulation;
}

.upgrade-box.character-bee .exp-indicator {
  --current-health: var(--current-exp-bee);
  --max-health: var(--max-exp-bee);
  width: calc(100% - var(--exp-indicator-height));
  touch-action: manipulation;
}

.upgrade-box.character-frog .exp-indicator {
  --current-health: var(--current-exp-frog);
  --max-health: var(--max-exp-frog);
  width: calc(100% - var(--exp-indicator-height));
  touch-action: manipulation;
}


.upgrade-box:hover {
  animation-play-state: paused;
  transform: scale(1.1);
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.5), inset 0 0 10px rgba(0, 0, 0, 0.5);
}

.character-icon {
  font-size: 24px;
  color: green;
  /* Change the color to green */
  text-stroke: 2px black;
  /* Add stroke to the text */
  -webkit-text-fill-color: white;
  /* Fallback for older browsers */
  fill: white;
  /* Fill the text color */
  user-select: none;
  touch-action: manipulation;
}

#infoboxes {
  visibility: hidden;
  position: absolute;
  right: calc(100% + 48px);
  bottom: 1px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  white-space: nowrap;
  user-select: none;
  color: rgb(255, 255, 255);
  font-family: "Fredoka One", Arial, sans-serif;
  font-weight: bold;
  text-shadow: 1px 1px .1px rgb(0, 0, 0), 0 0 .1em rgb(0, 0, 255), 0 0 0.1em rgb(255, 0, 0);
  font-size: 12px;
  touch-action: manipulation;
}

.infobox {

  display: flex;
  align-items: center;
  margin-bottom: -2px;
  /* Adjust the margin as needed */
}

.upgrade-box {
  margin-top: -4x;
  /* Adjust the margin as needed */
}

@keyframes bounce {

  0%,
  100% {
    transform: translateY(0);
  }

  50% {
    transform: translateY(-10px);
  }
}
#snail {
  position: absolute;
  top: 12px;
  left: 4%;
  width: 40px;
  height: 40px;
  background-image: url('https://i.imgur.com/shRbAl5.png');
  background-size: cover;
  z-index: 4;
}

@keyframes snail-movement {
  0% {
    left: 12%;
  }
  100% {
    left: 80%; /* Adjusted value to ensure it doesn't exceed the progress bar */
  }
}

@keyframes snail-animation {
  0%, 49% {
    background-image: url('https://i.imgur.com/shRbAl5.png');
  }
  50%, 100% {
    background-image: url('https://i.imgur.com/r3DQaWf.png');
  }
}

#progress {
  position: fixed;
  top: 30px;
  left: 14%;
  width: 68%;
  height: 20px;
  background-color: rgba(0, 0, 0, 0.363);
  z-index: 2;
}

#progress-filled {
  position: fixed;
  top: 30px;
  left: 14%;
  width: 0;
  height: 20px;
  background-color: rgba(0, 0, 0, 0.411);
  z-index: 3;
}

@keyframes progress-fill {
  0% {
    width: 0;
  }
  100% {
    width: 68%; /* Adjusted value to match the progress bar */
  }
}
#rotateDevice {
  display: none;
  position: fixed;
  background: linear-gradient(135deg, #0a0e1a 0%, #101828 50%, #0a1220 100%);
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
  text-align: center;
  overflow: hidden;
  font-size: 24px;
  z-index: 9999;
}

#menu-scene {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
}

/* ── Leaderboard button ──────────────────────────────────── */
#leaderboard-btn {
  font-size: 1.1em;
}

/* ── Leaderboard panel ───────────────────────────────────── */
#leaderboard-panel {
  position: relative;
  width: 85%;
  max-width: 380px;
  max-height: 80vh;
  overflow-y: auto;
  background: rgba(8, 12, 20, 0.94);
  border: 2px solid rgba(100, 160, 200, 0.5);
  border-radius: 16px;
  padding: 20px 16px;
  color: #dde4ec;
  font-family: 'Patrick Hand', cursive;
  text-align: center;
}

#leaderboard-panel h2 {
  font-family: 'Luckiest Guy', cursive;
  font-size: 1.8em;
  color: #e0e8f0;
  text-shadow: 0 0 8px rgba(80, 160, 220, 0.4), 2px 2px 4px rgba(0, 0, 0, 0.8);
  margin: 0 0 12px 0;
}

/* Rows */
#leaderboard-list {
  text-align: left;
}

.lb-row {
  display: flex;
  align-items: center;
  padding: 5px 6px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 1em;
}

.lb-row.lb-top .lb-rank {
  color: #8cc8e8;
  text-shadow: 0 0 6px rgba(80, 170, 220, 0.6);
}

.lb-rank {
  width: 28px;
  font-family: 'Luckiest Guy', cursive;
  font-size: 1.1em;
  text-align: center;
  flex-shrink: 0;
}

.lb-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lb-score {
  flex-shrink: 0;
  margin-left: 8px;
  font-family: 'Luckiest Guy', cursive;
  color: rgba(140, 200, 232, 0.9);
}

/* ── Score submission overlay ────────────────────────────── */
#score-submit-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  z-index: 100000;
  justify-content: center;
  align-items: center;
}

#score-submit-overlay.visible {
  display: flex;
}

#score-submit-panel {
  width: 80%;
  max-width: 340px;
  background: rgba(8, 12, 20, 0.94);
  border: 2px solid rgba(100, 160, 200, 0.5);
  border-radius: 16px;
  padding: 24px 20px;
  text-align: center;
  color: #dde4ec;
  font-family: 'Patrick Hand', cursive;
}

#score-submit-panel h2 {
  font-family: 'Luckiest Guy', cursive;
  font-size: 1.8em;
  color: #e0e8f0;
  text-shadow: 0 0 8px rgba(80, 160, 220, 0.4), 2px 2px 4px rgba(0, 0, 0, 0.8);
  margin: 0 0 8px 0;
}

#score-submit-score {
  font-family: 'Luckiest Guy', cursive;
  font-size: 1.6em;
  color: #fff;
  margin: 0 0 16px 0;
}

#score-submit-name {
  width: 80%;
  padding: 10px 12px;
  font-family: 'Patrick Hand', cursive;
  font-size: 1.1em;
  color: #fff;
  background: transparent;
  border: 2px solid rgba(100, 160, 200, 0.5);
  border-radius: 8px;
  outline: none;
  text-align: center;
  margin-bottom: 14px;
}

#score-submit-name::placeholder {
  color: rgba(255, 255, 255, 0.4);
}

#score-submit-buttons {
  display: flex;
  justify-content: center;
  gap: 12px;
}

#score-submit-buttons .menu-btn {
  width: auto;
  padding: 10px 24px;
  font-size: 1.1em;
}

#score-submit-status {
  font-size: 0.95em;
  margin: 10px 0 0 0;
  min-height: 1.2em;
}

/* ── Guide button ──────────────────────────────────────── */
#guide-btn {
  font-size: 1.1em;
}

/* ── Guide panel ───────────────────────────────────────── */
#guide-panel {
  position: relative;
  width: 85%;
  max-width: 380px;
  max-height: 80vh;
  overflow-y: auto;
  background: rgba(8, 12, 20, 0.94);
  border: 2px solid rgba(100, 160, 200, 0.5);
  border-radius: 16px;
  padding: 20px 16px;
  color: #dde4ec;
  font-family: 'Patrick Hand', cursive;
  text-align: center;
}

#guide-panel h2 {
  font-family: 'Luckiest Guy', cursive;
  font-size: 1.4em;
  color: #e0e8f0;
  text-shadow: 0 0 8px rgba(80, 160, 220, 0.4), 2px 2px 4px rgba(0, 0, 0, 0.8);
  margin: 0 0 8px 0;
  letter-spacing: 0.5px;
}

.guide-items {
  text-align: left;
  margin-bottom: 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.guide-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px;
  background: rgba(255, 255, 255, 0.04);
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.guide-item-icon {
  font-size: 1.2em;
  flex-shrink: 0;
  width: 26px;
  text-align: center;
}

.guide-item-text {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}
.guide-item-text strong {
  font-size: 0.9em;
  color: #e8eef4;
}
.guide-item-text span {
  font-size: 0.72em;
  opacity: 0.55;
}

.golden-bean-icon {
  width: 20px;
  height: 20px;
  filter: brightness(1.6) sepia(1) saturate(5) hue-rotate(10deg) drop-shadow(0 0 2px rgba(255, 200, 0, 0.5));
  flex-shrink: 0;
  margin-left: 3px;
}

.guide-matchups {
  text-align: left;
  margin-bottom: 10px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.matchup-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 10px;
  background: rgba(255, 255, 255, 0.04);
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.matchup-portrait {
  width: 34px;
  height: 34px;
  border-radius: 6px;
  border: 1.5px solid rgba(100, 160, 200, 0.35);
  flex-shrink: 0;
}

.matchup-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 0.8em;
}

.matchup-strong {
  display: flex;
  align-items: center;
  gap: 3px;
}
.matchup-strong::before {
  content: '+';
  color: #88ff88;
  font-weight: bold;
  font-size: 1.1em;
  margin-right: 2px;
}

.matchup-weak {
  display: flex;
  align-items: center;
  gap: 3px;
}
.matchup-weak::before {
  content: '\2212';
  color: #ff8888;
  font-weight: bold;
  font-size: 1.1em;
  margin-right: 2px;
}

.matchup-enemy-portrait {
  width: 26px;
  height: 26px;
  border-radius: 5px;
  vertical-align: middle;
}

/* ── Golden bean button icon ───────────────────────────── */
.golden-bean-btn-icon {
  width: 28px;
  height: 28px;
  filter: brightness(1.6) sepia(1) saturate(5) hue-rotate(10deg) drop-shadow(0 0 2px rgba(255, 200, 0, 0.5));
}

/* ── Layout panel ──────────────────────────────────────── */
#layout-panel {
  position: relative;
  width: 96%;
  max-width: 500px;
  max-height: 94vh;
  overflow-y: auto;
  background: rgba(8, 12, 20, 0.96);
  border: 2px solid rgba(100, 160, 200, 0.5);
  border-radius: clamp(10px, 3vmin, 16px);
  padding: clamp(8px, 2vmin, 14px) clamp(6px, 1.5vmin, 12px);
  color: #dde4ec;
  font-family: 'Patrick Hand', cursive;
  text-align: center;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
#layout-panel::-webkit-scrollbar { display: none; }

.layout-header {
  display: flex;
  align-items: center;
  gap: clamp(6px, 1.5vmin, 10px);
  margin-bottom: clamp(6px, 1.5vmin, 12px);
}
.layout-currency-center {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: clamp(8px, 2vmin, 14px);
}
#layout-bones {
  font-family: 'Luckiest Guy', cursive;
  font-size: clamp(1em, 3.5vmin, 1.5em);
  color: #f0e8d0;
  text-shadow: 0 0 6px rgba(200, 180, 100, 0.3), 1px 1px 2px rgba(0, 0, 0, 0.9);
}
#layout-hearts {
  font-family: 'Luckiest Guy', cursive;
  font-size: clamp(0.9em, 3vmin, 1.3em);
  color: #f0c0d8;
  text-shadow: 0 0 6px rgba(220, 120, 180, 0.3), 1px 1px 2px rgba(0, 0, 0, 0.9);
}

/* ── Card deck ────────────────────────────────────────── */
.layout-deck-area {
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  gap: 0;
}

.layout-nav-btn {
  position: absolute;
  top: 50%;
  width: clamp(28px, 7vmin, 36px);
  height: clamp(28px, 7vmin, 36px);
  border-radius: 50%;
  border: 2px solid rgba(100, 160, 200, 0.5);
  background: rgba(10, 15, 25, 0.75);
  color: #ccd8e4;
  font-size: clamp(1.1em, 3vmin, 1.6em);
  line-height: 1;
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition: transform 0.15s, background 0.15s;
  flex-shrink: 0;
  z-index: 10;
}

#layout-prev { left: -6px; transform: translateY(-50%); }
#layout-next { right: -6px; transform: translateY(-50%); }

.layout-nav-btn:hover {
  background: rgba(20, 40, 60, 0.85);
}

#layout-prev:hover { transform: translateY(-50%) scale(1.15); }
#layout-next:hover { transform: translateY(-50%) scale(1.15); }
#layout-prev:active { transform: translateY(-50%) scale(0.92); }
#layout-next:active { transform: translateY(-50%) scale(0.92); }

.layout-deck {
  position: relative;
  width: clamp(280px, 82vw, 420px);
  height: clamp(240px, 58vh, 380px);
  perspective: 600px;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.layout-card {
  position: absolute;
  top: 0; left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(145deg, rgba(15, 25, 45, 0.95), rgba(10, 18, 30, 0.98));
  border: 2px solid rgba(100, 160, 200, 0.4);
  border-radius: clamp(8px, 2vmin, 12px);
  padding: clamp(6px, 1.5vmin, 10px) clamp(8px, 2vmin, 14px);
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  align-items: center;
  transition: transform 0.4s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.4s ease, box-shadow 0.4s ease;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
  pointer-events: none;
  opacity: 0;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.layout-card::-webkit-scrollbar { display: none; }

.layout-card.card-pos-0 {
  transform: translateX(0) scale(1);
  opacity: 1;
  z-index: 4;
  pointer-events: auto;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.6), 0 0 12px rgba(80, 160, 220, 0.15);
  border-color: rgba(100, 180, 220, 0.7);
}

/* Character-themed card tints */
.layout-card[data-char="frog"] {
  background: linear-gradient(145deg, rgba(15, 35, 20, 0.95), rgba(10, 22, 14, 0.98));
  border-color: rgba(80, 180, 90, 0.35);
}
.layout-card[data-char="frog"].card-pos-0 {
  border-color: rgba(80, 200, 100, 0.65);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.6), 0 0 12px rgba(60, 180, 80, 0.15);
}
.layout-card[data-char="snail"] {
  background: linear-gradient(145deg, rgba(15, 18, 40, 0.95), rgba(10, 14, 32, 0.98));
  border-color: rgba(100, 120, 200, 0.35);
}
.layout-card[data-char="snail"].card-pos-0 {
  border-color: rgba(120, 140, 220, 0.65);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.6), 0 0 12px rgba(100, 120, 200, 0.15);
}
.layout-card[data-char="bird"] {
  background: linear-gradient(145deg, rgba(18, 30, 22, 0.95), rgba(16, 14, 28, 0.98));
  border-color: rgba(100, 170, 130, 0.35);
}
.layout-card[data-char="bird"].card-pos-0 {
  border-color: rgba(110, 180, 140, 0.65);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.6), 0 0 12px rgba(100, 160, 120, 0.15);
}
.layout-card[data-char="bee"] {
  background: linear-gradient(145deg, rgba(35, 30, 12, 0.95), rgba(25, 20, 10, 0.98));
  border-color: rgba(200, 180, 60, 0.35);
}
.layout-card[data-char="bee"].card-pos-0 {
  border-color: rgba(220, 200, 70, 0.65);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.6), 0 0 12px rgba(200, 180, 60, 0.15);
}

.layout-card.card-pos-1 {
  transform: translateX(14px) scale(0.94);
  opacity: 0.7;
  z-index: 3;
}

.layout-card.card-pos-2 {
  transform: translateX(28px) scale(0.88);
  opacity: 0.45;
  z-index: 2;
}

.layout-card.card-pos-3 {
  transform: translateX(42px) scale(0.82);
  opacity: 0.25;
  z-index: 1;
}

/* Swipe drag feedback — override transition when dragging */
.layout-card.swiping {
  transition: none !important;
}

.layout-portrait-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(6px, 1.5vmin, 10px);
  flex-shrink: 0;
  margin-bottom: clamp(2px, 0.6vmin, 6px);
}

.layout-portrait-wrap {
  position: relative;
  flex-shrink: 0;
}

.layout-card-portrait {
  width: clamp(48px, 14vmin, 72px);
  height: clamp(48px, 14vmin, 72px);
  border-radius: clamp(8px, 2vmin, 12px);
  border: 2px solid rgba(100, 160, 200, 0.4);
  image-rendering: pixelated;
  display: block;
}

.layout-card-name {
  position: absolute;
  bottom: -4px;
  left: 50%;
  transform: translateX(-50%);
  font-family: 'Luckiest Guy', cursive;
  font-size: clamp(0.65em, 2vmin, 0.85em);
  color: #e0e8f0;
  text-shadow: 0 0 4px rgba(0, 0, 0, 0.9), 0 0 8px rgba(0, 0, 0, 0.7);
  background: rgba(8, 14, 26, 0.85);
  padding: 0 clamp(4px, 1vmin, 8px);
  border-radius: 4px;
  white-space: nowrap;
  line-height: 1.4;
  z-index: 1;
}

.layout-card-stats {
  width: 100%;
  text-align: left;
  flex-shrink: 0;
}

.layout-row {
  display: flex;
  align-items: center;
  padding: clamp(1px, 0.4vmin, 3px) clamp(3px, 0.8vmin, 6px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.layout-stat-icon {
  font-size: clamp(13px, 3.2vmin, 17px);
  flex-shrink: 0;
  width: clamp(20px, 5vmin, 26px);
  text-align: center;
}

.layout-stat-bonus {
  flex: 1;
  font-family: 'Luckiest Guy', cursive;
  font-size: clamp(0.7em, 2.2vmin, 0.9em);
  color: #8cc8e8;
  text-shadow: 0 0 4px rgba(80, 160, 220, 0.3);
}

.layout-buy-btn {
  font-family: 'Luckiest Guy', cursive;
  font-size: clamp(0.65em, 1.9vmin, 0.8em);
  padding: clamp(2px, 0.6vmin, 4px) clamp(6px, 1.5vmin, 10px);
  border-radius: 6px;
  border: 2px solid rgba(200, 180, 100, 0.5);
  background: rgba(200, 180, 100, 0.12);
  color: #f0e8d0;
  cursor: pointer;
  transition: transform 0.15s, background 0.15s, border-color 0.15s;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.layout-buy-btn:hover {
  transform: scale(1.08);
  background: rgba(200, 180, 100, 0.25);
  border-color: rgba(200, 180, 100, 0.8);
}

.layout-buy-btn:active {
  transform: scale(0.95);
}

.layout-buy-btn.cant-afford {
  opacity: 0.35;
  cursor: not-allowed;
}

.layout-cosmetic-slot {
  width: clamp(58px, 15vmin, 76px);
  height: clamp(38px, 10vmin, 48px);
  border-radius: clamp(6px, 1.5vmin, 10px);
  border: 2px solid rgba(100, 160, 200, 0.4);
  background: rgba(14, 22, 38, 0.7);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  transition: transform 0.15s, border-color 0.15s, background 0.15s, box-shadow 0.15s;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

.layout-cosmetic-slot:hover {
  transform: scale(1.08);
  border-color: rgba(100, 180, 220, 0.7);
  background: rgba(22, 40, 65, 0.85);
  box-shadow: 0 0 10px rgba(60, 140, 200, 0.2), 0 2px 6px rgba(0, 0, 0, 0.4);
}

.layout-cosmetic-slot:active {
  transform: scale(0.95);
}

.cosmetic-label {
  font-family: 'Luckiest Guy', cursive;
  font-size: clamp(13px, 3.2vmin, 16px);
  color: rgba(180, 210, 240, 0.85);
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.7);
  letter-spacing: 0.5px;
  user-select: none;
}

/* ── Inline picker (hat/skin grid inside card) ────────── */
.layout-inline-picker {
  width: 100%;
  margin-top: clamp(4px, 1vmin, 8px);
  flex-shrink: 0;
}

.layout-inline-picker .inline-picker-grid {
  display: flex;
  flex-wrap: wrap;
  gap: clamp(3px, 0.8vmin, 5px);
  justify-content: center;
}

.layout-inline-picker .inline-picker-item {
  width: clamp(54px, 12.5vmin, 70px);
  height: clamp(54px, 12.5vmin, 70px);
  border-radius: clamp(6px, 1.5vmin, 9px);
  border: 2px solid rgba(100, 160, 200, 0.35);
  background: rgba(15, 25, 45, 0.8);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: clamp(16px, 4vmin, 22px);
  gap: 1px;
  cursor: pointer;
  transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.layout-inline-picker .inline-picker-item:hover {
  transform: scale(1.1);
  border-color: rgba(100, 180, 220, 0.7);
  box-shadow: 0 0 8px rgba(60, 140, 200, 0.25);
}

.layout-inline-picker .inline-picker-item:active {
  transform: scale(0.93);
}

.layout-inline-picker .inline-picker-item.equipped {
  border-color: rgba(80, 220, 120, 0.8);
  box-shadow: 0 0 10px rgba(50, 200, 100, 0.35);
  background: rgba(20, 50, 30, 0.6);
}

.layout-inline-picker .inline-picker-cost {
  font-family: 'Luckiest Guy', cursive;
  font-size: clamp(8px, 1.8vmin, 10px);
  color: #f0e8d0;
  text-shadow: 1px 1px 2px rgba(0,0,0,0.8);
  line-height: 1;
}

.layout-inline-picker .inline-picker-label {
  font-family: 'Patrick Hand', cursive;
  font-size: clamp(9px, 2vmin, 12px);
  color: rgba(200, 220, 240, 0.75);
  line-height: 1;
  text-align: center;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.layout-cosmetic-slot.slot-active {
  border-color: rgba(80, 220, 120, 0.8);
  box-shadow: 0 0 10px rgba(50, 200, 100, 0.3);
  background: rgba(20, 50, 30, 0.5);
}

/* ── Inventory button in header ───────────────────────── */
#layout-inventory-btn {
  font-family: 'Luckiest Guy', cursive;
  font-size: clamp(0.75em, 2.4vmin, 0.95em);
  padding: clamp(4px, 1vmin, 6px) clamp(10px, 2.5vmin, 16px);
  border-radius: 8px;
  border: 2px solid rgba(100, 160, 200, 0.45);
  background: rgba(14, 22, 38, 0.85);
  color: #ccd8e4;
  cursor: pointer;
  transition: transform 0.15s, background 0.15s, border-color 0.15s;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

#layout-inventory-btn:hover {
  transform: scale(1.08);
  background: rgba(22, 40, 65, 0.9);
  border-color: rgba(100, 180, 220, 0.7);
}

#layout-inventory-btn:active {
  transform: scale(0.95);
}

/* ── Layout sub-views (hats, skins, inventory) ───────── */
.layout-subview {
  display: none;
  width: 100%;
  flex-direction: column;
  align-items: center;
  padding-bottom: clamp(6px, 1.5vmin, 10px);
}

.layout-subview.active {
  display: flex;
}

.layout-subview-title {
  font-family: 'Luckiest Guy', cursive;
  font-size: clamp(1.2em, 3.5vmin, 1.6em);
  color: #e0e8f0;
  text-shadow: 0 0 6px rgba(80, 160, 220, 0.3), 1px 1px 2px rgba(0, 0, 0, 0.8);
  margin-bottom: clamp(6px, 1.5vmin, 12px);
}

.layout-subview-char {
  font-family: 'Luckiest Guy', cursive;
  font-size: clamp(0.85em, 2.6vmin, 1.1em);
  color: #8cc8e8;
  margin-bottom: clamp(8px, 2vmin, 14px);
}

.layout-back-btn {
  font-family: 'Luckiest Guy', cursive;
  font-size: clamp(0.8em, 2.4vmin, 1em);
  padding: clamp(6px, 1.4vmin, 10px) clamp(16px, 4vmin, 28px);
  border-radius: 8px;
  border: 2px solid rgba(100, 160, 200, 0.45);
  background: linear-gradient(145deg, rgba(18, 30, 52, 0.9), rgba(12, 20, 38, 0.95));
  color: #e0e8f0;
  cursor: pointer;
  transition: transform 0.15s, background 0.15s, border-color 0.15s;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  margin-top: clamp(8px, 2vmin, 14px);
}

.layout-back-btn:hover {
  transform: scale(1.08);
  background: linear-gradient(145deg, rgba(25, 45, 70, 0.95), rgba(18, 32, 55, 0.98));
  border-color: rgba(100, 180, 220, 0.7);
}

.layout-back-btn:active {
  transform: scale(0.95);
}

.layout-subview-grid {
  display: flex;
  flex-wrap: wrap;
  gap: clamp(8px, 2vmin, 12px);
  justify-content: center;
  width: 100%;
  min-height: clamp(100px, 30vh, 200px);
}

.layout-subview-item {
  width: clamp(60px, 15vmin, 80px);
  height: clamp(60px, 15vmin, 80px);
  border-radius: clamp(8px, 1.8vmin, 12px);
  border: 2px solid rgba(100, 160, 200, 0.35);
  background: rgba(15, 25, 45, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(24px, 6vmin, 32px);
  cursor: pointer;
  transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.layout-subview-item:hover {
  transform: scale(1.08);
  border-color: rgba(100, 180, 220, 0.7);
  box-shadow: 0 0 10px rgba(60, 140, 200, 0.2);
}

.layout-subview-item.locked {
  opacity: 0.35;
  cursor: not-allowed;
}

.layout-subview-item.equipped {
  border-color: rgba(80, 220, 120, 0.8);
  box-shadow: 0 0 12px rgba(50, 200, 100, 0.4);
  background: rgba(20, 50, 30, 0.6);
}

.layout-subview-empty {
  font-family: 'Patrick Hand', cursive;
  font-size: clamp(0.9em, 2.6vmin, 1.1em);
  color: rgba(200, 200, 220, 0.5);
  padding: clamp(20px, 5vmin, 40px) 0;
}

.layout-subview-item {
  flex-direction: column;
  gap: 2px;
}

.subview-cost {
  font-family: 'Luckiest Guy', cursive;
  font-size: clamp(10px, 2.4vmin, 13px);
  color: #f0e8d0;
  text-shadow: 1px 1px 2px rgba(0,0,0,0.8);
}

.subview-count {
  font-family: 'Luckiest Guy', cursive;
  font-size: clamp(11px, 2.6vmin, 14px);
  color: #8cc8e8;
  text-shadow: 1px 1px 2px rgba(0,0,0,0.8);
}

.subview-label {
  font-family: 'Patrick Hand', cursive;
  font-size: clamp(9px, 2vmin, 11px);
  color: rgba(200, 220, 240, 0.6);
}

/* ── Shop list (inventory) ──────────────────────────── */
.shop-list {
  display: flex;
  flex-direction: column;
  gap: clamp(4px, 1vmin, 6px);
  width: 100%;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.shop-list::-webkit-scrollbar { display: none; }

.shop-row {
  display: flex;
  align-items: center;
  gap: clamp(6px, 1.5vmin, 10px);
  padding: clamp(6px, 1.2vmin, 10px) clamp(8px, 2vmin, 12px);
  border-radius: clamp(6px, 1.4vmin, 10px);
  background: rgba(15, 25, 45, 0.7);
  border: 1px solid rgba(100, 160, 200, 0.2);
  transition: border-color 0.15s, background 0.15s;
}
.shop-row:hover {
  border-color: rgba(100, 180, 220, 0.45);
  background: rgba(20, 35, 60, 0.8);
}
.shop-row-icon {
  font-size: clamp(20px, 5vmin, 28px);
  flex-shrink: 0;
  width: clamp(32px, 7vmin, 40px);
  text-align: center;
}
.shop-row-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.shop-row-name {
  font-family: 'Luckiest Guy', cursive;
  font-size: clamp(0.75em, 2.2vmin, 0.95em);
  color: #e0e8f0;
  text-shadow: 1px 1px 2px rgba(0,0,0,0.8);
}
.shop-row-desc {
  font-family: 'Patrick Hand', cursive;
  font-size: clamp(0.6em, 1.8vmin, 0.78em);
  color: rgba(160, 190, 220, 0.6);
}
.shop-row-owned {
  font-family: 'Luckiest Guy', cursive;
  font-size: clamp(0.8em, 2.2vmin, 1em);
  color: #8cc8e8;
  text-shadow: 1px 1px 2px rgba(0,0,0,0.8);
  flex-shrink: 0;
  min-width: clamp(28px, 6vmin, 36px);
  text-align: center;
}
.shop-row-buy {
  font-family: 'Luckiest Guy', cursive;
  font-size: clamp(0.7em, 2vmin, 0.85em);
  padding: clamp(4px, 0.8vmin, 6px) clamp(8px, 2vmin, 12px);
  border-radius: 6px;
  border: 2px solid rgba(100, 180, 100, 0.5);
  background: rgba(20, 50, 30, 0.7);
  color: #a0e8a0;
  cursor: pointer;
  transition: transform 0.12s, background 0.12s, border-color 0.12s;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  flex-shrink: 0;
  white-space: nowrap;
}
.shop-row-buy:hover {
  transform: scale(1.06);
  background: rgba(30, 70, 40, 0.85);
  border-color: rgba(100, 200, 120, 0.7);
}
.shop-row-buy:active {
  transform: scale(0.94);
}
.shop-row-buy.cant-afford {
  border-color: rgba(160, 100, 100, 0.4);
  background: rgba(50, 20, 20, 0.5);
  color: rgba(200, 140, 140, 0.6);
  cursor: not-allowed;
}

/* ── Layout landscape tweaks ─────────────────────────── */
@media (orientation: landscape) and (max-height: 500px) {
  #layout-panel {
    max-width: 600px;
    max-height: 96vh;
    padding: 4px 8px;
  }
  .layout-header {
    margin-bottom: 4px;
  }
  .layout-deck {
    width: clamp(280px, 55vw, 420px);
    height: clamp(220px, 88vh, 380px);
  }
  .layout-card {
    padding: clamp(4px, 1.2vh, 8px) clamp(8px, 2vw, 14px);
  }
  .layout-card-portrait {
    width: clamp(40px, 10vh, 56px);
    height: clamp(40px, 10vh, 56px);
  }
  .layout-card-name {
    font-size: clamp(0.5em, 1.6vh, 0.7em);
  }
  .layout-portrait-row {
    margin-bottom: 1px;
    gap: clamp(4px, 1vh, 8px);
  }
  .layout-row {
    padding: 1px 4px;
  }
  .layout-stat-bonus { font-size: clamp(0.6em, 1.8vh, 0.8em); }
  .layout-buy-btn { font-size: clamp(0.55em, 1.4vh, 0.7em); padding: 1px 5px; }
  .layout-cosmetic-slot {
    width: clamp(36px, 8vh, 48px);
    height: clamp(22px, 5vh, 30px);
  }
  .cosmetic-label {
    font-size: clamp(9px, 2vh, 12px);
  }
  .layout-inline-picker .inline-picker-item {
    width: clamp(52px, 12vh, 72px);
    height: clamp(52px, 12vh, 72px);
    font-size: clamp(18px, 4.5vh, 26px);
  }
  .layout-inline-picker .inline-picker-label {
    font-size: clamp(8px, 2vh, 12px);
  }
  .layout-inline-picker .inline-picker-cost {
    font-size: clamp(8px, 1.8vh, 11px);
  }
  .layout-cosmetic-slot {
    width: clamp(44px, 10vh, 60px);
    height: clamp(28px, 7vh, 40px);
  }
}

/* ── Siege Reward Panel ───────────────────────────────── */
.siege-backdrop {
  display: none;
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: rgba(0, 0, 0, 0.75);
  z-index: 100000;
  justify-content: center;
  align-items: center;
}
.siege-backdrop.visible {
  display: flex;
}
#siege-reward-panel {
  width: 85%;
  max-width: 360px;
  background: linear-gradient(170deg, rgba(10, 16, 30, 0.97), rgba(6, 10, 22, 0.98));
  border: 2px solid rgba(80, 180, 220, 0.4);
  border-radius: 18px;
  padding: 20px 18px 16px;
  text-align: center;
  color: #dde4ec;
  font-family: 'Patrick Hand', cursive;
  box-shadow: 0 0 40px rgba(60, 160, 220, 0.15), inset 0 1px 0 rgba(255, 255, 255, 0.06);
  animation: siegePanelIn 0.4s ease-out;
}
@keyframes siegePanelIn {
  0% { transform: scale(0.7); opacity: 0; }
  60% { transform: scale(1.05); }
  100% { transform: scale(1); opacity: 1; }
}
#siege-reward-panel h2 {
  font-family: 'Luckiest Guy', cursive;
  font-size: 1.7em;
  color: #e0ecff;
  text-shadow: 0 0 14px rgba(80, 160, 240, 0.4), 0 2px 4px rgba(0, 0, 0, 0.6);
  margin: 0 0 6px;
}
#siege-reward-list {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin-bottom: 18px;
}
.siege-reward-item {
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.03));
  border: 1px solid rgba(80, 180, 220, 0.25);
  border-radius: 12px;
  padding: 10px 14px;
  font-size: 1em;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: transform 0.15s ease;
  animation: rewardItemPop 0.3s ease-out backwards;
}
.siege-reward-item:nth-child(1) { animation-delay: 0.1s; }
.siege-reward-item:nth-child(2) { animation-delay: 0.2s; }
.siege-reward-item:nth-child(3) { animation-delay: 0.3s; }
.siege-reward-item:nth-child(4) { animation-delay: 0.4s; }
.siege-reward-item:nth-child(5) { animation-delay: 0.5s; }
@keyframes rewardItemPop {
  0% { transform: scale(0); opacity: 0; }
  70% { transform: scale(1.15); }
  100% { transform: scale(1); opacity: 1; }
}
.siege-reward-item .reward-emoji {
  font-size: 1.5em;
}
.siege-reward-item .reward-name {
  font-size: 0.95em;
  color: #e8eef4;
}
#siege-reward-continue-btn {
  margin-top: 2px;
  border-color: rgba(80, 180, 220, 0.4);
  box-shadow: 0 0 12px rgba(60, 160, 220, 0.15);
}

/* ── Overworld Map Panel ──────────────────────────────── */
#map-panel {
  width: 95%;
  max-width: 500px;
  max-height: 88vh;
  border-radius: 16px;
  padding: 20px;
  text-align: center;
  color: #dde4ec;
  font-family: 'Patrick Hand', cursive;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: background 0.4s ease, border-color 0.4s ease;
  /* Default (before biome class applied) */
  background: rgb(8, 12, 20);
  border: 2px solid rgba(100, 160, 200, 0.5);
}
/* Biome-themed map panel backgrounds */
#map-panel.map-biome-forest  { background: linear-gradient(170deg, rgba(8, 20, 10, 0.96), rgba(4, 12, 6, 0.98));  border-color: rgba(60, 160, 80, 0.5); }
#map-panel.map-biome-desert  { background: linear-gradient(170deg, rgba(24, 18, 8, 0.96), rgba(16, 12, 4, 0.98));  border-color: rgba(200, 160, 60, 0.5); }
#map-panel.map-biome-tundra  { background: linear-gradient(170deg, rgba(8, 16, 24, 0.96), rgba(4, 10, 18, 0.98));  border-color: rgba(80, 180, 220, 0.5); }
#map-panel.map-biome-volcano { background: linear-gradient(170deg, rgba(20, 8, 6, 0.96), rgba(14, 4, 2, 0.98));   border-color: rgba(220, 80, 40, 0.5); }
#map-panel.map-biome-void    { background: linear-gradient(170deg, rgba(12, 6, 20, 0.96), rgba(6, 2, 14, 0.98));   border-color: rgba(140, 60, 220, 0.5); }

#map-header {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
  flex-shrink: 0;
}
#map-biome-title {
  font-family: 'Luckiest Guy', cursive;
  font-size: 1.5em;
  color: #e0e8f0;
  text-shadow: 0 0 12px rgba(80, 160, 240, 0.4);
  flex: 1;
  text-align: center;
}
/* Biome-colored titles */
#map-panel.map-biome-forest  #map-biome-title { color: rgba(120, 220, 140, 0.95); text-shadow: 0 0 12px rgba(60, 160, 80, 0.4); }
#map-panel.map-biome-desert  #map-biome-title { color: rgba(240, 200, 100, 0.95); text-shadow: 0 0 12px rgba(200, 160, 60, 0.4); }
#map-panel.map-biome-tundra  #map-biome-title { color: rgba(140, 210, 240, 0.95); text-shadow: 0 0 12px rgba(80, 180, 220, 0.4); }
#map-panel.map-biome-volcano #map-biome-title { color: rgba(240, 130, 80, 0.95);  text-shadow: 0 0 12px rgba(220, 80, 40, 0.4); }
#map-panel.map-biome-void    #map-biome-title { color: rgba(180, 120, 240, 0.95); text-shadow: 0 0 12px rgba(140, 60, 220, 0.4); }

.map-nav-btn {
  position: absolute;
  top: 50%;
  width: clamp(28px, 7vmin, 36px);
  height: clamp(28px, 7vmin, 36px);
  border-radius: 50%;
  border: 2px solid rgba(100, 160, 200, 0.5);
  background: rgba(10, 15, 25, 0.75);
  color: #ccd8e4;
  font-size: clamp(1.1em, 3vmin, 1.6em);
  line-height: 1;
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition: transform 0.15s, background 0.15s;
  flex-shrink: 0;
  z-index: 10;
}
#map-prev { left: -6px; transform: translateY(-50%); }
#map-next { right: -6px; transform: translateY(-50%); }
.map-nav-btn:hover {
  background: rgba(20, 40, 60, 0.85);
}
#map-prev:hover { transform: translateY(-50%) scale(1.15); }
#map-next:hover { transform: translateY(-50%) scale(1.15); }
#map-prev:active { transform: translateY(-50%) scale(0.92); }
#map-next:active { transform: translateY(-50%) scale(0.92); }
/* Biome-colored nav buttons */
#map-panel.map-biome-forest  .map-nav-btn { border-color: rgba(60, 160, 80, 0.5); }
#map-panel.map-biome-desert  .map-nav-btn { border-color: rgba(200, 160, 60, 0.5); }
#map-panel.map-biome-tundra  .map-nav-btn { border-color: rgba(80, 180, 220, 0.5); }
#map-panel.map-biome-volcano .map-nav-btn { border-color: rgba(220, 80, 40, 0.5); }
#map-panel.map-biome-void    .map-nav-btn { border-color: rgba(140, 60, 220, 0.5); }
.map-deck-area {
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  flex: 1;
  min-height: 0;
}
.map-deck {
  position: relative;
  width: clamp(280px, 82vw, 420px);
  height: clamp(260px, 60vh, 400px);
  perspective: 600px;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  margin: 0 auto;
}
.map-card {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  border-radius: clamp(8px, 2vmin, 12px);
  padding: 8px;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  -ms-overflow-style: none;
  transition: transform 0.4s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.4s ease;
  pointer-events: none;
  opacity: 0;
  background: rgb(15, 25, 45);
  border: 2px solid rgba(100, 160, 200, 0.3);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
}
.map-card::-webkit-scrollbar { display: none; }
.map-card-pos-0 { transform: translateX(0) scale(1);      opacity: 1;    z-index: 5; pointer-events: auto; box-shadow: 0 4px 20px rgba(0,0,0,0.6), 0 0 12px rgba(80,160,220,0.15); }
.map-card-pos-1 { transform: translateX(14px) scale(0.94); opacity: 0.65; z-index: 4; }
.map-card-pos-2 { transform: translateX(28px) scale(0.88); opacity: 0.4;  z-index: 3; }
.map-card-pos-3 { transform: translateX(42px) scale(0.82); opacity: 0.2;  z-index: 2; }
.map-card-pos-4 { transform: translateX(56px) scale(0.76); opacity: 0.1;  z-index: 1; }
/* Per-biome glow on front card */
.map-card.forest.map-card-pos-0  { border-color: rgba(80, 200, 100, 0.6); box-shadow: 0 4px 20px rgba(0,0,0,0.6), 0 0 12px rgba(60,180,80,0.15); }
.map-card.desert.map-card-pos-0  { border-color: rgba(220, 180, 80, 0.6); box-shadow: 0 4px 20px rgba(0,0,0,0.6), 0 0 12px rgba(200,160,60,0.15); }
.map-card.tundra.map-card-pos-0  { border-color: rgba(100, 200, 240, 0.6); box-shadow: 0 4px 20px rgba(0,0,0,0.6), 0 0 12px rgba(80,180,220,0.15); }
.map-card.volcano.map-card-pos-0 { border-color: rgba(240, 100, 60, 0.6); box-shadow: 0 4px 20px rgba(0,0,0,0.6), 0 0 12px rgba(220,80,40,0.15); }
.map-card.void.map-card-pos-0    { border-color: rgba(160, 80, 240, 0.6); box-shadow: 0 4px 20px rgba(0,0,0,0.6), 0 0 12px rgba(140,60,220,0.15); }
.map-card.swiping { transition: none !important; }
/* Map card grid content */
.map-card .map-grid {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0;
}
.map-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
}
.map-vconn-row {
  justify-content: center;
}
.map-node {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 1.1em;
  font-weight: bold;
  cursor: default;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  position: relative;
  flex-shrink: 0;
}
.map-node-label {
  font-size: 0.5em;
  opacity: 0.7;
  margin-top: -2px;
  pointer-events: none;
}
.map-node.start {
  background: rgba(40, 160, 80, 0.8);
  border: 2px solid rgba(80, 220, 120, 0.7);
  color: #fff;
  cursor: pointer;
  box-shadow: 0 0 10px rgba(40, 160, 80, 0.3);
}
.map-node.start:hover {
  transform: scale(1.1);
  box-shadow: 0 0 16px rgba(40, 160, 80, 0.5);
}
.map-node.unlocked {
  color: #fff;
  cursor: pointer;
}
.map-node.unlocked:hover {
  transform: scale(1.1);
}
.map-node.locked {
  background: rgba(60, 60, 70, 0.6);
  border: 2px solid rgba(100, 100, 110, 0.4);
  color: rgba(160, 160, 170, 0.5);
  opacity: 0.45;
}
/* Biome-tinted locked nodes */
.map-node.biome-forest.locked  { background: rgba(30, 60, 35, 0.5);  border-color: rgba(60, 120, 70, 0.25); }
.map-node.biome-desert.locked  { background: rgba(60, 50, 25, 0.5);  border-color: rgba(120, 100, 40, 0.25); }
.map-node.biome-tundra.locked  { background: rgba(30, 50, 65, 0.5);  border-color: rgba(60, 110, 140, 0.25); }
.map-node.biome-volcano.locked { background: rgba(60, 25, 20, 0.5);  border-color: rgba(120, 50, 30, 0.25); }
.map-node.biome-void.locked    { background: rgba(45, 20, 60, 0.5);  border-color: rgba(80, 40, 120, 0.25); }
.map-connector-h {
  width: 20px;
  height: 3px;
  background: rgba(100, 160, 200, 0.2);
  flex-shrink: 0;
}
.map-connector-h.active {
  box-shadow: 0 0 4px rgba(80, 180, 240, 0.3);
}
.map-connector-v {
  width: 3px;
  height: 18px;
  background: rgba(100, 160, 200, 0.2);
  flex-shrink: 0;
}
.map-connector-v.active {
  box-shadow: 0 0 4px rgba(80, 180, 240, 0.3);
}
/* Vertical connector row: spacers for column alignment */
.map-vconn-spacer {
  width: 52px;
  flex-shrink: 0;
}
.map-connector-h-spacer {
  width: 20px;
  flex-shrink: 0;
}
/* Biome node colors (unlocked) */
.map-node.biome-forest.unlocked  { background: rgba(40, 140, 60, 0.8);  border: 2px solid rgba(80, 200, 100, 0.7);  box-shadow: 0 0 10px rgba(40, 140, 60, 0.3); }
.map-node.biome-desert.unlocked  { background: rgba(180, 140, 50, 0.8); border: 2px solid rgba(220, 180, 80, 0.7);  box-shadow: 0 0 10px rgba(180, 140, 50, 0.3); }
.map-node.biome-tundra.unlocked  { background: rgba(60, 140, 180, 0.8); border: 2px solid rgba(100, 200, 240, 0.7); box-shadow: 0 0 10px rgba(60, 140, 180, 0.3); }
.map-node.biome-volcano.unlocked { background: rgba(180, 50, 30, 0.8);  border: 2px solid rgba(240, 100, 60, 0.7);  box-shadow: 0 0 10px rgba(180, 50, 30, 0.3); }
.map-node.biome-void.unlocked    { background: rgba(100, 40, 160, 0.8); border: 2px solid rgba(160, 80, 240, 0.7);  box-shadow: 0 0 10px rgba(100, 40, 160, 0.3); }

.map-node.biome-forest.unlocked:hover  { box-shadow: 0 0 16px rgba(80, 200, 100, 0.5); }
.map-node.biome-desert.unlocked:hover  { box-shadow: 0 0 16px rgba(220, 180, 80, 0.5); }
.map-node.biome-tundra.unlocked:hover  { box-shadow: 0 0 16px rgba(100, 200, 240, 0.5); }
.map-node.biome-volcano.unlocked:hover { box-shadow: 0 0 16px rgba(240, 100, 60, 0.5); }
.map-node.biome-void.unlocked:hover    { box-shadow: 0 0 16px rgba(160, 80, 240, 0.5); }

/* Biome connector colors (active) */
.map-connector-h.biome-forest.active,  .map-connector-v.biome-forest.active  { background: rgba(80, 200, 100, 0.5);  box-shadow: 0 0 4px rgba(80, 200, 100, 0.3); }
.map-connector-h.biome-desert.active,  .map-connector-v.biome-desert.active  { background: rgba(220, 180, 80, 0.5);  box-shadow: 0 0 4px rgba(220, 180, 80, 0.3); }
.map-connector-h.biome-tundra.active,  .map-connector-v.biome-tundra.active  { background: rgba(100, 200, 240, 0.5); box-shadow: 0 0 4px rgba(100, 200, 240, 0.3); }
.map-connector-h.biome-volcano.active, .map-connector-v.biome-volcano.active { background: rgba(240, 100, 60, 0.5);  box-shadow: 0 0 4px rgba(240, 100, 60, 0.3); }
.map-connector-h.biome-void.active,    .map-connector-v.biome-void.active    { background: rgba(160, 80, 240, 0.5);  box-shadow: 0 0 4px rgba(160, 80, 240, 0.3); }

/* Biome-themed close button */
#map-panel.map-biome-forest  .panel-close-btn { border-color: rgba(60, 160, 80, 0.45); }
#map-panel.map-biome-desert  .panel-close-btn { border-color: rgba(200, 160, 60, 0.45); }
#map-panel.map-biome-tundra  .panel-close-btn { border-color: rgba(80, 180, 220, 0.45); }
#map-panel.map-biome-volcano .panel-close-btn { border-color: rgba(220, 80, 40, 0.45); }
#map-panel.map-biome-void    .panel-close-btn { border-color: rgba(140, 60, 220, 0.45); }

