/* Reset and Base Styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  image-rendering: pixelated;
  image-rendering: -moz-crisp-edges;
  image-rendering: crisp-edges;
}

/* Attack Mode: selected stake turns green */
.stake-options .btn-secondary.selected {
  background: linear-gradient(135deg, #43a047, #2e7d32);
  border-color: #2e7d32;
}

html, body {
  height: 100%;
  background: #0a0a14;
}

body {
  font-family: 'Press Start 2P', monospace;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
  color: #ffffff;
  background: linear-gradient(135deg, #0a0a14 0%, #1a1a2e 100%);
}

/* Game Container */
#game-container {
  position: relative;
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  aspect-ratio: 16/9;
  overflow: hidden;
  background: #000;
  box-shadow: 0 0 50px rgba(0, 119, 255, 0.2);
}

canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: block;
}

/* Screens */
.screen {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  background: linear-gradient(135deg, rgba(10, 10, 20, 0.95) 0%, rgba(26, 26, 46, 0.95) 100%);
  z-index: 10;
  transition: opacity 0.3s ease;
  padding: 20px;
  text-align: center;
}

.screen.hidden {
  opacity: 0;
  pointer-events: none;
}

/* Main Content */
.main-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  z-index: 2;
}

/* Typography */
.pixel-text {
  color: #ffffff;
  text-shadow: 2px 2px 0 #000000;
  line-height: 1.5;
  text-align: center;
}

.title {
  font-size: clamp(24px, 6vw, 42px);
  color: #ffd700;
  margin-bottom: 24px;
  text-shadow: 3px 3px 0 #000000, 0 0 15px rgba(255, 215, 0, 0.5);
  letter-spacing: 1px;
}

.instructions {
  background: rgba(0, 0, 0, 0.6);
  padding: 16px 24px;
  border: 2px solid #333;
  border-radius: 12px;
  font-size: clamp(11px, 2.5vw, 15px);
  margin-bottom: 32px;
  color: #eeeeee;
  max-width: 90%;
  backdrop-filter: blur(10px);
}

.space-key {
  color: #00bfff;
  text-shadow: 2px 2px 0 #003366;
  font-weight: bold;
  padding: 2px 6px;
  background: rgba(0, 191, 255, 0.1);
  border-radius: 4px;
}

/* Buttons */
.btn-main {
  background: linear-gradient(135deg, #ff6b6b, #ff8e8e);
  color: #ffffff;
  border: none;
  padding: 20px 40px;
  margin: 12px;
  cursor: pointer;
  font-family: 'Press Start 2P', monospace;
  border: 3px solid #cc5555;
  box-shadow: 0 8px 0 #663333, 0 12px 20px rgba(0, 0, 0, 0.4);
  transition: all 0.2s ease;
  font-size: clamp(14px, 3vw, 18px);
  border-radius: 15px;
  position: relative;
  overflow: hidden;
  text-shadow: 2px 2px 0 #663333;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 10px;
}

.btn-main::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
  transition: left 0.6s ease;
  z-index: -1;
}

.btn-main:hover::before {
  left: 100%;
}

.btn-main:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 0 #663333, 0 16px 24px rgba(0, 0, 0, 0.5);
  background: linear-gradient(135deg, #ff8e8e, #ff6b6b);
}

.btn-main:active {
  transform: translateY(2px);
  box-shadow: 0 4px 0 #663333, 0 6px 10px rgba(0, 0, 0, 0.3);
}

.btn-secondary {
  background: linear-gradient(135deg, #00bfff, #0077ff);
  color: #ffffff;
  border: none;
  padding: 16px 32px;
  margin: 8px;
  cursor: pointer;
  font-family: 'Press Start 2P', monospace;
  border: 3px solid #0066cc;
  box-shadow: 0 6px 0 #003366, 0 8px 16px rgba(0, 0, 0, 0.3);
  transition: all 0.2s ease;
  font-size: clamp(12px, 2.5vw, 16px);
  border-radius: 12px;
  position: relative;
  overflow: hidden;
  text-shadow: 2px 2px 0 #003366;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-secondary::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
  transition: left 0.6s ease;
  z-index: -1;
}

.btn-secondary:hover::before {
  left: 100%;
}

.btn-secondary:hover {
  transform: translateY(-3px);
  box-shadow: 0 9px 0 #003366, 0 12px 20px rgba(0, 0, 0, 0.4);
  background: linear-gradient(135deg, #0077ff, #00bfff);
}

.btn-secondary:active {
  transform: translateY(1px);
  box-shadow: 0 3px 0 #003366, 0 4px 8px rgba(0, 0, 0, 0.3);
}

/* Side Buttons */
.side-buttons-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 2%;
  z-index: 1;
}

body.game-playing .side-buttons-container,
body.game-playing .side-column {
  pointer-events: none;
}

.side-column {
  pointer-events: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  height: 85%;
  justify-content: center;
  max-height: 100%;
}

.left-column {
  align-items: flex-start;
}

.right-column {
  align-items: flex-end;
}

.btn-feature {
  background: linear-gradient(135deg, #4a4a6a, #2a2a4a);
  color: #ffffff;
  border: none;
  padding: 12px 16px;
  cursor: pointer;
  font-family: 'Press Start 2P', monospace;
  border: 2px solid #5a5a8a;
  box-shadow: 0 4px 0 #1a1a3a, 0 6px 12px rgba(0, 0, 0, 0.3);
  transition: all 0.2s ease;
  font-size: clamp(8px, 1.5vw, 11px);
  width: clamp(100px, 15vw, 160px);
  min-height: 60px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 6px;
  border-radius: 10px;
  position: relative;
  overflow: hidden;
  text-align: center;
  text-shadow: 2px 2px 0 #1a1a3a;
  z-index: 1;
}

.btn-feature::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.15), transparent);
  transition: left 0.6s ease;
  z-index: -1;
}

