:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --secondary: #f59e0b;
  --secondary-dark: #d97706;
  --dark: #1e293b;
  --light: #f8fafc;
  --gray: #64748b;
  --success: #10b981;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Poppins', sans-serif;
  background: linear-gradient(135deg, #a8e6cf, #dce6f5);
  background-attachment: fixed;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  min-height: 100vh;
  color: var(--dark);
  line-height: 1.6;
  overflow-x: hidden;
  padding: 0;
}

body > *:not(footer) {
  flex-shrink: 0;
}

/* Header */
header {
  width: 100%;
  padding: 1rem 5%;
  background-color: rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.logo {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--dark);
  display: flex;
  align-items: center;
  gap: 0;
  line-height: 1;
}

.logo img {
  height: 65px !important;
  width: auto !important;
  max-height: none !important;
  max-width: none !important;
  vertical-align: middle;
}

.logo span {
  color: var(--secondary);
}

.nav-links {
  display: flex;
  gap: 1.5rem;
}

.nav-links a {
  color: var(--dark);
  text-decoration: none;
  font-weight: 500;
  transition: color 0.3s ease;
  position: relative;
}

.nav-links a:hover {
  color: var(--secondary);
}

.nav-links a::after {
  content: '';
  position: absolute;
  bottom: -5px;
  left: 0;
  width: 0;
  height: 2px;
  background-color: var(--secondary);
  transition: width 0.3s ease;
}

.nav-links a:hover::after {
  width: 100%;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.user-email {
  background: rgba(255, 255, 255, 0.6);
  padding: 0.5rem 1rem;
  border-radius: 20px;
  font-size: 0.9rem;
  backdrop-filter: blur(5px);
  color: var(--dark);
}

.user-info-container {
  display: flex;
  align-items: center;
  gap: 10px;
  background: linear-gradient(135deg, #fff9db 0%, #fff3bf 100%);
  padding: 8px 16px;
  border-radius: 6px;
  box-shadow: 0 2px 8px rgba(252, 196, 25, 0.2);
  transition: all 0.2s ease;
  border: 1px solid #fcc419;
  position: relative;
  overflow: hidden;
  cursor: pointer;
  user-select: none;
}

.user-info-container::before {
  content: "";
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: linear-gradient(45deg, transparent, rgba(255, 255, 255, 0.7), transparent);
  transform: rotate(45deg);
  animation: shine 5s infinite;
}

@keyframes shine {
  0% { transform: translateX(-150%) rotate(45deg); }
  100% { transform: translateX(150%) rotate(45deg); }
}

.user-info-container:hover {
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.12);
}

#user-info {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  color: var(--dark);
  font-size: 15px;
}

#user-info i {
  color: var(--gray);
  font-size: 16px;
}

/* Main Content */
.main-content {
  width: 100%;
  max-width: 1200px;
  padding: 2rem 1rem;
  margin-top: 0.5rem;
}

h1 {
  text-align: center;
  color: #0984e3;
  font-size: 1.8rem;
  margin-bottom: 1rem;
  text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.1);
}

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  justify-content: center;
  align-items: center;
  margin-bottom: 1.5rem;
  padding: 0 0.5rem;
}

.search-box {
  flex: 1;
  min-width: 200px;
  max-width: 300px;
}

.search-box input {
  width: 100%;
  padding: 0.8rem;
  border: 2px solid #0984e3;
  border-radius: 12px;
  font-size: 1rem;
  outline: none;
}

.sort-box {
  flex: 1;
  min-width: 200px;
  max-width: 250px;
}

.sort-box select {
  width: 100%;
  padding: 0.8rem;
  border: 2px solid #0984e3;
  border-radius: 12px;
  font-size: 1rem;
  background: white;
}

.game-box select {
  width: 100%;
  padding: 0.8rem;
  border: 2px solid #0984e3;
  border-radius: 12px;
  font-size: 1rem;
  background: white;
}

.custom-select {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0.8rem;
  border: 2px solid #0984e3;
  border-radius: 12px;
  background: white;
  cursor: pointer;
  font-size: 1rem;
  color: var(--dark);
  min-height: 48px;
  box-sizing: border-box;
}

.custom-select:focus {
  outline: 2px solid var(--primary);
}

.dropdown-menu {
  max-height: 200px;
  overflow-y: auto;
}

