/* ШЛЯПГРЕЙДЕР - Pirate Upgrader Stylesheet */
:root {
  --bg-main: #0c0e14;
  --bg-card: #131722;
  --bg-card-hover: #191e2c;
  --bg-secondary: #171b26;
  --bg-slot: #0f121a;
  
  --gold-primary: #f5b800;
  --gold-light: #ffd700;
  --gold-glow: rgba(245, 184, 0, 0.35);
  --gold-gradient: linear-gradient(135deg, #f5b800 0%, #e69500 100%);
  --gold-border: rgba(245, 184, 0, 0.25);
  
  --text-primary: #ffffff;
  --text-secondary: #8c93a8;
  --text-muted: #535a6e;
  
  --win-green: #2ecc71;
  --loss-red: #e74c3c;
  
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-pill: 9999px;
  
  --font-main: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-display: 'Rajdhani', -apple-system, sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  background-color: var(--bg-main);
  background-image: 
    radial-gradient(circle at 50% 10%, rgba(245, 184, 0, 0.07) 0%, transparent 50%),
    radial-gradient(circle at 80% 80%, rgba(20, 26, 40, 0.8) 0%, transparent 60%);
  color: var(--text-primary);
  font-family: var(--font-main);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  overflow-x: hidden;
  user-select: none;
}

/* Container tuned for Telegram Mini App and Mobile View */
.app-container {
  width: 100%;
  max-width: 460px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg-main);
  box-shadow: 0 0 50px rgba(0, 0, 0, 0.8);
  position: relative;
  padding-bottom: 24px;
}

/* Header */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: rgba(15, 18, 26, 0.85);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 100;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

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

.logo-chevron {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.chevron-arrow {
  width: 18px;
  height: 9px;
  clip-path: polygon(50% 0%, 100% 100%, 80% 100%, 50% 35%, 20% 100%, 0% 100%);
  background: var(--gold-gradient);
}

.logo-text {
  font-size: 1.15rem;
  font-weight: 900;
  letter-spacing: 1px;
  color: #fff;
  text-transform: uppercase;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Turbo Toggle Button */
.turbo-toggle-btn {
  background: var(--bg-secondary);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-secondary);
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1.1rem;
  transition: all 0.2s ease;
}

.turbo-toggle-btn.active {
  background: rgba(245, 184, 0, 0.18);
  border-color: var(--gold-primary);
  color: var(--gold-primary);
  box-shadow: 0 0 12px var(--gold-glow);
}

/* Header Balance Badge */
.header-balance {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(245, 184, 0, 0.1);
  border: 1px solid var(--gold-border);
  padding: 6px 12px;
  border-radius: var(--radius-pill);
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--gold-light);
}

.coin-icon-sm {
  width: 18px;
  height: 18px;
  object-fit: contain;
}

/* Live Feed Ticker */
.live-feed-bar {
  display: flex;
  align-items: center;
  overflow-x: auto;
  gap: 8px;
  padding: 6px 14px;
  background: #0e111a;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  scrollbar-width: none;
}
.live-feed-bar::-webkit-scrollbar {
  display: none;
}

.feed-item {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-secondary);
  border-radius: var(--radius-sm);
  padding: 4px 8px;
  font-size: 0.75rem;
  white-space: nowrap;
  border-left: 2px solid var(--gold-primary);
}
.feed-item.loss {
  border-left-color: var(--loss-red);
  opacity: 0.6;
}
.feed-item-img {
  width: 20px;
  height: 20px;
  object-fit: contain;
}

/* Wheel Arena Section */
.arena-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 18px 16px 12px;
  position: relative;
}

.wheel-container {
  width: 250px;
  height: 250px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 18px;
}

/* SVG Wheel */
.wheel-svg {
  width: 100%;
  height: 100%;
}

.wheel-track {
  fill: none;
  stroke: rgba(255, 255, 255, 0.05);
  stroke-width: 16;
}

.wheel-ticks {
  fill: none;
  stroke: rgba(255, 255, 255, 0.12);
  stroke-width: 1.5;
}

