/* ---- tokens ---- */
:root{
  --bg: #14161a;
  --bg-raised: #1b1e24;
  --bg-inset: #0f1114;
  --line: #2a2e36;
  --text: #eae6df;
  --text-dim: #93969f;
  --amber: #ffb454;
  --amber-dim: #7a5b2c;
  --cyan: #5eead4;
  --magenta: #ec8fd0;

  --tier-trash: #8a8f99;
  --tier-common: #b7bac1;
  --tier-uncommon: #6ee7b7;
  --tier-rare: #7dd3fc;
  --tier-epic: #c4b5fd;
  --tier-anomaly: #fdba74;
  --tier-mythic: #f472b6;

  --font-display: "Space Mono", monospace;
  --font-body: "Inter", system-ui, sans-serif;

  --radius: 14px;
}

*{ box-sizing: border-box; }
html,body{ margin:0; padding:0; }

body{
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  line-height: 1.5;
  min-height: 100vh;
  position: relative;
}

/* faint grain / vignette so the flat dark bg doesn't feel like a template */
.grain{
  position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background:
    radial-gradient(ellipse at 50% -10%, rgba(255,180,84,0.08), transparent 55%),
    radial-gradient(ellipse at 100% 110%, rgba(94,234,212,0.06), transparent 50%);
}

a{ color: var(--amber); }

/* ---- topbar ---- */
.topbar{
  position: relative; z-index: 1;
  border-bottom: 1px solid var(--line);
  background: rgba(15,17,20,0.6);
  backdrop-filter: blur(6px);
}
.topbar-inner{
  max-width: 1040px; margin: 0 auto;
  padding: 18px 24px;
  display: flex; align-items: baseline; gap: 14px;
  flex-wrap: wrap;
}
.brand{
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: 0.04em;
  font-size: 15px;
}
.brand-mark{ color: var(--amber); }
.topbar-sub{
  color: var(--text-dim);
  font-size: 13px;
  font-style: italic;
}

main{ position: relative; z-index: 1; }

/* ---- hero / reel ---- */
.hero{
  max-width: 1040px; margin: 0 auto;
  padding: 64px 24px 32px;
  display: flex; flex-direction: column; align-items: center;
  text-align: center;
}

.reel-wrap{ position: relative; margin-bottom: 36px; }

.reel{
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(48px, 11vw, 96px);
  letter-spacing: 0.05em;
  background: var(--bg-inset);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 36px;
  box-shadow:
    inset 0 2px 12px rgba(0,0,0,0.55),
    0 1px 0 rgba(255,255,255,0.03);
  position: relative;
  overflow: hidden;
}
.reel::before{
  /* scanline sheen */
  content: "";
  position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(255,255,255,0.05), transparent 30%, transparent 70%, rgba(0,0,0,0.15));
  pointer-events: none;
}
#reelDigits{ position: relative; z-index: 1; }
.reel.is-rolling #reelDigits{ animation: flicker 0.06s steps(2) infinite; color: var(--amber); }
@keyframes flicker{ from{ opacity:1;} to{ opacity:0.55; } }

.reel-glow{
  position: absolute; inset: -20px;
  border-radius: 28px;
  z-index: -1;
  opacity: 0;
  transition: opacity 0.4s ease;
  filter: blur(20px);
}
.reel-glow.show{ opacity: 0.55; }

.scan-form{
  display: flex; gap: 10px; flex-wrap: wrap; justify-content: center;
  width: 100%; max-width: 560px;
}
#numberInput{
  flex: 1 1 240px;
  min-width: 0;
  font-family: var(--font-display);
  font-size: 16px;
  background: var(--bg-raised);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 10px;
  padding: 13px 16px;
}
#numberInput:focus{
  outline: 2px solid var(--amber);
  outline-offset: 1px;
}
#numberInput::placeholder{ color: var(--text-dim); }

.btn{
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 14px;
  border-radius: 10px;
  padding: 13px 20px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform 0.12s ease, filter 0.12s ease, background 0.12s ease;
  white-space: nowrap;
}
.btn:active{ transform: translateY(1px); }
.btn:focus-visible{ outline: 2px solid var(--amber); outline-offset: 2px; }