.btn-feature:hover::before {
  left: 100%;
}

.btn-feature:hover {
  transform: translateY(-4px);
  box-shadow: 0 10px 0 #1a1a3a, 0 12px 20px rgba(0, 0, 0, 0.4);
  background: linear-gradient(135deg, #5a5a8a, #4a4a6a);
}

.btn-feature:active {
  transform: translateY(2px);
  box-shadow: 0 3px 0 #1a1a3a, 0 4px 8px rgba(0, 0, 0, 0.3);
}

.btn-icon {
  font-size: 22px;
  filter: drop-shadow(2px 2px 0 rgba(0, 0, 0, 0.3));
  line-height: 1;
}

/* HUD */
#hud {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  padding: 20px;
  display: flex;
  justify-content: center;
  z-index: 5;
  pointer-events: none;
}

#current-score {
  font-size: clamp(22px, 5vw, 38px);
  color: #ffffff;
  text-shadow: 3px 3px 0 #000000, 0 0 10px rgba(255, 255, 255, 0.5);
  background: rgba(0, 0, 0, 0.6);
  padding: 10px 20px;
  border-radius: 10px;
  border: 2px solid rgba(255, 255, 255, 0.2);
  backdrop-filter: blur(5px);
}

/* Game Over Screen */
#game-over-screen {
  background: linear-gradient(135deg, rgba(26, 10, 20, 0.95) 0%, rgba(46, 10, 30, 0.95) 100%);
}

.game-over-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 30px;
}

#game-over-screen .title {
  color: #ff6b6b;
  text-shadow: 3px 3px 0 #000000, 0 0 15px rgba(255, 107, 107, 0.5);
}

.score-display {
  display: flex;
  gap: 40px;
  margin: 20px 0;
}

.score-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.score-label {
  font-size: clamp(12px, 2.5vw, 16px);
  color: #cccccc;
}

.score-value {
  font-size: clamp(20px, 4vw, 32px);
  color: #ffd700;
  text-shadow: 2px 2px 0 #000000;
}

.action-buttons {
  display: flex;
  gap: 20px;
  margin-top: 20px;
}

/* Popup Overlay */
.popup-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: 9999;
  backdrop-filter: blur(8px);
  transition: opacity 0.3s ease;
}

