/* Loot Grinder - Medieval Theme Styles */

/* CSS Variables */
:root {
  --color-bg-dark: #1a0f0a;
  --color-bg-medium: #2d1810;
  --color-bg-light: #3d2418;
  --color-bg-panel: #4a2c1a;
  --color-gold: #ffd700;
  --color-gold-dark: #b8860b;
  --color-gold-light: #fff4cc;
  --color-text: #e8dcc8;
  --color-text-dim: #a89878;
  --color-accent: #8b4513;
  --color-success: #4a9c5d;
  --color-error: #9c4a4a;
  --color-info: #4a7a9c;
  --border-medieval: 2px solid #5a3d2a;
  --shadow-glow: 0 0 20px rgba(255, 215, 0, 0.3);
  --font-medieval: 'Georgia', 'Times New Roman', serif;
  --transition-fast: 0.15s ease;
  --transition-medium: 0.3s ease;
}

/* GPU Acceleration for animated elements and containers */
#particle-container,
#beer-rain-container,
#weather-container,
#peon-container,
#kingdom-map,
#starfield,
.falling-beer,
.beer-trail-star,
.raindrop,
.snowflake,
.peon,
.peon-drunk,
.dragon,
.seagull,
.coin-burst,
.star-burst,
.star-particle,
.breeding-heart,
.floating-text,
.click-particle,
.knight-sprite,
.witch-sprite,
.wizard-sprite,
.ghost-sprite,
.spider,
.goblin,
.fish,
.tornado,
.kaiju,
.disco-lights,
.lightning-flash,
.tiny-peon,
.plague-zombie,
.chest-image,
.chest-glow,
.coin-icon,
.news-icon,
.boat,
.sparkle-container,
.sparkle,
.witch-trail-star,
.wizard-trail-star,
.ghost-trail-star,
[class*="tiny-peon-walk-"],
[class*="seagull-fly-"] {
  will-change: transform, opacity;
  transform: translateZ(0);
  backface-visibility: hidden;
}

/* Reset and Base */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--font-medieval);
  color: var(--color-text);
  height: 100vh;
  overflow: hidden;
  background:
    linear-gradient(rgba(0, 0, 0, 0.8), rgba(0, 0, 0, 0.8)),
    url('img/wall.jpg') repeat;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

/* Prevent touch selection and zoom on all images */
img {
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

/* Prevent double-tap zoom on all interactive elements */
button, a, .clickable, [role="button"] {
  touch-action: manipulation;
}

/* Game Container */
#game-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  max-width: 1600px;
  margin: 0 auto;
  padding: 0.5rem;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
}

/* Header */
#game-header {
  padding: 0.5rem 0.75rem;
  background: url('img/wall.jpg') repeat;
  border-bottom: var(--border-medieval);
  border-radius: 8px 8px 0 0;
  box-shadow: inset 0 -2px 4px rgba(0, 0, 0, 0.3);
}

.header-top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 0.5rem;
}

.social-links {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  flex-shrink: 0;
}

.social-links a {
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity var(--transition-fast), transform var(--transition-fast);
}

.social-links a:hover {
  opacity: 0.8;
  transform: scale(1.1);
}

.social-links svg {
  width: 20px;
  height: 20px;
}

.header-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 0.6rem 0;
}

.header-logo {
  height: 48px;
  width: auto;
  filter: drop-shadow(2px 4px 6px rgba(0, 0, 0, 1));
}

/* Film Quote Panel */
#film_quote_panel {
  padding: 6px 12px;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.6), rgba(0, 0, 0, 0.3));
  border-radius: 8px;
  border: 1px solid var(--color-gold-dark);
  flex: 1;
  min-width: 0;
  transition: opacity 0.5s ease;
  cursor: pointer;
  line-height: 1.4;
}

#film_quote_panel.fade-out {
  opacity: 0;
}

#film_quote_panel.fade-in {
  opacity: 1;
}

#film_quote_panel .quote-text {
  font-style: italic;
  font-weight: 600;
  color: var(--color-text);
  font-size: 0.95rem;
}

#film_quote_panel .quote-source {
  font-size: 0.8rem;
  color: var(--color-gold);
  margin-left: 0.5em;
}

#film_quote_panel .film-search-icon {
  opacity: 0;
  margin-left: 0.4em;
  font-size: 0.75rem;
  cursor: pointer;
  transition: opacity 0.2s ease, transform 0.2s ease;
  display: inline-block;
  vertical-align: middle;
}

#film_quote_panel:hover .film-search-icon {
  opacity: 0.7;
}

#film_quote_panel .film-search-icon:hover {
  opacity: 1;
  transform: scale(1.2);
}

/* Navigation Tabs */
#main-nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.5rem;
}

.tab-btn {
  background: linear-gradient(180deg,
    #ffd700 0%,
    #ffec80 15%,
    #ffd700 30%,
    #b8960c 70%,
    #8b7209 100%);
  border: 2px solid #8b6914;
  border-top-color: #ffe066;
  border-left-color: #ffe066;
  color: #3d2e0a;
  padding: 0.5rem 1rem;
  font-family: var(--font-medieval);
  font-size: 0.9rem;
  font-weight: bold;
  cursor: pointer;
  border-radius: 4px;
  transition: all var(--transition-fast);
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.3);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.4),
    inset 0 -1px 0 rgba(0, 0, 0, 0.2),
    1px -1px 2px rgba(0, 0, 0, 0.6),
    3px 5px 8px rgba(0, 0, 0, 1);
  position: relative;
  overflow: hidden;
}

.tab-btn::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 50%;
  height: 100%;
  background: linear-gradient(90deg,
    transparent,
    rgba(255, 255, 255, 0.4),
    transparent);
  animation: gold-shine 20s ease-in-out infinite;
}

.tab-btn.shine-now::before {
  animation: gold-shine-once 0.6s ease-in-out !important;
}

@keyframes gold-shine {
  0%, 96%, 100% { left: -100%; }
  98% { left: 150%; }
}

@keyframes gold-shine-once {
  0% { left: -100%; }
  100% { left: 150%; }
}

.tab-btn:hover {
  background: linear-gradient(180deg,
    #ffe033 0%,
    #fff1a6 15%,
    #ffe033 30%,
    #cca80e 70%,
    #9a8009 100%);
  color: #2d2208;
  transform: translateY(-1px);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.5),
    inset 0 -1px 0 rgba(0, 0, 0, 0.2),
    0 4px 8px rgba(0, 0, 0, 0.3);
}

.tab-btn.active {
  background: linear-gradient(180deg,
    #ffdb4d 0%,
    #fff5c2 15%,
    #ffdb4d 30%,
    #d4b00f 70%,
    #a6890b 100%);
  color: #1a1505;
  border-color: #ffd700;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.6),
    inset 0 -1px 0 rgba(0, 0, 0, 0.1),
    0 0 10px rgba(255, 215, 0, 0.5),
    0 2px 4px rgba(0, 0, 0, 0.3);
}

/* Share Button */
.share-container {
  position: relative;
  display: inline-block;
}

.share-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem 0.75rem;
}

.share-btn svg {
  stroke: #3d2e0a;
}

.share-menu {
  display: none;
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 0.5rem;
  background: var(--color-bg-panel);
  border: 2px solid var(--color-gold-dark);
  border-radius: 8px;
  min-width: 160px;
  z-index: 1000;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.6);
  overflow: hidden;
}

.share-menu.open {
  display: block;
}

.share-option {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  color: var(--color-text);
  text-decoration: none;
  font-size: 0.9rem;
  border-bottom: 1px solid var(--color-bg-light);
  transition: background var(--transition-fast);
}

.share-option:last-child {
  border-bottom: none;
}

.share-option:hover {
  background: var(--color-bg-light);
  color: var(--color-gold);
}

.share-option svg {
  flex-shrink: 0;
}

/* Main Content Layout - 50/50 split */
#game-main {
  display: flex;
  flex: 1;
  gap: 0.2rem;
  padding: 0;
  min-height: 0;
  overflow: hidden;
  background:
    linear-gradient(rgba(0, 0, 0, 0.6), rgba(0, 0, 0, 0.6)),
    url('img/wall.jpg') repeat;
}

/* ============================================
   CHEST SECTION - 50% OF SCREEN
   ============================================ */
#chest-section {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: #000000;
  border: 2px solid #333333;
  border-radius: 8px;
  position: relative;
  overflow: hidden;
  container-type: size;
  container-name: chest-section;
}

/* Starfield canvas */
#starfield {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
}

#starfield.judder {
  animation: star-judder 0.15s ease-out;
}

@keyframes star-judder {
  0%, 100% { transform: translate(0, 0); }
  25% { transform: translate(-2px, 1px); }
  50% { transform: translate(2px, -1px); }
  75% { transform: translate(-1px, -2px); }
}

/* Tax Revenue Progress Bar */
#tax-bar-container {
  position: absolute;
  top: 50px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 99;
  width: 80%;
  max-width: 300px;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

#tax-bar-container:hover {
  transform: translateX(-50%) scale(1.02);
}

#tax-bar-container:active {
  transform: translateX(-50%) scale(0.98);
}

#tax-bar-container.hidden {
  display: none;
}

#tax-bar-label {
  color: var(--color-gold);
  font-size: 0.75rem;
  text-align: center;
  margin-bottom: 4px;
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
  font-weight: bold;
}

#tax-bar-wrapper {
  position: relative;
  height: 20px;
  background: linear-gradient(180deg, rgba(30, 30, 30, 0.9), rgba(20, 20, 20, 0.9));
  border: 2px solid var(--color-gold);
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5), inset 0 1px 3px rgba(0, 0, 0, 0.5);
}

#tax-bar-progress {
  height: 100%;
  width: 0%;
  background: linear-gradient(180deg, #4CAF50, #2E7D32);
  border-radius: 8px;
  transition: width 0.3s ease;
  box-shadow: inset 0 1px 2px rgba(255, 255, 255, 0.3);
}

#tax-bar-text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: white;
  font-size: 0.7rem;
  font-weight: bold;
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
  white-space: nowrap;
}

/* News Panel */
#news_panel {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.8), rgba(0, 0, 0, 0.6));
  border: 1px solid var(--color-gold);
  border-radius: 8px;
  padding: 8px 16px;
  color: var(--color-gold);
  font-size: 1rem;
  text-align: center;
  opacity: 1;
  transition: opacity 0.5s ease;
  pointer-events: none;
}

#news_panel.hidden {
  opacity: 0;
  visibility: hidden;
}

#news_panel.fade-out {
  opacity: 0;
}

/* News panel with icon support */
#news_panel {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.news-icon {
  font-size: 2rem;
  animation: news-icon-sway 5s ease-in-out infinite;
  display: inline-block;
}

.news-text {
  display: inline-block;
}

@keyframes news-icon-sway {
  0%, 100% {
    transform: rotate(-15deg);
  }
  50% {
    transform: rotate(15deg);
  }
}

/* Ambient background glow */
#chest-section::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 80%;
  height: 80%;
  background: radial-gradient(ellipse, rgba(255, 215, 0, 0.08) 0%, transparent 70%);
  animation: ambient-glow 4s ease-in-out infinite;
  pointer-events: none;
  z-index: 1;
}

@keyframes ambient-glow {
  0%, 100% { opacity: 0.3; transform: translate(-50%, -50%) scale(1); }
  50% { opacity: 0.5; transform: translate(-50%, -50%) scale(1.1); }
}

#chest-container {
  position: relative;
  width: 100%;
  max-width: 600px;
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  touch-action: manipulation;
}

/* Peon container - covers entire chest section */
#peon-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 5;
  overflow: visible;
  user-select: none;
  -webkit-user-select: none;
}

.peon {
  position: absolute;
  /* font-size, width, height controlled by JS for dynamic sizing */
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.5));
  transition: transform 0.15s ease, font-size 0.3s ease, width 0.3s ease, height 0.3s ease;
  will-change: left, top, transform;
  pointer-events: auto;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  /* Larger click area with padding */
  padding: 10px;
  margin: -10px;
  touch-action: manipulation;
}

.peon:hover {
  transform: scale(1.2);
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.5)) brightness(1.2);
}

.peon-tooltip {
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.85);
  color: var(--color-gold);
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 0.75rem;
  white-space: pre-line;
  text-align: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
  pointer-events: none;
  border: 1px solid var(--color-gold-dark);
  z-index: 100;
}

.peon:hover .peon-tooltip {
  opacity: 1;
  visibility: visible;
  transition-delay: 0.001s;
}

/* Peon visibility rotation animations */
.peon-fading-out {
  animation: peon-fade-out 0.5s ease-out forwards;
}

.peon-fading-in {
  animation: peon-fade-in 0.5s ease-in forwards;
}

@keyframes peon-fade-out {
  0% {
    opacity: 1;
    transform: scale(1);
  }
  100% {
    opacity: 0;
    transform: scale(0.5);
  }
}

@keyframes peon-fade-in {
  0% {
    opacity: 0;
    transform: scale(0.5);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

.peon-sleeping {
  opacity: 0.6;
}

.peon-sleeping .peon-sprite {
  animation: none !important;
}

.peon-sleeping::after {
  content: '💤';
  position: absolute;
  top: -10px;
  right: -5px;
  font-size: 1rem;
  animation: sleep-float 1.5s ease-in-out infinite;
}

@keyframes sleep-float {
  0%, 100% { transform: translateY(0); opacity: 1; }
  50% { transform: translateY(-5px); opacity: 0.6; }
}

/* Tax Revolt Effects */
.peon-pitchfork {
  position: absolute;
  top: -15px;
  right: -10px;
  font-size: 1.2rem;
  animation: pitchfork-shake 0.2s ease-in-out infinite;
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.5));
  z-index: 10;
}

@keyframes pitchfork-shake {
  0%, 100% { transform: rotate(-15deg); }
  50% { transform: rotate(15deg); }
}

.tax-revolt-active {
  animation: revolt-flash 0.5s ease-in-out 3;
}

@keyframes revolt-flash {
  0%, 100% { background-color: transparent; }
  50% { background-color: rgba(139, 0, 0, 0.15); }
}

.peon-jumped {
  animation: peon-jump-react 0.3s ease-out;
}

@keyframes peon-jump-react {
  0% { transform: scale(1); }
  30% { transform: scale(1.3) translateY(-10px); }
  100% { transform: scale(1) translateY(0); }
}

.peon-sprite {
  display: inline-block;
  animation: peon-bounce 0.3s ease-in-out infinite;
  transition: transform 0.1s ease;
}

.peon.walking-left .peon-sprite {
  transform: scaleX(-1);
}

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

.peon.walking-left .peon-sprite {
  animation: peon-bounce-flip 0.3s ease-in-out infinite;
}

@keyframes peon-bounce-flip {
  0%, 100% {
    transform: scaleX(-1) translateY(0);
  }
  50% {
    transform: scaleX(-1) translateY(-3px);
  }
}

/* Peon breeding effect */
.breeding-heart {
  position: absolute;
  font-size: 2rem;
  pointer-events: none;
  animation: heart-float 1s ease-out forwards;
  z-index: 1000;
}

@keyframes heart-float {
  0% {
    opacity: 1;
    transform: translateY(0) scale(0.5);
  }
  50% {
    opacity: 1;
    transform: translateY(-30px) scale(1.2);
  }
  100% {
    opacity: 0;
    transform: translateY(-60px) scale(1);
  }
}

/* Dragon attack styles */
.dragon {
  font-size: 5rem;
  z-index: 6000;
  cursor: pointer;
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.5));
  animation: dragon-flap 0.3s ease-in-out infinite;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.dragon:hover {
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.5)) brightness(1.3);
}

@keyframes dragon-flap {
  0%, 100% {
    transform: scaleX(var(--scale-x, 1)) translateY(0);
  }
  50% {
    transform: scaleX(var(--scale-x, 1)) translateY(-8px);
  }
}

.dragon-target {
  animation: target-pulse 0.5s ease-in-out infinite !important;
}

@keyframes target-pulse {
  0%, 100% {
    filter: drop-shadow(0 0 10px rgba(255, 0, 0, 0.8));
  }
  50% {
    filter: drop-shadow(0 0 20px rgba(255, 0, 0, 1)) brightness(1.2);
  }
}

.peon-eaten {
  animation: peon-eaten 0.3s ease-out forwards !important;
}

/* Knight styles */
.knight {
  font-size: 4rem;
  z-index: 2001;
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.5));
  animation: knight-charge 0.2s ease-in-out infinite;
  user-select: none;
  -webkit-user-select: none;
}

@keyframes knight-charge {
  0%, 100% { transform: scaleX(var(--scale-x, 1)) translateY(0); }
  50% { transform: scaleX(var(--scale-x, 1)) translateY(-5px); }
}

@keyframes peon-eaten {
  0% {
    transform: scale(1);
    opacity: 1;
  }
  50% {
    transform: scale(1.5);
  }
  100% {
    transform: scale(0);
    opacity: 0;
  }
}

/* Coin container for flying coins */
#coin-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1000;
  overflow: hidden;
}