.wheel-win-arc {
  fill: none;
  stroke: url(#goldArcGradient);
  stroke-width: 16;
  stroke-linecap: round;
  transition: stroke-dasharray 0.35s ease, transform 0.35s ease;
  filter: drop-shadow(0 0 8px rgba(245, 184, 0, 0.6));
}

/* Center Emblem */
.wheel-center {
  position: absolute;
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: radial-gradient(circle, #1a1e2b 0%, #0e111a 90%);
  border: 2px solid rgba(245, 184, 0, 0.3);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 25px rgba(0, 0, 0, 0.8), inset 0 0 15px rgba(0, 0, 0, 0.7);
  z-index: 5;
}

.wheel-center-logo {
  display: flex;
  flex-direction: column;
  gap: 3px;
  align-items: center;
  margin-bottom: 4px;
}

.center-chevron {
  width: 24px;
  height: 12px;
  clip-path: polygon(50% 0%, 100% 100%, 80% 100%, 50% 35%, 20% 100%, 0% 100%);
  background: var(--gold-gradient);
}

.chance-display {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--gold-light);
  letter-spacing: 0.5px;
  text-shadow: 0 0 10px rgba(245, 184, 0, 0.4);
}

.multiplier-display {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
}

/* Needle / Pointer */
.wheel-pointer {
  position: absolute;
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
  pointer-events: none;
  z-index: 10;
  display: flex;
  justify-content: center;
  align-items: flex-end;
}

.pointer-arrow {
  width: 0;
  height: 0;
  border-left: 9px solid transparent;
  border-right: 9px solid transparent;
  border-bottom: 22px solid #ffcc00;
  filter: drop-shadow(0 0 8px #ffb700);
  transform: translateY(6px);
}

/* Dual Item Selection Pods */
.slots-row {
  display: flex;
  width: 100%;
  gap: 10px;
  margin-bottom: 14px;
}

.slot-box {
  flex: 1;
  min-height: 155px;
  background: var(--bg-slot);
  border: 1px dashed rgba(255, 255, 255, 0.15);
  border-radius: var(--radius-md);
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 10px;
  cursor: pointer;
  transition: all 0.2s ease;
  overflow: hidden;
}

.slot-box:hover {
  border-color: rgba(245, 184, 0, 0.4);
  background: rgba(20, 25, 38, 0.7);
}

.slot-box.active {
  border: 1px solid var(--gold-primary);
  background: var(--bg-card);
  box-shadow: 0 0 15px rgba(245, 184, 0, 0.15);
}

.slot-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 8px;
  opacity: 0.7;
}

.slot-watermark {
  width: 42px;
  height: 42px;
  opacity: 0.25;
  filter: grayscale(1);
}

.slot-title {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-secondary);
}

.slot-hint {
  font-size: 0.68rem;
  color: var(--text-muted);
}