.dropdown-item {
  display: flex;
  align-items: center;
  padding: 0.6rem;
  cursor: pointer;
  gap: 8px;
  font-size: 1rem;
  color: var(--dark);
}

.dropdown-item:hover {
  background-color: #f1f5f9;
}

.game-icon {
  width: 50px;
  height: 50px;
  object-fit: contain;
  border-radius: 4px;
}

/* Pagination */
.pagination {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  align-items: center;
  margin: 1.5rem 0;
}

.pagination button {
  padding: 0.6rem 1rem;
  background: #0984e3;
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
}

.pagination button:disabled {
  background: #ccc;
  cursor: not-allowed;
}

.pagination span {
  font-weight: 600;
  color: #2d3436;
}

/* Item Container */
.item-container {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.75rem;
  padding: 0.5rem;
}

.item {
  width: 100%;
  max-width: 200px;
  min-height: auto;
  background: white;
  border: 1px solid #e0e0e0;
  border-radius: 12px;
  padding: 0.75rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  transition: all 0.3s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  cursor: pointer;
  overflow: hidden;
  position: relative;
}

.item:hover {
  transform: translateY(-4px) scale(1.03);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
  border-color: #0984e3;
}

.item img {
  width: 100%;
  height: 120px;
  object-fit: contain;
  object-position: center;
  border-radius: 8px;
  margin-bottom: 0.5rem;
  border: 1px solid #ddd;
  background: #f9f9f9;
  padding: 0;
}

.item h3 {
  font-size: 0.9rem;
  margin: 0.25rem 0 0.25rem;
  color: #2d3436;
  font-weight: 600;
  line-height: 1.3;
  word-wrap: break-word;
  max-height: 2.6rem;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
}

.item h3:hover {
  text-decoration: none;
}

.price {
  font-weight: 700;
  color: #27ae60;
  font-size: 0.9rem;
  text-align: center;
  background: #e8f5e9;
  padding: 0.3rem 0.6rem;
  border-radius: 6px;
  margin-top: 0.25rem;
  margin-bottom: 0;
}

.sold-count {
  font-size: 0.7rem;
  color: rgba(51, 51, 51, 0.6);
  font-style: italic;
  margin-top: 0.25rem;
  margin-bottom: 0;
}

.desc-btn {
  background: #6c5ce7;
  color: white;
  border: none;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 0.9rem;
  cursor: pointer;
  width: 100%;
  margin: 0.3rem 0 0.8rem;
}

.desc-btn:hover {
  background: #5f4fc9;
}

.buy-input {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: auto;
  padding-top: 0.8rem;
  border-top: 2px solid #f1f2f6;
}

.input-group {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
}

.input-group input {
  flex: 1 1 150px;
  min-width: 150px;
  padding: 0.6rem;
  border: 2px solid #0984e3;
  border-radius: 10px;
  font-size: 0.95rem;
  outline: none;
}

.input-group button {
  flex-shrink: 0;
  padding: 0.6rem 0.8rem;
  font-size: 0.9rem;
  background-color: #0984e3;
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  white-space: nowrap;
}

.input-group button:hover {
  background-color: #067bc2;
}

.spinner {
  border: 4px solid #f3f3f3;
  border-top: 4px solid #3b82f6;
  border-radius: 50%;
  width: 20px;
  height: 20px;
  animation: spin 1s linear infinite;
  margin: 0.5rem auto;
}

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

.result-info {
  font-size: 0.85rem;
  text-align: left;
  margin: 0.3rem 0 0.5rem 0;
  line-height: 1.4;
}