.popup-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.popup-content {
  background: linear-gradient(135deg, #1a1a2e, #16213e);
  border: 2px solid #00bfff;
  border-radius: 12px;
  box-shadow: 0 0 30px rgba(0, 191, 255, 0.4), 0 5px 0 #003366;
  width: 95%;
  max-width: 420px;
  max-height: 85vh;
  overflow: hidden;
  position: relative;
  animation: popup-appear 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  /* Respect safe areas (Telegram / mobile browsers) */
  margin: max(10px, env(safe-area-inset-top, 10px)) 10px max(10px, env(safe-area-inset-bottom, 10px));
}

@keyframes popup-appear {
  from {
    opacity: 0;
    transform: scale(0.8) translateY(-30px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.popup-header {
  background: linear-gradient(135deg, #0077ff, #00bfff);
  padding: calc(12px + env(safe-area-inset-top, 0px)) 16px 12px 16px;
  border-bottom: 2px solid #0066cc;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.popup-header h2 {
  color: #ffffff;
  text-shadow: 2px 2px 0 #003366;
  margin: 0;
  font-size: clamp(12px, 3.5vw, 16px);
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1 1 auto;
}

.popup-close {
  background: none;
  border: none;
  color: #ffffff;
  font-size: 20px;
  cursor: pointer;
  width: 44px;
  height: 44px;
  display: flex;
  justify-content: center;
  align-items: center;
  border-radius: 50%;
  transition: all 0.2s ease;
  text-shadow: 2px 2px 0 #003366;
  margin-left: auto;
  flex-shrink: 0;
}

.popup-close:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: scale(1.1);
}

.popup-body {
  padding: 12px 16px;
  max-height: calc(85vh - 120px);
  overflow-y: auto;
}

.popup-footer {
  padding: 12px 16px;
  background: rgba(0, 0, 0, 0.3);
  display: flex;
  justify-content: flex-end;
}

/* Settings Popup */
.settings-section {
  margin-bottom: 24px;
}

.section-title {
  color: #ffd700;
  margin-bottom: 16px;
  font-size: clamp(12px, 3vw, 16px);
  text-shadow: 2px 2px 0 #000000;
  border-bottom: 2px solid #333;
  padding-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.setting-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  padding: 16px;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 12px;
  border: 2px solid #333;
  transition: all 0.2s ease;
}

.setting-item:hover {
  border-color: #555;
  background: rgba(0, 0, 0, 0.4);
}

.setting-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.setting-label {
  font-size: clamp(11px, 2.5vw, 14px);
  color: #ffffff;
}

.setting-description {
  font-size: clamp(9px, 2vw, 11px);
  color: #aaaaaa;
}

.toggle-switch {
  position: relative;
  display: inline-block;
  width: 60px;
  height: 30px;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #333;
  transition: .4s;
  border-radius: 30px;
  border: 2px solid #555;
}

.toggle-slider:before {
  position: absolute;
  content: "";
  height: 22px;
  width: 22px;
  left: 4px;
  bottom: 2px;
  background-color: #ffffff;
  transition: .4s;
  border-radius: 50%;
  box-shadow: 2px 2px 0 #000000;
}

input:checked + .toggle-slider {
  background-color: #00bfff;
  border-color: #0077ff;
}

input:checked + .toggle-slider:before {
  transform: translateX(28px);
}

.btn-confirm {
  background: linear-gradient(135deg, #00bfff, #0077ff);
  color: #ffffff;
  border: none;
  padding: 16px 24px;
  cursor: pointer;
  font-family: 'Press Start 2P', monospace;
  border: 3px solid #0066cc;
  box-shadow: 0 6px 0 #003366, 0 8px 16px rgba(0, 0, 0, 0.3);
  transition: all 0.2s ease;
  font-size: clamp(11px, 2.5vw, 14px);
  border-radius: 12px;
  position: relative;
  overflow: hidden;
  text-shadow: 2px 2px 0 #003366;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-confirm:hover {
  transform: translateY(-3px);
  box-shadow: 0 9px 0 #003366, 0 12px 20px rgba(0, 0, 0, 0.4);
  background: linear-gradient(135deg, #0077ff, #00bfff);
}

.btn-confirm:active {
  transform: translateY(1px);
  box-shadow: 0 3px 0 #003366, 0 4px 8px rgba(0, 0, 0, 0.3);
}

/* Leaderboard Popup */
.leaderboard-popup {
  max-width: 600px;
}

.leaderboard-list {
  background: rgba(0, 0, 0, 0.3);
  border-radius: 12px;
  border: 2px solid #333;
  overflow: hidden;
}

.leaderboard-header {
  display: grid;
  grid-template-columns: 1fr 2fr 1fr;
  gap: 10px;
  padding: 16px;
  background: rgba(0, 119, 255, 0.2);
  border-bottom: 2px solid #333;
  font-size: clamp(10px, 2.5vw, 13px);
  color: #ffd700;
}

.leaderboard-items {
  max-height: 300px;
  overflow-y: auto;
}

.leaderboard-item {
  display: grid;
  grid-template-columns: 1fr 2fr 1fr;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid #333;
  transition: background 0.2s ease;
  font-size: clamp(10px, 2.5vw, 13px);
  align-items: center;
}

.leaderboard-item:hover {
  background: rgba(255, 255, 255, 0.05);
}

.leaderboard-item:last-child {
  border-bottom: none;
}

.leaderboard-rank {
  color: #ffd700;
  font-weight: bold;
  text-align: center;
}

.leaderboard-player {
  display: flex;
  align-items: center;
  gap: 10px;
}

.leaderboard-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 2px solid #00bfff;
}

.leaderboard-name {
  color: #ffffff;
  text-align: left;
  flex: 1;
}

.leaderboard-score {
  color: #00bfff;
  text-align: right;
}

/* Events Popup */
.events-popup {
  max-width: 700px;
}

.quests-container {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.quest-category {
  background: rgba(0, 0, 0, 0.3);
  border-radius: 12px;
  border: 2px solid #333;
  padding: 20px;
}

.category-title {
  color: #ffd700;
  margin-bottom: 16px;
  font-size: clamp(12px, 3vw, 16px);
  text-shadow: 2px 2px 0 #000000;
  display: flex;
  align-items: center;
  gap: 8px;
}

.quest-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.quest-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 10px;
  border: 2px solid #444;
  transition: all 0.2s ease;
}

.quest-item:hover {
  border-color: #555;
  background: rgba(0, 0, 0, 0.3);
}

.quest-info {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}

.quest-title {
  color: #ffffff;
  font-size: clamp(11px, 2.5vw, 14px);
  text-align: left;
}

.quest-description {
  color: #aaaaaa;
  font-size: clamp(9px, 2vw, 11px);
  text-align: left;
  line-height: 1.4;
}

.btn-quest {
  background: linear-gradient(135deg, #4a4a6a, #2a2a4a);
  color: #ffffff;
  border: none;
  padding: 12px 18px;
  cursor: pointer;
  font-family: 'Press Start 2P', monospace;
  border: 2px solid #5a5a8a;
  box-shadow: 0 4px 0 #1a1a3a;
  transition: all 0.2s ease;
  font-size: clamp(9px, 2vw, 11px);
  border-radius: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
  text-shadow: 1px 1px 0 #1a1a3a;
}

.btn-quest:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 0 #1a1a3a;
  background: linear-gradient(135deg, #5a5a8a, #4a4a6a);
}

.btn-quest:active {
  transform: translateY(1px);
  box-shadow: 0 2px 0 #1a1a3a;
}

/* Profile Popup */
.profile-popup {
  max-width: 500px;
}

.profile-header {
  display: flex;
  align-items: center;
  gap: 20px;
  margin-bottom: 24px;
  padding-bottom: 20px;
  border-bottom: 2px solid #333;
}

.avatar-container {
  position: relative;
  width: 80px;
  height: 80px;
  border-radius: 50%;
  overflow: hidden;
  border: 3px solid #00bfff;
  box-shadow: 0 0 15px rgba(0, 191, 255, 0.5);
}

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

.online-status {
  position: absolute;
  bottom: 5px;
  right: 5px;
  width: 15px;
  height: 15px;
  background: #4CAF50;
  border: 2px solid #1a1a2e;
  border-radius: 50%;
}

.profile-info {
  display: flex;
  flex-direction: column;
  gap: 8px;
  text-align: left;
  flex: 1;
}

.player-name {
  color: #ffd700;
  font-size: clamp(14px, 3vw, 18px);
}

.player-id {
  color: #aaaaaa;
  font-size: clamp(10px, 2.5vw, 12px);
}

.player-level {
  margin-top: 8px;
}

.level-progress {
  display: flex;
  align-items: center;
  gap: 10px;
}

.progress-bar {
  flex: 1;
  height: 8px;
  background: #333;
  border-radius: 4px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #00bfff, #0077ff);
  border-radius: 4px;
  transition: width 0.3s ease;
}

.level-text {
  color: #ffd700;
  font-size: clamp(9px, 2vw, 11px);
  min-width: 60px;
}

.profile-stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 24px;
  width: 100%;
}

.stat-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 16px 12px;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 10px;
  border: 2px solid #333;
  position: relative;
}

.stat-icon {
  position: absolute;
  top: 8px;
  right: 8px;
  color: #00bfff;
  font-size: 14px;
}

.stat-label {
  color: #cccccc;
  font-size: clamp(10px, 2.5vw, 12px);
}

.stat-value {
  color: #00bfff;
  font-size: clamp(14px, 3vw, 18px);
  text-shadow: 2px 2px 0 #000000;
}



/* Skin Popup */
.skin-popup {
  max-width: 930px;
}

.skin-categories {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.category-tabs {
  display: flex;
  gap: 8px;
  border-bottom: 2px solid #333;
  padding-bottom: 8px;
}

.category-tab {
  background: rgba(0, 0, 0, 0.3);
  border: 2px solid #333;
  border-bottom: none;
  color: #aaaaaa;
  padding: 10px 16px;
  cursor: pointer;
  font-family: 'Press Start 2P', monospace;
  font-size: clamp(9px, 2vw, 11px);
  border-radius: 8px 8px 0 0;
  transition: all 0.2s ease;
}

.category-tab.active {
  background: rgba(0, 119, 255, 0.2);
  color: #00bfff;
  border-color: #00bfff;
}

.skin-category {
  display: none;
}

.skin-category.active {
  display: block;
}

.skin-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 20px;
  padding: 20px;
}

@media (max-width: 768px) {
  .skin-grid {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 16px;
    padding: 16px;
  }
}

@media (max-width: 480px) {
  .skin-grid {
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 12px;
    padding: 12px;
  }
}

.skin-item {
  background: rgba(0, 0, 0, 0.5);
  border: 2px solid #333;
  border-radius: 12px;
  overflow: hidden;
  transition: all 0.3s ease;
  display: flex;
  flex-direction: column;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

.skin-item:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 16px rgba(0, 187, 255, 0.3);
  border-color: #00bfff;
}

.skin-preview {
  position: relative;
  height: 120px;
  background: #1a1a2e;
  display: flex;
  align-items: center;
  justify-content: center;
}

.skin-image {
  width: 100%;
  height: 140px;
  object-fit: contain;
  background: linear-gradient(135deg, rgba(0, 187, 255, 0.1), rgba(0, 119, 255, 0.1));
  transition: transform 0.3s ease;
}

.skin-item:hover .skin-image {
  transform: scale(1.05);
}

@media (max-width: 480px) {
  .skin-image {
    height: 120px;
  }
}

.skin-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 9px;
  font-weight: bold;
  text-shadow: 1px 1px 0 #000;
}

.skin-badge.owned {
  background: #4CAF50;
  color: white;
}

.skin-badge.premium {
  background: #ffd700;
  color: #000;
}

.skin-badge.exclusive {
  background: #9c27b0;
  color: white;
}

.skin-info {
  padding: 12px;
}

.skin-name {
  color: #ffffff;
  font-size: clamp(10px, 2.5vw, 12px);
  margin-bottom: 4px;
}

.skin-description {
  color: #aaaaaa;
  font-size: clamp(8px, 2vw, 10px);
  margin-bottom: 8px;
}

.skin-price {
  display: flex;
  align-items: center;
  gap: 6px;
  color: #ffd700;
  font-size: clamp(9px, 2vw, 11px);
}

.skin-actions {
  padding: 0 12px 12px;
  min-height: 40px;
  display: flex;
  align-items: flex-end;
}

.btn-skin {
  width: 100%;
  min-height: 36px;
  padding: 8px 12px;
  border: none;
  border-radius: 6px;
  font-family: 'Press Start 2P', monospace;
  font-size: clamp(8px, 2vw, 10px);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.2s ease;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.btn-equip {
  background: #ffd700;
  color: #000;
  border: 2px solid #ffd700;
  box-shadow: 0 3px 0 #ccaa00;
}

.btn-equip:hover {
  background: #ffed4e;
  border-color: #ffed4e;
}

.btn-buy {
  background: #ff4d4d;
  color: white;
  border: 2px solid #ff4d4d;
  box-shadow: 0 3px 0 #cc0000;
}

.btn-buy:hover {
  transform: translateY(-2px);
  box-shadow: 0 5px 0 #663333;
}

.btn-buy:active {
  transform: translateY(1px);
  box-shadow: 0 2px 0 #663333;
}

.btn-select {
  background: linear-gradient(135deg, #4CAF50, #45a049);
  color: white;
  border: 2px solid #2E7D32;
  box-shadow: 0 3px 0 #1B5E20;
}

.btn-select:hover {
  transform: translateY(-2px);
  box-shadow: 0 5px 0 #1B5E20;
}

.btn-select:active {
  transform: translateY(1px);
  box-shadow: 0 2px 0 #1B5E20;
}

/* Level Up Button */
.btn-levelup {
  background: linear-gradient(135deg, #9c27b0, #7b1fa2);
  color: white;
  border: 2px solid #6a1b9a;
  box-shadow: 0 3px 0 #4a148c;
}

.btn-levelup:hover {
  transform: translateY(-2px);
  box-shadow: 0 5px 0 #4a148c;
  background: linear-gradient(135deg, #ab47bc, #9c27b0);
}

.btn-levelup:active {
  transform: translateY(1px);
  box-shadow: 0 2px 0 #4a148c;
}

.transaction-section {
  margin-top: 24px;
  padding: 20px;
  border-top: 2px solid #333;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 12px;
  animation: slideDown 0.3s ease;
}

/* transaction-section is always displayed */

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

.transaction-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.form-group label {
  color: #ffffff;
  font-size: clamp(10px, 2.5vw, 12px);
  text-align: left;
}

.transaction-input, .skin-select {
  background: rgba(0, 0, 0, 0.3);
  border: 2px solid #333;
  border-radius: 8px;
  padding: 12px;
  color: #ffffff;
  font-family: 'Press Start 2P', monospace;
  font-size: clamp(9px, 2vw, 11px);
  transition: border-color 0.2s ease;
  width: 100%;
}

.transaction-input:focus, .skin-select:focus {
  outline: none;
  border-color: #00bfff;
}

.transaction-input:disabled, .skin-select:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.skin-select {
  cursor: pointer;
}

.skin-select option {
  background: #1a1a2e;
  color: #ffffff;
  padding: 8px;
}

.btn-verify:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-verify {
  background: linear-gradient(135deg, #4CAF50, #45a049);
  color: white;
  border: none;
  padding: 12px 20px;
  border-radius: 8px;
  font-family: 'Press Start 2P', monospace;
  font-size: clamp(10px, 2.5vw, 12px);
  cursor: pointer;
  border: 2px solid #2E7D32;
  box-shadow: 0 4px 0 #1B5E20;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn-verify:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 0 #1B5E20;
}

.btn-verify:active {
  transform: translateY(1px);
  box-shadow: 0 2px 0 #1B5E20;
}

/* Portrait Warning */
#portrait-warning {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, #0a0a14 0%, #1a1a2e 100%);
  z-index: 10000;
  justify-content: center;
  align-items: center;
  color: #ffffff;
  padding: 20px;
  text-align: center;
  flex-direction: column;
}

.warning-content h2 {
  color: #ffd700;
  margin-bottom: 20px;
  font-size: clamp(18px, 5vw, 24px);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.warning-content p {
  margin-bottom: 30px;
  font-size: clamp(12px, 3vw, 16px);
  color: #cccccc;
}

.rotate-icon {
  font-size: 60px;
  color: #00bfff;
  animation: rotate 2s infinite linear;
}

@keyframes rotate {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

@media (orientation: portrait) {
  #portrait-warning {
    display: flex;
  }
  
  #game-container {
    display: none !important;
  }
  
  body {
    overflow: hidden;
  }
}

/* Also check by width/height ratio for better detection */
@media (max-aspect-ratio: 1/1) {
  #portrait-warning {
    display: flex;
  }
  
  #game-container {
    display: none !important;
  }
  
  body {
    overflow: hidden;
  }
}

/* Responsive Design */
@media (max-width: 1024px) {
  .side-buttons-container {
    padding: 0 1.5%;
  }
  
  .side-column {
    gap: 8px;
  }
  
  .btn-feature {
    width: clamp(90px, 13vw, 140px);
    min-height: 50px;
    padding: 10px 12px;
    font-size: clamp(7px, 1.3vw, 10px);
  }
  
  .btn-icon {
    font-size: clamp(14px, 2.5vw, 18px);
  }
  
  .skin-grid {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  }
}

@media (max-width: 768px) {
  .side-buttons-container {
    padding: 0 1%;
  }
  
  .side-column {
    gap: 6px;
    height: 90%;
  }
  
  .btn-feature {
    width: clamp(80px, 12vw, 120px);
    min-height: 45px;
    padding: 8px 10px;
    font-size: clamp(6px, 1.2vw, 9px);
    border-radius: 8px;
    box-shadow: 0 3px 0 #1a1a3a;
  }
  
  .btn-icon {
    font-size: clamp(12px, 2vw, 16px);
  }
  
  .btn-main {
    padding: 14px 24px;
    font-size: clamp(12px, 2.5vw, 16px);
  }
  
  .popup-content {
    width: 95%;
  }
  
  .profile-header {
    flex-direction: column;
    text-align: center;
    gap: 16px;
  }
  
  .profile-info {
    text-align: center;
  }
  
  .skin-grid {
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  }
  
  .category-tabs {
    flex-wrap: wrap;
    gap: 4px;
  }
  
  .category-tab {
    padding: 8px 12px;
    font-size: clamp(7px, 1.5vw, 9px);
  }
}

@media (max-width: 600px) {
  .side-column {
    gap: 4px;
    height: 92%;
  }
  
  .btn-feature {
    width: clamp(70px, 11vw, 100px);
    min-height: 40px;
    padding: 6px 8px;
    font-size: clamp(5px, 1vw, 8px);
    border-width: 1px;
    box-shadow: 0 2px 0 #1a1a3a;
  }
  
  .btn-icon {
    font-size: clamp(10px, 1.8vw, 14px);
  }
  
  .title {
    font-size: clamp(20px, 5vw, 32px);
  }
  
  .instructions {
    padding: 12px 16px;
    font-size: clamp(8px, 2vw, 12px);
    margin-bottom: 20px;
  }
  
  .btn-main {
    padding: 12px 20px;
    font-size: clamp(10px, 2vw, 14px);
    box-shadow: 0 4px 0 #663333;
  }
}

@media (max-width: 480px) {
  .side-buttons-container {
    padding: 0 0.5%;
  }
  
  .side-column {
    gap: 3px;
  }
  
  .btn-feature {
    width: clamp(60px, 10vw, 90px);
    min-height: 36px;
    padding: 5px 6px;
    font-size: clamp(4px, 0.9vw, 7px);
  }
  
  .btn-icon {
    font-size: clamp(9px, 1.5vw, 12px);
  }
  
  .btn-main {
    padding: 10px 18px;
    font-size: clamp(9px, 1.8vw, 12px);
    box-shadow: 0 3px 0 #663333;
  }
  
  .score-display {
    flex-direction: column;
    gap: 20px;
  }
  
  .action-buttons {
    flex-direction: column;
    gap: 12px;
  }
  
  .quest-item {
    flex-direction: column;
    gap: 12px;
    text-align: center;
  }
  
  .quest-info {
    text-align: center;
  }
  
  .profile-stats {
    grid-template-columns: 1fr;
    gap: 12px;
  }
  
  .skin-grid {
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 12px;
  }
  
  .skin-preview {
    height: 100px;
  }
}

@media (max-height: 600px) {
  .side-column {
    height: 80%;
  }
  
  .btn-feature {
    height: 50px;
    padding: 10px 12px;
  }
  
  .btn-main {
    padding: 14px 24px;
  }
  
  .title {
    margin-bottom: 16px;
  }
  
  .instructions {
    margin-bottom: 20px;
    padding: 12px 18px;
  }
}

@media (max-width: 600px) {
  .popup-content {
    width: 96%;
    max-height: 88vh;
    border-width: 2px;
    border-radius: 10px;
    box-shadow: 0 0 25px rgba(0, 191, 255, 0.35), 0 4px 0 #003366;
    margin: 5px;
  }

  .popup-header {
    padding: 10px 12px;
  }

  .popup-header h2 {
    font-size: clamp(11px, 3vw, 14px);
    gap: 5px;
  }

  .popup-close {
    width: 28px;
    height: 28px;
    font-size: 16px;
  }

  .popup-body {
    padding: 10px 12px;
    max-height: calc(88vh - 100px);
  }

  .popup-footer {
    padding: 10px 12px;
  }
}

@media (max-width: 360px) {
  .popup-content {
    width: 98%;
    max-height: 90vh;
    margin: 2px;
  }
  
  .popup-header {
    padding: 8px 10px;
  }

  .popup-header h2 {
    font-size: clamp(10px, 2.8vw, 12px);
  }

  .popup-close {
    width: 24px;
    height: 24px;
    font-size: 14px;
  }

  .popup-body {
    padding: 8px 10px;
    max-height: calc(90vh - 90px);
  }
  
  .popup-footer {
    padding: 8px 10px;
  }
}

@media (max-height: 600px) {
  .popup-content {
    max-height: 92vh;
  }

  .popup-body {
    max-height: calc(92vh - 100px);
  }
  
  .popup-header {
    padding: 8px 12px;
  }
  
  .popup-footer {
    padding: 8px 12px;
  }
}

/* Scrollbar Styling */
.popup-body::-webkit-scrollbar {
  width: 8px;
}

.popup-body::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.2);
  border-radius: 4px;
}

.popup-body::-webkit-scrollbar-thumb {
  background: #00bfff;
  border-radius: 4px;
}

.popup-body::-webkit-scrollbar-thumb:hover {
  background: #0077ff;
}



/* Referral section styles */
.referral-section {
  margin-top: 20px;
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.referral-code-box,
.referrals-box {
  background: rgba(0, 119, 255, 0.1);
  border-radius: 10px;
  padding: 15px;
  border: 2px solid #0077ff;
}

.referral-label,
.referrals-label {
  display: block;
  text-align: center;
  color: #ffd700; /* Yellow for title */
  font-size: 10px;
  margin-bottom: 10px;
}

.code-container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #0077ff; /* Blue for background */
  border-radius: 5px;
  padding: 8px 12px;
}

.referral-code {
  color: #ffffff; /* White for code text */
  font-size: 12px;
  font-weight: bold;
}

.btn-copy {
  background: #ffffff; /* White for button */
  border: none;
  color: #0077ff; /* Blue for icon */
  padding: 5px 8px;
  border-radius: 3px;
  cursor: pointer;
  font-size: 10px;
}

.referrals-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.referral-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px;
  background: rgba(0, 119, 255, 0.2); /* Light blue */
  border-radius: 5px;
}

.referral-user i {
  color: #0077ff; /* Blue for icon */
  font-size: 12px;
}

.username {
  color: #ffffff; /* White for username */
  font-size: 11px;
}

/* Withdraw Popup Responsive */
.withdraw-popup {
  max-width: 500px;
}

@media (max-width: 768px) {
  .withdraw-popup {
    max-width: 90vw;
  }
}

@media (max-width: 480px) {
  .withdraw-popup {
    max-width: 95vw;
  }
}

/* Landscape Mode Adjustments */
@media (orientation: landscape) and (max-height: 500px) {
  .popup-content {
    max-height: 95vh;
  }
  
  .popup-body {
    max-height: calc(95vh - 100px);
    overflow-y: auto;
  }
  
  .popup-overlay {
    display: flex;
    align-items: center;
    justify-content: center;
  }
}

/* Portrait Mode - Game Disabled */
@media (orientation: portrait) and (max-width: 768px) {
  #game-canvas {
    opacity: 0.3;
    pointer-events: none;
  }
}

/* Battle UI */
#battle-stage.hidden { display: none; }
#battle-stage {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 20;
  pointer-events: auto;
}
.battle-hud {
  position: absolute;
  top: 10px;
  left: 0;
  width: 100%;
  display: flex;
  justify-content: space-between;
  padding: 0 20px;
  z-index: 2;
}
.battle-side-label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: rgba(0, 0, 0, 0.35);
  border: 2px solid #333;
  border-radius: 8px;
  padding: 8px 12px;
}
.battle-split {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: grid;
  grid-template-columns: 1fr 1fr;
}
.battle-split canvas {
  position: relative; /* override global canvas absolute positioning */
  width: 100%;
  height: 100%;
  display: block;
}
.battle-split::before {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  width: 4px;
  height: 100%;
  background: rgba(255, 77, 77, 0.9);
  box-shadow: 0 0 12px rgba(255, 77, 77, 0.7);
}