/* Remove button on filled slot */
.slot-remove-btn {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 24px;
  height: 24px;
  background: rgba(0, 0, 0, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  cursor: pointer;
  z-index: 10;
  transition: all 0.15s ease;
}
.slot-remove-btn:hover {
  background: var(--loss-red);
  border-color: var(--loss-red);
}

/* Upgrade Action Button (ВЫШЛЯПКА) */
.upgrade-action-btn {
  width: 100%;
  height: 52px;
  background: var(--gold-gradient);
  border: none;
  border-radius: var(--radius-md);
  color: #0b0c10;
  font-size: 1.1rem;
  font-weight: 900;
  letter-spacing: 1px;
  text-transform: uppercase;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  box-shadow: 0 4px 20px var(--gold-glow);
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.upgrade-action-btn:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 6px 25px rgba(245, 184, 0, 0.55);
}

.upgrade-action-btn:active:not(:disabled) {
  transform: translateY(1px);
}

.upgrade-action-btn:disabled {
  background: #252a38;
  color: #5d6478;
  box-shadow: none;
  cursor: not-allowed;
}

.btn-chevron {
  width: 14px;
  height: 7px;
  clip-path: polygon(50% 0%, 100% 100%, 80% 100%, 50% 35%, 20% 100%, 0% 100%);
  background: currentColor;
}

/* Lower Section: Tabs & Grids */
.tabs-section {
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Main Segmented Control */
.main-tabs-nav {
  display: flex;
  background: #0f121a;
  border-radius: var(--radius-md);
  padding: 4px;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.main-tab-btn {
  flex: 1;
  padding: 10px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 700;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: center;
}

.main-tab-btn.active {
  background: var(--bg-card);
  color: #fff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
}

/* Sub-pills (Инвентарь / Магазин) */
.sub-tabs-nav {
  display: flex;
  gap: 8px;
}

.sub-tab-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-pill);
  background: var(--bg-secondary);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.sub-tab-pill.active {
  background: var(--gold-gradient);
  border-color: var(--gold-primary);
  color: #0d0f17;
  font-weight: 800;
}

/* Shop Info Banner with User Balance */
.shop-balance-card {
  background: linear-gradient(135deg, #1b2030 0%, #131724 100%);
  border: 1px solid var(--gold-border);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
}

.shop-balance-left {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.shop-balance-label {
  font-size: 0.75rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.shop-balance-val {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 1.35rem;
  font-weight: 900;
  color: var(--gold-light);
}

.shop-balance-val img {
  width: 26px;
  height: 26px;
  object-fit: contain;
}

.shop-badge {
  background: rgba(245, 184, 0, 0.15);
  color: var(--gold-light);
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  font-size: 0.75rem;
  font-weight: 700;
  border: 1px solid var(--gold-border);
}

/* Filter & Search Bar for Desired Items */
.filters-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}

.search-input {
  flex: 1;
  background: var(--bg-card);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  color: #fff;
  font-size: 0.85rem;
  outline: none;
}
.search-input:focus {
  border-color: var(--gold-primary);
}

.sort-select {
  background: var(--bg-card);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  color: #fff;
  font-size: 0.85rem;
  outline: none;
  cursor: pointer;
}

/* Grid of Items */
.items-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

/* Item Card (Strict replication of original Upgrader card) */
.item-card {
  background: var(--bg-card);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: var(--radius-md);
  padding: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
  overflow: hidden;
}

.item-card:hover {
  transform: translateY(-2px);
  border-color: rgba(245, 184, 0, 0.4);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
}

.item-card.selected {
  border: 2px solid var(--gold-primary);
  background: rgba(245, 184, 0, 0.06);
  box-shadow: 0 0 14px var(--gold-glow);
}

/* Card Top: Price + Coin */
.card-top {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  margin-bottom: 6px;
}

.card-price {
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--gold-light);
  letter-spacing: 0.3px;
}

.card-coin-icon {
  width: 16px;
  height: 16px;
  object-fit: contain;
}

/* Card Middle: Image with radial background glow */
.card-img-wrapper {
  width: 100%;
  height: 110px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  margin: 4px 0 8px;
}

.card-img-glow {
  position: absolute;
  width: 70px;
  height: 70px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(245, 184, 0, 0.2) 0%, transparent 70%);
  pointer-events: none;
}

.card-img {
  max-width: 90%;
  max-height: 95px;
  object-fit: contain;
  z-index: 2;
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.5));
  transition: transform 0.2s ease;
}

.item-card:hover .card-img {
  transform: scale(1.05);
}

/* Card Bottom: Category + Name */
.card-bottom {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 2px;
}

.card-category {
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.3px;
}