/* Gold coin animation */
.gold-coin {
  position: absolute;
  width: 30px;
  height: 30px;
  background: radial-gradient(ellipse at 30% 30%, #fff7a8, #ffd700 40%, #b8860b 100%);
  border-radius: 50%;
  box-shadow:
    inset -2px -2px 4px rgba(0, 0, 0, 0.3),
    inset 2px 2px 4px rgba(255, 255, 255, 0.5),
    0 0 10px rgba(255, 215, 0, 0.5);
  animation: coin-burst 1s ease-out forwards;
  pointer-events: none;
}

.gold-coin::before {
  content: '$';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 14px;
  font-weight: bold;
  color: #8b6914;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.5);
}

@keyframes coin-burst {
  0% {
    opacity: 1;
    transform: translate(0, 0) rotate(0deg) scale(1);
  }
  100% {
    opacity: 0;
    transform: translate(var(--tx), var(--ty)) rotate(720deg) scale(0.5);
  }
}

/* Star particle for purchase explosion */
.star-particle {
  position: absolute;
  pointer-events: none;
  animation: star-burst 0.7s ease-out forwards;
  filter: drop-shadow(0 0 6px rgba(255, 215, 0, 0.8));
  transform: translate(-50%, -50%);
}

@keyframes star-burst {
  0% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
  100% {
    opacity: 0;
    transform: translate(calc(-50% + var(--tx)), calc(-50% + var(--ty))) scale(0.5);
  }
}

/* Particle container */
#particle-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1001;
}

.click-particle {
  position: absolute;
  color: var(--color-gold);
  font-size: 3.2rem;
  font-weight: bold;
  -webkit-text-stroke: 2px #b8860b;
  text-shadow: 0 0 10px rgba(255, 215, 0, 0.8), 0 0 20px rgba(255, 215, 0, 0.5);
  background: transparent;
  padding: 4px 12px;
  border-radius: 8px;
  animation: float-up 1s ease-out forwards;
  pointer-events: none;
}

@keyframes float-up {
  0% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
  100% {
    opacity: 0;
    transform: translateY(-100px) scale(1.5);
  }
}

/* ============================================
   THE CHEST - MAIN FOCUS
   ============================================ */
#chest {
  position: relative;
  width: 100%;
  height: 100%;
  background: none;
  border: none;
  outline: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: chest-throb 2s ease-in-out infinite;
  transform-origin: center bottom;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  user-select: none;
  touch-action: manipulation;
}

@keyframes chest-throb {
  0%, 100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.05);
  }
}

#chest:hover {
  animation: chest-throb 1s ease-in-out infinite;
}

#chest:active,
#chest.clicked {
  animation: none;
  transform: scale(0.95);
}

/* Chest image */
.chest-image {
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 10px 30px rgba(0, 0, 0, 0.5));
  transition: filter 0.3s ease;
  user-select: none;
  -webkit-user-select: none;
  -webkit-user-drag: none;
  -khtml-user-drag: none;
  -moz-user-drag: none;
  -o-user-drag: none;
  pointer-events: none;
  animation: chest-sway 8s ease-in-out infinite;
  transform-origin: center bottom;
}

@keyframes chest-sway {
  0%, 100% {
    transform: rotate(-5deg);
  }
  50% {
    transform: rotate(10deg);
  }
}

#chest:hover .chest-image {
  filter:
    drop-shadow(0 10px 30px rgba(0, 0, 0, 0.5))
    drop-shadow(0 0 20px rgba(255, 215, 0, 0.4));
}

/* Fallback chest (CSS-based) */
.chest-fallback {
  width: 80%;
  height: 80%;
}

.chest-body {
  position: relative;
  width: 100%;
  height: 100%;
}

.chest-base {
  position: absolute;
  bottom: 0;
  width: 100%;
  height: 70%;
  background: linear-gradient(135deg, #8b4513 0%, #654321 50%, #4a3728 100%);
  border: 4px solid #3d2817;
  border-radius: 8px;
  box-shadow:
    inset 0 -10px 20px rgba(0, 0, 0, 0.4),
    inset 0 10px 20px rgba(255, 255, 255, 0.1),
    0 8px 20px rgba(0, 0, 0, 0.5);
}

.chest-base::before,
.chest-base::after {
  content: '';
  position: absolute;
  background: linear-gradient(90deg, #b8860b, #ffd700, #b8860b);
  height: 8px;
  left: 5%;
  right: 5%;
}

.chest-base::before {
  top: 20%;
  border-radius: 2px;
}

.chest-base::after {
  top: 60%;
  border-radius: 2px;
}

.chest-lid {
  position: absolute;
  top: 0;
  width: 100%;
  height: 45%;
  background: linear-gradient(135deg, #9b5523 0%, #7a4420 50%, #5a3418 100%);
  border: 4px solid #3d2817;
  border-radius: 8px 8px 0 0;
  transform-origin: bottom;
  transition: transform var(--transition-fast);
  box-shadow:
    inset 0 10px 20px rgba(255, 255, 255, 0.1),
    0 -4px 10px rgba(0, 0, 0, 0.3);
}

.chest-lid::before {
  content: '';
  position: absolute;
  top: 40%;
  left: 5%;
  right: 5%;
  height: 8px;
  background: linear-gradient(90deg, #b8860b, #ffd700, #b8860b);
  border-radius: 2px;
}

#chest:hover .chest-lid,
#chest.clicked .chest-lid {
  transform: rotateX(-15deg);
}

.chest-lock {
  position: absolute;
  top: -15px;
  left: 50%;
  transform: translateX(-50%);
  width: 30px;
  height: 35px;
  background: linear-gradient(135deg, #ffd700 0%, #b8860b 100%);
  border: 3px solid #8b6914;
  border-radius: 4px 4px 8px 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

.chest-lock::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 8px;
  height: 12px;
  background: #3d2817;
  border-radius: 0 0 4px 4px;
}

/* ============================================
   SPARKLE & TWINKLE EFFECTS
   ============================================ */
.sparkle-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.sparkle {
  position: absolute;
  width: 10px;
  height: 10px;
  background: radial-gradient(circle, #fff 0%, #ffd700 50%, transparent 70%);
  border-radius: 50%;
  animation: twinkle 1.5s ease-in-out infinite;
  box-shadow: 0 0 10px #ffd700, 0 0 20px #ffd700;
}

.sparkle::before,
.sparkle::after {
  content: '';
  position: absolute;
  background: linear-gradient(90deg, transparent, #fff, transparent);
}

.sparkle::before {
  width: 20px;
  height: 2px;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

.sparkle::after {
  width: 2px;
  height: 20px;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

/* Position each sparkle differently */
.sparkle.s1 { top: 10%; left: 20%; animation-delay: 0s; }
.sparkle.s2 { top: 15%; right: 15%; animation-delay: 0.2s; }
.sparkle.s3 { top: 40%; left: 5%; animation-delay: 0.4s; }
.sparkle.s4 { top: 35%; right: 8%; animation-delay: 0.6s; }
.sparkle.s5 { bottom: 30%; left: 12%; animation-delay: 0.8s; }
.sparkle.s6 { bottom: 25%; right: 18%; animation-delay: 1s; }
.sparkle.s7 { top: 25%; left: 45%; animation-delay: 1.2s; }
.sparkle.s8 { bottom: 40%; right: 40%; animation-delay: 0.3s; }

@keyframes twinkle {
  0%, 100% {
    opacity: 0;
    transform: scale(0.5);
  }
  50% {
    opacity: 1;
    transform: scale(1.2);
  }
}

/* Chest glow effect */
.chest-glow {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 120%;
  height: 120%;
  background: radial-gradient(ellipse, rgba(255, 215, 0, 0.3) 0%, transparent 60%);
  animation: glow-pulse 2s ease-in-out infinite;
  pointer-events: none;
}

@keyframes glow-pulse {
  0%, 100% { opacity: 0.3; transform: translate(-50%, -50%) scale(1); }
  50% { opacity: 0.7; transform: translate(-50%, -50%) scale(1.1); }
}

/* Stats Display - Bottom of chest section */
#stats-display {
  position: absolute;
  bottom: 0.5rem;
  left: 50%;
  transform: translateX(-50%);
  width: 95%;
  max-width: 400px;
  z-index: 20;
  display: flex;
  gap: 0.5rem;
  align-items: stretch;
}

.stat-item {
  text-align: center;
  padding: 0.5rem 0.75rem;
  background: rgba(0, 0, 0, 0.85);
  border: var(--border-medieval);
  border-radius: 6px;
}

.stat-item.main-stat {
  flex: 2;
  padding: 0.5rem 1rem;
  background: linear-gradient(180deg, rgba(255, 215, 0, 0.15) 0%, rgba(0, 0, 0, 0.85) 100%);
  border-color: var(--color-gold-dark);
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.stat-item.main-stat .loot-text {
  flex: 1;
}

.stat-item.main-stat .stat-value {
  font-size: 1.75rem;
  color: var(--color-gold);
  text-shadow: 0 0 10px rgba(255, 215, 0, 0.5);
}

/* Spinning Coin */
.spinning-coin {
  width: 32px;
  height: 32px;
  position: relative;
  transform-style: preserve-3d;
  animation: coin-spin 2s linear infinite;
}

.coin-face {
  position: absolute;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  backface-visibility: hidden;
}

.coin-front {
  background: radial-gradient(ellipse at 30% 30%, #fff7a8, #ffd700 40%, #b8860b 100%);
  box-shadow:
    inset -2px -2px 4px rgba(0, 0, 0, 0.3),
    inset 2px 2px 4px rgba(255, 255, 255, 0.5);
}

.coin-front::before {
  content: '$';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 18px;
  font-weight: bold;
  color: #8b6914;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.5);
}

.coin-back {
  background: radial-gradient(ellipse at 70% 30%, #fff7a8, #ffd700 40%, #b8860b 100%);
  box-shadow:
    inset 2px -2px 4px rgba(0, 0, 0, 0.3),
    inset -2px 2px 4px rgba(255, 255, 255, 0.5);
  transform: rotateY(180deg);
}

.coin-back::before {
  content: '★';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 16px;
  color: #8b6914;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.5);
}

@keyframes coin-spin {
  0% { transform: rotateY(0deg); }
  100% { transform: rotateY(360deg); }
}

.stat-row {
  display: flex;
  flex: 1;
  gap: 0.5rem;
}

.stat-row .stat-item {
  flex: 1;
}

.stat-label {
  display: block;
  font-size: 0.8rem;
  color: var(--color-text-dim);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 0.25rem;
}

.stat-value {
  display: block;
  font-size: 1.25rem;
  font-weight: bold;
  color: var(--color-gold-light);
}

/* ============================================
   PANEL SECTION - 50% OF SCREEN
   ============================================ */
#panel-section {
  flex: 0 0 40%;
  max-width: 40%;
  min-height: 0;
  background:
    linear-gradient(rgba(0, 0, 0, 0.4), rgba(0, 0, 0, 0.4)),
    url('img/wall.jpg') repeat;
  border: 2px solid #333333;
  border-radius: 8px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.tab-panel {
  display: none;
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  min-height: 0;
  scrollbar-gutter: stable;
}

.tab-panel.active {
  display: block;
}

/* Panel section titles - Silver plaque style */
#panel-section h3,
#panel-section h4 {
  text-align: center;
  margin: 0 auto 1rem auto;
  padding: 0.5rem 1.5rem;
  background: linear-gradient(180deg,
    #e8e8e8 0%,
    #f5f5f5 15%,
    #d0d0d0 30%,
    #a8a8a8 70%,
    #888888 100%);
  border: 2px solid #666;
  border-top-color: #ccc;
  border-left-color: #ccc;
  border-radius: 4px;
  color: #000000;
  font-family: var(--font-medieval);
  font-size: 1rem;
  font-weight: bold;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.5);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.6),
    inset 0 -1px 0 rgba(0, 0, 0, 0.2),
    0 2px 4px rgba(0, 0, 0, 0.3);
  display: inline-block;
  width: auto;
}

#panel-section .tab-panel {
  text-align: center;
}

#panel-section #buildings-list,
#panel-section #upgrades-list,
#panel-section #achievements-list,
#panel-section #population-list,
#panel-section .stats-grid,
#panel-section .options-grid {
  text-align: left;
}

/* Buildings List */
#buildings-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.building-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem;
  background: rgba(0, 0, 0, 0.85);
  border: var(--border-medieval);
  border-radius: 6px;
  cursor: pointer;
  transition: all var(--transition-fast);
  position: relative;
}

.building-item:hover {
  background: rgba(0, 0, 0, 0.9);
  border-color: var(--color-gold-dark);
}

.building-item.affordable {
  border-left: 4px solid var(--color-success);
  animation: affordable-shine 3s ease-in-out infinite;
}

@keyframes affordable-shine {
  0%, 85%, 100% {
    box-shadow: none;
  }
  92% {
    box-shadow: 0 0 15px rgba(255, 215, 0, 0.6), inset 0 0 10px rgba(255, 215, 0, 0.1);
  }
}

.building-item.unaffordable {
  border-left: 4px solid var(--color-error);
}

.building-item.unaffordable .building-info,
.building-item.unaffordable .building-icon {
  opacity: 0.6;
}

.building-item.affordable:hover {
  box-shadow: var(--shadow-glow);
}

/* Sale ribbon for affordable items */
.sale-ribbon {
  position: absolute;
  top: -2px;
  right: -2px;
  background: linear-gradient(135deg, #2ecc71 0%, #27ae60 50%, #1e8449 100%);
  color: white;
  font-size: 0.65rem;
  font-weight: bold;
  padding: 0.2rem 0.5rem;
  border-radius: 0 6px 0 6px;
  text-transform: uppercase;
  letter-spacing: 1px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
  z-index: 1;
  animation: ribbon-pulse 2s ease-in-out infinite;
}

@keyframes ribbon-pulse {
  0%, 100% {
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
  }
  50% {
    box-shadow: 0 2px 8px rgba(46, 204, 113, 0.6);
  }
}

.building-icon {
  font-size: 2rem;
  width: 50px;
  text-align: center;
}

.building-info {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  word-wrap: break-word;
}

.building-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.25rem;
}

.building-name {
  font-weight: bold;
  color: var(--color-gold-light);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.building-owned {
  position: absolute;
  right: 2.5rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: 1.25rem;
  font-weight: bold;
  color: var(--color-gold);
  background: var(--color-bg-dark);
  padding: 0.2rem 0.6rem;
  border-radius: 4px;
}

.building-description {
  font-size: 0.8rem;
  color: var(--color-text-dim);
  margin-bottom: 0.25rem;
}

.building-stats {
  display: flex;
  gap: 1rem;
  font-size: 0.85rem;
}

.building-cost {
  color: var(--color-gold);
}

.building-lps {
  color: var(--color-success);
}

.building-shortcut {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  font-size: 0.7rem;
  color: var(--color-text-dim);
  background: var(--color-bg-dark);
  padding: 0.1rem 0.4rem;
  border-radius: 3px;
}

/* Upgrades */
#upgrades-list h3, #upgrades-list h4 {
  color: #000000;
  margin: 1rem 0 0.5rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--color-accent);
}

#upgrades-list h3:first-child {
  margin-top: 0;
}

.no-items {
  color: var(--color-text-dim);
  font-style: italic;
  text-align: center;
  padding: 2rem;
}

.upgrade-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem;
  background: rgba(0, 0, 0, 0.85);
  border: var(--border-medieval);
  border-radius: 6px;
  cursor: pointer;
  margin-bottom: 0.5rem;
  transition: all var(--transition-fast);
  position: relative;
}

.upgrade-item:hover {
  background: rgba(0, 0, 0, 0.9);
}

.upgrade-item.affordable {
  border-color: var(--color-success);
  animation: affordable-shine 3s ease-in-out infinite;
}

.upgrade-item.affordable:hover {
  box-shadow: var(--shadow-glow);
}

.upgrade-item.unaffordable .upgrade-icon,
.upgrade-item.unaffordable .upgrade-info {
  opacity: 0.6;
}

.upgrade-icon {
  font-size: 1.5rem;
  width: 40px;
  text-align: center;
}

.upgrade-info {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  word-wrap: break-word;
}

.upgrade-name {
  font-weight: bold;
  color: var(--color-gold-light);
  margin-bottom: 0.2rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.upgrade-description {
  font-size: 0.8rem;
  color: var(--color-text-dim);
  margin-bottom: 0.2rem;
  word-wrap: break-word;
}

.upgrade-cost {
  font-size: 0.85rem;
  color: var(--color-gold);
}

.purchased-upgrades {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.upgrade-owned {
  font-size: 1.5rem;
  padding: 0.5rem;
  background: rgba(0, 0, 0, 0.85);
  border: var(--border-medieval);
  border-radius: 4px;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
}

.upgrade-owned:hover {
  transform: scale(1.1);
  box-shadow: 0 0 10px var(--color-gold);
}

/* Upgrade Popup */
.upgrade-popup {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.upgrade-popup.show {
  opacity: 1;
}

.upgrade-popup-content {
  background: linear-gradient(180deg, #2a1810, #1a0f0a);
  border: 3px solid var(--color-gold);
  border-radius: 12px;
  padding: 2rem;
  text-align: center;
  max-width: 300px;
  box-shadow: 0 0 30px rgba(212, 175, 55, 0.4);
}

.upgrade-popup-icon {
  font-size: 4rem;
  margin-bottom: 1rem;
}

.upgrade-popup-name {
  font-size: 1.5rem;
  font-weight: bold;
  color: var(--color-gold);
  margin-bottom: 0.5rem;
}

.upgrade-popup-description {
  font-size: 1rem;
  color: var(--color-text);
  margin-bottom: 1rem;
}

.upgrade-popup-hint {
  font-size: 0.75rem;
  color: var(--color-text-dim);
  font-style: italic;
}

/* Peon Stats Popup */
.peon-stats-popup {
  position: fixed;
  transform: translate(-50%, -100%);
  background: linear-gradient(180deg, #2a1810, #1a0f0a);
  border: 2px solid var(--color-gold);
  border-radius: 8px;
  padding: 0.75rem;
  z-index: 1000;
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
  box-shadow: 0 0 15px rgba(0, 0, 0, 0.8);
}

.peon-stats-popup.show {
  opacity: 1;
}

.peon-stats-content {
  text-align: center;
  min-width: 120px;
}

.peon-stats-name {
  font-size: 0.9rem;
  font-weight: bold;
  color: var(--color-gold);
  margin-bottom: 0.25rem;
}

.peon-stats-sex {
  font-size: 1rem;
  margin-bottom: 0.5rem;
}

.peon-stats-row {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  font-size: 0.75rem;
  color: var(--color-text);
}

/* Achievements */
#achievements-list h3, #achievements-list h4 {
  color: #000000;
  margin: 1rem 0 0.5rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--color-accent);
}

#achievements-list h3:first-child {
  margin-top: 0;
}

.achievements-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 0.5rem;
}

.achievement-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0.75rem;
  background: rgba(0, 0, 0, 0.85);
  border: var(--border-medieval);
  border-radius: 6px;
  text-align: center;
  cursor: help;
  opacity: 0.9;
}

.achievement-item.unlocked {
  border-color: var(--color-gold-dark);
  background: linear-gradient(135deg, rgba(0, 0, 0, 0.95) 0%, rgba(0, 0, 0, 0.9) 100%);
  box-shadow: inset 0 0 20px rgba(255, 215, 0, 0.15);
}

.achievement-icon {
  font-size: 2rem;
  margin-bottom: 0.25rem;
}

.achievement-name {
  font-size: 0.75rem;
  color: var(--color-text-dim);
}

.achievement-item.unlocked .achievement-name {
  color: var(--color-gold-light);
}

/* Stats Panel */
.stats-grid {
  display: grid;
  gap: 1rem;
}

.stats-card {
  background: rgba(0, 0, 0, 0.85);
  border: var(--border-medieval);
  border-radius: 6px;
  padding: 1rem;
}

.stats-card h3 {
  color: #000000;
  margin-bottom: 0.75rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--color-accent);
}

.stats-row {
  display: flex;
  justify-content: space-between;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--color-bg-dark);
}

