.game-page {
  --game-green: #188253;
  --game-red: #d9483d;
  --game-gold: #f2bd51;
  --game-cream: #fff6df;
  --game-ink: #17100c;
  --game-panel: #26170f;
}

.game-main {
  padding-top: clamp(1rem, 2.5vw, 2.4rem);
}

.game-heading {
  display: grid;
  grid-template-columns: minmax(260px, .75fr) minmax(380px, 1.25fr);
  align-items: end;
  gap: clamp(1rem, 4vw, 4rem);
  margin-bottom: clamp(1rem, 2vw, 1.7rem);
}

.game-heading h1 {
  margin: 0;
  font-family: Georgia, serif;
  font-size: clamp(3rem, 7vw, 6.6rem);
  line-height: .86;
  letter-spacing: -.055em;
}

.game-heading > p {
  max-width: 680px;
  margin: 0;
  color: var(--cream-deep);
  font-size: clamp(1rem, 1.5vw, 1.15rem);
}

.pizza-race {
  position: relative;
  max-width: 1180px;
  min-height: 660px;
  margin-inline: auto;
}

.game-screen {
  min-height: 660px;
  padding: clamp(1rem, 3vw, 2rem);
  overflow: hidden;
  color: var(--game-cream);
  background:
    radial-gradient(circle at 50% 0, rgba(242, 189, 81, .16), transparent 27rem),
    linear-gradient(145deg, #21140f, #100b09 68%);
  border: 1px solid rgba(221, 200, 161, .2);
  border-radius: 26px;
  box-shadow: var(--shadow);
}

.game-screen[hidden] {
  display: none !important;
}

.screen-heading {
  max-width: 720px;
  margin: 0 auto clamp(1rem, 2.2vw, 1.6rem);
  text-align: center;
}

.screen-heading h2 {
  margin: .15rem 0 .45rem;
  font-family: Georgia, serif;
  font-size: clamp(2rem, 4.5vw, 4rem);
  line-height: .98;
}

.screen-heading p:last-child {
  margin: 0;
  color: var(--cream-deep);
}

.step-label {
  margin: 0;
  color: var(--game-gold);
  font-size: .76rem;
  font-weight: 900;
  letter-spacing: .13em;
  text-transform: uppercase;
}

.opponent-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: clamp(.7rem, 2vw, 1.25rem);
  max-width: 820px;
  margin-inline: auto;
}

.opponent-card {
  display: grid;
  padding: 0 0 1rem;
  overflow: hidden;
  color: var(--game-cream);
  background: rgba(255, 255, 255, .055);
  border: 2px solid rgba(255, 255, 255, .12);
  border-radius: 22px;
  cursor: pointer;
  text-align: center;
  touch-action: manipulation;
  transition: transform .18s ease, border-color .18s ease, box-shadow .18s ease;
}

.opponent-card:hover,
.opponent-card:focus-visible {
  transform: translateY(-5px);
  border-color: var(--game-gold);
  box-shadow: 0 18px 38px rgba(0, 0, 0, .34), 0 0 0 4px rgba(242, 189, 81, .12);
  outline: none;
}

.opponent-card--left {
  background: linear-gradient(180deg, rgba(31, 108, 179, .2), rgba(255, 255, 255, .045));
}

.opponent-card--right {
  background: linear-gradient(180deg, rgba(216, 92, 103, .2), rgba(255, 255, 255, .045));
}

.opponent-portrait {
  width: 100%;
  aspect-ratio: 700 / 921;
  margin-bottom: .8rem;
  background: #392216;
  border-bottom: 1px solid rgba(255, 255, 255, .12);
}

.sprite-crop {
  position: relative;
  display: block;
  overflow: hidden;
}

.sprite-crop img {
  position: absolute;
  top: 0;
  width: 200%;
  max-width: none;
  height: 100%;
  object-fit: cover;
  object-position: center top;
}

.sprite-crop--left img {
  left: 0;
}

.sprite-crop--right img {
  left: -100%;
}

.opponent-name {
  padding-inline: .5rem;
  font-family: Georgia, serif;
  font-size: clamp(1.25rem, 3vw, 2rem);
  font-weight: 800;
}