.card-title {
  font-size: 0.88rem;
  font-weight: 800;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

/* Buy Button inside shop cards */
.card-buy-btn {
  margin-top: 8px;
  width: 100%;
  padding: 6px 0;
  background: var(--gold-gradient);
  border: none;
  border-radius: var(--radius-sm);
  color: #0b0d14;
  font-size: 0.82rem;
  font-weight: 800;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  transition: all 0.15s ease;
}
.card-buy-btn:hover {
  filter: brightness(1.1);
}

/* Empty State Message */
.empty-state {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 36px 16px;
  text-align: center;
  gap: 12px;
  background: rgba(18, 22, 33, 0.5);
  border-radius: var(--radius-md);
  border: 1px dashed rgba(255, 255, 255, 0.1);
}
.empty-state-icon {
  font-size: 2.2rem;
  opacity: 0.6;
}
.empty-state-text {
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.4;
}
.empty-state-btn {
  background: var(--gold-gradient);
  border: none;
  padding: 8px 18px;
  border-radius: var(--radius-pill);
  color: #0b0d14;
  font-size: 0.85rem;
  font-weight: 800;
  cursor: pointer;
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 1000;
  width: 90%;
  max-width: 380px;
  pointer-events: none;
}

.toast {
  background: #181d2c;
  border-left: 4px solid var(--gold-primary);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  color: #fff;
  font-size: 0.85rem;
  font-weight: 600;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: space-between;
  animation: toastIn 0.3s ease forwards;
}

.toast.success {
  border-left-color: var(--win-green);
}

.toast.error {
  border-left-color: var(--loss-red);
}

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

/* Win Overlay Modal */
.result-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(5, 7, 12, 0.85);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.result-modal.show {
  opacity: 1;
  pointer-events: auto;
}

.result-card {
  background: #141824;
  border: 1px solid var(--gold-border);
  border-radius: var(--radius-lg);
  padding: 24px 20px;
  width: 88%;
  max-width: 340px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  position: relative;
  box-shadow: 0 0 40px rgba(0, 0, 0, 0.9);
  transform: scale(0.9);
  transition: transform 0.3s cubic-bezier(0.18, 0.89, 0.32, 1.28);
}

.result-modal.show .result-card {
  transform: scale(1);
}

.result-title {
  font-size: 1.4rem;
  font-weight: 900;
  margin-bottom: 8px;
  letter-spacing: 0.5px;
}

.result-card.won .result-title {
  color: var(--gold-light);
  text-shadow: 0 0 15px rgba(245, 184, 0, 0.5);
}

.result-card.lost .result-title {
  color: var(--loss-red);
}

.result-img-box {
  width: 140px;
  height: 140px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 12px 0;
  position: relative;
}

.result-img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 8px 16px rgba(0, 0, 0, 0.6));
}

.result-item-name {
  font-size: 1.1rem;
  font-weight: 800;
  margin-bottom: 4px;
}

.result-item-price {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 1rem;
  font-weight: 700;
  color: var(--gold-light);
  margin-bottom: 16px;
}

.result-close-btn {
  width: 100%;
  height: 44px;
  background: var(--gold-gradient);
  border: none;
  border-radius: var(--radius-md);
  color: #0c0e14;
  font-size: 0.95rem;
  font-weight: 800;
  cursor: pointer;
}

/* Unauthorized Direct Access Overlay */
.unauth-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: radial-gradient(circle at center, #171b26 0%, #0a0c12 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 99999;
  padding: 20px;
}

.unauth-card {
  background: #131722;
  border: 1px solid var(--gold-border);
  border-radius: var(--radius-lg);
  padding: 36px 24px;
  max-width: 380px;
  text-align: center;
  box-shadow: 0 0 50px rgba(0, 0, 0, 0.9), 0 0 20px var(--gold-glow);
  display: flex;
  flex-direction: column;
  align-items: center;
}

.unauth-skull {
  font-size: 3.5rem;
  margin-bottom: 12px;
  animation: pulse 2s infinite ease-in-out;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.08); }
}

.unauth-title {
  font-size: 1.25rem;
  font-weight: 900;
  color: var(--gold-light);
  letter-spacing: 0.5px;
  margin-bottom: 12px;
}

.unauth-text {
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: 24px;
}

.unauth-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  height: 48px;
  background: var(--gold-gradient);
  border-radius: var(--radius-md);
  color: #0b0c10;
  font-weight: 900;
  font-size: 1rem;
  text-decoration: none;
  box-shadow: 0 4px 15px var(--gold-glow);
  transition: transform 0.15s ease;
}

.unauth-btn:hover {
  transform: translateY(-2px);
}

