/* ============================================
   STAR POKER — PBS Kids Themed Styles
   ============================================ */

/* ----- Reset & Base ----- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --green: #00A651;
  --blue: #0072BC;
  --orange: #F7941D;
  --yellow: #FFD700;
  --purple: #7B2D8E;
  --red: #E4002B;
  --pink: #FF6B9D;
  --teal: #00BCD4;
  --bg-light: #FFF9E6;
  --card-bg: #FFFFFF;
  --shadow: 0 4px 15px rgba(0,0,0,0.15);
  --shadow-hover: 0 6px 25px rgba(0,0,0,0.25);
}

body {
  font-family: 'Bubblegum Sans', 'Comic Sans MS', cursive;
  background: linear-gradient(135deg, #87CEEB 0%, #98FB98 30%, #FFE4B5 60%, #FFB6C1 100%);
  min-height: 100vh;
  color: #333;
  overflow-x: hidden;
}

/* ----- Overlays & Modals ----- */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(4px);
}
.hidden { display: none !important; }

.welcome-box, .modal-box, .result-box {
  background: var(--bg-light);
  border-radius: 30px;
  padding: 40px;
  text-align: center;
  max-width: 550px;
  width: 90%;
  box-shadow: var(--shadow);
  border: 4px solid var(--orange);
  animation: popIn 0.4s ease-out;
}

@keyframes popIn {
  from { transform: scale(0.7); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

/* ----- Welcome Screen ----- */
.rainbow-text {
  font-family: 'Fredoka One', cursive;
  font-size: 2.8rem;
  background: linear-gradient(90deg, var(--red), var(--orange), var(--yellow), var(--green), var(--blue), var(--purple));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.subtitle {
  font-family: 'Fredoka One', cursive;
  font-size: 1.3rem;
  color: var(--purple);
  margin-top: 4px;
}
.mascot-big {
  font-size: 6rem;
  margin: 15px 0;
  animation: bounce 2s ease-in-out infinite;
}
@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-15px); }
}
.welcome-msg {
  font-size: 1.15rem;
  line-height: 1.6;
  margin: 10px 0 25px;
}
.welcome-buttons {
  display: flex;
  gap: 15px;
  justify-content: center;
  flex-wrap: wrap;
}

/* ----- Buttons ----- */
.btn {
  font-family: 'Fredoka One', cursive;
  font-size: 1.2rem;
  border: none;
  border-radius: 50px;
  padding: 14px 32px;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
  display: inline-block;
}
.btn:hover { transform: translateY(-3px); box-shadow: var(--shadow-hover); }
.btn:active { transform: translateY(0); }

.btn-primary {
  background: linear-gradient(135deg, var(--green), var(--teal));
  color: white;
}
.btn-secondary {
  background: linear-gradient(135deg, var(--orange), var(--yellow));
  color: #333;
}
.btn-info {
  background: linear-gradient(135deg, var(--blue), var(--purple));
  color: white;
}
.btn-small { font-size: 1rem; padding: 8px 16px; }

