/* ==========================================================================
   fruit_pang: studio-themed styles
   ========================================================================== */

:root {
  --fp-bg: #faf7f2;
  --fp-ink: #0f0f14;
  --fp-sub: #52525c;
  --fp-muted: #6b6b78;
  --fp-card: #ffffff;
  --fp-card-shadow: 0 10px 30px rgba(17, 17, 24, 0.06), 0 2px 6px rgba(17, 17, 24, 0.04);
  --fp-accent-1: #ff6b6b;
  --fp-accent-2: #a855f7;
  --fp-accent-3: #4f46e5;
  --fp-danger: #ff6b6b;
  --fp-gradient: linear-gradient(135deg, var(--fp-accent-1) 0%, var(--fp-accent-2) 55%, var(--fp-accent-3) 100%);
}

.fp-body {
  background: var(--fp-bg) !important;
  color: var(--fp-ink);
}

/* intro ------------------------------------------------------------------- */

.fp-intro-hero {
  text-align: center;
  padding: 28px 0 12px;
}
.fp-intro-marks {
  font-size: clamp(28px, 6vw, 40px);
  letter-spacing: 6px;
  margin-bottom: 8px;
  filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.08));
}
.fp-intro-title {
  font-size: clamp(32px, 7vw, 44px);
  font-weight: 800;
  letter-spacing: -0.02em;
  margin: 6px 0 8px;
  background: var(--fp-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.fp-intro-lede {
  color: var(--fp-sub);
  font-size: 14px;
  line-height: 1.55;
  margin: 0;
}

/* cards ------------------------------------------------------------------- */

.fp-card {
  background: var(--fp-card);
  border-radius: 20px;
  padding: 20px 22px;
  margin: 16px 0;
  box-shadow: var(--fp-card-shadow);
}
.fp-card-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--fp-ink);
  margin: 0 0 12px;
  letter-spacing: -0.005em;
}
.fp-rules {
  list-style: none;
  padding: 0;
  margin: 0;
  font-size: 14px;
  line-height: 1.7;
  color: var(--fp-sub);
}
.fp-kbd {
  display: inline-block;
  font-size: 12px;
  font-weight: 600;
  color: var(--fp-accent-3);
  background: rgba(79, 70, 229, 0.08);
  padding: 1px 8px;
  border-radius: 6px;
}

.fp-cta {
  display: block;
  text-align: center;
  background: var(--fp-gradient);
  color: #fff;
  font-weight: 700;
  font-size: 16px;
  padding: 14px 0;
  border-radius: 16px;
  margin: 18px 0 6px;
  box-shadow: 0 8px 24px rgba(79, 70, 229, 0.22);
  text-decoration: none;
  transition: transform 180ms cubic-bezier(0.2, 0.8, 0.2, 1), box-shadow 180ms;
}
.fp-cta:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 28px rgba(79, 70, 229, 0.28);
}
.fp-cta:active { transform: translateY(0); }

/* leaderboard ------------------------------------------------------------- */

.fp-leaderboard { margin-top: 18px; }
.fp-top-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.fp-top-list li {
  display: grid;
  grid-template-columns: 32px 1fr auto auto;
  gap: 10px;
  align-items: center;
  padding: 8px 10px;
  border-radius: 10px;
  font-size: 14px;
  color: var(--fp-sub);
}
.fp-top-list li:nth-child(odd) { background: rgba(168, 85, 247, 0.05); }
.fp-top-rank {
  font-weight: 700;
  color: var(--fp-accent-2);
  text-align: center;
}
.fp-top-list li:nth-child(1) .fp-top-rank { color: var(--fp-accent-1); }
.fp-top-name {
  color: var(--fp-ink);
  font-weight: 600;
}
.fp-top-score {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  color: var(--fp-ink);
}
.fp-top-combo {
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  background: var(--fp-gradient);
  padding: 2px 7px;
  border-radius: 999px;
  letter-spacing: 0.02em;
}
.fp-top-empty {
  color: var(--fp-muted);
  font-size: 13px;
  text-align: center;
  padding: 10px 0;
  margin: 0;
}

/* HUD -------------------------------------------------------------------- */

