:root {
  --pg-primary: #4a6cf7;
  --pg-primary-dark: #3a5be0;
  --pg-bg: #eef2f7;
  --pg-success: #2ecc71;
  --pg-fail: #ff4a4a;
  --pg-gold: #ffd24a;
}

.pg-screen {
  flex: 1;
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 30px;
  text-align: center;
  padding: 20px;
}

.pg-screen.active {
  display: flex;
}

.pg-title {
  font-size: 2.6rem;
  margin: 0;
  color: #2f3542;
  font-weight: 700;
}

.pg-subtitle {
  font-size: 1.1rem;
  color: #555;
  max-width: 480px;
}

.pg-btn {
  padding: 18px 36px;
  font-size: 1.3rem;
  font-weight: 600;
  border: none;
  border-radius: 14px;
  background: var(--pg-primary);
  color: white;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(74, 108, 247, 0.35);
  transition: transform 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}

.pg-btn:hover {
  background: var(--pg-primary-dark);
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(74, 108, 247, 0.45);
}

.pg-btn:active {
  transform: translateY(0);
}

.pg-btn-row {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
  justify-content: center;
}

.pg-btn-secondary {
  background: #99a1b3;
  box-shadow: none;
}

.pg-btn-secondary:hover {
  background: #808a9e;
}

.pg-diff-row {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
  justify-content: center;
}

.pg-diff-card {
  width: 160px;
  padding: 24px 16px;
  background: white;
  border-radius: 16px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  cursor: pointer;
  border: 3px solid transparent;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.pg-diff-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.18);
  border-color: var(--pg-primary);
}

.pg-diff-card__label {
  font-size: 1.2rem;
  font-weight: 700;
  color: #2f3542;
  margin-bottom: 6px;
}

.pg-diff-card__time {
  font-size: 0.9rem;
  color: #777;
}