.qty-control {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.qty-btn {
  width: 36px;
  height: 36px;
  background: #0984e3;
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 1.2rem;
  cursor: pointer;
}

.qty-btn:hover {
  background: #067bc2;
}

.qty-input {
  width: 60px;
  text-align: center;
  font-size: 1.1rem;
  padding: 0.4rem;
  border: 2px solid #0984e3;
  border-radius: 6px;
  outline: none;
}

.total-price {
  text-align: center;
  font-weight: 700;
  color: #e74c3c;
  font-size: 1.1rem;
  margin-bottom: 0.5rem;
}

.buy-input button.buy-now {
  padding: 0.6rem 1rem;
  background: linear-gradient(to bottom, #27ae60, #219653);
  color: white;
  border: none;
  border-radius: 10px;
  font-size: 0.95rem;
  cursor: pointer;
  transition: all 0.3s;
  font-weight: 600;
  white-space: nowrap;
  box-shadow: 0 4px 8px rgba(39, 174, 96, 0.2);
  margin-top: 0.5rem;
}

.buy-input button.buy-now:hover:not(:disabled) {
  background: linear-gradient(to bottom, #219653, #1e8a4c);
  transform: translateY(-2px);
}

.buy-input button.buy-now:disabled {
  background: #b2bec3;
  color: #666;
  cursor: not-allowed;
  transform: none;
}

/* Popup Description */
#popup-description {
  display: none;
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: white;
  border: 2px solid #0984e3;
  border-radius: 16px;
  padding: 1.5rem;
  z-index: 1000;
  width: 90%;
  max-width: 500px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

#popup-description h3 {
  margin-top: 0;
  color: #0984e3;
  text-align: center;
  font-size: 1.3rem;
}

#popup-description button {
  display: block;
  margin: 1rem auto 0;
  padding: 8px 16px;
  background: #00b894;
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
}

/* Tutorial Popup */
#tutorial-popup {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.6);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

#tutorial-popup .tutorial-modal-content {
  background: white;
  border-radius: 16px;
  padding: 1.5rem;
  width: 90%;
  max-width: 600px;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
  position: relative;
}

.tutorial-close {
  position: absolute;
  top: 10px;
  right: 15px;
  font-size: 2rem;
  color: #aaa;
  cursor: pointer;
}

.tutorial-close:hover {
  color: #000;
}

/* Popup Top Up */
.popup-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  justify-content: center;
  align-items: center;
  z-index: 1000;
  backdrop-filter: blur(4px);
  animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.popup-content {
  background: white;
  color: var(--dark);
  border-radius: 16px;
  padding: 20px;
  width: 90%;
  max-width: 360px;
  text-align: center;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.2);
  border: 2px solid var(--success);
  transform: scale(0.95);
  opacity: 0;
  animation: popIn 0.3s ease forwards;
}

@keyframes popIn {
  to {
    transform: scale(1);
    opacity: 1;
  }
}

.popup-content h3 {
  margin-top: 0;
  color: var(--primary);
  font-size: 1.4rem;
  font-weight: 600;
}

.payment-methods {
  margin: 12px 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.method-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  border: 2px solid #ddd;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 14px;
}

.method-option:hover {
  background-color: #f8fafc;
  transform: scale(1.02);
  transition: all 0.2s ease;
}

/* Social Section */
.social-section {
  margin: 2rem 0 0.8rem 0;
  text-align: center;
}

.social-title {
  font-size: 1.2rem;
  margin-bottom: 1.5rem;
  color: var(--dark);
}

.social-icons {
  display: flex;
  gap: 0.8rem;
  justify-content: center;
  flex-wrap: wrap;
  align-items: center;
}

.social-icons a {
  text-decoration: none;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.7);
  color: var(--dark);
  font-size: 1.2rem;
  transition: all 0.3s ease;
  backdrop-filter: blur(5px);
  border: 1px solid rgba(255, 255, 255, 0.5);
}

.social-icons a:hover {
  background: var(--secondary);
  color: white;
  transform: translateY(-5px);
  box-shadow: 0 5px 15px rgba(245, 158, 11, 0.3);
}

/* Footer */
footer {
  margin-top: auto;
  width: 100%;
  background-color: rgba(255, 255, 255, 0.8);
  padding: 2rem 5%;
  text-align: center;
  backdrop-filter: blur(10px);
  color: var(--dark);
}

.footer-content {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
}

.footer-logo {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--dark);
}

.footer-logo span {
  color: var(--secondary);
}

.footer-links {
  display: flex;
  gap: 1.5rem;
  flex-wrap: wrap;
  justify-content: center;
}

.footer-links a {
  color: var(--gray);
  text-decoration: none;
  transition: color 0.3s ease;
}

.footer-links a:hover {
  color: var(--secondary);
}

.footer-copyright {
  text-align: center;
  font-size: 13px;
  color: #aaa;
  margin-top: 10px;
}

.footer-copyright p {
  margin: 2px 0;
  line-height: 1.2;
}

.copyright {
  color: var(--gray);
  font-size: 0.9rem;
  margin-top: 1rem;
}

.loading-more {
  text-align: center;
  padding: 1rem;
  color: var(--gray);
  font-size: 0.9rem;
}

