/* Team Pupcorn - warm & cozy clicker
   Palette: cream backdrop, corn-yellow accents, warm brown ink. */
:root {
  --cream: #fff6e9;
  --cream-2: #fbe9cf;
  --panel: #fffdf8;
  --panel-2: #fdf3e2;
  --ink: #5a3d24;
  --ink-soft: #8a6b4d;
  --corn: #f5c542;
  --corn-deep: #e29a00;
  --corn-glow: #ffe6a3;
  --heart: #e8836b;
  --line: #efdcc0;
  --good: #7bbf6a;
  --radius: 18px;
  --shadow: 0 10px 24px rgba(120, 80, 30, 0.12);
  --shadow-sm: 0 4px 12px rgba(120, 80, 30, 0.1);
  --font: "Fredoka", "Baloo 2", "Nunito", ui-rounded, "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(1200px 600px at 15% -10%, var(--corn-glow) 0%, transparent 55%),
    radial-gradient(1000px 700px at 110% 10%, #ffd9c2 0%, transparent 50%),
    linear-gradient(160deg, var(--cream) 0%, var(--cream-2) 100%);
  min-height: 100%;
  display: flex;
  flex-direction: column;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

/* ---------- Top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding: 18px clamp(16px, 4vw, 40px);
}
.brand { display: flex; align-items: center; gap: 14px; }
.brand-logo { height: 48px; width: auto; max-width: 220px; object-fit: contain; display: block; filter: drop-shadow(0 3px 4px rgba(0,0,0,0.12)); }
.brand-text h1 {
  margin: 0;
  font-size: clamp(26px, 4vw, 38px);
  letter-spacing: 0.5px;
  color: var(--corn-deep);
  text-shadow: 0 2px 0 #fff;
}
.tagline { margin: 2px 0 0; color: var(--ink-soft); font-size: 14px; }
#dog-name { color: var(--ink); font-weight: 700; }

.bank {
  background: var(--panel);
  border: 2px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 22px;
  text-align: right;
  box-shadow: var(--shadow-sm);
  min-width: 200px;
}
.kernels { font-size: clamp(22px, 3.4vw, 30px); font-weight: 800; color: var(--ink); }
.kernels .unit { font-size: 0.6em; color: var(--ink-soft); font-weight: 700; }
.kps { font-size: 14px; color: var(--corn-deep); font-weight: 700; margin-top: 2px; }

/* ---------- Layout ---------- */
main {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 24px;
  padding: 8px clamp(16px, 4vw, 40px) 24px;
  align-items: start;
}
@media (max-width: 860px) {
  main { grid-template-columns: 1fr; }
}

/* ---------- Stage / pup ---------- */
.stage {
  position: relative;
  background: var(--panel);
  border: 2px solid var(--line);
  border-radius: 28px;
  box-shadow: var(--shadow);
  padding: clamp(20px, 4vw, 48px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
  overflow: hidden;
}
.stage::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(closest-side, var(--corn-glow) 0%, transparent 70%);
  opacity: 0.5;
  pointer-events: none;
}
.pup {
  position: relative;
  border: none;
  background: transparent;
  cursor: pointer;
  padding: 0;
  width: min(46vw, 360px);
  height: min(46vw, 360px);
  border-radius: 50%;
  display: grid;
  place-items: center;
  outline: none;
  transition: filter 0.15s ease;
}
.pup:focus-visible { box-shadow: 0 0 0 5px var(--corn); }
.pup:hover { filter: drop-shadow(0 8px 16px rgba(226,154,0,0.35)); }
/* The visual floats; the button hit area stays put so taps never miss. */
.pup-art { position: relative; width: 100%; height: 100%; will-change: transform; animation: bob 3.2s ease-in-out infinite; }
.pup-art svg, .pup-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
  filter: drop-shadow(0 8px 14px rgba(90,61,36,0.18));
}
.pup-img { background: var(--panel-2); }
/* Optional two-photo click reaction: layer pup-happy over pup-neutral. */
.pup-art .pup-happy { position: absolute; inset: 0; opacity: 0; transition: opacity 0.06s ease; }
.pup-art.show-happy .pup-neutral { opacity: 0; }
.pup-art.show-happy .pup-happy { opacity: 1; }

@keyframes bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}
@keyframes pop {
  0% { transform: scale(1); }
  30% { transform: scale(0.88) rotate(-2deg); }
  60% { transform: scale(1.07) rotate(1deg); }
  100% { transform: scale(1); }
}
.pup.pop { animation: pop 0.22s ease; }
@media (prefers-reduced-motion: reduce) {
  .pup-art { animation: none; }
  .pup.pop { animation: none; }
}

.click-hint { margin: 22px 0 0; font-size: 18px; font-weight: 700; color: var(--ink); }
.per-click { color: var(--corn-deep); }
.click-sub { margin: 4px 0 0; min-height: 18px; font-size: 14px; color: var(--ink-soft); }

