:root {
  --bg: #080910;
  --panel: #12141f;
  --panel-2: #1a1d2c;
  --line: #2a2f45;
  --text: #e8ebf7;
  --muted: #8f97bb;
  --gold: #ffd479;
  --good: #7ee787;
  --bad: #ff6b8a;
  --ivory: #ffe9c2;
  --obsidian: #8ab4ff;
  --epic: #c58bff;
  --rare: #5db6ff;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  background: radial-gradient(1100px 620px at 50% -12%, #1b1f36 0%, var(--bg) 62%);
  color: var(--text);
  font-family: ui-sans-serif, system-ui, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  min-height: 100%;
}

.app {
  max-width: 1180px;
  margin: 0 auto;
  padding: 16px 14px 40px;
}

/* ------------------------------------------------------------- topbar */

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.topbar h1 {
  margin: 0;
  font-size: 24px;
  letter-spacing: 0.14em;
  background: linear-gradient(180deg, #fff2cf, #d8a63c);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.tagline {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  flex: 1 1 260px;
}

.topbar-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.gemsbtn {
  display: flex;
  align-items: center;
  gap: 6px;
  background: linear-gradient(180deg, #2b3153, #1d2138);
  border-color: #46508a;
}

.gem {
  filter: drop-shadow(0 0 4px #7cc7ff);
}

/* ------------------------------------------------------------- layout */

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(292px, 0.85fr);
  gap: 14px;
  align-items: start;
}

@media (max-width: 900px) {
  .layout {
    grid-template-columns: 1fr;
  }
}

.board-col,
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
}

.stats {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  margin-bottom: 10px;
}

.stat {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 6px 10px;
  display: flex;
  flex-direction: column;
}

.stat span {
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

.stat b {
  font-size: 18px;
  font-variant-numeric: tabular-nums;
}

#stat-gold {
  color: var(--gold);
}

#stat-lives.low {
  color: var(--bad);
}

.canvas-holder {
  position: relative;
}

canvas {
  width: 100%;
  display: block;
  border-radius: 10px;
  cursor: pointer;
  touch-action: manipulation;
}

/* ------------------------------------------------------------ overlays */

.overlay {
  position: absolute;
  inset: 0;
  background: rgba(6, 7, 15, 0.9);
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 16px;
  text-align: center;
  z-index: 4;
}

.overlay h2 {
  margin: 0;
  font-size: 22px;
}

.overlay .sub {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  max-width: 40ch;
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 8px;
  width: 100%;
  margin-top: 6px;
}

.card {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 10px;
  cursor: pointer;
  text-align: left;
  color: var(--text);
  transition: transform 0.08s ease, border-color 0.15s ease, background 0.15s ease;
}

.card:hover {
  transform: translateY(-3px);
  background: #232840;
}

.card h4 {
  margin: 4px 0 6px;
  font-size: 14px;
}

.card p {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.45;
}

.card .crarity,
.pull .prarity,
.ccard .crarity {
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  opacity: 0.9;
}

.r-common {
  border-color: #3c4467;
}
.r-common .crarity,
.r-common .prarity {
  color: #9fb0dd;
}
.r-rare {
  border-color: var(--rare);
  box-shadow: 0 0 16px rgba(93, 182, 255, 0.16) inset;
}
.r-rare .crarity,
.r-rare .prarity {
  color: var(--rare);
}
.r-epic {
  border-color: var(--epic);
  box-shadow: 0 0 20px rgba(197, 139, 255, 0.22) inset;
}
.r-epic .crarity,
.r-epic .prarity {
  color: var(--epic);
}

.curse-card {
  border-color: #6b3a52;
}

.card p.bad {
  color: var(--bad);
}

.card p.good {
  color: var(--good);
}

.over-actions {
  display: flex;
  gap: 8px;
  margin-top: 6px;
}

/* -------------------------------------------------------------- timer */

.timerbar {
  position: relative;
  height: 18px;
  margin-top: 8px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 9px;
  overflow: hidden;
}

