:root {
  font-family: sans-serif;
  background: #111;
  color: #fefefe;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  background: #111;
  overflow: hidden;
}

body {
  display: block;
}

#game {
  width: 100vw;
  height: 100vh;
  display: block;
  background: #1e1e1e;
  border: 2px solid #444;
  box-sizing: border-box;
  box-shadow: 0 0 30px rgba(0, 0, 0, 0.35);
}

.rarity-label {
  position: relative;
  display: inline-block;
  padding-right: 6px;
  font-weight: 600;
}

.rarity-label--common {
  color: #7ad36a;
}

.rarity-label--uncommon {
  color: #1d8b5e;
}

.rarity-label--rare {
  color: #4d7bff;
}

.rarity-label--epic {
  color: #ff8bd8;
}

.rarity-label--legendary {
  color: #ffbd45;
}

.rarity-label--mythic {
  color: #ff4d5a;
}

.rarity-label--traderonly {
  color: #00f7bf;
}

.rarity-label--dilladon,
.rarity-label--dilleenyoctopiseeny,
.rarity-label--losdilladonitos,
.rarity-label--losdilleenyoctopitos {
  color: #5afae0;
}

.rarity-label--shiny {
  text-shadow: 0 0 8px currentColor, 0 0 18px rgba(255, 255, 255, 0.6);
}

.rarity-label--shiny::before,
.rarity-label--shiny::after {
  content: '';
  position: absolute;
  top: 50%;
  right: 0;
  width: 12px;
  height: 12px;
  pointer-events: none;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.85) 0%, rgba(255, 255, 255, 0.15) 55%, transparent 70%);
  opacity: 0.7;
  filter: blur(0.2px);
  transform: translate(40%, -50%) scale(0.7);
  mix-blend-mode: screen;
}

.rarity-label--shiny::before {
  animation: raritySparkleOrbit 2.8s linear infinite;
}

.rarity-label--shiny::after {
  animation: raritySparklePulse 2.1s ease-in-out infinite;
  animation-delay: -1s;
}

@keyframes raritySparkleOrbit {
  0% {
    transform: translate(40%, -50%) scale(0.7) rotate(0deg);
    opacity: 0.4;
  }
  50% {
    transform: translate(65%, -65%) scale(1.05) rotate(180deg);
    opacity: 0.95;
  }
  100% {
    transform: translate(40%, -50%) scale(0.7) rotate(360deg);
    opacity: 0.4;
  }
}

@keyframes raritySparklePulse {
  0% {
    transform: translate(35%, -60%) scale(0.6);
    opacity: 0.35;
  }
  50% {
    transform: translate(75%, -30%) scale(1.15);
    opacity: 1;
  }
  100% {
    transform: translate(35%, -60%) scale(0.6);
    opacity: 0.35;
  }
}

#auth-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.95);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
}

#auth-container {
  background: #1e1e1e;
  border: 2px solid #444;
  border-radius: 12px;
  padding: 40px;
  max-width: 400px;
  width: 90%;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

#auth-container h1 {
  margin: 0 0 20px 0;
  color: #ffe7a3;
  text-align: center;
  font-size: 32px;
}

#auth-container h2 {
  margin: 0 0 20px 0;
  color: #fefefe;
  font-size: 24px;
}

#auth-message {
  padding: 10px;
  margin-bottom: 15px;
  border-radius: 6px;
  text-align: center;
  display: none;
}

#auth-message.error {
  background: rgba(255, 80, 80, 0.2);
  border: 1px solid #ff5050;
  color: #ff9090;
  display: block;
}

#auth-message.success {
  background: rgba(80, 255, 80, 0.2);
  border: 1px solid #50ff50;
  color: #90ff90;
  display: block;
}

#auth-container input {
  width: 100%;
  padding: 12px;
  margin-bottom: 15px;
  background: #111;
  border: 2px solid #444;
  border-radius: 6px;
  color: #fefefe;
  font-size: 16px;
  box-sizing: border-box;
}

#auth-container input:focus {
  outline: none;
  border-color: #ffe7a3;
}

#auth-container button {
  width: 100%;
  padding: 12px;
  background: #ffe7a3;
  border: none;
  border-radius: 6px;
  color: #111;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}

#auth-container button:hover {
  background: #ffd76a;
}

#auth-container button:active {
  background: #ffce50;
}

#auth-container p {
  text-align: center;
  margin-top: 15px;
  color: #999;
}