/* Floating "+N" pops */
.float-layer { position: absolute; inset: 0; pointer-events: none; }
.float {
  position: absolute;
  transform: translate(-50%, -50%);
  font-weight: 800;
  font-size: 20px;
  color: var(--corn-deep);
  text-shadow: 0 2px 0 #fff;
  animation: floatup 0.9s ease forwards;
}
.float.word { color: var(--heart); font-size: 18px; }
@keyframes floatup {
  0% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -170%) scale(1.15); }
}

/* ---------- Shop ---------- */
.shop {
  background: var(--panel);
  border: 2px solid var(--line);
  border-radius: 24px;
  box-shadow: var(--shadow);
  padding: 16px 16px 20px;
  position: sticky;
  top: 12px;
  max-height: calc(100vh - 24px);
  overflow-y: auto;
}
.shop-title {
  margin: 14px 4px 8px;
  font-size: 16px;
  color: var(--corn-deep);
  display: flex;
  align-items: baseline;
  justify-content: space-between;
}
.shop-title:first-child { margin-top: 0; }
.shop-hint { font-size: 11px; font-weight: 600; color: var(--ink-soft); }
.list { display: flex; flex-direction: column; gap: 8px; }

.item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  text-align: left;
  background: var(--panel-2);
  border: 2px solid var(--line);
  border-radius: 14px;
  padding: 10px 12px;
  cursor: not-allowed;
  font-family: inherit;
  color: var(--ink);
  opacity: 0.6;
  transition: transform 0.08s ease, box-shadow 0.12s ease, opacity 0.12s ease;
}
.item.afford { opacity: 1; cursor: pointer; border-color: var(--corn); }
.item.afford:hover { transform: translateY(-2px); box-shadow: var(--shadow-sm); }
.item.afford:active { transform: translateY(0) scale(0.99); }
.item-icon { font-size: 28px; line-height: 1; width: 34px; text-align: center; }
.item-main { flex: 1; min-width: 0; }
.item-name { display: block; font-weight: 700; font-size: 15px; }
.item-flavor { display: block; font-size: 11.5px; color: var(--ink-soft); }
.item-right { text-align: right; white-space: nowrap; }
.item-cost { display: block; font-weight: 800; color: var(--corn-deep); font-size: 14px; }
.item-owned { display: block; font-size: 12px; color: var(--ink-soft); }
.item-sub { display: block; font-size: 11px; color: var(--good); font-weight: 700; }

/* ---------- Footer ---------- */
.footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 12px clamp(16px, 4vw, 40px) 22px;
  color: var(--ink-soft);
  font-size: 13px;
}
.footer-actions { display: flex; gap: 8px; }
.ghost-btn {
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  color: var(--ink-soft);
  background: var(--panel);
  border: 2px solid var(--line);
  border-radius: 12px;
  padding: 7px 14px;
  cursor: pointer;
  transition: transform 0.08s ease, border-color 0.12s ease, color 0.12s ease;
}
.ghost-btn:hover { transform: translateY(-1px); border-color: var(--corn); color: var(--ink); }
.ghost-btn.danger:hover { border-color: var(--heart); color: var(--heart); }
.save-status { min-width: 70px; color: var(--good); font-weight: 700; transition: opacity 0.4s ease; opacity: 0; }
.save-status.show { opacity: 1; }
.credit { opacity: 0.85; }

/* ---------- Modal ---------- */
.modal-root {
  position: fixed;
  inset: 0;
  background: rgba(90, 61, 36, 0.35);
  display: grid;
  place-items: center;
  z-index: 50;
  padding: 20px;
}
/* The class's display:grid would otherwise override the [hidden] attribute,
   leaving this overlay on top of the page swallowing every click. */
.modal-root[hidden] { display: none; }
.modal {
  background: var(--panel);
  border: 2px solid var(--line);
  border-radius: 20px;
  box-shadow: var(--shadow);
  padding: 24px;
  max-width: 380px;
  width: 100%;
  text-align: center;
}
.modal h3 { margin: 0 0 8px; color: var(--ink); }
.modal p { margin: 0 0 20px; color: var(--ink-soft); font-size: 14px; }
.modal-actions { display: flex; gap: 10px; justify-content: center; }
.btn {
  font-family: inherit;
  font-weight: 800;
  font-size: 14px;
  border-radius: 12px;
  padding: 10px 20px;
  cursor: pointer;
  border: 2px solid transparent;
}
.btn-primary { background: var(--corn); color: var(--ink); }
.btn-primary:hover { background: var(--corn-deep); color: #fff; }
.btn-secondary { background: var(--panel-2); color: var(--ink-soft); border-color: var(--line); }
.btn-secondary:hover { color: var(--ink); }
