* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}
body {
  min-height: 100vh;
  margin: 0;
  display: flex;
  flex-direction: column;
  background: #0f172a;
  color: #e5e7eb;
  font-family:
    "Microsoft Yahei",
    system-ui,
    -apple-system,
    "Segoe UI",
    Roboto,
    "Helvetica Neue",
    Arial,
    sans-serif;
}
main.container {
  flex: 1;
  width: 100%;
}

/* 顶部栏：布局、边框与背景；用于放置标题和操作按钮 */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 10px;
  border-bottom: 1px solid #1f2937;
  background: #111827;
}

.topbar h1 {
  margin: 0;
  font-size: 20px;
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.author,
footer {
  font-size: 12px;
  color: #9ca3af;
  font-weight: 400;
}

footer {
  width: 100%;
  padding: 20px 10px;
  text-align: center;
  border-top: 1px solid #1f2937;
  background: #111827;
}
footer p {
  margin: 2px 0;
}

/*标题文字样式*/

.actions {
  display: flex;
  gap: 12px;
  align-items: center;
}
.actions button {
  min-height: 34px;
  padding: 6px 12px;
  border: 1px solid #374151;
  border-radius: 8px;
  background: #1f2937;
  color: #e5e7eb;
  cursor: pointer;
}
button {
  font: inherit;
  transition:
    background-color 0.15s ease,
    border-color 0.15s ease,
    color 0.15s ease,
    opacity 0.15s ease;
}
button:not(:disabled):hover {
  background-color: #374151;
}
button:focus-visible,
input:focus-visible {
  outline: 2px solid #3b82f6;
  outline-offset: 2px;
}


/* 页面主容器：控制页面内容的内边距与最大宽度并居中 */
.container {
  padding: 20px;
  max-width: 1800px;
  margin: 0 auto;
}

/* 搜索栏：输入框与按钮的布局与样式 */
.searchbar {
  display: flex;
  gap: 10px;
  width: 100%;
  max-width: 700px;
  margin: 0 auto 10px;
}
.searchbar input {
  flex: 1;
  min-width: 0;
  height: 38px;
  padding: 0 12px;
  border: 1px solid #1f2937;
  border-radius: 8px;
  background: #0b1220;
  color: #e5e7eb;
  font-size: 16px;
}
.searchbar button {
  flex: 0 0 auto;
  height: 38px;
  padding: 0 16px;
  border: 1px solid #374151;
  border-radius: 8px;
  background: #1f2937;
  color: #e5e7eb;
  cursor: pointer;
}

.suggestions-container {
  width: 100%;
  max-width: 700px;
  max-height: 320px;
  margin: 6px auto 0;
  overflow-y: auto;
  border: 1px solid #374151;
  border-radius: 8px;
  background: #1f2937;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.25);
}

.suggestions-container.hidden {
  display: none;
}

.suggestion-item {
  padding: 8px 12px;
  border-bottom: 1px solid #374151;
  cursor: pointer;
  transition: background-color 0.15s ease;
}

.suggestion-item:last-child {
  border-bottom: none;
}

.suggestion-item:hover {
  background: #374151;
}

/* 系统消息提示：默认、成功与失败状态颜色 */
.msg {
  min-height: 22px;
  margin: 12px auto 0;
  text-align: center;
  color: #9ca3af;
}

.msg.ok {
  color: #10b981;
}

.msg.bad {
  color: #ef4444;
}

/* 数据表格：外层间距与表格基础布局/边框 */
.tablewrap {
  width: 100%;
  margin-top: 16px;
  padding-bottom: 10px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

table.result {
  width: 100%;
  min-width: 1500px;
  border-collapse: collapse;
}

table.result thead th {
  padding: 6px 4px;
  text-align: center;
  font-weight: 600;
  white-space: nowrap;
  border-bottom: 1px solid #1f2937;
  background: #111827;
}

table.result tbody td {
  /* padding: 5px 4px; */
  text-align: center;
  vertical-align: middle;
  border-bottom: 1px solid #1f2937;
}

table.result tbody tr {
  transition: background-color 0.15s ease;
}
table.result tbody tr:nth-child(even) {
  background-color: rgba(255, 255, 255, 0.025);
}
table.result tbody tr:hover {
  background-color: rgba(255, 255, 255, 0.1);
}


/* 表格内状态色：成功与失败列的高亮 */
td.ok {
  color: #10b981;
  font-weight: 600;
}

td.bad {
  color: #ef4444;
}

td.bad_low {
  color: #ef4444;
}

td.bad_low::after {
  content: " ↑";
}


td.bad_high {
  color: #ef4444;
}

td.bad_high::after {
  content: " ↓";
}

td.close_low {
  color: #fbbf24;
}



td.close_low::after {
  content: " ↑";
  /* 目标值更高 */
}

td.close_high {
  color: #fbbf24;
}

td.close_high::after {
  content: " ↓";
  /* 目标值更低 */
}

/* 标签样式：用于显示列表类型的属性（如胜鞍、服务器） */
.tags {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 4px;
  min-width: 120px;
  max-width: 240px;
  margin: 0 auto;
}

.tag {
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 12px;
  background: #1f2937;
  color: #9ca3af;
  border: 1px solid #374151;
}

.tag.ok {
  background: #064e3b;
  color: #34d399;
  border-color: #059669;
}

.tag.bad {
  background: #450a0a;
  color: #f87171;
  border-color: #b91c1c;
}

input:disabled,
button:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 20px;
  overflow-y: auto;
  background: rgba(0, 0, 0, 0.7);
}


.modal.hidden {
  display: none;
}

.modal-content {
  width: 90%;
  max-width: 400px;
  max-height: calc(100dvh - 40px);
  overflow-y: auto;
  padding: 24px;
  border: 1px solid #374151;
  border-radius: 12px;
  background: #1f2937;
  box-shadow:
    0 10px 25px rgba(0, 0, 0, 0.35),
    0 4px 10px rgba(0, 0, 0, 0.2);
}

.modal-content h2 {
  margin: 0 0 20px 0;
  font-size: 1.5rem;
  color: #f3f4f6;
  text-align: center;
}

.form-group {
  margin-bottom: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.form-group label {
  color: #d1d5db;
  font-size: 0.95rem;
}

.form-group input {
  height: 40px;
  padding: 0 12px;
  border-radius: 6px;
  border: 1px solid #374151;
  background: #111827;
  color: #f3f4f6;
  font-size: 1rem;
}

.form-group input:focus {
  /* outline: none; */
  border-color: #3b82f6;

}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

.modal-actions button {
  padding: 8px 16px;
  border: 1px solid transparent;
  border-radius: 6px;
  font-size: 0.95rem;
  cursor: pointer;
}

#save-setting {
  background: #2563eb;
  color: white;
}

#save-setting:hover {
  background: #1d4ed8;
}