#auth-container a {
  color: #ffe7a3;
  text-decoration: none;
}

#auth-container a:hover {
  text-decoration: underline;
}

/* Shop Overlay */
#shop-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
}

#shop-container {
  position: relative;
  background: radial-gradient(120% 140% at 15% 10%, rgba(120, 255, 210, 0.08), transparent),
              linear-gradient(155deg, rgba(14, 18, 28, 0.95) 0%, rgba(20, 24, 36, 0.98) 40%, rgba(10, 12, 18, 0.98) 100%);
  border: 1px solid rgba(120, 255, 210, 0.25);
  border-radius: 24px;
  padding: 48px;
  max-width: 980px;
  width: min(96%, 980px);
  max-height: 84vh;
  overflow-y: auto;
  box-shadow: 0 50px 120px rgba(0, 0, 0, 0.55), 0 0 80px rgba(120, 255, 210, 0.12);
  /* Improve touch scrolling on iPad */
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
}

#shop-container h1 {
  margin: 0;
  color: #d6fff8;
  font-size: 40px;
  letter-spacing: 1px;
  text-transform: uppercase;
  text-align: left;
}

#shop-close-btn {
  position: absolute;
  top: 22px;
  right: 22px;
  width: 42px;
  height: 42px;
  background: radial-gradient(circle at 30% 30%, rgba(255, 120, 140, 0.45), rgba(120, 16, 32, 0.65));
  border: 1px solid rgba(255, 120, 140, 0.65);
  border-radius: 50%;
  color: #ffe7f0;
  font-size: 22px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  box-shadow: 0 0 18px rgba(255, 120, 140, 0.25);
}

#shop-close-btn:hover {
  transform: scale(1.05) rotate(6deg);
  box-shadow: 0 0 24px rgba(255, 120, 140, 0.4);
}

#shop-close-btn:active {
  transform: scale(0.92);
}

#shop-content {
  min-height: 260px;
}

.shop-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 32px;
  margin-bottom: 28px;
}

.shop-title-block {
  flex: 1;
}

.shop-title-block h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  color: rgba(214, 255, 248, 0.85);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.shop-subtitle {
  margin-top: 12px;
  color: rgba(182, 229, 220, 0.85);
  font-size: 15px;
  max-width: 560px;
  line-height: 1.6;
}

.shop-sigil {
  flex-shrink: 0;
  width: 120px;
  height: 120px;
  border-radius: 20px;
  background: radial-gradient(circle at 50% 35%, rgba(120, 255, 190, 0.55), rgba(90, 215, 255, 0.12));
  box-shadow: inset 0 0 25px rgba(120, 255, 210, 0.35), 0 0 60px rgba(120, 255, 210, 0.22);
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(214, 255, 248, 0.92);
  font-size: 48px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.shop-tabs {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 30px;
}

.shop-tab {
  flex: 1;
  padding: 14px 0;
  border-radius: 16px;
  border: 1px solid rgba(120, 255, 210, 0.25);
  background: rgba(16, 24, 32, 0.45);
  color: rgba(182, 229, 220, 0.7);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.05em;
  cursor: pointer;
  transition: all 0.25s;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.22);
}

.shop-tab:hover {
  border-color: rgba(120, 255, 210, 0.6);
  color: rgba(214, 255, 248, 0.9);
  transform: translateY(-2px);
  box-shadow: 0 12px 28px rgba(120, 255, 210, 0.2);
}

.shop-tab.active {
  border-color: rgba(120, 255, 210, 0.9);
  background: linear-gradient(145deg, rgba(120, 255, 210, 0.25), rgba(80, 180, 255, 0.25));
  color: #eaffff;
  box-shadow: 0 16px 36px rgba(120, 255, 210, 0.35);
  transform: translateY(-3px);
}

.shop-alert {
  padding: 18px 20px;
  border-radius: 16px;
  border: 1px solid rgba(120, 255, 210, 0.25);
  background: linear-gradient(145deg, rgba(18, 28, 38, 0.9), rgba(12, 18, 26, 0.9));
  text-align: center;
  font-size: 15px;
  margin-bottom: 24px;
  box-shadow: 0 14px 28px rgba(0, 0, 0, 0.3);
  color: rgba(214, 255, 248, 0.85);
}

.shop-alert strong {
  color: #8fffe2;
}