.stats-row:last-of-type {
  border-bottom: none;
}

.stats-row span:last-child {
  font-weight: bold;
  color: var(--color-gold-light);
}

.prestige-section {
  margin-top: 1rem;
}

.btn-prestige {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  padding: 1rem;
  background: linear-gradient(135deg, #4a3060 0%, #2d1840 100%);
  border: 2px solid #6a4080;
  border-radius: 6px;
  color: var(--color-text);
  font-family: var(--font-medieval);
  cursor: pointer;
  transition: all var(--transition-fast);
  opacity: 0.6;
}

.btn-prestige.available {
  opacity: 1;
  animation: prestige-pulse 2s ease-in-out infinite;
}

@keyframes prestige-pulse {
  0%, 100% { box-shadow: 0 0 10px rgba(138, 43, 226, 0.3); }
  50% { box-shadow: 0 0 25px rgba(138, 43, 226, 0.6); }
}

.btn-prestige:hover {
  background: linear-gradient(135deg, #5a4070 0%, #3d2850 100%);
}

.prestige-icon {
  font-size: 1.5rem;
}

.prestige-reward {
  font-size: 0.8rem;
  color: #b088d0;
}

/* Options Panel */
.options-grid {
  display: grid;
  gap: 0.5rem;
}

.options-card {
  background: rgba(0, 0, 0, 0.85);
  border: var(--border-medieval);
  border-radius: 6px;
  padding: 1rem;
}

#panel-section .options-card h3 {
  color: #ffd700;
  margin: 0 0 0.75rem 0;
  font-family: 'MedievalSharp', cursive;
  font-size: 1.2rem;
  font-weight: bold;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.9), 0 0 10px rgba(212, 175, 55, 0.3);
  border: none;
  background: transparent;
  padding: 0;
  letter-spacing: 0.5px;
  box-shadow: none;
  text-align: left;
}

.options-card.danger-zone {
  border-color: var(--color-error);
}

#save-btn {
  background: linear-gradient(145deg, #2e7d32, #1b5e20);
  border: 2px solid #4caf50;
  color: #fff;
  font-size: 1.2rem;
  padding: 0.85rem 1.5rem;
  font-weight: bold;
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 2px 4px rgba(0, 0, 0, 0.3);
  float: right;
}

#save-btn:hover {
  background: linear-gradient(145deg, #388e3c, #2e7d32);
  border-color: #66bb6a;
}

.toggle-option {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  cursor: pointer;
}

.kingdom-select {
  width: 100%;
  padding: 0.5rem;
  font-size: 1rem;
  font-family: 'Georgia', serif;
  background: linear-gradient(180deg, #2a1a0a 0%, #1a0f05 100%);
  color: #ffd700;
  border: 2px solid #8B4513;
  border-radius: 4px;
  cursor: pointer;
}

.kingdom-select:hover {
  border-color: #ffd700;
}

.kingdom-select option {
  background: #1a0f05;
  color: #ffd700;
}

.toggle-option input[type="checkbox"] {
  width: 20px;
  height: 20px;
  accent-color: var(--color-gold);
  cursor: pointer;
}

.toggle-label {
  color: var(--color-text);
}

.btn-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.btn {
  padding: 0.5rem 1rem;
  background: var(--color-bg-panel);
  border: var(--border-medieval);
  border-radius: 4px;
  color: var(--color-text);
  font-family: var(--font-medieval);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn:hover {
  background: var(--color-accent);
  border-color: var(--color-gold-dark);
}

.btn-danger {
  background: #5a2020;
  border-color: var(--color-error);
}

.btn-danger:hover {
  background: #7a3030;
}

.btn-primary {
  background: #2a4a6a;
  border-color: var(--color-gold);
}

.btn-primary:hover {
  background: #3a5a7a;
}

.btn-success {
  background: #2a5a2a;
  border-color: #4a8a4a;
}

.info-text {
  font-size: 0.8rem;
  color: var(--color-text-secondary);
  margin-top: 0.5rem;
}

.last-save-info {
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  font-size: 0.85rem;
}

.last-save-info.hidden {
  display: none;
}

.last-save-info p {
  margin: 0.25rem 0;
}

.last-save-info #last-save-time {
  color: var(--color-gold);
}

.last-save-info .save-ago {
  font-size: 0.8rem;
  color: var(--color-text-secondary);
}

/* Install App Button */
.install-card.hidden {
  display: none;
}

.install-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.75rem 1rem;
  font-size: 1rem;
}

.install-icon {
  font-size: 1.2rem;
}

.warning-text {
  font-size: 0.8rem;
  color: var(--color-error);
  margin-top: 0.5rem;
}

.shortcuts-list {
  list-style: none;
}

.shortcuts-list li {
  padding: 0.4rem 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

kbd {
  background: var(--color-bg-dark);
  border: 1px solid var(--color-accent);
  border-radius: 3px;
  padding: 0.2rem 0.5rem;
  font-family: monospace;
  font-size: 0.85rem;
}


#news-text.fade-in {
  animation: fade-in 0.5s ease;
}

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

/* Notifications */
.notification {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  padding: 0.75rem 1.5rem;
  background: var(--color-bg-panel);
  border: var(--border-medieval);
  border-radius: 6px;
  color: var(--color-text);
  font-family: var(--font-medieval);
  opacity: 0;
  transition: all var(--transition-medium);
  z-index: 4000;
}

.notification.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.notification.success {
  border-color: var(--color-success);
  background: linear-gradient(135deg, var(--color-bg-panel) 0%, rgba(74, 156, 93, 0.2) 100%);
}

.notification.error {
  border-color: var(--color-error);
}

.notification.achievement {
  border-color: var(--color-gold);
  background: linear-gradient(135deg, var(--color-bg-panel) 0%, rgba(255, 215, 0, 0.2) 100%);
}

/* Offline Notification Popup */
#offline-notification {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 3000;
  opacity: 0;
  visibility: hidden;
  transition: all var(--transition-medium);
}

#offline-notification.show {
  opacity: 1;
  visibility: visible;
}

.notification-content {
  background: var(--color-bg-medium);
  border: 3px solid var(--color-gold);
  border-radius: 12px;
  padding: 2rem;
  text-align: center;
  max-width: 90%;
  width: 350px;
  box-shadow: var(--shadow-glow);
}

.notification-content h3 {
  color: var(--color-gold);
  font-size: 1.5rem;
  margin-bottom: 1rem;
}

.offline-loot {
  font-size: 2rem;
  font-weight: bold;
  color: var(--color-gold);
  margin: 1rem 0;
}

.notification-content .btn {
  margin-top: 1rem;
  padding: 0.75rem 2rem;
  background: var(--color-gold-dark);
  color: var(--color-bg-dark);
  font-weight: bold;
}

/* GDPR Consent Modal */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 4000;
}

.modal-overlay.hidden {
  display: none;
}

.modal-content {
  background: var(--color-bg-medium);
  border: 3px solid var(--color-gold);
  border-radius: 12px;
  padding: 2rem;
  max-width: 90%;
  width: 450px;
  box-shadow: var(--shadow-glow);
}

.gdpr-modal h2 {
  color: var(--color-gold);
  font-size: 1.4rem;
  margin-bottom: 1rem;
  text-align: center;
}

.gdpr-modal p {
  margin-bottom: 1rem;
  line-height: 1.5;
}

.gdpr-details {
  background: rgba(0, 0, 0, 0.3);
  padding: 0.75rem;
  border-radius: 6px;
  font-size: 0.9rem;
}

.gdpr-note {
  font-size: 0.85rem;
  color: var(--color-text-secondary);
  font-style: italic;
}

.gdpr-buttons {
  display: flex;
  gap: 1rem;
  justify-content: center;
  margin-top: 1.5rem;
}

.gdpr-buttons .btn {
  padding: 0.75rem 1.5rem;
  min-width: 120px;
}

/* Welcome Back Overlay (over chest section) */
#welcome-back-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 100;
  cursor: pointer;
  transition: opacity 0.5s ease-out;
}

#welcome-back-overlay.hidden {
  display: none;
}

#welcome-back-overlay.fade-out {
  opacity: 0;
  pointer-events: none;
}

#welcome-image {
  max-width: 80%;
  max-height: 50%;
  object-fit: contain;
  border-radius: 8px;
  box-shadow: 0 0 40px rgba(255, 215, 0, 0.3);
}

#welcome-version {
  color: #ffd700;
  font-size: 1rem;
  font-weight: bold;
  margin-top: 0.5rem;
  text-shadow: 0 0 10px rgba(255, 215, 0, 0.5);
}

#welcome-back-message {
  background: rgba(0, 0, 0, 0.8);
  border: 2px solid #ffd700;
  border-radius: 10px;
  padding: 1rem 1.5rem;
  margin-top: 1rem;
  text-align: center;
}

#welcome-back-message.hidden {
  display: none;
}

#welcome-back-message h3 {
  color: #ffd700;
  font-size: 1.4rem;
  margin: 0 0 0.5rem 0;
  text-shadow: 0 0 10px rgba(255, 215, 0, 0.5);
}

#welcome-back-message p {
  color: #fff;
  margin: 0.3rem 0;
}

#welcome-back-message .welcome-loot {
  color: #ffd700;
  font-size: 1.3rem;
  font-weight: bold;
  margin-top: 0.5rem;
}

#welcome-click-hint {
  color: rgba(255, 255, 255, 0.7);
  font-size: 0.9rem;
  margin-top: 1rem;
  animation: pulse-hint 2s ease-in-out infinite;
}

@keyframes pulse-hint {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 1; }
}

/* Kingdom Overlay */
#kingdom-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 3000;
  transition: opacity 0.3s ease;
}

#kingdom-overlay.hidden {
  display: none;
}

#kingdom-container {
  width: 75%;
  height: 75%;
  background: linear-gradient(180deg, #053045 0%, #064a68 30%, #0a6080 70%, #0f7095 100%);
  border: 4px solid var(--color-gold);
  border-radius: 12px;
  position: relative;
  box-shadow: 0 0 40px rgba(255, 215, 0, 0.3), inset 0 0 60px rgba(0, 0, 0, 0.5);
  overflow: hidden;
}

#kingdom-container h2 {
  text-align: center;
  color: var(--color-gold);
  font-family: var(--font-medieval);
  font-size: 1.5rem;
  padding: 0.75rem;
  margin: 0;
  background: rgba(0, 0, 0, 0.5);
  border-bottom: 2px solid var(--color-gold-dark);
  position: relative;
  z-index: 10;
}

#kingdom-close {
  position: absolute;
  top: 0.25rem;
  right: 0.75rem;
  background: none;
  border: none;
  color: var(--color-gold);
  font-size: 2rem;
  cursor: pointer;
  z-index: 20;
  transition: transform 0.2s, color 0.2s;
  line-height: 1;
  padding: 0.25rem 0.5rem;
}

#kingdom-close:hover {
  color: #fff;
  transform: scale(1.2);
}

#kingdom-zoom-control {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 0.5rem;
  background: rgba(0, 0, 0, 0.4);
  border-bottom: 1px solid var(--color-gold-dark);
  color: var(--color-text);
  font-size: 0.85rem;
  position: relative;
}

#kingdom-zoom-slider {
  width: 120px;
  height: 6px;
  -webkit-appearance: none;
  appearance: none;
  background: linear-gradient(90deg, var(--color-bg-medium) 0%, var(--color-gold-dark) 100%);
  border-radius: 3px;
  cursor: pointer;
}

#kingdom-zoom-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  background: var(--color-gold);
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 0 4px rgba(0, 0, 0, 0.5);
}

#kingdom-zoom-slider::-moz-range-thumb {
  width: 16px;
  height: 16px;
  background: var(--color-gold);
  border-radius: 50%;
  cursor: pointer;
  border: none;
  box-shadow: 0 0 4px rgba(0, 0, 0, 0.5);
}

#kingdom-zoom-value {
  min-width: 2rem;
  text-align: left;
  color: var(--color-gold);
  font-weight: bold;
}

#kingdom-zoom-reset {
  padding: 0.25rem 0.5rem;
  background: var(--color-bg-medium);
  border: 1px solid var(--color-gold-dark);
  border-radius: 4px;
  color: var(--color-text);
  font-family: var(--font-medieval);
  font-size: 0.75rem;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}

#kingdom-zoom-reset:hover {
  background: var(--color-gold-dark);
  color: #fff;
}

#kingdom-map {
  position: relative;
  width: 100%;
  height: calc(100% - 5.5rem);
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
}

/* Sea waves effect */
#kingdom-map::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background:
    repeating-linear-gradient(
      90deg,
      transparent,
      transparent 50px,
      rgba(255, 255, 255, 0.02) 50px,
      rgba(255, 255, 255, 0.02) 100px
    );
  animation: sea-shimmer 8s linear infinite;
  pointer-events: none;
}

@keyframes sea-shimmer {
  0% { transform: translateX(0); }
  100% { transform: translateX(100px); }
}

#kingdom-content {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  transform-origin: center center;
  cursor: grab;
  will-change: transform;
  user-select: none;
  -webkit-user-select: none;
}

#kingdom-content.dragging {
  cursor: grabbing;
}

#kingdom-content * {
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

#kingdom-sea-elements {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

#kingdom-sea-elements > * {
  pointer-events: auto;
}

#kingdom-land {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 80%;
  height: 80%;
  background:
    /* Grass blade texture */
    repeating-linear-gradient(
      90deg,
      transparent 0px,
      transparent 2px,
      rgba(0, 80, 0, 0.3) 2px,
      rgba(0, 80, 0, 0.3) 3px
    ),
    repeating-linear-gradient(
      0deg,
      transparent 0px,
      transparent 3px,
      rgba(0, 60, 0, 0.2) 3px,
      rgba(0, 60, 0, 0.2) 4px
    ),
    repeating-linear-gradient(
      45deg,
      transparent 0px,
      transparent 5px,
      rgba(50, 120, 50, 0.15) 5px,
      rgba(50, 120, 50, 0.15) 6px
    ),
    /* Base green gradient - highlight lower and more spread out */
    linear-gradient(180deg,
      #1a5c1a 0%,
      #1e6e1e 30%,
      #228B22 50%,
      #2d8a2d 70%,
      #1a5c1a 100%),
    radial-gradient(ellipse 100% 80% at 50% 70%,
      rgba(45, 138, 45, 0.5) 0%,
      transparent 60%);
  clip-path: url(#island-clip);
  box-shadow:
    inset 0 0 30px rgba(0, 100, 0, 0.5),
    0 0 20px rgba(0, 50, 0, 0.3);
}

/* Beach/shore effect */
#kingdom-land::before {
  content: '';
  position: absolute;
  top: -3%;
  left: -3%;
  width: 106%;
  height: 106%;
  background: radial-gradient(ellipse 70% 60% at 50% 50%,
    transparent 0%,
    transparent 75%,
    #d4b896 85%,
    #c4a882 90%,
    transparent 100%);
  clip-path: url(#island-clip);
  z-index: -1;
}

#kingdom-buildings {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 80%;
  height: 80%;
  pointer-events: auto;
}

