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

html {
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body {
  background: #0f172a;
  color: #e2e8f0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  overflow-x: hidden;
}

header {
  padding: 20px 40px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.logo { font-size: 24px; font-weight: bold; color: white; }

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

.network {
  background: #1e293b;
  padding: 8px 16px;
  border-radius: 30px;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.connect-btn {
  background: linear-gradient(90deg, #8b5cf6, #6366f1);
  color: white;
  border: none;
  padding: 12px 28px;
  border-radius: 30px;
  font-weight: bold;
  cursor: pointer;
  font-size: 15px;
  box-shadow: 0 4px 15px rgba(99,102,241,0.4);
  transition: all 0.3s ease;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.connect-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(99,102,241,0.5);
}

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

.wallet-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.wallet-address {
  background: #1e293b;
  padding: 8px 16px;
  border-radius: 30px;
  font-size: 14px;
  color: #8b5cf6;
  font-weight: 600;
}

main { 
  flex: 1; 
  display: flex; 
  justify-content: center; 
  align-items: center; 
}

.swap-card {
  background: #111827;
  width: 405px;
  border-radius: 24px;
  padding: 24px;
  box-shadow: 0 20px 40px rgba(0,0,0,0.6);
  position: relative;
}

.swap-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  font-size: 18px;
  color: #e2e8f0;
}

.settings-icon { 
  width: 24px; 
  height: 24px; 
  cursor: pointer; 
  transition: transform 0.2s ease;
  opacity: 0.8;
}

.settings-icon:hover {
  transform: rotate(90deg);
  opacity: 1;
}

.token-row {
  background: #1e293b;
  border-radius: 16px;
  padding: 10px 15px;
  margin-bottom: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.amount-input {
  background: transparent;
  border: none;
  color: white;
  font-size: 36px;
  font-weight: 600;
  width: 180px;
  outline: none;
  -webkit-appearance: none;
  -moz-appearance: textfield;
  touch-action: manipulation;
}

.amount-input::-webkit-inner-spin-button,
.amount-input::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.token-btn {
  background: #334155;
  border: none;
  padding: 8px 12px;
  border-radius: 30px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  font-size: 15px;
  cursor: pointer;
  color: white;
  white-space: nowrap;
  transition: all 0.2s ease;
}

.token-btn:hover {
  background: #475569;
  transform: scale(1.02);
}

.token-btn img { width: 19px; height: 20px; border-radius: 50%; }

.swap-btn {
  width: 100%;
  background: #334155;
  color: #94a3b8;
  border: none;
  padding: 18px;
  margin-top: 20px;
  border-radius: 16px;
  font-size: 18px;
  font-weight: bold;
  cursor: not-allowed;
  transition: all 0.3s ease;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.swap-btn.active {
  background: linear-gradient(90deg, #6366f1, #8b5cf6);
  color: white;
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(99,102,241,0.4);
}

.swap-btn.active:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 28px rgba(99,102,241,0.5);
}

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

footer { 
  text-align: center; 
  padding: 20px; 
  font-size: 14px; 
  color: #64748b; 
}

.settings-modal {
  position: absolute;
  top: 70px;
  right: 20px;
  background: #1e293b;
  border-radius: 16px;
  padding: 16px;
  width: 200px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.5);
  display: none;
  z-index: 100;
}

.settings-modal.active { display: block; }

.settings-title { 
  font-size: 16px; 
  font-weight: 600; 
  margin-bottom: 12px; 
  color: white; 
}

.slippage-title { 
  font-size: 14px; 
  color: #cbd5e1; 
  margin-bottom: 8px; 
}

.slippage-buttons { 
  display: flex; 
  gap: 8px; 
}

.slippage-btn {
  flex: 1;
  background: #334155;
  color: #e2e8f0;
  border: none;
  padding: 10px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.slippage-btn:hover {
  background: #475569;
}

.slippage-btn.active { 
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: white;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
}

.modal {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(8px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: fadeIn 0.2s ease;
}

.modal.active { 
  display: flex; 
}

.modal-content {
  background: #1e293b;
  width: 400px;
  max-width: 90vw;
  border-radius: 24px;
  padding: 24px;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.7);
  animation: slideUpModal 0.3s ease;
  scrollbar-width: thin;
  scrollbar-color: #475569 #1e293b;
}

.modal-content::-webkit-scrollbar {
  width: 6px;
}

.modal-content::-webkit-scrollbar-track {
  background: #1e293b;
  border-radius: 10px;
}

.modal-content::-webkit-scrollbar-thumb {
  background: #475569;
  border-radius: 10px;
}

.modal-header { 
  display: flex; 
  justify-content: space-between; 
  align-items: center; 
  margin-bottom: 20px; 
  font-size: 20px; 
  font-weight: 700; 
  color: white;
}

.close-modal { 
  cursor: pointer; 
  font-size: 28px;
  color: #94a3b8;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  transition: all 0.2s;
}

.close-modal:hover {
  background: #334155;
  color: white;
}

.token-item {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px;
  border-radius: 16px;
  cursor: pointer;
  transition: all 0.2s ease;
  margin-bottom: 4px;
}

.token-item:hover { 
  background: #334155;
  transform: translateX(4px);
}

.token-item:active {
  transform: translateX(2px);
}

.token-item img { 
  width: 36px; 
  height: 36px; 
  border-radius: 50%; 
}

.token-name { 
  font-weight: 600; 
}

.token-symbol { 
  font-size: 13px; 
  color: #94a3b8; 
}

.toast-notification {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: #fef3c7;
  color: #92400e;
  padding: 16px 28px;
  border-radius: 12px;
  font-weight: bold;
  font-size: 16px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.3);
  z-index: 999999;
  display: flex;
  align-items: center;
  gap: 12px;
  animation: slideDown 0.4s ease;
}

@keyframes slideDown {
  from { transform: translate(-50%, -100px); opacity: 0; }
  to   { transform: translateX(-50%); opacity: 1; }
}

@keyframes slideUp {
  to { transform: translate(-50%, -100px); opacity: 0; }
}

.wallet-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(8px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  animation: fadeIn 0.2s ease;
}

.wallet-modal.active {
  display: flex;
}

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

.wallet-modal-content {
  background: #1e293b;
  width: 420px;
  max-width: 90vw;
  border-radius: 24px;
  padding: 0;
  max-height: 85vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.7);
  animation: slideUpModal 0.3s ease;
}

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

.wallet-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 24px;
  border-bottom: 1px solid #334155;
  position: relative;
}

.wallet-modal-help {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #334155;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  color: #cbd5e1;
  cursor: pointer;
  transition: all 0.2s;
  font-weight: 600;
}

.wallet-modal-help:hover {
  background: #475569;
  color: white;
}

.wallet-modal-title {
  font-size: 20px;
  font-weight: 700;
  color: white;
  flex: 1;
  text-align: center;
  letter-spacing: -0.5px;
}

.wallet-modal-close {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: #94a3b8;
  font-size: 24px;
  font-weight: 300;
  border-radius: 8px;
  transition: all 0.2s;
}

.wallet-modal-close:hover {
  background: #334155;
  color: white;
}

.wallet-list {
  padding: 8px;
  max-height: 450px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: #475569 #1e293b;
}

.wallet-list::-webkit-scrollbar {
  width: 6px;
}

.wallet-list::-webkit-scrollbar-track {
  background: #1e293b;
  border-radius: 10px;
}

.wallet-list::-webkit-scrollbar-thumb {
  background: #475569;
  border-radius: 10px;
}

.wallet-list::-webkit-scrollbar-thumb:hover {
  background: #64748b;
}

.wallet-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-radius: 16px;
  cursor: pointer;
  transition: all 0.2s ease;
  margin-bottom: 4px;
  position: relative;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  min-height: 60px;
}

.wallet-item:hover {
  background: #334155;
  transform: translateX(4px);
}

.wallet-item:active {
  transform: translateX(2px);
}

.wallet-item-left {
  display: flex;
  align-items: center;
  gap: 16px;
  flex: 1;
}

.wallet-icon-container {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(99, 102, 241, 0.1);
  border-radius: 12px;
  position: relative;
  overflow: hidden;
}

.wallet-icon {
  font-size: 28px;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.wallet-logo {
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 6px;
  border-radius: 12px;
  display: block;
  background: transparent;
}

.wallet-logo[src=""] {
  display: none;
}

.wallet-name {
  font-size: 16px;
  font-weight: 600;
  color: white;
  letter-spacing: -0.3px;
}

.wallet-item-right {
  display: flex;
  gap: 8px;
  align-items: center;
}

.wallet-badge {
  padding: 6px 14px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  white-space: nowrap;
}

.wallet-badge.installed {
  background: linear-gradient(135deg, #10b981, #059669);
  color: white;
  box-shadow: 0 2px 8px rgba(16, 185, 129, 0.3);
}

.wallet-badge.qr {
  background: linear-gradient(135deg, #3b82f6, #2563eb);
  color: white;
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.3);
}

.wallet-badge.not-installed {
  background: #475569;
  color: #cbd5e1;
}

.wallet-modal-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 24px;
  border-top: 1px solid #334155;
  color: #94a3b8;
  font-size: 13px;
  background: rgba(0, 0, 0, 0.2);
}

.wallet-modal-footer span:last-child {
  font-weight: 600;
  color: #6366f1;
}

@media (max-width: 768px) {
  header {
    padding: 16px 20px;
    flex-wrap: wrap;
    gap: 12px;
  }

  .logo {
    font-size: 20px;
  }

  .header-right {
    gap: 8px;
    flex-wrap: wrap;
  }

  .network {
    padding: 6px 12px;
    font-size: 12px;
  }

  .connect-btn {
    padding: 10px 20px;
    font-size: 14px;
  }

  .wallet-address {
    padding: 6px 12px;
    font-size: 12px;
  }

  main {
    padding: 20px;
    align-items: flex-start;
  }

  .swap-card {
    width: 100%;
    max-width: 100%;
    padding: 20px;
    border-radius: 20px;
  }

  .swap-header {
    font-size: 16px;
    margin-bottom: 16px;
  }

  .token-row {
    padding: 12px;
    gap: 8px;
    flex-wrap: wrap;
  }

  .amount-input {
    font-size: 28px;
    width: 100%;
    min-width: 120px;
    flex: 1;
  }

  .token-btn {
    padding: 6px 10px;
    font-size: 13px;
    gap: 6px;
  }

  .token-btn img {
    width: 16px;
    height: 16px;
  }

  .swap-btn {
    padding: 16px;
    font-size: 16px;
    margin-top: 16px;
  }

  .settings-modal {
    top: 60px;
    right: 10px;
    width: 180px;
    padding: 12px;
  }

  .modal-content {
    width: 95vw;
    padding: 20px;
    max-height: 85vh;
  }

  .modal-header {
    font-size: 18px;
    margin-bottom: 16px;
  }

  .token-item {
    padding: 12px;
    gap: 12px;
  }

  .token-item img {
    width: 32px;
    height: 32px;
  }

  footer {
    padding: 16px;
    font-size: 12px;
  }

  .wallet-modal-content {
    width: 95vw;
    max-height: 90vh;
  }

  .wallet-modal-header {
    padding: 20px;
  }

  .wallet-item {
    padding: 14px 16px;
  }

  .wallet-name {
    font-size: 15px;
  }

  .wallet-badge {
    font-size: 10px;
    padding: 5px 12px;
  }

  .toast-notification {
    padding: 12px 20px;
    font-size: 14px;
    max-width: 90vw;
    left: 50%;
    transform: translateX(-50%);
  }
}

@media (max-width: 480px) {
  header {
    padding: 12px 16px;
  }

  .logo {
    font-size: 18px;
  }

  .header-right {
    width: 100%;
    justify-content: space-between;
    margin-top: 8px;
  }

  .network {
    font-size: 11px;
    padding: 5px 10px;
  }

  .connect-btn {
    padding: 8px 16px;
    font-size: 13px;
  }

  .wallet-address {
    font-size: 11px;
    padding: 5px 10px;
  }

  main {
    padding: 16px;
    padding-top: 20px;
  }

  .swap-card {
    padding: 16px;
    border-radius: 16px;
  }

  .swap-header {
    font-size: 15px;
    margin-bottom: 12px;
  }

  .settings-icon {
    width: 20px;
    height: 20px;
  }

  .token-row {
    padding: 10px;
    margin-bottom: 10px;
    gap: 6px;
  }

  .amount-input {
    font-size: 24px;
    width: 100%;
    min-height: 44px;
  }

  .token-btn {
    padding: 5px 8px;
    font-size: 12px;
    gap: 5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 140px;
    min-height: 32px;
    touch-action: manipulation;
  }

  .token-btn img {
    width: 14px;
    height: 14px;
  }

  .swap-btn {
    padding: 14px;
    font-size: 15px;
    margin-top: 12px;
  }

  .settings-modal {
    top: 50px;
    right: 8px;
    left: 8px;
    width: auto;
    padding: 12px;
  }

  .slippage-buttons {
    gap: 6px;
  }

  .slippage-btn {
    padding: 8px;
    font-size: 12px;
  }

  .modal-content {
    width: 95vw;
    padding: 16px;
    border-radius: 20px;
  }

  .modal-header {
    font-size: 16px;
    margin-bottom: 12px;
  }

  .close-modal {
    width: 28px;
    height: 28px;
    font-size: 24px;
  }

  .token-item {
    padding: 10px;
    gap: 10px;
  }

  .token-item img {
    width: 28px;
    height: 28px;
  }

  .token-name {
    font-size: 14px;
  }

  .wallet-modal-content {
    width: 95vw;
    max-height: 92vh;
    border-radius: 20px;
  }

  .wallet-modal-header {
    padding: 16px;
  }

  .wallet-modal-title {
    font-size: 18px;
  }

  .wallet-modal-help {
    width: 24px;
    height: 24px;
    font-size: 12px;
  }

  .wallet-modal-close {
    width: 28px;
    height: 28px;
    font-size: 20px;
  }

  .wallet-list {
    padding: 6px;
    max-height: 400px;
  }

  .wallet-item {
    padding: 12px 14px;
    gap: 12px;
  }

  .wallet-icon-container {
    width: 36px;
    height: 36px;
  }

  .wallet-icon {
    font-size: 24px;
  }

  .wallet-name {
    font-size: 14px;
  }

  .wallet-badge {
    font-size: 9px;
    padding: 4px 10px;
  }

  .wallet-modal-footer {
    padding: 12px 16px;
    font-size: 12px;
  }

  .toast-notification {
    padding: 10px 16px;
    font-size: 13px;
    top: 10px;
    max-width: 95vw;
  }

  footer {
    padding: 12px;
    font-size: 11px;
  }
}

@media (max-width: 360px) {
  .amount-input {
    font-size: 20px;
  }

  .token-btn {
    max-width: 120px;
    font-size: 11px;
  }

  .swap-btn {
    font-size: 14px;
    padding: 12px;
  }

  .wallet-modal-content {
    width: 98vw;
  }

  .modal-content {
    width: 98vw;
    padding: 14px;
  }
}

@media (max-height: 600px) and (orientation: landscape) {
  main {
    padding: 10px;
  }

  .swap-card {
    padding: 16px;
  }

  .wallet-modal-content {
    max-height: 95vh;
  }

  .wallet-list {
    max-height: 300px;
  }
}

