:root {
  --bg: #2b1d14;
  --paper: #f4e9cc;
  --paper2: #e6d3a3;
  --ink: #2a1a0e;
  --muted: #7a5c3e;
  --gold: #ffcc33;
  --gold-light: #fff1a8;
  --gold-dark: #c8901a;
  --good: #2f8a3a;
  --bad: #b03030;
  --px: 4px;
  --rainbow: linear-gradient(90deg, #e53935, #fb8c00, #fdd835, #43a047, #1e88e5, #8e24aa);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; min-height: 100%; }

body {
  background-color: var(--bg);
  background-image: repeating-linear-gradient(0deg, rgba(0,0,0,.18) 0 4px, transparent 4px 72px);
  color: var(--ink);
  font-family: 'VT323', ui-monospace, Menlo, monospace;
  font-size: 22px;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

button { font: inherit; color: inherit; cursor: pointer; border: none; background: none; }
button:disabled { cursor: not-allowed; }
h1, h2, h3 { margin: 0; font-weight: 700; }
.muted { color: var(--muted); }
.small { font-size: 18px; }
.center { text-align: center; }
.good { color: var(--good); }
.bad { color: var(--bad); }

/* Pixel border: a box shadow on four sides leaves notched corners */
.box {
  background: var(--paper);
  box-shadow:
    var(--px) 0 0 0 var(--ink),
    calc(-1 * var(--px)) 0 0 0 var(--ink),
    0 var(--px) 0 0 var(--ink),
    0 calc(-1 * var(--px)) 0 0 var(--ink),
    inset 0 calc(-1 * var(--px)) 0 0 rgba(0,0,0,.12);
}

/* ================= Top bar ================= */

.topbar {
  display: flex;
  gap: 24px;
  align-items: flex-start;
  padding: 20px 24px 8px;
  max-width: 1280px;
  width: 100%;
  margin: 0 auto;
}
.tab { padding: 8px 16px; display: inline-flex; gap: 12px; align-items: center; }
.tab:hover { background: var(--gold-light); }
.caret { display: inline-block; transition: transform .15s; font-size: 18px; }
.tab.open .caret { transform: rotate(180deg); }

.dropdown { position: relative; }
.popover { position: absolute; top: calc(100% + 14px); left: 0; z-index: 20; width: 300px; padding: 14px 16px; }
.popover p { margin: 8px 0 0; }
.popover table { width: 100%; margin-top: 8px; border-collapse: collapse; }
.popover td { padding: 3px 0; }
.popover td:last-child { text-align: right; font-weight: 700; }
.link { margin-top: 12px; color: var(--bad); text-decoration: underline; padding: 0; font-size: 18px; }

.gold-box { margin-left: auto; padding: 8px 18px; display: flex; flex-direction: column; align-items: flex-end; min-width: 200px; }
.gold-box .label { font-size: 18px; color: var(--muted); }
.gold-num { font-size: 30px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.coin-icon {
  width: 20px; height: 20px;
  background: radial-gradient(circle at 35% 35%, var(--gold-light) 0 20%, var(--gold) 21% 65%, var(--gold-dark) 66%);
  border: 3px solid var(--ink);
  border-radius: 50%;
}

/* ================= Home screen ================= */

.board {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(300px, 1fr) minmax(340px, 1.25fr);
  grid-template-rows: auto 1fr;
  grid-template-areas: "clicker store" "upgrades store";
  gap: 28px 36px;
  padding: 16px 24px;
  max-width: 1280px;
  width: 100%;
  margin: 0 auto;
}

.clicker { grid-area: clicker; display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 10px 0; }
.clicker h1 { color: var(--gold); font-size: 38px; text-shadow: 3px 3px 0 #000; letter-spacing: 1px; }
.clicker .muted { color: var(--paper2); }

.coin {
  width: 210px; height: 210px;
  border-radius: 50%;
  border: 6px solid var(--ink);
  background: radial-gradient(circle at 35% 30%, var(--gold-light) 0 14%, var(--gold) 15% 62%, var(--gold-dark) 63%);
  box-shadow: 0 8px 0 0 #000;
  font-size: 26px;
  font-weight: 700;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition: transform .06s;
}
.coin:hover { filter: brightness(1.06); }
.coin:active { transform: translateY(4px) scale(.97); box-shadow: 0 4px 0 0 #000; }
.coin.bump { animation: bump .15s; }
.coin.has-art { background-size: cover; background-position: center; image-rendering: pixelated; border-color: transparent; box-shadow: none; }
.coin.has-art span { display: none; }
@keyframes bump { 50% { transform: scale(.93); } }

.floater {
  position: fixed;
  pointer-events: none;
  font-weight: 700;
  font-size: 26px;
  color: var(--gold);
  text-shadow: 2px 2px 0 #000;
  transform: translate(-50%, 0);
  animation: float .9s ease-out forwards;
  z-index: 50;
}
@keyframes float { to { transform: translate(-50%, -70px); opacity: 0; } }

.panel { padding: 16px; }
.panel h2 { margin-bottom: 12px; font-size: 28px; }

.upgrades { grid-area: upgrades; align-self: start; }
.panel-tabs { display: flex; gap: 8px; margin-bottom: 12px; border-bottom: 3px solid var(--ink); }
.panel-tabs button { padding: 6px 10px; font-weight: 700; color: var(--muted); border-bottom: 4px solid transparent; margin-bottom: -3px; }
.panel-tabs button.active { color: var(--ink); border-bottom-color: var(--gold-dark); }

.upgrade-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.upgrade { width: 100%; text-align: left; padding: 8px 12px; background: #fff8e4; border: 3px solid var(--ink); }
.upgrade:hover:not(:disabled) { background: var(--gold-light); }
.upgrade:disabled { opacity: .55; }
.u-top, .u-bottom { display: flex; justify-content: space-between; gap: 10px; }
.u-name { font-weight: 700; text-decoration: underline; }
.u-owned { font-weight: 700; color: var(--good); }
.u-desc, .u-cost { font-size: 19px; }
.u-cost { font-weight: 700; white-space: nowrap; }

/* ================= Store and packs ================= */

.store { grid-area: store; align-self: start; }
.pack-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px 10px; }
.pack-exotic { grid-column: 4; grid-row: 3; }

.pack-btn {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 10px 4px;
  border: 3px solid transparent;
  text-align: center;
  line-height: 1.1;
}
.pack-btn:hover:not(:disabled) { border-color: var(--ink); background: #fff8e4; }
.pack-btn:hover:not(:disabled) .pack-art { transform: translateY(-4px) rotate(-3deg); }
.pack-btn:disabled .pack-art { filter: grayscale(.6) brightness(.85); }
.pack-btn:disabled .p-price { color: var(--bad); }
.p-name { font-weight: 700; font-size: 20px; margin-top: 4px; }
.p-price { font-size: 19px; }
.p-dots { display: flex; gap: 3px; justify-content: center; margin-top: 2px; }
.p-note { font-size: 16px; color: var(--muted); }
.god-note { font-weight: 700; color: #b8860b; animation: shimmer 1.2s steps(2) infinite; }
@keyframes shimmer { 50% { color: #e53935; } }

.pack-art {
  width: 46px; height: 66px;
  background: var(--pc);
  border: 3px solid var(--ink);
  position: relative;
  transition: transform .12s;
  box-shadow: inset 6px 0 0 rgba(255,255,255,.35), inset -6px 0 0 rgba(0,0,0,.18);
}
.pack-art.stripes { background: repeating-linear-gradient(135deg, #1c1c1c 0 9px, #e8e8e8 9px 14px); }
.pack-art.shady { background: repeating-linear-gradient(45deg, #2a2236 0 6px, #3f3352 6px 12px); }
.pack-art.shady::after { content: "?"; position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: #b48cff; font-size: 30px; font-weight: 700; }
.pack-art.has-art { background: none; border: none; box-shadow: none; }
.pack-art.has-art::after { content: none; }
.pack-art img { width: 100%; height: 100%; object-fit: contain; image-rendering: pixelated; }

.dot { width: 10px; height: 10px; background: var(--rc); border: 2px solid var(--ink); display: inline-block; }
.dot.big { width: 22px; height: 22px; border-width: 3px; flex-shrink: 0; }
.dot.god { background: var(--rainbow); }

/* ================= Bottom bar ================= */

.bottombar { display: flex; gap: 24px; justify-content: center; padding: 12px 24px 28px; }

/* ================= Cards ================= */

.card {
  --rc: #ccc;
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 5px;
  background: var(--rc);
  border: 3px solid var(--ink);
  box-shadow: inset 0 0 0 2px rgba(255,255,255,.35);
  text-align: center;
  overflow: hidden;
}
.c-name {
  background: rgba(255,255,255,.8);
  border: 2px solid var(--ink);
  font-weight: 700;
  line-height: 1;
  padding: 2px 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.c-attrs { display: flex; gap: 2px; justify-content: center; align-items: center; }
.a-icon { display: inline-flex; }
.a-icon svg { width: 100%; height: 100%; }
.c-pic {
  flex: 1;
  min-height: 0;
  background: #fbf6e8;
  border: 2px solid var(--ink);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.c-pic svg, .c-pic img { width: 100%; height: 100%; display: block; }
.c-pic img { object-fit: contain; image-rendering: pixelated; }
.c-bottom {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(255,255,255,.8);
  border: 2px solid var(--ink);
  padding: 0 5px;
  line-height: 1;
}
.c-rarity { color: var(--muted); }
.c-str { font-weight: 700; }
.c-str::before { content: "STR "; font-size: .6em; color: var(--muted); }

.size-big  { width: 156px; height: 226px; }
.size-big  .c-name { font-size: 21px; }
.size-big  .c-attrs { height: 20px; }
.size-big  .a-icon { width: 20px; height: 20px; }
.size-big  .c-bottom { font-size: 17px; height: 30px; }
.size-big  .c-str { font-size: 30px; }

.size-mini { width: 114px; height: 168px; padding: 4px; }
.size-mini .c-name { font-size: 17px; }
.size-mini .c-attrs { height: 15px; }
.size-mini .a-icon { width: 15px; height: 15px; }
.size-mini .c-bottom { font-size: 14px; height: 24px; }
.size-mini .c-str { font-size: 23px; }

.size-tiny { width: 66px; height: 96px; padding: 2px; gap: 2px; border-width: 2px; }
.size-tiny .c-name { font-size: 12px; border-width: 1px; padding: 1px; }
.size-tiny .c-attrs { height: 9px; gap: 1px; }
.size-tiny .a-icon { width: 9px; height: 9px; }
.size-tiny .c-pic { border-width: 1px; }
.size-tiny .c-bottom { font-size: 14px; height: 16px; border-width: 1px; justify-content: center; }
.size-tiny .c-rarity { display: none; }

/* The God card */
.r-god { background: var(--rainbow); animation: godglow 1s steps(2) infinite; }
@keyframes godglow { 50% { box-shadow: inset 0 0 0 2px #fff, 0 0 18px 4px #fff3b0; } }

/* Attribute looks */
.a-gold { box-shadow: inset 0 0 0 3px #ffcc33, 0 0 0 2px #ffcc33, 0 0 12px #ffcc33; }
.a-gold .c-name, .a-gold .c-bottom { background: linear-gradient(135deg, #fff6c2, #ffd95a 50%, #fff6c2); }
.a-rainbow { animation: rainbowglow 1.6s steps(6) infinite; }
@keyframes rainbowglow {
  0%   { box-shadow: 0 0 0 3px #e53935, 0 0 12px #e53935; }
  17%  { box-shadow: 0 0 0 3px #fb8c00, 0 0 12px #fb8c00; }
  33%  { box-shadow: 0 0 0 3px #fdd835, 0 0 12px #fdd835; }
  50%  { box-shadow: 0 0 0 3px #43a047, 0 0 12px #43a047; }
  67%  { box-shadow: 0 0 0 3px #1e88e5, 0 0 12px #1e88e5; }
  83%  { box-shadow: 0 0 0 3px #8e24aa, 0 0 12px #8e24aa; }
}
.a-rainbow .c-pic { background: linear-gradient(160deg, #ffe0e0, #fff6d0, #dff5df, #dde9ff, #f0e0ff); }
.a-mini .c-pic svg, .a-mini .c-pic img { transform: scale(.7) translateY(18%); }
.a-mega .c-pic svg, .a-mega .c-pic img { transform: scale(1.18); }
.a-alpha .c-pic svg, .a-alpha .c-pic img { transform: scale(1.25); }
.a-alpha .c-pic { background: radial-gradient(circle, #fff 0 30%, #ffd2d2); }
.a-ascended .c-pic { background: radial-gradient(circle at 50% 30%, #ffffff 0 25%, #fff3b0 60%, #fbf6e8); }
.a-descended .c-pic { background: radial-gradient(circle at 50% 60%, #7a2020 0 30%, #3a1010); }
.a-professional .c-name { border-color: #b8860b; }
.a-of_a_kind { background: linear-gradient(135deg, var(--rc) 0 40%, #e8fbff 50%, var(--rc) 60%); background-size: 300% 300%; animation: sheen 2.5s linear infinite; }
@keyframes sheen { from { background-position: 100% 100%; } to { background-position: 0 0; } }

/* Glitched cards are animated */
.a-glitched { animation: glitch 1.4s steps(1) infinite; }
.a-glitched .c-pic { animation: glitchpic .9s steps(1) infinite; }
@keyframes glitch {
  0%, 100% { transform: none; filter: none; }
  8%  { transform: translate(-3px, 1px); filter: hue-rotate(90deg); }
  10% { transform: translate(3px, -1px); filter: hue-rotate(-60deg) saturate(2); }
  12% { transform: none; filter: none; }
  55% { transform: skewX(-4deg); filter: invert(.15); }
  57% { transform: none; filter: none; }
}
@keyframes glitchpic {
  0%, 100% { clip-path: none; }
  20% { clip-path: inset(10% 0 55% 0); transform: translateX(4px); }
  22% { clip-path: none; transform: none; }
  60% { clip-path: inset(50% 0 20% 0); transform: translateX(-4px); }
  63% { clip-path: none; transform: none; }
}
.glitch-bars {
  position: absolute; inset: 0;
  pointer-events: none;
  background:
    linear-gradient(transparent 0 30%, rgba(255,42,109,.35) 30% 33%, transparent 33% 70%, rgba(5,217,232,.35) 70% 72%, transparent 72%);
  background-size: 100% 200%;
  animation: bars 1.1s steps(4) infinite;
  mix-blend-mode: multiply;
}
@keyframes bars { to { background-position: 0 200%; } }

/* A card you do not own yet */
.card.missing { --rc: #e2d6b4; color: var(--muted); }
.card.missing .c-pic { background: #efe4c8; }
.card.missing .q { font-size: 44px; font-weight: 700; }
.card.missing .c-name, .card.missing .c-bottom { background: #efe4c8; }

/* ================= Popups ================= */

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 5, 0, .72);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  z-index: 40;
}
.modal { max-width: 720px; width: 100%; max-height: calc(100vh - 48px); overflow: auto; padding: 18px 20px; }
.modal.wide { max-width: 1000px; }
.modal-head { display: flex; align-items: baseline; gap: 14px; margin-bottom: 8px; }
.modal-head h2 { font-size: 30px; }
.close { margin-left: auto; font-size: 24px; padding: 0 6px; }
.close:hover { color: var(--bad); }

.btn { padding: 8px 16px; font-weight: 700; }
.btn:hover:not(:disabled) { background: var(--gold-light); }
.btn:disabled { opacity: .5; }
.btn.gold { background: var(--gold); }
.btn.gold:hover:not(:disabled) { background: var(--gold-light); }
.small-btn { padding: 3px 10px; font-size: 18px; }
.modal-actions { display: flex; gap: 20px; justify-content: center; flex-wrap: wrap; margin-top: 18px; padding: 4px; }

/* Pack opening */
.open-cards { display: flex; gap: 18px; justify-content: center; flex-wrap: wrap; margin: 16px 0 6px; padding-top: 8px; }
.flip { width: 156px; height: 226px; perspective: 800px; padding: 0; }
.flip-inner { position: relative; width: 100%; height: 100%; transition: transform .5s; transform-style: preserve-3d; }
.flip:hover:not(.flipped) .flip-inner { transform: translateY(-6px); }
.flip.flipped .flip-inner { transform: rotateY(180deg); }
.face { position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden; }
.face.front { transform: rotateY(180deg); }
.face.back {
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  background: var(--pc);
  border: 4px solid var(--ink);
  box-shadow: inset 8px 0 0 rgba(255,255,255,.3);
}
.face.back.stripes { background: repeating-linear-gradient(135deg, #1c1c1c 0 12px, #e8e8e8 12px 18px); }
.face.back.shady { background: repeating-linear-gradient(45deg, #2a2236 0 10px, #3f3352 10px 20px); }
.face.back.shady::after { content: none; }
.face.back.has-art { background: none; border: none; box-shadow: none; }
.face.back img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; image-rendering: pixelated; }
.face.back .q { position: relative; font-size: 60px; font-weight: 700; color: #fff; text-shadow: 3px 3px 0 var(--ink); }

.badge {
  position: absolute;
  top: -14px;
  right: -12px;
  padding: 2px 8px;
  font-size: 17px;
  font-weight: 700;
  border: 2px solid var(--ink);
  transform: rotate(6deg);
  z-index: 2;
  white-space: nowrap;
}
.badge.new { background: #ff5a5a; color: #fff; }
.badge.version { background: #4a9be0; color: #fff; }
.badge.dup { background: var(--paper2); font-size: 15px; top: auto; bottom: -12px; right: -6px; transform: rotate(-4deg); }
.badge.secret { background: #222; color: #7cff6b; top: auto; bottom: 30px; left: -12px; right: auto; transform: rotate(-6deg); }

.open-msg { text-align: center; min-height: 10px; }
.big { font-size: 28px; font-weight: 700; margin-top: 10px; }
.god-text {
  background: linear-gradient(90deg, #e53935, #fb8c00, #c9a400, #43a047, #1e88e5, #8e24aa);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent !important;
  font-size: 34px;
}

/* Collection */
.coll-body { display: flex; flex-direction: column; gap: 18px; }
.legend { background: #fff8e4; border: 3px solid var(--ink); padding: 8px 12px; }
.legend-list { display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 6px 0; }
.legend-item { display: inline-flex; align-items: center; gap: 5px; font-size: 19px; }
.legend-item .a-icon { width: 18px; height: 18px; }
.set { border-top: 3px dashed var(--paper2); padding-top: 12px; }
.set-head { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; flex-wrap: wrap; }
.set-title strong { font-size: 24px; }
.set-info { margin-left: auto; font-size: 19px; color: var(--muted); }
.set-info.done { color: var(--good); font-weight: 700; }
.set-grid { display: grid; grid-template-columns: repeat(auto-fill, 114px); gap: 12px; }
.god-set { border-top-style: solid; border-top-color: #fdd835; }
.coll-card { padding: 0; position: relative; display: flex; flex-direction: column; align-items: center; }
.coll-card:hover .card { transform: translateY(-4px); }
.coll-card .card { transition: transform .1s; }
.count { font-size: 16px; font-weight: 700; color: var(--good); }

/* Card detail */
.detail-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(124px, 1fr)); gap: 14px; margin-top: 10px; }
.detail-cell { display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center; }

/* Picker */
.picker-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(122px, 1fr)); gap: 14px; margin-top: 8px; }
.pick { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 4px; border: 3px solid transparent; }
.pick:hover:not(:disabled) { border-color: var(--ink); background: #fff8e4; }
.pick:disabled { opacity: .5; }
.pick-chance { font-weight: 700; font-size: 19px; }

/* Toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: 90px;
  transform: translateX(-50%);
  padding: 10px 18px;
  z-index: 60;
  font-size: 22px;
  font-weight: 700;
  max-width: calc(100vw - 32px);
  text-align: center;
  transition: opacity .4s;
}
.toast.good { background: #dff3d8; }
.toast.bad { background: #f6d6d0; }
.toast.out { opacity: 0; }

/* ================= Tavern screen ================= */

.tavern {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(300px, 1fr) 270px minmax(320px, 1.05fr);
  grid-template-areas: "quests pit market" "events events events";
  grid-template-rows: auto auto;
  gap: 28px;
  padding: 16px 24px;
  max-width: 1280px;
  width: 100%;
  margin: 0 auto;
  align-items: start;
}

.quests { grid-area: quests; }
.quest-list { display: flex; flex-direction: column; gap: 8px; }
.quest { display: flex; justify-content: space-between; align-items: center; gap: 10px; background: #fff8e4; border: 3px solid var(--ink); padding: 6px 10px; min-height: 76px; }
.q-name { font-weight: 700; font-size: 21px; }
.q-side { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.q-side .size-tiny { width: 48px; height: 70px; }
.q-side .size-tiny .c-name, .q-side .size-tiny .c-attrs { display: none; }
.q-info { flex: 1; min-width: 0; }
.q-bar { height: 12px; margin-top: 5px; background: #e6dcc4; border: 2px solid var(--ink); }
.q-fill { height: 100%; background: var(--gold); transition: width .1s linear; }
.q-time { font-size: 24px; font-weight: 700; min-width: 54px; text-align: right; }

.pit { grid-area: pit; display: flex; justify-content: center; }
.pit-arch {
  width: 100%;
  border: 4px solid var(--ink);
  border-radius: 135px 135px 0 0;
  background:
    repeating-linear-gradient(0deg, rgba(0,0,0,.25) 0 3px, transparent 3px 26px),
    linear-gradient(#5a4a3e, #2e241c);
  padding: 40px 16px 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
  color: var(--paper);
}
.pit-sign { font-size: 34px; font-weight: 700; color: var(--gold); text-shadow: 3px 3px 0 #000; margin-bottom: 8px; }
.pit-body { display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; }
.pit-body .muted { color: var(--paper2); }
.pit-rank { font-weight: 700; font-size: 21px; }

.market { grid-area: market; }
.market-cards { display: grid; grid-template-columns: repeat(auto-fill, 114px); gap: 12px; justify-content: center; margin: 8px 0 14px; }
.offer { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.shady { display: flex; justify-content: center; border-top: 3px dashed var(--paper2); padding-top: 10px; }

.events { grid-area: events; }
.events p { margin: 0; }

/* Fights */
.arena { display: flex; align-items: center; justify-content: center; gap: 24px; margin: 10px 0; }
.fighter { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.f-label { font-weight: 700; }
.fighter.hit .card { animation: hit .4s; }
@keyframes hit {
  0%, 100% { transform: none; filter: none; }
  20% { transform: translateX(-8px) rotate(-3deg); filter: brightness(1.6) sepia(1) hue-rotate(-50deg) saturate(4); }
  40% { transform: translateX(8px) rotate(3deg); }
  60% { transform: translateX(-5px); }
}
.vs { font-size: 48px; font-weight: 700; color: var(--bad); }
.fight-score { display: flex; justify-content: center; align-items: center; gap: 16px; }
.score-text { font-size: 30px; font-weight: 700; }
.pips { display: flex; gap: 4px; }
.pip { width: 16px; height: 16px; border: 3px solid var(--ink); background: #fff; }
.pips.you .pip.on { background: var(--good); }
.pips.them .pip.on { background: var(--bad); }
.fight-log { text-align: center; min-height: 120px; margin-top: 8px; }

/* ================= Phones ================= */

@media (max-width: 960px) {
  .tavern { grid-template-columns: 1fr; grid-template-areas: "pit" "quests" "market" "events"; }
  .pit-arch { max-width: 320px; }
}

@media (max-width: 800px) {
  body { font-size: 20px; }
  .topbar { gap: 10px; padding: 16px 16px 4px; flex-wrap: wrap; }
  .gold-box { min-width: 0; width: 100%; order: -1; align-items: center; }
  .board { grid-template-columns: 1fr; grid-template-areas: "clicker" "upgrades" "store"; padding: 12px 16px; }
  .tavern { padding: 12px 16px; }
  .pack-grid { grid-template-columns: repeat(3, 1fr); }
  .pack-exotic { grid-column: auto; grid-row: auto; }
  .coin { width: 170px; height: 170px; }
  .flip { width: 114px; height: 168px; }
  .flip .size-big { width: 114px; height: 168px; }
  .flip .size-big .c-name { font-size: 16px; }
  .flip .size-big .c-str { font-size: 22px; }
  .arena { gap: 8px; }
  .arena .size-big { width: 114px; height: 168px; }
  .vs { font-size: 32px; }
  .popover { width: min(300px, calc(100vw - 32px)); }
  .set-grid, .market-cards { grid-template-columns: repeat(auto-fill, 100px); }
  .set-grid .size-mini, .market-cards .size-mini { width: 100px; height: 150px; }
}

/* ================= Fixes after testing ================= */

/* Cards keep dark text, also on the dark Pit arch */
.card { color: var(--ink); }
.pit-body .btn { color: var(--ink); }
/* Small cards show only strength. The card color shows the rarity. */
.size-mini .c-rarity { display: none; }
.size-mini .c-bottom { justify-content: center; }
.market-cards { grid-template-columns: repeat(2, 114px); }
/* A quest is ready to collect */
#nav-btn.alert::after {
  content: "!";
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px;
  background: var(--bad); color: #fff;
  border: 2px solid var(--ink);
  font-weight: 700;
  animation: shimmer 1s steps(2) infinite;
}
@media (max-width: 800px) {
  .market-cards { grid-template-columns: repeat(2, 100px); }
}

/* ================= The scene around the coin ================= */

.clicker { padding: 0; gap: 10px; }
.scene {
  position: relative;
  width: 100%;
  height: 400px;
  overflow: hidden;
  border: 4px solid var(--ink);
  background:
    linear-gradient(to top, #8a6a45 0 30px, #a8845a 30px 36px, #6fb04a 36px 100px, transparent 100px),
    radial-gradient(ellipse 38% 26% at 18% 80%, #5d9a3d 0 97%, transparent 100%),
    radial-gradient(ellipse 44% 30% at 82% 82%, #5d9a3d 0 97%, transparent 100%),
    linear-gradient(#8fd0ff, #dff3ff 78%);
}
.coin-wrap { position: absolute; left: 50%; top: 26px; transform: translateX(-50%); z-index: 5; }
.scene .coin { width: 180px; height: 180px; }
.tool {
  position: absolute;
  width: 62px; height: 62px;
  right: -58px; top: 8px;
  pointer-events: none;
  transform-origin: 20% 90%;
  transform: rotate(10deg);
}
.tool svg { width: 100%; height: 100%; }
.tool.strike { animation: strike .18s ease-out; }
@keyframes strike { 0% { transform: rotate(10deg); } 50% { transform: rotate(-40deg) translate(-12px, 6px); } 100% { transform: rotate(10deg); } }

.cloud { position: absolute; height: 22px; width: 70px; background: #fff; border-radius: 20px; opacity: .85; animation: cloud 60s linear infinite; }
.cloud::before { content: ""; position: absolute; width: 36px; height: 30px; background: #fff; border-radius: 50%; left: 14px; top: -14px; }
.cloud.c1 { top: 40px; left: -80px; }
.cloud.c2 { top: 110px; left: -80px; animation-delay: -30s; transform: scale(.7); }
@keyframes cloud { to { left: 110%; } }

.actor { position: absolute; pointer-events: none; }
.actor svg { width: 100%; height: auto; display: block; overflow: visible; }
.layer-1 { z-index: 1; }
.layer-2 { z-index: 2; }
.layer-3 { z-index: 3; }
.layer-4 { z-index: 4; }
.actor.arrive { animation: arrive .8s ease-out; }
@keyframes arrive { 0% { transform: scale(0) translateY(20px); opacity: 0; } 60% { transform: scale(1.2); opacity: 1; } 100% { transform: scale(1); } }
.puff { position: absolute; width: 20px; height: 20px; margin: -10px; border-radius: 50%; background: #fff; z-index: 6; pointer-events: none; animation: puff .7s ease-out forwards; }
@keyframes puff { to { transform: scale(6); opacity: 0; } }

.scene-pop {
  position: absolute;
  z-index: 7;
  pointer-events: none;
  transform: translateX(-50%);
  font-weight: 700;
  font-size: 18px;
  color: var(--gold);
  text-shadow: 2px 2px 0 #000;
  animation: scenepop 1.3s ease-out forwards;
}
@keyframes scenepop { to { transform: translate(-50%, -40px); opacity: 0; } }

/* Parts that move inside the sprites */
.actor g.swing { transform-box: fill-box; transform-origin: 0% 100%; animation: swing .7s ease-in-out infinite alternate; }
@keyframes swing { from { transform: rotate(-35deg); } to { transform: rotate(25deg); } }
.actor g.twinkle { animation: twinkle 1.2s steps(2) infinite; }
@keyframes twinkle { 50% { opacity: .3; } }
.actor g.flag { transform-box: fill-box; transform-origin: 0% 50%; animation: flag .8s ease-in-out infinite alternate; }
@keyframes flag { from { transform: skewY(-8deg) scaleX(.9); } to { transform: skewY(8deg) scaleX(1.05); } }
.actor g.flap { transform-box: fill-box; transform-origin: 50% 100%; animation: flap .35s ease-in-out infinite alternate; }
@keyframes flap { from { transform: scaleY(1); } to { transform: scaleY(-.6); } }
.actor g.cart { animation: cart 3.2s ease-in-out infinite alternate; }
@keyframes cart { from { transform: translateX(0); } to { transform: translateX(34px); } }
.actor g.bob { animation: bob .35s ease-in-out infinite alternate; }
@keyframes bob { to { transform: translateY(-1.5px); } }
.actor g.glow { animation: twinkle 2s steps(2) infinite; }
.actor g.star { transform-box: fill-box; transform-origin: 50% 50%; animation: star 1.6s ease-in-out infinite; }
@keyframes star { 50% { transform: scale(1.5) rotate(36deg); } }
.actor g.rock { transform-box: fill-box; transform-origin: 50% 100%; animation: rock 2.4s ease-in-out infinite alternate; }
@keyframes rock { from { transform: rotate(-4deg) translateY(0); } to { transform: rotate(4deg) translateY(-1.5px); } }
.actor g.flicker { animation: twinkle .3s steps(2) infinite; }
.actor g.smoke { animation: smoke 2.4s linear infinite; }
.actor g.smoke.s2 { animation-delay: -1.2s; }
@keyframes smoke { from { transform: translate(0, 0) scale(.6); opacity: .9; } to { transform: translate(6px, -14px) scale(1.6); opacity: 0; } }
.actor g.sparks { animation: twinkle .5s steps(2) infinite; }
.actor g.hammer { transform-box: fill-box; transform-origin: 0% 100%; animation: hammer .5s ease-in infinite alternate; }
@keyframes hammer { from { transform: rotate(-30deg); } to { transform: rotate(10deg); } }
.actor g.coinpop { animation: coinpop 1.8s ease-out infinite; }
.actor g.coinpop.c2 { animation-delay: .6s; }
.actor g.coinpop.c3 { animation-delay: 1.2s; }
@keyframes coinpop { 0% { transform: translateY(8px); opacity: 0; } 30% { opacity: 1; } 100% { transform: translateY(-12px); opacity: 0; } }
.actor g.breathe { transform-box: fill-box; transform-origin: 50% 100%; animation: breathe 2.6s ease-in-out infinite; }
@keyframes breathe { 50% { transform: scale(1.04, 1.1); } }
.actor g.zzz { animation: zzz 2.6s ease-out infinite; }
@keyframes zzz { from { transform: translate(0, 4px); opacity: 0; } 40% { opacity: 1; } to { transform: translate(-6px, -8px); opacity: 0; } }

/* Whole sprites that move around the scene */
.actor.float { animation: float-up 4s ease-in-out infinite alternate; }
@keyframes float-up { to { transform: translateY(-10px); } }
.actor.walk { animation: walk 22s linear infinite; }
@keyframes walk {
  0% { left: 4%; transform: scaleX(1); }
  49.9% { left: 86%; transform: scaleX(1); }
  50% { left: 86%; transform: scaleX(-1); }
  100% { left: 4%; transform: scaleX(-1); }
}
.actor.run { animation: run 7s linear infinite; animation-delay: -2s; }
@keyframes run { 0% { left: -12%; } 70% { left: 108%; } 100% { left: 108%; } }
.actor.run svg { animation: bob .15s ease-in-out infinite alternate; }
.actor.carry { animation: carry 9s linear infinite; }
.actor.carry.second { animation-delay: -4.5s; }
@keyframes carry {
  0% { left: 30%; opacity: 0; }
  8% { opacity: 1; }
  88% { opacity: 1; }
  100% { left: 78%; opacity: 0; }
}
.actor.drive { animation: drive 28s linear infinite; animation-delay: -6s; }
@keyframes drive { 0% { left: 104%; } 100% { left: -24%; } }
.keep-dragon { width: 48px; left: 6%; bottom: 190px; animation: circle 9s linear infinite; }
@keyframes circle {
  0%   { transform: translate(0, 0) scaleX(1); }
  25%  { transform: translate(60px, -30px) scaleX(1); }
  49.9% { transform: translate(120px, 0) scaleX(1); }
  50%  { transform: translate(120px, 0) scaleX(-1); }
  75%  { transform: translate(60px, 24px) scaleX(-1); }
  100% { transform: translate(0, 0) scaleX(-1); }
}

/* Upgrade rows with a small picture */
.upgrade { display: flex; align-items: center; gap: 10px; }
.u-text { flex: 1; min-width: 0; }
.u-icon { width: 44px; height: 44px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; background: #e8f4ff; border: 2px solid var(--ink); overflow: hidden; }
.u-icon svg { width: 100%; height: 100%; }
.upgrade.owned { background: #e6f3dc; opacity: 1; }
.upgrade.owned .u-cost { color: var(--good); }
.u-locked { padding: 8px 12px; border: 3px dashed var(--muted); color: var(--muted); text-align: center; }

@media (max-width: 800px) {
  .scene { height: 340px; }
  .scene .coin { width: 140px; height: 140px; font-size: 20px; }
  .tool { width: 48px; height: 48px; right: -44px; }
  .keep-dragon { bottom: 150px; }
}
@media (max-width: 800px) {
  .actor { scale: .78; transform-origin: 50% 100%; }
}

/* ================= Quest board ================= */

.quest { border-left-width: 10px; }
.quest.tier-short     { border-left-color: #d9d3c4; }
.quest.tier-medium    { border-left-color: #7cc860; }
.quest.tier-long      { border-left-color: #4a9be0; }
.quest.tier-epic      { border-left-color: #9a62dc; }
.quest.tier-legendary { border-left-color: #f39234; }
.q-buttons { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.skip { margin-top: 0; font-size: 17px; color: var(--muted); }
.quest.new-quest { animation: newquest .6s ease-out; }
@keyframes newquest { 0% { transform: translateX(-30px); opacity: 0; background: var(--gold-light); } 100% { transform: none; opacity: 1; } }

/* Hover tip, for example on attribute icons */
.tip {
  position: fixed; z-index: 2000; max-width: 240px;
  padding: 6px 10px; background: var(--paper); color: var(--ink);
  font-size: 18px; line-height: 1.1; pointer-events: none;
}
.a-icon[data-tip] { cursor: help; }

/* Black Market: pay for new deals */
.reroll { display: block; margin: 0 auto 14px; }
.offer.new-offer { animation: newquest .6s ease-out; }