.kingdom-building {
  position: absolute;
  font-size: 1.5rem;
  filter: drop-shadow(2px 2px 2px rgba(0, 0, 0, 0.8));
  transition: transform 0.2s;
  pointer-events: auto;
  cursor: pointer;
}

.kingdom-building:hover {
  transform: scale(1.2);
  z-index: 10;
}

.kingdom-building.massive-castle:hover {
  transform: translate(-50%, -50%) scale(1.1);
}

/* Building occupier popup */
.building-occupier-popup {
  background: var(--color-bg-panel);
  border: 2px solid var(--color-gold-dark);
  border-radius: 8px;
  padding: 0.75rem;
  min-width: 160px;
  z-index: 2000;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.6);
}

.occupier-header {
  font-weight: bold;
  color: var(--color-gold);
  font-size: 1rem;
  margin-bottom: 0.5rem;
  border-bottom: 1px solid var(--color-gold-dark);
  padding-bottom: 0.25rem;
}

.occupier-label {
  font-size: 0.75rem;
  color: var(--color-text-dim);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.occupier-name {
  font-weight: bold;
  color: var(--color-text);
  font-size: 1rem;
  margin: 0.25rem 0;
}

.occupier-stats {
  font-size: 0.8rem;
  color: var(--color-text-dim);
  line-height: 1.4;
}

.occupier-empty {
  font-style: italic;
  color: var(--color-text-dim);
  font-size: 0.85rem;
}

.kingdom-building.massive-castle {
  font-size: 3rem;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 5;
}

/* Population display - grand ancient map style */
#kingdom-population-display {
  text-align: center;
  margin-bottom: 0.5rem;
  font-family: 'Times New Roman', 'Georgia', serif;
  font-size: 0.9rem;
  font-style: italic;
  color: #FFD700;
  text-shadow:
    -1px -1px 0 #8B0000,
    1px -1px 0 #8B0000,
    -1px 1px 0 #8B0000,
    1px 1px 0 #8B0000,
    0 0 8px rgba(255, 215, 0, 0.4);
  letter-spacing: 1px;
}

#kingdom-title {
  font-family: 'Times New Roman', 'Georgia', serif;
  font-size: 1.8rem;
  font-style: italic;
  color: #FFD700;
  text-shadow:
    -2px -2px 0 #8B0000,
    2px -2px 0 #8B0000,
    -2px 2px 0 #8B0000,
    2px 2px 0 #8B0000,
    0 0 15px rgba(255, 215, 0, 0.6);
  letter-spacing: 3px;
  margin-bottom: 0.5rem;
}

/* Sea rocks */
.kingdom-rock {
  position: absolute;
  font-size: 1rem;
  filter: drop-shadow(1px 1px 2px rgba(0, 0, 0, 0.6));
  opacity: 0.9;
}

/* Clickable wrapper for sea elements */
.kingdom-clickable-wrapper {
  position: absolute;
  padding: 0.3rem;
  cursor: pointer;
  pointer-events: auto;
  user-select: none;
  -webkit-user-select: none;
  z-index: 10;
}

/* Seagulls */
.kingdom-seagull {
  position: relative;
  width: 5px;
  height: 5px;
  pointer-events: none;
}

.kingdom-seagull::before,
.kingdom-seagull::after {
  content: '';
  position: absolute;
  background: #fff;
  width: 4px;
  height: 2px;
  border-radius: 50%;
}

.kingdom-seagull::before {
  left: -3px;
  transform: rotate(-20deg);
  animation: seagull-flap-left 0.3s ease-in-out infinite;
}

.kingdom-seagull::after {
  left: 2px;
  transform: rotate(20deg);
  animation: seagull-flap-right 0.3s ease-in-out infinite;
}

@keyframes seagull-flap-left {
  0%, 100% { transform: rotate(-20deg); }
  50% { transform: rotate(-40deg); }
}

@keyframes seagull-flap-right {
  0%, 100% { transform: rotate(20deg); }
  50% { transform: rotate(40deg); }
}

.seagull-fly-1 { animation: seagull-path-1 12s linear infinite; }
.seagull-fly-2 { animation: seagull-path-2 15s linear infinite; }
.seagull-fly-3 { animation: seagull-path-3 10s linear infinite; }
.seagull-fly-4 { animation: seagull-path-4 18s linear infinite; }
.seagull-fly-5 { animation: seagull-path-5 14s linear infinite; }

@keyframes seagull-path-1 {
  0% { left: 5%; top: 15%; }
  25% { left: 20%; top: 10%; }
  50% { left: 35%; top: 8%; }
  75% { left: 15%; top: 12%; }
  100% { left: 5%; top: 15%; }
}

@keyframes seagull-path-2 {
  0% { left: 80%; top: 20%; }
  25% { left: 90%; top: 35%; }
  50% { left: 85%; top: 50%; }
  75% { left: 92%; top: 30%; }
  100% { left: 80%; top: 20%; }
}

@keyframes seagull-path-3 {
  0% { left: 10%; top: 75%; }
  25% { left: 5%; top: 85%; }
  50% { left: 15%; top: 90%; }
  75% { left: 8%; top: 80%; }
  100% { left: 10%; top: 75%; }
}

@keyframes seagull-path-4 {
  0% { left: 85%; top: 70%; }
  25% { left: 92%; top: 80%; }
  50% { left: 88%; top: 88%; }
  75% { left: 90%; top: 75%; }
  100% { left: 85%; top: 70%; }
}

@keyframes seagull-path-5 {
  0% { left: 8%; top: 45%; }
  25% { left: 3%; top: 55%; }
  50% { left: 6%; top: 65%; }
  75% { left: 4%; top: 50%; }
  100% { left: 8%; top: 45%; }
}

/* Wrapper for tiny peons - provides larger click area */
.kingdom-tiny-peon-wrapper {
  position: absolute;
  padding: 0.5rem;
  cursor: pointer;
  pointer-events: auto;
  z-index: 50;
}

/* Tiny land peons walking on the kingdom map */
.kingdom-tiny-peon {
  position: relative;
  width: 4px;
  height: 4px;
  background: #1a1a1a;
  border-radius: 50%;
  pointer-events: none;
  /* Head above the body */
  box-shadow: 0 -3px 0 0 #1a1a1a;
}

/* Left leg and left arm */
.kingdom-tiny-peon::before {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0px;
  width: 1px;
  height: 2px;
  background: #1a1a1a;
  /* Left arm using box-shadow */
  box-shadow: -1px -4px 0 0 #1a1a1a;
  animation: tiny-peon-left-limbs 0.3s ease-in-out infinite;
}

/* Right leg and right arm */
.kingdom-tiny-peon::after {
  content: '';
  position: absolute;
  bottom: -2px;
  right: 0px;
  width: 1px;
  height: 2px;
  background: #1a1a1a;
  /* Right arm using box-shadow */
  box-shadow: 1px -4px 0 0 #1a1a1a;
  animation: tiny-peon-right-limbs 0.3s ease-in-out infinite;
}

@keyframes tiny-peon-left-limbs {
  0%, 100% { transform: translateX(-1px); }
  50% { transform: translateX(1px); }
}

@keyframes tiny-peon-right-limbs {
  0%, 100% { transform: translateX(1px); }
  50% { transform: translateX(-1px); }
}

/* Walking paths for tiny peons - staying on land */
.tiny-peon-walk-1 { animation: tiny-peon-path-1 20s linear infinite; }
.tiny-peon-walk-2 { animation: tiny-peon-path-2 25s linear infinite; }
.tiny-peon-walk-3 { animation: tiny-peon-path-3 18s linear infinite; }
.tiny-peon-walk-4 { animation: tiny-peon-path-4 22s linear infinite; }
.tiny-peon-walk-5 { animation: tiny-peon-path-5 28s linear infinite; }
.tiny-peon-walk-6 { animation: tiny-peon-path-6 24s linear infinite; }
.tiny-peon-walk-7 { animation: tiny-peon-path-7 19s linear infinite; }
.tiny-peon-walk-8 { animation: tiny-peon-path-8 26s linear infinite; }
.tiny-peon-walk-9 { animation: tiny-peon-path-9 21s linear infinite; }
.tiny-peon-walk-10 { animation: tiny-peon-path-10 23s linear infinite; }
.tiny-peon-walk-11 { animation: tiny-peon-path-11 27s linear infinite; }
.tiny-peon-walk-12 { animation: tiny-peon-path-12 17s linear infinite; }
.tiny-peon-walk-13 { animation: tiny-peon-path-13 29s linear infinite; }
.tiny-peon-walk-14 { animation: tiny-peon-path-14 20s linear infinite; }
.tiny-peon-walk-15 { animation: tiny-peon-path-15 24s linear infinite; }
.tiny-peon-walk-16 { animation: tiny-peon-path-16 22s linear infinite; }
.tiny-peon-walk-17 { animation: tiny-peon-path-17 26s linear infinite; }
.tiny-peon-walk-18 { animation: tiny-peon-path-18 18s linear infinite; }
.tiny-peon-walk-19 { animation: tiny-peon-path-19 25s linear infinite; }
.tiny-peon-walk-20 { animation: tiny-peon-path-20 21s linear infinite; }
.tiny-peon-walk-21 { animation: tiny-peon-path-21 23s linear infinite; }
.tiny-peon-walk-22 { animation: tiny-peon-path-22 19s linear infinite; }
.tiny-peon-walk-23 { animation: tiny-peon-path-23 27s linear infinite; }
.tiny-peon-walk-24 { animation: tiny-peon-path-24 20s linear infinite; }
.tiny-peon-walk-25 { animation: tiny-peon-path-25 24s linear infinite; }
.tiny-peon-walk-26 { animation: tiny-peon-path-26 18s linear infinite; }
.tiny-peon-walk-27 { animation: tiny-peon-path-27 26s linear infinite; }
.tiny-peon-walk-28 { animation: tiny-peon-path-28 22s linear infinite; }
.tiny-peon-walk-29 { animation: tiny-peon-path-29 25s linear infinite; }
.tiny-peon-walk-30 { animation: tiny-peon-path-30 21s linear infinite; }
.tiny-peon-walk-31 { animation: tiny-peon-path-31 28s linear infinite; }
.tiny-peon-walk-32 { animation: tiny-peon-path-32 17s linear infinite; }
.tiny-peon-walk-33 { animation: tiny-peon-path-33 23s linear infinite; }
.tiny-peon-walk-34 { animation: tiny-peon-path-34 19s linear infinite; }
.tiny-peon-walk-35 { animation: tiny-peon-path-35 26s linear infinite; }
.tiny-peon-walk-36 { animation: tiny-peon-path-36 20s linear infinite; }
.tiny-peon-walk-37 { animation: tiny-peon-path-37 24s linear infinite; }
.tiny-peon-walk-38 { animation: tiny-peon-path-38 22s linear infinite; }
.tiny-peon-walk-39 { animation: tiny-peon-path-39 27s linear infinite; }
.tiny-peon-walk-40 { animation: tiny-peon-path-40 18s linear infinite; }
.tiny-peon-walk-41 { animation: tiny-peon-path-41 25s linear infinite; }
.tiny-peon-walk-42 { animation: tiny-peon-path-42 21s linear infinite; }
.tiny-peon-walk-43 { animation: tiny-peon-path-43 23s linear infinite; }
.tiny-peon-walk-44 { animation: tiny-peon-path-44 19s linear infinite; }
.tiny-peon-walk-45 { animation: tiny-peon-path-45 28s linear infinite; }
.tiny-peon-walk-46 { animation: tiny-peon-path-46 20s linear infinite; }
.tiny-peon-walk-47 { animation: tiny-peon-path-47 24s linear infinite; }
.tiny-peon-walk-48 { animation: tiny-peon-path-48 22s linear infinite; }
.tiny-peon-walk-49 { animation: tiny-peon-path-49 26s linear infinite; }
.tiny-peon-walk-50 { animation: tiny-peon-path-50 17s linear infinite; }

/* Paths staying on land (center green area roughly 25%-75% x, 25%-80% y) */
@keyframes tiny-peon-path-1 {
  0% { left: 30%; top: 35%; }
  25% { left: 45%; top: 40%; }
  50% { left: 55%; top: 50%; }
  75% { left: 40%; top: 45%; }
  100% { left: 30%; top: 35%; }
}

@keyframes tiny-peon-path-2 {
  0% { left: 60%; top: 30%; }
  25% { left: 70%; top: 45%; }
  50% { left: 65%; top: 60%; }
  75% { left: 55%; top: 40%; }
  100% { left: 60%; top: 30%; }
}

@keyframes tiny-peon-path-3 {
  0% { left: 35%; top: 55%; }
  25% { left: 45%; top: 65%; }
  50% { left: 55%; top: 70%; }
  75% { left: 40%; top: 60%; }
  100% { left: 35%; top: 55%; }
}

@keyframes tiny-peon-path-4 {
  0% { left: 50%; top: 40%; }
  25% { left: 65%; top: 35%; }
  50% { left: 70%; top: 50%; }
  75% { left: 55%; top: 55%; }
  100% { left: 50%; top: 40%; }
}

@keyframes tiny-peon-path-5 {
  0% { left: 28%; top: 45%; }
  25% { left: 35%; top: 55%; }
  50% { left: 30%; top: 65%; }
  75% { left: 25%; top: 50%; }
  100% { left: 28%; top: 45%; }
}

@keyframes tiny-peon-path-6 {
  0% { left: 68%; top: 55%; }
  25% { left: 72%; top: 65%; }
  50% { left: 65%; top: 70%; }
  75% { left: 60%; top: 60%; }
  100% { left: 68%; top: 55%; }
}

@keyframes tiny-peon-path-7 {
  0% { left: 45%; top: 28%; }
  25% { left: 55%; top: 35%; }
  50% { left: 50%; top: 45%; }
  75% { left: 42%; top: 35%; }
  100% { left: 45%; top: 28%; }
}

@keyframes tiny-peon-path-8 {
  0% { left: 40%; top: 70%; }
  25% { left: 50%; top: 75%; }
  50% { left: 60%; top: 70%; }
  75% { left: 50%; top: 65%; }
  100% { left: 40%; top: 70%; }
}

@keyframes tiny-peon-path-9 {
  0% { left: 32%; top: 38%; }
  25% { left: 42%; top: 48%; }
  50% { left: 38%; top: 58%; }
  75% { left: 30%; top: 48%; }
  100% { left: 32%; top: 38%; }
}

@keyframes tiny-peon-path-10 {
  0% { left: 62%; top: 42%; }
  25% { left: 70%; top: 52%; }
  50% { left: 68%; top: 62%; }
  75% { left: 58%; top: 52%; }
  100% { left: 62%; top: 42%; }
}

@keyframes tiny-peon-path-11 {
  0% { left: 48%; top: 50%; }
  25% { left: 52%; top: 58%; }
  50% { left: 48%; top: 65%; }
  75% { left: 45%; top: 55%; }
  100% { left: 48%; top: 50%; }
}

@keyframes tiny-peon-path-12 {
  0% { left: 55%; top: 32%; }
  25% { left: 62%; top: 40%; }
  50% { left: 58%; top: 48%; }
  75% { left: 52%; top: 38%; }
  100% { left: 55%; top: 32%; }
}

@keyframes tiny-peon-path-13 {
  0% { left: 38%; top: 62%; }
  25% { left: 48%; top: 68%; }
  50% { left: 55%; top: 62%; }
  75% { left: 45%; top: 58%; }
  100% { left: 38%; top: 62%; }
}

@keyframes tiny-peon-path-14 {
  0% { left: 65%; top: 38%; }
  25% { left: 72%; top: 48%; }
  50% { left: 68%; top: 55%; }
  75% { left: 62%; top: 45%; }
  100% { left: 65%; top: 38%; }
}

@keyframes tiny-peon-path-15 {
  0% { left: 30%; top: 50%; }
  25% { left: 38%; top: 58%; }
  50% { left: 35%; top: 68%; }
  75% { left: 28%; top: 58%; }
  100% { left: 30%; top: 50%; }
}

@keyframes tiny-peon-path-16 {
  0% { left: 58%; top: 55%; }
  25% { left: 65%; top: 62%; }
  50% { left: 60%; top: 72%; }
  75% { left: 52%; top: 62%; }
  100% { left: 58%; top: 55%; }
}