#battle-left-name {
  font-size: clamp(18px, 3.2vw, 26px);
  color: #ff4d4d;
}

.stake-options { display: flex; gap: 8px; flex-wrap: wrap; }
.stake-options .btn-secondary.selected { box-shadow: 0 0 0 3px rgba(0, 191, 255, 0.4) inset; }

/* Battle countdown overlay */
.battle-countdown {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.4);
  z-index: 3;
  pointer-events: none;
}
.battle-countdown-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.battle-countdown .count-num {
  font-size: clamp(28px, 8vw, 64px);
  color: #ffd700;
  text-shadow: 3px 3px 0 #000000, 0 0 15px rgba(255, 215, 0, 0.5);
}
.battle-countdown .count-sub {
  font-size: clamp(12px, 3vw, 16px);
  color: #ffffff;
  opacity: 0.9;
}

.matching-spinner {
  width: 48px;
  height: 48px;
  border: 4px solid rgba(255,255,255,0.15);
  border-top-color: #00bfff;
  border-radius: 50%;
  margin: 0 auto;
  animation: spinner-rot 1s linear infinite;
}
@keyframes spinner-rot { to { transform: rotate(360deg); } }

/* ==================== TELEGRAM REDIRECT PAGE ==================== */
#telegram-redirect-page {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, #0a0a1a 0%, #1a1a3e 50%, #0d1b2a 100%);
  z-index: 99999;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
}

