
#canvas-wrapper {
  transform-origin: top left;
  width: 1050px;
  position: relative;
  left : 3%;
  right-padding: 3%;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  /* Normally invisible (the diner art covers the wrapper exactly); shows at
     the edges when the bonus zoom-out shrinks the backdrop. */
  background: #9db4b6;
}

/* Hide HUD chrome during the bonus-end freeze so the bonus-end text reads
   cleanly against the flat canvas background. The render-canvas itself swaps
   to a flat color in JS; these rules hide the score/shots overlays that sit
   on top of the canvas. */
#canvas-wrapper.frozen .shots-text,
#canvas-wrapper.frozen .score-text,
#canvas-wrapper.frozen .welcome-badge {
  display: none;
}

#canvas-wrapper canvas {
  -webkit-tap-highlight-color: transparent;
  position: relative;
  /* Above the HUD overlays (z-index 10) so flying hammos render in front of
   * the shots/score text. The canvas is transparent, so the HUD still shows
   * through wherever no hammo is drawn — the only visible effect is hammos
   * occluding the HUD as they fly past. */
  z-index: 20;
}

/* Canvas backdrops live behind the (transparent) Matter canvas inside
   #canvas-wrapper. Only one is visible at a time: the diner art during play,
   the flat color during the bonus-end freeze. Swapping which is visible is
   pure CSS — no Matter render-option fiddling. */
.canvas-bg {
  position: absolute;
  left: 0;
  top: 0;
  width: 1050px;
  height: 602px;
  z-index: 0;
  pointer-events: none;
}
.canvas-bg-diner {
  background: url('../assets/dinerandscore.png') center / cover no-repeat;
  display: block;
}
.canvas-bg-flat {
  background: #e1d4c0;
  display: none;
}
#canvas-wrapper.frozen .canvas-bg-diner { display: none; }
#canvas-wrapper.frozen .canvas-bg-flat  { display: block; }

#info-nav {
  position: absolute;
  top: 20px;
  left: 20px;
  margin: 0;
  z-index: 50;
}

p {
  margin: 0;
}

.title-text {
  font-family: 'Dosis', sans-serif;
  font-size: 24px;
}

a {
  width: 32px;
  height: 32px;

}

img  {
  margin-left: 20px;
  margin-top: 7px;
  height: 20px;
  position: absolute;
}

.portfolio-link {
  font-family: 'Dosis', sans-serif;
  position: absolute;
  width: 90px;
  margin-left: 62px;
  margin-top: 7px;
}

#title-screen {
  position: absolute;
  left: 0;
  top: 0;
  width: 1050px;
  height: 602px;
  background: #A8C5C7 url('../assets/intro2.png') center / 1050px 602px no-repeat;
  z-index: 100;
  display: block;
}

/* Goal copy overlaid on the title artwork, on the clear floor area between
   the sign legs below the START GAME button. */
#title-goal-text {
  position: absolute;
  left: 245px;
  top: 508px;
  width: 560px;
  text-align: center;
  font-family: 'Dosis', sans-serif;
  font-weight: 700;
  font-size: 21px;
  line-height: 1.3;
  color: #C8302C;
  text-shadow: 0 1px 0 rgba(255, 252, 240, 0.75);
  pointer-events: none;
}

#start-game-btn {
  position: absolute;
  left: 334px;
  top: 384px;
  width: 382px;
  height: 99px;
  background: transparent;
  border: none;
  padding: 0;
  cursor: pointer;
  font-size: 0;       /* hide the label text — the artwork provides it */
  color: transparent;
  outline: none;
}

#level-intro {
  position: absolute;
  left: 0;
  top: 0;
  width: 1050px;
  height: 602px;
  background:#e1d4c0;
  z-index: 150;
  display: none;
  align-items: center;
  justify-content: center;
}

#level-intro.active { display: flex; }

