/* Peel Loop — banana clicker. Scoped under .pl so it can live inside any page. */

#game-root {
  width: 100%;
}

.pl {
  --pl-ink: #24301a;
  --pl-muted: #7c7a63;
  --pl-line: #e7e0c8;
  --pl-paper: #fffdf4;
  --pl-yellow: #ffd21f;
  --pl-green: #2f4a24;
  position: relative;
  max-width: 960px;
  margin: 0 auto;
  color: var(--pl-ink);
  font-family: ui-rounded, "Nunito", "Segoe UI", system-ui, -apple-system, sans-serif;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.pl *,
.pl *::before,
.pl *::after {
  box-sizing: border-box;
}

.pl button {
  font: inherit;
  color: inherit;
  cursor: pointer;
  border: 0;
  background: none;
  touch-action: manipulation;
}

.pl button:focus-visible {
  outline: 3px solid #2f6df6;
  outline-offset: 3px;
}

/* ---------- HUD ---------- */
.pl-hud {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  padding: 10px 12px;
  background: var(--pl-paper);
  border: 1px solid var(--pl-line);
  border-radius: 16px;
  box-shadow: 0 8px 24px rgba(70, 58, 20, 0.08);
}

.pl-stat {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 84px;
  padding: 4px 10px;
  border-left: 1px solid var(--pl-line);
}

.pl-stat:first-child {
  border-left: 0;
  padding-left: 2px;
}

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

.pl-stat strong {
  font-size: 21px;
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}

.pl-hud .pl-spacer {
  flex: 1 1 auto;
}

.pl-icon-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid var(--pl-line);
  font-size: 17px;
  display: grid;
  place-items: center;
  background: #fff;
}

.pl-icon-btn[aria-pressed="true"] {
  background: #f1efe2;
  opacity: 0.65;
}

/* ---------- News ---------- */
.pl-news {
  display: flex;
  align-items: stretch;
  margin: 10px 0;
  background: #1f2a17;
  border-radius: 10px;
  overflow: hidden;
  color: #f5f1da;
  min-height: 32px;
}

.pl-news b {
  display: grid;
  place-items: center;
  padding: 0 10px;
  background: var(--pl-yellow);
  color: #1f2a17;
  font-size: 10px;
  letter-spacing: 0.16em;
  font-weight: 900;
}

