:root {
  --panel: rgba(10,14,40,.72); --card: rgba(10,14,40,.72); --edge: #27407a; --dark: rgba(4,7,24,.85);
  --ink: #eef2fb; --soft: #bfcae4; --muted: #8d9ac0;
  --up: #4ade80; --down: #f87171; --gold: #f5c542; --cyan: #7dd3fc; --orange: #fb923c;
  --sv: #a855f7; --scrt: #f59e0b; --ltd: #ef4444;
  --g: #22c55e; --y: #eab308; --r: #f87171;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif; color: var(--ink);
  background: #02030a; /* only a fallback: the space canvas covers it */
  min-height: 100vh;
}
a { color: inherit; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

.top { display: flex; align-items: center; justify-content: space-between; padding: 14px 22px;
  border-bottom: 1px solid #3a5aa044; background: rgba(4,7,24,.6); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  position: sticky; top: 0; z-index: 5; }
/* the logo and name, 50% bigger */
.brand { display: flex; align-items: center; gap: 18px; text-decoration: none; }
.logo { width: 66px; height: 66px; border-radius: 50%; }
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-text b { font-size: 33px; letter-spacing: .4px; }
.brand-text small { color: var(--soft); font-size: 18px; }
.updated { color: var(--soft); font-size: 12px; text-shadow: 0 1px 3px #000, 0 0 6px #000; position: relative; }

/* the top bar's pixel cubes and the update banner in its middle (changed with each game update) */
.top { background: linear-gradient(rgba(4,6,22,.15), rgba(4,6,22,.35)), url(/header.png) left center / auto 112px repeat,
  rgba(4,7,24,.6);   /* the cubes keep their size on every screen; the darker part stays behind the logo */
  border-bottom-color: #6a5cff66; }
.brand { position: relative; z-index: 1; }
.banner { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); text-align: center;
  padding: 6px 70px; pointer-events: none; display: flex; flex-direction: column; align-items: center;
  background: radial-gradient(ellipse at center, rgba(4,6,22,.82) 0%, rgba(4,6,22,.55) 45%, rgba(4,6,22,0) 72%); }
.banner b { font-size: 32px; font-weight: 900; letter-spacing: 4px; line-height: 1; color: #fff;
  text-shadow: 0 0 10px #8b5cff, 0 0 22px #3b82f6, 0 2px 0 #000; }
.banner small { margin-top: 5px; font-size: 16px; font-weight: 700; letter-spacing: 1.5px; color: #7dd3fc;
  text-shadow: 0 0 8px #2bc4c9, 0 1px 0 #000; }
/* narrower screens: the banner moves onto its own line under the logo, so it never covers the name */
@media (max-width: 1100px) {
  .top { flex-wrap: wrap; row-gap: 6px; }
  .banner { position: static; transform: none; order: 3; width: 100%; padding: 4px 10px;
    background: radial-gradient(ellipse at center, rgba(4,6,22,.8) 0%, rgba(4,6,22,0) 70%); }
  .banner b { font-size: 24px; letter-spacing: 2px; } .banner small { font-size: 13px; margin-top: 3px; }
}

main { max-width: 1180px; margin: 0 auto; padding: 18px 16px 40px; }
.search { display: flex; justify-content: center; margin: 10px 0 18px; }
.search input { width: min(640px, 100%); font-size: 18px; padding: 12px 16px; color: var(--ink);
  background: rgba(6,10,32,.8); border: 2px solid #1f9d4c; border-radius: 12px; outline: none; }
.search input:focus { border-color: var(--up); }

.tabs { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-bottom: 12px; }
.tabs button, .tabs select { background: var(--card); color: var(--soft); border: 1px solid var(--edge);
  border-radius: 8px; padding: 6px 12px; font-weight: 600; font-size: 14px; cursor: pointer; }
.tabs button.on { background: #1f9d4c; color: #fff; border-color: #1f9d4c; }
.tabs button.gold { color: var(--gold); } .tabs button.cyan { color: var(--cyan); }
.tabs button.gold.on, .tabs button.cyan.on { color: #fff; }
.tabs .spacer { flex: 1; }
.count { color: var(--muted); font-size: 13px; margin-left: 6px; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.card { position: relative; background: var(--card); border: 2px solid #34508f; border-radius: 12px; padding: 8px; backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  text-align: center; cursor: pointer; transition: transform .08s ease, box-shadow .08s ease; }
.card:hover { transform: translateY(-2px); box-shadow: 0 6px 18px #000a, 0 0 0 1px #4a70c055; }
/* rarity edges like in the game: Secret = a flowing rainbow, Souvenir (SV) = flowing yellow / orange / dark orange,
   Limited = plain red (no animation). The moving edge is a thin ring laid over the card's border. */
@property --spin { syntax: "<angle>"; initial-value: 0deg; inherits: false; }
@keyframes bv-spin { to { --spin: 360deg; } }
.card.Limited { border-color: #c00018; }   /* a deeper red: #ef4444 looked orange */
.card.Secret, .card.Souvenir { border-color: transparent; }
.card.Secret::before, .card.Souvenir::before {
  content: ""; position: absolute; inset: -2px; border-radius: 12px; padding: 2px; pointer-events: none;
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor; mask-composite: exclude;
  animation: bv-spin 3s linear infinite;
}
.card.Secret::before {
  background: conic-gradient(from var(--spin), #ff2a2a, #ff9f1a, #ffe81a, #3dff6e, #1ae0ff, #3d6bff, #b23dff, #ff2ad4, #ff2a2a);
}
.card.Souvenir::before {
  background: conic-gradient(from var(--spin), #ffd400, #ff8c00, #c2410c, #ff8c00, #ffd400, #ff8c00, #c2410c, #ff8c00, #ffd400);
}
@media (prefers-reduced-motion: reduce) { .card.Secret::before, .card.Souvenir::before { animation: none; } }
.card .pic { width: 100%; aspect-ratio: 1; border-radius: 8px; background: var(--dark); object-fit: contain; display: block; }
.card .nopic { width: 100%; aspect-ratio: 1; border-radius: 8px; background: var(--dark); display: flex; align-items: center;
  justify-content: center; color: var(--muted); font-size: 12px; }
.card .by { position: absolute; top: 12px; right: 12px; font-size: 12px; font-weight: 700; padding: 0 5px;
  border-radius: 5px; background: var(--dark); border: 1px solid currentColor; }
.by.C { color: var(--cyan); } .by.M { color: var(--gold); }
.card .v { font-weight: 800; margin-top: 6px; font-size: 15px; color: var(--up); }
.card .v.unknown { color: var(--muted); }
.card .bv { font-weight: 700; font-size: 13px; color: var(--soft); }
.card .d { font-weight: 700; font-size: 13px; }
.card .n { font-size: 13px; margin-top: 4px; }
.note { font-size: 12px; margin-top: 2px; }
.note.troll, .bv.troll { color: var(--down); } .note.good, .bv.good { color: var(--g); }
.tier-OC { color: var(--gold) !important; } .tier-ER { color: var(--orange) !important; } .tier-R { color: var(--cyan) !important; }

.list { display: flex; flex-direction: column; gap: 8px; }
.row { display: flex; gap: 14px; align-items: center; background: var(--card); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); border: 1px solid var(--edge);
  border-radius: 12px; padding: 10px 12px; cursor: pointer; }
.row img, .row .nopic { width: 72px; height: 72px; border-radius: 8px; object-fit: contain; background: var(--dark); flex: none; }
.row .t1 { font-weight: 700; font-size: 16px; }
.row .t2 { font-weight: 700; color: var(--up); }
.row .t3 { color: var(--soft); font-size: 13px; }
.row .t4 { color: var(--muted); font-size: 12px; font-style: italic; }
.empty { color: var(--muted); text-align: center; padding: 40px 10px; }

.item { backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); background: var(--panel); border: 1px solid var(--edge); border-radius: 14px; padding: 16px 18px; }
.back { float: right; background: #1c2f66; color: var(--ink); border: 0; border-radius: 8px; padding: 6px 12px; cursor: pointer; }
.item-head { display: flex; gap: 14px; align-items: center; }
.i-pic { width: 84px; height: 84px; border-radius: 10px; background: var(--dark); object-fit: contain; }
.item h1 { margin: 0; font-size: 24px; }
.i-value { margin-top: 10px; font-size: 34px; font-weight: 800; color: var(--up); }
.trend { font-size: 16px; margin-left: 12px; }
.i-bv { font-size: 19px; font-weight: 700; margin-top: 2px; }
.i-bv .muted { font-size: 13px; font-weight: 400; margin-left: 10px; }
.i-demand { margin-top: 8px; display: flex; align-items: center; gap: 10px; font-weight: 700; flex-wrap: wrap; }
.bar { display: inline-flex; gap: 3px; } .bar i { width: 13px; height: 13px; border-radius: 3px; background: #23305c; display: inline-block; }
.i-info { margin-top: 10px; color: var(--soft); line-height: 1.6; }
#chart { width: 100%; margin-top: 10px; display: block; }
/* "This month" / "All time" in the chart's top-right corner */
.chart-box { position: relative; margin-top: 10px; }
.chart-box #chart { margin-top: 30px; }   /* room for the buttons: they never cover a sale */
.ranges { position: absolute; top: 0; right: 0; display: flex; gap: 4px; z-index: 1; }
.ranges button { background: var(--dark); color: var(--soft); border: 1px solid var(--edge); border-radius: 7px;
  padding: 3px 9px; font-size: 12px; font-weight: 600; cursor: pointer; }
.ranges button.on { background: #1f9d4c; color: #fff; border-color: #1f9d4c; }
.legend { text-align: right; }

.foot { max-width: 1180px; margin: 0 auto; padding: 18px 16px 30px; color: var(--muted); font-size: 12px;
  display: flex; flex-direction: column; gap: 4px; }
/* demand colours as classes (the site's safety rules forbid inline styles) */
.dg { color: var(--g); } .dy { color: var(--y); } .dr { color: var(--r); } .dm { color: var(--muted); }
.bar i.g { background: var(--g); } .bar i.y { background: var(--y); } .bar i.r { background: var(--r); }

/* the login page (private mode) */
.login { max-width: 360px; margin: 12vh auto; background: var(--panel); border: 1px solid var(--edge); border-radius: 16px;
  padding: 28px; text-align: center; backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
.login img { width: 72px; height: 72px; border-radius: 50%; }
.login h1 { margin: 10px 0 4px; } .login p { color: var(--soft); margin: 0 0 16px; }
.login input { width: 100%; font-size: 16px; padding: 10px 12px; border-radius: 10px; border: 2px solid #1f9d4c;
  background: rgba(6,10,32,.8); color: var(--ink); }
.login button { margin-top: 12px; width: 100%; padding: 10px; border: 0; border-radius: 10px; background: #1f9d4c;
  color: #fff; font-weight: 700; font-size: 16px; cursor: pointer; }
.bad { color: var(--down) !important; }

@media (max-width: 560px) {
  .grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
  .i-value { font-size: 28px; } .updated { display: none; }
  .logo { width: 50px; height: 50px; } .brand { gap: 12px; }        /* phones: still bigger, but fits */
  .brand-text b { font-size: 26px; } .brand-text small { font-size: 14px; }
}

/* floating items in the space (only when turned on): above the space canvas (z -1), below the page (z 1) */
#floaters { position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; }
.floater { position: absolute; left: 0; top: 0; height: auto; pointer-events: auto; user-select: none; -webkit-user-select: none;
  -webkit-user-drag: none; touch-action: none; cursor: grab; will-change: transform; filter: drop-shadow(0 0 8px rgba(125,211,252,.35)); }
.floater:active { cursor: grabbing; }
/* the page content sits above the items but lets clicks through its empty parts, so the items can be reached there */
body.has-floaters main, body.has-floaters .foot { position: relative; z-index: 1; pointer-events: none; }
body.has-floaters main > *, body.has-floaters .foot > * { pointer-events: auto; }
body.has-floaters .grid, body.has-floaters .list { pointer-events: none; }
body.has-floaters .grid > *, body.has-floaters .list > * { pointer-events: auto; }
.floater-toast { position: fixed; z-index: 20; padding: 6px 12px; border-radius: 8px; font-size: 13px; color: var(--ink);
  background: rgba(4,7,24,.92); border: 1px solid var(--edge); pointer-events: none; animation: floater-toast 2.2s ease forwards; }
@keyframes floater-toast { 0%, 85% { opacity: 1; } 100% { opacity: 0; } }
/* double-click: placeholder animation (floaterSpecial in app.js), a pop and a glow */
.floater-special { animation: floater-special .8s ease-out; }
@keyframes floater-special {
  0% { scale: 1; filter: drop-shadow(0 0 0 rgba(245,197,66,0)); }
  35% { scale: 1.5; filter: drop-shadow(0 0 22px rgba(245,197,66,1)) brightness(1.4); }
  100% { scale: 1; filter: drop-shadow(0 0 8px rgba(125,211,252,.35)); }
}
@media (prefers-reduced-motion: reduce) { .floater-special { animation-duration: .01s; } .floater-toast { animation: none; } }