:root {
  --background: #ffffff;
  --foreground: #020817;
  --card: #ffffff;
  --card-foreground: #020817;
  --popover: #ffffff;
  --popover-foreground: #020817;
  --primary: #1a212d;
  --primary-foreground: #f8fafc;
  --secondary: #f1f5f9;
  --secondary-foreground: #0f172a;
  --muted: #f1f5f9;
  --muted-foreground: #64748b;
  --accent: #f1f5f9;
  --accent-foreground: #0f172a;
  --destructive: #ef4444;
  --destructive-foreground: #f8fafc;
  --border: #e2e8f0;
  --input: #e2e8f0;
  --ring: #94a3b8;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  background-color: var(--background);
  color: var(--foreground);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 2rem;
  flex-grow: 1;
  width: 100%;
}

h1 {
  font-size: 1.8rem;
  font-weight: 700;
  text-align: center;
  margin-bottom: 0.5rem;
}

.page-description {
  text-align: center;
  font-size: 1rem;
  color: var(--muted-foreground);
  max-width: 1200px;
  margin: 0 auto 2rem auto;
}

.trade-container {
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.trade-panel {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  padding: 1rem;
}

.trade-panel h2 {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 1rem;
}

.grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
}

.grid-item {
  position: relative;
  aspect-ratio: 1 / 1;
  border-radius: 0.5rem;
  background-color: var(--card);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  padding: 2px;
}

.add-item-btn {
  width: 100%;
  height: 100%;
  border: 2px dashed var(--border);
  border-radius: 0.5rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  color: var(--muted-foreground);
  transition: background-color 0.2s, border-color 0.2s;
}
.add-item-btn:hover {
  background-color: var(--secondary);
  border-color: var(--ring);
}

.grid-item .item-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  position: relative;
  padding: 2px;
}

.grid-item img {
  width: 45%;
  height: 45%;
  object-fit: contain;
}

.grid-item .item-name {
  font-size: 0.6rem;
  font-weight: 500;
  margin-top: 2px;
  text-align: center;
}

.grid-item input {
  width: 90%;
  padding: 2px;
  border: 1px solid var(--border);
  border-radius: 0.25rem;
  margin-top: 4px;
  text-align: center;
  font-size: 0.7rem;
}

.remove-item-btn {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 18px;
  height: 18px;
  background-color: var(--muted);
  color: var(--muted-foreground);
  border: none;
  border-radius: 50%;
  cursor: pointer;
  font-size: 10px;
  line-height: 18px;
  text-align: center;
}

.results-container {
  text-align: center;
  padding: 1.5rem;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
}

.results-container h2 {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 1rem;
}

#trade-result {
  font-size: 1.8rem;
  font-weight: 700;
  padding-bottom: 0.5rem;
}

.win {
  color: #22c55e;
}
.fair {
  color: #f97316;
}
.lose {
  color: #ef4444;
}

.value-display {
  font-size: 0.9rem;
  color: var(--muted-foreground);
}

.modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  z-index: 1000;
}
.modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background-color: var(--card);
  padding: 1rem;
  border-radius: 0.5rem;
  z-index: 1001;
  width: 90%;
  max-width: 600px;
  max-height: 80vh;
  display: none;
  flex-direction: column;
}
.modal-header {
  display: flex;
  flex-direction: column;
}
.modal-close-btn {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  width: 24px;
  height: 24px;
  background: transparent;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--muted-foreground);
  align-self: flex-end;
}
.modal-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1rem;
}
.modal-tab-btn {
  padding: 0.5rem 1rem;
  border: none;
  background: transparent;
  cursor: pointer;
  color: var(--muted-foreground);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  font-size: 0.9rem;
}
.modal-tab-btn.active {
  color: var(--foreground);
  border-bottom-color: var(--primary);
  font-weight: 500;
}
#modal-content {
  overflow-y: auto;
}
#modal-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  grid-auto-rows: 150px;
  gap: 0.5rem;
}
.modal-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0.5rem;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  cursor: pointer;
  transition: background-color 0.2s;
}
.modal-item:hover {
  background-color: var(--secondary);
}
.modal-item img {
  width: 40px;
  height: 40px;
}
.modal-item span {
  margin-top: 0.5rem;
  font-size: 0.7rem;
  text-align: center;
}

.model-footer {
  margin-top: 20px;
}

.modal-confirm-btn {
  margin-top: 5px;
  background-color: white;
  border-radius: 4px;
  border: 1px solid #555;
  width: 100%;
  padding: 10px;
}

.modal-confirm-btn:hover {
  background-color: var(--secondary);
  border-color: var(--ring);
}

