/* ---------- Colors ---------- */

:root {
  --red: #d63a2f;
  --dark: #3b2418;
  --cream: #fff6e6;
  --card: #ffffff;
  --gold: #f5b82e;
}


/* ---------- Page ---------- */

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Fredoka", sans-serif;
  color: var(--dark);
  /* A red and white checkered tablecloth */
  background-color: var(--cream);
  background-image: repeating-conic-gradient(#f6d9cf 0 25%, var(--cream) 0 50%);
  background-size: 64px 64px;
}

button {
  font-family: inherit;
  color: inherit;
  cursor: pointer;
}


/* ---------- The game area (kitchen + shop side by side) ---------- */

#game {
  display: flex;
  min-height: 100vh;
}


/* ---------- Left side: the kitchen ---------- */

#kitchen {
  position: relative;
  isolation: isolate;  /* keeps the falling pizzas behind everything else */
  overflow: hidden;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 24px 16px;
  text-align: center;
}

h1 {
  margin: 0;
  font-size: 44px;
  color: var(--red);
}

#money {
  margin: 8px 0 0;
  font-size: 48px;
  font-weight: 700;
}

#per-click,
#per-second {
  margin: 2px 0;
  font-size: 20px;
}

#pizza {
  margin: 24px 0 0;
  padding: 0;
  border: none;
  background: none;
  border-radius: 50%;
  transition: transform 0.08s;
}

#pizza img {
  display: block;
  width: min(360px, 80vw, 42vh);
  height: auto;
  animation: spin 60s linear infinite;
  filter: drop-shadow(0 12px 16px rgba(59, 36, 24, 0.3));
}

#pizza:hover {
  transform: scale(1.04);
}

#pizza:active {
  transform: scale(0.94);
}

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

/* The lane under the pizza where your helpers run */
#floor {
  position: relative;
  overflow: hidden;
  width: 100%;
  height: 76px;
  margin-bottom: 8px;
  border-bottom: 4px dashed rgba(59, 36, 24, 0.25);
}

#loading {
  font-size: 20px;
}

#warning {
  max-width: 360px;
  padding: 12px 16px;
  border-radius: 12px;
  background: var(--red);
  color: white;
  font-size: 18px;
}

#account {
  align-self: flex-end;
  margin: 0 0 8px;
  font-size: 17px;
}

#account a {
  color: var(--red);
  font-weight: 600;
}

#reset {
  margin-top: auto;
  padding: 6px 14px;
  border: 2px solid var(--dark);
  border-radius: 999px;
  background: var(--card);
  opacity: 0.6;
}


/* ---------- Right side: the shop ---------- */

#shop {
  width: 420px;
  height: 100vh;
  overflow-y: auto;
  padding: 16px;
  background: rgba(255, 255, 255, 0.85);
  border-left: 4px solid var(--red);
}

h2 {
  margin: 16px 0 8px;
  font-size: 24px;
  color: var(--red);
}

h2 small {
  display: block;
  font-size: 15px;
  font-weight: 400;
  color: var(--dark);
}

.card {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
  padding: 8px 12px;
  border: 2px solid var(--dark);
  border-radius: 14px;
  background: var(--card);
  text-align: left;
  box-shadow: 0 3px 0 var(--dark);
}

.card:hover:not(:disabled) {
  background: #fff3d6;
}

.card:active:not(:disabled) {
  transform: translateY(2px);
  box-shadow: 0 1px 0 var(--dark);
}

/* Too expensive right now */
.card:disabled {
  cursor: default;
  opacity: 0.45;
}

.card img {
  width: 56px;
  height: 56px;
}

.info {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.info b {
  font-size: 18px;
}

.info small {
  font-size: 15px;
}

.price {
  font-size: 16px;
  font-weight: 600;
  color: var(--red);
}

.count {
  font-size: 28px;
  font-weight: 700;
}


/* ---------- Golden pizza and popups ---------- */

#golden-pizza {
  position: fixed;
  z-index: 10;
  padding: 0;
  border: none;
  background: none;
  animation: wobble 0.6s ease-in-out infinite alternate;
}

#golden-pizza img {
  width: 120px;
}

@keyframes wobble {
  from { transform: rotate(-10deg) scale(1); }
  to   { transform: rotate(10deg) scale(1.1); }
}