@keyframes tiny-peon-path-17 {
  0% { left: 42%; top: 35%; }
  25% { left: 50%; top: 42%; }
  50% { left: 48%; top: 52%; }
  75% { left: 40%; top: 42%; }
  100% { left: 42%; top: 35%; }
}

@keyframes tiny-peon-path-18 {
  0% { left: 52%; top: 68%; }
  25% { left: 58%; top: 72%; }
  50% { left: 55%; top: 65%; }
  75% { left: 48%; top: 70%; }
  100% { left: 52%; top: 68%; }
}

@keyframes tiny-peon-path-19 {
  0% { left: 35%; top: 42%; }
  25% { left: 45%; top: 50%; }
  50% { left: 42%; top: 58%; }
  75% { left: 32%; top: 50%; }
  100% { left: 35%; top: 42%; }
}

@keyframes tiny-peon-path-20 {
  0% { left: 68%; top: 48%; }
  25% { left: 72%; top: 58%; }
  50% { left: 65%; top: 65%; }
  75% { left: 60%; top: 55%; }
  100% { left: 68%; top: 48%; }
}

@keyframes tiny-peon-path-21 {
  0% { left: 33%; top: 42%; }
  25% { left: 40%; top: 52%; }
  50% { left: 35%; top: 62%; }
  75% { left: 28%; top: 52%; }
  100% { left: 33%; top: 42%; }
}

@keyframes tiny-peon-path-22 {
  0% { left: 58%; top: 38%; }
  25% { left: 65%; top: 48%; }
  50% { left: 60%; top: 58%; }
  75% { left: 52%; top: 48%; }
  100% { left: 58%; top: 38%; }
}

@keyframes tiny-peon-path-23 {
  0% { left: 42%; top: 55%; }
  25% { left: 52%; top: 62%; }
  50% { left: 48%; top: 72%; }
  75% { left: 38%; top: 65%; }
  100% { left: 42%; top: 55%; }
}

@keyframes tiny-peon-path-24 {
  0% { left: 70%; top: 35%; }
  25% { left: 72%; top: 45%; }
  50% { left: 68%; top: 55%; }
  75% { left: 65%; top: 42%; }
  100% { left: 70%; top: 35%; }
}

@keyframes tiny-peon-path-25 {
  0% { left: 26%; top: 55%; }
  25% { left: 32%; top: 65%; }
  50% { left: 28%; top: 72%; }
  75% { left: 25%; top: 62%; }
  100% { left: 26%; top: 55%; }
}

@keyframes tiny-peon-path-26 {
  0% { left: 52%; top: 28%; }
  25% { left: 58%; top: 38%; }
  50% { left: 55%; top: 48%; }
  75% { left: 48%; top: 35%; }
  100% { left: 52%; top: 28%; }
}

@keyframes tiny-peon-path-27 {
  0% { left: 38%; top: 68%; }
  25% { left: 48%; top: 72%; }
  50% { left: 55%; top: 68%; }
  75% { left: 45%; top: 65%; }
  100% { left: 38%; top: 68%; }
}

@keyframes tiny-peon-path-28 {
  0% { left: 65%; top: 62%; }
  25% { left: 70%; top: 70%; }
  50% { left: 62%; top: 75%; }
  75% { left: 58%; top: 68%; }
  100% { left: 65%; top: 62%; }
}

@keyframes tiny-peon-path-29 {
  0% { left: 30%; top: 32%; }
  25% { left: 38%; top: 42%; }
  50% { left: 35%; top: 52%; }
  75% { left: 28%; top: 42%; }
  100% { left: 30%; top: 32%; }
}

@keyframes tiny-peon-path-30 {
  0% { left: 72%; top: 42%; }
  25% { left: 74%; top: 52%; }
  50% { left: 70%; top: 62%; }
  75% { left: 68%; top: 50%; }
  100% { left: 72%; top: 42%; }
}

@keyframes tiny-peon-path-31 {
  0% { left: 46%; top: 35%; }
  25% { left: 54%; top: 42%; }
  50% { left: 50%; top: 52%; }
  75% { left: 44%; top: 45%; }
  100% { left: 46%; top: 35%; }
}

@keyframes tiny-peon-path-32 {
  0% { left: 35%; top: 62%; }
  25% { left: 42%; top: 70%; }
  50% { left: 38%; top: 75%; }
  75% { left: 32%; top: 68%; }
  100% { left: 35%; top: 62%; }
}

@keyframes tiny-peon-path-33 {
  0% { left: 62%; top: 32%; }
  25% { left: 68%; top: 40%; }
  50% { left: 65%; top: 50%; }
  75% { left: 58%; top: 38%; }
  100% { left: 62%; top: 32%; }
}

@keyframes tiny-peon-path-34 {
  0% { left: 28%; top: 48%; }
  25% { left: 35%; top: 58%; }
  50% { left: 30%; top: 68%; }
  75% { left: 26%; top: 55%; }
  100% { left: 28%; top: 48%; }
}

@keyframes tiny-peon-path-35 {
  0% { left: 55%; top: 58%; }
  25% { left: 62%; top: 65%; }
  50% { left: 58%; top: 72%; }
  75% { left: 52%; top: 62%; }
  100% { left: 55%; top: 58%; }
}

@keyframes tiny-peon-path-36 {
  0% { left: 40%; top: 32%; }
  25% { left: 48%; top: 40%; }
  50% { left: 45%; top: 50%; }
  75% { left: 38%; top: 42%; }
  100% { left: 40%; top: 32%; }
}

@keyframes tiny-peon-path-37 {
  0% { left: 68%; top: 58%; }
  25% { left: 72%; top: 68%; }
  50% { left: 65%; top: 72%; }
  75% { left: 62%; top: 62%; }
  100% { left: 68%; top: 58%; }
}

@keyframes tiny-peon-path-38 {
  0% { left: 32%; top: 55%; }
  25% { left: 40%; top: 62%; }
  50% { left: 36%; top: 70%; }
  75% { left: 30%; top: 60%; }
  100% { left: 32%; top: 55%; }
}

@keyframes tiny-peon-path-39 {
  0% { left: 58%; top: 45%; }
  25% { left: 65%; top: 55%; }
  50% { left: 60%; top: 65%; }
  75% { left: 52%; top: 52%; }
  100% { left: 58%; top: 45%; }
}

@keyframes tiny-peon-path-40 {
  0% { left: 45%; top: 65%; }
  25% { left: 52%; top: 72%; }
  50% { left: 48%; top: 78%; }
  75% { left: 42%; top: 70%; }
  100% { left: 45%; top: 65%; }
}

@keyframes tiny-peon-path-41 {
  0% { left: 70%; top: 48%; }
  25% { left: 74%; top: 58%; }
  50% { left: 68%; top: 65%; }
  75% { left: 65%; top: 55%; }
  100% { left: 70%; top: 48%; }
}

@keyframes tiny-peon-path-42 {
  0% { left: 27%; top: 42%; }
  25% { left: 34%; top: 52%; }
  50% { left: 30%; top: 60%; }
  75% { left: 26%; top: 50%; }
  100% { left: 27%; top: 42%; }
}

@keyframes tiny-peon-path-43 {
  0% { left: 50%; top: 32%; }
  25% { left: 58%; top: 42%; }
  50% { left: 52%; top: 52%; }
  75% { left: 46%; top: 40%; }
  100% { left: 50%; top: 32%; }
}

@keyframes tiny-peon-path-44 {
  0% { left: 38%; top: 48%; }
  25% { left: 45%; top: 58%; }
  50% { left: 40%; top: 68%; }
  75% { left: 35%; top: 55%; }
  100% { left: 38%; top: 48%; }
}

@keyframes tiny-peon-path-45 {
  0% { left: 64%; top: 38%; }
  25% { left: 70%; top: 48%; }
  50% { left: 66%; top: 58%; }
  75% { left: 60%; top: 45%; }
  100% { left: 64%; top: 38%; }
}

@keyframes tiny-peon-path-46 {
  0% { left: 30%; top: 65%; }
  25% { left: 38%; top: 72%; }
  50% { left: 34%; top: 78%; }
  75% { left: 28%; top: 70%; }
  100% { left: 30%; top: 65%; }
}

@keyframes tiny-peon-path-47 {
  0% { left: 56%; top: 52%; }
  25% { left: 62%; top: 60%; }
  50% { left: 58%; top: 68%; }
  75% { left: 52%; top: 58%; }
  100% { left: 56%; top: 52%; }
}

@keyframes tiny-peon-path-48 {
  0% { left: 42%; top: 42%; }
  25% { left: 50%; top: 50%; }
  50% { left: 46%; top: 60%; }
  75% { left: 40%; top: 50%; }
  100% { left: 42%; top: 42%; }
}

@keyframes tiny-peon-path-49 {
  0% { left: 66%; top: 52%; }
  25% { left: 72%; top: 62%; }
  50% { left: 68%; top: 70%; }
  75% { left: 62%; top: 60%; }
  100% { left: 66%; top: 52%; }
}

@keyframes tiny-peon-path-50 {
  0% { left: 34%; top: 38%; }
  25% { left: 42%; top: 48%; }
  50% { left: 38%; top: 58%; }
  75% { left: 32%; top: 45%; }
  100% { left: 34%; top: 38%; }
}

/* Boat */
.kingdom-boat {
  position: relative;
  font-size: 1.5rem;
  filter: drop-shadow(2px 2px 3px rgba(0, 0, 0, 0.5));
}

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

@keyframes boat-sink {
  0% { transform: translateY(0) rotate(0deg); opacity: 1; }
  30% { transform: translateY(5px) rotate(15deg); opacity: 1; }
  60% { transform: translateY(15px) rotate(-10deg); opacity: 0.7; }
  100% { transform: translateY(40px) rotate(30deg); opacity: 0; }
}

.kingdom-boat.sinking {
  animation: boat-sink 1.5s ease-in forwards !important;
}

/* Fish */
.kingdom-fish {
  position: relative;
  font-size: 1.2rem;
  filter: drop-shadow(1px 1px 2px rgba(0, 0, 0, 0.5));
  animation: fish-swim 2s ease-in-out infinite;
}

@keyframes fish-swim {
  0%, 100% { transform: translateX(0) scaleX(1); }
  25% { transform: translateX(5px) scaleX(1); }
  50% { transform: translateX(0) scaleX(-1); }
  75% { transform: translateX(-5px) scaleX(-1); }
}

@keyframes fish-fade {
  0% { opacity: 1; transform: scale(1); }
  100% { opacity: 0; transform: scale(0.5) translateY(10px); }
}

/* Wave crests */
.kingdom-wave {
  position: absolute;
  width: 20px;
  height: 6px;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.6), transparent);
  border-radius: 50%;
  pointer-events: none;
  animation: wave-crest 3s ease-in-out forwards;
}

@keyframes wave-crest {
  0% { opacity: 0; transform: scale(0.5); }
  20% { opacity: 0.8; transform: scale(1); }
  80% { opacity: 0.6; transform: scale(1.2) translateX(10px); }
  100% { opacity: 0; transform: scale(0.8) translateX(15px); }
}

/* Scrollbar Styling */
::-webkit-scrollbar {
  width: 10px;
}

::-webkit-scrollbar-track {
  background: #1a1508;
}

::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, #b8960c 0%, #8b7209 100%);
  border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, #d4a50d 0%, #a6890b 100%);
}

/* ============================================
   MOBILE RESPONSIVE
   ============================================ */
@media (max-width: 900px) {
  #game-main {
    flex-direction: column;
  }

  #chest-section {
    flex: 1;
    min-height: 0;
  }

  #chest-container {
    max-width: 600px;
  }

  #panel-section {
    flex: 1;
    max-width: 100%;
    min-height: 0;
  }
}

/* iPad and tablet - chest half size */
@media (min-width: 601px) and (max-width: 1024px) {
  #chest-container {
    max-width: 300px;
    max-height: 300px;
  }

  #chest-section {
    display: flex;
    align-items: center;
    justify-content: center;
  }
}

@media (max-width: 600px) {
  #game-container {
    padding: 0.25rem;
  }

  #game-header {
    padding: 0;
  }

  #game-main {
    padding: 0;
    margin: 0;
    gap: 0;
  }

  .header-top-bar {
    flex-direction: column;
    gap: 0.5rem;
  }

  #film_quote_panel {
    order: -1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    padding: 4px 8px;
    margin: 0 0.2rem;
  }

  #film_quote_panel .quote-text {
    font-size: 0.68rem;
  }

  #film_quote_panel .quote-source {
    font-size: 0.58rem;
  }

  .social-links {
    justify-content: center;
  }

  .header-content {
    flex-direction: column;
    gap: 0.5rem;
    margin: 0;
  }

  .header-logo {
    height: 40px;
  }

  #main-nav {
    justify-content: center;
    gap: 0.25rem;
  }

  .tab-btn {
    padding: 0.1rem 0.15rem;
    font-size: 0.98rem;
  }

  #chest-section {
    padding: 0.5rem;
    min-height: 45vh;
    flex: 1;
  }

  .peon {
    transform: scale(0.6);
  }

  #chest-container {
    max-width: 150px;
  }

  #stats-display {
    padding: 0.25rem;
    gap: 0.25rem;
  }

  .stat-item {
    padding: 0.3rem 0.5rem;
  }

  .stat-item.main-stat {
    padding: 0.3rem 0.6rem;
  }

  .stat-item.main-stat .stat-value {
    font-size: 1.17rem;
  }

  .stat-label {
    font-size: 0.53rem;
  }

  .stat-value {
    font-size: 0.83rem;
  }

  .stat-row {
    gap: 0.25rem;
  }

  .building-item {
    padding: 0.5rem;
  }

  .building-icon {
    font-size: 1.5rem;
    width: 40px;
  }

  .building-description {
    display: none;
  }

  .achievements-grid {
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
  }
}

/* Weather effects */
#weather-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1500;
  overflow: hidden;
}

#weather-container.hidden {
  display: none;
}

/* Rain */
#weather-container.rain {
  background: linear-gradient(180deg, rgba(50, 50, 70, 0.3) 0%, rgba(30, 30, 50, 0.2) 100%);
}

/* Storm effects */
body.storm-active {
  background-color: #0a0508;
}

body.storm-active #weather-container.rain {
  background: linear-gradient(180deg, rgba(20, 20, 40, 0.6) 0%, rgba(10, 10, 25, 0.5) 100%);
}

body.lightning-flash {
  animation: lightning-flash-anim 0.1s ease-out;
}

body.lightning-flash::after {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.7);
  pointer-events: none;
  z-index: 9999;
}

@keyframes lightning-flash-anim {
  0% { filter: brightness(2); }
  100% { filter: brightness(1); }
}

.raindrop {
  position: absolute;
  top: -20px;
  width: 2px;
  height: 15px;
  background: linear-gradient(180deg, transparent, rgba(174, 194, 224, 0.8));
  animation: rain-fall linear infinite;
}

@keyframes rain-fall {
  0% {
    transform: translateY(0);
  }
  100% {
    transform: translateY(100vh);
  }
}

/* Snow */
#weather-container.snow {
  background: linear-gradient(180deg, rgba(200, 220, 255, 0.15) 0%, rgba(150, 180, 220, 0.1) 100%);
}

.snowflake {
  position: absolute;
  top: -20px;
  color: #fff;
  text-shadow: 0 0 5px rgba(255, 255, 255, 0.8);
  animation: snow-fall linear infinite;
}

@keyframes snow-fall {
  0% {
    transform: translateY(0) rotate(0deg) translateX(0);
  }
  25% {
    transform: translateY(25vh) rotate(90deg) translateX(10px);
  }
  50% {
    transform: translateY(50vh) rotate(180deg) translateX(-10px);
  }
  75% {
    transform: translateY(75vh) rotate(270deg) translateX(10px);
  }
  100% {
    transform: translateY(100vh) rotate(360deg) translateX(0);
  }
}

/* Witch styles */
.witch {
  position: fixed;
  font-size: 4rem;
  cursor: pointer;
  z-index: 6000;
  filter: drop-shadow(0 4px 8px rgba(128, 0, 255, 0.5));
  transition: filter 0.2s ease;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.witch:hover {
  filter: drop-shadow(0 4px 15px rgba(255, 215, 0, 0.8)) brightness(1.3);
  transform: scale(1.1);
}

.witch.from-right {
  transform: scaleX(-1);
}

.witch.from-right:hover {
  transform: scaleX(-1) scale(1.1);
}

/* Witch rainbow star trail */
.witch-trail-star {
  position: fixed;
  font-size: 1.2rem;
  pointer-events: none;
  z-index: 5999;
  animation: witch-star-fade 2s ease-out forwards;
}

@keyframes witch-star-fade {
  0% {
    opacity: 1;
    transform: scale(1) rotate(0deg);
  }
  50% {
    opacity: 0.8;
    transform: scale(1.2) rotate(180deg);
  }
  100% {
    opacity: 0;
    transform: scale(0.3) rotate(360deg) translateY(30px);
  }
}

/* Witch bonus timer above chest */
#witch-bonus-timer {
  position: absolute;
  top: -60px;
  left: 50%;
  transform: translateX(-50%);
  background: linear-gradient(180deg, rgba(128, 0, 255, 0.9), rgba(75, 0, 130, 0.9));
  border: 2px solid #ffd700;
  border-radius: 8px;
  padding: 8px 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 1rem;
  color: #fff;
  box-shadow: 0 0 20px rgba(128, 0, 255, 0.6), 0 0 40px rgba(255, 215, 0, 0.3);
  animation: witch-bonus-pulse 0.5s ease-in-out infinite alternate;
  z-index: 100;
}

