:root {
  --bg: #14120e;
  --panel: #1e1b14;
  --panel2: #27231a;
  --border: #3d3626;
  --gold: #d8b95c;
  --gold-dim: #a08a4a;
  --text: #e8e0cc;
  --muted: #9b9180;
  --red: #e2654f;
  --green: #7fbf6a;
  --blue: #6fa8dc;
  --chip: #332d1f;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html {
  font-size: 16px;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  padding-bottom: 40px;
}

header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  padding: calc(env(safe-area-inset-top) + 16px) 12px 16px;
}

.logo {
  margin: 0 2px 20px;
  text-align: center;
}

.logo img {
  display: block;
  margin-inline: auto;
  max-width: 100%;
  height: auto;
  max-height: 96px;
  width: auto;
}

.tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 8px;
}

.tab {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 0;
  border-radius: 5px;
  cursor: pointer;
  user-select: none;
  font-weight: 700;
  font-size: 0.95rem;
  color: #ff981f;
  text-shadow: 1px 1px 0 #000;
  letter-spacing: 0.3px;
  background: linear-gradient(#544936, #3e3526 45%, #2e2719);
  border: 2px solid;
  border-color: #6f6147 #211c12 #211c12 #6f6147;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.07);
}

.tab.active {
  background: linear-gradient(#26201400, #00000000), linear-gradient(#272014, #362c1c 60%, #3e3220);
  border-color: #211c12 #6f6147 #6f6147 #211c12;
  color: #f8e25c;
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.55);
}

.tab svg,
.tab img {
  width: 19px;
  height: 19px;
  flex: 0 0 auto;
  filter: drop-shadow(1px 1px 0 rgba(0, 0, 0, 0.6));
}

.tab svg {
  display: none;
}

#search {
  width: 100%;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  font-size: 1rem;
  outline: none;
}

#search:focus {
  border-color: var(--gold-dim);
}

#count {
  font-size: 0.72rem;
  color: var(--muted);
  margin: 6px 4px 0;
}

main {
  padding: 10px 12px;
}

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  margin-bottom: 8px;
  overflow: hidden;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  cursor: pointer;
  user-select: none;
}

.card-head .nm {
  font-weight: 600;
  font-size: 1rem;
}

.card-head .sub {
  font-size: 0.72rem;
  color: var(--muted);
  margin-top: 2px;
}

.lvl {
  font-size: 0.78rem;
  color: var(--gold);
  background: var(--chip);
  border: 1px solid var(--border);
  padding: 3px 8px;
  border-radius: 8px;
  white-space: nowrap;
  margin-left: 8px;
}

.body {
  display: none;
  border-top: 1px solid var(--border);
  padding: 10px 14px 14px;
  background: var(--panel2);
}

.card.open .body {
  display: block;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 2px 0 10px;
}

.chip {
  padding: 7px 11px;
  border-radius: 16px;
  background: var(--chip);
  border: 1px solid var(--border);
  font-size: 0.82rem;
  color: var(--muted);
  cursor: pointer;
}

.chip.sel {
  color: var(--gold);
  border-color: var(--gold-dim);
  font-weight: 600;
}

.row {
  display: flex;
  margin-bottom: 8px;
  line-height: 1.45;
}

.lbl {
  flex: 0 0 62px;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.8px;
  color: var(--gold-dim);
  text-transform: uppercase;
  padding-top: 3px;
}

.val {
  flex: 1;
  font-size: 0.88rem;
}

.val .req {
  color: var(--red);
  font-weight: 600;
}

.val .ok {
  color: var(--green);
}

.pity {
  color: var(--blue);
  font-weight: 600;
}

.wiki {
  display: inline-block;
  margin-top: 4px;
  font-size: 0.8rem;
  color: var(--blue);
  text-decoration: none;
  border: 1px solid var(--border);
  padding: 6px 12px;
  border-radius: 8px;
  background: var(--panel);
}

.empty {
  text-align: center;
  color: var(--muted);
  padding: 40px 20px;
  font-size: 0.9rem;
}

.mchips {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  margin-top: 8px;
  padding-bottom: 2px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.mchips::-webkit-scrollbar {
  display: none;
}

.mchip {
  flex: 0 0 auto;
  padding: 6px 12px;
  border-radius: 14px;
  background: var(--panel);
  border: 1px solid var(--border);
  font-size: 0.78rem;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}

.mchip.sel {
  color: var(--gold);
  border-color: var(--gold-dim);
  background: var(--chip);
  font-weight: 600;
}

.fav {
  font-size: 1.15rem;
  padding: 4px 8px 4px 2px;
  cursor: pointer;
  user-select: none;
  color: var(--muted);
  line-height: 1;
}

.fav.on {
  color: var(--gold);
}

.note {
  font-size: 0.75rem;
  color: var(--muted);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 10px;
  line-height: 1.5;
}

.note b {
  color: var(--gold);
}

footer {
  font-size: 0.68rem;
  color: var(--muted);
  text-align: center;
  padding: 18px 20px 8px;
  line-height: 1.6;
}

.card-head-title {
  flex: 1;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  padding-top: calc(env(safe-area-inset-top) + 20px);
  padding-bottom: calc(env(safe-area-inset-bottom) + 20px);
  background: rgba(0, 0, 0, 0.72);
}

.modal-backdrop[hidden] {
  display: none;
}

.modal {
  width: 100%;
  max-width: 360px;
  background: var(--panel);
  border: 2px solid var(--border);
  border-radius: 14px;
  padding: 22px 20px 18px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.55);
}

.modal-title {
  margin: 0 0 14px;
  font-size: 1.15rem;
  color: var(--gold);
  text-align: center;
}

.modal p {
  margin: 0 0 12px;
  font-size: 0.9rem;
  line-height: 1.55;
  color: var(--text);
}

.modal p strong {
  color: var(--gold);
}

.modal-domain {
  margin-bottom: 16px !important;
  font-size: 0.85rem !important;
  color: var(--muted);
}

.modal-domain a {
  color: var(--blue);
  text-decoration: none;
  font-weight: 600;
}

.modal-dismiss-label {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
  font-size: 0.82rem;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
}

.modal-dismiss-label input {
  width: 16px;
  height: 16px;
  accent-color: var(--gold);
  cursor: pointer;
}

.modal-btn {
  width: 100%;
  padding: 12px 16px;
  border-radius: 8px;
  border: 2px solid;
  border-color: #6f6147 #211c12 #211c12 #6f6147;
  background: linear-gradient(#544936, #3e3526 45%, #2e2719);
  color: #f8e25c;
  font-weight: 700;
  font-size: 0.95rem;
  text-shadow: 1px 1px 0 #000;
  cursor: pointer;
  letter-spacing: 0.3px;
}

.modal-btn:active {
  border-color: #211c12 #6f6147 #6f6147 #211c12;
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.55);
}