.shop-alert--danger {
  border-color: rgba(255, 120, 140, 0.45);
  background: linear-gradient(145deg, rgba(60, 16, 24, 0.9), rgba(30, 6, 12, 0.9));
  color: rgba(255, 205, 215, 0.9);
  box-shadow: 0 16px 34px rgba(255, 120, 140, 0.25);
}

.shop-alert--info {
  border-color: rgba(120, 255, 210, 0.35);
  background: linear-gradient(145deg, rgba(18, 35, 48, 0.9), rgba(10, 18, 28, 0.9));
}

/* Chat System */
#chat-container {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  display: flex;
  align-items: center;
  gap: 8px;
}

#chat-input {
  width: 400px;
  padding: 10px 15px;
  background: rgba(0, 0, 0, 0.85);
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 8px;
  color: #ffffff;
  font-size: 14px;
  outline: none;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
}

#chat-input:focus {
  border-color: #ffe7a3;
  background: rgba(0, 0, 0, 0.9);
}

#chat-send-btn {
  padding: 10px 20px;
  background: #00ff88;
  color: black;
  border: none;
  border-radius: 8px;
  font-weight: bold;
  cursor: pointer;
  font-size: 14px;
  box-shadow: 0 4px 12px rgba(0, 255, 136, 0.3);
  transition: all 0.2s;
}

#chat-send-btn:hover {
  background: #00dd77;
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(0, 255, 136, 0.4);
}

#chat-send-btn:active {
  transform: translateY(0);
  box-shadow: 0 2px 8px rgba(0, 255, 136, 0.3);
}

@media (max-width: 768px) {
  #chat-container {
    bottom: 240px;
    left: 50%;
    transform: translateX(-50%);
  }
  
  #chat-input {
    width: 220px;
    font-size: 16px;
  }
  
  #chat-send-btn {
    padding: 10px 15px;
    font-size: 14px;
  }
}

/* Ensure chat is above mobile controls */
#chat-container {
  pointer-events: auto;
}

/* Sign Out Button */
#signout-btn {
  position: fixed;
  top: 80px;
  left: 12px;
  padding: 8px 16px;
  background: rgba(12, 12, 16, 0.85);
  border: 1px solid rgba(255, 231, 163, 0.38);
  border-radius: 8px;
  color: #ffe7a3;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  z-index: 900;
  transition: all 0.2s;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

#signout-btn:hover {
  background: rgba(255, 231, 163, 0.15);
  border-color: rgba(255, 231, 163, 0.6);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

#signout-btn:active {
  transform: translateY(0);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

/* Shop Button */
#shop-btn {
  position: fixed;
  top: 120px;
  left: 12px;
  padding: 8px 16px;
  background: rgba(12, 12, 16, 0.85);
  border: 1px solid rgba(255, 231, 163, 0.38);
  border-radius: 8px;
  color: #ffe7a3;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  z-index: 900;
  transition: all 0.2s;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

#shop-btn:hover {
  background: rgba(255, 231, 163, 0.15);
  border-color: rgba(255, 231, 163, 0.6);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

#shop-btn:active {
  transform: translateY(0);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

/* Leaderboard Button */
#leaderboard-btn {
  position: fixed;
  top: 160px;
  left: 12px;
  padding: 8px 16px;
  background: rgba(12, 12, 16, 0.85);
  border: 1px solid rgba(255, 200, 100, 0.38);
  border-radius: 8px;
  color: #ffc864;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  z-index: 900;
  transition: all 0.2s;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

#leaderboard-btn:hover {
  background: rgba(255, 200, 100, 0.15);
  border-color: rgba(255, 200, 100, 0.6);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

#leaderboard-btn:active {
  transform: translateY(0);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

/* Friend Button */
#friend-btn {
  position: fixed;
  top: 210px;
  left: 12px;
  padding: 8px 16px;
  background: rgba(12, 12, 16, 0.85);
  border: 1px solid rgba(255, 200, 100, 0.38);
  border-radius: 8px;
  color: #ffc864;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  z-index: 900;
  transition: all 0.2s;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

#friend-btn:hover {
  background: rgba(255, 200, 100, 0.15);
  border-color: rgba(255, 200, 100, 0.6);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

#friend-btn:active {
  transform: translateY(0);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

#lucky-blox-btn {
  position: fixed;
  top: 260px;
  left: 12px;
  padding: 8px 16px;
  background: rgba(12, 12, 16, 0.85);
  border: 1px solid rgba(255, 200, 100, 0.38);
  border-radius: 8px;
  color: #ffc864;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  z-index: 900;
  transition: all 0.2s;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