#witch-bonus-timer.hidden {
  display: none;
}

#witch-bonus-timer .bonus-icon {
  font-size: 1.5rem;
}

#witch-bonus-timer .bonus-text {
  font-weight: bold;
  color: #ffd700;
}

#witch-bonus-timer #witch-timer-value {
  font-weight: bold;
  min-width: 30px;
  text-align: center;
}

@keyframes witch-bonus-pulse {
  0% {
    box-shadow: 0 0 20px rgba(128, 0, 255, 0.6), 0 0 40px rgba(255, 215, 0, 0.3);
  }
  100% {
    box-shadow: 0 0 30px rgba(128, 0, 255, 0.8), 0 0 60px rgba(255, 215, 0, 0.5);
  }
}

/* Chest witch bonus effect */
#chest.witch-bonus {
  animation: chest-witch-glow 0.3s ease-in-out infinite alternate;
}

@keyframes chest-witch-glow {
  0% {
    filter: drop-shadow(0 0 10px rgba(128, 0, 255, 0.8));
  }
  100% {
    filter: drop-shadow(0 0 25px rgba(255, 215, 0, 0.9));
  }
}

/* Wizard styles */
.wizard {
  position: fixed;
  font-size: 4rem;
  cursor: pointer;
  z-index: 6000;
  filter: drop-shadow(0 4px 8px rgba(0, 100, 255, 0.5));
  transition: filter 0.2s ease;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.wizard:hover {
  filter: drop-shadow(0 4px 15px rgba(100, 200, 255, 0.8)) brightness(1.3);
  transform: scale(1.1);
}

.wizard.from-right {
  transform: scaleX(-1);
}

.wizard.from-right:hover {
  transform: scaleX(-1) scale(1.1);
}

/* Wizard rainbow star trail */
.wizard-trail-star {
  position: fixed;
  font-size: 1.2rem;
  pointer-events: none;
  z-index: 5999;
  animation: wizard-star-fade 2s ease-out forwards;
}

@keyframes wizard-star-fade {
  0% {
    opacity: 1;
    transform: scale(1) rotate(0deg);
  }
  50% {
    opacity: 0.8;
    transform: scale(1.2) rotate(180deg);
  }
  100% {
    opacity: 0;
    transform: scale(0.3) rotate(360deg) translateY(30px);
  }
}

/* Wizard bonus timer above chest */
#wizard-bonus-timer {
  position: absolute;
  top: -60px;
  left: 50%;
  transform: translateX(-50%);
  background: linear-gradient(180deg, rgba(0, 100, 255, 0.9), rgba(0, 50, 130, 0.9));
  border: 2px solid #88ccff;
  border-radius: 8px;
  padding: 8px 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 1rem;
  color: #fff;
  box-shadow: 0 0 20px rgba(0, 100, 255, 0.6), 0 0 40px rgba(100, 200, 255, 0.3);
  animation: wizard-bonus-pulse 0.5s ease-in-out infinite alternate;
  z-index: 100;
}

#wizard-bonus-timer.hidden {
  display: none;
}

#wizard-bonus-timer .bonus-icon {
  font-size: 1.5rem;
}

#wizard-bonus-timer .bonus-text {
  font-weight: bold;
  color: #88ccff;
}

#wizard-bonus-timer #wizard-timer-value {
  font-weight: bold;
  min-width: 30px;
  text-align: center;
}

@keyframes wizard-bonus-pulse {
  0% {
    box-shadow: 0 0 20px rgba(0, 100, 255, 0.6), 0 0 40px rgba(100, 200, 255, 0.3);
  }
  100% {
    box-shadow: 0 0 30px rgba(0, 100, 255, 0.8), 0 0 60px rgba(100, 200, 255, 0.5);
  }
}

/* Chest wizard bonus effect */
#chest.wizard-bonus {
  animation: chest-wizard-glow 0.3s ease-in-out infinite alternate;
}

@keyframes chest-wizard-glow {
  0% {
    filter: drop-shadow(0 0 10px rgba(0, 100, 255, 0.8));
  }
  100% {
    filter: drop-shadow(0 0 25px rgba(100, 200, 255, 0.9));
  }
}

/* Ghost styles */
.ghost {
  position: fixed;
  font-size: 4rem;
  cursor: pointer;
  z-index: 6000;
  filter: drop-shadow(0 4px 8px rgba(200, 200, 220, 0.5));
  transition: filter 0.2s ease;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.ghost:hover {
  filter: drop-shadow(0 4px 15px rgba(255, 255, 255, 0.8)) brightness(1.3);
  transform: scale(1.1);
}

.ghost.from-right {
  transform: scaleX(-1);
}

.ghost.from-right:hover {
  transform: scaleX(-1) scale(1.1);
}

/* Ghost star trail */
.ghost-trail-star {
  position: fixed;
  font-size: 1.2rem;
  pointer-events: none;
  z-index: 5999;
  animation: ghost-star-fade 2s ease-out forwards;
}

@keyframes ghost-star-fade {
  0% {
    opacity: 1;
    transform: scale(1) rotate(0deg);
  }
  50% {
    opacity: 0.8;
    transform: scale(1.2) rotate(180deg);
  }
  100% {
    opacity: 0;
    transform: scale(0.3) rotate(360deg) translateY(30px);
  }
}

/* Ghost bonus timer above chest */
#ghost-bonus-timer {
  position: absolute;
  top: -60px;
  left: 50%;
  transform: translateX(-50%);
  background: linear-gradient(180deg, rgba(200, 200, 220, 0.9), rgba(100, 100, 130, 0.9));
  border: 2px solid #ffffff;
  border-radius: 8px;
  padding: 8px 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 1rem;
  color: #fff;
  box-shadow: 0 0 20px rgba(200, 200, 220, 0.6), 0 0 40px rgba(255, 255, 255, 0.3);
  animation: ghost-bonus-pulse 0.5s ease-in-out infinite alternate;
  z-index: 100;
}

#ghost-bonus-timer.hidden {
  display: none;
}

#ghost-bonus-timer .bonus-icon {
  font-size: 1.5rem;
}

#ghost-bonus-timer .bonus-text {
  font-weight: bold;
  color: #ffffff;
}

#ghost-bonus-timer #ghost-timer-value {
  font-weight: bold;
  min-width: 30px;
  text-align: center;
}

@keyframes ghost-bonus-pulse {
  0% {
    box-shadow: 0 0 20px rgba(200, 200, 220, 0.6), 0 0 40px rgba(255, 255, 255, 0.3);
  }
  100% {
    box-shadow: 0 0 30px rgba(200, 200, 220, 0.8), 0 0 60px rgba(255, 255, 255, 0.5);
  }
}

/* Chest ghost bonus effect */
#chest.ghost-bonus {
  animation: chest-ghost-glow 0.3s ease-in-out infinite alternate;
}

@keyframes chest-ghost-glow {
  0% {
    filter: drop-shadow(0 0 10px rgba(200, 200, 220, 0.8));
  }
  100% {
    filter: drop-shadow(0 0 25px rgba(255, 255, 255, 0.9));
  }
}

/* UFO / Flying Saucer */
.ufo {
  position: fixed;
  font-size: 3rem;
  z-index: 9999;
  cursor: pointer;
  filter: drop-shadow(0 0 10px rgba(0, 255, 0, 0.8));
  animation: ufo-fly 8s linear forwards, ufo-wobble 0.5s ease-in-out infinite;
  pointer-events: auto;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

@keyframes ufo-fly {
  0% {
    left: -100px;
    top: 20%;
  }
  25% {
    top: 40%;
  }
  50% {
    top: 15%;
  }
  75% {
    top: 35%;
  }
  100% {
    left: calc(100% + 100px);
    top: 25%;
  }
}

@keyframes ufo-wobble {
  0%, 100% {
    transform: rotate(-5deg);
  }
  50% {
    transform: rotate(5deg);
  }
}

.ufo:hover {
  filter: drop-shadow(0 0 20px rgba(0, 255, 0, 1)) drop-shadow(0 0 40px rgba(255, 255, 0, 0.8));
}

.ufo.clicked {
  animation: ufo-explode 0.5s ease-out forwards;
}

@keyframes ufo-explode {
  0% {
    transform: scale(1);
    opacity: 1;
  }
  50% {
    transform: scale(1.5);
    opacity: 0.8;
  }
  100% {
    transform: scale(0);
    opacity: 0;
  }
}

/* Ale Fest / Beer Rain */
#beer-rain-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 9998;
  overflow: hidden;
  contain: layout style;
}

.falling-beer {
  position: absolute;
  top: -50px;
  font-size: 2.5rem;
  animation: beer-fall linear forwards, beer-sway ease-in-out infinite;
  filter: drop-shadow(0 0 5px rgba(255, 200, 0, 0.5));
  pointer-events: auto;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  padding: 10px;
  margin: -10px;
}

/* Rainbow star trail behind falling beers */
.falling-beer::before,
.falling-beer::after {
  content: '⭐';
  position: absolute;
  font-size: 1rem;
  opacity: 0;
  animation: star-trail 0.8s ease-out infinite;
  pointer-events: none;
}

.falling-beer::before {
  top: -15px;
  left: 5px;
  animation-delay: 0s;
  filter: hue-rotate(0deg) drop-shadow(0 0 3px red);
}

.falling-beer::after {
  top: -25px;
  left: 15px;
  animation-delay: 0.2s;
  filter: hue-rotate(60deg) drop-shadow(0 0 3px yellow);
}

/* Additional star elements via box-shadow trick */
.falling-beer-stars {
  position: absolute;
  top: -10px;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

@keyframes star-trail {
  0% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
  50% {
    opacity: 0.8;
  }
  100% {
    opacity: 0;
    transform: translateY(-30px) scale(0.3);
  }
}

@keyframes rainbow-star {
  0% { filter: hue-rotate(0deg); }
  100% { filter: hue-rotate(360deg); }
}

.falling-beer:hover {
  filter: drop-shadow(0 0 10px rgba(255, 215, 0, 0.9)) brightness(1.2);
}

@keyframes beer-fall {
  0% {
    top: -50px;
  }
  100% {
    top: 110vh;
  }
}

@keyframes beer-sway {
  0%, 100% {
    transform: translateX(-20px) rotate(-10deg) translateZ(0);
  }
  50% {
    transform: translateX(20px) rotate(10deg) translateZ(0);
  }
}

/* Drunk peon wobble during Ale Fest */
.peon-drunk {
  animation: peon-wobble 0.5s ease-in-out infinite;
  transform-origin: center bottom;
}

@keyframes peon-wobble {
  0%, 100% {
    transform: rotate(-30deg);
  }
  50% {
    transform: rotate(30deg);
  }
}

/* Disco lights overlay during Ale Fest */
.disco-lights {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 9997;
  animation: disco-flash 0.3s ease-in-out infinite;
  opacity: 0.15;
}

@keyframes disco-flash {
  0% {
    background: radial-gradient(circle at 20% 30%, rgba(255, 0, 0, 0.8), transparent 50%),
                radial-gradient(circle at 80% 20%, rgba(0, 255, 0, 0.8), transparent 50%),
                radial-gradient(circle at 50% 80%, rgba(0, 0, 255, 0.8), transparent 50%);
  }
  33% {
    background: radial-gradient(circle at 70% 60%, rgba(255, 255, 0, 0.8), transparent 50%),
                radial-gradient(circle at 30% 80%, rgba(255, 0, 255, 0.8), transparent 50%),
                radial-gradient(circle at 60% 20%, rgba(0, 255, 255, 0.8), transparent 50%);
  }
  66% {
    background: radial-gradient(circle at 40% 40%, rgba(255, 128, 0, 0.8), transparent 50%),
                radial-gradient(circle at 80% 70%, rgba(128, 0, 255, 0.8), transparent 50%),
                radial-gradient(circle at 20% 60%, rgba(0, 255, 128, 0.8), transparent 50%);
  }
  100% {
    background: radial-gradient(circle at 20% 30%, rgba(255, 0, 0, 0.8), transparent 50%),
                radial-gradient(circle at 80% 20%, rgba(0, 255, 0, 0.8), transparent 50%),
                radial-gradient(circle at 50% 80%, rgba(0, 0, 255, 0.8), transparent 50%);
  }
}

/* Sleeping peon effect */
.peon-sleeping {
  filter: grayscale(50%) brightness(0.7);
  animation: peon-snooze 1s ease-in-out infinite;
}

@keyframes peon-snooze {
  0%, 100% {
    transform: rotate(-5deg);
  }
  50% {
    transform: rotate(5deg);
  }
}

/* Passed out peons after Ale Fest - upside down */
.peon-passed-out {
  filter: grayscale(50%) brightness(0.7);
  transform: rotate(180deg);
  transition: transform 0.3s ease;
  }
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
  :root {
    --color-text: #ffffff;
    --color-text-dim: #cccccc;
    --border-medieval: 3px solid #888888;
  }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Focus Styles for Accessibility */
:focus {
  outline: 2px solid var(--color-gold);
  outline-offset: 2px;
}

:focus:not(:focus-visible) {
  outline: none;
}

:focus-visible {
  outline: 2px solid var(--color-gold);
  outline-offset: 2px;
}

/* Earthquake screen shake */
.earthquake-shake {
  animation: earthquake-shake 0.1s ease-in-out infinite;
}

@keyframes earthquake-shake {
  0%, 100% {
    transform: translateX(0) translateY(0);
  }
  25% {
    transform: translateX(-5px) translateY(3px);
  }
  50% {
    transform: translateX(5px) translateY(-3px);
  }
  75% {
    transform: translateX(-3px) translateY(5px);
  }
}

/* Drought effects */
.drought-active {
  background: linear-gradient(180deg, #2a1a00 0%, #1a1000 50%, #0a0500 100%) !important;
}

.drought-tint {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(180deg, rgba(255, 200, 100, 0.15) 0%, rgba(200, 150, 50, 0.1) 100%);
  pointer-events: none;
  z-index: 5;
}

/* Drought sun */
.drought-sun {
  position: absolute;
  width: 300px;
  height: 300px;
  background: radial-gradient(circle, #ffff00 0%, #ffcc00 40%, #ff9900 70%, transparent 100%);
  border-radius: 50%;
  box-shadow: 0 0 200px 100px rgba(255, 200, 0, 0.5),
              0 0 400px 200px rgba(255, 150, 0, 0.3);
  z-index: 10;
  pointer-events: auto;
  cursor: pointer;
  animation: sun-arc 20s linear forwards;
  transition: transform 0.1s ease;
}

.drought-sun:hover {
  transform: scale(1.3);
  box-shadow: 0 0 250px 125px rgba(255, 200, 0, 0.7),
              0 0 500px 250px rgba(255, 150, 0, 0.5);
}

@keyframes sun-arc {
  0% {
    left: -300px;
    top: 85%;
    transform: scale(0.7);
    opacity: 0.3;
  }
  5% {
    opacity: 1;
  }
  15% {
    left: 5%;
    top: 45%;
    transform: scale(0.9);
  }
  30% {
    left: 20%;
    top: 20%;
    transform: scale(1.0);
  }
  50% {
    left: calc(50% - 150px);
    top: 5%;
    transform: scale(1.2);
  }
  70% {
    left: 65%;
    top: 20%;
    transform: scale(1.0);
  }
  85% {
    left: 80%;
    top: 45%;
    transform: scale(0.9);
  }
  95% {
    opacity: 1;
  }
  100% {
    left: calc(100% + 300px);
    top: 85%;
    transform: scale(0.7);
    opacity: 0.3;
  }
}

/* Sandstorm effect */
.sandstorm {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 6;
  overflow: hidden;
}

.sand-particle {
  position: absolute;
  width: 3px;
  height: 3px;
  background: rgba(210, 180, 140, 0.6);
  border-radius: 50%;
  animation: sand-blow 2s linear infinite;
}

@keyframes sand-blow {
  0% {
    transform: translateX(-100px) translateY(0);
    opacity: 0;
  }
  10% {
    opacity: 1;
  }
  90% {
    opacity: 1;
  }
  100% {
    transform: translateX(calc(100vw + 100px)) translateY(50px);
    opacity: 0;
  }
}

/* Tornado effects */
.tornado-container {
  position: absolute;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 15;
  overflow: hidden;
}

.tornado-funnel {
  position: absolute;
  width: 120px;
  height: 200px;
  pointer-events: none;
  transform-origin: center bottom;
}

.tornado-emoji {
  position: absolute;
  font-size: 28px;
  animation: tornado-spin 0.8s linear infinite;
  text-shadow: 0 0 10px rgba(100, 100, 100, 0.5);
}

@keyframes tornado-spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

@keyframes tornado-path-bl-tr {
  0% {
    left: -150px;
    top: calc(100% - 50px);
  }
  100% {
    left: calc(100% + 50px);
    top: -150px;
  }
}

@keyframes tornado-path-br-tl {
  0% {
    left: calc(100% + 50px);
    top: calc(100% - 50px);
  }
  100% {
    left: -150px;
    top: -150px;
  }
}

@keyframes tornado-path-tl-br {
  0% {
    left: -150px;
    top: -50px;
  }
  100% {
    left: calc(100% + 50px);
    top: calc(100% + 50px);
  }
}

@keyframes tornado-path-tr-bl {
  0% {
    left: calc(100% + 50px);
    top: -50px;
  }
  100% {
    left: -150px;
    top: calc(100% + 50px);
  }
}

.tornado-tint {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(180deg, rgba(80, 80, 80, 0.2) 0%, rgba(60, 70, 60, 0.15) 100%);
  pointer-events: none;
  z-index: 5;
}

/* Peon thrown animation */
.peon-thrown {
  transition: none !important;
  animation: peon-tumble 0.5s ease-out;
}

@keyframes peon-tumble {
  0% {
    transform: rotate(0deg);
  }
  25% {
    transform: rotate(90deg);
  }
  50% {
    transform: rotate(180deg);
  }
  75% {
    transform: rotate(270deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

/* Peon sweating during drought */
.peon-sweating::after {
  content: '💧';
  position: absolute;
  top: -8px;
  right: -4px;
  font-size: 12px;
  animation: sweat-drip 1.5s ease-in-out infinite;
  z-index: 10;
}

@keyframes sweat-drip {
  0% {
    opacity: 0;
    transform: translateY(0);
  }
  20% {
    opacity: 1;
    transform: translateY(0);
  }
  80% {
    opacity: 1;
    transform: translateY(8px);
  }
  100% {
    opacity: 0;
    transform: translateY(12px);
  }
}

/* Kaiju effects */
.kaiju-container {
  position: absolute;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 20;
  overflow: hidden;
}

.kaiju {
  position: absolute;
  font-size: 50cqh;
  line-height: 1;
  pointer-events: auto;
  cursor: pointer;
  z-index: 21;
  filter: drop-shadow(0 5cqh 10cqh rgba(0, 0, 0, 0.5));
  transition: filter 0.1s ease;
}

.kaiju:hover {
  filter: drop-shadow(0 10px 30px rgba(255, 0, 0, 0.7));
}

.kaiju-left-to-right {
  animation: kaiju-walk-lr 15s linear forwards, kaiju-hop-flip 0.4s ease-in-out infinite;
  /* 🦖 emoji naturally faces left, so flip it to face right when walking right */
}

.kaiju-right-to-left {
  animation: kaiju-walk-rl 15s linear forwards, kaiju-hop 0.4s ease-in-out infinite;
  /* 🦖 emoji naturally faces left, which is correct when walking left */
}

@keyframes kaiju-walk-lr {
  0% {
    left: -55cqh;
    top: 25%;
  }
  100% {
    left: calc(100% + 10cqh);
    top: 25%;
  }
}

@keyframes kaiju-walk-rl {
  0% {
    left: calc(100% + 10cqh);
    top: 25%;
  }
  100% {
    left: -55cqh;
    top: 25%;
  }
}

@keyframes kaiju-hop {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-5cqh);
  }
}

@keyframes kaiju-hop-flip {
  0%, 100% {
    transform: scaleX(-1) translateY(0);
  }
  50% {
    transform: scaleX(-1) translateY(-5cqh);
  }
}

@keyframes kaiju-death {
  0% {
    transform: scale(1) rotate(0deg);
    opacity: 1;
  }
  50% {
    transform: scale(1.2) rotate(-20deg);
    opacity: 0.8;
  }
  100% {
    transform: scale(0) rotate(-90deg);
    opacity: 0;
  }
}

/* Peon screaming */
.peon-screaming {
  animation: peon-shake 0.1s ease-in-out infinite;
}

.peon-screaming::before {
  content: '😱';
  position: absolute;
  top: -15px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 14px;
  animation: scream-bounce 0.2s ease-in-out infinite;
}

@keyframes peon-shake {
  0%, 100% {
    transform: translateX(0);
  }
  25% {
    transform: translateX(-3px);
  }
  75% {
    transform: translateX(3px);
  }
}

@keyframes scream-bounce {
  0%, 100% {
    transform: translateX(-50%) translateY(0);
  }
  50% {
    transform: translateX(-50%) translateY(-5px);
  }
}

/* Population Panel */
.population-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid rgba(139, 115, 85, 0.3);
}

.pop-tab-btn {
  padding: 0.5rem 1rem;
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(139, 115, 85, 0.5);
  border-radius: 4px;
  color: var(--color-text-dim);
  cursor: pointer;
  transition: all var(--transition-fast);
  font-size: 0.85rem;
}

.pop-tab-btn:hover {
  background: rgba(0, 0, 0, 0.7);
  border-color: var(--color-gold);
  color: var(--color-text);
}

.pop-tab-btn.active {
  background: rgba(139, 115, 85, 0.3);
  border-color: var(--color-gold);
  color: var(--color-gold);
}

#population-list {
  display: block;
  min-height: 100px;
  padding: 0.5rem 0;
  text-align: left;
}

#population-list p.no-items {
  color: var(--color-text-dim);
  font-style: italic;
  text-align: center;
  padding: 1rem;
  background: rgba(0, 0, 0, 0.7);
  border-radius: 8px;
  margin: 1rem;
}

#population-list .population-item {
  margin-bottom: 0.5rem;
}