.pg-diff-card--easy .pg-diff-card__label { color: #2ecc71; }
.pg-diff-card--medium .pg-diff-card__label { color: #f5a623; }
.pg-diff-card--hard .pg-diff-card__label { color: #ff4a4a; }

/* Game UI chrome */
.pg-game {
  display: none;
  flex-direction: column;
  flex: 1;
}

.pg-game.active {
  display: flex;
}

.pg-topbar {
  background: #2f3542;
  color: white;
  padding: 14px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 1.1rem;
}

.pg-mode-badge {
  background: rgba(255, 255, 255, 0.15);
  padding: 6px 14px;
  border-radius: 20px;
  font-weight: 600;
}

/* Timer */
.pg-timer {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 18px 24px 0 24px;
}

.pg-timer__value {
  font-size: 1.7rem;
  font-weight: 700;
  color: #2f3542;
  font-variant-numeric: tabular-nums;
}

.pg-timer__bar-track {
  width: 100%;
  max-width: 420px;
  height: 14px;
  background: #dfe4ec;
  border-radius: 8px;
  overflow: hidden;
}

.pg-timer__bar-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, var(--pg-primary), #6f8cff);
  border-radius: 8px;
  transition: width 0.05s linear, background 0.2s ease;
}

.pg-timer__bar-fill.pg-timer--warn {
  background: linear-gradient(90deg, #ff9a3c, #ff7043);
}

.pg-timer__bar-fill.pg-timer--danger {
  background: linear-gradient(90deg, #ff4a4a, #d32f2f);
}

/* Feedback flashes */
.pg-flash-success {
  animation: pgFlashSuccess 0.4s ease;
}

.pg-flash-fail {
  animation: pgFlashFail 0.4s ease;
}

@keyframes pgFlashSuccess {
  0%   { box-shadow: inset 0 0 0 0 rgba(46, 204, 113, 0); }
  30%  { box-shadow: inset 0 0 60px 10px rgba(46, 204, 113, 0.5); }
  100% { box-shadow: inset 0 0 0 0 rgba(46, 204, 113, 0); }
}

@keyframes pgFlashFail {
  0%   { box-shadow: inset 0 0 0 0 rgba(255, 74, 74, 0); }
  30%  { box-shadow: inset 0 0 60px 10px rgba(255, 74, 74, 0.5); }
  100% { box-shadow: inset 0 0 0 0 rgba(255, 74, 74, 0); }
}

/* Bottom trays */
.pg-bottom-bar {
  padding: 16px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
  background: white;
  border-top: 1px solid #e0e4ea;
}

.pg-tray-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.pg-orb-tray,
.pg-fail-tray {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.pg-orb-slot {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #d8dee8;
  box-shadow: inset 0 0 0 2px #c3cad6;
  transition: background 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

.pg-orb-slot.filled {
  background: radial-gradient(circle at 35% 30%, #fff6cf, var(--pg-gold) 60%, #e0a800 100%);
  box-shadow: 0 0 10px rgba(255, 210, 74, 0.8);
  transform: scale(1.1);
}

.pg-fly-orb {
  position: fixed;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff6cf, var(--pg-gold) 60%, #e0a800 100%);
  box-shadow: 0 0 10px rgba(255, 210, 74, 0.9);
  pointer-events: none;
  z-index: 2000;
  transition: left 0.5s cubic-bezier(.2, .7, .3, 1), top 0.5s cubic-bezier(.2, .7, .3, 1), transform 0.5s ease, opacity 0.5s ease;
}

.pg-tomato-slot {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #f0d9d9;
  box-shadow: inset 0 0 0 2px #e0b8b8;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  opacity: 0.3;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.pg-tomato-slot.filled {
  opacity: 1;
  animation: pgTomatoPop 0.3s ease;
}

@keyframes pgTomatoPop {
  0%   { transform: scale(0.3); }
  60%  { transform: scale(1.25); }
  100% { transform: scale(1); }
}

.pg-tray-label {
  font-size: 0.85rem;
  color: #777;
}

/* Countdown */
.pg-countdown-overlay {
  position: fixed;
  inset: 0;
  background: rgba(238, 242, 247, 0.94);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 3000;
}

.pg-countdown-overlay.visible {
  display: flex;
}

.pg-countdown-number {
  font-size: 140px;
  font-weight: 800;
  color: var(--pg-primary);
  animation: pgCountdownAnim 1s ease-out forwards;
}

@keyframes pgCountdownAnim {
  0%   { transform: scale(0.6); opacity: 0; }
  30%  { transform: scale(1.15); opacity: 1; }
  70%  { transform: scale(1); opacity: 1; }
  100% { transform: scale(0.9); opacity: 0; }
}

/* Result overlay (win / fail) */
.pg-result-overlay {
  position: fixed;
  inset: 0;
  background: rgba(20, 25, 35, 0.55);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 4000;
  padding: 20px;
}

.pg-result-overlay.visible {
  display: flex;
}

.pg-result-card {
  position: relative;
  background: white;
  border-radius: 20px;
  padding: 40px 50px;
  max-width: 420px;
  width: 100%;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  animation: pgResultPop 0.35s ease;
}

@keyframes pgResultPop {
  0%   { transform: scale(0.85); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

.pg-result-icon {
  font-size: 64px;
  margin-bottom: 10px;
}

.pg-result-title {
  font-size: 1.8rem;
  font-weight: 700;
  margin: 0 0 6px 0;
}

.pg-result-card--win .pg-result-title { color: #2ecc71; }
.pg-result-card--lose .pg-result-title { color: var(--pg-fail); }

.pg-result-message {
  color: #666;
  margin: 0;
}

.pg-result-stats {
  margin: 20px 0;
  padding: 16px;
  background: #f5f7fa;
  border-radius: 12px;
  text-align: left;
  font-size: 0.95rem;
  color: #444;
  line-height: 1.8;
}

.pg-result-stats strong {
  color: #2f3542;
}

.pg-confetti {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 3900;
}

.pg-confetti-piece {
  position: absolute;
  top: -20px;
  border-radius: 2px;
  animation: pgConfettiFall linear forwards;
}

@keyframes pgConfettiFall {
  to { transform: translateY(110vh) rotate(360deg); opacity: 0.8; }
}
