/* OSRS Gemstone Crab — jewel-toned dark UI, difficulty-ringed tiles */
:root {
  --bg: #0b1020;
  --bg-2: #0e1428;
  --panel: #1b2338;
  --panel-2: #232d48;
  --border: #060912;
  --border-hi: #3a4568;
  --gold: #ffcf5c;
  --gold-dim: #cfa94e;
  --text: #e9edf7;
  --muted: #8f9bb6;
  --done: #2ea043;
  --done-glow: #57d568;
  --done-bg: #12361c;

  /* difficulty ramp: cool -> hot, easy ... grandmaster */
  --easy: #46c6d6;
  --medium: #4f7fe8;
  --hard: #9b5de5;
  --elite: #e24aa0;
  --master: #f5a623;
  --grandmaster: #ff4d5e;

  --tile-w: 156px;
  --gap: 14px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Trebuchet MS", "Segoe UI", system-ui, sans-serif;
  color: var(--text);
  background:
    /* gem glints — one per tier colour, scattered like facets on the shell */
    radial-gradient(3px 3px at 12% 24%, rgba(70, 198, 214, 0.5), transparent 60%),
    radial-gradient(3px 3px at 82% 18%, rgba(226, 74, 160, 0.5), transparent 60%),
    radial-gradient(2px 2px at 68% 42%, rgba(245, 166, 35, 0.5), transparent 60%),
    radial-gradient(2px 2px at 30% 60%, rgba(155, 93, 229, 0.5), transparent 60%),
    radial-gradient(2px 2px at 92% 66%, rgba(79, 127, 232, 0.5), transparent 60%),
    radial-gradient(1100px 520px at 50% -8%, #1a2440 0%, transparent 60%),
    radial-gradient(900px 560px at 88% 8%, rgba(226, 74, 160, 0.10), transparent 55%),
    radial-gradient(900px 560px at 10% 18%, rgba(79, 127, 232, 0.10), transparent 55%),
    radial-gradient(1200px 700px at 50% 120%, rgba(46, 160, 67, 0.08), transparent 60%),
    var(--bg);
  background-attachment: fixed;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* faceted gem band under the header — ties the difficulty gems to the crab's shell */
.gem-band {
  height: 6px;
  background: linear-gradient(90deg,
    var(--easy) 0%, var(--easy) 16.6%,
    var(--medium) 16.6%, var(--medium) 33.3%,
    var(--hard) 33.3%, var(--hard) 50%,
    var(--elite) 50%, var(--elite) 66.6%,
    var(--master) 66.6%, var(--master) 83.3%,
    var(--grandmaster) 83.3%, var(--grandmaster) 100%);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.25);
  opacity: 0.9;
}

.panel {
  background: linear-gradient(var(--panel), var(--panel-2));
  border: 2px solid var(--border);
  box-shadow: inset 0 0 0 2px var(--border-hi), 0 6px 20px rgba(0, 0, 0, 0.55);
  border-radius: 7px;
}
.muted { color: var(--muted); }

/* ---------- top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  flex-wrap: wrap;
  padding: 14px 22px;
  background: linear-gradient(#141b30, #0d1324);
  border-bottom: 3px solid var(--border);
  box-shadow: inset 0 -2px 0 var(--border-hi), 0 4px 16px rgba(0, 0, 0, 0.5);
}
.brand { display: flex; align-items: center; gap: 16px; }
.sigil {
  font-size: 40px;
  display: flex; align-items: center; justify-content: center;
  width: 72px; height: 72px;
}
.sigil .crab {
  width: 72px; height: 72px; object-fit: contain;
  image-rendering: -webkit-optimize-contrast;
  filter: drop-shadow(0 0 10px rgba(70, 198, 214, 0.45)) drop-shadow(0 2px 3px #000);
}
h1 {
  margin: 0;
  font-size: 25px;
  letter-spacing: 0.5px;
  color: var(--gold);
  text-shadow: 2px 2px 0 #000;
}
#subtitle { margin: 2px 0 0; font-size: 13px; }

.stats { display: flex; align-items: stretch; gap: 12px; flex-wrap: wrap; }
.stat {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 96px;
  padding: 8px 14px;
  background: linear-gradient(var(--panel), var(--panel-2));
  border: 2px solid var(--border);
  box-shadow: inset 0 0 0 1px var(--border-hi);
  border-radius: 6px;
  text-align: center;
}
.stat-label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; }
.stat-value { font-size: 20px; font-weight: 700; color: var(--gold); text-shadow: 1px 1px 0 #000; font-variant-numeric: tabular-nums; }
.stat-sub { font-size: 11px; color: var(--muted); }
.stat.points .stat-value { color: var(--done-glow); }

/* ---------- rail / board ---------- */
main { padding: 16px clamp(8px, 3vw, 40px) 40px; }
.rail-hint {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-bottom: 10px;
  font-size: 12px;
}
.nav-btn {
  cursor: pointer;
  width: 40px; height: 40px;
  font-size: 18px;
  color: var(--gold);
  background: linear-gradient(var(--panel), var(--panel-2));
  border: 2px solid var(--border);
  box-shadow: inset 0 0 0 1px var(--border-hi);
  border-radius: 6px;
}
.nav-btn:hover { filter: brightness(1.2); }
.nav-btn:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

.board {
  overflow-x: auto;
  overflow-y: hidden;
  padding: 24px 0;
  cursor: grab;
  -webkit-overflow-scrolling: touch;
  scrollbar-color: var(--border-hi) transparent;
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 5%, #000 95%, transparent);
          mask-image: linear-gradient(90deg, transparent, #000 5%, #000 95%, transparent);
}
.board.dragging { cursor: grabbing; }
.board:focus-visible { outline: 2px solid var(--gold); outline-offset: -2px; }
.board::-webkit-scrollbar { height: 12px; }
.board::-webkit-scrollbar-thumb { background: var(--border-hi); border-radius: 6px; }

.track {
  position: relative;
  display: inline-flex;
  gap: var(--gap);
  padding: 0 50vw;
  align-items: flex-start; /* stages vary in height; align to top */
}

/* ---------- a stage (column) ---------- */
.stage {
  flex: 0 0 var(--tile-w);
  display: flex;
  flex-direction: column;
  gap: var(--gap);
  transform-origin: center center;
  will-change: transform, opacity;
}
.stage.is-active .stage-head { color: var(--done-glow); }

.stage-head {
  text-align: center;
  font-weight: 700;
  font-size: 13px;
  color: var(--gold-dim);
  text-shadow: 1px 1px 0 #000;
  min-height: 34px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding-bottom: 2px;
}
.stage-head .idx { font-size: 11px; color: var(--muted); letter-spacing: 1px; }
.stage.is-active .stage-head .idx::after { content: " · LIVE"; color: var(--done-glow); }

/* ---------- a tile ---------- */
.tile {
  --ring: var(--border-hi);
  position: relative;
  height: 128px;
  padding: 8px 8px 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 3px;
  background: linear-gradient(var(--panel), var(--panel-2));
  border: 2px solid var(--border);
  box-shadow: inset 0 0 0 2px var(--ring);
  border-radius: 6px;
  user-select: none;
  cursor: pointer;
  overflow: hidden;
}
.tile[data-tier="easy"]        { --ring: var(--easy); }
.tile[data-tier="medium"]      { --ring: var(--medium); }
.tile[data-tier="hard"]        { --ring: var(--hard); }
.tile[data-tier="elite"]       { --ring: var(--elite); }
.tile[data-tier="master"]      { --ring: var(--master); }
.tile[data-tier="grandmaster"] { --ring: var(--grandmaster); }

.tile .cat {
  position: absolute; top: 5px; left: 0; right: 0;
  font-size: 9px; letter-spacing: 1.5px; text-transform: uppercase; font-weight: 700;
  color: var(--ring);
  text-shadow: 1px 1px 0 #000;
}
.tile .art {
  width: 46px; height: 46px; margin-top: 12px;
  display: flex; align-items: center; justify-content: center;
  object-fit: contain;
  image-rendering: -webkit-optimize-contrast;
  filter: drop-shadow(0 2px 2px rgba(0,0,0,0.6));
}
.tile .art-fallback {
  width: 42px; height: 42px; margin-top: 12px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
  background: radial-gradient(circle at 35% 30%, #ffffff33, transparent 60%), var(--ring);
  box-shadow: inset 0 0 0 2px #00000055;
}
.tile .name { font-size: 12px; font-weight: 700; line-height: 1.15; }
.tile .src { font-size: 10px; color: var(--muted); line-height: 1.1; }

/* done = green background wash + check, ring stays the difficulty colour */
.tile.done {
  background:
    linear-gradient(var(--done-bg), #0e2a15);
  box-shadow: inset 0 0 0 2px var(--ring), 0 0 10px rgba(46, 160, 67, 0.3);
}
.tile.done::after {
  content: "✓";
  position: absolute; bottom: 3px; right: 7px;
  color: var(--done-glow); font-weight: 900; font-size: 15px;
  text-shadow: 1px 1px 0 #000;
}
.tile.active-tile:not(.done) { animation: pulse 1.8s ease-in-out infinite; }
@keyframes pulse { 50% { box-shadow: inset 0 0 0 2px var(--ring), 0 0 14px color-mix(in srgb, var(--ring) 50%, transparent); } }

/* specific-item tile (annoying + more points) */
.tile.item { border-style: dashed; }
.tile.item .pin { position: absolute; bottom: 3px; left: 5px; font-size: 11px; }
.tile .badge {
  position: absolute; top: 3px; right: 5px;
  font-size: 10px; font-weight: 800; padding: 1px 5px; border-radius: 10px;
  background: #142e12; color: var(--done-glow); border: 1px solid #295f22;
  z-index: 1;
}

/* locked tile — carries NO data */
.tile.locked {
  cursor: default;
  --ring: #2b344f;
  color: var(--muted);
  background: repeating-linear-gradient(135deg, #10152a 0 8px, #0c1022 8px 16px);
}
.tile.locked .art-fallback { background: #1a2238; box-shadow: inset 0 0 0 2px #00000055; opacity: 0.6; }
.tile.locked .name { color: var(--muted); font-style: italic; font-size: 11px; }

/* ---------- legend ---------- */
.legend {
  display: flex; flex-wrap: wrap; gap: 16px; justify-content: center;
  margin-top: 20px; font-size: 12px; color: var(--muted);
}
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.chip { width: 14px; height: 14px; border-radius: 3px; border: 1px solid var(--border); display: inline-block; box-shadow: inset 0 0 0 2px currentColor; }
.chip.c-easy { color: var(--easy); } .chip.c-medium { color: var(--medium); }
.chip.c-hard { color: var(--hard); } .chip.c-elite { color: var(--elite); }
.chip.c-master { color: var(--master); } .chip.c-grandmaster { color: var(--grandmaster); }
.chip.c-done { background: var(--done); border-color: var(--done); box-shadow: none; }
.chip.c-item { background: transparent; border-style: dashed; color: var(--muted); box-shadow: none; }
.chip.c-locked { background: repeating-linear-gradient(135deg, #10152a 0 4px, #0c1022 4px 8px); box-shadow: none; }

/* ---------- sections (challenges + bucket list) ---------- */
.section-title {
  margin: 0 0 2px; font-size: 19px; color: var(--gold); text-shadow: 1px 1px 0 #000;
}
.section-sub { margin: 0 0 12px; font-size: 12.5px; color: var(--muted); }
.challenges, .funtasks { margin-top: 34px; }
.challenges[hidden], .funtasks[hidden] { display: none; }

.chal-group { margin-bottom: 14px; }
.chal-group-label {
  font-size: 11px; text-transform: uppercase; letter-spacing: 1.5px; font-weight: 700;
  color: var(--gold-dim); margin-bottom: 6px;
}
.chal-row {
  display: flex; gap: 12px; overflow-x: auto; padding: 4px 2px 10px;
  scrollbar-color: var(--border-hi) transparent;
}
.chal-row::-webkit-scrollbar { height: 8px; }
.chal-row::-webkit-scrollbar-thumb { background: var(--border-hi); border-radius: 6px; }

.chal-card {
  flex: 0 0 230px;
  padding: 11px 13px;
  background: linear-gradient(var(--panel), var(--panel-2));
  border: 2px solid var(--border);
  box-shadow: inset 0 0 0 2px var(--border-hi);
  border-radius: 7px;
}
.chal-card.past { opacity: 0.72; }
.chal-card.active { box-shadow: inset 0 0 0 2px var(--done), 0 0 12px rgba(46, 160, 67, 0.3); }
.chal-card.next { box-shadow: inset 0 0 0 2px var(--master); opacity: 0.9; }
.chal-period { font-size: 11px; color: var(--muted); letter-spacing: 0.5px; }
.chal-title { font-size: 14.5px; font-weight: 700; margin: 3px 0 9px; line-height: 1.2; }
.chal-foot { font-size: 12.5px; color: var(--text); display: flex; align-items: center; gap: 6px; }
.chal-card.active .chal-foot { color: var(--done-glow); }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--done-glow); box-shadow: 0 0 6px var(--done-glow); display: inline-block; }
.next-badge { font-size: 10px; font-weight: 800; padding: 1px 6px; border-radius: 10px; background: #3a2c10; color: var(--master); border: 1px solid var(--master); }

.fun-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 10px;
  max-height: 340px;
  overflow-y: auto;
  padding: 4px 6px 4px 2px;
  scrollbar-color: var(--border-hi) transparent;
}
.fun-grid::-webkit-scrollbar { width: 10px; }
.fun-grid::-webkit-scrollbar-thumb { background: var(--border-hi); border-radius: 6px; }
.fun-card {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 10px 12px;
  background: linear-gradient(var(--panel), var(--panel-2));
  border: 2px solid var(--border);
  box-shadow: inset 0 0 0 1px var(--border-hi);
  border-radius: 7px;
}
.fun-num {
  flex: 0 0 24px; height: 24px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 800; color: var(--bg);
  background: radial-gradient(circle at 35% 30%, #ffffff55, transparent 60%), var(--master);
  font-variant-numeric: tabular-nums;
}
.fun-text { font-size: 13px; line-height: 1.3; }

/* ---------- modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(0, 0, 0, 0.74);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.modal-backdrop[hidden] { display: none; }
.modal { position: relative; max-width: 420px; width: 100%; padding: 22px; }
.modal h2 { margin: 0 0 6px; color: var(--gold); text-shadow: 1px 1px 0 #000; }
.modal-close {
  position: absolute; top: 10px; right: 12px;
  cursor: pointer; background: none; border: none; color: var(--muted); font-size: 18px;
}
.modal-close:hover { color: var(--gold); }

.detail-art { width: 56px; height: 56px; margin: 0 auto; display: block; object-fit: contain; filter: drop-shadow(0 2px 3px #000); }
.detail-name { text-align: center; font-size: 20px; font-weight: 800; color: var(--gold); margin-top: 8px; }
.detail-tier { text-align: center; font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: 1.5px; margin-top: 2px; }
.detail-grid { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin-top: 16px; font-size: 14px; }
.detail-grid dt { color: var(--muted); }
.detail-grid dd { margin: 0; font-weight: 600; }
.accepts { margin-top: 16px; }
.accepts-head { font-size: 12px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); margin-bottom: 6px; }
.accepts-list { margin: 0; padding-left: 18px; display: grid; gap: 3px; font-size: 13.5px; }
.accepts-list li { line-height: 1.3; }
.accept-note { margin-top: 6px; font-size: 13px; color: var(--text); }
.gated {
  margin-top: 14px; padding: 10px 12px; border-radius: 6px;
  background: rgba(255, 77, 94, 0.1); border: 1px solid rgba(255, 77, 94, 0.35);
}
.gated-head { font-size: 12px; text-transform: uppercase; letter-spacing: 1px; font-weight: 700; color: #ff8d98; margin-bottom: 6px; }
.gated-list { margin: 0; padding-left: 18px; display: grid; gap: 3px; font-size: 13.5px; color: #ffb3ba; }
.gated-list li { line-height: 1.3; }
.detail-status { margin-top: 16px; padding: 10px 12px; border-radius: 6px; text-align: center; font-weight: 700; }
.detail-status.done { background: var(--done-bg); color: var(--done-glow); border: 1px solid #295f22; }
.detail-status.open { background: #1b2238; color: var(--gold); border: 1px solid var(--border-hi); }

/* iPad / tablet */
@media (max-width: 1024px) {
  :root { --tile-w: 150px; }
  main { padding: 14px clamp(6px, 2vw, 24px) 32px; }
}

/* phones */
@media (max-width: 640px) {
  :root { --tile-w: 132px; --gap: 10px; }
  .topbar { padding: 10px 12px; gap: 10px; }
  .sigil, .sigil .crab { width: 48px; height: 48px; }
  h1 { font-size: 18px; }
  #subtitle { font-size: 11px; }
  .stats { gap: 8px; }
  .stat { min-width: 0; padding: 6px 9px; }
  .stat-value { font-size: 17px; }
  .stat-label { font-size: 10px; }
  .tile { height: 116px; }
  .tile .name { font-size: 11px; }
  .tile .art, .tile .art-fallback { width: 40px; height: 40px; margin-top: 10px; }
  .rail-hint span { display: none; } /* keep just the arrows on narrow screens */
  .legend { gap: 10px 14px; font-size: 11px; }
  .modal { padding: 18px; }
  .section-title { font-size: 16px; }
  .chal-card { flex-basis: 200px; }
  .fun-grid { grid-template-columns: 1fr; max-height: 300px; }
}

/* small phones */
@media (max-width: 380px) {
  :root { --tile-w: 118px; }
  h1 { font-size: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  .tile.active-tile:not(.done) { animation: none; }
}