.btn-challenge {
  font-family: 'Fredoka One', cursive;
  font-size: 1.1rem;
  border: 3px solid transparent;
  border-radius: 20px;
  padding: 15px 25px;
  cursor: pointer;
  transition: all 0.2s;
  min-width: 140px;
}
.btn-challenge:hover { transform: translateY(-3px); box-shadow: var(--shadow-hover); }
.btn-challenge.easy {
  background: linear-gradient(135deg, #A8E6CF, #88D8A8);
  border-color: var(--green);
  color: #2D6A4F;
}
.btn-challenge.medium {
  background: linear-gradient(135deg, #FFD3A5, #FFB347);
  border-color: var(--orange);
  color: #8B4513;
}
.btn-challenge.hard {
  background: linear-gradient(135deg, #DDA0DD, #DA70D6);
  border-color: var(--purple);
  color: #4A0E4E;
}

/* ----- How To Play Modal ----- */
.modal-box {
  max-width: 600px;
  max-height: 90vh;
  overflow-y: auto;
  text-align: left;
}
.modal-box h2 {
  font-family: 'Fredoka One', cursive;
  color: var(--blue);
  text-align: center;
  font-size: 1.8rem;
  margin-bottom: 15px;
}
.modal-box h3 {
  font-family: 'Fredoka One', cursive;
  color: var(--purple);
  margin: 20px 0 10px;
  font-size: 1.2rem;
}
.modal-box .btn { display: block; margin: 20px auto 0; }

.step {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin: 12px 0;
}
.step-num {
  background: var(--orange);
  color: white;
  font-family: 'Fredoka One', cursive;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 1rem;
}
.step p { font-size: 1rem; }

.rankings { display: flex; flex-direction: column; gap: 6px; }
.rank-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px;
  border-radius: 10px;
  font-size: 0.95rem;
}
.rank-badge {
  font-size: 1.2rem;
  width: 28px;
  text-align: center;
}

/* ----- Result Overlay ----- */
.result-box h2 {
  font-family: 'Fredoka One', cursive;
  font-size: 2rem;
  margin: 10px 0;
}
.result-emoji { font-size: 4rem; animation: bounce 1s ease-in-out infinite; }
.result-message { font-size: 1.1rem; margin: 8px 0; }
.result-hands { font-size: 1rem; color: #666; margin: 4px 0; }
.result-stars {
  font-family: 'Fredoka One', cursive;
  font-size: 1.6rem;
  margin: 12px 0;
}
.result-box .btn { margin-top: 15px; }
.result-win { border-color: var(--green); }
.result-lose { border-color: var(--orange); }
.result-tie { border-color: var(--blue); }

/* ----- Game Screen ----- */
#game-screen {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  padding: 10px;
}

/* Top Bar */
.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(255,255,255,0.85);
  border-radius: 20px;
  padding: 10px 20px;
  box-shadow: var(--shadow);
  gap: 10px;
  flex-wrap: wrap;
}
.star-display {
  font-family: 'Fredoka One', cursive;
  font-size: 1.3rem;
  color: var(--orange);
}
.star-icon { font-size: 1.5rem; }
.round-display {
  font-family: 'Fredoka One', cursive;
  font-size: 1.1rem;
  color: var(--purple);
}

/* Hand Areas */
.hand-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px 0;
}
.computer-area { margin-top: 8px; }
.player-area { margin-bottom: 8px; }
.player-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: 'Fredoka One', cursive;
  font-size: 1.1rem;
  color: var(--blue);
  margin: 6px 0;
}
.mascot { font-size: 1.8rem; }
.chippy-stars {
  font-size: 0.9rem;
  color: var(--orange);
  margin-left: 4px;
}