.opponent-action {
  justify-self: center;
  margin-top: .45rem;
  padding: .3rem .7rem;
  color: #1b120d;
  background: var(--game-gold);
  border-radius: 999px;
  font-size: .72rem;
  font-weight: 900;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.pizza-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
  max-width: 920px;
  margin: 2rem auto 0;
}

.pizza-card {
  display: grid;
  justify-items: center;
  gap: .45rem;
  min-height: 260px;
  padding: 1.3rem 1rem;
  color: var(--game-cream);
  background:
    radial-gradient(circle at 50% 28%, rgba(242, 189, 81, .18), transparent 7rem),
    rgba(255, 255, 255, .055);
  border: 2px solid rgba(255, 255, 255, .13);
  border-radius: 22px;
  cursor: pointer;
  text-align: center;
  touch-action: manipulation;
  transition: transform .16s ease, border-color .16s ease, background .16s ease;
}

.pizza-card:hover,
.pizza-card:focus-visible {
  transform: translateY(-4px) rotate(-1deg);
  background-color: rgba(255, 255, 255, .1);
  border-color: var(--game-gold);
  outline: none;
}

.pizza-icon {
  font-size: clamp(4rem, 9vw, 6.5rem);
  filter: drop-shadow(0 13px 14px rgba(0, 0, 0, .34));
}

.pizza-card strong {
  font-family: Georgia, serif;
  font-size: clamp(1.25rem, 2.5vw, 1.8rem);
}

.pizza-card small {
  color: var(--cream-deep);
  font-size: .84rem;
  line-height: 1.45;
}

.race-screen {
  position: relative;
}

.race-topbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 1rem;
  padding-bottom: .8rem;
  border-bottom: 1px solid rgba(255, 255, 255, .12);
}

.race-topbar > div:first-child > span {
  color: var(--game-gold);
  font-size: .72rem;
  font-weight: 900;
  letter-spacing: .1em;
  text-transform: uppercase;
}

.race-topbar h2 {
  margin: .1rem 0 0;
  font-family: Georgia, serif;
  font-size: clamp(1.7rem, 4vw, 3rem);
}

.duel-score,
.result-scoreline,
.final-score {
  display: flex;
  align-items: center;
  gap: .65rem;
  font-weight: 800;
}

.duel-score span {
  white-space: nowrap;
}

.duel-score strong,
.result-scoreline strong,
.final-score strong {
  color: var(--game-gold);
  font-family: Georgia, serif;
  font-size: 1.8rem;
  font-variant-numeric: tabular-nums;
}

.game-status {
  min-height: 1.7em;
  margin: .8rem 0;
  color: var(--game-gold);
  font-weight: 800;
  text-align: center;
}

.opponent-kitchen {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) minmax(220px, .7fr);
  align-items: center;
  gap: 1rem;
  min-height: 220px;
  margin-bottom: .8rem;
  padding: .7rem 1rem;
  overflow: hidden;
  background: linear-gradient(115deg, rgba(255, 255, 255, .07), rgba(242, 189, 81, .1));
  border: 1px solid rgba(242, 189, 81, .24);
  border-radius: 18px;
}

.opponent-kitchen__scene {
  position: relative;
  min-height: 205px;
}

.opponent-chef {
  position: absolute;
  left: 3%;
  bottom: -42px;
  z-index: 2;
  width: 170px;
  aspect-ratio: 700 / 921;
  filter: drop-shadow(0 12px 14px rgba(0, 0, 0, .36));
  transform-origin: 55% 90%;
}

.opponent-worktop {
  position: absolute;
  left: 34%;
  bottom: 18px;
  z-index: 3;
  display: grid;
  place-items: center;
  width: 120px;
  height: 62px;
  background: #9b5d33;
  border: 6px solid #5b301c;
  border-radius: 50%;
  box-shadow: 0 18px 0 #3b2116, 0 22px 18px rgba(0, 0, 0, .35);
}

.opponent-workpiece {
  font-size: 3.3rem;
  filter: drop-shadow(0 5px 5px rgba(0, 0, 0, .3));
}

.opponent-ingredient {
  position: absolute;
  top: -68px;
  z-index: 4;
  font-size: 2.2rem;
  opacity: 0;
}