#cancel-setting {
  background: transparent;
  color: #d1d5db;
  border: 1px solid #374151;
}

#cancel-setting:hover {
  background: #374151;
  color: white;
}


/* 响应式适配 */
@media (max-width: 768px) {
  .topbar {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    padding-top: max(10px, env(safe-area-inset-top));
    padding-right: max(10px, env(safe-area-inset-right));
    padding-bottom: 10px;
    padding-left: max(10px, env(safe-area-inset-left));
  }
  .topbar h1 {
    flex-wrap: wrap;
    justify-content: center;
    font-size: 17px;
    line-height: 1.3;
    text-align: center;
  }
  .author {
    font-size: 11px;
    white-space: nowrap;
  }
  .actions {
    justify-content: center;
    flex-wrap: wrap;
    gap: 8px 12px;
    width: 100%;
  }
  .actions button {
    min-height: 44px;
  }
  #attempts {
    white-space: nowrap;
  }
  .container {
    padding: 10px;
  }
  .searchbar {
    flex-wrap: wrap;
    padding: 0;
  }
  .searchbar input {
    flex: 1 1 100%;
    width: 100%;
    height: 44px;
    margin: 0;
  }
  .searchbar button {
    flex: 1 1 calc(50% - 5px);
    width: auto;
    height: 44px;
    margin: 0;
  }
  .suggestions-container {
    max-height: min(240px, 35dvh);
    overscroll-behavior: contain;
  }
  .suggestion-item {
    display: flex;
    align-items: center;
    min-height: 44px;
    padding: 10px 12px;
    overflow-wrap: anywhere;
  }
  .game-tip {
    margin-top: 8px;
    padding: 0 4px;
    font-size: 12px;
    line-height: 1.5;
  }
  .msg {
    margin-top: 8px;
    padding: 0 8px;
    font-size: 14px;
    line-height: 1.5;
    overflow-wrap: anywhere;
  }
  .tablewrap {
    width: calc(100% + 20px);
    margin-right: -10px;
    margin-left: -10px;
    padding-right: 10px;
    padding-left: 10px;
    overscroll-behavior-x: contain;
  }
  table.result {
    min-width: 1350px;
    font-size: 12px;
  }
  table.result thead th {
    padding: 7px 4px;
  }
  table.result tbody td {
    padding: 6px 4px;
  }

  table.result thead th:first-child {
    z-index: 4;
    background-color: #111827;
  }
  table.result tbody tr:nth-child(even) td:first-child {
    background-color: #111827;
  }
  .tags {
    min-width: 100px;
    max-width: 180px;
  }
  .tag {
    padding: 2px 4px;
    font-size: 11px;
  }
  /* 移动端设置面板。 */
  .modal {
    align-items: flex-end;
    padding: 0;
  }
  .modal-content {
    width: 100%;
    max-width: none;
    max-height: calc(100dvh - 20px);
    padding-top: 20px;
    padding-right: max(20px, env(safe-area-inset-right));
    padding-bottom: max(20px, env(safe-area-inset-bottom));
    padding-left: max(20px, env(safe-area-inset-left));
    border-right: none;
    border-bottom: none;
    border-left: none;
    border-radius: 16px 16px 0 0;
  }
  .modal-content h2 {
    margin-bottom: 16px;
    font-size: 1.25rem;
  }
  .modal-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }
  .modal-actions button {
    width: 100%;
    min-height: 44px;
  }
  footer {
    padding-top: 16px;
    padding-right: max(14px, env(safe-area-inset-right));
    padding-bottom: max(20px, env(safe-area-inset-bottom));
    padding-left: max(14px, env(safe-area-inset-left));
  }
  footer p {
    line-height: 1.6;
    overflow-wrap: anywhere;
  }
}
@media (max-width: 380px) {
  .searchbar button {
    flex-basis: 100%;
  }
  .topbar h1 {
    flex-direction: column;
    align-items: center;
    gap: 2px;
  }
}

