/* AchievementGoblin — tavern-at-night palette: dark wood, lantern gold, goblin green */
:root {
  --bg: #120b07;
  --bg-2: #1a110b;
  --panel: #21160e;
  --panel-2: #2b1d12;
  --wood: #4b321e;
  --wood-hi: #6b4a2b;
  --gold: #f6b92f;
  --gold-hi: #ffdc6b;
  --gold-lo: #a86c0c;
  --goblin: #9fd23f;
  --goblin-lo: #5c8a1a;
  --sky: #8cc3f0;
  --parch: #ead7aa;
  --text: #f4e7cd;
  --muted: #b39d7e;
  --radius: 14px;
  --shadow: 0 10px 30px rgba(0, 0, 0, .45);

  --r-legend: #ff9b3d;
  --r-epic: #c58cff;
  --r-rare: #6fb6ff;
  --r-common: #a99a86;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: "Nunito", system-ui, sans-serif;
  color: var(--text);
  background:
    radial-gradient(1200px 600px at 85% -10%, rgba(246, 185, 47, .13), transparent 60%),
    radial-gradient(900px 500px at -10% 30%, rgba(159, 210, 63, .07), transparent 60%),
    radial-gradient(800px 600px at 50% 120%, rgba(246, 150, 47, .08), transparent 60%),
    var(--bg);
  background-attachment: fixed;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; display: block; }
a { color: var(--gold-hi); }
button, select, input { font: inherit; color: inherit; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
[hidden] { display: none !important; }

h1, h2, h3, .brand, .stat b {
  font-family: "Lilita One", "Nunito", sans-serif;
  font-weight: 400;
  letter-spacing: .3px;
}

/* ─── topbar ─── */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 10px max(16px, calc((100% - 1240px) / 2));
  background: rgba(18, 11, 7, .86);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--wood);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--gold); font-size: 1.45rem; text-shadow: 0 2px 0 #5a3405; }
.brand img { border-radius: 50%; border: 2px solid var(--gold); }
.brand .g { color: var(--gold-hi); }
.links { display: flex; gap: 8px; flex-wrap: wrap; }
.links a {
  text-decoration: none; font-weight: 700; font-size: .9rem; color: var(--parch);
  padding: 6px 12px; border-radius: 999px; border: 1px solid var(--wood);
}
.links a:hover { border-color: var(--gold); color: var(--gold-hi); }

main { max-width: 1240px; margin: 0 auto; padding: 22px 16px 40px; }

