:root {
  --bg: #140e09;
  --bg-2: #2a1a10;
  --felt: #3b2416;
  --panel: #1c130d;
  --card: #2a1c12;
  --line: #4d3824;
  --cream: #f6efe4;
  --muted: #cbbba8;
  --gold: #f0c14b;
  --gold-2: #ffe7a8;
  --ink: #2a1608;
  --shadow: rgba(0, 0, 0, 0.45);
  color-scheme: dark;
  font-family: "Nunito", "Avenir Next", "Segoe UI", sans-serif;
  color: var(--cream);
  background: var(--bg);
}

* { box-sizing: border-box; }

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

body {
  height: 100dvh;
  overflow: hidden;
  background:
    radial-gradient(900px 520px at 30% 20%, rgba(232, 176, 74, 0.12), transparent 60%),
    radial-gradient(700px 500px at 80% 100%, rgba(120, 42, 28, 0.35), transparent 55%),
    var(--bg);
}

button, input { font: inherit; color: inherit; }

.app {
  height: 100dvh;
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
}

.top {
  display: grid;
  grid-template-columns: minmax(140px, 1fr) auto minmax(140px, 1fr);
  gap: 16px;
  align-items: center;
  padding: 18px 22px 8px;
}

.brand h1 {
  margin: 0;
  font-family: "Fraunces", Georgia, serif;
  font-weight: 700;
  font-size: clamp(1.8rem, 3vw, 2.6rem);
  letter-spacing: -0.03em;
  line-height: 0.95;
}

.eyebrow {
  margin: 0 0 2px;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 0.68rem;
  font-weight: 800;
  color: var(--gold);
}

.stats { text-align: center; }

.doge {
  margin: 0;
  font-family: "Fraunces", Georgia, serif;
  font-size: clamp(2.2rem, 5vw, 3.6rem);
  font-weight: 700;
  letter-spacing: -0.04em;
  line-height: 0.9;
  color: var(--gold-2);
}

.unit {
  font-family: "Nunito", sans-serif;
  font-size: 0.42em;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--gold);
  font-weight: 800;
}

.sub {
  margin: 6px 0 0;
  color: var(--muted);
  font-weight: 700;
  font-size: 0.95rem;
}

.tools {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.tools button,
.qty {
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 12px;
  font-weight: 800;
  font-size: 0.85rem;
  cursor: pointer;
}

.tools button:hover,
.qty:hover { border-color: var(--gold); }

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(320px, 0.85fr);
  min-height: 0;
}

.stage {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 8px 20px 28px;
  gap: 8px;
}

.felt {
  position: relative;
  width: min(520px, 100%);
  display: grid;
  place-items: center;
  padding: 12px 0 4px;
}

.felt::before {
  content: "";
  position: absolute;
  left: 8%;
  right: 8%;
  bottom: 8%;
  height: 46px;
  background: radial-gradient(ellipse at center, rgba(0, 0, 0, 0.45), transparent 70%);
  pointer-events: none;
}

.coin-wrap {
  position: relative;
  width: min(420px, 70vh, 78vw);
  height: min(420px, 70vh, 78vw);
}

.coin-btn {
  width: 100%;
  height: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  border-radius: 50%;
  filter: drop-shadow(0 16px 14px var(--shadow));
}

.coin-btn img {
  width: 100%;
  height: 100%;
  display: block;
  user-select: none;
  -webkit-user-drag: none;
  transition: transform 90ms ease;
}

.coin-btn:hover img { transform: scale(1.02) rotate(-0.4deg); }
.coin-btn:active img,
.coin-btn.boop img { transform: scale(0.95) rotate(-1.6deg); }
.coin-btn:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 6px;
}

.glint {
  position: absolute;
  inset: 7%;
  border-radius: 50%;
  overflow: hidden;
  pointer-events: none;
}

.coin-wrap.shining .glint::after {
  content: "";
  position: absolute;
  inset: -20%;
  background: linear-gradient(115deg, transparent 36%, rgba(255, 248, 220, 0.55) 48%, transparent 58%);
  animation: sweep 0.7s ease;
}

@keyframes sweep {
  from { transform: translateX(-40%); }
  to { transform: translateX(40%); }
}

.hint {
  margin: 0;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-size: 0.78rem;
  color: var(--gold-2);
  animation: bob 1.4s ease-in-out infinite;
}

.floaters {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: visible;
}

.floater {
  position: absolute;
  transform: translate(-50%, -20%);
  font-family: "Fraunces", Georgia, serif;
  font-weight: 700;
  color: var(--gold-2);
  text-shadow: 0 2px 0 #3a2208;
  animation: rise 800ms ease-out forwards;
  white-space: nowrap;
}

.floater.player { font-size: 1.7rem; }

@keyframes rise {
  to { transform: translate(-50%, -86px); opacity: 0; }
}

.spark {
  position: absolute;
  width: 7px;
  height: 7px;
  margin: -3px 0 0 -3px;
  border-radius: 50%;
  background: var(--gold-2);
  animation: spark 520ms ease-out forwards;
}

@keyframes spark {
  to {
    transform: rotate(var(--a)) translateX(var(--r));
    opacity: 0;
  }
}