.btn-primary{ background: var(--amber); color: #241a08; }
.btn-primary:hover{ filter: brightness(1.08); }

.btn-ghost{
  background: transparent; color: var(--text);
  border-color: var(--line);
}
.btn-ghost:hover{ background: var(--bg-raised); }

.btn-secondary{
  background: var(--bg-raised); color: var(--cyan);
  border-color: var(--line);
}
.btn-secondary:hover{ filter: brightness(1.15); }
.btn-secondary:disabled{ opacity: 0.5; cursor: progress; }

.hint{
  margin-top: 16px; color: var(--text-dim); font-size: 13px;
}

/* ---- result ---- */
.result{
  max-width: 1040px; margin: 0 auto;
  padding: 0 24px 56px;
}
.result-top{
  display: flex; align-items: center; gap: 28px; flex-wrap: wrap;
  border: 1px solid var(--line);
  background: var(--bg-raised);
  border-radius: var(--radius);
  padding: 22px 26px;
  margin-bottom: 28px;
}

.rarity-pill{
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.08em;
  padding: 7px 14px;
  border-radius: 999px;
  border: 1px solid currentColor;
}
.rarity-trash{ color: var(--tier-trash); }
.rarity-common{ color: var(--tier-common); }
.rarity-uncommon{ color: var(--tier-uncommon); }
.rarity-rare{ color: var(--tier-rare); }
.rarity-epic{ color: var(--tier-epic); }
.rarity-anomaly{ color: var(--tier-anomaly); }
.rarity-mythic{ color: var(--tier-mythic); }

.ep-block{ display: flex; align-items: baseline; gap: 8px; }
.ep-value{
  font-family: var(--font-display); font-weight: 700;
  font-size: 30px; color: var(--amber);
}
.ep-label{ color: var(--text-dim); font-size: 13px; }

.percentile-block{ display: flex; align-items: baseline; gap: 8px; margin-left: auto; }
.percentile-value{ font-family: var(--font-display); font-weight: 700; font-size: 20px; color: var(--cyan); }
.percentile-label{ color: var(--text-dim); font-size: 13px; }

.badges-header h2{
  font-size: 16px; font-weight: 700;
  margin: 0 0 16px;
  display: flex; align-items: baseline; gap: 8px;
}
.badge-count{ color: var(--text-dim); font-weight: 500; font-size: 14px; }

.badges-grid{
  list-style: none; margin: 0; padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 12px;
}
.badge-card{
  border: 1px solid var(--line);
  background: var(--bg-raised);
  border-radius: 12px;
  padding: 14px 16px;
  display: flex; gap: 12px; align-items: flex-start;
}
.badge-emoji{ font-size: 22px; line-height: 1; }
.badge-body{ min-width: 0; }
.badge-label{ font-weight: 700; font-size: 14px; margin-bottom: 2px; }
.badge-desc{ color: var(--text-dim); font-size: 12.5px; line-height: 1.4; }
.badge-score{ font-family: var(--font-display); font-size: 11px; color: var(--cyan); margin-top: 6px; }

.empty-state{ color: var(--text-dim); font-style: italic; }

/* ---- explore ---- */
.explore{
  max-width: 1040px; margin: 0 auto;
  padding: 8px 24px 80px;
  border-top: 1px solid var(--line);
  padding-top: 48px;
}
.explore-head h2{ font-size: 22px; margin: 0 0 8px; }
.explore-head p{ color: var(--text-dim); font-size: 14px; max-width: 640px; }

.explore-actions{
  display: flex; align-items: center; gap: 14px; margin: 20px 0 28px;
  flex-wrap: wrap;
}
.explore-status{ color: var(--text-dim); font-size: 13px; font-family: var(--font-display); }

.chart-grid{
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  margin-bottom: 18px;
}
@media (max-width: 800px){
  .chart-grid{ grid-template-columns: 1fr; }
}

.leaderboard-wide{
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  column-gap: 24px;
}
@media (max-width: 640px){
  .leaderboard-wide{ grid-template-columns: 1fr; }
}

.panel{
  border: 1px solid var(--line);
  background: var(--bg-raised);
  border-radius: var(--radius);
  padding: 18px 20px;
}
.panel h3{ font-size: 14px; margin: 0 0 12px; color: var(--text-dim); font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }

.leaderboard{ list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.leaderboard li{
  display: flex; justify-content: space-between; gap: 10px;
  font-size: 13.5px;
  border-bottom: 1px dashed var(--line);
  padding-bottom: 8px;
}
.leaderboard li:last-child{ border-bottom: none; padding-bottom: 0; }
.leaderboard .lb-name{ color: var(--text); display: flex; flex-direction: column; gap: 2px; }
.leaderboard .lb-sub{ color: var(--text-dim); font-size: 11.5px; font-style: italic; }
.leaderboard .lb-value{ font-family: var(--font-display); color: var(--cyan); white-space: nowrap; }
.leaderboard .placeholder{ color: var(--text-dim); font-style: italic; justify-content: flex-start; }

/* ---- footer ---- */
.site-footer{
  border-top: 1px solid var(--line);
  padding: 24px;
  text-align: center;
  color: var(--text-dim);
  font-size: 12.5px;
  position: relative; z-index: 1;
}

@media (prefers-reduced-motion: reduce){
  .reel.is-rolling #reelDigits{ animation: none; }
  .btn{ transition: none; }
}