#lucky-blox-btn:hover {
  background: rgba(255, 200, 100, 0.15);
  border-color: rgba(255, 200, 100, 0.6);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

#lucky-blox-btn:active {
  transform: translateY(0);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

/* Unlock Base Button */
#unlock-base-btn {
  position: fixed;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  padding: 12px 24px;
  background: rgba(12, 12, 16, 0.95);
  border: 2px solid rgba(0, 255, 0, 0.6);
  border-radius: 12px;
  color: #00ff00;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  z-index: 1000;
  transition: all 0.2s;
  box-shadow: 0 4px 16px rgba(0, 255, 0, 0.3);
  pointer-events: auto;
}

#unlock-base-btn:hover {
  background: rgba(0, 255, 0, 0.15);
  border-color: rgba(0, 255, 0, 0.9);
  transform: translateX(-50%) scale(1.05);
  box-shadow: 0 6px 20px rgba(0, 255, 0, 0.5);
}

#unlock-base-btn:active {
  transform: translateX(-50%) scale(0.98);
  box-shadow: 0 2px 8px rgba(0, 255, 0, 0.3);
}

/* Mobile Controls */
#mobile-controls {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 800;
}

#joystick-area {
  position: absolute;
  bottom: 40px;
  left: 40px;
  width: 150px;
  height: 150px;
  pointer-events: all;
}

#joystick-base {
  position: absolute;
  width: 100%;
  height: 100%;
  background: rgba(255, 255, 255, 0.1);
  border: 3px solid rgba(255, 231, 163, 0.4);
  border-radius: 50%;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

#joystick-stick {
  position: absolute;
  width: 60px;
  height: 60px;
  background: rgba(255, 231, 163, 0.8);
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  transition: all 0.1s;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

#action-buttons {
  position: absolute;
  bottom: 40px;
  right: 40px;
  display: flex;
  flex-direction: column;
  gap: 15px;
  pointer-events: all;
}

.action-btn {
  width: 80px;
  height: 80px;
  background: rgba(12, 12, 16, 0.85);
  border: 2px solid rgba(255, 231, 163, 0.4);
  border-radius: 50%;
  color: #ffe7a3;
  font-size: 18px;
  font-weight: bold;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  transition: all 0.15s;
}

.action-btn span {
  font-size: 11px;
  font-weight: 600;
}

.action-btn:active {
  background: rgba(255, 231, 163, 0.3);
  transform: scale(0.95);
  border-color: rgba(255, 231, 163, 0.7);
}

/* Arrow Controls */
#arrow-controls {
  position: absolute;
  bottom: 40px;
  left: 40px;
  width: 180px;
  height: 180px;
  display: grid;
  grid-template-columns: 60px 60px 60px;
  grid-template-rows: 60px 60px 60px;
  gap: 0;
  pointer-events: all;
}

.arrow-btn {
  background: rgba(12, 12, 16, 0.85);
  border: 2px solid rgba(255, 231, 163, 0.4);
  color: #ffe7a3;
  font-size: 24px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  transition: all 0.15s;
}

.arrow-btn[data-direction="up"] {
  grid-column: 2;
  grid-row: 1;
  border-radius: 8px 8px 0 0;
}

.arrow-btn[data-direction="left"] {
  grid-column: 1;
  grid-row: 2;
  border-radius: 8px 0 0 8px;
}

.arrow-btn[data-direction="down"] {
  grid-column: 2;
  grid-row: 3;
  border-radius: 0 0 8px 8px;
}

.arrow-btn[data-direction="right"] {
  grid-column: 3;
  grid-row: 2;
  border-radius: 0 8px 8px 0;
}

.arrow-btn:active {
  background: rgba(255, 231, 163, 0.3);
  transform: scale(0.95);
  border-color: rgba(255, 231, 163, 0.7);
}

/* Control Switch Button */
#control-switch-btn {
  position: absolute;
  bottom: 400px;
  right: 40px;
  padding: 10px 20px;
  background: rgba(12, 12, 16, 0.85);
  border: 2px solid rgba(255, 231, 163, 0.4);
  border-radius: 8px;
  color: #ffe7a3;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  pointer-events: all;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  transition: all 0.2s;
}

#control-switch-btn:active {
  background: rgba(255, 231, 163, 0.3);
  transform: scale(0.95);
  border-color: rgba(255, 231, 163, 0.7);
}