/* ─── hero ─── */
.hero {
  position: relative;
  border-radius: calc(var(--radius) + 4px);
  overflow: hidden;
  border: 2px solid var(--gold-lo);
  box-shadow: var(--shadow), 0 0 0 4px #2a1a0d, 0 0 40px rgba(246, 185, 47, .15);
  background: var(--panel);
}
.player { position: relative; width: 100%; aspect-ratio: 16 / 9; background: #0d0805 url("img/offline.webp") center / cover no-repeat; }
.player iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.player .watch {
  position: absolute; inset: 0; display: grid; place-items: end center; padding: 24px;
  background: linear-gradient(180deg, transparent 55%, rgba(13, 8, 5, .85));
  text-decoration: none;
}
.player .watch span { background: #9146ff; color: #fff; font-weight: 800; padding: 10px 18px; border-radius: 10px; box-shadow: 0 4px 14px rgba(0, 0, 0, .5); }
.hero-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  padding: 14px 20px;
  background: linear-gradient(180deg, #2a1b10, #1c120b);
  border-top: 2px solid var(--gold-lo);
}
.who { display: flex; align-items: center; gap: 14px; }
.avatar { width: 64px; height: 64px; border-radius: 12px; border: 3px solid var(--gold); box-shadow: 0 0 0 3px #3b250f; object-fit: cover; }
.who h1 { margin: 0; font-size: clamp(1.4rem, 3vw, 2rem); color: var(--gold-hi); text-shadow: 0 2px 0 #5a3405; }
.who p { margin: 2px 0 0; font-size: .9rem; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; list-style: none; margin: 0; padding: 0; }
.chips li {
  font-size: .82rem; font-weight: 800; padding: 6px 12px; border-radius: 999px;
  background: #1a100a; border: 1px solid var(--wood-hi); color: var(--parch);
}
.chips .live { border-color: var(--goblin-lo); color: #d9f5a6; display: flex; align-items: center; gap: 6px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--goblin); box-shadow: 0 0 0 0 rgba(159, 210, 63, .7); animation: pulse 2s infinite; }
@keyframes pulse { 70% { box-shadow: 0 0 0 8px rgba(159, 210, 63, 0); } 100% { box-shadow: 0 0 0 0 rgba(159, 210, 63, 0); } }

/* ─── notice ─── */
.notice {
  margin-top: 20px; display: grid; grid-template-columns: 220px 1fr; gap: 20px; align-items: center;
  padding: 16px; border-radius: var(--radius); background: var(--panel); border: 1px solid var(--wood);
}
.notice img { border-radius: 10px; aspect-ratio: 16/9; object-fit: cover; }
.notice h2 { margin: 0 0 4px; color: var(--gold); }
.notice.error { border-color: #8a3a1e; }
.notice.error h2 { color: #ff9f6b; }

/* ─── progress bars ─── */
.bar { height: 8px; border-radius: 99px; background: #0d0805; border: 1px solid #3a2616; overflow: hidden; }
.bar.big { height: 12px; margin-top: 10px; }
.bar span {
  display: block; height: 100%; width: 0;
  background: linear-gradient(90deg, var(--goblin-lo), var(--goblin));
  border-radius: inherit;
  transition: width .6s ease;
}
.bar.full span, .bar span.full { background: linear-gradient(90deg, var(--gold-lo), var(--gold), var(--gold-hi)); }

/* ─── stats ─── */
.stats {
  margin: 22px 0; display: grid; gap: 14px;
  grid-template-columns: repeat(6, 1fr);
}
.stat {
  position: relative; text-align: center; padding: 18px 10px 14px;
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--wood); border-radius: var(--radius);
  box-shadow: inset 0 1px 0 rgba(255, 220, 107, .08);
}
.hex {
  width: 52px; height: 58px; margin: 0 auto 8px;
  display: grid; place-items: center; font-size: 1.4rem;
  clip-path: polygon(50% 0, 100% 25%, 100% 75%, 50% 100%, 0 75%, 0 25%);
  background: linear-gradient(160deg, var(--gold-hi), var(--gold-lo));
  position: relative; isolation: isolate;
}
.hex::before {
  content: ""; position: absolute; inset: 3px; z-index: -1;
  clip-path: polygon(50% 0, 100% 25%, 100% 75%, 50% 100%, 0 75%, 0 25%);
  background: radial-gradient(circle at 50% 35%, #3a2a1a, #120b07);
}
.stat b { display: block; font-size: 1.85rem; color: var(--gold-hi); line-height: 1.1; text-shadow: 0 2px 0 #4a2a04; }
.stat span { font-size: .8rem; font-weight: 800; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); }

/* ─── panels ─── */
.panel {
  margin-top: 22px; padding: 18px 18px 20px;
  background: linear-gradient(180deg, rgba(43, 29, 18, .85), rgba(30, 20, 12, .85));
  border: 1px solid var(--wood); border-radius: calc(var(--radius) + 2px);
  box-shadow: var(--shadow);
}
.panel-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.panel-head h2 { margin: 0; font-size: 1.6rem; color: var(--gold); text-shadow: 0 2px 0 #4a2a04; display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.panel-head small { font-family: "Nunito", sans-serif; font-size: .85rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .8px; }
.ico { font-size: 1.2rem; }
.link-btn { background: none; border: 0; color: var(--gold-hi); font-weight: 800; cursor: pointer; text-decoration: none; font-size: .9rem; }
.link-btn:hover { text-decoration: underline; }

/* ─── recent ─── */
.recent {
  display: grid; grid-auto-flow: column; grid-auto-columns: minmax(260px, 300px);
  gap: 12px; overflow-x: auto; padding-bottom: 8px; scroll-snap-type: x mandatory;
  scrollbar-color: var(--wood-hi) transparent;
}
.loot {
  scroll-snap-align: start;
  display: grid; grid-template-columns: 64px 1fr; gap: 12px; align-items: center;
  padding: 12px; border-radius: 12px; cursor: pointer;
  background: #1a110a; border: 1px solid #3a2616;
  transition: transform .15s, border-color .15s;
  text-align: left;
}
.loot:hover { transform: translateY(-2px); border-color: var(--gold-lo); }
.frame {
  width: 64px; height: 64px; padding: 3px; border-radius: 12px;
  background: linear-gradient(150deg, var(--gold-hi), var(--gold-lo));
  box-shadow: 0 0 14px rgba(246, 185, 47, .25);
}
.frame img { width: 100%; height: 100%; border-radius: 9px; object-fit: cover; background: #0d0805; }
.loot h4 { margin: 0; font-size: .98rem; line-height: 1.2; color: var(--text); }
.loot .game { font-size: .8rem; color: var(--gold); font-weight: 700; margin: 2px 0 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.loot .meta { display: flex; gap: 6px; align-items: center; font-size: .75rem; color: var(--muted); flex-wrap: wrap; }

.rar { font-size: .7rem; font-weight: 800; padding: 2px 7px; border-radius: 99px; border: 1px solid currentColor; text-transform: uppercase; letter-spacing: .4px; }
.rar.legend { color: var(--r-legend); background: rgba(255, 155, 61, .1); }
.rar.epic { color: var(--r-epic); background: rgba(197, 140, 255, .1); }
.rar.rare { color: var(--r-rare); background: rgba(111, 182, 255, .1); }
.rar.common { color: var(--r-common); }

/* ─── hoard ─── */
.hoard { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.trophy {
  position: relative; border-radius: 10px; overflow: hidden; cursor: pointer;
  border: 2px solid var(--gold); background: #0d0805; padding: 0;
  box-shadow: 0 0 16px rgba(246, 185, 47, .22);
  aspect-ratio: 460 / 215;
}
.trophy img { position: relative; z-index: 1; width: 100%; height: 100%; object-fit: cover; }
.trophy .t-name { position: absolute; inset: 0; display: grid; place-items: center; padding: 6px; font-family: "Lilita One", sans-serif; font-size: .85rem; color: var(--gold); text-align: center; line-height: 1.15; }
.trophy::after { z-index: 2; }
.trophy::after { content: "👑"; position: absolute; top: 4px; right: 6px; font-size: 1.1rem; filter: drop-shadow(0 2px 2px #000); }
.trophy:hover { transform: translateY(-2px); }

/* ─── toolbar ─── */
.toolbar { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: center; margin-bottom: 16px; }
.search {
  flex: 1 1 240px; display: flex; align-items: center; gap: 8px;
  background: #140d08; border: 1px solid var(--wood-hi); border-radius: 10px; padding: 0 12px;
}
.search input { flex: 1; background: none; border: 0; outline: 0; padding: 10px 0; min-width: 0; }
.search:focus-within { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(246, 185, 47, .15); }
.seg { display: inline-flex; background: #140d08; border: 1px solid var(--wood-hi); border-radius: 10px; padding: 3px; flex-wrap: wrap; }
.seg button { border: 0; background: none; padding: 7px 12px; border-radius: 7px; font-weight: 800; font-size: .85rem; color: var(--muted); cursor: pointer; }
.seg button.on { background: linear-gradient(180deg, var(--gold), var(--gold-lo)); color: #2a1803; }
.sel { display: inline-flex; align-items: center; gap: 8px; font-size: .85rem; font-weight: 800; color: var(--muted); }
.sel select {
  background: #140d08; border: 1px solid var(--wood-hi); border-radius: 10px; padding: 8px 10px; color: var(--text); font-weight: 700;
}
.check { display: inline-flex; align-items: center; gap: 6px; font-size: .85rem; color: var(--muted); font-weight: 700; cursor: pointer; }
.check input { accent-color: var(--gold); }

/* ─── game grid ─── */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 14px; }
.card {
  display: flex; flex-direction: column; text-align: left; padding: 0; cursor: pointer;
  background: #1a110a; border: 1px solid #3a2616; border-radius: 12px; overflow: hidden;
  transition: transform .15s, border-color .15s, box-shadow .15s;
}
.card:hover, .card:focus-visible { transform: translateY(-3px); border-color: var(--gold-lo); box-shadow: 0 10px 24px rgba(0, 0, 0, .5); outline: none; }
.card.perfect { border-color: var(--gold); box-shadow: 0 0 18px rgba(246, 185, 47, .2); }
.cover { position: relative; aspect-ratio: 460 / 215; background: linear-gradient(135deg, #2b1d12, #120b07); }
.cover img { position: relative; z-index: 1; width: 100%; height: 100%; object-fit: cover; }
.cover .fallback { position: absolute; inset: 0; display: grid; place-items: center; padding: 12px; text-align: center; font-family: "Lilita One"; color: var(--gold); font-size: 1.1rem; }
.cover .pct {
  position: absolute; right: 8px; bottom: 8px;
  font-family: "Lilita One"; font-size: 1.05rem; padding: 2px 10px; border-radius: 8px;
  background: rgba(13, 8, 5, .85); color: var(--goblin); border: 1px solid #3a2616; z-index: 2;
}
.card.perfect .pct { color: #2a1803; background: linear-gradient(180deg, var(--gold-hi), var(--gold)); border-color: var(--gold-hi); }
.card.perfect .pct::before { content: "👑 "; }
.card .body { padding: 12px 12px 14px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.card h3 { margin: 0; font-size: 1.08rem; line-height: 1.2; color: var(--text); overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.card .row { display: flex; justify-content: space-between; font-size: .8rem; color: var(--muted); font-weight: 700; gap: 8px; }
.card .row b { color: var(--parch); }
.card.noach .pct { color: var(--muted); }
.more { text-align: center; margin-top: 18px; }
.btn {
  border: 0; border-radius: 10px; padding: 10px 22px; font-weight: 800; cursor: pointer;
  background: linear-gradient(180deg, var(--gold), var(--gold-lo)); color: #2a1803;
  box-shadow: 0 3px 0 #5a3405;
}
.btn:active { transform: translateY(2px); box-shadow: 0 1px 0 #5a3405; }
.empty { grid-column: 1 / -1; text-align: center; padding: 40px 10px; color: var(--muted); }

.skeleton-row { height: 88px; border-radius: 12px; background: linear-gradient(90deg, #1a110a, #2b1d12, #1a110a); background-size: 200% 100%; animation: shimmer 1.4s infinite; min-width: 280px; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ─── modal ─── */
dialog {
  width: min(860px, calc(100% - 24px)); max-height: calc(100dvh - 40px);
  padding: 0; border: 2px solid var(--gold-lo); border-radius: 16px;
  background: var(--bg-2); color: var(--text); box-shadow: 0 30px 80px rgba(0, 0, 0, .7);
  overflow: hidden; display: none; flex-direction: column;
}
dialog[open] { display: flex; }
dialog::backdrop { background: rgba(8, 5, 3, .75); backdrop-filter: blur(3px); }
.m-head { position: relative; display: grid; grid-template-columns: 230px 1fr; gap: 16px; padding: 16px; background: linear-gradient(180deg, #2b1d12, #1a110b); border-bottom: 1px solid var(--wood); }
.m-head img { border-radius: 10px; aspect-ratio: 460/215; object-fit: cover; width: 100%; height: auto; background: #0d0805; }
.m-info h3 { margin: 0 34px 4px 0; font-size: 1.5rem; color: var(--gold-hi); }
.m-info p { margin: 0 0 10px; font-size: .9rem; }
.close { position: absolute; top: 10px; right: 10px; width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--wood-hi); background: #140d08; cursor: pointer; }
.close:hover { border-color: var(--gold); }
.m-tools { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; padding: 12px 16px; border-bottom: 1px solid #2e1f13; }
.m-tools .link-btn { margin-left: auto; }
.ach-list { list-style: none; margin: 0; padding: 8px 16px 16px; overflow-y: auto; }
.ach {
  display: grid; grid-template-columns: 56px 1fr auto; gap: 12px; align-items: center;
  padding: 10px; border-radius: 10px; border: 1px solid transparent;
}
.ach + .ach { margin-top: 4px; }
.ach:nth-child(odd) { background: rgba(43, 29, 18, .45); }
.ach img { width: 56px; height: 56px; border-radius: 8px; border: 2px solid #3a2616; background: #0d0805; }
.ach.got img { border-color: var(--gold); box-shadow: 0 0 10px rgba(246, 185, 47, .3); }
.ach.locked img { filter: saturate(.2) brightness(.7); }
.ach h5 { margin: 0; font-size: 1rem; }
.ach.locked h5 { color: var(--muted); }
.ach p { margin: 2px 0 0; font-size: .85rem; color: var(--muted); }
.ach .side { text-align: right; font-size: .78rem; color: var(--muted); display: flex; flex-direction: column; gap: 4px; align-items: flex-end; white-space: nowrap; }
.ach .when { color: var(--goblin); font-weight: 800; }

/* ─── footer ─── */
.foot { text-align: center; padding: 24px 16px 40px; border-top: 1px solid var(--wood); color: var(--parch); font-size: .9rem; }
.foot p { margin: 4px 0; }

/* ─── responsive ─── */
@media (max-width: 1000px) { .stats { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 700px) {
  .topbar .links { display: none; }
  .stats { grid-template-columns: repeat(3, 1fr); gap: 8px; }
  .stat { padding: 12px 4px 10px; }
  .hex { width: 38px; height: 42px; font-size: 1rem; margin-bottom: 6px; }
  .stat b { font-size: 1.25rem; }
  .stat span { font-size: .64rem; letter-spacing: .3px; }
  .hoard { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); }
  .panel { padding: 14px 12px 16px; }
  .hero-bar { padding: 12px 14px; }
  .chips li { font-size: .74rem; padding: 4px 9px; }
  .notice { grid-template-columns: 1fr; }
  .grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .card h3 { font-size: .95rem; }
  .card .row { flex-direction: column; gap: 2px; }
  .m-head { grid-template-columns: 1fr; }
  .m-head img { max-height: 140px; }
  .ach { grid-template-columns: 44px 1fr; }
  .ach img { width: 44px; height: 44px; }
  .ach .side { grid-column: 2; flex-direction: row; align-items: center; }
  .m-tools .link-btn { margin-left: 0; }
}
@media (max-width: 420px) { .grid { grid-template-columns: 1fr; } }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