.game-tip {
  margin-top: 10px;
  color: #9ca3af;
  font-size: 14px;
  text-align: center;
}

table.result thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  padding: 6px 4px;
  text-align: center;
  font-weight: 600;
  white-space: nowrap;
  border-bottom: 1px solid #1f2937;
  background: #111827;
}

button:not(:disabled):active {
  transform: translateY(1px);
}

input::placeholder {
  color: #6b7280;
  opacity: 1;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}


.tablewrap {
  overscroll-behavior-x: contain;
  scrollbar-color: #4b5563 #111827;
  scrollbar-width: thin;
}

.tablewrap::-webkit-scrollbar {
  height: 8px;
}
.tablewrap::-webkit-scrollbar-track {
  background: #111827;
  border-radius: 999px;
}
.tablewrap::-webkit-scrollbar-thumb {
  background: #4b5563;
  border-radius: 999px;
}
.tablewrap::-webkit-scrollbar-thumb:hover {
  background: #6b7280;
}

@media (max-width: 768px) {
  .tablewrap {
    width: calc(100% + 20px);
    margin-right: -10px;
    margin-left: -10px;
    padding-right: 10px;
    padding-left: 10px;
  }
}

@media (max-width: 768px) {
  table.result {
    min-width: 1350px;
    font-size: 12px;
  }
  table.result thead th {
    padding: 7px 4px;
  }
  table.result tbody td {
    padding: 6px 4px;
  }
  .tags {
    min-width: 100px;
    max-width: 180px;
  }
  .tag {
    padding: 2px 4px;
    font-size: 11px;
  }
  .topbar {
    gap: 8px;
    padding: 10px;
  }
  .topbar h1 {
    flex-wrap: wrap;
    line-height: 1.3;
    text-align: center;
  }
  .author {
    white-space: nowrap;
  }
  .actions {
    gap: 8px 12px;
  }
  #attempts {
    white-space: nowrap;
  }
}