/* Shop Items */
.shop-item {
  position: relative;
  background: linear-gradient(145deg, rgba(16, 20, 30, 0.92), rgba(10, 14, 20, 0.92));
  border: 1px solid rgba(120, 255, 210, 0.2);
  border-radius: 18px;
  padding: 26px;
  margin-bottom: 24px;
  transition: all 0.25s;
  box-shadow: 0 20px 45px rgba(0, 0, 0, 0.45);
  overflow: hidden;
}

.shop-item:hover {
  border-color: rgba(120, 255, 210, 0.55);
  background: linear-gradient(145deg, rgba(20, 28, 40, 0.98), rgba(10, 16, 24, 0.98));
  box-shadow: 0 26px 55px rgba(120, 255, 210, 0.18);
  transform: translateY(-3px);
}

.shop-item-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  margin-bottom: 16px;
}

.shop-item-header h3 {
  margin: 0;
  color: #eaffff;
  font-size: 26px;
  letter-spacing: 0.02em;
}

.shop-item-price {
  color: #74ffe0;
  font-weight: 600;
  font-size: 15px;
  background: rgba(120, 255, 210, 0.16);
  padding: 8px 16px;
  border-radius: 999px;
  border: 1px solid rgba(120, 255, 210, 0.4);
  box-shadow: inset 0 0 18px rgba(120, 255, 210, 0.25);
}

.shop-item-description {
  color: rgba(205, 227, 222, 0.9);
  font-size: 15px;
  margin: 0 0 18px 0;
  line-height: 1.6;
}

.shop-buy-btn {
  width: 100%;
  padding: 14px;
  background: linear-gradient(135deg, rgba(120, 255, 210, 0.95), rgba(82, 180, 255, 0.95));
  border: 0;
  border-radius: 12px;
  color: #041820;
  font-size: 17px;
  font-weight: 800;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 12px 25px rgba(120, 255, 210, 0.35);
}

.shop-buy-btn:hover:not(:disabled) {
  transform: translateY(-3px);
  box-shadow: 0 18px 32px rgba(120, 255, 210, 0.45);
  filter: brightness(1.05);
}

.shop-buy-btn:active:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 10px 22px rgba(120, 255, 210, 0.35);
}

.shop-buy-btn:disabled {
  background: rgba(40, 50, 60, 0.8);
  color: rgba(140, 160, 160, 0.65);
  cursor: not-allowed;
  box-shadow: none;
  border: 1px solid rgba(70, 90, 100, 0.5);
}

.shop-item-info {
  margin: 16px 0 0 0;
  text-align: center;
  color: rgba(182, 229, 220, 0.6);
  font-size: 13px;
}

.shop-item-info strong {
  color: #8fffe2;
  font-weight: 700;
}

/* Leaderboard Overlay */
#leaderboard-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.95);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

#leaderboard-container {
  background: #1e1e1e;
  border: 2px solid #ffc864;
  border-radius: 12px;
  padding: 40px;
  max-width: 600px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
  position: relative;
  /* Improve touch scrolling on iPad */
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
}

#leaderboard-container h1 {
  margin: 0 0 20px 0;
  color: #ffc864;
  text-align: center;
  font-size: 32px;
}

#leaderboard-close-btn {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 36px;
  height: 36px;
  background: rgba(255, 80, 80, 0.2);
  border: 2px solid #ff5050;
  border-radius: 50%;
  color: #ff5050;
  font-size: 20px;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

#leaderboard-close-btn:hover {
  background: rgba(255, 80, 80, 0.4);
  transform: rotate(90deg);
}

#leaderboard-close-btn:active {
  transform: rotate(90deg) scale(0.95);
}

#leaderboard-tabs {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
  border-bottom: 2px solid #444;
  padding-bottom: 10px;
}

.leaderboard-tab {
  flex: 1;
  padding: 10px 20px;
  background: rgba(40, 40, 40, 0.5);
  border: 1px solid #555;
  border-radius: 8px 8px 0 0;
  color: #aaa;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.leaderboard-tab:hover {
  background: rgba(60, 60, 60, 0.7);
  color: #ccc;
}

.leaderboard-tab.active {
  background: rgba(255, 200, 100, 0.2);
  border-color: #ffc864;
  color: #ffc864;
}

#leaderboard-content {
  min-height: 300px;
}

.leaderboard-entry {
  display: flex;
  align-items: center;
  padding: 15px;
  margin-bottom: 10px;
  background: rgba(40, 40, 50, 0.6);
  border: 1px solid #444;
  border-radius: 8px;
  transition: all 0.2s;
}