.opponent-oven {
  position: absolute;
  right: 1%;
  bottom: 8px;
  display: grid;
  place-items: center;
  width: 112px;
  height: 104px;
  color: #fff6df;
  background: radial-gradient(circle at 50% 68%, #e64d2f, #662018 46%, #271510 48%);
  border: 7px solid #8f5f3b;
  border-radius: 56px 56px 12px 12px;
  box-shadow: inset 0 0 0 4px rgba(255, 255, 255, .08), 0 12px 20px rgba(0, 0, 0, .35);
  opacity: .58;
}

.opponent-oven span {
  font-size: 2.7rem;
}

.opponent-oven small {
  font-size: .58rem;
  font-weight: 900;
  letter-spacing: .12em;
}

.opponent-kitchen > p {
  margin: 0;
  color: var(--cream-deep);
  font-size: clamp(1rem, 2.2vw, 1.3rem);
  line-height: 1.4;
}

.opponent-kitchen > p strong {
  display: block;
  margin-bottom: .2rem;
  color: var(--game-gold);
  font-family: Georgia, serif;
  font-size: clamp(1.6rem, 3vw, 2.3rem);
}

.opponent-kitchen[data-phase="dough"] .opponent-chef {
  animation: opponent-knead .48s ease-in-out infinite alternate;
}

.opponent-kitchen[data-phase="dough"] .opponent-workpiece {
  animation: dough-bounce .48s ease-in-out infinite alternate;
}

.opponent-kitchen[data-phase="toppings"] .opponent-chef {
  animation: opponent-top .7s ease-in-out infinite alternate;
}

.opponent-kitchen[data-phase="toppings"] .opponent-ingredient {
  opacity: 1;
  animation: ingredient-drop .8s ease-in infinite;
}

.opponent-kitchen[data-phase="oven"] .opponent-chef {
  animation: opponent-carry .55s ease-in-out infinite alternate;
}

.opponent-kitchen[data-phase="oven"] .opponent-workpiece {
  animation: pizza-to-oven 1.1s ease-in-out infinite;
}

.opponent-kitchen[data-phase="oven"] .opponent-oven,
.opponent-kitchen[data-phase="finished"] .opponent-oven {
  opacity: 1;
  animation: oven-glow .55s ease-in-out infinite alternate;
}

.opponent-kitchen[data-phase="finished"] .opponent-workpiece {
  opacity: 0;
}

.race-lanes {
  display: grid;
  gap: .7rem;
}

.race-lane {
  display: grid;
  grid-template-columns: 78px minmax(0, 1fr) 56px;
  align-items: center;
  gap: .8rem;
  min-height: 92px;
  padding: .55rem .8rem;
  background: rgba(255, 255, 255, .055);
  border: 1px solid rgba(255, 255, 255, .1);
  border-radius: 18px;
}

.race-lane--user {
  border-left: 6px solid var(--game-green);
}

.race-lane--opponent {
  border-left: 6px solid var(--game-red);
}

.racer-badge,
.racer-avatar {
  width: 72px;
  aspect-ratio: 1;
  overflow: hidden;
  background: #40271a;
  border: 2px solid rgba(255, 255, 255, .18);
  border-radius: 50%;
}

.racer-badge {
  display: grid;
  place-items: center;
  font-size: 2.7rem;
}

.lane-heading {
  display: flex;
  justify-content: space-between;
  gap: .8rem;
  margin-bottom: .4rem;
}

.lane-heading strong {
  font-family: Georgia, serif;
  font-size: 1.2rem;
}

.lane-heading span {
  color: var(--cream-deep);
  font-size: .82rem;
}

.progress-track {
  height: 16px;
  overflow: hidden;
  background: rgba(0, 0, 0, .36);
  border: 1px solid rgba(255, 255, 255, .08);
  border-radius: 999px;
}

.progress-track > span {
  display: block;
  width: 0;
  height: 100%;
  background: linear-gradient(90deg, var(--game-green), #56d795, var(--game-gold));
  border-radius: inherit;
  transition: width .16s ease;
}

.race-lane--opponent .progress-track > span {
  background: linear-gradient(90deg, var(--game-red), #f58b63, var(--game-gold));
}

.lane-pizza {
  font-size: 2.6rem;
  text-align: center;
  filter: drop-shadow(0 7px 8px rgba(0, 0, 0, .3));
}

.kitchen-controls {
  margin-top: .9rem;
  padding: clamp(.8rem, 2vw, 1.15rem);
  color: #2c2018;
  background: var(--game-cream);
  border-radius: 18px;
}

.recipe-strip {
  display: flex;
  align-items: baseline;
  gap: .7rem;
  padding-bottom: .75rem;
  border-bottom: 1px dashed rgba(44, 32, 24, .25);
}

.recipe-strip > span {
  flex: 0 0 auto;
  color: #8d2f29;
  font-size: .7rem;
  font-weight: 900;
  letter-spacing: .11em;
  text-transform: uppercase;
}

.recipe-strip strong {
  line-height: 1.4;
}

.control-stage {
  display: grid;
  justify-items: center;
  gap: .75rem;
  padding-top: .8rem;
  text-align: center;
}

.control-stage[hidden] {
  display: none !important;
}

.control-stage p {
  margin: 0;
}

.action-button {
  min-width: min(100%, 330px);
  min-height: 58px;
  font-size: 1rem;
  touch-action: manipulation;
}

.action-button.is-punched {
  animation: dough-punch .2s ease;
}

.topping-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: .55rem;
  width: 100%;
}

.topping-button {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: .45rem;
  min-height: 56px;
  padding: .45rem .65rem;
  color: #2c2018;
  background: #fff;
  border: 2px solid rgba(44, 32, 24, .14);
  border-radius: 12px;
  font-weight: 800;
  cursor: pointer;
  text-align: left;
  touch-action: manipulation;
}

.topping-button span {
  font-size: 1.55rem;
}

.topping-button:hover:not(:disabled),
.topping-button:focus-visible:not(:disabled) {
  border-color: var(--game-gold);
  outline: none;
}

.topping-button.is-correct {
  color: #0c5736;
  background: #dcf7e8;
  border-color: var(--game-green);
}

.topping-button.is-wrong {
  color: #8d241f;
  background: #ffe3df;
  border-color: var(--game-red);
}

.oven-button {
  background: linear-gradient(135deg, #da3c31, #8f251f);
  box-shadow: 0 10px 28px rgba(180, 46, 37, .32);
}

.round-result {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: grid;
  align-content: center;
  justify-items: center;
  padding: 1.5rem;
  color: var(--game-cream);
  background: rgba(15, 9, 7, .94);
  text-align: center;
}

.round-result[hidden] {
  display: none !important;
}

.round-result h3 {
  margin: .2rem 0 .6rem;
  font-family: Georgia, serif;
  font-size: clamp(2.2rem, 6vw, 4.6rem);
  line-height: .95;
}

.round-result > p:not(.eyebrow) {
  max-width: 540px;
  margin: 0 0 1rem;
  color: var(--cream-deep);
}

.result-scoreline {
  margin-bottom: 1.25rem;
  font-size: 1.1rem;
}

.final-screen {
  display: grid;
  grid-template-columns: minmax(250px, .7fr) minmax(320px, 1.3fr);
  align-items: center;
  gap: clamp(1.2rem, 4vw, 3rem);
}

.final-portrait {
  width: 100%;
  max-width: 390px;
  aspect-ratio: 700 / 921;
  background: #3b2418;
  border: 2px solid rgba(255, 255, 255, .13);
  border-radius: 24px;
}

.final-copy h2 {
  margin: .25rem 0 .8rem;
  font-family: Georgia, serif;
  font-size: clamp(2.4rem, 5.5vw, 5rem);
  line-height: .92;
}

.final-copy > p:not(.eyebrow) {
  max-width: 620px;
  color: var(--cream-deep);
  font-size: 1.05rem;
}

.final-score {
  margin: 1.2rem 0 1.4rem;
  font-size: 1.2rem;
}

@keyframes dough-punch {
  50% { transform: scale(.94); }
}

@keyframes opponent-knead {
  from { transform: rotate(-2deg) translateY(0); }
  to { transform: rotate(3deg) translateY(7px); }
}

@keyframes dough-bounce {
  from { transform: scale(.92) rotate(-4deg); }
  to { transform: scale(1.06) rotate(4deg); }
}

@keyframes opponent-top {
  from { transform: rotate(-3deg) translateX(0); }
  to { transform: rotate(3deg) translateX(7px); }
}

@keyframes ingredient-drop {
  0% { transform: translateY(-16px) rotate(-12deg); opacity: 0; }
  30% { opacity: 1; }
  100% { transform: translateY(62px) rotate(18deg); opacity: 0; }
}

@keyframes opponent-carry {
  from { transform: translateX(0) rotate(0); }
  to { transform: translateX(15px) rotate(3deg); }
}

@keyframes pizza-to-oven {
  0% { transform: translateX(0) scale(1); opacity: 1; }
  80% { transform: translateX(160px) translateY(-12px) scale(.7); opacity: 1; }
  100% { transform: translateX(178px) translateY(-8px) scale(.45); opacity: 0; }
}

@keyframes oven-glow {
  from { filter: brightness(.9); box-shadow: inset 0 0 0 4px rgba(255, 255, 255, .08), 0 12px 20px rgba(0, 0, 0, .35); }
  to { filter: brightness(1.18); box-shadow: inset 0 0 0 4px rgba(255, 255, 255, .12), 0 0 28px rgba(242, 189, 81, .48); }
}

@media (max-width: 760px) {
  .game-heading {
    grid-template-columns: 1fr;
    align-items: start;
  }

  .pizza-race,
  .game-screen {
    min-height: 0;
  }

  .pizza-grid {
    grid-template-columns: 1fr;
  }

  .pizza-card {
    grid-template-columns: auto 1fr;
    justify-items: start;
    min-height: 0;
    text-align: left;
  }

  .pizza-card .pizza-icon {
    grid-row: span 2;
    font-size: 3.2rem;
  }

  .race-topbar {
    align-items: start;
  }

  .duel-score {
    align-self: center;
  }

  .final-screen {
    grid-template-columns: minmax(150px, .5fr) minmax(0, 1fr);
  }

  .opponent-kitchen {
    grid-template-columns: 1fr;
  }

  .opponent-kitchen > p {
    text-align: center;
  }
}

@media (max-width: 560px) {
  .game-heading h1 {
    font-size: clamp(3rem, 18vw, 4.5rem);
  }

  .game-screen {
    padding: .7rem;
    border-radius: 18px;
  }

  .opponent-grid {
    gap: .55rem;
  }

  .opponent-card {
    border-radius: 15px;
  }

  .opponent-name {
    font-size: 1rem;
  }

  .opponent-action {
    font-size: .62rem;
  }

  .race-topbar {
    display: grid;
  }

  .duel-score {
    justify-self: stretch;
    justify-content: center;
    padding: .45rem;
    background: rgba(255, 255, 255, .06);
    border-radius: 10px;
  }

  .race-lane {
    grid-template-columns: 52px minmax(0, 1fr) 38px;
    min-height: 70px;
    padding: .42rem;
  }

  .opponent-kitchen {
    min-height: 190px;
    padding: .45rem;
  }

  .opponent-kitchen__scene {
    min-height: 168px;
  }

  .opponent-chef {
    width: 125px;
    bottom: -32px;
  }

  .opponent-worktop {
    left: 36%;
    width: 90px;
    height: 48px;
  }

  .opponent-workpiece {
    font-size: 2.5rem;
  }

  .opponent-oven {
    width: 86px;
    height: 80px;
  }

  .opponent-oven span {
    font-size: 2rem;
  }

  .racer-badge,
  .racer-avatar {
    width: 48px;
  }

  .racer-badge {
    font-size: 1.8rem;
  }

  .lane-heading {
    display: grid;
    gap: 0;
  }

  .lane-heading strong {
    font-size: 1rem;
  }

  .lane-heading span {
    font-size: .68rem;
  }

  .lane-pizza {
    font-size: 1.9rem;
  }

  .recipe-strip {
    display: grid;
    gap: .25rem;
  }

  .topping-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .topping-button {
    font-size: .72rem;
  }

  .final-screen {
    grid-template-columns: 1fr;
    text-align: center;
  }

  .final-portrait {
    width: min(70%, 280px);
    margin-inline: auto;
  }

  .final-score {
    justify-content: center;
  }
}

@media (prefers-reduced-motion: reduce) {
  .opponent-card,
  .pizza-card,
  .progress-track > span {
    transition: none;
  }

  .action-button.is-punched {
    animation: none;
  }

  .opponent-chef,
  .opponent-workpiece,
  .opponent-ingredient,
  .opponent-oven {
    animation: none !important;
  }
}

.game-page .developer-credit {
  font-size: .66rem;
  opacity: .68;
}
