/* ---------- panels & typography ---------- */
.panel {
  position: relative;
  z-index: 5;
  background: rgba(255, 250, 241, .92);
  border-radius: var(--panel-radius);
  box-shadow: 0 12px 30px rgba(0,0,0,.12);
  padding: 1.75rem 2rem;
  max-width: 32rem;
  width: 100%;
  text-align: center;
  backdrop-filter: blur(6px);
}
.panel-center { margin: auto; }
.panel-top { position: absolute; top: calc(1rem + var(--safe-top)); left: 50%; transform: translateX(-50%); }
.panel-bottom { position: absolute; bottom: calc(1rem + var(--safe-bottom)); left: 50%; transform: translateX(-50%); display: flex; gap: .75rem; justify-content: center; flex-wrap: wrap; }

.logo { font-size: clamp(2.5rem, 8vw, 4.5rem); margin-bottom: .5rem; font-weight: 900; }
.tagline { line-height: 1.6; margin-bottom: 1.5rem; color: #5a5163; font-size: 1.2rem; }
.status-text { color: #5a5163; margin-top: .5rem; font-size: 1.15rem; font-weight: 700; }

/* ---------- buttons ---------- */
.btn {
  font: inherit;
  font-weight: 700;
  border: none;
  border-radius: 999px;
  padding: .8rem 1.6rem;
  cursor: pointer;
  transition: transform .15s ease, box-shadow .15s ease, opacity .15s ease;
  color: var(--ink);
  background: #fff;
  box-shadow: 0 4px 0 rgba(0,0,0,.08);
}
.btn:hover { transform: translateY(-2px); }
.btn:active { transform: translateY(1px); box-shadow: 0 2px 0 rgba(0,0,0,.08); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--accent); color: #fff; box-shadow: 0 4px 0 var(--accent-dark); }
.btn-big { display: inline-block; margin-top: .5rem; font-size: 1.5rem; padding: 1.2rem 2.8rem; }
.btn-ghost { background: transparent; border: 2px solid rgba(44,37,48,.2); box-shadow: none; }
.btn-row { display: flex; gap: .6rem; justify-content: center; flex-wrap: wrap; margin: 1rem 0; }

.text-input {
  display: block;
  width: 100%;
  font: inherit;
  padding: .8rem 1rem;
  border-radius: 999px;
  border: 2px solid rgba(44,37,48,.2);
  text-align: center;
  margin: 1rem 0;
}

/* ---------- cursor ---------- */
.cursor {
  position: fixed;
  top: 0; left: 0;
  width: 0; height: 0;
  z-index: 999;
  pointer-events: none;
}
.cursor-dot {
  position: absolute;
  top: 0; left: 0;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid var(--accent);
  transform: translate(-50%, -50%);
  transition: transform .1s ease;
}
.cursor-drop {
  position: absolute;
  top: -34px; left: 0;
  width: 30px; height: 30px;
  border-radius: 50% 50% 50% 0;
  transform: translate(-50%, -50%) rotate(-45deg) scale(0);
  background: var(--held-color, transparent);
  border: 2px solid rgba(255,255,255,.8);
  box-shadow: 0 3px 8px rgba(0,0,0,.25);
  transition: transform .18s cubic-bezier(.34,1.56,.64,1);
}
.cursor.holding .cursor-drop { transform: translate(-50%, -50%) rotate(-45deg) scale(1); }
.cursor.holding .cursor-dot { transform: translate(-50%, -50%) scale(1.3); }
.cursor-ring {
  position: absolute;
  top: 0; left: 0;
  width: 44px; height: 44px;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  opacity: 0;
  transition: opacity .15s ease;
  -webkit-mask: radial-gradient(closest-side, transparent 60%, #000 62%);
  mask: radial-gradient(closest-side, transparent 60%, #000 62%);
}

/* ---------- toast ---------- */
.toast {
  position: absolute;
  top: calc(1rem + var(--safe-top));
  left: 50%;
  transform: translate(-50%, -140%);
  background: var(--ink);
  color: #fff;
  padding: .9rem 1.8rem;
  border-radius: 999px;
  font-weight: 800;
  font-size: 1.3rem;
  z-index: 50;
  opacity: 0;
  transition: transform .25s ease, opacity .25s ease;
  pointer-events: none;
  white-space: nowrap;
}
.toast.show { transform: translate(-50%, 0); opacity: 1; }
.toast.good { background: var(--leaf-dark); }
.toast.bad { background: var(--accent-dark); }

/* ---------- calibration ---------- */
.calibration-target {
  position: relative;
  z-index: 5;
  width: clamp(140px, 24vw, 220px);
  aspect-ratio: 1;
  border-radius: 50%;
  border: 4px dashed rgba(255,255,255,.85);
  background: rgba(255,255,255,.15);
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 1.2rem;
  color: #fff;
  font-weight: 800;
  font-size: 1.4rem;
  text-shadow: 0 2px 6px rgba(0,0,0,.5);
  transition: background .2s ease, border-color .2s ease;
}
.calibration-target.filled {
  background: rgba(107, 201, 138, .5);
  border-color: #6bc98a;
}

/* ---------- tutorial ---------- */
.stage {
  position: relative;
  z-index: 5;
  width: min(90vw, 700px);
  height: min(60vh, 480px);
}
.tutorial-target {
  position: absolute;
  width: clamp(90px, 16vw, 140px);
  aspect-ratio: 1;
  border-radius: 50%;
  border: 4px dashed rgba(44,37,48,.35);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color .2s ease, background .2s ease;
}
.tutorial-target.done { border-style: solid; border-color: var(--leaf-dark); background: rgba(107,201,138,.25); }
.tutorial-swatch {
  position: absolute;
  width: clamp(60px, 11vw, 90px);
  aspect-ratio: 1;
  border-radius: 50%;
  border: 3px solid rgba(255,255,255,.9);
  box-shadow: 0 4px 10px rgba(0,0,0,.15);
  transition: opacity .2s ease, transform .2s ease;
}
.tutorial-swatch.used { opacity: 0; transform: scale(.4); }
.tutorial-tray {
  position: absolute;
  bottom: 4%;
  left: 50%;
  transform: translateX(-50%);
  width: clamp(160px, 32vw, 240px);
  min-height: clamp(90px, 15vh, 120px);
  background: rgba(255, 250, 241, .88);
  border: 3px dashed rgba(44, 37, 48, .25);
  border-radius: 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  padding: .6rem;
  box-shadow: 0 6px 16px rgba(0, 0, 0, .12);
  transition: border-color .2s ease, background .2s ease;
}
.tutorial-tray.done { border-style: solid; border-color: var(--leaf-dark); background: rgba(107, 201, 138, .25); }
.tutorial-tray-label { font-weight: 700; color: #8a8190; }
.tutorial-swatch.in-tray { position: static; }

/* ---------- HUD ---------- */
.hud {
  position: absolute;
  top: calc(.8rem + var(--safe-top));
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: .6rem;
  z-index: 20;
}
.hud-pill {
  background: rgba(255,250,241,.92);
  border-radius: 999px;
  padding: .6rem 1.4rem;
  font-weight: 800;
  font-size: 1.3rem;
  box-shadow: 0 4px 12px rgba(0,0,0,.15);
}
#hud-timer.low { color: var(--accent-dark); animation: pulse 1s infinite; }
@keyframes pulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.12); } }

/* ---------- animals & palette ---------- */
.animal-layer { position: absolute; inset: 0; z-index: 6; }
.animal-slot {
  position: absolute;
  width: clamp(90px, 14vw, 160px);
  transform: translate(-50%, -50%);
  text-align: center;
}
.animal-slot img.animal-img {
  width: 100%;
  filter: grayscale(1) contrast(.9);
  transition: filter .6s ease;
  display: block;
}
.animal-slot.solved img.animal-img { filter: grayscale(0); }
.animal-need {
  width: 22px; height: 22px;
  border-radius: 50%;
  margin: 0 auto 4px;
  border: 3px solid #fff;
  box-shadow: 0 2px 6px rgba(0,0,0,.2);
  transition: opacity .3s ease, transform .3s ease;
}
.animal-slot.solved .animal-need { opacity: 0; transform: scale(0); }
.animal-color-name {
  font-size: 1.3rem;
  font-weight: 900;
  background: #fff;
  padding: 4px 14px;
  border-radius: 999px;
  display: inline-block;
  margin-bottom: 10px;
  box-shadow: 0 4px 0 rgba(0,0,0,.1), 0 6px 12px rgba(0,0,0,.12);
  transition: opacity .3s ease, transform .3s ease;
}
.animal-slot.solved .animal-color-name { opacity: 0; transform: scale(0); }

.palette-tray {
  position: absolute;
  bottom: calc(5rem + var(--safe-bottom));
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 1.2rem;
  padding: 1rem 1.5rem;
  background: rgba(255,250,241,.85);
  border-radius: 999px;
  box-shadow: 0 6px 16px rgba(0,0,0,.12);
  z-index: 20;
  flex-wrap: wrap;
  justify-content: center;
  max-width: 92vw;
}
.swatch {
  width: clamp(60px, 10vw, 80px);
  aspect-ratio: 1;
  border-radius: 50%;
  border: 3px solid #fff;
  box-shadow: 0 3px 8px rgba(0,0,0,.18), inset 0 0 0 2px rgba(0,0,0,.06);
  transition: transform .15s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow .15s ease, opacity .2s ease;
  cursor: pointer;
}
.swatch.picked { transform: scale(1.15); box-shadow: 0 0 0 4px var(--accent); }
.swatch.used { opacity: 0; pointer-events: none; transform: scale(.3); }

/* ---------- results / leaderboard ---------- */
.result-name { font-size: 1.2rem; font-weight: 700; margin-top: .5rem; }
.result-score { font-size: 2.4rem; font-weight: 800; color: var(--accent-dark); margin: .25rem 0 1rem; }
.result-breakdown { display: flex; justify-content: center; gap: 1rem; margin-bottom: .5rem; color: #5a5163; }

.leaderboard-list {
  position: relative;
  z-index: 5;
  width: min(90vw, 560px);
  max-height: 64vh;
  overflow-y: auto;
  background: rgba(255,250,241,.92);
  border-radius: var(--panel-radius);
  padding: 1rem;
  box-shadow: 0 12px 30px rgba(0,0,0,.12);
  margin-top: 4.5rem;
}
.leaderboard-row {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .5rem .25rem;
  border-bottom: 1px solid rgba(44,37,48,.08);
}
.leaderboard-row:last-child { border-bottom: none; }
.leaderboard-rank { width: 1.8rem; font-weight: 800; color: var(--accent-dark); }
.leaderboard-name { flex: 1; font-weight: 700; text-align: left; }
.leaderboard-score { font-weight: 800; }
.leaderboard-date { font-size: .75rem; color: #8a8190; }
.leaderboard-empty { color: #8a8190; padding: 1rem; }

@media (max-width: 480px) {
  .panel { padding: 1.25rem 1.25rem; }
}