.pl-news-track {
  flex: 1;
  display: flex;
  align-items: center;
  padding: 0 12px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.01em;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.pl-news-track.is-flash {
  animation: plNewsFlash 0.5s ease;
}

@keyframes plNewsFlash {
  0% { opacity: 0; transform: translateY(8px); }
  100% { opacity: 1; transform: translateY(0); }
}

/* ---------- Stage ---------- */
.pl-stage {
  position: relative;
  height: clamp(320px, 50vh, 540px);
  border-radius: 22px;
  overflow: hidden;
  background: linear-gradient(160deg, var(--sky-a, #f2f8e2), var(--sky-b, #d9efb0));
  transition: background 1.1s ease;
  border: 1px solid rgba(90, 74, 20, 0.14);
  box-shadow: inset 0 -40px 80px rgba(90, 70, 10, 0.12), 0 18px 40px rgba(70, 58, 20, 0.12);
  isolation: isolate;
}

.pl-stage::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(120% 80% at 50% 108%, rgba(255, 255, 255, 0.55), transparent 60%);
  z-index: 1;
}

.pl.is-cosmic .pl-stage::after {
  background:
    radial-gradient(90% 70% at 50% 50%, transparent 38%, rgba(3, 2, 10, 0.75) 100%),
    radial-gradient(120% 80% at 50% 108%, rgba(120, 80, 255, 0.25), transparent 60%);
}

.pl-sky,
.pl-stars,
.pl-decor {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.pl-sky {
  background:
    radial-gradient(60% 45% at 22% 18%, rgba(255, 255, 255, 0.65), transparent 70%),
    radial-gradient(40% 30% at 80% 12%, rgba(255, 255, 255, 0.45), transparent 70%);
  z-index: 0;
}

.pl-stars {
  opacity: 0;
  transition: opacity 1.2s ease;
  z-index: 0;
}

.pl.is-stars .pl-stars {
  opacity: 1;
}

.pl-stars i {
  position: absolute;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 6px rgba(255, 255, 255, 0.9);
  animation: plTwinkle 3.4s ease-in-out infinite;
}

@keyframes plTwinkle {
  0%, 100% { opacity: 0.25; transform: scale(0.7); }
  50% { opacity: 1; transform: scale(1.15); }
}

.pl-decor {
  z-index: 0;
}

.pl-decor span {
  position: absolute;
  font-size: clamp(26px, 5vw, 44px);
  opacity: 0.42;
  filter: saturate(0.9);
  transition: opacity 0.8s ease, transform 0.8s ease;
}

.pl-decor span.is-hidden {
  opacity: 0;
  transform: translateY(10px) scale(0.8);
}

/* banana */
.pl-banana {
  position: absolute;
  left: 50%;
  top: 52%;
  width: min(56%, 300px);
  aspect-ratio: 1;
  transform: translate(-50%, -50%) rotate(-7deg) scale(var(--pl-scale, 1));
  transform-origin: 50% 55%;
  transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1), filter 0.4s ease;
  z-index: 3;
  border-radius: 50%;
  filter: drop-shadow(0 22px 22px rgba(80, 56, 0, 0.28));
}

.pl-banana svg {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.pl-banana.is-tapped {
  transform: translate(-50%, -50%) rotate(-7deg) scale(calc(var(--pl-scale, 1) * 0.93));
  transition-duration: 0.06s;
}

.pl-banana.is-frenzy {
  filter: drop-shadow(0 0 26px rgba(255, 210, 31, 0.95)) drop-shadow(0 22px 22px rgba(80, 56, 0, 0.28));
}

.pl-face {
  transform-origin: 134px 150px;
  animation: plBlink 5.2s infinite;
}

@keyframes plBlink {
  0%, 92%, 100% { transform: scaleY(1); }
  95% { transform: scaleY(0.12); }
}

.pl-hint {
  position: absolute;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  z-index: 4;
  padding: 7px 14px;
  border-radius: 999px;
  background: rgba(31, 42, 23, 0.82);
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.04em;
  animation: plHint 1.8s ease-in-out infinite;
  pointer-events: none;
  white-space: nowrap;
}

.pl-hint.is-hidden {
  display: none;
}

@keyframes plHint {
  0%, 100% { transform: translate(-50%, 0); opacity: 0.95; }
  50% { transform: translate(-50%, -6px); opacity: 0.7; }
}

/* floating +N */
.pl-float {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 6;
  overflow: hidden;
}

.pl-float span {
  position: absolute;
  font-weight: 900;
  font-size: clamp(18px, 3.4vw, 26px);
  color: #3f3300;
  text-shadow: 0 2px 0 #ffe56b, 0 0 14px rgba(255, 240, 160, 0.9);
  animation: plRise 0.85s cubic-bezier(0.22, 0.9, 0.3, 1) forwards;
  will-change: transform, opacity;
}

.pl-float span.is-big {
  color: #fff;
  text-shadow: 0 2px 0 #b57b00, 0 0 16px rgba(255, 190, 40, 0.9);
}

@keyframes plRise {
  0% { transform: translate(-50%, 0) scale(0.7); opacity: 0; }
  18% { opacity: 1; transform: translate(-50%, -14px) scale(1.08); }
  100% { transform: translate(calc(-50% + var(--dx, 0px)), -92px) scale(1); opacity: 0; }
}

.pl-ripple {
  position: absolute;
  width: 18px;
  height: 18px;
  margin: -9px 0 0 -9px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.9);
  pointer-events: none;
  z-index: 5;
  animation: plRipple 0.55s ease-out forwards;
}

@keyframes plRipple {
  0% { transform: scale(0.4); opacity: 0.9; }
  100% { transform: scale(4.2); opacity: 0; }
}

/* attackers */
.pl-attack {
  position: absolute;
  inset: 0;
  z-index: 5;
  pointer-events: none;
}

.pl-attacker {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  width: 74px;
  padding: 6px 4px 5px;
  border-radius: 14px;
  background: rgba(255, 253, 244, 0.94);
  border: 2px solid #e8503a;
  box-shadow: 0 6px 0 rgba(150, 40, 20, 0.18);
  pointer-events: auto;
  animation: plWobble 1.4s ease-in-out infinite;
  z-index: 2;
}

.pl-attacker span {
  font-size: 30px;
  line-height: 1;
}

.pl-attacker em {
  font-style: normal;
  font-size: 9px;
  font-weight: 900;
  letter-spacing: 0.04em;
  color: #8a2c1c;
  text-transform: uppercase;
  white-space: nowrap;
}

.pl-attacker:active {
  transform: scale(0.94);
}

@keyframes plWobble {
  0%, 100% { transform: rotate(-4deg) translateY(0); }
  50% { transform: rotate(4deg) translateY(-5px); }
}

/* banner */
.pl-banner {
  position: absolute;
  left: 50%;
  top: 34%;
  transform: translate(-50%, -50%);
  z-index: 8;
  pointer-events: none;
  text-align: center;
  opacity: 0;
}

.pl-banner.is-on {
  animation: plBanner 1.7s cubic-bezier(0.2, 0.9, 0.2, 1) forwards;
}

.pl-banner strong {
  display: block;
  font-size: clamp(26px, 5.4vw, 48px);
  font-weight: 900;
  letter-spacing: -0.02em;
  color: #fff;
  text-transform: uppercase;
  text-shadow: 0 4px 0 #6d4a00, 0 0 30px rgba(255, 210, 31, 0.85);
  white-space: nowrap;
}

.pl-banner small {
  display: block;
  margin-top: 4px;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: #ffe98a;
  text-shadow: 0 2px 0 #3c2a00;
}

@keyframes plBanner {
  0% { opacity: 0; transform: translate(-50%, -40%) scale(0.7); }
  15% { opacity: 1; transform: translate(-50%, -50%) scale(1.06); }
  70% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -58%) scale(1.02); }
}