.fp-hud {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 10px;
  padding: 12px 14px;
  background: var(--fp-card);
  border-radius: 16px;
  box-shadow: var(--fp-card-shadow);
  margin: 4px 0 12px;
}
.fp-hud-cell {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
}
.fp-hud-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--fp-muted);
}
.fp-hud-value {
  font-size: 22px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--fp-ink);
  letter-spacing: -0.01em;
}
.fp-hud-score { align-items: flex-end; }
.fp-hud-combo { align-items: flex-end; }
.fp-hud-combo .fp-hud-value {
  background: var(--fp-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.fp-hud-cell.fp-hud-low .fp-hud-value {
  color: var(--fp-danger);
  animation: fp-pulse-danger 1s ease-in-out infinite;
}
@keyframes fp-pulse-danger {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.55; }
}

/* stage + board ---------------------------------------------------------- */

.fp-stage {
  position: relative;
  background: var(--fp-card);
  border-radius: 20px;
  padding: 10px;
  box-shadow: var(--fp-card-shadow);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.fp-board {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  --fp-cols: 7;
  --fp-rows: 7;
}

.fp-tile {
  position: absolute;
  top: 0;
  left: 0;
  width: calc(100% / var(--fp-cols));
  height: calc(100% / var(--fp-rows));
  padding: 3px;
  box-sizing: border-box;
  transform: translate(calc(var(--c, 0) * 100%), calc(var(--r, 0) * 100%));
  transition: transform 180ms cubic-bezier(0.2, 0.8, 0.2, 1);
  will-change: transform;
  cursor: pointer;
}
.fp-tile.fp-falling {
  transition: transform 220ms cubic-bezier(0.5, 0, 0.5, 1.4);
}

.fp-tile-inner {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(168, 85, 247, 0.05);
  border-radius: 10px;
  font-size: clamp(26px, 5.2vw, 40px);
  line-height: 1;
  transition: background-color 120ms ease, box-shadow 180ms ease, transform 180ms ease;
  user-select: none;
  -webkit-user-select: none;
}
.fp-tile.fp-selected .fp-tile-inner {
  box-shadow: 0 0 0 2px var(--fp-accent-2), 0 4px 12px rgba(168, 85, 247, 0.25);
  animation: fp-select-pulse 1.1s ease-in-out infinite;
}
@keyframes fp-select-pulse {
  0%, 100% { box-shadow: 0 0 0 2px var(--fp-accent-2), 0 4px 12px rgba(168, 85, 247, 0.25); }
  50% { box-shadow: 0 0 0 3px var(--fp-accent-2), 0 6px 16px rgba(168, 85, 247, 0.35); }
}
.fp-tile.fp-pop .fp-tile-inner {
  animation: fp-pop 200ms ease-in forwards;
}
@keyframes fp-pop {
  0% { transform: scale(1) rotate(0deg); opacity: 1; }
  55% { transform: scale(1.18) rotate(8deg); opacity: 1; }
  100% { transform: scale(0.15) rotate(-6deg); opacity: 0; }
}
.fp-tile.fp-invalid .fp-tile-inner {
  animation: fp-shake 220ms ease-in-out;
}
@keyframes fp-shake {
  0%, 100% { transform: translate(0, 0); }
  25% { transform: translate(-5%, 0); }
  50% { transform: translate(5%, 0); }
  75% { transform: translate(-2%, 0); }
}
.fp-tile.fp-spawn .fp-tile-inner {
  animation: fp-spawn 200ms ease-out;
}
@keyframes fp-spawn {
  0% { transform: scale(0.5); opacity: 0; }
  60% { transform: scale(1.08); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}

/* countdown overlay ------------------------------------------------------ */

.fp-countdown {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(80px, 22vw, 160px);
  font-weight: 900;
  color: transparent;
  background: var(--fp-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  pointer-events: none;
  opacity: 0;
}
.fp-countdown.fp-show {
  animation: fp-count 900ms ease-out forwards;
}
@keyframes fp-count {
  0% { opacity: 0; transform: scale(0.6); }
  35% { opacity: 1; transform: scale(1.1); }
  75% { opacity: 1; transform: scale(1); }
  100% { opacity: 0; transform: scale(1.25); }
}

/* modal ------------------------------------------------------------------ */

.fp-modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 15, 20, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 50;
  animation: fp-fade 240ms ease-out;
}
@keyframes fp-fade {
  from { opacity: 0; }
  to { opacity: 1; }
}
.fp-modal[hidden] { display: none; }
.fp-modal-card {
  background: var(--fp-card);
  border-radius: 24px;
  padding: 28px 24px;
  width: 100%;
  max-width: 420px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.25);
  animation: fp-rise 300ms cubic-bezier(0.2, 0.8, 0.2, 1);
}
@keyframes fp-rise {
  from { opacity: 0; transform: translateY(16px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.fp-modal-title {
  margin: 0 0 18px;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.01em;
  text-align: center;
}
.fp-modal-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 18px;
}
.fp-modal-stats > div {
  background: rgba(168, 85, 247, 0.06);
  padding: 12px;
  border-radius: 12px;
  text-align: center;
}
.fp-modal-stats strong {
  display: block;
  font-size: 26px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--fp-ink);
  margin-top: 4px;
}
.fp-modal-label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--fp-muted);
}
.fp-submit-form { display: flex; flex-direction: column; gap: 8px; }
.fp-submit-form input {
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid #e5e5ea;
  font-size: 16px;
  outline: none;
  transition: border-color 160ms;
}
.fp-submit-form input:focus {
  border-color: var(--fp-accent-2);
  box-shadow: 0 0 0 3px rgba(168, 85, 247, 0.15);
}
.fp-submit-cta { margin: 6px 0 0; }
.fp-submit-error {
  color: var(--fp-danger);
  font-size: 13px;
  text-align: center;
  margin: 6px 0 0;
}
.fp-submit-done { padding-top: 4px; }
.fp-modal-rank {
  font-size: 36px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  margin: 4px 0 12px;
  text-align: center;
  background: var(--fp-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.fp-modal-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 16px;
}
.fp-cta-outline {
  display: block;
  text-align: center;
  padding: 12px 0;
  border-radius: 12px;
  font-weight: 700;
  font-size: 14px;
  text-decoration: none;
  color: var(--fp-ink);
  background: rgba(168, 85, 247, 0.08);
  transition: background 160ms;
}
.fp-cta-outline:hover { background: rgba(168, 85, 247, 0.15); }
