/* Higher or Lower — the parts of the board that are not Bingo's (content/higher-lower-board.js).
   The setup card, the full-screen stage, the buttons, the result styles and the pills come from
   content/bingo-board.css (#hlApp shares its variables); this file adds the cards, the row
   strip. The playing-card faces are the only new colours. */

#hlApp { --hl-ink: #1F1438; --hl-red: #D63B4A; }

/* ── Setup ─────────────────────────────────────────────────────────────── */
.hl-setup { display: grid; gap: 4px; max-width: 640px; margin: 0 auto; }
.hl-setup > .bg-row { margin: 8px 0 2px; }
.hl-setup .bg-names { margin: 6px 0 8px; }
.hl-setup > .bgh-head { margin-bottom: 6px; }
.hl-actions { margin: 18px 0 4px; }
.hl-setup > .bg-resume { margin: 10px 0 0; }

/* ── Stage ─────────────────────────────────────────────────────────────── */
.hl-stage { grid-template-rows: auto minmax(0, 1fr) auto; }
.hl-mid { grid-template-columns: minmax(0, 1fr); min-height: 0; }
.hl-stage .bgs-top { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; }
.hl-stage .bgs-acts { justify-self: end; }

/* Caller, top centre: the name and Hangman's dice to pick another. */
.hl-who { display: flex; align-items: center; justify-content: center; gap: 12px; min-width: 0; min-height: 44px; }
.hl-who-name { font: 800 clamp(1.5rem, 4vh, 2.4rem)/1 var(--bg-font-display); color: var(--bg-green); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 40vw; }
.hl-who-dice {
    flex: none; display: grid; place-items: center; width: 44px; height: 44px; padding: 0; border-radius: 50%;
    border: 1px solid rgba(255,255,255,.35); background: transparent; color: #fff; cursor: pointer;
}
.hl-who-dice:hover { background: rgba(255,255,255,.12); }
.bg-dice { width: 24px; height: 24px; fill: currentColor; }
.bg-dice rect { fill: none; stroke: currentColor; stroke-width: 2; }

/* Full-screen icon: Hangman's corner arrows. */
.hl-fs svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; display: block; }
.hl-fs .hl-fs-exit, .hl-fs.is-full .hl-fs-enter { display: none; }
.hl-fs.is-full .hl-fs-exit { display: block; }
.hl-main { display: grid; align-content: center; justify-items: center; gap: 1.8vh; min-height: 0; min-width: 0; }
.hl-toast {
    position: absolute; left: 50%; bottom: 4vh; transform: translateX(-50%); z-index: 20;
    padding: 10px 20px; border-radius: 14px; background: rgba(16,8,34,.92); border: 1px solid rgba(255,255,255,.25);
    font: 800 1.05rem/1.2 var(--bg-font-body); color: #fff;
}

/* The two cards: the current one face up, the next one face down beside it. */
.hl-cards { display: flex; align-items: flex-end; justify-content: center; gap: clamp(16px, 4vw, 56px); }
.hl-slot { position: relative; display: grid; justify-items: center; }
.hl-slot.is-tap { cursor: pointer; }

.hl-card {
    --w: min(21vh, 24vw, 230px);
    position: relative; width: var(--w); aspect-ratio: 5 / 7; border-radius: calc(var(--w) * .07);
    background: #fff; color: var(--hl-ink); box-shadow: 0 1.2vh 1.6vh rgba(0,0,0,.4);
    display: grid; place-items: center; overflow: hidden;
}
.hl-card.is-small { --w: clamp(34px, 5.4vh, 64px); box-shadow: 0 .3vh .5vh rgba(0,0,0,.3); }

.hl-face { position: absolute; inset: 0; color: var(--hl-ink); font-family: var(--bg-font-display); }
.hl-face.is-red, .hl-suit.is-red { color: var(--hl-red); }
.hl-corner { position: absolute; display: grid; justify-items: center; line-height: 1; font-weight: 800; font-size: calc(var(--w) * .22); }
.hl-corner span + span { font-size: .8em; }
.hl-tl { top: 6%; left: 8%; }
.hl-br { bottom: 6%; right: 8%; transform: rotate(180deg); }
.hl-pip { position: absolute; inset: 0; display: grid; place-items: center; font-size: calc(var(--w) * .56); line-height: 1; }
.is-small .hl-corner { font-size: calc(var(--w) * .34); }
.is-small .hl-pip { display: none; }