.loading-spinner {
  display: inline-block;
  width: 30px;
  height: 30px;
  border: 3px solid #f3f3f3;
  border-top: 3px solid #0984e3;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 1rem auto;
}

.btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border: none;
  border-radius: 6px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 4px 10px rgba(37, 99, 235, 0.2);
}

.btn-topup {
  background: linear-gradient(to bottom, #10b981, #059669);
  color: white;
  border-radius: 30px;
  padding: 8px 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 4px 10px rgba(16, 185, 129, 0.3);
}

.btn-topup:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 15px rgba(16, 185, 129, 0.4);
  background: linear-gradient(to bottom, #059669, #047857);
}

.btn-logout {
  background: linear-gradient(to bottom, #e74c3c, #c0392b);
  color: white;
  border-radius: 30px;
  padding: 8px 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 4px 10px rgba(231, 76, 60, 0.3);
}

/* Media Queries */
@media (max-width: 768px) {
  header {
    flex-direction: column;
    gap: 1rem;
    padding: 1rem;
  }
  
  .nav-links {
    gap: 1rem;
    flex-wrap: wrap;
    justify-content: center;
  }
}

@media (max-width: 600px) {
  header {
    flex-direction: column;
    gap: 0.4rem;
    padding: 0.6rem 1rem;
  }
  
  header img {
    height: 38px !important;
  }
  
  .logo {
    font-size: 1.1rem;
  }
  
  .logo img {
    height: 50px !important;
  }
  
  .nav-links {
    flex-wrap: wrap;
    gap: 0.6rem;
    font-size: 0.85rem;
    justify-content: center;
  }
  
  .user-email {
    padding: 0.3rem 0.8rem;
    font-size: 0.8rem;
  }
  
  .controls {
    flex-direction: column;
    align-items: stretch;
  }
  
  .game-box,
  .search-box {
    max-width: 100% !important;
    width: 100% !important;
  }
  
  .social-section {
    margin: 1.5rem 0 0.8rem 0;
    text-align: center;
  }
  
  .social-title {
    font-size: 1rem;
    margin-bottom: 1rem;
  }
  
  .social-icons a {
    width: 40px;
    height: 40px;
    font-size: 1rem;
  }
  
  .social-icons {
    gap: 0.6rem;
  }
  
  .item-container {
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 0.6rem;
    padding: 0.5rem;
  }
  
  .item {
    max-width: none;
    padding: 0.6rem;
  }
  
  .item img {
    height: 100px;
    object-fit: contain;
    padding: 0.3rem;
  }
  
  .item h3 {
    font-size: 0.85rem;
    max-height: 2.2rem;
    -webkit-line-clamp: 2;
    line-clamp: 2;
  }
  
  .price {
    font-size: 0.85rem;
    padding: 0.25rem 0.5rem;
  }
  
  .sold-count {
    font-size: 0.7rem;
  }
  
  .popup-content {
    padding: 16px;
    max-width: 95vw;
    font-size: 13px;
  }
  
  .method-option {
    padding: 10px;
    font-size: 13px;
  }
  
  .header-buttons {
    flex-direction: column;
    align-items: center;
    gap: 12px;
  }
  
  .mobile-action-row {
    display: flex;
    gap: 10px;
    width: 100%;
    justify-content: center;
  }
}

@media (min-width: 601px) {
  .header-buttons {
    flex-direction: row;
  }
}

@media (max-width: 600px) {
  footer {
    padding: 1rem 0.8rem;
    margin-top: 1rem;
  }
  
  .footer-content {
    gap: 0.3rem;
  }
  
  .footer-logo {
    font-size: 1.3rem;
    margin-bottom: 0.1rem;
  }
  
  .footer-links {
    gap: 0.8rem;
    font-size: 0.85rem;
    margin: 0.3rem 0;
  }
  
  .footer-copyright {
    margin-top: 0.3rem;
  }
  
  .copyright {
    font-size: 0.8rem;
    margin-top: 0.2rem;
  }
}

#turnstile-container {
  margin: 15px 0;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 65px;
}

#ts-widget {
  transform-origin: center;
}

/* Mobile optimization - penting untuk lazy load */
@media (max-width: 600px) {
  #turnstile-container {
    transform: scale(0.85);
    margin: 10px 0;
  }
  
  #tosPopup iframe {
    height: 250px !important; /* Lebih kecil di mobile */
  }
}

