:root {
  --bg-deep: #050a14;
  --bg-mid: #0d1a31;
  --panel-top: #0f1d36;
  --panel-bottom: #08111f;
  --gold: #c9a45c;
  --gold-dim: #6e5a2f;
  --gold-bright: #f0d48a;
  --text: #e8e4d8;
  --muted: #8e9bb3;
  --empty: #27324a;
  --slot: 112px;
  --gap: 8px;
  --serif: "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { margin: 0; min-height: 100%; }

body {
  font-family: var(--sans);
  color: var(--text);
  background:
    radial-gradient(ellipse at 50% 15%, #15294d 0%, transparent 60%),
    radial-gradient(ellipse at 50% 100%, #0a1428 0%, transparent 70%),
    var(--bg-deep);
  background-attachment: fixed;
  padding: 24px 12px 40px;
}

.msg {
  max-width: 520px;
  margin: 18vh auto 0;
  padding: 22px 26px;
  text-align: center;
  font-family: var(--serif);
  font-size: 18px;
  line-height: 1.5;
  border: 1px solid var(--gold-dim);
  background: linear-gradient(180deg, var(--panel-top), var(--panel-bottom));
}

.profile { max-width: 1040px; margin: 0 auto; }

.bar {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  padding: 0 4px 10px;
  border-bottom: 1px solid var(--gold-dim);
  margin-bottom: 14px;
}
.bar-title {
  font-family: var(--serif);
  font-size: 18px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--gold-bright);
}
.expiry { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }

.grid {
  display: grid;
  grid-template-columns: 230px minmax(0, 1fr) 260px;
  gap: 14px;
  align-items: start;
}

/* ---------- panels ---------- */

.panel {
  position: relative;
  padding: 18px 16px 16px;
  border: 1px solid var(--gold-dim);
  background: linear-gradient(180deg, var(--panel-top), var(--panel-bottom));
  box-shadow: inset 0 0 0 1px #000, inset 0 0 24px #00000080, 0 10px 30px #0009;
}
.panel::before {
  content: "";
  position: absolute;
  left: 12px; right: 12px; top: -1px;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
}

.info { text-align: center; }

.emblem { width: 96px; margin: 0 auto 8px; }
.emblem svg { width: 100%; display: block; }
.ring-outer { fill: none; stroke: var(--gold); stroke-width: 2; }
.ring-inner { fill: #0a1426; stroke: var(--gold-dim); stroke-width: 1.5; }
.star { fill: #c9a45c22; stroke: var(--gold); stroke-width: 1; }
.emblem-letter { fill: var(--gold-bright); font-family: var(--serif); font-size: 28px; font-weight: 700; }

h1 {
  margin: 4px 0 2px;
  font-family: var(--serif);
  font-size: 24px;
  font-weight: 700;
  line-height: 1.15;
  overflow-wrap: anywhere;
}
.title { font-family: var(--serif); font-style: italic; color: var(--gold); font-size: 14px; min-height: 1em; overflow-wrap: anywhere; }
.level { margin-top: 10px; font-size: 20px; font-weight: 600; font-variant-numeric: tabular-nums; }
.level-tag { font-size: 13px; color: var(--muted); letter-spacing: 0.08em; }

.facts {
  margin: 16px 0 0;
  padding-top: 12px;
  border-top: 1px solid #ffffff14;
  text-align: left;
  font-size: 13px;
}
.facts div { display: flex; justify-content: space-between; gap: 10px; padding: 5px 0; border-bottom: 1px solid #ffffff0d; }
.facts dt { color: var(--muted); flex: none; }
.facts dd { margin: 0; text-align: right; overflow-wrap: anywhere; }

/* ---------- stage: gear strips + portrait ---------- */

.stage {
  display: grid;
  grid-template-columns: var(--slot) minmax(0, 1fr) var(--slot);
  gap: 14px;
  align-items: stretch;
  justify-content: center;
}
.strip { display: flex; flex-direction: column; justify-content: center; align-items: center; gap: var(--gap); }

.portrait {
  margin: 0;
  min-height: 400px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  border: 1px solid #ffffff10;
  background:
    radial-gradient(ellipse at 50% 85%, #1d3a6a55, transparent 65%),
    linear-gradient(180deg, #0a1426aa, #060c18aa);
  overflow: hidden;
}
.portrait img { max-width: 100%; max-height: 400px; object-fit: contain; display: block; }
.portrait svg { width: 55%; max-height: 380px; fill: #16233f; stroke: #2a3d66; stroke-width: 2; }

.slot {
  --rc: var(--empty);
  position: relative;
  width: var(--slot);
  height: var(--slot);
  padding: 0;
  display: grid;
  place-items: center;
  border: 2px solid var(--rc);
  border-radius: 6px;
  background: radial-gradient(circle at 50% 30%, color-mix(in srgb, var(--rc) 26%, #0b1424), #050a14);
  box-shadow: 0 0 10px color-mix(in srgb, var(--rc) 45%, transparent), inset 0 0 8px #000;
  color: var(--text);
  cursor: pointer;
  touch-action: manipulation;
}
.slot:focus-visible { outline: 2px solid var(--gold-bright); outline-offset: 2px; }
.slot.empty { border-style: dashed; box-shadow: none; opacity: 0.55; cursor: default; }
.slot img { width: 100%; height: 100%; object-fit: contain; display: block; }
.slot .fb { font-family: var(--serif); font-size: 34px; font-weight: 700; color: var(--rc); }
.slot .up {
  position: absolute;
  right: 1px; bottom: 1px;
  padding: 0 4px;
  font-size: 13px;
  font-weight: 700;
  line-height: 18px;
  color: var(--gold-bright);
  background: #050a14e0;
  border-radius: 3px;
  font-variant-numeric: tabular-nums;
}

/* ---------- stats ---------- */

.power { text-align: center; padding-bottom: 14px; margin-bottom: 12px; border-bottom: 1px solid #ffffff14; }
.power-label { font-size: 11px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--gold); }
.power-value {
  font-family: var(--serif);
  font-size: 38px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  background: linear-gradient(180deg, #fff3cf, #d6a94a);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
h2 {
  margin: 0 0 8px;
  font-family: var(--serif);
  font-size: 13px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--gold);
  text-align: center;
}
.stat-list { list-style: none; margin: 0; padding: 0; font-size: 14px; }
.stat-list li { display: flex; justify-content: space-between; gap: 12px; padding: 6px 2px; border-bottom: 1px solid #ffffff0d; }
.stat-list .k { color: var(--gold-bright); }
.stat-list .v { font-weight: 600; font-variant-numeric: tabular-nums; text-align: right; }

/* ---------- tooltip ---------- */

.tip {
  --rc: var(--empty);
  position: fixed;
  z-index: 50;
  left: 0; top: 0;
  width: max-content;
  max-width: min(300px, calc(100vw - 16px));
  padding: 10px 12px 11px;
  pointer-events: none;
  border: 1px solid var(--rc);
  border-radius: 4px;
  background: #070d1a;
  box-shadow: 0 8px 26px #000c, 0 0 14px color-mix(in srgb, var(--rc) 35%, transparent);
  font-size: 13px;
  line-height: 1.4;
}
.tip-name { font-family: var(--serif); font-size: 16px; font-weight: 700; color: var(--rc); overflow-wrap: anywhere; }
.tip-name.muted { color: var(--muted); }
.tip-sub { margin-top: 1px; color: var(--muted); font-size: 12px; }
.tip-el { margin-top: 6px; color: var(--text); }
.tip-el + .tip-el { margin-top: 1px; }
.tip-stats { list-style: none; margin: 8px 0 0; padding: 8px 0 0; border-top: 1px solid #ffffff1a; }
.tip-stats li { display: flex; justify-content: space-between; gap: 18px; padding: 1px 0; }
.tip-stats .k { color: var(--muted); }
.tip-stats .v { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }
.tip-set { margin-top: 8px; color: var(--gold); font-size: 12px; }
.tip-desc { margin: 8px 0 0; color: #b9c2d3; font-style: italic; font-size: 12px; }

/* ---------- small screens ---------- */

@media (max-width: 860px) {
  .grid { grid-template-columns: 1fr; }
  .stage { order: 2; }
  .stats { order: 3; }
  .info { order: 1; }
  :root { --slot: 96px; }
  .portrait { min-height: 360px; }
  .portrait img { max-height: 360px; }
}
@media (max-width: 480px) {
  :root { --slot: 72px; --gap: 6px; }
  .stage { gap: 6px; }
  .portrait { min-height: 300px; }
  .portrait img { max-height: 300px; }
  .slot .fb { font-size: 26px; }
  .slot .up { font-size: 11px; line-height: 15px; }
}


/* ---------- motion ---------- */

@property --angle { syntax: "<angle>"; initial-value: 0deg; inherits: false; }

/* Gold text with a light ray. The gradient tile repeats, and the ray moves exactly one tile width
   per cycle, so the loop restarts without any visible jump. */
#name, .title, h2 {
  background-image: linear-gradient(100deg, #d4b165 0%, #d4b165 40%, #fff7da 50%, #d4b165 60%, #d4b165 100%);
  background-size: 360px 100%;
  background-repeat: repeat-x;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
  animation: ray 6s linear infinite, halo 4.5s ease-in-out infinite;
}
#name { animation-delay: -1.5s, 0s; }
.title { animation-delay: -3s, -1s; }
h2 { animation-delay: -4.5s, -2s; }
@keyframes ray { from { background-position: 0 0; } to { background-position: 360px 0; } }
@keyframes halo {
  0%, 100% { filter: drop-shadow(0 0 2px #f0d48a40); }
  50% { filter: drop-shadow(0 0 7px #f0d48a99); }
}

/* Gear squares: rarity glow that pulses (opacity only). */
.slot:not(.empty)::after {
  content: "";
  position: absolute;
  inset: -2px;
  border-radius: 8px;
  pointer-events: none;
  box-shadow: 0 0 22px 3px var(--rc), inset 0 0 14px color-mix(in srgb, var(--rc) 55%, transparent);
  opacity: 0.35;
}
.slot .up { z-index: 2; }
.slot { transition: transform 0.15s ease; }
.slot:not(.empty):hover { transform: translateY(-2px) scale(1.03); }
.slot:not(.empty):hover::after { opacity: 0.9; animation: none; }

.slot[data-rarity="rare"]::after,
.slot[data-rarity="epic"]::after { animation: pulse 3.6s ease-in-out infinite; }
.slot[data-rarity="legendary"]::after,
.slot[data-rarity="unique"]::after { animation: pulse 2.8s ease-in-out infinite; }
.slot[data-rarity="mythic"]::after,
.slot[data-rarity="divine"]::after { animation: pulse 2.2s ease-in-out infinite; }

/* mythic and divine: a light travels around the border */
.slot[data-rarity="mythic"],
.slot[data-rarity="divine"] {
  border-color: transparent;
  background:
    radial-gradient(circle at 50% 30%, color-mix(in srgb, var(--rc) 26%, #0b1424), #050a14) padding-box,
    conic-gradient(from var(--angle), color-mix(in srgb, var(--rc) 35%, #000) 0%, var(--rc) 20%, #ffffff 28%, var(--rc) 36%, color-mix(in srgb, var(--rc) 35%, #000) 60%, color-mix(in srgb, var(--rc) 35%, #000) 100%) border-box;
  animation: spin 4.5s linear infinite;
}
.slot[data-rarity="divine"] { animation-duration: 3.2s; }

@keyframes pulse { 0%, 100% { opacity: 0.25; } 50% { opacity: 0.85; } }
@keyframes spin { to { --angle: 360deg; } }

/* Sparkles on the frame outline. app.js moves and animates them. */
.sparks { position: absolute; inset: 0; z-index: 1; pointer-events: none; }
.spark {
  position: absolute;
  width: calc(var(--slot) * 0.16);
  height: calc(var(--slot) * 0.16);
  opacity: 0;
  filter: drop-shadow(0 0 3px var(--rc)) drop-shadow(0 0 6px var(--rc));
}
.spark i {
  display: block;
  width: 100%;
  height: 100%;
  background: #fff;
  clip-path: polygon(50% 0, 58% 42%, 100% 50%, 58% 58%, 50% 100%, 42% 58%, 0 50%, 42% 42%);
}

@media (prefers-reduced-motion: reduce) {
  #name, .title, h2, .slot, .slot::after { animation: none !important; }
  .slot:not(.empty):hover { transform: none; }
}
