:root {
  color-scheme: dark;
  --bg: #14080b;
  --card: #221417;
  --line: #3a2428;
  --text: #f4efe8;
  --muted: #b7a8a2;
  --red: #e11d2e;
  --red-dark: #8d1220;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 "Segoe UI", "Microsoft YaHei", sans-serif;
}

main {
  max-width: 1040px;
  margin: 0 auto;
  padding: 32px 16px 64px;
}

h1 {
  margin: 0;
  text-align: center;
  font-size: 32px;
  letter-spacing: 0.04em;
}

h1 span { color: var(--red); }

.sub, .note, .hint, footer {
  color: var(--muted);
  text-align: center;
}

.role-switch, .tabs, .challenges, .actions, .filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.role-switch {
  margin: 20px 0;
  padding: 4px;
  background: #1b1013;
  border-radius: 12px;
}

.role-switch button, .tabs button, .challenges button, .actions button, .recent button {
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  font: inherit;
}

.role-switch button { flex: 1; padding: 12px; }

.role-switch button[aria-pressed="true"],
.tabs button[aria-selected="true"],
.challenges button[aria-pressed="true"],
.actions button.primary {
  background: var(--red);
}

.tabs { border-bottom: 1px solid var(--line); margin-bottom: 16px; }
.tabs button { padding: 10px 14px; border-radius: 10px 10px 0 0; }
.tabs button[aria-selected="true"] { border-bottom: 3px solid var(--red); background: transparent; color: var(--text); }

.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px;
  margin: 12px 0;
}

.challenges button {
  background: #3a3032;
  padding: 8px 14px;
  border-radius: 999px;
}

.rules { display: grid; gap: 10px; }
.rules label, .filters label { display: flex; gap: 8px; align-items: flex-start; }
.hint { display: block; margin-left: 24px; text-align: left; font-size: 13px; }

.luck { display: flex; justify-content: space-between; align-items: center; }
.luck strong { color: var(--red); }
input[type="range"] { width: 100%; accent-color: var(--red); }
.luck-scale { display: flex; justify-content: space-between; color: var(--muted); font-size: 13px; }

.block-title {
  margin: 18px 0 10px;
  font-size: 15px;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.who {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 0 4px;
  text-align: left;
}

.who span { font-size: 20px; color: var(--text); }

.portrait {
  width: 64px;
  height: 64px;
  object-fit: cover;
  border-radius: 12px;
  background: #0c0608;
}

.gear-owner { margin: 8px 0 0; text-align: left; }

.pieces {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
}

.piece {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  min-width: 0;
  padding: 14px 12px 12px;
  background: #12090c;
  border: 1px solid var(--line);
  border-radius: 14px;
}

.kind {
  align-self: flex-start;
  font-size: 12px;
  letter-spacing: 0.06em;
  color: #ffb4bc;
}

.piece-icon {
  width: 88px;
  height: 88px;
  object-fit: contain;
}

.piece h3 {
  margin: 0;
  width: 100%;
  text-align: center;
  font-size: 16px;
}

.piece .desc { width: 100%; }

.perks {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.perk {
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
  padding: 12px;
  background: #12090c;
  border: 1px solid var(--line);
  border-radius: 14px;
}

.perk-icon {
  width: 76px;
  height: 76px;
  object-fit: contain;
  background: radial-gradient(circle at 50% 35%, #4a3034, #0c0608 72%);
  border-radius: 12px;
}

.perk-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.perk h3 { margin: 0; font-size: 16px; }

.tag {
  flex: none;
  padding: 2px 8px;
  border-radius: 999px;
  background: #3a2428;
  color: var(--text);
  font-size: 12px;
}

.desc, .meta { margin: 6px 0 0; white-space: pre-wrap; color: var(--muted); font-size: 13px; line-height: 1.55; }
.meta { color: #7d6d68; font-size: 12px; }

.card, .tier-row, .collection details {
  background: #1a1012;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
}

.card {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.card .icon {
  width: 84px;
  height: 84px;
  object-fit: contain;
  background: #0c0608;
  border-radius: 8px;
}


.tier-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon.tiny {
  width: 32px;
  height: 32px;
  object-fit: contain;
}

.card h3 { margin: 0 0 6px; font-size: 16px; }
.card p, .tier-row p { margin: 6px 0 0; white-space: pre-wrap; color: var(--muted); font-size: 13px; }
.missing { color: #e7b341; font-size: 12px; }

.actions button { padding: 10px 14px; background: #2a1c1f; }
.recent { display: flex; flex-direction: column; gap: 8px; }
.recent button { text-align: left; background: #1a1012; border: 1px solid var(--line); padding: 8px 10px; }

.collection { display: grid; gap: 10px; }
.perk-list { display: grid; gap: 4px; margin-top: 8px; }

.tier-list { display: grid; gap: 8px; }
.filters { margin-bottom: 12px; align-items: center; }
select, input[type="checkbox"] { accent-color: var(--red); }
select { background: #1a1012; color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 6px; }

.copy-image {
  width: 100%;
  margin: 0 0 14px;
  padding: 12px;
  border: 0;
  border-radius: 10px;
  background: var(--red);
  color: white;
  font: inherit;
  cursor: pointer;
}

.error { text-align: center; font-size: 20px; }
button:disabled { opacity: 0.55; }

@media (max-width: 800px) {
  .cards, .perks, .pieces { grid-template-columns: 1fr; }
  .perk { grid-template-columns: 64px minmax(0, 1fr); }
  .perk-icon { width: 64px; height: 64px; }
}