/* confetti */
.pl-confetti {
  position: absolute;
  width: 10px;
  height: 14px;
  border-radius: 2px;
  z-index: 7;
  pointer-events: none;
  animation: plConfetti 1.1s ease-out forwards;
}

@keyframes plConfetti {
  0% { transform: translate(0, 0) rotate(0); opacity: 1; }
  100% { transform: translate(var(--cx, 0px), var(--cy, 120px)) rotate(var(--cr, 180deg)); opacity: 0; }
}

/* ---------- Progress ---------- */
.pl-progress {
  margin-top: 12px;
  padding: 10px 12px 12px;
  background: var(--pl-paper);
  border: 1px solid var(--pl-line);
  border-radius: 14px;
}

.pl-progress-top {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--pl-muted);
  margin-bottom: 7px;
}

.pl-progress-top b {
  color: var(--pl-ink);
  letter-spacing: 0.02em;
}

.pl-bar {
  height: 12px;
  border-radius: 999px;
  background: #efe9d3;
  overflow: hidden;
  box-shadow: inset 0 2px 4px rgba(80, 60, 0, 0.08);
}

.pl-bar i {
  display: block;
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background: linear-gradient(90deg, #ffb800, #ffe45c 60%, #fff3a8);
  transition: width 0.25s ease;
  box-shadow: 0 0 12px rgba(255, 200, 20, 0.55);
}

/* ---------- Actions ---------- */
.pl-actions {
  display: grid;
  grid-template-columns: 1.2fr 1fr 1fr;
  gap: 8px;
  margin-top: 10px;
}

.pl-actions button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 52px;
  padding: 8px 10px;
  border-radius: 14px;
  border: 1px solid var(--pl-line);
  background: var(--pl-paper);
  font-weight: 900;
  font-size: 14px;
  box-shadow: 0 3px 0 rgba(80, 60, 0, 0.12);
  transition: transform 0.08s ease, background 0.2s ease;
}

.pl-actions button:active:not(:disabled) {
  transform: translateY(2px);
  box-shadow: 0 1px 0 rgba(80, 60, 0, 0.12);
}

.pl-actions button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  box-shadow: none;
}

#pl-shop-btn {
  background: #24301a;
  color: #fff8dd;
  border-color: #24301a;
}

#pl-frenzy-btn.is-active {
  background: #fff1a8;
  border-color: #e0a900;
  animation: plFrenzyPulse 0.7s ease-in-out infinite;
}