.level-intro-content {
  text-align: center;
  font-family: 'Bungee Inline', cursive;
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1.1;
}
.level-intro-title      { font-size: 72px; color: #C8302C; }
.level-intro-label      { font-size: 48px; color: #333; margin-top: 30px; }
.level-intro-img        { width: 168px; height: auto; margin-top: 35px; margin-left: 0; position: static; }
.level-intro-last-score { font-size: 32px; color: #333; margin-top: 30px; min-height: 1em; }
.level-intro-score      { font-size: 36px; color: #333; margin-top: 20px; min-height: 1em; }

@keyframes levelIntroFadeOut {
  from { opacity: 1; }
  to   { opacity: 0; }
}
#level-intro.active .level-intro-content > * {
  animation: textReveal 0.5s cubic-bezier(0.2, 0.7, 0.2, 1) both;
}
#level-intro.active .level-intro-content > *:nth-child(2) { animation-delay: 0.10s; }
#level-intro.active .level-intro-content > *:nth-child(3) { animation-delay: 0.20s; }
#level-intro.active .level-intro-content > *:nth-child(4) { animation-delay: 0.30s; }
#level-intro.active .level-intro-content > *:nth-child(5) { animation-delay: 0.40s; }

#level-intro.fading {
  animation: levelIntroFadeOut 0.5s ease-out forwards;
}

/* Bonus-ended overlay — transparent so the live (frozen) canvas shows the
   in-play objects + red circle behind the text. The render canvas swaps its
   own background to a flat #e1d4c0 in JS during freeze, so the scene reads
   cleanly without competing with the diner artwork. */
#bonus-end-screen {
  position: absolute;
  left: 0;
  top: 0;
  width: 1050px;
  height: 357px;
  background: transparent;
  z-index: 300;
  display: none;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
#bonus-end-screen.active { display: flex; }

.bonus-end-content {
  text-align: center;
  font-family: 'Bungee Inline', cursive;
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1.1;
}
.bonus-end-title    { font-size: 64px; color: #C8302C; }
.bonus-end-reason   { font-size: 36px; color: #333; margin-top: 18px; }
.bonus-end-score    { font-size: 30px; color: #333; margin-top: 24px; }
.bonus-end-total    { font-size: 30px; color: #333; margin-top: 14px; }
.bonus-end-continue { font-size: 24px; color: #333; margin-top: 28px; opacity: 0.85; }

#bonus-end-screen.active .bonus-end-content > * {
  animation: textReveal 0.5s cubic-bezier(0.2, 0.7, 0.2, 1) both;
}
#bonus-end-screen.active .bonus-end-content > *:nth-child(2) { animation-delay: 0.10s; }
#bonus-end-screen.active .bonus-end-content > *:nth-child(3) { animation-delay: 0.20s; }
#bonus-end-screen.active .bonus-end-content > *:nth-child(4) { animation-delay: 0.30s; }
#bonus-end-screen.active .bonus-end-content > *:nth-child(5) { animation-delay: 0.40s; }

/* Round-end overlay — shown when a level ends WITHOUT entering bonus mode
   (player ran out of tosses without going perfect). Same content shape as
   bonus-end-screen, but fully opaque #e1d4c0 (covers the play field rather
   than leaving objects visible). */
#round-end-screen {
  position: absolute;
  left: 0;
  top: 0;
  width: 1050px;
  height: 602px;
  background: #e1d4c0;
  z-index: 300;
  display: none;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
#round-end-screen.active { display: flex; }

#round-end-screen.active .bonus-end-content > * {
  animation: textReveal 0.5s cubic-bezier(0.2, 0.7, 0.2, 1) both;
}
#round-end-screen.active .bonus-end-content > *:nth-child(2) { animation-delay: 0.10s; }
#round-end-screen.active .bonus-end-content > *:nth-child(3) { animation-delay: 0.20s; }
#round-end-screen.active .bonus-end-content > *:nth-child(4) { animation-delay: 0.30s; }
#round-end-screen.active .bonus-end-content > *:nth-child(5) { animation-delay: 0.40s; }

#game-screen {
  margin-left: 0;
  margin-top: 80px;
}


.score-text{
  display: none;
  font-family: 'Bungee Inline', cursive;
  top: 65px;
  left: 526px;
  width: 390px;
  text-align: center;
  font-size: 29px;
  position: absolute;
  z-index: 10;
}

.score-number {
  display: inline-block;
  margin-left: 24px;
}

.shots-text {
  display: none;
  font-family: 'Bungee Inline', cursive;
  top: 65px;
  left: 138px;
  width: 390px;
  text-align: center;
  font-size: 29px;
  position: absolute;
  z-index: 10;
}

.shots-number {
  display: inline-block;
  margin-left: 16px;
}

.bonus-text {
  display: none;
  position: relative;
}

.welcome-badge {
  position: absolute;
  top: 138px;
  left: 478px;
  width: 100px;
  text-align: center;
  font-family: 'Bungee Inline', cursive;
  font-size: 14px;
  color: #000000c2;
  letter-spacing: 3px;
  z-index: 10;
}

@keyframes bonusPulse {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.4); }
  100% { transform: scale(1); }
}

@keyframes bonusRainbow {
  0%   { background-position: 0% 50%; }
  100% { background-position: 200% 50%; }
}

.bonus-text.celebrate .bonus-label {
  transform-origin: left center;
  animation: bonusPulse 1.17s cubic-bezier(0.2, 0.7, 0.2, 1),
             bonusRainbow 1.17s linear;
  background: linear-gradient(
    90deg,
    #ff4d4d, #ffae3d, #ffe14d, #6BE36B, #4dd2ff, #b066ff, #ff4d4d
  );
  background-size: 200% 100%;
  -webkit-background-clip: text;
          background-clip: text;
  -webkit-text-fill-color: transparent;
          color: transparent;
}

.spark {
  position: absolute;
  left: 60px;
  top: 20px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #FFD24A;
  box-shadow: 0 0 6px #FFD24A;
  pointer-events: none;
  animation: sparkFly 0.91s ease-out forwards;
}

@keyframes sparkFly {
  0% {
    transform: translate(0, 0) scale(1);
    opacity: 1;
  }
  100% {
    transform: translate(var(--dx, 0), var(--dy, 0)) scale(0.3);
    opacity: 0;
  }
}

.bonus-label {
  color: #C8302C;
  font-family: 'Bungee Inline', cursive;
  font-size: 29px;
}

.bonus-explainer {
  position: absolute;
  top: 122px;
  left: 0;
  width: auto;
  text-align: center;
  font-family: 'Bungee Inline', cursive;
  font-size: 26px;
  color: #C8302C;
  line-height: 1.1;
}

.bonus-timer {
  font-size: 22px;
  font-weight: 400;
  margin-top: 27px;
  color: #C8302C;
  line-height: 1.1;
  display: none;
}

.bonus-timer.active {
  display: block;
}

.shots-text.bonus .shots-label,
.shots-text.bonus .shots-number {
  display: none;
}

.shots-text.bonus .bonus-text {
  display: block;
}

#ending-screen {
  position: absolute;
  left: 0;
  top: 0;
  width: 1050px;
  height: 602px;
  background: #e1d4c0;
  z-index: 100;
  display: none;
  align-items: center;
  justify-content: center;
}

.ending-screen-text {
  font-family: 'Bungee Inline', cursive;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1.1;
  gap: 28px;
}

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

.ending-screen-text > * {
  animation: textReveal 0.45s cubic-bezier(0.2, 0.7, 0.2, 1) both;
}

.ending-screen-text > *:nth-child(2) { animation-delay: 0.08s; }

.ending-screen-text > *:nth-child(3) { animation-delay: 0.16s; }

.ending-screen-text > *:nth-child(4) { animation-delay: 0.24s; }

.ending-screen-text > *:nth-child(5) { animation-delay: 0.32s; }

/* Two-column body of the game-complete screen: run results on the left,
   leaderboard panel on the right. */
.ending-columns {
  display: flex;
  gap: 44px;
  align-items: center;
  justify-content: center;
}

.ending-main {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
}

.ending-main .ending-score-text {
  margin-top: 0;
  font-size: 34px;
}

.ending-main .high-score-text {
  font-size: 22px;
}

/* Leaderboard panel. Clicks inside must not restart the game — JS stops
   propagation, this just makes the cursor honest. */
.leaderboard-panel {
  width: 320px;
  box-sizing: border-box;
  padding: 14px 18px 16px;
  border: 3px solid #C8302C;
  border-radius: 12px;
  background: #f2e7d3;
  cursor: default;
  text-align: center;
}

.leaderboard-title {
  font-size: 24px;
  color: #C8302C;
}

.leaderboard-list {
  list-style: none;
  margin: 10px 0 0;
  padding: 0;
  font-family: 'Dosis', sans-serif;
  font-weight: 700;
  font-size: 16px;
  color: #333;
  text-align: left;
}

.leaderboard-list li {
  display: flex;
  gap: 10px;
  align-items: baseline;
  padding: 1px 6px;
}

.lb-rank {
  width: 20px;
  font-family: 'Bungee Inline', cursive;
  font-size: 12px;
  color: #C8302C;
}

.lb-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lb-score {
  font-family: 'Bungee Inline', cursive;
  font-size: 13px;
}

.leaderboard-you {
  background: #ffe9a8;
  border-radius: 6px;
}

.leaderboard-empty {
  justify-content: center;
  color: #7a6a52;
}

.leaderboard-entry-form {
  display: none;  /* shown by JS when the score makes the cut */
  margin-top: 10px;
  font-family: 'Dosis', sans-serif;
}

.leaderboard-entry-prompt {
  font-size: 18px;
  font-weight: 700;
  color: #C8302C;
  margin-bottom: 8px;
}

#leaderboard-name {
  width: 110px;
  box-sizing: border-box;
  padding: 6px 10px;
  font-family: 'Dosis', sans-serif;
  font-weight: 700;
  font-size: 22px;
  letter-spacing: 6px;
  text-transform: uppercase;
  text-align: center;
  color: #333;
  background: #fffbef;
  border: 2px solid #C8302C;
  border-radius: 8px;
  outline: none;
}