#telegram-redirect-page::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: 
    radial-gradient(circle at 20% 80%, rgba(0, 191, 255, 0.1) 0%, transparent 50%),
    radial-gradient(circle at 80% 20%, rgba(55, 174, 226, 0.1) 0%, transparent 50%),
    radial-gradient(circle at 50% 50%, rgba(0, 119, 255, 0.05) 0%, transparent 70%);
  pointer-events: none;
}

.telegram-redirect-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100%;
  padding: 20px;
  position: relative;
  z-index: 1;
}

.telegram-redirect-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  max-width: 500px;
  width: 100%;
  animation: fadeInUp 0.8s ease-out;
}

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

.telegram-logo-wrapper {
  position: relative;
  width: 120px;
  height: 120px;
  margin-bottom: 24px;
}

.telegram-logo-glow {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 160px;
  height: 160px;
  background: radial-gradient(circle, rgba(55, 174, 226, 0.4) 0%, transparent 70%);
  border-radius: 50%;
  animation: pulseGlow 2s ease-in-out infinite;
}

@keyframes pulseGlow {
  0%, 100% { transform: translate(-50%, -50%) scale(1); opacity: 0.6; }
  50% { transform: translate(-50%, -50%) scale(1.2); opacity: 0.3; }
}

.telegram-logo {
  position: relative;
  width: 100%;
  height: 100%;
  filter: drop-shadow(0 8px 24px rgba(55, 174, 226, 0.4));
  animation: floatLogo 3s ease-in-out infinite;
}

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