.leaderboard-entry:hover {
  background: rgba(50, 50, 60, 0.8);
  border-color: #666;
}

.leaderboard-rank {
  font-size: 24px;
  font-weight: bold;
  color: #ffc864;
  width: 50px;
  text-align: center;
}

.leaderboard-rank.rank-1 {
  color: #ffd700;
}

.leaderboard-rank.rank-2 {
  color: #c0c0c0;
}

.leaderboard-rank.rank-3 {
  color: #cd7f32;
}

.leaderboard-username {
  flex: 1;
  font-size: 18px;
  font-weight: 600;
  color: #ffe7a3;
  margin-left: 15px;
}

.leaderboard-value {
  font-size: 18px;
  font-weight: bold;
  color: #78ff78;
}

/* Friend Overlay */
#friend-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.95);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

#friend-container {
  background: #1e1e1e;
  border: 2px solid #ffc864;
  border-radius: 12px;
  padding: 40px;
  max-width: 600px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
  position: relative;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
}

#friend-container h1 {
  margin: 0 0 20px 0;
  color: #ffc864;
  text-align: center;
  font-size: 32px;
}

#friend-close-btn {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 36px;
  height: 36px;
  background: rgba(255, 80, 80, 0.2);
  border: 2px solid #ff5050;
  border-radius: 50%;
  color: #ff5050;
  font-size: 20px;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

#friend-close-btn:hover {
  background: rgba(255, 80, 80, 0.4);
  transform: rotate(90deg);
}

#friend-close-btn:active {
  transform: rotate(90deg) scale(0.95);
}

#lucky-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.3);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

#lucky-container {
  position: relative;
  width: min(700px, 90%);
  max-width: 90vw;
  max-height: 90vh;
  padding: 40px 36px;
  background: linear-gradient(160deg, #14141c, #1c1c28);
  border: 2px solid rgba(255, 200, 100, 0.35);
  border-radius: 18px;
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.8);
  text-align: center;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

#lucky-container h1 {
  margin: 0 0 28px 0;
  color: #ffc864;
  font-size: 32px;
  letter-spacing: 2px;
  text-transform: uppercase;
  text-shadow: 0 0 20px rgba(255, 200, 100, 0.5);
}

#lucky-close-btn {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 32px;
  height: 32px;
  background: rgba(255, 80, 80, 0.18);
  border: 2px solid #ff5050;
  border-radius: 50%;
  color: #ff7979;
  font-size: 18px;
  font-weight: bold;
  cursor: pointer;
  transition: transform 0.2s, background 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

#lucky-close-btn:hover {
  background: rgba(255, 80, 80, 0.3);
  transform: scale(1.05);
}

#lucky-close-btn:active {
  transform: scale(0.95);
}

#lucky-content {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.lucky-option {
  position: relative;
  padding: 28px 32px;
  background: linear-gradient(145deg, rgba(25, 40, 55, 0.94), rgba(10, 16, 24, 0.95));
  border: 2px solid rgba(120, 255, 210, 0.4);
  border-radius: 16px;
  color: #eaffff;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.25s, border-color 0.25s, box-shadow 0.25s;
  overflow: hidden;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.42);
  text-align: left;
}

.lucky-option.divine-lucky {
  border-color: rgba(30, 252, 223, 0.5);
}

.lucky-option.divine-lucky::before {
  background: conic-gradient(from 0deg, rgba(30, 252, 223, 0.65), rgba(238, 155, 255, 0.6), rgba(30, 252, 223, 0.65));
}

.lucky-option.mythic-lucky {
  border-color: rgba(194, 107, 255, 0.55);
}

.lucky-option.mythic-lucky::before {
  background: conic-gradient(from 0deg, rgba(194, 107, 255, 0.65), rgba(255, 224, 102, 0.6), rgba(194, 107, 255, 0.65));
}

.lucky-option.secret-lucky {
  border-color: rgba(192, 192, 192, 0.5);
}

.lucky-option.secret-lucky::before {
  background: conic-gradient(from 0deg, rgba(192, 192, 192, 0.65), rgba(128, 128, 128, 0.6), rgba(192, 192, 192, 0.65));
}

.lucky-option::before {
  content: '';
  position: absolute;
  inset: -45%;
  background: conic-gradient(from 0deg, rgba(120, 255, 210, 0.65), rgba(206, 145, 255, 0.6), rgba(120, 255, 210, 0.65));
  filter: blur(55px);
  opacity: 0.35;
  animation: luckyOptionSpin 8s linear infinite;
  pointer-events: none;
}

