.ppg {
  --ppg-ink: #322018;
  --ppg-green: #126454;
  max-width: 920px;
  margin: 1rem auto;
  padding: clamp(14px, 4vw, 36px);
  color: var(--ppg-ink);
  background:
    radial-gradient(ellipse at 19% 0%, #fff0bba8, transparent 59%),
    radial-gradient(ellipse at 86% 110%, #60321955, transparent 65%),
    #b67b4e url("bois-bureau.jpg") center / cover;
  border: 1px solid #784423;
  box-shadow: inset 0 3px 4px #ffe7ba, inset 0 -7px 10px #71422160, 0 8px 18px #4c2d2345;
  border-radius: 26px;
  font-family: system-ui, sans-serif;
  box-sizing: border-box;
}
.ppg [hidden] { display: none !important; }
.ppg header p { margin: 0 0 4px; color: #4e2e1b; font-size: .9rem; font-weight: 650; }
.ppg h2 { margin: 0 0 18px; color: var(--ppg-ink); font-size: clamp(1.8rem, 5vw, 3rem); line-height: 1.05; }
.ppg-controls, .ppg-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.ppg label { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; font-weight: 650; }
.ppg button, .ppg select {
  min-height: 44px;
  padding: 8px 14px;
  border: 1px solid #91aca4;
  border-radius: 12px;
  background: #fff;
  color: var(--ppg-ink);
  font: inherit;
  line-height: 1.2;
}
.ppg button { cursor: pointer; font-weight: 700; }
.ppg :focus-visible { outline: 3px solid #a05000; outline-offset: 2px; }
.ppg-play {
  display: grid;
  grid-template-columns: minmax(100px, 1fr) minmax(0, 2fr);
  gap: clamp(12px, 3vw, 28px);
  align-items: start;
  margin-top: 18px;
}
.ppg-stack {
  position: relative;
  isolation: isolate;
  width: min(90%, 224px);
  aspect-ratio: 1;
  margin: 17px auto 11px;
}
.ppg-stack img, .ppg-stack-sheets span {
  position: absolute;
  inset: 0;
  box-sizing: border-box;
  width: 100%;
  height: 100%;
  border: 1px solid #ccab82;
  border-radius: 9%;
  background: #fff9ed;
  box-shadow: 1px 3px 0 #d5ba99, 2px 5px 7px #522a2657;
  transform: translateY(calc(-1 * var(--lift, 0px))) rotate(var(--tilt, 0deg));
}
.ppg-stack img { display: block; object-fit: contain; padding: 4%; transition: transform 230ms ease-out; }
.ppg-count { text-align: center; font-weight: 650; margin: 8px 0 0; }
.ppg-work { min-width: 0; text-align: center; }
.ppg-word { display: flex; justify-content: center; flex-wrap: wrap; gap: 4px; }
.ppg-word span { min-width: 1.3em; border-radius: 7px; background: #f1f4f2; font-size: clamp(1.15rem, 4vw, 1.8rem); font-weight: 800; }
.ppg-word .current { background: #ffd889; }
.ppg-word .done { background: #c9eddb; color: #125041; }
.ppg-status { margin: 8px 0; min-height: 2.6em; line-height: 1.3; }
.ppg-slate {
  box-sizing: border-box;
  touch-action: none;
  display: flex;
  width: min(100%, 310px);
  aspect-ratio: 210 / 297;
  margin: auto;
  padding: clamp(20px, 4vw, 33px);
  border: 2px solid #78421d;
  border-radius: 15% / 11%;
  background:
    radial-gradient(ellipse at 25% 0%, #fff0bfad, transparent 58%),
    linear-gradient(147deg, #fff2c536, transparent 44%, #51260d79),
    #cc9d65 url("bois-ardoise.jpg") center / cover;
  box-shadow: inset 0 5px 5px #fff0bfaa, inset 3px 0 5px #f4bd7b,
    inset -5px -7px 6px #62321788, 0 8px 0 #783e20, 3px 14px 17px #522b1f73;
}
.ppg-slate svg {
  display: block;
  width: 100%;
  height: 100%;
  min-width: 0;
  box-sizing: border-box;
  border: 2px solid #492719;
  border-radius: 11% / 8%;
  background:
    radial-gradient(ellipse at 22% 15%, #ffffff13, transparent 63%),
    repeating-linear-gradient(125deg, transparent 0 6px, #ffffff0a 7px, transparent 8px 13px) 0 0 / 100% 100%,
    linear-gradient(155deg, #343a3c, #17191b 80%);
  background-blend-mode: normal, overlay, normal;
  box-shadow: inset 0 4px 11px #000d, 0 2px 2px #ffdf9fbb;
  touch-action: none;
  user-select: none;
  cursor: crosshair;
}
.ppg-guide { fill: none; stroke: #d1d5d7; stroke-width: 3; stroke-dasharray: .1 7; stroke-linecap: round; }
.ppg-ink { fill: none; stroke: #fff6e0; stroke-width: 13; stroke-opacity: .94; stroke-linecap: round; stroke-linejoin: round; }
.ppg-arrow { fill: none; stroke: #8af3c4; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; pointer-events: none; }
.ppg-marker { fill: #31b677; stroke: #fff; stroke-width: 1.5; }
.ppg-actions { justify-content: center; margin-top: 10px; }

.ppg-result { margin: 22px auto 0; width: min(100%, 420px); }
.ppg-result p { margin: 0 0 5px; font-size: .95rem; font-weight: 700; }
.ppg-written {
  display: flex;
  justify-content: center;
  box-sizing: border-box;
  min-height: 76px;
  padding: 16px 7px 21px 21px;
  overflow: hidden;
  border: 1px solid #d5c6a9;
  border-radius: 3px 9px 4px 3px;
  background:
    linear-gradient(to right, transparent 14px, #d46d87 14px 15px, transparent 15px),
    repeating-linear-gradient(to bottom, #606da8 0 1px, transparent 1px 36px),
    repeating-linear-gradient(to bottom, #aebce1 0 1px, transparent 1px 9px),
    repeating-linear-gradient(to right, #aebce1 0 1px, transparent 1px 36px),
    #fffdf4;
  background-position: 0 0, 0 16px, 0 7px, 21px 0, 0 0;
  box-shadow: 1px 3px 5px #57352355;
}
.ppg-written span {
  width: 36px;
  flex: 0 1 36px;
  min-width: 0;
  height: 36px;
  color: #253f78;
  font-size: clamp(29px, 6vw, 38px);
  font-weight: 750;
  line-height: 36px;
  box-sizing: border-box;
}
.ppg-written span:empty::after {
  content: '';
  display: block;
  width: 10px;
  margin: 33px auto 0;
  border-top: 1px dashed #8489a6;
}
.ppg-stars {
  min-height: 1.5em;
  display: flex;
  justify-content: center;
  gap: 4px;
  color: #3e2719;
  font-family: system-ui, sans-serif;
  font-size: clamp(1.75rem, 5vw, 2.6rem);
  line-height: 1.2;
}
.ppg-stars .ppg-star-earned { color: #ffdf67; text-shadow: 0 1px 2px #54340a, 0 2px 0 #6a4316; animation: ppg-pop 420ms ease-out both; }
.ppg-finale {
  position: relative;
  overflow: hidden;
  margin-top: 18px;
  padding: clamp(20px, 5vw, 42px);
  text-align: center;
  background: white;
  border-radius: 18px;
}
.ppg-finale h3 { position: relative; margin: 0; font-size: clamp(1.6rem, 6vw, 3rem); }
.ppg-finale h4 { margin: 10px 0 4px; font-size: 1.15rem; }
.ppg-final-stars {
  position: relative;
  margin: 4px 0 0;
  color: #a65b00;
  font-size: clamp(1.8rem, 8vw, 3.5rem);
  letter-spacing: .06em;
  animation: ppg-pop 650ms ease-out both;
}
.ppg-score { margin: 0 0 12px; }
.ppg-palmares {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 7px;
  list-style: none;
  padding: 0;
  margin: 0 0 16px;
}
.ppg-palmares li { padding: 5px 10px; border-radius: 8px; background: #edf7ef; font-weight: 750; }
.ppg button.ppg-replay { background: var(--ppg-green); color: white; position: relative; }
.ppg-confetti { position: absolute; inset: 0; pointer-events: none; }
.ppg-confetti span {
  position: absolute;
  left: var(--x);
  top: -12px;
  width: 8px;
  height: 12px;
  border-radius: 2px;
  background: #ffc354;
  animation: ppg-confetti 1300ms var(--delay) ease-out both;
}
.ppg-confetti span:nth-child(3n+1) { background: #53bb94; }
.ppg-confetti span:nth-child(3n+2) { background: #ee8db4; }
@keyframes ppg-pop {
  0% { transform: scale(.65); opacity: 0; }
  60% { transform: scale(1.16); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}
@keyframes ppg-confetti {
  from { transform: translate(0, 0) rotate(0); opacity: 1; }
  to { transform: translate(var(--drift), 210px) rotate(345deg); opacity: 0; }
}
@media (max-width: 570px) {
  .ppg-play { grid-template-columns: minmax(0, 1fr); }
  .ppg-card { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; column-gap: 7px; }
  .ppg-stack { grid-row: 1; grid-column: 2; width: clamp(100px, 28vw, 140px); margin: 14px auto 4px; }
  .ppg-card .ppg-stars { grid-row: 2; grid-column: 1 / -1; }
  .ppg-card .ppg-count { grid-row: 1; grid-column: 3; margin: 0; font-size: .85rem; }
  .ppg-slate { width: min(100%, 235px); }
}
@media (prefers-reduced-motion: reduce) {
  .ppg-stars .ppg-star-earned, .ppg-final-stars { animation: none; }
  .ppg-stack img { transition: none; }
  .ppg-confetti { display: none; }
}
