/* ===== Reset ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: "Segoe UI", system-ui, sans-serif;
  background: #0d1117;
  color: #c9d1d9;
  min-height: 100vh;
  padding: 32px 16px 48px;
}
.container { max-width: 920px; margin: 0 auto; }

/* ===== Header — centered ===== */
.header { text-align: center; margin-bottom: 24px; }
.title {
  font-size: 2rem;
  font-weight: 800;
  color: #f0a500;
  letter-spacing: 1px;
}
.subtitle { margin-top: 8px; font-size: 0.88rem; color: #8b949e; letter-spacing: .5px; }

/* ===== Search bar ===== */
.search-wrap { margin-bottom: 20px; }
.search-box {
  display: flex;
  align-items: center;
  background: #161b22;
  border: 1px solid #30363d;
  border-radius: 10px;
  padding: 0 14px;
  transition: border-color .2s;
}
.search-box:focus-within { border-color: #f0a500; }
.search-icon { width: 16px; height: 16px; flex-shrink: 0; margin-right: 10px; }
#search-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: #c9d1d9;
  font-size: 0.9rem;
  padding: 11px 0;
  font-family: "Courier New", monospace;
}
#search-input::placeholder { color: #484f58; font-family: "Segoe UI", system-ui, sans-serif; }
#btn-search {
  flex-shrink: 0;
  padding: 6px 18px;
  background: #f0a500;
  color: #0d1117;
  border: none;
  border-radius: 7px;
  font-size: 0.84rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .2s;
  margin-left: 10px;
}
#btn-search:hover { background: #d4900a; }
#btn-search:disabled { opacity: .5; cursor: default; }