.lucky-option::after {
  content: '';
  position: absolute;
  inset: 1px;
  border-radius: 12px;
  background: linear-gradient(155deg, rgba(30, 45, 60, 0.96), rgba(18, 28, 40, 0.96));
  box-shadow: inset 0 0 40px rgba(120, 255, 210, 0.22);
  pointer-events: none;
  transition: opacity 0.25s, box-shadow 0.25s;
}

.lucky-option:hover {
  transform: translateY(-4px);
  box-shadow: 0 32px 70px rgba(120, 255, 210, 0.28);
}

.lucky-option.divine-lucky:hover {
  border-color: rgba(30, 252, 223, 0.75);
  box-shadow: 0 32px 70px rgba(30, 252, 223, 0.3);
}

.lucky-option.mythic-lucky:hover {
  border-color: rgba(194, 107, 255, 0.75);
  box-shadow: 0 32px 70px rgba(194, 107, 255, 0.28);
}

.lucky-option.secret-lucky:hover {
  border-color: rgba(192, 192, 192, 0.75);
  box-shadow: 0 32px 70px rgba(192, 192, 192, 0.3);
}

.lucky-option:hover::before {
  opacity: 0.65;
}

.lucky-option:hover::after {
  box-shadow: inset 0 0 65px rgba(120, 255, 210, 0.38);
}

.lucky-option.divine-lucky:hover::after {
  box-shadow: inset 0 0 65px rgba(30, 252, 223, 0.4);
}

.lucky-option.mythic-lucky:hover::after {
  box-shadow: inset 0 0 65px rgba(194, 107, 255, 0.35);
}

.lucky-option.secret-lucky:hover::after {
  box-shadow: inset 0 0 65px rgba(192, 192, 192, 0.4);
}

.lucky-option:active {
  transform: translateY(-1px);
  box-shadow: 0 16px 35px rgba(120, 255, 210, 0.2);
}

.lucky-option:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.lucky-option:disabled::before {
  opacity: 0.2;
}

.lucky-option-content {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.lucky-option-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}

.lucky-option-title {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: 0.05em;
  color: #f4ffff;
  text-shadow: 0 0 15px rgba(244, 255, 255, 0.4);
}

.lucky-option-price {
  font-size: 20px;
  font-weight: 700;
  color: #78ff78;
  background: rgba(120, 255, 120, 0.15);
  padding: 6px 14px;
  border-radius: 8px;
  border: 1px solid rgba(120, 255, 120, 0.3);
  text-shadow: 0 0 10px rgba(120, 255, 120, 0.5);
}

.lucky-option-perks {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin: 8px 0;
  padding: 16px;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.perk-item {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
}

.perk-icon {
  font-size: 18px;
  width: 24px;
  text-align: center;
}

.perk-text {
  color: rgba(214, 255, 248, 0.9);
  flex: 1;
}

.perk-text strong {
  color: #f4ffff;
  font-weight: 700;
}

.perk-list {
  margin-left: 34px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 4px;
}

.perk-reward {
  color: rgba(120, 255, 210, 0.85);
  font-size: 13px;
  padding-left: 8px;
  font-weight: 500;
}

.perk-reward-note {
  color: rgba(255, 200, 100, 0.75);
  font-size: 11px;
  padding-left: 8px;
  font-style: italic;
  margin-top: 2px;
}

.lucky-option-note {
  font-size: 12px;
  font-weight: 500;
  color: rgba(214, 255, 248, 0.75);
  font-style: italic;
  margin-top: 4px;
  padding-top: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

@keyframes luckyOptionSpin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

@keyframes adminAbusePulse {
  0% { transform: scale(1); box-shadow: 0 0 30px rgba(255, 0, 255, 0.9), 0 0 60px rgba(255, 255, 0, 0.7), 0 0 90px rgba(0, 255, 255, 0.5); }
  100% { transform: scale(1.02); box-shadow: 0 0 50px rgba(255, 0, 255, 1), 0 0 80px rgba(255, 255, 0, 0.9), 0 0 120px rgba(0, 255, 255, 0.7); }
}

.lucky-feedback {
  min-height: 20px;
  font-size: 13px;
  font-weight: 500;
  color: #ff8080;
  margin-top: 4px;
}

.lucky-feedback.success {
  color: #78ff78;
}

.lucky-feedback.error {
  color: #ff8080;
}

.lucky-feedback.info {
  color: #8fffe2;
}

#friend-tabs {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
  border-bottom: 2px solid #444;
  padding-bottom: 10px;
}

.friend-tab {
  flex: 1;
  padding: 10px 20px;
  background: rgba(40, 40, 40, 0.5);
  border: 1px solid #555;
  border-radius: 8px 8px 0 0;
  color: #aaa;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.friend-tab:hover {
  background: rgba(60, 60, 60, 0.7);
  border-color: #777;
}

.friend-tab.active {
  background: rgba(255, 200, 100, 0.2);
  border-color: #ffc864;
  color: #ffc864;
}

#friend-search-container {
  margin-bottom: 20px;
}