.redirect-title {
  font-size: clamp(28px, 6vw, 42px);
  color: #ffd700;
  margin-bottom: 8px;
  text-shadow: 3px 3px 0 #000, 0 0 20px rgba(255, 215, 0, 0.4);
  letter-spacing: 2px;
}

.redirect-subtitle {
  font-family: 'Press Start 2P', monospace;
  font-size: clamp(10px, 2.5vw, 14px);
  color: #00bfff;
  margin-bottom: 32px;
  opacity: 0.9;
  text-shadow: 1px 1px 0 #000;
}

.redirect-message {
  background: rgba(0, 119, 255, 0.1);
  border: 2px solid rgba(0, 191, 255, 0.3);
  border-radius: 16px;
  padding: 24px;
  margin-bottom: 28px;
  backdrop-filter: blur(10px);
  max-width: 400px;
}

.message-icon {
  width: 56px;
  height: 56px;
  background: linear-gradient(135deg, #00bfff, #0077ff);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
  box-shadow: 0 4px 16px rgba(0, 191, 255, 0.4);
}

.message-icon i {
  font-size: 24px;
  color: #fff;
}

.redirect-message p {
  font-family: 'Press Start 2P', monospace;
  font-size: clamp(9px, 2vw, 12px);
  color: #fff;
  line-height: 1.8;
  margin: 0;
}

.redirect-message .message-small {
  font-size: clamp(8px, 1.8vw, 10px);
  color: #aaa;
  margin-top: 12px;
}

.telegram-button {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  background: linear-gradient(135deg, #37aee2, #1e96c8);
  color: #fff;
  font-family: 'Press Start 2P', monospace;
  font-size: clamp(12px, 2.5vw, 16px);
  padding: 18px 36px;
  border-radius: 50px;
  text-decoration: none;
  border: 3px solid #1e96c8;
  box-shadow: 0 8px 0 #0d6e94, 0 12px 30px rgba(55, 174, 226, 0.4);
  transition: all 0.2s ease;
  position: relative;
  overflow: hidden;
}

.telegram-button::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
  transition: left 0.6s ease;
}

.telegram-button:hover::before {
  left: 100%;
}

.telegram-button:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 0 #0d6e94, 0 16px 40px rgba(55, 174, 226, 0.5);
  background: linear-gradient(135deg, #4db8e8, #2aa3d5);
}

.telegram-button:active {
  transform: translateY(2px);
  box-shadow: 0 4px 0 #0d6e94, 0 6px 15px rgba(55, 174, 226, 0.3);
}

.telegram-button i {
  font-size: 24px;
}

.redirect-features {
  display: flex;
  gap: 24px;
  margin-top: 36px;
  flex-wrap: wrap;
  justify-content: center;
}

.feature-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 16px 20px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  min-width: 100px;
  transition: all 0.3s ease;
}

.feature-item:hover {
  background: rgba(0, 191, 255, 0.1);
  border-color: rgba(0, 191, 255, 0.3);
  transform: translateY(-4px);
}

.feature-item i {
  font-size: 24px;
  color: #ffd700;
}

.feature-item span {
  font-family: 'Press Start 2P', monospace;
  font-size: 9px;
  color: #ccc;
}

.redirect-footer {
  margin-top: 40px;
  text-align: center;
}

.redirect-footer p {
  font-family: 'Press Start 2P', monospace;
  font-size: 9px;
  color: #555;
}

/* Telegram redirect responsive */
@media (max-width: 480px) {
  .telegram-logo-wrapper {
    width: 100px;
    height: 100px;
  }
  
  .telegram-logo-glow {
    width: 130px;
    height: 130px;
  }
  
  .redirect-message {
    padding: 20px 16px;
  }
  
  .telegram-button {
    padding: 14px 28px;
    font-size: 11px;
  }
  
  .redirect-features {
    gap: 12px;
  }
  
  .feature-item {
    min-width: 80px;
    padding: 12px 16px;
  }
  
  .feature-item i {
    font-size: 20px;
  }
  
  .feature-item span {
    font-size: 8px;
  }
}