@keyframes plFrenzyPulse {
  0%, 100% { box-shadow: 0 3px 0 rgba(80, 60, 0, 0.12), 0 0 0 rgba(255, 210, 31, 0); }
  50% { box-shadow: 0 3px 0 rgba(80, 60, 0, 0.12), 0 0 22px rgba(255, 210, 31, 0.8); }
}

#pl-compost-btn.is-ready {
  background: #e9f5dc;
  border-color: #7fb35a;
}

.pl-frenzy-tag {
  display: inline-block;
  margin-left: 4px;
  padding: 1px 6px;
  border-radius: 999px;
  background: #ffd21f;
  color: #3a2b00;
  font-size: 10px;
  font-weight: 900;
  vertical-align: 1px;
}

/* ---------- Shop sheet ---------- */
.pl-sheet-wrap {
  position: absolute;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgba(20, 24, 14, 0.42);
  backdrop-filter: blur(2px);
  animation: plFade 0.2s ease;
}

.pl-sheet-wrap[hidden] {
  display: none;
}

@keyframes plFade {
  from { opacity: 0; }
  to { opacity: 1; }
}

.pl-sheet {
  width: 100%;
  max-height: 82%;
  overflow: auto;
  background: #fffdf4;
  border-radius: 22px 22px 0 0;
  padding: 14px 14px 18px;
  box-shadow: 0 -18px 50px rgba(20, 20, 0, 0.28);
  animation: plSheetUp 0.28s cubic-bezier(0.2, 0.9, 0.3, 1);
  overscroll-behavior: contain;
}

@keyframes plSheetUp {
  from { transform: translateY(40px); opacity: 0.6; }
  to { transform: translateY(0); opacity: 1; }
}

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

.pl-sheet-head b {
  font-size: 18px;
  letter-spacing: -0.01em;
}

.pl-sheet-head span {
  font-size: 11px;
  color: var(--pl-muted);
  font-weight: 700;
  margin-left: 8px;
}

.pl-sheet-close {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: #f0ecd9;
  font-size: 16px;
  display: grid;
  place-items: center;
}

.pl-shop-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.pl-up {
  display: grid;
  grid-template-columns: auto 1fr auto;
  grid-template-areas:
    "icon name cost"
    "icon desc cost";
  align-items: center;
  gap: 2px 8px;
  text-align: left;
  padding: 10px;
  border-radius: 13px;
  border: 1px solid var(--pl-line);
  background: #fff;
  transition: transform 0.08s ease, border-color 0.2s ease, background 0.2s ease;
}

.pl-up:active:not(:disabled) {
  transform: scale(0.985);
}

.pl-up:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.pl-up.is-affordable {
  border-color: #d9b21a;
  background: #fffbe8;
}

.pl-up .pl-up-icon {
  grid-area: icon;
  font-size: 24px;
  line-height: 1;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: #f7f3e2;
}

.pl-up .pl-up-name {
  grid-area: name;
  font-size: 13px;
  font-weight: 900;
  line-height: 1.2;
}

.pl-up .pl-up-desc {
  grid-area: desc;
  font-size: 10.5px;
  line-height: 1.3;
  color: var(--pl-muted);
  font-weight: 600;
}

.pl-up .pl-up-cost {
  grid-area: cost;
  font-size: 11px;
  font-weight: 900;
  color: #8a6a00;
  white-space: nowrap;
  text-align: right;
}

.pl-up .pl-up-lv {
  display: block;
  font-size: 9px;
  letter-spacing: 0.08em;
  color: var(--pl-muted);
  font-weight: 800;
  text-transform: uppercase;
}

.pl-shop-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px dashed #e2dcc6;
  font-size: 11px;
  color: var(--pl-muted);
  font-weight: 700;
}

.pl-reset {
  color: #b4432e;
  font-weight: 800;
  font-size: 11px;
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* ---------- Intro ---------- */
.pl-intro {
  position: absolute;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(18, 26, 12, 0.55);
  backdrop-filter: blur(5px);
  transition: opacity 0.35s ease, visibility 0.35s ease;
}

.pl-intro.is-hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.pl-intro-card {
  width: min(420px, 100%);
  padding: 24px 22px 20px;
  background: #fffdf4;
  border-radius: 22px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.3);
  text-align: center;
}