.leaderboard-entry-buttons {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-top: 8px;
}

.leaderboard-entry-buttons button {
  font-family: 'Bungee Inline', cursive;
  font-size: 15px;
  padding: 6px 16px;
  border: 2px solid #C8302C;
  border-radius: 8px;
  cursor: pointer;
}

#leaderboard-save {
  background: #C8302C;
  color: #fffbef;
}

#leaderboard-skip {
  background: transparent;
  color: #C8302C;
}

/* Title-screen leaderboard: a button in the corner of the artwork opens a
   dimmed overlay reusing the leaderboard-panel styles. */
#title-leaderboard-btn {
  position: absolute;
  right: 28px;
  bottom: 22px;
  font-family: 'Bungee Inline', cursive;
  font-size: 17px;
  color: #fffbef;
  background: #C8302C;
  border: 3px solid #7e1f1c;
  border-radius: 10px;
  padding: 8px 16px;
  cursor: pointer;
}

#title-leaderboard {
  position: absolute;
  left: 0;
  top: 0;
  width: 1050px;
  height: 602px;
  background: rgba(30, 20, 15, 0.55);
  z-index: 120;
  display: none;
  align-items: center;
  justify-content: center;
}

#title-leaderboard.active { display: flex; }

.leaderboard-close {
  margin-top: 12px;
  font-family: 'Bungee Inline', cursive;
  font-size: 16px;
  color: #C8302C;
  background: transparent;
  border: 2px solid #C8302C;
  border-radius: 8px;
  padding: 5px 18px;
  cursor: pointer;
}

