/* This file controls how the website LOOKS: colors, sizes, and fonts */

body {
  margin: 0;
  font-family: "Comic Sans MS", "Chalkboard SE", sans-serif;
  background: #fdf6e3;
  color: #333;
  text-align: center;
}

button {
  font-family: inherit;
}

header {
  background: #6c5ce7;
  color: white;
  padding: 20px 16px;
}

h1 {
  margin: 0;
  font-size: 44px;
}

/* ----- The guide ----- */

#open-guide {
  font-size: 18px;
  padding: 8px 20px;
  background: white;
  color: #6c5ce7;
  border: none;
  border-radius: 20px;
  cursor: pointer;
}

#open-guide:hover {
  background: #ffeaa7;
}

#pause-button {
  font-size: 18px;
  padding: 8px 20px;
  background: #ffeaa7;
  color: #6c5ce7;
  border: none;
  border-radius: 20px;
  cursor: pointer;
}

#pause-button:hover {
  background: white;
}

/* The big "Paused" sign that covers the yard */
#paused-sign {
  display: none;
  position: absolute;
  inset: 0;
  z-index: 5;
  justify-content: center;
  align-items: center;
  flex-direction: column;
  background: rgba(0, 0, 0, 0.45);
  color: white;
  font-size: 48px;
  font-weight: bold;
  cursor: pointer;
}

#paused-sign span {
  font-size: 20px;
  font-weight: normal;
}

#yard.paused #paused-sign {
  display: flex;
}

#start-over {
  font-size: 18px;
  padding: 8px 20px;
  background: transparent;
  color: white;
  border: 2px solid white;
  border-radius: 20px;
  cursor: pointer;
}

#start-over:hover {
  background: rgba(255, 255, 255, 0.2);
}

.save-note {
  margin: 8px 0 0;
  font-size: 14px;
  opacity: 0.8;
}

#guide {
  max-width: 560px;
  border: 6px solid #6c5ce7;
  border-radius: 20px;
  padding: 24px;
  text-align: left;
  font-size: 17px;
  line-height: 1.5;
}

/* Darkens the page behind the guide */
#guide::backdrop {
  background: rgba(0, 0, 0, 0.5);
}

#guide h2 {
  margin-top: 0;
  text-align: center;
}

#guide h3 {
  margin-bottom: 4px;
  color: #6c5ce7;
}

#guide li {
  margin-bottom: 4px;
}

#close-guide {
  display: block;
  margin: 16px auto 0;
  font-size: 22px;
  padding: 12px 28px;
  background: #fd79a8;
  color: white;
  border: none;
  border-radius: 12px;
  cursor: pointer;
}

#close-guide:hover {
  background: #e84393;
}

/* ----- The champion reward ----- */

.reward {
  max-width: 480px;
  border: 6px solid #f9ca24;
  border-radius: 20px;
  padding: 24px;
  font-size: 18px;
  line-height: 1.5;
  background: #fffbea;
  animation: bounce-in 0.6s;
}

.reward::backdrop {
  background: rgba(0, 0, 0, 0.5);
}

.reward h2 {
  margin-top: 0;
  font-size: 36px;
  color: #e67e22;
}

.reward ul {
  text-align: left;
}

.reward-button {
  font-size: 22px;
  padding: 12px 28px;
  background: #f9ca24;
  color: #333;
  border: none;
  border-radius: 12px;
  cursor: pointer;
}

.reward-button:hover {
  background: #f0b400;
}

@keyframes bounce-in {
  0%   { transform: scale(0.3); }
  60%  { transform: scale(1.1); }
  100% { transform: scale(1); }
}

/* The crown your pet wears after winning every trophy */
#yard.champion #yard-pet::before {
  content: "👑";
  position: absolute;
  top: -0.4em;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.45em;
}

/* The rainbow glow your pet gets after beating every challenge */
#yard.legend #yard-pet:not(.jumping) {
  animation: rainbow-glow 2s linear infinite;
}