.popup {
  position: fixed;
  z-index: 20;
  pointer-events: none;
  font-size: 24px;
  font-weight: 700;
  color: var(--red);
  text-shadow: 0 2px 0 white;
  transform: translate(-50%, -50%);
  animation: float-up 1s ease-out forwards;
}

@keyframes float-up {
  to {
    opacity: 0;
    transform: translate(-50%, -120px);
  }
}

/* The "hidden" attribute should always hide things */
[hidden] {
  display: none !important;
}


/* ---------- About the game (the words under the game) ---------- */

#about {
  max-width: 720px;
  margin: 0 auto;
  padding: 32px 16px;
  font-size: 18px;
  line-height: 1.6;
  background: rgba(255, 255, 255, 0.9);
}

#about h3 {
  margin-bottom: 0;
}

#about p {
  margin-top: 4px;
}

footer {
  padding: 16px;
  text-align: center;
  background: var(--red);
  color: white;
}


/* ---------- Ad spaces ---------- */

.ad {
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 24px auto;
  border: 2px dashed rgba(59, 36, 24, 0.3);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.7);
  color: rgba(59, 36, 24, 0.5);
  font-size: 14px;
}

.ad-banner {
  width: min(728px, calc(100% - 32px));
  height: 90px;
}

.ad-box {
  width: 300px;
  max-width: 100%;
  height: 250px;
}


/* ---------- Login page ---------- */

.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 16px;
}

.login-box {
  width: 100%;
  max-width: 380px;
  padding: 24px;
  border: 3px solid var(--dark);
  border-radius: 20px;
  background: var(--card);
  box-shadow: 0 6px 0 var(--dark);
  text-align: center;
  font-size: 18px;
}

.login-box form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin: 16px 0;
  text-align: left;
}

.login-box label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-weight: 600;
}

.login-box input {
  padding: 10px 12px;
  border: 2px solid var(--dark);
  border-radius: 10px;
  font: inherit;
}

.login-box button {
  padding: 12px;
  border: 2px solid var(--dark);
  border-radius: 999px;
  background: var(--red);
  color: white;
  font-size: 18px;
  font-weight: 700;
}

.login-box button.secondary {
  background: var(--card);
  color: var(--dark);
}

.login-box a {
  color: var(--red);
}

.login-error {
  padding: 10px;
  border-radius: 10px;
  background: #fde2df;
  color: var(--red);
  font-weight: 600;
}


/* ---------- Animations ---------- */

/* Bits of pizza that fly out when you click */
.crumb {
  position: fixed;
  z-index: 15;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  pointer-events: none;
  animation: crumb-fly 0.7s ease-out forwards;
}

@keyframes crumb-fly {
  to {
    opacity: 0;
    transform: translate(var(--x), var(--y)) scale(0.3);
  }
}

/* Tiny pizzas falling from the sky */
.raindrop {
  position: absolute;
  top: -60px;
  z-index: -1;
  width: 48px;
  pointer-events: none;
  opacity: 0.8;
  animation: fall var(--speed) linear forwards;
}

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

/* Helpers running and driving across the floor */
.runner,
.driver {
  position: absolute;
  bottom: 2px;
  left: -80px;
  width: 68px;
  pointer-events: none;
  animation: move-across var(--speed) linear forwards;
}

/* Runners lean forward and wiggle a little, like they're taking fast steps */
.runner {
  transform-origin: bottom center;
  animation:
    move-across var(--speed) linear forwards,
    stride 0.18s ease-in-out infinite alternate;
}

@keyframes move-across {
  to { left: 100%; }
}

@keyframes stride {
  from { rotate: 2deg; }
  to   { rotate: 10deg; }
}

/* A quick bounce (money when you click, cards when you buy) */
.pop {
  animation: pop 0.3s ease-out;
}

@keyframes pop {
  50% { transform: scale(1.12); }
}

/* Some people get dizzy from moving things. Turn the extras off for them. */
@media (prefers-reduced-motion: reduce) {
  .crumb, .raindrop, .runner, .driver {
    display: none;
  }

  #pizza img, #golden-pizza {
    animation: none;
  }
}


/* ---------- Small screens (phones) ---------- */

@media (max-width: 800px) {
  #game {
    flex-direction: column;
  }

  #shop {
    width: 100%;
    height: auto;
    border-left: none;
    border-top: 4px solid var(--red);
  }
}
