/* Shared styles for the hub, Klotski and Chinese Rings (builds on styles.css) */
.pz {
  animation: rise 0.6s ease both;
}

.pz-head {
  padding-top: 0.75rem;
}

.pz-head .title {
  font-size: clamp(2.4rem, 7vw, 4.2rem);
}

.pz-head .subtitle {
  margin-bottom: 1.25rem;
}

.pz-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 2rem;
  align-items: start;
}

.pz-side {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem 1.15rem;
  backdrop-filter: blur(12px);
}

.card h2 {
  margin: 0 0 0.6rem;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 1.15rem;
}

.card p {
  margin: 0;
  color: var(--ink-dim);
  font-size: 0.88rem;
  line-height: 1.6;
}

.card p + p {
  margin-top: 0.5rem;
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.stat {
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.25);
  min-width: 0;
}

.stat-label {
  display: block;
  font-size: 0.66rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-dim);
  white-space: nowrap;
}

.stat-value {
  display: block;
  margin-top: 0.15rem;
  font-size: 1.45rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.stat-value.bump {
  animation: bump 0.25s ease;
}

@keyframes bump {
  50% {
    transform: scale(1.12);
    color: var(--wood);
  }
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.chip {
  appearance: none;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--ink-dim);
  font: inherit;
  font-size: 0.85rem;
  font-weight: 500;
  padding: 0.45rem 0.8rem;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.chip:hover {
  color: var(--ink);
  border-color: rgba(243, 235, 225, 0.3);
}

.chip.is-active {
  background: rgba(196, 48, 43, 0.88);
  border-color: transparent;
  color: #fff8f4;
}

.chip .tick {
  color: #6fbf7a;
  margin-left: 0.25rem;
}

.chip.is-active .tick {
  color: #fff8f4;
}

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.btn-row .btn {
  flex: 1 1 auto;
  padding: 0.65rem 1rem;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.toast {
  min-height: 1.4rem;
  margin: 0.75rem 0 0;
  font-size: 0.88rem;
  color: var(--wood);
  text-align: center;
  transition: opacity 0.2s ease;
}

.toast.warn {
  color: #ff8a6a;
}

.level-meta {
  margin-top: 0.6rem !important;
  font-size: 0.8rem !important;
}

/* ---------- Klotski ---------- */
.kl-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.kl-board {
  --frame: 12px;
  position: relative;
  width: min(100%, 400px, calc((100vh - 15rem) * 0.8));
  min-width: 260px;
  padding: var(--frame);
  border-radius: 18px;
  background: linear-gradient(160deg, #5a3a24, #3b2616);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.12) inset,
    0 24px 60px rgba(0, 0, 0, 0.5);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

/* exit slot in the bottom frame */
.kl-board::after {
  content: "";
  position: absolute;
  left: calc(var(--frame) + (100% - 2 * var(--frame)) * 0.25);
  width: calc((100% - 2 * var(--frame)) * 0.5);
  bottom: 0;
  height: var(--frame);
  background: repeating-linear-gradient(90deg, rgba(196, 48, 43, 0.9) 0 10px, rgba(196, 48, 43, 0.35) 10px 20px);
  border-radius: 3px 3px 0 0;
}

.kl-exit {
  margin-top: 0.45rem;
  font-size: 0.68rem;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--crimson);
}

.kl-grid {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 5;
  border-radius: 8px;
  background:
    linear-gradient(rgba(0, 0, 0, 0.35), rgba(0, 0, 0, 0.35)),
    repeating-linear-gradient(0deg, transparent 0 calc(20% - 1px), rgba(255, 255, 255, 0.05) calc(20% - 1px) 20%),
    repeating-linear-gradient(90deg, transparent 0 calc(25% - 1px), rgba(255, 255, 255, 0.05) calc(25% - 1px) 25%),
    #1d140d;
  overflow: visible;
}

.kl-piece {
  position: absolute;
  left: calc(var(--x) * 25%);
  top: calc(var(--y) * 20%);
  width: calc(var(--w) * 25%);
  height: calc(var(--h) * 20%);
  padding: 3px;
  transition: left 0.11s ease, top 0.11s ease, transform 0.6s ease, opacity 0.6s ease;
  cursor: grab;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
}

.kl-piece:active {
  cursor: grabbing;
}

.kl-piece > i {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  border-radius: 10px;
  font-style: normal;
  box-shadow:
    0 2px 0 rgba(255, 255, 255, 0.25) inset,
    0 -3px 0 rgba(0, 0, 0, 0.25) inset,
    0 4px 10px rgba(0, 0, 0, 0.35);
  transition: filter 0.15s ease, box-shadow 0.15s ease;
}

.kl-piece.t-B > i {
  background: linear-gradient(160deg, #e0483f, #a82420);
  color: #fff3ec;
  font-family: var(--font-display);
  font-size: clamp(0.9rem, 3.4vw, 1.2rem);
  letter-spacing: 0.08em;
}

.kl-piece.t-V > i {
  background: linear-gradient(160deg, #d8a070, #a86e44);
}

.kl-piece.t-H > i {
  background: linear-gradient(160deg, #c79a5e, #93683a);
}

.kl-piece.t-S > i {
  background: linear-gradient(160deg, #f4ecdf, #d9ccb8);
}

.kl-piece > i::before {
  content: "";
  display: block;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.14);
}

.kl-piece.t-V > i::before {
  width: 22%;
  height: 50%;
}

.kl-piece.t-H > i::before {
  width: 50%;
  height: 22%;
}

.kl-piece.t-S > i::before {
  width: 26%;
  height: 26%;
}

.kl-piece.t-B > i::before {
  display: none;
}

.kl-piece.is-selected > i {
  box-shadow:
    0 0 0 3px #f3ebe1,
    0 4px 14px rgba(0, 0, 0, 0.45);
}

.kl-piece.is-hint > i {
  animation: hintPulse 0.9s ease-in-out 3;
}

@keyframes hintPulse {
  50% {
    filter: brightness(1.25);
    box-shadow:
      0 0 0 4px #6fbf7a,
      0 0 22px rgba(111, 191, 122, 0.7);
  }
}

.kl-ghost {
  position: absolute;
  left: calc(var(--x) * 25%);
  top: calc(var(--y) * 20%);
  width: calc(var(--w) * 25%);
  height: calc(var(--h) * 20%);
  padding: 3px;
  pointer-events: none;
}

.kl-ghost > i {
  display: block;
  width: 100%;
  height: 100%;
  border: 2px dashed #6fbf7a;
  border-radius: 10px;
  background: rgba(111, 191, 122, 0.12);
}

.kl-board.is-won .kl-piece.t-B {
  transform: translateY(120%);
  opacity: 0;
}

.kl-board.shake {
  animation: shake 0.3s ease;
}

@keyframes shake {
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

/* ---------- Chinese Rings ---------- */
.rg-stage {
  position: relative;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    radial-gradient(ellipse 70% 60% at 50% 30%, rgba(196, 137, 90, 0.12), transparent 70%),
    rgba(0, 0, 0, 0.25);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
  padding: 0.5rem;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}

.rg-svg {
  display: block;
  width: 100%;
  height: auto;
}

.rg-ring {
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.rg-ring .rg-move {
  transition: transform 0.28s cubic-bezier(0.3, 1.4, 0.5, 1);
}

.rg-ring .hoop {
  fill: none;
  stroke: #d9b27c;
  stroke-width: 5;
}

.rg-ring .hoop-back {
  fill: none;
  stroke: #8a6a44;
  stroke-width: 5;
}

.rg-ring.is-off .hoop,
.rg-ring.is-off .hoop-back {
  stroke: #6b5a48;
}

.rg-ring .rod {
  stroke: #7d6650;
  stroke-width: 3;
}

.rg-ring .label {
  fill: var(--ink-dim);
  font: 600 13px var(--font-body);
  text-anchor: middle;
}

.rg-ring.is-movable .label {
  fill: var(--ink);
}

.rg-ring.is-movable .glow {
  opacity: 1;
}

.rg-ring .glow {
  fill: rgba(196, 137, 90, 0.16);
  stroke: rgba(196, 137, 90, 0.5);
  stroke-width: 1.5;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.rg-ring.is-hint .hoop {
  animation: ringHint 0.8s ease-in-out 3;
}

@keyframes ringHint {
  50% {
    stroke: #6fbf7a;
    stroke-width: 8;
  }
}

.rg-ring.is-denied .rg-move {
  animation: ringNo 0.3s ease;
}

@keyframes ringNo {
  25% { transform: translateX(-5px); }
  75% { transform: translateX(5px); }
}

.rg-bar {
  fill: none;
  stroke: #c9ced6;
  stroke-width: 5;
  stroke-linecap: round;
}

.rg-handle {
  fill: #8a5a38;
}

.rules {
  margin: 0;
  padding-left: 1.1rem;
  color: var(--ink-dim);
  font-size: 0.88rem;
  line-height: 1.6;
}

/* ---------- Hub ---------- */
.hub-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.25rem;
  margin-top: 0.5rem;
}

.hub-card {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  padding: 1.1rem 1.1rem 1.25rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--ink);
  text-decoration: none;
  transition: transform 0.18s ease, border-color 0.18s ease;
}

.hub-card:hover {
  transform: translateY(-3px);
  border-color: rgba(196, 137, 90, 0.55);
}

.hub-art {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 150px;
  border-radius: 10px;
  background: linear-gradient(180deg, #f7f2ea, #e8dfd0);
}

.hub-art svg {
  height: 120px;
  width: auto;
}

.hub-card h2 {
  margin: 0.2rem 0 0;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 1.5rem;
}

.hub-card p {
  margin: 0;
  color: var(--ink-dim);
  font-size: 0.9rem;
  line-height: 1.55;
}

.hub-card .play-link {
  margin-top: auto;
  padding-top: 0.4rem;
  color: var(--wood);
  font-weight: 600;
  font-size: 0.9rem;
}

.hub-best {
  font-size: 0.78rem !important;
  color: #6fbf7a !important;
}

/* confetti */
.confetti {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 50;
}

@media (max-width: 900px) {
  .hub-grid {
    grid-template-columns: 1fr;
  }
  .hub-card {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
  }
  .hub-art {
    height: 96px;
    width: 96px;
    flex: 0 0 96px;
  }
  .hub-art svg {
    height: 76px;
  }
  .hub-card .hub-text {
    flex: 1 1 0;
    min-width: 0;
  }
  .hub-card .play-link {
    display: none;
  }
}

@media (max-width: 820px) {
  .pz-layout {
    grid-template-columns: 1fr;
    gap: 1.25rem;
  }
  .pz-head {
    padding-top: 0;
  }
  .pz-head .subtitle {
    font-size: 0.92rem;
    margin: 0.4rem 0 0.9rem;
  }
  .pz-head .eyebrow {
    font-size: 0.7rem;
  }
  .stats {
    margin-bottom: 0.75rem;
  }
  .stat {
    padding: 0.45rem 0.6rem;
  }
  .stat-value {
    font-size: 1.2rem;
  }
  .kl-board {
    --frame: 9px;
    width: min(100%, 400px, calc((100svh - 13rem) * 0.8));
  }
}

.rg-ring:focus {
  outline: none;
}

.rg-ring:focus-visible .glow {
  opacity: 1;
  stroke: #f3ebe1;
}

.kl-piece:focus {
  outline: none;
}

.kl-piece:focus-visible > i {
  box-shadow:
    0 0 0 3px #f3ebe1,
    0 4px 14px rgba(0, 0, 0, 0.45);
}