#modal-search-input {
  width: 100%;
  padding: 8px 12px;
  margin-top: 8px;
  margin-bottom: 12px;
  font-size: 14px;
  border: 1px solid var(--ring);
  border-radius: 6px;
  background-color: var(--secondary);
  color: var(--foreground);
  box-sizing: border-box;
  transition: all 0.2s ease;
}

#modal-search-input::placeholder {
  color: #aaa;
}

#modal-search-input:focus {
  outline: none;
  border-color: #4caf50; /* 聚焦时高亮边框 */
  box-shadow: 0 0 6px rgba(76, 175, 80, 0.4);
  background-color: var(--background);
}

/* Footer Styles */
.site-footer {
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
  text-align: center;
  color: var(--muted-foreground);
}
.footer-links {
  display: flex;
  justify-content: center;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}
.footer-links a {
  color: var(--muted-foreground);
  text-decoration: none;
  font-size: 0.8rem;
}
.footer-links a:hover {
  text-decoration: underline;
}
.copyright {
  font-size: 0.7rem;
}

@media (min-width: 768px) {
  body {
    padding: 2rem;
  }

  h1 {
    font-size: 2rem;
  }

  .page-description {
    font-size: 1.1rem;
  }

  .trade-container {
    flex-direction: row;
    justify-content: space-between;
  }

  .trade-panel {
    padding: 1.5rem;
  }

  .trade-panel h2 {
    font-size: 1.5rem;
  }

  .grid {
    gap: 1rem;
  }

  .grid-item img {
    width: 50%;
    height: 50%;
  }

  .grid-item .item-name {
    font-size: 0.75rem;
  }
}

.info-section {
  max-width: 1000px;
  margin: 4rem auto 0 auto;
  padding-top: 2rem;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.info-section h2 {
  font-size: 1.5rem;
  font-weight: 600;
  margin-bottom: 1rem;
}

.info-section p,
.info-section li {
  line-height: 1.6;
  color: var(--muted-foreground);
}

.info-section ol {
  padding-left: 20px;
}

.info-section li {
  margin-bottom: 0.5rem;
}

.info-section strong {
  color: var(--foreground);
}

.info-section a {
  color: var(--primary);
  font-weight: 500;
  text-decoration: none;
}

.info-section a:hover {
  text-decoration: underline;
}

.table-container {
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  margin: 20px auto;
  padding: 15px;
  max-width: 950px;
  background-color: #ffffff;
  border-radius: 10px;
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.08);
}

.comparison-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.comparison-table th,
.comparison-table td {
  padding: 16px;
  border: 1px solid #e0e0e0;
}

.comparison-table thead {
  background-color: #007bff;
  color: #ffffff;
}

.comparison-table thead th {
  font-size: 1.1em;
  font-weight: 600;
}

.comparison-table tbody tr:nth-of-type(even) {
  background-color: #f8f9fa;
}

.comparison-table tbody tr:hover {
  background-color: #e9ecef;
}

.comparison-table td:first-child {
  font-weight: bold;
  color: #333;
}

.comparison-table strong {
  color: #0056b3;
}

@media screen and (max-width: 768px) {
  .comparison-table thead {
    display: none;
  }

  .comparison-table,
  .comparison-table tbody,
  .comparison-table tr,
  .comparison-table td {
    display: block;
    width: 100%;
  }

  .comparison-table tr {
    margin-bottom: 20px;
    border: 1px solid #ddd;
    border-radius: 8px;
    overflow: hidden;
  }

  .comparison-table td {
    border: none;
    border-bottom: 1px solid #e0e0e0;
    padding: 15px;
    text-align: left;
  }

  .comparison-table tr td:last-child {
    border-bottom: none;
  }

  .comparison-table td::before {
    content: attr(data-label);
    display: block;
    font-weight: bold;
    font-size: 0.9em;
    text-transform: uppercase;
    color: #007bff;
    margin-bottom: 8px;
  }

  .comparison-table td[data-label="Feature"]::before {
    display: none;
  }

  .comparison-table td[data-label="Feature"] {
    background-color: #f2f2f2;
    font-weight: bold;
    font-size: 1.2em;
    color: #333;
  }
}

.modal-item {
  position: relative;
}

.item-rarity {
  position: absolute;
  top: 4px;
  left: 4px;
  font-size: 0.7em;
  font-weight: bold;
  padding: 2px 5px;
  border-radius: 4px;
  color: white;
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
  z-index: 2;
}

.rarity-common {
  background-color: #9e9e9e;
}
.rarity-uncommon {
  background-color: #4caf50;
}
.rarity-rare {
  background-color: #2196f3;
}
.rarity-legendary {
  background-color: #9c27b0;
}
.rarity-mythical {
  background-color: #ff9800;
}
.rarity-divine {
  background-color: #f44336;
}