@media (max-width: 768px) {
  .topbar h1 {
    font-size: 17px;
  }
  .author {
    font-size: 11px;
  }
}


@media (max-width: 768px) {
  .suggestions-container {
    max-height: min(240px, 35dvh);
    overscroll-behavior: contain;
  }
}

.suggestion-item {
  overflow-wrap: anywhere;
}

.game-tip {
  margin-top: 10px;
  color: #9ca3af;
  font-size: 14px;
  line-height: 1.6;
  text-align: center;
}
@media (max-width: 768px) {
  .game-tip {
    margin-top: 8px;
    padding: 0 4px;
    font-size: 12px;
    line-height: 1.5;
  }
  .msg {
    margin-top: 8px;
    padding: 0 8px;
    font-size: 14px;
    line-height: 1.5;
    overflow-wrap: anywhere;
  }
}

@media (max-width: 768px) {
  .modal {
    align-items: center;
    padding:
      max(16px, env(safe-area-inset-top))
      max(16px, env(safe-area-inset-right))
      max(16px, env(safe-area-inset-bottom))
      max(16px, env(safe-area-inset-left));
  }
  .modal-content {
    width: 100%;
    max-width: 400px;
    max-height: calc(100dvh - 32px);
    padding: 20px;
    overflow-y: auto;
    border: 1px solid #374151;
    border-radius: 12px;
  }
  .modal-content h2 {
    margin-bottom: 16px;
    font-size: 1.25rem;
  }
  .modal-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }
  .modal-actions button {
    width: 100%;
    min-height: 44px;
  }
}

.topbar {
  padding-top: max(6px, env(safe-area-inset-top));
}
footer {
  padding-bottom: max(20px, env(safe-area-inset-bottom));
}

@media (max-width: 768px) {
  .topbar {
    padding-top: max(10px, env(safe-area-inset-top));
    padding-right: max(10px, env(safe-area-inset-right));
    padding-left: max(10px, env(safe-area-inset-left));
  }
  footer {
    padding-right: max(10px, env(safe-area-inset-right));
    padding-bottom: max(20px, env(safe-area-inset-bottom));
    padding-left: max(10px, env(safe-area-inset-left));
  }
  .modal-content {
    padding-right: max(20px, env(safe-area-inset-right));
    padding-bottom: max(20px, env(safe-area-inset-bottom));
    padding-left: max(20px, env(safe-area-inset-left));
  }
}


@media (max-width: 768px) {
  footer {
    padding: 16px 14px;
  }
  footer p {
    line-height: 1.6;
  }
}

footer p {
  margin: 2px 0;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

@media (max-width: 900px) and (orientation: landscape) {
  .topbar {
    flex-direction: row;
    padding-top: 6px;
    padding-bottom: 6px;
  }
  .topbar h1 {
    font-size: 16px;
  }
  .container {
    padding-top: 10px;
  }
  .modal {
    align-items: center;
    padding: 10px;
  }
  .modal-content {
    width: min(90%, 420px);
    max-height: calc(100dvh - 20px);
    border: 1px solid #374151;
    border-radius: 12px;
  }
}

@media (hover: hover) and (pointer: fine) {
  button:not(:disabled):hover {
    background-color: #374151;
  }
  .suggestion-item:hover {
    background-color: #374151;
  }
  table.result tbody tr:hover {
    background-color: rgba(255, 255, 255, 0.1);
  }
  #save-setting:hover {
    background-color: #1d4ed8;
  }
  #cancel-setting:hover {
    background-color: #374151;
    color: white;
  }
}

footer a {
  color: inherit;
}
footer a:hover {
  color: #e5e7eb;
}