/* Per-object score breakdown on the game-complete screen. */
.ending-breakdown {
  display: flex;
  gap: 26px;
  justify-content: center;
}

.breakdown-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 12px 20px;
  min-width: 140px;
  border: 3px solid #C8302C;
  border-radius: 12px;
  background: #f2e7d3;
}

.breakdown-img {
  position: static;  /* the global img rule sets absolute — undo it */
  margin: 0;
  height: 42px;
  width: auto;
}

.breakdown-object { font-size: 17px; color: #333; }
.breakdown-run    { font-size: 34px; color: #C8302C; line-height: 1; }
.breakdown-best   { font-size: 14px; color: #7a6a52; }

.game-over-text {
  font-size: 72px;
  color: #C8302C;
}

.ending-score-text {
  margin-top: 16px;
  font-size: 48px;
  color: #333;
}

.high-score-text {
  font-size: 36px;
  color: #C8302C;
}

/* Play Again / Main Menu on the game-complete screen (replaces the old
   click-anywhere / any-key restart). */
.ending-buttons {
  display: flex;
  gap: 22px;
  justify-content: center;
  align-items: center;
  margin-top: 10px;
}

#play-again-btn {
  font-family: 'Bungee Inline', cursive;
  font-size: 30px;
  color: #fffbef;
  background: #C8302C;
  border: 4px solid #7e1f1c;
  border-radius: 14px;
  padding: 14px 40px;
  cursor: pointer;
}

#main-menu-btn {
  font-family: 'Bungee Inline', cursive;
  font-size: 20px;
  color: #C8302C;
  background: transparent;
  border: 3px solid #C8302C;
  border-radius: 12px;
  padding: 12px 24px;
  cursor: pointer;
}

.high-score-number {
  display: inline-block;
  margin-left: 24px;
}

@media (pointer: coarse) {
  html, body {
    overflow-x: hidden;
  }

  #game-screen {
    margin-top: 56px;
  }

  #canvas-wrapper {
    left: 0;
  }

  #info-nav {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    padding: 6px 16px;
    background: #ffffff;
    box-sizing: border-box;
    z-index: 200;
  }
}