#friend-search-input {
  width: 100%;
  padding: 12px 16px;
  background: rgba(40, 40, 50, 0.6);
  border: 1px solid #555;
  border-radius: 8px;
  color: #fff;
  font-size: 15px;
  transition: all 0.2s;
}

#friend-search-input:focus {
  outline: none;
  border-color: #ffc864;
  background: rgba(50, 50, 60, 0.8);
}

#friend-search-input::placeholder {
  color: #888;
}

#friend-content {
  min-height: 300px;
  max-height: 400px;
  overflow-y: auto;
}

.user-entry {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 15px;
  margin-bottom: 8px;
  background: rgba(40, 40, 50, 0.6);
  border: 1px solid #444;
  border-radius: 8px;
  transition: all 0.2s;
}

.user-entry:hover {
  background: rgba(50, 50, 60, 0.8);
  border-color: #666;
}

.user-entry-left {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}

.user-entry-name {
  font-size: 16px;
  font-weight: 600;
  color: #ffe7a3;
}

.user-entry-status {
  font-size: 13px;
  color: #aaa;
}

.user-entry-status.online {
  color: #78ff78;
}

.user-entry-status.offline {
  color: #888;
}

.add-friend-btn {
  padding: 8px 16px;
  background: rgba(120, 255, 120, 0.2);
  border: 1px solid #78ff78;
  border-radius: 6px;
  color: #78ff78;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.add-friend-btn:hover {
  background: rgba(120, 255, 120, 0.3);
  transform: translateY(-1px);
}

.add-friend-btn:active {
  transform: translateY(0);
}

.accept-friend-btn {
  padding: 8px 16px;
  background: rgba(120, 255, 120, 0.2);
  border: 1px solid #78ff78;
  border-radius: 6px;
  color: #78ff78;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  margin-right: 8px;
}

.accept-friend-btn:hover {
  background: rgba(120, 255, 120, 0.3);
  transform: translateY(-1px);
}

.accept-friend-btn:active {
  transform: translateY(0);
}

.decline-friend-btn {
  padding: 8px 16px;
  background: rgba(255, 80, 80, 0.2);
  border: 1px solid #ff5050;
  border-radius: 6px;
  color: #ff5050;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.decline-friend-btn:hover {
  background: rgba(255, 80, 80, 0.3);
  transform: translateY(-1px);
}

.decline-friend-btn:active {
  transform: translateY(0);
}

#tutorial-overlay {
  position: fixed;
  left: 50%;
  bottom: 150px;
  transform: translateX(-50%);
  pointer-events: none;
  display: none;
  z-index: 9000;
}

#tutorial-overlay.visible {
  display: flex;
}

#tutorial-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  background: rgba(12, 20, 38, 0.85);
  border: 1px solid rgba(255, 231, 163, 0.4);
  border-radius: 12px;
  padding: 12px 18px;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.45);
}

#tutorial-arrow {
  font-size: 20px;
  letter-spacing: 4px;
  color: #ffd76a;
  text-shadow: 0 0 12px rgba(255, 215, 100, 0.9);
  font-weight: 700;
}

#tutorial-inner {
  text-align: center;
  color: #fefefe;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

#tutorial-inner strong {
  font-size: 18px;
}

#tutorial-subtext {
  font-size: 14px;
  color: rgba(255, 255, 255, 0.8);
}

#tutorial-banner {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  padding: 8px 18px;
  border-radius: 999px;
  background: rgba(30, 30, 40, 0.95);
  border: 1px solid rgba(255, 231, 163, 0.6);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s ease;
  z-index: 9000;
}

#tutorial-banner.visible {
  opacity: 1;
}