#population-list h3 {
  color: var(--color-gold);
  font-size: 1rem;
  margin: 0 0 0.75rem 0;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid rgba(139, 115, 85, 0.3);
}

.population-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem;
  background: rgba(0, 0, 0, 0.85);
  border: var(--border-medieval);
  border-radius: 6px;
  transition: all var(--transition-fast);
}

.population-item:hover {
  background: rgba(0, 0, 0, 0.95);
  border-color: var(--color-gold);
}

.population-item.is-favorite {
  border-color: var(--color-gold);
  box-shadow: 0 0 10px rgba(255, 215, 0, 0.3);
}

.population-item.is-dead {
  opacity: 0.7;
  border-color: #666;
  background: linear-gradient(135deg, #1a1a1a 0%, #2a2a2a 100%);
}

.population-item.is-dead .pop-name {
  color: #999;
}

.pop-sex {
  font-size: 1.2rem;
  font-weight: bold;
  width: 20px;
  text-align: center;
}

.pop-sex.male {
  color: #4a9eff;
}

.pop-sex.female {
  color: #ff69b4;
}

.pop-icon {
  font-size: 1.5rem;
  width: 40px;
  text-align: center;
}

.pop-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.pop-name-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.pop-rank {
  font-weight: bold;
  color: var(--color-gold);
  font-size: 0.85rem;
}

.pop-name {
  font-size: 0.95rem;
  color: var(--color-text);
  font-weight: 500;
}

.pop-occupation {
  font-size: 0.75rem;
  color: #a0d0ff;
  font-style: italic;
}

.pop-stats {
  font-size: 0.8rem;
  color: var(--color-text-dim);
}

.pop-favorite-btn {
  background: transparent;
  border: none;
  font-size: 1.2rem;
  cursor: pointer;
  padding: 0.25rem;
  transition: transform var(--transition-fast);
  color: var(--color-gold);
}

.pop-favorite-btn:hover {
  transform: scale(1.2);
}

.pop-share-btn {
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 0.25rem;
  transition: transform var(--transition-fast);
  color: var(--color-text-dim);
  display: flex;
  align-items: center;
  justify-content: center;
}

.pop-share-btn:hover {
  transform: scale(1.2);
  color: var(--color-gold);
}

.pop-share-btn svg {
  stroke: currentColor;
}

/* Peon Share Menu Popup */
.peon-share-menu {
  background: var(--color-bg-panel);
  border: 2px solid var(--color-gold-dark);
  border-radius: 8px;
  min-width: 150px;
  z-index: 2000;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.6);
  overflow: hidden;
}

.peon-share-option {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0.8rem;
  color: var(--color-text);
  text-decoration: none;
  font-size: 0.85rem;
  border-bottom: 1px solid var(--color-bg-light);
  transition: background var(--transition-fast);
}

.peon-share-option:last-child {
  border-bottom: none;
}

.peon-share-option:hover {
  background: var(--color-bg-light);
  color: var(--color-gold);
}

.peon-share-option svg {
  flex-shrink: 0;
}

/* Favorite peon purple aura */
.peon-favorite {
  filter: drop-shadow(0 0 8px rgba(147, 51, 234, 0.8))
          drop-shadow(0 0 15px rgba(147, 51, 234, 0.5));
  animation: peon-favorite-glow 1.5s ease-in-out infinite alternate;
}

@keyframes peon-favorite-glow {
  0% {
    filter: drop-shadow(0 0 8px rgba(147, 51, 234, 0.8))
            drop-shadow(0 0 15px rgba(147, 51, 234, 0.5));
  }
  100% {
    filter: drop-shadow(0 0 12px rgba(147, 51, 234, 1))
            drop-shadow(0 0 25px rgba(147, 51, 234, 0.7));
  }
}

/* Peon star indicator for favorites */
.peon-star {
  position: absolute;
  top: -12px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 14px;
  animation: peon-star-bounce 0.5s ease-in-out infinite;
  pointer-events: none;
  z-index: 10;
  filter: hue-rotate(270deg) saturate(2);
  text-shadow: 0 0 8px rgba(147, 51, 234, 0.9);
}

@keyframes peon-star-bounce {
  0%, 100% {
    transform: translateX(-50%) translateY(0);
  }
  50% {
    transform: translateX(-50%) translateY(-6px);
  }
}

@keyframes peon-star-float {
  0%, 100% {
    transform: translateX(-50%) translateY(0);
  }
  50% {
    transform: translateX(-50%) translateY(-3px);
  }
}

/* Secret Debug Menu */
#secret-zone {
  position: fixed;
  top: 0;
  left: 0;
  width: 0.67rem;
  height: 0.67rem;
  z-index: 9999;
  cursor: pointer;
  background: transparent;
}

#secret-menu {
  display: none;
  position: fixed;
  top: 2.5rem;
  left: 15px;
  background: linear-gradient(135deg, var(--color-bg-panel) 0%, var(--color-bg-medium) 100%);
  border: 2px solid var(--color-gold-dark);
  border-radius: 8px;
  padding: 8px 0;
  z-index: 10000;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5), 0 0 10px rgba(255, 215, 0, 0.2);
  min-width: 180px;
}

#secret-menu.visible {
  display: block;
  animation: secretMenuFadeIn 0.2s ease;
}

@keyframes secretMenuFadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

#secret-menu h4 {
  color: var(--color-gold);
  font-size: 0.75rem;
  padding: 4px 12px 8px;
  margin: 0;
  border-bottom: 1px solid var(--color-accent);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.secret-menu-item {
  display: block;
  width: 100%;
  padding: 8px 12px;
  background: none;
  border: none;
  color: var(--color-text);
  font-family: var(--font-medieval);
  font-size: 0.85rem;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.secret-menu-item:hover {
  background: rgba(255, 215, 0, 0.15);
  color: var(--color-gold);
}

.secret-menu-item:active {
  background: rgba(255, 215, 0, 0.25);
}

/* Lazy Peon Sleep Zzz Particles */
.sleep-zzz {
  position: absolute;
  font-size: 14px;
  color: #aaccff;
  text-shadow: 0 0 4px rgba(100, 150, 255, 0.8);
  pointer-events: none;
  z-index: 100;
  animation: sleepZzzFloat 2s ease-out forwards;
  font-weight: bold;
}

@keyframes sleepZzzFloat {
  0% {
    opacity: 1;
    transform: translateY(0) translateX(0) scale(0.6);
  }
  50% {
    opacity: 0.8;
    transform: translateY(-20px) translateX(10px) scale(1);
  }
  100% {
    opacity: 0;
    transform: translateY(-40px) translateX(15px) scale(1.2);
  }
}

/* Blood Effects */
.blood-splatter {
  position: absolute;
  font-size: 20px;
  pointer-events: none;
  z-index: 150;
  animation: bloodSplatter 0.5s ease-out forwards;
}

@keyframes bloodSplatter {
  0% {
    opacity: 1;
    transform: translate(0, 0) scale(0.5);
  }
  100% {
    opacity: 0;
    transform: translate(var(--end-x), var(--end-y)) scale(1.5);
  }
}

.blood-pool {
  position: absolute;
  width: 40px;
  height: 20px;
  background: radial-gradient(ellipse, #8B0000 0%, #5C0000 50%, transparent 70%);
  border-radius: 50%;
  pointer-events: none;
  z-index: 50;
  animation: bloodPool 3s ease-out forwards;
}

@keyframes bloodPool {
  0% {
    opacity: 0;
    transform: scale(0.3);
  }
  20% {
    opacity: 0.8;
    transform: scale(1);
  }
  100% {
    opacity: 0;
    transform: scale(1.2);
  }
}

/* Splash Effect for drowning peons */
.splash-effect {
  position: fixed;
  font-size: 24px;
  pointer-events: none;
  z-index: 200;
  animation: splashAnim 1s ease-out forwards;
  transform: translate(-50%, -50%);
}

@keyframes splashAnim {
  0% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(0.5);
  }
  50% {
    opacity: 1;
    transform: translate(-50%, -100%) scale(1.5);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -150%) scale(0.5);
  }
}

/* Forest Fire Effect */
.forest-fire-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 150;
  overflow: hidden;
  transition: opacity 0.5s ease;
}

/* Red/orange pulsing overlay */
.fire-pulse-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: radial-gradient(ellipse at center,
    rgba(255, 100, 0, 0.3) 0%,
    rgba(255, 50, 0, 0.2) 50%,
    rgba(200, 0, 0, 0.3) 100%);
  animation: fire-pulse 0.3s ease-in-out infinite alternate;
}

@keyframes fire-pulse {
  0% {
    background: radial-gradient(ellipse at center,
      rgba(255, 100, 0, 0.2) 0%,
      rgba(255, 50, 0, 0.15) 50%,
      rgba(200, 0, 0, 0.2) 100%);
  }
  100% {
    background: radial-gradient(ellipse at center,
      rgba(255, 150, 0, 0.4) 0%,
      rgba(255, 80, 0, 0.3) 50%,
      rgba(255, 0, 0, 0.35) 100%);
  }
}

/* Random fire icons spawning */
.random-fire-icon {
  position: absolute;
  font-size: 1.5rem;
  animation: fire-pop 0.8s ease-out forwards;
  pointer-events: none;
  filter: drop-shadow(0 0 8px rgba(255, 100, 0, 0.8));
}

@keyframes fire-pop {
  0% {
    opacity: 0;
    transform: scale(0.3) translateY(20px);
  }
  20% {
    opacity: 1;
    transform: scale(1.2) translateY(0);
  }
  100% {
    opacity: 0;
    transform: scale(0.8) translateY(-30px);
  }
}

.fire-wall {
  position: absolute;
  top: 0;
  left: -100%;
  width: 30%;
  height: 100%;
  background: linear-gradient(90deg,
    transparent 0%,
    rgba(255, 100, 0, 0.3) 20%,
    rgba(255, 50, 0, 0.6) 50%,
    rgba(255, 100, 0, 0.3) 80%,
    transparent 100%);
  animation: fire-sweep 3s ease-in-out forwards;
}

.fire-flame {
  position: absolute;
  font-size: 2rem;
  animation: flame-flicker 0.2s ease-in-out infinite alternate;
  filter: drop-shadow(0 0 10px rgba(255, 100, 0, 0.8));
}

@keyframes fire-sweep {
  0% {
    left: -30%;
  }
  100% {
    left: 100%;
  }
}

@keyframes flame-flicker {
  0% {
    transform: scale(1) rotate(-5deg);
    opacity: 0.8;
  }
  100% {
    transform: scale(1.2) rotate(5deg);
    opacity: 1;
  }
}

/* Burning peon */
.peon-burning {
  animation: peon-burn 0.5s ease-out forwards !important;
}

@keyframes peon-burn {
  0% {
    transform: scale(1);
    filter: brightness(1);
  }
  50% {
    transform: scale(1.3);
    filter: brightness(2) sepia(1) saturate(5) hue-rotate(-20deg);
  }
  100% {
    transform: scale(0);
    filter: brightness(3);
    opacity: 0;
  }
}

/* Tsunami Effect */
.tsunami-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 150;
  overflow: hidden;
  transition: opacity 0.5s ease;
}

/* Aquamarine/navy pulsing overlay */
.tsunami-pulse-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: radial-gradient(ellipse at center,
    rgba(127, 255, 212, 0.3) 0%,
    rgba(0, 128, 128, 0.25) 50%,
    rgba(0, 0, 128, 0.3) 100%);
  animation: tsunami-pulse 0.4s ease-in-out infinite alternate;
}

