/* Reusable pieces: pop-in animation, buttons, cards, badges and rows. */

/* ---------- Pop-in stagger ---------- */
.pop {
  animation: popIn 0.6s var(--bounce) backwards;
  animation-delay: calc(var(--d, 0) * 70ms + 60ms);
}
.pop:nth-child(even) { animation-name: popInAlt; }
@keyframes popIn {
  0% { opacity: 0; transform: translateY(40px) scale(0.5) rotate(-5deg); }
  100% { opacity: 1; transform: none; }
}
@keyframes popInAlt {
  0% { opacity: 0; transform: translateY(40px) scale(0.5) rotate(5deg); }
  100% { opacity: 1; transform: none; }
}

/* ---------- Buttons ---------- */
.btn {
  font: inherit;
  font-weight: 900;
  font-size: 18px;
  border: 4px solid var(--ink);
  border-radius: 999px;
  padding: 12px 22px;
  background: #fff;
  color: var(--ink);
  box-shadow: 0 6px 0 var(--ink);
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease, filter 0.2s, opacity 0.2s, background 0.2s;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  min-height: 48px;
}
@media (hover: hover) {
  .btn:hover:not(:disabled) { transform: translateY(-3px) rotate(-1.5deg) scale(1.03); box-shadow: 0 9px 0 var(--ink); }
}
.btn:active:not(:disabled) { transform: translateY(4px) scale(0.98); box-shadow: 0 2px 0 var(--ink); transition-duration: 0.05s; }
.btn:focus-visible { outline: 4px solid var(--cyan); outline-offset: 3px; }
.btn:disabled { opacity: 0.45; filter: grayscale(0.7); cursor: not-allowed; }

.btn-primary { background: var(--yellow); }
.btn-primary:not(:disabled) { position: relative; overflow: hidden; }
.btn-primary:not(:disabled)::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(110deg, transparent 30%, rgba(255, 255, 255, 0.7) 50%, transparent 70%);
  transform: translateX(-120%);
  animation: shine 2.8s ease-in-out 1s infinite;
  pointer-events: none;
}
@keyframes shine { 0%, 60% { transform: translateX(-120%); } 100% { transform: translateX(120%); } }

.btn-xl { font-size: clamp(20px, 5.5vw, 26px); padding: 16px 30px; min-height: 64px; }
.btn-ghost { background: rgba(255, 255, 255, 0.9); }
.btn-link {
  background: none;
  border: none;
  box-shadow: none;
  color: var(--cyan);
  text-decoration: underline wavy;
  text-underline-offset: 6px;
  font-size: 16px;
  padding: 8px;
}
.btn-link:hover { box-shadow: none !important; }
.btn-link.armed { color: var(--yellow); text-decoration-style: solid; }
.btn-round {
  width: 64px;
  height: 64px;
  padding: 0;
  font-size: 34px;
  line-height: 1;
  display: grid;
  place-items: center;
  background: var(--cyan);
  flex: none;
}
.btn-sm { width: 46px; height: 46px; min-height: 46px; font-size: 26px; box-shadow: 0 4px 0 var(--ink); border-width: 3px; }
.btn-toggle { background: var(--pink); color: #fff; font-size: 16px; padding: 8px 16px; min-height: 44px; white-space: nowrap; }
.word-row.showing .btn-toggle { background: var(--ink); color: #fff; border-color: var(--ink); }

/* ---------- Cards & rows ---------- */
.card {
  background: var(--paper);
  color: var(--ink);
  border: 4px solid var(--ink);
  border-radius: var(--radius);
  box-shadow: 0 7px 0 var(--ink);
  padding: 10px 12px;
}
.badge {
  flex: none;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 3px solid var(--ink);
  background: hsl(var(--h, 300) 90% 62%);
  color: var(--ink);
  font-family: var(--display);
  font-size: 20px;
  display: grid;
  place-items: center;
  position: relative;
}
.pname { font-size: 19px; font-weight: 900; min-width: 0; overflow-wrap: anywhere; }

.name-row { display: flex; align-items: center; gap: 12px; cursor: text; }
.input {
  flex: 1;
  min-width: 0;
  font: inherit;
  font-size: 19px;
  font-weight: 900;
  color: var(--ink);
  border: none;
  background: transparent;
  padding: 8px 4px;
  outline: none;
}
.input::placeholder { color: #a89ac4; }
.name-row:focus-within { background: #fff; transform: scale(1.02) rotate(-0.5deg); box-shadow: 0 7px 0 var(--pink); border-color: var(--pink); transition: transform 0.2s var(--bounce); }

/* Secret word rows */
.word-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  grid-template-areas: 'badge name btn' 'secret secret secret';
  align-items: center;
  column-gap: 12px;
  transition: background 0.3s, transform 0.3s var(--bounce);
}
.word-row .badge { grid-area: badge; }
.word-row .pname { grid-area: name; }
.word-row .btn-toggle { grid-area: btn; }
.word-row.peeked .badge::after {
  content: '✓';
  position: absolute;
  right: -6px;
  bottom: -6px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--green);
  border: 2px solid var(--ink);
  font-family: 'Nunito', sans-serif;
  font-size: 13px;
  font-weight: 900;
  display: grid;
  place-items: center;
  animation: popIn 0.4s var(--bounce);
}
.word-row.showing { background: #fff; transform: scale(1.03); }
.secret {
  grid-area: secret;
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 0.4s var(--snap);
}
.secret > div { overflow: hidden; }
.word-row.showing .secret { grid-template-rows: 1fr; }
.secret-inner { display: flex; flex-direction: column; align-items: center; gap: 4px; padding-top: 12px; }
.secret-inner:empty { padding: 0; }
.secret-label { font-size: 14px; color: #6b5a8e; text-transform: uppercase; letter-spacing: 0.1em; }
.secret-word {
  font-family: var(--display);
  font-size: clamp(30px, 9vw, 44px);
  color: #fff;
  background: repeating-linear-gradient(-45deg, var(--pink) 0 14px, #ff5ea0 14px 28px);
  border: 4px solid var(--ink);
  border-radius: 16px;
  padding: 6px 22px;
  box-shadow: 0 5px 0 var(--ink);
  -webkit-text-stroke: 2px var(--ink);
  paint-order: stroke fill;
  animation: flipIn 0.6s var(--bounce) 0.1s backwards;
  max-width: 100%;
  overflow-wrap: anywhere;
}
.secret-hint { font-size: 13px; color: #6b5a8e; }
.category-tag {
  margin-top: 4px;
  font-size: 14px;
  background: var(--yellow);
  border: 2px solid var(--ink);
  border-radius: 999px;
  padding: 2px 12px;
}
@keyframes flipIn {
  0% { transform: perspective(400px) rotateX(90deg) scale(0.6); opacity: 0; }
  100% { transform: none; opacity: 1; }
}


/* ---------- Action bar ---------- */
/* A screen's main button(s) with any progress text, after the list. Scrolls with the page. */
.action-bar {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
}
.center .action-bar { align-items: center; }
.action-bar .progress { margin: 0; }

/* ---------- Lots of players ---------- */
/* Compact rows from 8 players up, and two columns where there's room. */
.list.many { gap: 8px; }
.list.many .card { padding: 6px 10px; box-shadow: 0 5px 0 var(--ink); }
.list.many .badge { width: 38px; height: 38px; font-size: 17px; }
.list.many .input { padding: 6px 4px; }
.list.many .btn-toggle { min-height: 40px; padding: 6px 14px; }
@media (min-width: 760px) {
  .screen.wide { max-width: 860px; }
  .list.many { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 14px; align-items: start; }
}
