:root {
  --bg: #1b1d27; --panel: #242736; --panel-2: #2c3042; --line: #343849; --text: #e8e9f0; --muted: #8d91a8;
  --accent: #7c4dff; --accent-hover: #8d63ff; --twitch: #9146ff; --danger: #ff6b6b;
  --common: #9aa0b4; --uncommon: #5fd3a0; --rare: #4dabff; --legendary: #f5a623; --worn: #3ba55d; --coin: #f5c442;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 "Segoe UI", system-ui, -apple-system, sans-serif; }
[hidden] { display: none !important; }
a { color: inherit; }
h1 { font-size: 22px; margin: 0 0 6px; }
h2 { font-size: 17px; margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.error { color: var(--danger); }

.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--line); background: var(--panel); }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 18px; }
.logo { width: 22px; height: 22px; border-radius: 6px; background: linear-gradient(135deg, var(--accent), var(--uncommon)); }
.user { display: flex; align-items: center; gap: 10px; font-size: 14px; }
.user form { margin: 0; }

main { max-width: 980px; margin: 0 auto; padding: 16px; display: grid; gap: 16px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 18px; }

.btn { display: inline-flex; align-items: center; gap: 8px; border: 0; border-radius: 8px; padding: 9px 16px; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; background: var(--panel-2); color: var(--text); }
.btn:hover { filter: brightness(1.15); }
.btn:focus-visible, input:focus-visible { outline: 2px solid var(--accent-hover); outline-offset: 2px; }
.btn.twitch { background: var(--twitch); color: #fff; }
.btn.ghost { background: transparent; border: 1px solid var(--line); padding: 6px 12px; font-weight: 500; }
input { font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 6px 10px; }

.hero { display: flex; align-items: center; gap: 24px; flex-wrap: wrap; }
.hero > div { flex: 1 1 280px; }
.dev { margin-top: 16px; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; font-size: 13px; color: var(--muted); }

canvas { image-rendering: pixelated; }
#dino, #hero-dino { width: 192px; height: 192px; background: var(--panel-2); border-radius: 12px; flex: none; }
.profile { display: flex; gap: 24px; align-items: center; flex-wrap: wrap; }
.stats { flex: 1 1 260px; display: grid; gap: 10px; }
.stats h1 { margin: 0; }
.level { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-weight: 600; }
.bar { flex: 1 1 160px; height: 10px; background: var(--bg); border-radius: 99px; overflow: hidden; }
.bar > div { height: 100%; width: 0; background: linear-gradient(90deg, var(--accent), var(--rare)); }
.coins { display: flex; align-items: center; gap: 8px; }
.coin { width: 14px; height: 14px; border-radius: 50%; background: var(--coin); box-shadow: inset -2px -2px 0 #c99a1d; }

.inv-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chips button { font: inherit; font-size: 13px; color: var(--muted); background: var(--panel-2); border: 1px solid var(--line); border-radius: 99px; padding: 4px 12px; cursor: pointer; }
.chips button[aria-selected="true"] { color: #fff; background: var(--accent); border-color: var(--accent); }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 10px; }
.cell { position: relative; aspect-ratio: 1; background: var(--panel-2); border: 3px solid var(--common); border-radius: 10px; display: grid; place-items: center; }
.cell.uncommon { border-color: var(--uncommon); } .cell.rare { border-color: var(--rare); } .cell.legendary { border-color: var(--legendary); }
.cell canvas { width: 72%; height: 72%; }
.cell .name { position: absolute; left: 0; right: 0; bottom: 4px; text-align: center; font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding: 0 6px; }
.cell .worn { position: absolute; top: 4px; right: 4px; width: 18px; height: 18px; border-radius: 5px; background: var(--worn); color: #fff; font-size: 12px; display: grid; place-items: center; font-weight: 700; }
.legend { margin: 14px 0 0; font-size: 13px; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.sw.worn { display: inline-block; width: 12px; height: 12px; border-radius: 3px; background: var(--worn); }
.r { padding: 0 6px; border-radius: 4px; border: 2px solid; }
.r.common { border-color: var(--common); } .r.uncommon { border-color: var(--uncommon); } .r.rare { border-color: var(--rare); } .r.legendary { border-color: var(--legendary); }

@media (max-width: 520px) {
  main { padding: 12px; }
  .profile { justify-content: center; text-align: center; }
  .level, .coins { justify-content: center; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); }
}