@keyframes rainbow-glow {
  0%   { filter: drop-shadow(0 0 12px #ff4757); }
  20%  { filter: drop-shadow(0 0 12px #ffa502); }
  40%  { filter: drop-shadow(0 0 12px #eccc68); }
  60%  { filter: drop-shadow(0 0 12px #2ed573); }
  80%  { filter: drop-shadow(0 0 12px #1e90ff); }
  100% { filter: drop-shadow(0 0 12px #a55eea); }
}

/* Confetti falling down the whole screen */
.confetti {
  position: fixed;
  top: -40px;
  z-index: 30;
  pointer-events: none;
  animation: confetti-fall linear forwards;
}

@keyframes confetti-fall {
  to { transform: translateY(110vh) rotate(720deg); }
}

/* ----- The pet picker ----- */

.picker {
  padding: 16px 16px 0;
}

.picker h2 {
  margin: 0 0 10px;
}

#pet-choices {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 18px 10px;
}

/* The little level tag under each pet you've played with */
.choice[data-level]:not([data-level=""])::after {
  content: attr(data-level);
  position: absolute;
  bottom: -10px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 11px;
  line-height: 1.5;
  padding: 0 6px;
  border-radius: 8px;
  background: #6c5ce7;
  color: white;
  white-space: nowrap;
}

.choice {
  position: relative;
  font-size: 36px;
  width: 64px;
  height: 64px;
  background: white;
  border: 4px solid #dfe6e9;
  border-radius: 16px;
  cursor: pointer;
}

.choice:hover {
  border-color: #a29bfe;
}

/* The pet you picked gets a purple border */
.choice.picked {
  border-color: #6c5ce7;
  background: #ffeaa7;
}

/* ----- The page layout ----- */

/* Puts the play area and the side panels side by side */
main {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: flex-start;
  gap: 24px;
  padding: 20px 16px 40px;
}

.play-area {
  flex: 1 1 560px;
  max-width: 760px;
}

.side {
  width: 320px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* ----- The stats boxes ----- */

.stats {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 12px;
}

.stat-box {
  flex: 1 1 180px;
  background: white;
  border-radius: 16px;
  padding: 12px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.stat-box p {
  margin: 4px 0;
}

.score {
  font-size: 36px;
  font-weight: bold;
}

.big-label {
  font-size: 24px;
  font-weight: bold;
}

.small {
  font-size: 15px;
  color: #777;
}

/* The bars that fill up (level, food, fun) */
.meter {
  flex: 1;
  height: 16px;
  background: #dfe6e9;
  border-radius: 10px;
  overflow: hidden;
}

.meter-fill {
  height: 100%;
  width: 0%;
  background: #6c5ce7;
  transition: width 0.3s;
}

.care-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  font-size: 15px;
  text-align: left;
}

#mood {
  font-weight: bold;
}

#feed {
  font-size: 16px;
  padding: 6px 14px;
  background: #00b894;
  color: white;
  border: none;
  border-radius: 10px;
  cursor: pointer;
}

#feed:hover {
  background: #00a383;
}

#feed:disabled {
  background: #ccc;
  cursor: not-allowed;
}

/* ----- The yard ----- */

#yard {
  position: relative;
  height: 400px;
  overflow: hidden;
  border: 6px solid #fdcb6e;
  border-radius: 20px;
  /* Blue sky on top, green grass on the bottom */
  background: linear-gradient(#81ecec 0%, #c7f5f5 45%, #55efc4 45%, #00b894 100%);
  user-select: none;
}

/* The trees, flowers and other things in the pet's world */
#scenery,
#night {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.thing {
  position: absolute;
  line-height: 1;
}

#sun {
  position: absolute;
  right: 4%;
  top: 5%;
  font-size: 60px;
  line-height: 1;
  pointer-events: none;
  animation: sun-spin 20s linear infinite;
}

@keyframes sun-spin {
  to { transform: rotate(360deg); }
}

/* ----- Night time ----- */

/* The dark sky is invisible in the day, and fades in at night */
#night {
  z-index: 1;
  background: rgba(12, 20, 69, 0.65);
  opacity: 0;
  transition: opacity 3s;
}

#yard.night #night {
  opacity: 1;
}

#moon {
  position: absolute;
  right: 4%;
  top: 5%;
  font-size: 55px;
  line-height: 1;
  filter: drop-shadow(0 0 12px #fff9c4);
}

.star {
  position: absolute;
  color: white;
  animation: twinkle 1.5s infinite alternate;
}

@keyframes twinkle {
  from { opacity: 0.2; }
  to   { opacity: 1; }
}

.firefly {
  position: absolute;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #fff59d;
  box-shadow: 0 0 8px 4px #ffeb3b;
  animation: firefly 6s ease-in-out infinite alternate;
}

/* Fireflies wiggle around and blink */
@keyframes firefly {
  0%   { transform: translate(0, 0);       opacity: 0.2; }
  30%  { transform: translate(30px, -20px); opacity: 1; }
  60%  { transform: translate(-20px, -40px); opacity: 0.4; }
  100% { transform: translate(15px, 10px);  opacity: 1; }
}

#yard-pet {
  position: absolute;
  font-size: 70px;
  line-height: 1;
  cursor: pointer;
  z-index: 3;
}

/* The jump: go up, then come back down */
#yard-pet.jumping {
  animation: jump 0.5s ease-out;
}

@keyframes jump {
  0%   { transform: translateY(0); }
  50%  { transform: translateY(-70px); }
  100% { transform: translateY(0); }
}

#rain-banner {
  display: none;
  position: absolute;
  top: 10px;
  left: 0;
  right: 0;
  font-size: 24px;
  font-weight: bold;
  color: white;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.6);
  z-index: 4;
}

