/* -------------------------------------------------------------------
   END-OF-GAME RESULT SCREEN

   A DOM layer drawn over the game canvas when the GameOver layout
   starts. It replaces the old "Game Over -> Leaderboard" screen with
   the win / lose card, the player's score, and the Try Again / Exit
   buttons.

   GEOMETRY
   The artwork was cut from a 2940 x 5225 design canvas (the same 9:16
   shape as the game's 720 x 1280 project), so every piece is placed as
   a percentage of that canvas and the whole layer is stretched over the
   canvas rect by scripts/result-screen.js. Percentages therefore hold
   at any screen size - to move a piece, re-measure it against the
   design canvas and divide by 2940 (x) or 5225 (y).
   ------------------------------------------------------------------- */

.pb-result {
    position: fixed;
    /* Placed over the game canvas from JS; these are only a sane start. */
    left: 0; top: 0; width: 100%; height: 100%;
    z-index: 2147481500;
    overflow: hidden;
    background: #0b1030 center/cover no-repeat url("images/result-bg.webp");
    /* Stops a tap on the card being passed through as a game touch, and
       kills the 300ms delay / double-tap zoom on the buttons. */
    touch-action: manipulation;
    -webkit-user-select: none;
    user-select: none;
    opacity: 0;
    transition: opacity .18s ease;
}
.pb-result.is-open { opacity: 1; }
.pb-result[hidden] { display: none; }

/* Every child is positioned against the design canvas. */
.pb-result__card,
.pb-result__player,
.pb-result__score,
.pb-result__btn {
    position: absolute;
    margin: 0;
    padding: 0;
}

.pb-result__card,
.pb-result__player,
.pb-result__btn img {
    display: block;
    width: 100%;
    height: 100%;
    /* The art is already the right shape; never let it letterbox itself. */
    object-fit: fill;
    pointer-events: none;
}

/* --- the win / lose card --------------------------------------------
   The two cards are different sizes, so each gets its own box. The lose
   card includes the sad player, which is why it is so much taller.     */
.pb-result--lose .pb-result__card {
    left: 18.027%; top: 31.081%; width: 72.041%; height: 53.512%;
}
.pb-result--win .pb-result__card {
    left: 19.286%; top: 31.598%; width: 61.973%; height: 26.775%;
}

/* --- the score, dropped into the card's empty panel ------------------
   The band sits between the "YOUR SCORE" label and the line underneath
   it; both cards put those in the same place, so one box serves both.
   50.31% is the card's centre, not the screen's. Font size is set from
   JS so it tracks the canvas height. */
.pb-result__score {
    left: 50.31%;
    top: 45.742%;
    height: 8.038%;
    width: 60%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Arial Black', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    font-weight: 900;
    line-height: 1;
    color: #fff;
    text-shadow: 0 0 .18em rgba(0, 0, 0, .55);
    white-space: nowrap;
}

/* --- the celebrating player, win screen only -------------------------
   Sized by height and centred; the width follows from the art. It sits
   in the gap the win card leaves above the buttons.                    */
.pb-result__player {
    display: none;
    left: 50%;
    bottom: 15.407%;
    height: 25.263%;
    width: auto;
    transform: translateX(-50%);
}
.pb-result--win .pb-result__player { display: block; }

/* --- buttons --------------------------------------------------------- */
.pb-result__btn {
    top: 84.861%;
    height: 7.943%;
    border: 0;
    background: none;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: transform .08s ease, filter .08s ease;
}
.pb-result__btn--again { left: 8.639%;  width: 41.837%; }
.pb-result__btn--exit  { left: 51.463%; width: 41.803%; }

.pb-result__btn:active { transform: scale(.95); filter: brightness(1.15); }
.pb-result__btn[disabled] { opacity: .6; pointer-events: none; }

/* --- while the score is still being saved ---------------------------- */
.pb-result__status {
    position: absolute;
    left: 0; right: 0;
    top: 45%;
    text-align: center;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    font-size: min(4vw, 2.25vh);
    font-weight: 600;
    letter-spacing: .04em;
    color: #ffd54a;
    text-shadow: 0 .15em .4em rgba(0, 0, 0, .7);
}

/* The pieces are hidden until the result is known, so the screen never
   shows the wrong card for a frame. */
.pb-result:not(.pb-result--win):not(.pb-result--lose) .pb-result__card,
.pb-result:not(.pb-result--win):not(.pb-result--lose) .pb-result__score,
.pb-result:not(.pb-result--win):not(.pb-result--lose) .pb-result__btn {
    visibility: hidden;
}
.pb-result--win  .pb-result__status,
.pb-result--lose .pb-result__status {
    display: none;
}