.hl-card--back {
    background:
        repeating-linear-gradient(45deg, rgba(255,255,255,.12) 0 2px, transparent 2px 10px),
        repeating-linear-gradient(-45deg, rgba(255,255,255,.12) 0 2px, transparent 2px 10px),
        linear-gradient(160deg, #8F45FF, #4A3590);
    border: clamp(4px, .9vh, 10px) solid #fff;
    transition: transform .38s ease;
}
.hl-card--back.is-turning { animation: hl-away .38s ease-in both; }
@keyframes hl-away { to { transform: perspective(900px) rotateY(90deg); } }

/* The turned card: green for a right call (drops into place), red for a wrong one (shakes). */
.hl-card.is-right { box-shadow: 0 0 0 .8vh var(--bg-green), 0 0 5vh rgba(61,220,132,.6); }
.hl-card.is-wrong { box-shadow: 0 0 0 .8vh #FF4D5E, 0 0 5vh rgba(255,77,94,.6); }
.hl-card.is-anim-drop { animation: hl-drop .55s cubic-bezier(.3,1.4,.5,1) both; }
.hl-card.is-anim-wrong { animation: hl-turn .3s ease-out both, hl-shake .5s .3s ease-in-out; }
@keyframes hl-drop { 0% { transform: translateY(-14vh) perspective(900px) rotateY(90deg); opacity: 0; } 60% { opacity: 1; } 100% { transform: none; opacity: 1; } }
@keyframes hl-turn { from { transform: perspective(900px) rotateY(90deg); } to { transform: none; } }
@keyframes hl-shake { 0%, 100% { transform: none; } 20% { transform: translateX(-1.4vh) rotate(-2deg); } 40% { transform: translateX(1.4vh) rotate(2deg); } 60% { transform: translateX(-1vh); } 80% { transform: translateX(.8vh); } }

.hl-badge {
    position: absolute; top: -1.6vh; right: -1.6vh; z-index: 2; width: 6vh; height: 6vh; min-width: 34px; min-height: 34px;
    display: grid; place-items: center; border-radius: 50%; font: 900 clamp(1.2rem, 3.4vh, 2rem)/1 var(--bg-font-display);
    color: #1F1438; box-shadow: 0 .6vh 1.2vh rgba(0,0,0,.4);
}
.hl-badge.is-right { background: var(--bg-green); }
.hl-badge.is-wrong { background: #FF4D5E; color: #fff; }
.hl-badge.is-go { background: var(--bg-gold); }

/* A broken row: the cards fall away, left to right. */
.hl-card.is-falling { animation: hl-fall .9s ease-in both; animation-delay: calc(var(--i, 0) * 90ms + .5s); }
@keyframes hl-fall { 0% { transform: none; opacity: 1; } 100% { transform: translateY(34vh) rotate(var(--r, 12deg)); opacity: 0; } }

.hl-won { margin: 0; font-size: clamp(2rem, 6vh, 3.4rem); }

.hl-controls { justify-content: center; }
.hl-call:disabled { opacity: .4; }
.hl-flip { min-width: 7em; }

/* ── Row strip ─────────────────────────────────────────────────────────── */
.hl-strip { display: flex; justify-content: center; align-items: center; gap: clamp(4px, .8vw, 10px); padding-bottom: 2px; min-height: clamp(48px, 8vh, 90px); }
.hl-strip[hidden] { display: none; }
.hl-strip-slot { display: grid; place-items: center; }
.hl-strip-slot.is-empty { width: clamp(34px, 5.4vh, 64px); aspect-ratio: 5 / 7; border: 2px dashed rgba(255,255,255,.22); border-radius: 8px; }

@media (max-width: 860px) {
    .hl-stage .bgs-top { grid-template-columns: 1fr auto; }
    .hl-who { grid-column: 1 / -1; grid-row: 2; }
    .hl-cards { gap: 14px; }
}
@media (prefers-reduced-motion: reduce) {
    .hl-card, .hl-card--back.is-turning { animation: none !important; }
}