@keyframes tsunami-pulse {
  0% {
    background: radial-gradient(ellipse at center,
      rgba(127, 255, 212, 0.2) 0%,
      rgba(0, 128, 128, 0.15) 50%,
      rgba(0, 0, 128, 0.2) 100%);
  }
  100% {
    background: radial-gradient(ellipse at center,
      rgba(127, 255, 212, 0.4) 0%,
      rgba(0, 139, 139, 0.35) 50%,
      rgba(0, 0, 139, 0.4) 100%);
  }
}

/* Random water icons spawning */
.random-water-icon {
  position: absolute;
  font-size: 1.5rem;
  animation: water-pop 0.8s ease-out forwards;
  pointer-events: none;
  filter: drop-shadow(0 0 8px rgba(0, 191, 255, 0.8));
}

@keyframes water-pop {
  0% {
    transform: scale(0) translateY(20px);
    opacity: 0;
  }
  30% {
    transform: scale(1.2) translateY(-10px);
    opacity: 1;
  }
  100% {
    transform: scale(0.8) translateY(-30px);
    opacity: 0;
  }
}

.water-wall {
  position: absolute;
  bottom: -100%;
  left: 0;
  width: 100%;
  height: 30%;
  background: linear-gradient(0deg,
    transparent 0%,
    rgba(0, 191, 255, 0.3) 20%,
    rgba(0, 128, 128, 0.5) 50%,
    rgba(0, 191, 255, 0.3) 80%,
    transparent 100%);
  animation: tsunami-sweep 3s ease-in-out forwards;
}

.water-wave {
  position: absolute;
  font-size: 2rem;
  animation: wave-bob 0.3s ease-in-out infinite alternate;
  filter: drop-shadow(0 0 10px rgba(0, 191, 255, 0.8));
}

@keyframes tsunami-sweep {
  0% {
    bottom: -30%;
  }
  100% {
    bottom: 100%;
  }
}

@keyframes wave-bob {
  0% {
    transform: scale(1) translateY(0);
    opacity: 0.8;
  }
  100% {
    transform: scale(1.1) translateY(-5px);
    opacity: 1;
  }
}

/* Drowning peon */
.peon-drowning {
  animation: peon-drown 0.5s ease-out forwards !important;
}

@keyframes peon-drown {
  0% {
    transform: scale(1) translateY(0);
    filter: brightness(1);
  }
  50% {
    transform: scale(0.8) translateY(10px);
    filter: brightness(0.7) hue-rotate(180deg);
  }
  100% {
    transform: scale(0) translateY(20px);
    filter: brightness(0.5);
    opacity: 0;
  }
}

/* Plague / Zombie peons */
.plague-zombie {
  animation: zombie-shamble 0.5s ease-in-out infinite alternate !important;
  filter: drop-shadow(0 0 10px rgba(0, 255, 0, 1)) drop-shadow(0 0 20px rgba(0, 255, 0, 0.6)) brightness(0.85) !important;
  cursor: crosshair !important;
}

.plague-zombie.case-zero {
  filter: drop-shadow(0 0 15px rgba(0, 255, 0, 1)) drop-shadow(0 0 30px rgba(0, 255, 0, 0.8)) brightness(0.8) !important;
}

.plague-infected {
  animation: infected-pulse 0.3s ease-in-out infinite alternate !important;
  filter: drop-shadow(0 0 8px rgba(100, 255, 100, 1)) drop-shadow(0 0 16px rgba(0, 200, 0, 0.6)) !important;
  cursor: pointer !important;
}

@keyframes zombie-shamble {
  0% {
    transform: rotate(-5deg) translateX(-2px);
  }
  100% {
    transform: rotate(5deg) translateX(2px);
  }
}

@keyframes infected-pulse {
  0% {
    filter: drop-shadow(0 0 8px rgba(100, 255, 100, 1)) drop-shadow(0 0 16px rgba(0, 200, 0, 0.6));
  }
  100% {
    filter: drop-shadow(0 0 15px rgba(150, 255, 150, 1)) drop-shadow(0 0 25px rgba(0, 255, 0, 0.8));
  }
}

.peon-death {
  animation: peon-death-fade 0.5s ease-out forwards !important;
}

@keyframes peon-death-fade {
  0% {
    transform: scale(1);
    opacity: 1;
  }
  50% {
    transform: scale(1.2) rotate(180deg);
  }
  100% {
    transform: scale(0) rotate(360deg);
    opacity: 0;
  }
}

/* Mobile Performance Optimizations */
@media (max-width: 768px), (hover: none) {
  /* Disable ambient glow animation */
  .ambient-glow {
    display: none !important;
  }

  /* Simplify chest effects */
  #chest {
    filter: drop-shadow(0 5px 10px rgba(0, 0, 0, 0.5)) !important;
    animation: none !important;
  }

  #chest:hover {
    filter: drop-shadow(0 5px 10px rgba(0, 0, 0, 0.5)) brightness(1.1) !important;
  }

  .chest-glow {
    display: none !important;
  }

  /* Simplify peon effects */
  .peon {
    filter: none !important;
    transition: none !important;
  }

  .peon:hover {
    filter: none !important;
    transform: scale(1.1);
  }

  .peon-sprite {
    animation-duration: 0.6s !important;
  }

  /* Disable gold shine animation */
  #loot-display {
    animation: none !important;
  }

  /* Simplify building panel effects */
  .building-item {
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3) !important;
  }

  .building-item:hover,
  .building-item.affordable {
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3) !important;
    animation: none !important;
  }

  /* Disable upgrade shine */
  .upgrade-item.affordable {
    animation: none !important;
  }

  /* Simplify dragon effects */
  .dragon {
    filter: none !important;
    animation: none !important;
  }

  /* Simplify witch effects */
  .witch {
    filter: none !important;
    transition: none !important;
  }

  /* Disable news icon sway */
  .news-icon {
    animation: none !important;
  }

  /* Reduce weather particle count via opacity */
  .raindrop:nth-child(n+50),
  .snowflake:nth-child(n+30) {
    display: none !important;
  }

  /* Simplify falling beer - only disable filter and sway, keep fall animation */
  .falling-beer {
    filter: none !important;
    animation-name: beer-fall !important;
    animation-timing-function: linear !important;
    animation-fill-mode: forwards !important;
  }


  /* Disable twinkle effects */
  .coin-icon {
    animation: none !important;
    box-shadow: none !important;
  }

  /* Reduce starfield rendering */
  #splash-starfield,
  #kingdom-starfield {
    opacity: 0.5;
  }
}


/* Cemetery Panel Styles */
#cemetery-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  z-index: 2000;
  display: flex;
  justify-content: center;
  align-items: center;
}

#cemetery-panel {
  background: linear-gradient(180deg, #1a1a2e 0%, #16213e 50%, #0f0f23 100%);
  border: 3px solid #4a4a6a;
  border-radius: 15px;
  padding: 20px;
  width: 90%;
  max-width: 500px;
  max-height: 80vh;
  position: relative;
  box-shadow: 0 0 30px rgba(100, 100, 150, 0.3), inset 0 0 20px rgba(0, 0, 0, 0.5);
}

#cemetery-close {
  position: absolute;
  top: 10px;
  right: 15px;
  background: none;
  border: none;
  color: #8888aa;
  font-size: 28px;
  cursor: pointer;
  transition: color 0.2s;
}

#cemetery-close:hover {
  color: #fff;
}

#cemetery-title {
  text-align: center;
  color: #c0c0d0;
  font-size: 1.8rem;
  margin: 0 0 5px 0;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

#cemetery-subtitle {
  text-align: center;
  color: #7777aa;
  font-size: 0.9rem;
  font-style: italic;
  margin-bottom: 15px;
}

#cemetery-list {
  max-height: 55vh;
  overflow-y: auto;
  padding-right: 5px;
}

#cemetery-list::-webkit-scrollbar {
  width: 8px;
}

#cemetery-list::-webkit-scrollbar-track {
  background: #1a1a2e;
  border-radius: 4px;
}

#cemetery-list::-webkit-scrollbar-thumb {
  background: #4a4a6a;
  border-radius: 4px;
}

.cemetery-empty {
  text-align: center;
  color: #6666aa;
  font-style: italic;
  padding: 40px 20px;
}

.cemetery-entry {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background: rgba(30, 30, 50, 0.6);
  border: 1px solid #3a3a5a;
  border-radius: 8px;
  padding: 12px 15px;
  margin-bottom: 10px;
  transition: background 0.2s;
}

.cemetery-entry:hover {
  background: rgba(40, 40, 60, 0.8);
}

.cemetery-skull {
  font-size: 1.8rem;
  line-height: 1;
  opacity: 0.7;
}

.cemetery-entry-content {
  flex: 1;
}

.cemetery-entry-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.cemetery-name {
  color: #d0d0e0;
  font-weight: bold;
  font-size: 1.1rem;
}

.cemetery-gender {
  font-size: 1rem;
}

.cemetery-occupation {
  color: #9999bb;
  font-size: 0.85rem;
  margin-bottom: 6px;
}

.cemetery-cause {
  color: #888899;
  font-size: 0.85rem;
}

.cemetery-cause-text {
  color: #cc6666;
  font-weight: bold;
}

.cemetery-date {
  color: #666688;
  font-size: 0.75rem;
  margin-top: 6px;
  text-align: right;
}

/* Cemetery button style */
#cemetery-btn {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  background: linear-gradient(180deg, #3a3a5a 0%, #2a2a4a 100%);
  border: 1px solid #5a5a7a;
  color: #c0c0d0;
  padding: 5px 12px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.85rem;
  transition: all 0.2s;
}

#cemetery-btn:hover {
  background: linear-gradient(180deg, #4a4a6a 0%, #3a3a5a 100%);
  border-color: #7a7a9a;
  color: #fff;
}


#cemetery-overlay.hidden {
  display: none !important;
}


#cemetery-btn:disabled,
#cemetery-btn.disabled {
  background: linear-gradient(180deg, #2a2a3a 0%, #1a1a2a 100%);
  border-color: #3a3a4a;
  color: #5a5a6a;
  cursor: not-allowed;
  opacity: 0.6;
}

#cemetery-btn:disabled:hover,
#cemetery-btn.disabled:hover {
  background: linear-gradient(180deg, #2a2a3a 0%, #1a1a2a 100%);
  border-color: #3a3a4a;
  color: #5a5a6a;
}


/* Chest toggle button */
#chest-toggle {
  position: absolute;
  bottom: calc(5% - 3rem);
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(255, 215, 0, 0.3);
  border-radius: 50%;
  width: 32px;
  height: 32px;
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s;
  opacity: 0.6;
}

#chest-toggle:hover {
  opacity: 1;
  background: rgba(0, 0, 0, 0.7);
  border-color: rgba(255, 215, 0, 0.6);
}

/* Bigger toggle when chest is hidden */
#chest-toggle.chest-toggle-active {
  width: 48px;
  height: 48px;
  font-size: 24px;
  opacity: 1;
  background: rgba(0, 0, 0, 0.7);
  border-color: rgba(255, 215, 0, 0.6);
}

/* Hidden chest state */
#chest.chest-hidden,
#chest.chest-hidden * {
  opacity: 0.1;
  pointer-events: none !important;
}

/* Make chest-container and child containers pass through clicks when chest is hidden */
#chest-container:has(#chest.chest-hidden) {
  pointer-events: none;
}

#chest-container:has(#chest.chest-hidden) #coin-container,
#chest-container:has(#chest.chest-hidden) #particle-container {
  pointer-events: none !important;
}

/* But keep the toggle button clickable */
#chest-container:has(#chest.chest-hidden) #chest-toggle {
  pointer-events: auto !important;
}

/* Onboarding hint tooltip */
.onboarding-hint {
  position: absolute;
  top: calc(50% - 140px);
  left: 50%;
  transform: translateX(-50%) translateY(-10px);
  background: linear-gradient(135deg, #2a1a0a 0%, #1a0f05 100%);
  border: 3px solid #d4af37;
  border-radius: 12px;
  padding: 16px 28px;
  z-index: 1000;
  opacity: 0;
  transition: opacity 0.3s ease, transform 0.3s ease;
  pointer-events: none;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5), 0 0 20px rgba(212, 175, 55, 0.4);
  max-width: 320px;
}

.onboarding-hint.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.onboarding-hint-arrow {
  position: absolute;
  bottom: -12px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 12px solid transparent;
  border-right: 12px solid transparent;
  border-top: 12px solid #d4af37;
}

.onboarding-hint-arrow::after {
  content: '';
  position: absolute;
  bottom: 3px;
  left: -10px;
  width: 0;
  height: 0;
  border-left: 10px solid transparent;
  border-right: 10px solid transparent;
  border-top: 10px solid #2a1a0a;
}

.onboarding-hint-text {
  color: #f0e6d2;
  font-family: 'MedievalSharp', cursive;
  font-size: 22px;
  text-align: center;
  line-height: 1.4;
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
}

/* Pulse animation for attention */
@keyframes hint-pulse {
  0%, 100% { box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5), 0 0 15px rgba(212, 175, 55, 0.3); }
  50% { box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5), 0 0 25px rgba(212, 175, 55, 0.6); }
}

.onboarding-hint.show {
  animation: hint-pulse 2s ease-in-out infinite;
}

/* Peon purchase hint */
.peon-hint {
  position: absolute;
  top: calc(50% - 140px);
  left: 50%;
  transform: translateX(-50%) translateY(-10px);
  background: linear-gradient(135deg, #2a1a0a 0%, #1a0f05 100%);
  border: 3px solid #d4af37;
  border-radius: 12px;
  padding: 16px 28px;
  z-index: 1000;
  opacity: 0;
  transition: opacity 0.3s ease, transform 0.3s ease;
  pointer-events: none;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5), 0 0 20px rgba(212, 175, 55, 0.4);
  max-width: 320px;
}

.peon-hint.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
  animation: hint-pulse 2s ease-in-out infinite;
}

.peon-hint .onboarding-hint-arrow {
  position: absolute;
  bottom: -12px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 12px solid transparent;
  border-right: 12px solid transparent;
  border-top: 12px solid #d4af37;
}

.peon-hint .onboarding-hint-arrow::after {
  content: '';
  position: absolute;
  bottom: 3px;
  left: -10px;
  width: 0;
  height: 0;
  border-left: 10px solid transparent;
  border-right: 10px solid transparent;
  border-top: 10px solid #2a1a0a;
}

/* Spider Event (Arachnophobia) */
.spider-container {
  position: absolute;
  z-index: 6000;
  display: flex;
  flex-direction: column;
  align-items: center;
  pointer-events: none;
}

.spider-silk {
  width: 2px;
  background: linear-gradient(to bottom, rgba(255, 255, 255, 0.9), rgba(255, 255, 255, 0.3));
  position: absolute;
  top: 0;
  left: calc(50% + 2.5rem);
  transform: translateX(-50%);
  height: calc(100% - 2.5rem);
  z-index: -1;
}

.spider {
  font-size: 5rem;
  cursor: pointer;
  pointer-events: auto;
  filter: drop-shadow(0 0 10px rgba(255, 255, 255, 0.9)) drop-shadow(0 0 20px rgba(255, 255, 255, 0.6)) drop-shadow(2px 2px 4px rgba(0, 0, 0, 0.8));
  transition: transform 0.1s ease;
  animation: spider-wiggle 0.3s ease-in-out infinite;
}

.spider:hover {
  transform: scale(1.2);
}

@keyframes spider-wiggle {
  0%, 100% { transform: rotate(-5deg); }
  50% { transform: rotate(5deg); }
}

.spider-container.has-peon .spider {
  animation: spider-grab 0.3s ease-in-out;
}

@keyframes spider-grab {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.3); }
}

.spider-container.spider-killed {
  animation: spider-death 0.3s ease-out forwards;
}

@keyframes spider-death {
  0% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.5) rotate(180deg); }
  100% { transform: scale(0) rotate(360deg); opacity: 0; }
}

.peon.spider-grabbed {
  animation: peon-grabbed 0.5s ease-in-out infinite;
  filter: brightness(0.7);
}

@keyframes peon-grabbed {
  0%, 100% { transform: translateY(0) rotate(-10deg); }
  50% { transform: translateY(-5px) rotate(10deg); }
}

/* Goblin Attack Event */
.goblin {
  font-size: 4rem;
  z-index: 6000;
  cursor: pointer;
  filter: drop-shadow(2px 2px 4px rgba(0, 0, 0, 0.5));
  animation: goblin-run 0.15s ease-in-out infinite;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.goblin:hover {
  filter: drop-shadow(2px 2px 4px rgba(0, 0, 0, 0.5)) brightness(1.3);
}

@keyframes goblin-run {
  0%, 100% { transform: scaleX(var(--scale-x, 1)) translateY(0); }
  50% { transform: scaleX(var(--scale-x, 1)) translateY(-8px); }
}

.goblin-killed {
  animation: goblin-death 0.3s ease-out forwards !important;
}

@keyframes goblin-death {
  0% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.3) rotate(180deg); }
  100% { transform: scale(0) rotate(360deg); opacity: 0; }
}

/* Hunter (Goblin Hunter upgrade) */
.hunter {
  font-size: 4rem;
  z-index: 6001;
  filter: drop-shadow(2px 2px 4px rgba(0, 0, 0, 0.5));
  user-select: none;
  -webkit-user-select: none;
}