/* Ending-screen readability at phone scale: the fixed 1050px layout gets
   CSS-scaled to ~0.35x on portrait phones, so text set for desktop becomes
   unreadably small. Bump relative sizes and tighten gaps on touch devices
   and small windows (both mean a heavily scaled-down canvas). */
@media (pointer: coarse), (max-width: 700px) {
  .ending-screen-text { gap: 14px; }
  .ending-screen-text > .game-over-text { font-size: 46px; }
  .ending-buttons { gap: 16px; margin-top: 4px; }
  #play-again-btn { font-size: 26px; padding: 12px 30px; }
  #main-menu-btn { font-size: 18px; padding: 10px 20px; }
  .ending-columns { gap: 26px; }
  .ending-main { gap: 14px; }
  .ending-main .ending-score-text { font-size: 30px; }
  .ending-main .high-score-text { font-size: 20px; }
  .breakdown-card { min-width: 118px; padding: 8px 12px; gap: 3px; }
  .breakdown-img { height: 34px; }
  .breakdown-object { font-size: 14px; }
  .breakdown-run { font-size: 26px; }
  .breakdown-best { font-size: 12px; }
  .leaderboard-panel { width: 380px; padding: 12px 16px 14px; }
  .leaderboard-title { font-size: 26px; }
  .leaderboard-list { font-size: 21px; }
  .leaderboard-list li { gap: 12px; padding: 2px 6px; }
  .lb-rank { font-size: 15px; width: 26px; }
  .lb-score { font-size: 17px; }
  .leaderboard-entry-prompt { font-size: 20px; }
  #leaderboard-name { font-size: 26px; width: 120px; }
  .leaderboard-entry-buttons button { font-size: 17px; padding: 7px 18px; }
}
