/* ================= CALCULATOR SPECIFIC STYLES ================= */

body {
  background: url('your-background.png') center/cover no-repeat fixed;
  background-color: #0f0f0f;
}

.page-wrapper {
  background: rgba(0, 0, 0, 0.6);
  min-height: 100vh;
}

.calculator-header {
  text-align: center;
  padding: clamp(30px, 2.5vw, 40px) clamp(20px, 1.7vw, 30px);
}

.calculator-title {
  font-size: clamp(28px, 2.4vw, 38px);
  font-weight: bold;
  margin-bottom: clamp(8px, 0.7vw, 10px);
}

.calculator-subtitle {
  font-size: clamp(13px, 1.1vw, 16px);
  opacity: 0.8;
  margin-bottom: clamp(20px, 1.7vw, 25px);
}

/* ================= HEADER CONTROLS ================= */
.header-controls {
  display: flex;
  gap: clamp(15px, 1.3vw, 20px);
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  margin-top: clamp(15px, 1.3vw, 20px);
}

/* ================= SCREENSHOT BUTTON ================= */
.screenshot-btn {
  background: linear-gradient(135deg, #3b0000, #5a0000);
  color: white;
  border: 2px solid rgba(255, 0, 0, 0.5);
  padding: clamp(8px, 0.7vw, 10px) clamp(20px, 1.7vw, 25px);
  border-radius: 6px;
  font-size: clamp(12px, 1vw, 14px);
  font-weight: bold;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: clamp(6px, 0.5vw, 8px);
  transition: all 0.3s;
}

.screenshot-btn:hover {
  background: linear-gradient(135deg, #5a0000, #7a0000);
  transform: translateY(-2px);
  box-shadow: 0 4px 15px rgba(255, 0, 0, 0.4);
}

.screenshot-btn:active { transform: translateY(0); }

.screenshot-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.screenshot-icon { font-size: clamp(16px, 1.4vw, 20px); }

/* ================= IMAGE TOGGLE SWITCH ================= */
.image-toggle-switch {
  background: #1a1a1a;
  border-radius: 50px;
  padding: 4px;
  display: flex;
  gap: 6px;
  border: 2px solid rgba(255, 0, 0, 0.3);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
}

.image-toggle-container {
  display: flex;
  justify-content: center;
  margin-top: clamp(15px, 1.3vw, 20px);
}

.toggle-option {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: #2a2a2a;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.3s;
  border: 3px solid transparent;
  padding: 6px;
}

.toggle-option:hover {
  background: #3a3a3a;
  transform: scale(1.05);
}

.toggle-option.active {
  background: linear-gradient(135deg, #3b0000, #5a0000);
  border-color: #ff0000;
  box-shadow: 0 0 15px rgba(255, 0, 0, 0.5);
}

.toggle-image {
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 50%;
}

/* ================= SCREENSHOT AREA ================= */
#screenshotArea {
  padding: clamp(20px, 1.7vw, 30px) clamp(20px, 1.7vw, 30px) clamp(8px, 0.7vw, 12px);
  max-width: 1400px;
  margin: 0 auto;
}

/* ================= TRADE CONTAINER ================= */
.trade-container {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: clamp(20px, 1.7vw, 30px);
  margin-bottom: clamp(20px, 1.7vw, 30px);
}

/* ================= TRADE BOXES ================= */
.trade-box {
  background: linear-gradient(to bottom, #2a2a2a, #1c1c1c);
  border-radius: 12px;
  padding: clamp(18px, 1.5vw, 24px);
  min-height: 300px;
  display: flex;
  flex-direction: column;
}

.trade-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: clamp(15px, 1.3vw, 20px);
  padding-bottom: clamp(10px, 0.9vw, 12px);
  border-bottom: 1px solid rgba(255,255,255,0.1);
}

.trade-header h2 { font-size: clamp(16px, 1.4vw, 20px); font-weight: bold; }

.clear-btn {
  background: rgba(255,0,0,0.2);
  color: white;
  border: 1px solid rgba(255,0,0,0.4);
  padding: clamp(5px, 0.4vw, 6px) clamp(10px, 0.9vw, 12px);
  border-radius: 4px;
  font-size: clamp(11px, 0.95vw, 13px);
  cursor: pointer;
  transition: all 0.2s;
}

.clear-btn:hover { background: rgba(255,0,0,0.4); }

/* ================= TRADE ITEMS AREA ================= */
.trade-items {
  flex: 1;
  display: flex;
  flex-wrap: wrap;
  gap: clamp(10px, 0.9vw, 12px);
  padding: clamp(10px, 0.9vw, 12px);
  background: rgba(0,0,0,0.3);
  border-radius: 8px;
  min-height: 200px;
  align-content: flex-start;
}

.empty-message {
  width: 100%;
  text-align: center;
  padding: clamp(40px, 3.3vw, 50px) 0;
  color: rgba(255,255,255,0.3);
  font-size: clamp(12px, 1vw, 14px);
}

.trade-items.has-items .empty-message { display: none; }

/* ================= TRADE ITEM CARD ================= */
.trade-item-card {
  background: #2a2a2a;
  border-radius: 8px;
  padding: clamp(8px, 0.7vw, 10px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(6px, 0.5vw, 8px);
  width: clamp(80px, 7vw, 100px);
  position: relative;
  animation: dropIn 0.3s ease;
}

@keyframes dropIn {
  from { opacity: 0; transform: translateY(-10px) scale(0.9); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.trade-item-card img {
  width: 100%;
  height: clamp(60px, 5.2vw, 75px);
  object-fit: contain;
  border-radius: 4px;
  pointer-events: none;
}

.trade-item-card .item-name {
  font-size: clamp(9px, 0.8vw, 11px);
  text-align: center;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.trade-item-card .item-value {
  font-size: clamp(10px, 0.9vw, 12px);
  font-weight: bold;
  color: #4caf50;
}

.trade-item-card .remove-btn {
  position: absolute;
  top: 2px;
  right: 2px;
  background: rgba(255,0,0,0.8);
  color: white;
  border: none;
  width: clamp(16px, 1.4vw, 20px);
  height: clamp(16px, 1.4vw, 20px);
  border-radius: 50%;
  font-size: clamp(10px, 0.9vw, 12px);
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
}

.trade-item-card:hover .remove-btn { display: flex; }

/* ================= TRADE TOTAL ================= */
.trade-total {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: clamp(12px, 1vw, 15px);
  margin-top: clamp(12px, 1vw, 15px);
  background: rgba(0,0,0,0.4);
  border-radius: 8px;
  font-size: clamp(13px, 1.1vw, 16px);
  font-weight: bold;
}

.total-value {
  color: #4caf50;
  font-size: clamp(16px, 1.4vw, 20px);
}

/* ================= WIN/LOSS INDICATOR ================= */
.win-loss-indicator {
  margin-top: clamp(10px, 0.9vw, 12px);
  padding: clamp(8px, 0.7vw, 10px);
  border-radius: 6px;
  text-align: center;
  font-size: clamp(12px, 1vw, 14px);
  font-weight: bold;
  opacity: 0;
  transition: opacity 0.3s;
}

.win-loss-indicator.active { opacity: 1; }

.win-loss-indicator.winning {
  background: rgba(0, 255, 0, 0.15);
  border: 1px solid rgba(0, 255, 0, 0.3);
  color: #00ff00;
}

.win-loss-indicator.losing {
  background: rgba(255, 0, 0, 0.15);
  border: 1px solid rgba(255, 0, 0, 0.3);
  color: #ff0000;
}

.win-loss-indicator.balanced {
  background: rgba(76, 175, 80, 0.15);
  border: 1px solid rgba(76, 175, 80, 0.3);
  color: #4caf50;
}

/* ================= BRANDING BOX (MIDDLE) ================= */
.trade-middle {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.branding-box {
  background: linear-gradient(to right, #3b0000, #1a0000);
  padding: clamp(20px, 1.7vw, 25px);
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(12px, 1vw, 15px);
  min-width: clamp(120px, 10vw, 150px);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(255, 0, 0, 0.3);
}

.brand-logo {
  width: clamp(50px, 4.2vw, 65px);
  height: auto;
  filter: drop-shadow(0 2px 8px rgba(255, 0, 0, 0.5));
}

.brand-url {
  font-size: clamp(11px, 0.95vw, 13px);
  font-weight: bold;
  color: rgba(255, 255, 255, 0.9);
  text-align: center;
  letter-spacing: 0.5px;
}

/* ================= ITEMS SECTION ================= */
.items-section {
  padding: clamp(30px, 2.5vw, 40px) clamp(20px, 1.7vw, 30px);
  max-width: 1400px;
  margin: 0 auto;
}

.items-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: clamp(20px, 1.7vw, 25px);
  gap: clamp(15px, 1.3vw, 20px);
}

.items-header h3 { font-size: clamp(18px, 1.5vw, 22px); font-weight: bold; }

.search-box {
  background: #2a2a2a;
  border: 1px solid rgba(255,255,255,0.1);
  color: white;
  padding: clamp(8px, 0.7vw, 10px) clamp(12px, 1vw, 15px);
  border-radius: 6px;
  font-size: clamp(12px, 1vw, 14px);
  width: clamp(200px, 17vw, 250px);
  outline: none;
  transition: border-color 0.2s;
}

.search-box:focus { border-color: #ff0000; }
.search-box::placeholder { color: rgba(255,255,255,0.4); }

/* ================= LOADING STATE ================= */
.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(15px, 1.3vw, 20px);
  padding: clamp(50px, 4.2vw, 70px);
}

.loading-spinner {
  width: clamp(40px, 3.3vw, 50px);
  height: clamp(40px, 3.3vw, 50px);
  border: 3px solid rgba(255,255,255,0.1);
  border-top-color: #ff0000;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.loading-state p { font-size: clamp(13px, 1.1vw, 15px); opacity: 0.7; }

/* ================= ITEMS GRID ================= */
.items-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(clamp(110px, 9.5vw, 130px), 1fr));
  gap: clamp(15px, 1.3vw, 20px);
}

/* ================= ITEM CARD (in grid) ================= */
.item-card {
  background: linear-gradient(to bottom, #2a2a2a, #1c1c1c);
  border-radius: 10px;
  padding: clamp(12px, 1vw, 15px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(8px, 0.7vw, 10px);
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
  border: 2px solid transparent;
  user-select: none;
  -webkit-user-select: none;
}

.item-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 4px 15px rgba(255,0,0,0.3);
  border-color: rgba(255,0,0,0.5);
}

.item-card img {
  width: 100%;
  height: clamp(80px, 6.8vw, 100px);
  object-fit: contain;
  border-radius: 6px;
  background: rgba(0,0,0,0.3);
  padding: clamp(5px, 0.4vw, 6px);
  pointer-events: none;
}

.item-card .card-name {
  font-size: clamp(11px, 0.95vw, 13px);
  text-align: center;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  min-height: clamp(28px, 2.4vw, 34px);
  pointer-events: none;
}

.item-card .card-value {
  font-size: clamp(13px, 1.1vw, 16px);
  font-weight: bold;
  color: #4caf50;
  padding: clamp(4px, 0.3vw, 5px) clamp(8px, 0.7vw, 10px);
  background: rgba(76, 175, 80, 0.1);
  border-radius: 4px;
  pointer-events: none;
}

/* ================= DESKTOP CONTROLS ================= */
.desktop-controls {
  display: none;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  margin-top: 4px;
}

@media (min-width: 769px) {
  .desktop-controls { display: flex; }
}

.quantity-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.qty-btn {
  background: rgba(255, 0, 0, 0.2);
  color: white;
  border: 1px solid rgba(255, 0, 0, 0.4);
  width: 24px;
  height: 24px;
  border-radius: 4px;
  font-size: 14px;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.qty-btn:hover { background: rgba(255, 0, 0, 0.4); transform: scale(1.1); }
.qty-btn:active { transform: scale(0.95); }

.qty-input {
  width: 40px;
  height: 24px;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: white;
  text-align: center;
  border-radius: 4px;
  font-size: 12px;
  font-weight: bold;
  padding: 0;
}

.qty-input:focus { outline: none; border-color: #ff0000; }

.qty-input::-webkit-inner-spin-button,
.qty-input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.qty-input[type=number] { -moz-appearance: textfield; }

.add-arrows {
  display: flex;
  gap: 6px;
  justify-content: center;
}

.arrow-btn {
  background: linear-gradient(135deg, #3b0000, #5a0000);
  color: white;
  border: 1px solid rgba(255, 0, 0, 0.5);
  width: 32px;
  height: 28px;
  border-radius: 4px;
  font-size: 16px;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  position: relative;
}

.arrow-btn:hover {
  background: linear-gradient(135deg, #5a0000, #7a0000);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(255, 0, 0, 0.4);
}

.arrow-btn:active { transform: translateY(0); }

.arrow-btn::after {
  content: attr(title);
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.9);
  color: white;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 10px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
  margin-bottom: 4px;
}

.arrow-btn:hover::after { opacity: 1; }

/* ================= SELECTION MODAL (MOBILE) ================= */
.selection-modal {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.selection-modal.active { opacity: 1; }

.modal-content {
  background: linear-gradient(to bottom, #2a2a2a, #1c1c1c);
  border-radius: 12px;
  padding: clamp(25px, 2.1vw, 35px);
  max-width: 400px;
  width: 90%;
  border: 2px solid rgba(255, 0, 0, 0.3);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.8);
  transform: scale(0.9);
  transition: transform 0.3s ease;
}

.selection-modal.active .modal-content { transform: scale(1); }

.modal-content h3 {
  font-size: clamp(18px, 1.5vw, 22px);
  font-weight: bold;
  margin-bottom: clamp(20px, 1.7vw, 25px);
  text-align: center;
  color: white;
}

.modal-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(10px, 0.9vw, 12px);
  padding: clamp(15px, 1.3vw, 20px);
  background: rgba(0, 0, 0, 0.3);
  border-radius: 8px;
  margin-bottom: clamp(15px, 1.3vw, 20px);
}

.modal-item img {
  width: clamp(80px, 6.8vw, 100px);
  height: clamp(80px, 6.8vw, 100px);
  object-fit: contain;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.3);
  padding: clamp(8px, 0.7vw, 10px);
}

.modal-item-name { font-size: clamp(14px, 1.2vw, 16px); text-align: center; font-weight: bold; }

.modal-item-value {
  font-size: clamp(16px, 1.4vw, 20px);
  font-weight: bold;
  color: #4caf50;
  padding: clamp(5px, 0.4vw, 6px) clamp(12px, 1vw, 15px);
  background: rgba(76, 175, 80, 0.1);
  border-radius: 4px;
}

/* ================= MODAL QUANTITY ================= */
.modal-quantity {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 15px;
  margin-bottom: clamp(20px, 1.7vw, 25px);
  padding: 12px;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 8px;
}

.modal-quantity label { font-size: clamp(13px, 1.1vw, 15px); font-weight: bold; color: rgba(255,255,255,0.9); }
.modal-quantity .quantity-controls { flex: 1; max-width: 150px; }
.modal-quantity .qty-input { width: 50px; height: 32px; font-size: 14px; }
.modal-quantity .qty-btn  { width: 32px; height: 32px; font-size: 16px; }

.modal-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: clamp(12px, 1vw, 15px);
  margin-bottom: clamp(15px, 1.3vw, 20px);
}

.modal-btn {
  background: linear-gradient(135deg, #3b0000, #5a0000);
  color: white;
  border: 2px solid rgba(255, 0, 0, 0.5);
  padding: clamp(12px, 1vw, 15px);
  border-radius: 8px;
  font-size: clamp(13px, 1.1vw, 15px);
  font-weight: bold;
  cursor: pointer;
  transition: all 0.3s;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(6px, 0.5vw, 8px);
}

.modal-btn:hover {
  background: linear-gradient(135deg, #5a0000, #7a0000);
  transform: translateY(-2px);
  box-shadow: 0 4px 15px rgba(255, 0, 0, 0.4);
}

.modal-btn:active { transform: translateY(0); }
.btn-icon { font-size: clamp(20px, 1.7vw, 24px); }

.modal-close {
  background: rgba(255, 255, 255, 0.1);
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.2);
  padding: clamp(10px, 0.9vw, 12px);
  border-radius: 6px;
  font-size: clamp(12px, 1vw, 14px);
  cursor: pointer;
  transition: all 0.2s;
  width: 100%;
}

.modal-close:hover { background: rgba(255, 255, 255, 0.2); }

/* ================= RESPONSIVE ================= */
@media (max-width: 1100px) {
  .trade-container { grid-template-columns: 1fr; grid-template-rows: auto auto auto; }
  .trade-middle { flex-direction: row; order: 2; }
  #yourOffer { order: 1; }
  #theirOffer { order: 3; }
}

@media (max-width: 768px) {
  .desktop-controls { display: none !important; }
}

@media (max-width: 600px) {
  .items-header { flex-direction: column; align-items: stretch; }
  .search-box { width: 100%; }
  .items-grid { grid-template-columns: repeat(auto-fill, minmax(90px, 1fr)); }
  .header-controls { flex-direction: column; }
  .screenshot-btn { width: 100%; justify-content: center; }
  .modal-buttons { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
  .modal-content  { max-width: 90vw !important; padding: 16px !important; }
  .modal-item     { padding: 12px !important; }
  .modal-item img { width: 56px !important; height: 56px !important; padding: 6px !important; }
  .modal-item-name  { font-size: 12px !important; }
  .modal-item-value { font-size: 14px !important; padding: 4px 8px !important; }
  .modal-btn  { font-size: 12px !important; padding: 10px !important; }
  .btn-icon   { font-size: 16px !important; }
  .modal-quantity { flex-direction: column; gap: 10px; }
  .modal-quantity .quantity-controls { max-width: 100%; }
}

/* ================= STACK BADGE ================= */
.stack-badge {
  position: absolute;
  top: 4px;
  left: 4px;
  background: rgba(0, 0, 0, 0.85);
  color: #fff;
  font-size: clamp(9px, 0.8vw, 11px);
  font-weight: 700;
  line-height: 1;
  padding: 3px 6px;
  border-radius: 3px;
  z-index: 2;
  pointer-events: none;
  box-shadow: 0 2px 4px rgba(0,0,0,0.6);
  letter-spacing: 0.3px;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.stack-each {
  color: rgba(255, 255, 255, 0.55);
  font-size: 0.85em;
  font-weight: normal;
}