.timerbar i {
  position: absolute;
  inset: 0 auto 0 0;
  background: linear-gradient(90deg, #4a5aa8, #7c6ad8);
  transition: width 0.12s linear;
}

.timerbar span {
  position: relative;
  display: block;
  text-align: center;
  font-size: 11px;
  line-height: 16px;
  color: #dfe4ff;
}

.controls,
.abilities {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.abilities {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
}

.ability {
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  padding: 7px 10px;
  font-size: 12px;
  opacity: 0.6;
}

.ability.ready {
  opacity: 1;
  border-color: #5a67b8;
}

.ability .cdfill {
  position: absolute;
  inset: 0 auto 0 0;
  background: rgba(120, 140, 255, 0.16);
}

.ability .alabel,
.ability .acd {
  position: relative;
}

.ability .acd {
  color: var(--muted);
  font-size: 11px;
}

/* -------------------------------------------------------------- panel */

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.panel h2 {
  margin: 2px 0 8px;
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.offers {
  display: grid;
  gap: 7px;
}

.offer {
  display: grid;
  grid-template-columns: 30px 1fr auto;
  align-items: center;
  gap: 9px;
  text-align: left;
  padding: 7px 9px;
  width: 100%;
}

.offer .glyph {
  font-size: 22px;
  line-height: 1;
  text-align: center;
}

.glyph.ivory {
  color: var(--ivory);
  text-shadow: 0 0 8px rgba(255, 220, 160, 0.5);
}

.glyph.obsidian {
  color: var(--obsidian);
  text-shadow: 0 0 8px rgba(120, 170, 255, 0.5);
}

.oinfo {
  min-width: 0;
}

.oname {
  display: block;
  font-size: 13px;
}

.oname em {
  font-style: normal;
  font-size: 10px;
  color: var(--gold);
  border: 1px solid currentColor;
  border-radius: 4px;
  padding: 0 3px;
  margin-left: 4px;
}

.odesc {
  display: block;
  font-size: 11px;
  color: var(--muted);
  font-weight: 400;
  line-height: 1.35;
}

.ocost {
  color: var(--gold);
  font-variant-numeric: tabular-nums;
  font-size: 13px;
}

.offer.selected {
  border-color: var(--gold);
  background: #2a2438;
}

.offer.poor .ocost {
  color: var(--bad);
}

.offer.sold {
  opacity: 0.35;
  cursor: default;
}

.offer.champ {
  background: linear-gradient(180deg, #241f36, #1a1d2c);
}

.selection {
  margin: 10px 0;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
}

.selection.empty .hint,
.relics .hint {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.selection h3 {
  margin: 0 0 8px;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.selection h3 .glyph {
  font-size: 20px;
}

.selection dl {
  margin: 0 0 9px;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 2px 10px;
  font-size: 12px;
}

.selection dt {
  color: var(--muted);
}

.selection dd {
  margin: 0;
  font-variant-numeric: tabular-nums;
}

.row {
  display: flex;
  gap: 8px;
}

.row button {
  flex: 1;
}

.relics {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-bottom: 10px;
}

.chip {
  font-size: 11px;
  padding: 3px 7px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  cursor: help;
}

.chip.r-rare {
  color: var(--rare);
}
.chip.r-epic {
  color: var(--epic);
}
.chip.curse {
  color: var(--bad);
  border-color: #6b3a52;
}

.log {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 4px;
  max-height: 148px;
  overflow-y: auto;
  font-size: 11.5px;
}

.log li {
  padding: 4px 7px;
  border-radius: 6px;
  background: var(--panel-2);
  border-left: 3px solid var(--line);
  color: var(--muted);
}

.log li.good {
  border-left-color: var(--good);
  color: #cfe9d4;
}
.log li.bad {
  border-left-color: var(--bad);
  color: #f6cfd8;
}
.log li.warn {
  border-left-color: var(--gold);
  color: #f6e6c6;
}

/* ------------------------------------------------------------ buttons */

button {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 7px 11px;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: transform 0.06s ease, border-color 0.15s, background 0.15s;
}

button:hover:not(:disabled) {
  border-color: #4d569b;
  background: #232840;
}

button:active:not(:disabled) {
  transform: translateY(1px);
}

button:disabled {
  opacity: 0.42;
  cursor: not-allowed;
}

button.primary {
  background: linear-gradient(180deg, #d8a63c, #a97c1d);
  border-color: #e2b64f;
  color: #1c1405;
}

button.primary:hover:not(:disabled) {
  background: linear-gradient(180deg, #ecb948, #bd8b22);
}

button.ghost {
  background: transparent;
}

button.mini {
  padding: 4px 8px;
  font-size: 11px;
}

/* ------------------------------------------------------------- modals */

.modal {
  position: fixed;
  inset: 0;
  background: rgba(4, 5, 12, 0.82);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  z-index: 20;
}

.modal-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 18px;
  max-width: 560px;
  width: 100%;
  max-height: 88vh;
  overflow-y: auto;
}

.modal-card.wide {
  max-width: 720px;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.modal-head h2 {
  margin: 0;
  font-size: 18px;
}

.modal-head-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.gemtag {
  display: flex;
  align-items: center;
  gap: 5px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 13px;
}

.tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.tab.active {
  border-color: var(--gold);
  color: var(--gold);
}

.banner-art {
  position: relative;
  border-radius: 12px;
  border: 1px solid #4a3f70;
  background: linear-gradient(135deg, #2a2145, #171a2c 60%);
  padding: 18px;
  overflow: hidden;
  text-align: center;
  margin-bottom: 10px;
}

.banner-glow {
  position: absolute;
  width: 260px;
  height: 260px;
  left: 50%;
  top: -140px;
  transform: translateX(-50%);
  background: radial-gradient(circle, rgba(197, 139, 255, 0.35), transparent 65%);
}

.banner-art h3 {
  margin: 0 0 4px;
  position: relative;
  letter-spacing: 0.18em;
  font-size: 18px;
}

.banner-art p {
  margin: 0;
  position: relative;
  font-size: 12px;
  color: var(--muted);
}

.banner-art .pity {
  margin-top: 4px;
  color: var(--gold);
}

.pulls {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(104px, 1fr));
  gap: 7px;
  margin-top: 12px;
}

.pull {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px;
  text-align: center;
  display: grid;
  gap: 2px;
  animation: pop 0.28s ease;
}

@keyframes pop {
  from {
    transform: scale(0.82);
    opacity: 0;
  }
}

.pull .pglyph {
  font-size: 26px;
}

.pull .pname {
  font-size: 12px;
}

.pull .ptag {
  font-size: 10px;
  color: var(--gold);
}

.collection {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 8px;
}

.ccard {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px;
}

.ccard.locked {
  opacity: 0.45;
}

.chead {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.cglyph {
  font-size: 26px;
  color: var(--ivory);
}

.ccard h4 {
  margin: 4px 0;
  font-size: 13px;
}

.ccard p {
  margin: 0 0 6px;
  font-size: 11px;
  color: var(--muted);
  line-height: 1.4;
}

.stars {
  color: var(--gold);
  letter-spacing: 2px;
  font-size: 12px;
}

.shardline,
.lockline {
  font-size: 11px;
  color: var(--muted);
}

.pass-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.pass-head h3 {
  margin: 0 0 2px;
  font-size: 15px;
}

.pass-track {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 8px;
}

.ptier {
  min-width: 62px;
  display: grid;
  gap: 4px;
  text-align: center;
}

.pnum {
  font-size: 11px;
  color: var(--muted);
}

.ptier.reached .pnum {
  color: var(--gold);
}

.preward {
  font-size: 11px;
  padding: 8px 4px;
  border-radius: 8px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--muted);
}

.preward.premium {
  border-color: #6a5a2c;
  background: #241f14;
  color: var(--gold);
}

.preward.claimable {
  cursor: pointer;
  border-color: var(--good);
  color: var(--good);
  animation: glow 1.6s infinite;
}

@keyframes glow {
  50% {
    box-shadow: 0 0 12px rgba(126, 231, 135, 0.4);
  }
}

.preward.claimed {
  opacity: 0.35;
}

.packs {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 9px;
}

.pack {
  position: relative;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px 10px 12px;
  text-align: center;
  display: grid;
  gap: 8px;
}

.pack.tagged {
  border-color: var(--gold);
}

.ptagline {
  position: absolute;
  top: -9px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--gold);
  color: #1c1405;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  white-space: nowrap;
}

.pgem {
  font-size: 15px;
}

.pgem em {
  font-style: normal;
  color: var(--good);
  font-size: 12px;
}

.demo-note {
  margin: 12px 0 0;
  font-size: 11.5px;
  color: var(--muted);
  line-height: 1.5;
  border-top: 1px dashed var(--line);
  padding-top: 10px;
}

.help-body {
  font-size: 13.5px;
  line-height: 1.65;
}

.help-body h3 {
  margin: 16px 0 4px;
  font-size: 12px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

.help-body ul {
  margin: 0;
  padding-left: 20px;
}

kbd {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 5px;
  padding: 1px 5px;
  font-size: 11px;
  font-family: ui-monospace, monospace;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translate(-50%, 20px);
  background: #232840;
  border: 1px solid var(--line);
  color: var(--text);
  padding: 9px 16px;
  border-radius: 999px;
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 40;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.hidden {
  display: none !important;
}

.ocost em {
  display: block;
  font-style: normal;
  font-size: 10px;
  color: var(--muted);
  font-weight: 500;
}