/* ===== Controls bar ===== */
.controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
  gap: 12px;
  flex-wrap: wrap;
}
.controls-left { display: flex; align-items: center; gap: 10px; }
.last-update-text { font-size: 0.8rem; color: #8b949e; }
.btn-refresh {
  padding: 5px 14px;
  border: 1px solid #30363d;
  border-radius: 6px;
  background: #21262d;
  color: #c9d1d9;
  cursor: pointer;
  font-size: 0.82rem;
  transition: background .2s;
}
.btn-refresh:hover { background: #30363d; }
.btn-refresh:disabled { opacity: .45; cursor: default; }
.controls-right { display: flex; align-items: center; gap: 12px; }
.total-info { font-size: 0.82rem; color: #8b949e; }
.total-info strong { color: #c9d1d9; font-weight: 600; }
.divider { width: 1px; height: 16px; background: #30363d; }
.auto-refresh-wrap { display: flex; align-items: center; gap: 6px; }
.ar-label { font-size: 0.8rem; color: #8b949e; }
.ar-countdown { font-size: 0.78rem; font-family: "Courier New", monospace; color: #f0a500; min-width: 22px; }

/* Toggle switch */
.toggle-switch { position: relative; display: inline-block; width: 34px; height: 18px; cursor: pointer; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; inset: 0; background: #30363d; border-radius: 18px; transition: background .25s; }
.slider::before {
  content: ""; position: absolute;
  width: 12px; height: 12px; left: 3px; top: 3px;
  background: #c9d1d9; border-radius: 50%; transition: transform .25s;
}
.toggle-switch input:checked + .slider { background: #f0a500; }
.toggle-switch input:checked + .slider::before { transform: translateX(16px); }

/* ===== Table ===== */
.table-wrap { border: 1px solid #21262d; border-radius: 10px; overflow: hidden; }
table { width: 100%; border-collapse: collapse; }
thead tr { background: #161b22; }
th {
  padding: 12px 16px; text-align: left;
  font-size: 0.75rem; color: #8b949e;
  text-transform: uppercase; letter-spacing: 1px;
  border-bottom: 1px solid #21262d;
}
tbody tr { border-bottom: 1px solid #21262d; transition: background .15s; }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: #161b22; }
td { padding: 13px 16px; font-size: 0.92rem; }

.col-rank { width: 72px; text-align: center; }
.col-diff { width: 160px; text-align: right; }
.col-time { width: 155px; color: #8b949e; font-size: 0.8rem; }

.rank-badge {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; border-radius: 50%; font-weight: 700; font-size: .88rem;
}
.rank-1 { background: #f0a500; color: #0d1117; font-size: 1.15rem; }
.rank-2 { background: #8b949e; color: #0d1117; font-size: 1.15rem; }
.rank-3 { background: #7d4e00; color: #ffd27f; font-size: 1.15rem; }
.rank-other { background: #21262d; color: #8b949e; }

.diff-value { font-family: "Courier New", monospace; font-weight: 600; color: #58a6ff; }
.wallet-addr { font-family: "Courier New", monospace; font-size: 0.84rem; word-break: break-all; }
.loading, .empty { text-align: center; padding: 40px; color: #8b949e; font-size: .95rem; }
.error-msg { color: #f85149; }

/* ===== Table footer ===== */
.table-footer {
  display: flex; justify-content: space-between; align-items: center;
  margin-top: 14px; flex-wrap: wrap; gap: 10px;
}
.page-size-wrap { display: flex; align-items: center; gap: 8px; font-size: .8rem; color: #8b949e; }
#page-size-select {
  background: #161b22; border: 1px solid #30363d;
  color: #c9d1d9; border-radius: 6px; padding: 3px 8px; font-size: .8rem; cursor: pointer;
}
#page-size-select:focus { outline: none; border-color: #f0a500; }

.pagination { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.pg-btn {
  min-width: 32px; height: 30px; padding: 0 8px;
  border: 1px solid #30363d; border-radius: 6px;
  background: #161b22; color: #c9d1d9; font-size: .82rem;
  cursor: pointer; transition: background .15s;
}
.pg-btn:hover:not([disabled]):not(.active) { background: #21262d; }
.pg-btn.active { background: #f0a500; border-color: #f0a500; color: #0d1117; font-weight: 700; cursor: default; }
.pg-btn[disabled] { opacity: .3; cursor: default; }
.pg-ellipsis { color: #8b949e; font-size: .88rem; padding: 0 2px; }

/* ===== Modal ===== */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.7);
  backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
  animation: fadeIn .18s ease;
}
.modal-overlay.hidden { display: none; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal-card {
  position: relative;
  background: #161b22;
  border: 1px solid #30363d;
  border-radius: 16px;
  padding: 40px 48px;
  min-width: 340px;
  max-width: 480px;
  width: 90%;
  text-align: center;
  animation: slideUp .2s ease;
  box-shadow: 0 24px 64px rgba(0,0,0,.5);
}
@keyframes slideUp { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

.modal-close {
  position: absolute; top: 14px; right: 16px;
  background: none; border: none;
  color: #8b949e; font-size: 1.1rem; cursor: pointer; line-height: 1;
  transition: color .15s;
}
.modal-close:hover { color: #c9d1d9; }

/* Found state */
.modal-medal { font-size: 3.5rem; line-height: 1; margin-bottom: 8px; }
.modal-rank-num {
  font-size: 4rem; font-weight: 900; color: #f0a500;
  line-height: 1; letter-spacing: -1px;
}
.modal-rank-num sup { font-size: 1.4rem; font-weight: 700; vertical-align: super; }
.modal-rank-label { font-size: 0.85rem; color: #8b949e; text-transform: uppercase; letter-spacing: 1.5px; margin: 6px 0 16px; }
.modal-wallet {
  font-family: "Courier New", monospace; font-size: 0.82rem;
  color: #8b949e; background: #0d1117;
  border-radius: 6px; padding: 6px 12px; margin-bottom: 20px;
  word-break: break-all;
}
.modal-stats {
  display: flex; justify-content: center; gap: 24px; flex-wrap: wrap;
  padding-top: 16px; border-top: 1px solid #21262d;
}
.modal-stat { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.stat-label { font-size: 0.72rem; color: #8b949e; text-transform: uppercase; letter-spacing: 1px; }
.stat-val { font-size: 1.05rem; font-weight: 600; color: #c9d1d9; }

/* Not found state */
.modal-notfound { padding: 8px 0; }
.modal-nf-icon { font-size: 3rem; margin-bottom: 12px; }
.modal-nf-title { font-size: 1.5rem; font-weight: 700; color: #f85149; margin-bottom: 10px; }
.modal-nf-wallet {
  font-family: "Courier New", monospace; font-size: 0.8rem;
  color: #8b949e; background: #0d1117;
  border-radius: 6px; padding: 5px 10px; margin-bottom: 16px;
  word-break: break-all;
}
.modal-nf-msg { font-size: 0.95rem; color: #c9d1d9; line-height: 1.6; margin-bottom: 8px; }
.modal-nf-hint { font-size: 0.82rem; color: #8b949e; }

/* ===== Responsive ===== */
@media (max-width: 600px) {
  .title { font-size: 1.45rem; }
  .col-time { display: none; }
  .col-diff { width: 110px; }
  .modal-card { padding: 28px 20px; }
  .modal-rank-num { font-size: 3rem; }
}