.crew-block {
  width: min(560px, 100%);
  text-align: center;
}

.crew-label {
  margin: 0;
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

.crew-empty {
  margin: 8px 0 0;
  color: var(--muted);
}

.crew {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 2px 4px;
  min-height: 0;
}

.pal {
  position: relative;
  margin: 0;
  width: 74px;
}

.pal img {
  width: 74px;
  height: 74px;
  object-fit: contain;
  display: block;
  animation: idle 2.6s ease-in-out infinite;
  animation-delay: var(--bob, 0s);
}

.pal img.tap { animation: hop 0.42s ease; }

.more {
  position: absolute;
  right: 0;
  bottom: 6px;
  background: var(--gold);
  color: var(--ink);
  font-size: 0.68rem;
  font-weight: 800;
  border-radius: 999px;
  padding: 1px 6px;
}

@keyframes idle {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-5px); }
}

@keyframes bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-3px); }
}

@keyframes hop {
  0% { transform: translateY(0) scale(1, 1); }
  40% { transform: translateY(-22px) scale(1.05, 0.94); }
  70% { transform: translateY(-2px) scale(0.97, 1.04); }
  100% { transform: translateY(0) scale(1, 1); }
}

.shop {
  margin: 8px 16px 16px 0;
  background: rgba(28, 19, 13, 0.92);
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 16px;
  overflow: auto;
  min-height: 0;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25);
}

.shop-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-end;
  margin-bottom: 12px;
}

.shop-head h2 {
  margin: 0;
  font-family: "Fraunces", Georgia, serif;
  font-size: 1.7rem;
  font-weight: 700;
}

.shop-head p {
  margin: 4px 0 0;
  color: var(--muted);
  font-weight: 700;
  font-size: 0.92rem;
  max-width: 36ch;
}

.qty-row { display: flex; gap: 6px; }

.qty.on {
  background: var(--gold);
  color: var(--ink);
  border-color: var(--gold);
}

.shop-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.card {
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr) auto;
  grid-template-rows: auto auto;
  column-gap: 12px;
  row-gap: 8px;
  align-items: center;
  width: 100%;
  text-align: left;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 10px 12px 10px;
  cursor: pointer;
}

.card:hover:not(:disabled) { border-color: #8a6a3e; }
.card:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }

.card.afford {
  border-color: #c4963a;
  background:
    linear-gradient(180deg, rgba(240, 193, 75, 0.1), transparent 42%),
    var(--card);
}

.card:disabled {
  cursor: not-allowed;
  opacity: 0.72;
}

.card.bought { animation: pop 280ms ease; }

@keyframes pop {
  40% { transform: scale(1.015); }
}

.portrait {
  position: relative;
  width: 76px;
  height: 76px;
  grid-row: 1;
}

.portrait img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.count {
  position: absolute;
  right: -4px;
  bottom: -2px;
  min-width: 1.5em;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--gold);
  color: var(--ink);
  font-size: 0.75rem;
  font-weight: 800;
  text-align: center;
}

.count.zero { background: #4a3824; color: var(--muted); }

.info { min-width: 0; }

.name-row {
  display: flex;
  gap: 8px;
  align-items: baseline;
}

.name {
  font-weight: 800;
  font-size: 1.05rem;
}

.tag {
  color: var(--gold);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.blurb, .rates {
  display: block;
  color: var(--muted);
  font-weight: 700;
  font-size: 0.86rem;
  line-height: 1.3;
}

.rates { color: #efd7a4; margin-top: 2px; }

.price {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  min-width: 4.5rem;
}

.cost {
  font-family: "Fraunces", Georgia, serif;
  font-weight: 700;
  font-size: 1.25rem;
  color: var(--gold-2);
}

.mult {
  font-size: 0.75rem;
  font-weight: 800;
  color: var(--muted);
}

.meter {
  grid-column: 1 / -1;
  height: 4px;
  border-radius: 99px;
  background: #120c08;
  overflow: hidden;
}

.meter-fill {
  display: block;
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #a8742a, var(--gold-2));
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 20px;
  transform: translateX(-50%) translateY(8px);
  max-width: min(520px, calc(100% - 24px));
  background: #3a2716;
  color: var(--cream);
  border: 1px solid var(--gold);
  border-radius: 16px;
  padding: 12px 16px;
  font-weight: 800;
  text-align: center;
  box-shadow: 0 12px 30px var(--shadow);
  opacity: 0;
  transition: opacity 220ms ease, transform 220ms ease;
}

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

@media (max-width: 860px) {
  .top {
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "brand tools"
      "stats stats";
  }
  .brand { grid-area: brand; }
  .tools { grid-area: tools; }
  .stats { grid-area: stats; text-align: left; }
  .layout {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(0, 1fr);
    overflow: hidden;
  }
  .shop { margin: 0 12px 12px; overflow: auto; }
  .stage { justify-content: flex-start; padding: 0 12px 4px; }
  .coin-wrap {
    width: min(230px, 56vw);
    height: min(230px, 56vw);
  }
}

@media (prefers-reduced-motion: reduce) {
  .hint, .pal img, .floater, .spark, .coin-wrap.shining .glint::after, .card.bought {
    animation: none !important;
  }
}