@keyframes shimmer {
  0% {
    background-position: 0% 50%;
  }
  50% {
    background-position: 100% 50%;
  }
  100% {
    background-position: 0% 50%;
  }
}

.rarity-prismatic {
  background-image: linear-gradient(
    90deg,
    #f9484a,
    #fbd72b,
    #51e28a,
    #34b3f1,
    #9b5de5,
    #f9484a
  );
  color: white;

  background-size: 200% 200%;
  animation: shimmer 4s linear infinite;
}

.item-inputs {
  display: flex;
  gap: 4px;
  width: 100%;
  margin-top: 5px;
  padding: 0 4px;
  box-sizing: border-box;
}

.item-inputs input {
  width: 100%;
  box-sizing: border-box;
  text-align: center;
  padding: 5px;
  border: 1px solid #555;
  border-radius: 4px;
}

.mutations-container {
  width: 100%;
}

.add-mutation-btn {
  margin-top: 5px;
  background-color: white;
  border-radius: 4px;
  border: 1px solid #555;
  width: 100%;
  padding: 4px;
}

.tabs-header {
  display: flex;
  border: 1px solid var(--border);
  border-radius: 4px;
  width: 500px;
  margin: auto;
  gap: 5px;
  overflow: hidden;
  padding: 5px;
}

.tab-btn {
  flex: 1;
  padding: 10px 0;
  border: none;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  background-color: transparent;
  color: #374151;
  border-radius: 4px;
}

.tab-btn:hover {
  background-color: #e2e8f0;
  border-color: var(--ring);
}

.tab-btn.active {
  background-color: #efefef;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.tabs-header a {
  text-decoration: none;
  color: inherit;
}

@media screen and (max-width: 768px) {
  /* 1. 让容器占据全部宽度 */
  .tabs-header {
    width: 100%;
    flex-direction: column; /* 核心：将按钮垂直堆叠 */
    border-radius: 8px; /* 稍微增大圆角以适应新布局 */
    margin-bottom: 2rem; /* 在下方增加一些间距 */
  }

  /* 2. 优化按钮样式，使其更适合触摸操作 */
  .tab-btn {
    padding: 14px 10px; /* 增大按钮的垂直内边距，使其更高 */
    font-size: 1rem; /* 增大字体，提高可读性 */
  }
}

.formula-container {
  background-color: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  margin: 2rem 0;
  padding: 1.5rem;
  font-family: "Georgia", "Times New Roman", Times, serif;
}

.formula-title {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--card-foreground);
  text-align: center;
  margin-bottom: 1.5rem;
}

.formula-section,
.formula-breakdown {
  margin-top: 1.5rem;
}

.formula-expression,
.breakdown-logic {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  font-size: 1.1rem;
}

.main-equation {
  font-size: 1.2rem;
}

.formula-expression span,
.breakdown-logic span,
.breakdown-logic div {
  white-space: nowrap;
}

.variable {
  color: #0f172a;
  font-weight: 500;
}
.long-var {
  background-color: #eef2f9;
  border: 1px solid #d1d9e6;
  padding: 0.25rem 0.75rem;
  border-radius: 4px;
}
.operator {
  color: #64748b;
  font-size: 1.2em;
}
.constant {
  color: #8f5bde;
  font-weight: bold;
}
.function {
  font-family: "SF Mono", monospace;
  color: #f59e0b;
  font-weight: 600;
}
.grouping {
  font-size: 1.8em;
  color: #94a3b8;
  font-weight: 300;
}

sup {
  font-size: 0.8em;
  vertical-align: super;
}

.formula-breakdown {
  border-top: 1px dashed var(--border);
  padding-top: 1.5rem;
}

.breakdown-title {
  font-family: -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 1rem;
  font-weight: 500;
  color: var(--muted-foreground);
  margin-bottom: 1rem;
  text-align: center;
}

.conditional-logic {
  display: flex;
  align-items: center;
}
.brace {
  font-size: 5em;
  font-weight: 200;
  line-height: 1;
  color: #94a3b8;
  margin-right: 0.75rem;
}
.conditions {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.condition-line {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.condition-text {
  font-family: -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 0.85rem;
  color: #64748b;
  font-style: italic;
}

.function.sigma {
  font-size: 1.5em;
  font-weight: 400;
  line-height: 1;
}

.formula-note {
  text-align: center;
  font-size: 0.85rem;
  color: var(--muted-foreground);
  margin-top: 1rem;
  font-style: italic;
  font-family: -apple-system, BlinkMacSystemFont, sans-serif;
}