.pl-intro-card h2 {
  margin: 0;
  font-size: clamp(30px, 7vw, 42px);
  line-height: 1;
  letter-spacing: -0.03em;
  color: #24301a;
}

.pl-intro-card h2 em {
  font-style: normal;
  color: #d9a400;
}

.pl-intro-card p {
  margin: 10px 0 16px;
  font-size: 14px;
  line-height: 1.55;
  color: #5c5a45;
  font-weight: 600;
}

.pl-intro-card .pl-big-btn {
  width: 100%;
  min-height: 54px;
  border-radius: 14px;
  background: #24301a;
  color: #fff8dd;
  font-weight: 900;
  font-size: 16px;
  letter-spacing: 0.02em;
  box-shadow: 0 4px 0 #0f160a;
}

.pl-intro-card .pl-big-btn:active {
  transform: translateY(2px);
  box-shadow: 0 2px 0 #0f160a;
}

.pl-intro-card .pl-fine {
  margin: 12px 0 0;
  font-size: 10.5px;
  color: #9a967d;
  line-height: 1.45;
}

/* ---------- Toast ---------- */
.pl-toast {
  position: absolute;
  left: 50%;
  bottom: 92px;
  z-index: 60;
  transform: translate(-50%, 10px);
  max-width: calc(100% - 32px);
  padding: 9px 15px;
  border-radius: 999px;
  background: rgba(31, 42, 23, 0.94);
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.01em;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  white-space: nowrap;
}

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

/* ---------- Responsive ---------- */
@media (max-width: 640px) {
  .pl-stat {
    min-width: 66px;
    padding: 3px 7px;
  }

  .pl-stat strong {
    font-size: 17px;
  }

  .pl-stat:nth-child(3) {
    border-left: 0;
    padding-left: 2px;
  }

  .pl-hud {
    gap: 4px;
    padding: 8px 10px;
  }

  .pl-stage {
    height: clamp(300px, 46vh, 440px);
    border-radius: 18px;
  }

  .pl-banana {
    width: min(66%, 250px);
  }

  .pl-news {
    margin: 8px 0;
  }

  .pl-news-track {
    font-size: 11px;
  }

  .pl-actions button {
    min-height: 48px;
    font-size: 12.5px;
    gap: 5px;
    padding: 6px;
  }

  .pl-shop-list {
    grid-template-columns: 1fr;
  }

  .pl-sheet {
    max-height: 86%;
    padding: 12px 12px 16px;
  }

  .pl-toast {
    bottom: 84px;
    font-size: 11px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .pl-banana,
  .pl-attacker,
  .pl-face,
  .pl-hint,
  .pl-banner.is-on,
  .pl-float span,
  .pl-ripple,
  .pl-confetti {
    animation: none !important;
    transition: none !important;
  }
}

/* ---------- Face ---------- */
.pl-face {
  position: absolute;
  inset: 0;
  pointer-events: none;
  transform-origin: 50% 66%;
  animation: plBlink 5.2s infinite;
}

.pl-eye {
  position: absolute;
  top: 67.5%;
  width: 6.4%;
  aspect-ratio: 0.78;
  background: #2b2200;
  border-radius: 50%;
}

.pl-eye::after {
  content: "";
  position: absolute;
  left: 20%;
  top: 14%;
  width: 34%;
  height: 30%;
  background: #fff;
  border-radius: 50%;
}

.pl-eye:nth-of-type(1) {
  left: 44.5%;
}

.pl-eye:nth-of-type(2) {
  left: 54.2%;
}

.pl-mouth {
  position: absolute;
  left: 45%;
  top: 76%;
  width: 11%;
  height: 7%;
  border-bottom: 3px solid #2b2200;
  border-radius: 0 0 60% 60%;
}

/* ---------- Page integration ---------- */
.stage-card-game {
  padding: clamp(10px, 2vw, 18px);
  background: #10140b;
}

.stage-card-game #game-root {
  border-radius: 18px;
}

.stage-card-game .stage-bar {
  border-top-color: rgba(255, 255, 255, 0.12);
  padding-bottom: 2px;
}

.stage-card-game .stage-bar p {
  color: #a8a58e;
}