/* The treats that fall during treat rain */
.falling-treat {
  position: absolute;
  font-size: 34px;
  line-height: 1;
  z-index: 2;
}

/* The golden treat */
#golden {
  position: absolute;
  font-size: 50px;
  line-height: 1;
  cursor: pointer;
  z-index: 2;
  animation: sparkle 0.6s infinite alternate;
}

@keyframes sparkle {
  from { transform: scale(1) rotate(-10deg); filter: drop-shadow(0 0 4px gold); }
  to   { transform: scale(1.2) rotate(10deg); filter: drop-shadow(0 0 16px gold); }
}

.controls {
  color: #777;
  font-size: 15px;
}

/* Stops iPads from zooming in when you tap buttons fast */
button,
#yard-pet {
  touch-action: manipulation;
}

/* ----- Touch screen buttons ----- */

/* Hidden on computers... */
#touch-controls {
  display: none;
  justify-content: center;
  align-items: center;
  gap: 40px;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

/* ...but shown on touch screens like iPads */
@media (any-pointer: coarse) {
  #touch-controls {
    display: flex;
  }

  .controls {
    display: none;
  }
}

/* The four arrows, arranged like a plus sign */
.dpad {
  display: grid;
  grid-template-columns: 70px 70px 70px;
  grid-template-rows: 70px 70px 70px;
  gap: 4px;
}

.pad-button,
#jump-button {
  font-size: 28px;
  background: #a29bfe;
  color: white;
  border: none;
  border-radius: 16px;
  cursor: pointer;
  touch-action: none;
}

.pad-button:active,
#jump-button:active {
  background: #6c5ce7;
}

.up    { grid-column: 2; grid-row: 1; }
.left  { grid-column: 1; grid-row: 2; }
.right { grid-column: 3; grid-row: 2; }
.down  { grid-column: 2; grid-row: 3; }

#jump-button {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: #fd79a8;
  font-size: 24px;
}

#jump-button:active {
  background: #e84393;
}

/* The little "+1" that floats up when you get treats */
.pop {
  position: fixed;
  font-size: 28px;
  font-weight: bold;
  color: #e84393;
  pointer-events: none;
  z-index: 10;
  animation: float-up 0.8s forwards;
}

@keyframes float-up {
  from { opacity: 1; transform: translateY(0); }
  to   { opacity: 0; transform: translateY(-80px); }
}

/* ----- The shop and trophies ----- */

.panel {
  background: white;
  border-radius: 20px;
  padding: 20px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.panel h2 {
  margin-top: 0;
}

.upgrade {
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 100%;
  margin-bottom: 12px;
  padding: 12px;
  font-size: 16px;
  background: #a29bfe;
  color: white;
  border: none;
  border-radius: 12px;
  cursor: pointer;
}

.upgrade:hover {
  background: #6c5ce7;
}

.upgrade-name {
  font-size: 22px;
  font-weight: bold;
}

/* Gray out upgrades you can't afford yet */
.upgrade:disabled {
  background: #ccc;
  cursor: not-allowed;
}

.trophy-list {
  list-style: none;
  margin: 0;
  padding: 0;
  text-align: left;
}

.trophy-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px;
  margin-bottom: 6px;
  border-radius: 10px;
  background: #f1f2f6;
  color: #aaa;
  font-size: 14px;
}

/* Trophies you haven't won yet are gray */
.trophy-list li .trophy-emoji {
  font-size: 26px;
  filter: grayscale(1);
  opacity: 0.4;
}

/* Trophies you won turn gold! */
.trophy-list li.won {
  background: #ffeaa7;
  color: #333;
}

.trophy-list li.won .trophy-emoji {
  filter: none;
  opacity: 1;
}

/* ----- Pop-up messages ----- */

#messages {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 20;
}

.message {
  background: #6c5ce7;
  color: white;
  font-size: 20px;
  font-weight: bold;
  padding: 12px 24px;
  border-radius: 16px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  animation: slide-in 0.3s;
}

@keyframes slide-in {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}