/* Chippy's Speech Bubble */
.chippy-bubble {
  background: white;
  border: 2px solid var(--orange);
  border-radius: 20px;
  padding: 8px 18px;
  font-size: 1rem;
  color: #333;
  position: relative;
  margin-bottom: 8px;
  max-width: 350px;
  animation: fadeIn 0.3s ease;
}
.chippy-bubble::after {
  content: '';
  position: absolute;
  top: -10px;
  left: 30px;
  border-left: 10px solid transparent;
  border-right: 10px solid transparent;
  border-bottom: 10px solid white;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(5px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Stars In Play */
.stars-in-play {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 8px 20px;
  background: linear-gradient(135deg, #FFF8DC, #FFFACD);
  border: 3px solid var(--yellow);
  border-radius: 20px;
  margin: 4px auto;
  box-shadow: var(--shadow);
  animation: glow 2s ease-in-out infinite;
}
@keyframes glow {
  0%, 100% { box-shadow: 0 0 10px rgba(255,215,0,0.3); }
  50% { box-shadow: 0 0 25px rgba(255,215,0,0.6); }
}
.sip-label {
  font-family: 'Fredoka One', cursive;
  color: var(--orange);
  font-size: 1rem;
}
.sip-amount {
  font-family: 'Fredoka One', cursive;
  font-size: 1.4rem;
  color: var(--orange);
}

/* ----- Cards ----- */
.card-row {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
  perspective: 800px;
}

.card {
  width: 90px;
  height: 130px;
  border-radius: 12px;
  position: relative;
  cursor: default;
  transition: transform 0.3s, box-shadow 0.3s;
  transform-style: preserve-3d;
}
.card.selectable {
  cursor: pointer;
}
.card.selectable:hover {
  transform: translateY(-8px);
  box-shadow: var(--shadow-hover);
}
.card.selected {
  transform: translateY(-20px);
  box-shadow: 0 8px 30px rgba(0,0,0,0.3);
}
.card.selected::after {
  content: '🔄 SWAP';
  position: absolute;
  bottom: -22px;
  left: 50%;
  transform: translateX(-50%);
  font-family: 'Fredoka One', cursive;
  font-size: 0.65rem;
  color: var(--red);
  white-space: nowrap;
}

.card-face, .card-back {
  position: absolute;
  inset: 0;
  border-radius: 12px;
  backface-visibility: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.card-face {
  background: var(--card-bg);
  border: 2.5px solid #ccc;
  box-shadow: var(--shadow);
  padding: 6px;
}
.card-back {
  background: linear-gradient(135deg, var(--blue), var(--purple));
  border: 2.5px solid var(--blue);
  box-shadow: var(--shadow);
  transform: rotateY(180deg);
}
.card-back-pattern {
  font-size: 2.5rem;
  opacity: 0.9;
}

.card.face-down { transform: rotateY(180deg); }
.card.face-down.card-flip { animation: flipToFront 0.6s forwards; }
@keyframes flipToFront {
  0% { transform: rotateY(180deg); }
  100% { transform: rotateY(0deg); }
}
.card.dealing {
  animation: dealCard 0.4s ease-out forwards;
  opacity: 0;
}
@keyframes dealCard {
  from { opacity: 0; transform: translateY(-40px) scale(0.8); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* Card content */
.card-corner {
  position: absolute;
  font-family: 'Fredoka One', cursive;
  font-size: 0.75rem;
  line-height: 1;
  text-align: center;
}
.card-corner-top { top: 5px; left: 6px; }
.card-corner-bottom { bottom: 5px; right: 6px; transform: rotate(180deg); }
.card-center-suit {
  font-size: 2.4rem;
  margin: auto;
}
.card-rank-display {
  font-family: 'Fredoka One', cursive;
  font-size: 0.8rem;
}

/* Suit Colors */
.suit-hearts .card-face { border-color: #FF6B9D; }
.suit-hearts { color: var(--red); }
.suit-diamonds .card-face { border-color: #4DA6FF; }
.suit-diamonds { color: var(--blue); }
.suit-clubs .card-face { border-color: #4CAF50; }
.suit-clubs { color: var(--green); }
.suit-spades .card-face { border-color: #9C27B0; }
.suit-spades { color: var(--purple); }

/* ----- Action Panel ----- */
.action-panel {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 12px 20px;
  flex-wrap: wrap;
  background: rgba(255,255,255,0.85);
  border-radius: 20px;
  margin: 8px auto;
  box-shadow: var(--shadow);
  max-width: 650px;
  width: 100%;
}
.action-panel .action-label {
  font-family: 'Fredoka One', cursive;
  color: var(--purple);
  font-size: 1.1rem;
  width: 100%;
  text-align: center;
}

/* ----- Star Burst Animation ----- */
.star-burst {
  position: fixed;
  pointer-events: none;
  z-index: 2000;
  font-size: 2rem;
  animation: starFly 1s ease-out forwards;
}
@keyframes starFly {
  0% { opacity: 1; transform: scale(1); }
  100% { opacity: 0; transform: translateY(-80px) scale(1.8) rotate(30deg); }
}

/* Star Rain - falls from the top on win */
.star-rain {
  position: fixed;
  top: -40px;
  pointer-events: none;
  z-index: 2000;
  animation: starFall linear forwards;
}
@keyframes starFall {
  0%   { opacity: 1; transform: translateY(0) rotate(0deg) scale(1); }
  70%  { opacity: 1; }
  100% { opacity: 0; transform: translateY(110vh) rotate(720deg) scale(0.6); }
}

/* ----- Responsive ----- */
@media (max-width: 600px) {
  .rainbow-text { font-size: 2rem; }
  .mascot-big { font-size: 4rem; }
  .welcome-box, .modal-box, .result-box { padding: 25px; }
  .card { width: 68px; height: 100px; }
  .card-center-suit { font-size: 1.8rem; }
  .card-corner { font-size: 0.6rem; }
  .card-row { gap: 6px; }
  .btn { font-size: 1rem; padding: 12px 24px; }
  .btn-challenge { padding: 12px 18px; min-width: 110px; font-size: 0.95rem; }
  .chippy-bubble { font-size: 0.9rem; padding: 6px 14px; }
}

@media (max-width: 400px) {
  .card { width: 58px; height: 86px; }
  .card-center-suit { font-size: 1.4rem; }
  .card-corner { font-size: 0.55rem; }
}
