.page-shell {
  display: grid;
  gap: 18px;
}

.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}

.back-btn {
  min-width: 168px;
  background: linear-gradient(180deg, #172742 0%, #101b31 100%);
}

.game-header {
  flex: 1;
  padding: 18px 22px;
  border-radius: var(--radius-xl);
  background: linear-gradient(135deg, rgba(20, 31, 52, 0.96), rgba(13, 22, 40, 0.96));
  box-shadow: var(--shadow);
  border: 1px solid var(--border-soft);
}

.game-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(300px, 0.8fr);
  gap: 18px;
  align-items: start;
}

.stats-row {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
}

.stat-pill {
  flex: 1;
  min-width: 140px;
  padding: 14px 18px;
  border-radius: 999px;
  background: rgba(16, 27, 45, 0.95);
  font-weight: 800;
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.24);
  border: 1px solid var(--border-soft);
}

.canvas-wrap,
.side-card,
.puzzle-board-card {
  padding: 18px;
  border-radius: var(--radius-xl);
  background: var(--panel);
  box-shadow: var(--shadow);
  border: 1px solid var(--border-soft);
}

.control-btn:active,
.shuffle-btn:active,
.restart-btn:active,
.back-btn:active,
.play-btn:active {
  transform: translateY(2px) scale(0.99);
}

.side-card h3,
.puzzle-board-card h3 {
  margin: 0 0 10px;
  font-size: 1.45rem;
}

.side-card p,
.puzzle-board-card p {
  margin: 0;
  line-height: 1.5;
}

.status-message {
  min-height: 30px;
  margin-top: 14px;
  font-weight: 800;
  color: #8ed9ff;
}

.shuffle-btn,
.restart-btn {
  background: linear-gradient(180deg, #73d564 0%, #49c158 100%);
  color: #fff;
  min-width: 156px;
}
.win-banner[hidden] {
  display: none;
}

.trophy-win-modal {
  z-index: 4;
}

.trophy-badge {
  position: relative;
  overflow: hidden;
  width: min(100%, 320px);
  display: grid;
  justify-items: center;
  gap: 8px;
  padding: 24px 24px 20px;
  border-radius: 28px;
  background:
    radial-gradient(circle at top, rgba(255, 247, 191, 0.9), rgba(255, 247, 191, 0) 38%),
    linear-gradient(180deg, #ffe58f 0%, #ffc83d 45%, #f29a1f 100%);
  color: #4f2800;
  border: 1px solid rgba(255, 255, 255, 0.38);
  box-shadow:
    0 20px 34px rgba(0, 0, 0, 0.24),
    inset 0 2px 0 rgba(255, 255, 255, 0.58);
  animation: trophyBounceIn 700ms cubic-bezier(0.22, 1.2, 0.36, 1) both;
}

.trophy-badge__shine {
  position: absolute;
  inset: -20% auto -20% -38%;
  width: 34%;
  transform: rotate(18deg);
  background: linear-gradient(90deg, rgba(255, 255, 255, 0), rgba(255, 255, 255, 0.62), rgba(255, 255, 255, 0));
  animation: trophyShine 2s ease-in-out 350ms infinite;
}

.trophy-badge__icon {
  font-size: 0.76rem;
  letter-spacing: 0.18em;
  font-weight: 900;
  opacity: 0.82;
}

.trophy-badge__title {
  font-size: clamp(1.8rem, 4vw, 2.3rem);
  line-height: 1;
  font-weight: 900;
  text-transform: uppercase;
  text-shadow: 0 2px 0 rgba(255, 255, 255, 0.26);
}

.trophy-badge__subtitle {
  font-size: 0.95rem;
  font-weight: 800;
  letter-spacing: 0.04em;
}

.trophy-badge__button {
  margin-top: 8px;
}

.game-modal {
  position: absolute;
  inset: 18px;
  display: grid;
  place-items: center;
  padding: 18px;
  border-radius: 28px;
  background: rgba(6, 11, 20, 0.72);
  backdrop-filter: blur(6px);
  z-index: 3;
}

.game-modal-card {
  width: min(100%, 320px);
  display: grid;
  gap: 14px;
  padding: 24px 22px;
  text-align: center;
  border-radius: 24px;
  background: linear-gradient(180deg, rgba(17, 28, 49, 0.98), rgba(10, 18, 34, 0.98));
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.34);
}

.game-modal[hidden] {
  display: none;
}

.game-modal-card h3,
.game-modal-card p {
  margin: 0;
}

.sparkles {
  display: inline-flex;
  gap: 6px;
  margin-left: 6px;
  vertical-align: middle;
}

.sparkles span {
  animation: twinkle 900ms ease-in-out infinite alternate;
}

.sparkles span:nth-child(2) {
  animation-delay: 200ms;
}

.sparkles span:nth-child(3) {
  animation-delay: 400ms;
}

@keyframes trophyBounceIn {
  0% {
    opacity: 0;
    transform: translateY(20px) scale(0.82);
  }
  55% {
    opacity: 1;
    transform: translateY(-8px) scale(1.06);
  }
  75% {
    transform: translateY(4px) scale(0.98);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes trophyShine {
  0% {
    left: -38%;
    opacity: 0;
  }
  18% {
    opacity: 1;
  }
  55% {
    left: 112%;
    opacity: 0.95;
  }
  100% {
    left: 112%;
    opacity: 0;
  }
}
