/* Blajacko - play page: neon arcade blackjack vs trash-talking AI dealers.
   Buttons ARE the craftpix blank-button art via border-image 9-slice (shared
   with the chessingo / checkerslingo / connectmore siblings). The felt table,
   cards and chips are pure CSS so they scale crisp at any size. Palette leans
   casino: felt green, corn gold, crimson red, neon accents. */

:root {
    --felt: #0e6e36;
    --felt-deep: #073d1e;
    --sky: #4da6ff;
    --lime: #4dffb0;
    --magenta: #ff4757;
    --magenta-deep: #a3112c;
    --corn: #ffd23f;
    --tangerine: #ff9f1c;
    --berry: #b34fff;
    --text: #ffffff;
    --text-dim: rgba(255, 255, 255, 0.82);
    --card-line: rgba(255, 255, 255, 0.25);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: 'Outfit', 'Segoe UI', sans-serif;
    color: var(--text);
    min-height: 100vh;
    min-height: 100dvh;
    overflow-x: hidden;
    background-color: #08120c;
    background:
        radial-gradient(circle at 100% 15%, rgba(255, 210, 63, 0.16) 0%, transparent 45%),
        radial-gradient(circle at 0% 55%, rgba(255, 71, 87, 0.12) 0%, transparent 42%),
        radial-gradient(circle at 50% 100%, rgba(77, 255, 176, 0.10) 0%, transparent 50%),
        linear-gradient(180deg, #10251a 0%, #0c1710 55%, #06100a 100%);
    background-attachment: fixed;
}

header.play-head {
    display: flex;
    align-items: center;
    gap: 0.9rem;
    flex-wrap: wrap;
    padding: 0.9rem clamp(0.8rem, 3vw, 1.4rem);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.08) 0%, rgba(255, 255, 255, 0) 100%);
    border-bottom: 1px solid rgba(255, 255, 255, 0.14);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
}
header.play-head h1.logo {
    font-weight: 400;
    font-size: clamp(1.3rem, 4vw, 1.9rem);
    letter-spacing: 0;
    line-height: 1;
    margin-right: auto;
}
header.play-head h1.logo .wm-a {
    font-family: 'Bungee', 'Arial Black', sans-serif;
    color: var(--corn);
    text-shadow: 0 0 16px rgba(255, 210, 63, 0.5);
}
header.play-head h1.logo .wm-b {
    font-family: 'Titan One', 'Arial Black', sans-serif;
    color: var(--magenta);
    text-shadow: 0 0 16px rgba(255, 71, 87, 0.45), 2px 2px 0 rgba(0, 0, 0, 0.35);
}
/* Nav links use the real craftpix blue button art (border-image 9-slice). */
header.play-head a {
    position: relative;
    text-decoration: none;
    color: #06202f;
    font-weight: 800;
    font-size: 0.82rem;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    text-align: center;
    padding: 0.05rem 0.35rem 0.15rem;
    border-style: solid;
    border-width: 13px 18px 17px 16px;
    border-image-source: url('/img/ui/btnbg-blue.png');
    border-image-slice: 40 48 52 44 fill;
    border-image-repeat: stretch;
    text-shadow: 0 1px 0 rgba(255, 255, 255, 0.4);
    filter: drop-shadow(0 3px 5px rgba(0, 0, 0, 0.35));
    transition: transform 0.07s ease, filter 0.12s ease;
}
header.play-head a:hover { filter: brightness(1.07) saturate(1.06) drop-shadow(0 4px 7px rgba(0, 0, 0, 0.4)); }
header.play-head a:active { transform: translateY(2px); filter: brightness(0.97) drop-shadow(0 2px 3px rgba(0, 0, 0, 0.35)); }

.arena {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: center;
    gap: 1.2rem;
    padding: 0.9rem clamp(0.6rem, 3vw, 1.4rem) 2rem;
    max-width: 1180px;
    margin: 0 auto;
}

.table-wrap {
    position: relative;
    flex: 1 1 460px;
    max-width: min(100%, 720px);
    margin: 0 auto;
}
@media (max-width: 780px) {
    .table-wrap { flex-basis: 100%; }
}

/* The felt: a rounded casino table with a glossy sheen. */
#felt {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 0.6rem;
    min-height: 460px;
    padding: clamp(14px, 3vw, 26px);
    border-radius: 26px;
    background:
        radial-gradient(ellipse 120% 80% at 50% 0%, rgba(255, 255, 255, 0.12) 0%, rgba(255, 255, 255, 0) 40%),
        radial-gradient(ellipse 90% 70% at 50% 45%, rgba(23, 134, 74, 0.35) 0%, rgba(14, 110, 54, 0.2) 45%, rgba(7, 61, 30, 0.55) 100%),
        url('/img/kit/felt.png') center / cover no-repeat,
        var(--felt-deep);
    box-shadow:
        0 0 0 6px #5a3a17,
        0 0 0 9px #3a2510,
        0 18px 50px rgba(0, 0, 0, 0.55),
        inset 0 2px 6px rgba(255, 255, 255, 0.22),
        inset 0 -14px 30px rgba(0, 0, 0, 0.4);
    user-select: none;
}

.hand-row { display: flex; flex-direction: column; gap: 0.5rem; }
.hand-row.dealer { align-items: flex-start; }
.hand-row.player { align-items: flex-start; }
.hand-label {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-family: 'Titan One', 'Arial Black', sans-serif;
    font-size: 0.85rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.9);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}
.val-badge {
    min-width: 1.7em;
    padding: 0.05rem 0.45rem 0.12rem;
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.25);
    font-family: 'Outfit', sans-serif;
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--corn);
    text-align: center;
}
.val-badge.bust { color: var(--magenta); }
.val-badge.blackjack { color: var(--lime); }

.cards { display: flex; gap: 0.4rem; flex-wrap: wrap; min-height: 108px; }

/* Playing cards - craftpix kit art (234x328, ratio ~0.71) rendered as <img>.
   The hole card / shoe back uses the kit's card back. */
.pcard {
    width: clamp(60px, 15vw, 76px);
    height: auto;
    aspect-ratio: 234 / 328;
    border-radius: 8px;
    filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.45));
    flex: 0 0 auto;
    display: block;
}
/* Motion is driven by fx.js flyCard() (solitaire-style fly-in from the shoe). */

/* The dealing shoe - origin of the flying-card animation. A little tilted stack
   of card backs parked in the middle of the felt. */
#shoe {
    width: clamp(54px, 13vw, 68px);
    height: auto;
    aspect-ratio: 234 / 328;
    flex: 0 0 auto;
    border-radius: 7px;
    background: url('/img/kit/cards/back.png') center / cover no-repeat;
    transform: rotate(-7deg);
    /* A thick stack of card backs so it reads as the shoe the cards fly from. */
    box-shadow:
        0 5px 12px rgba(0, 0, 0, 0.55),
        3px -3px 0 -1px #7d0d21,
        6px -6px 0 -2px #5c0a18,
        9px -9px 0 -3px #490813;
}

/* Particle layer - above the cards, below the round-result overlay. */
#fx {
    position: absolute;
    inset: 0;
    z-index: 4;
    pointer-events: none;
}

#table-center {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 1.6rem;
    position: relative;
}
#bet-display {
    font-family: 'Titan One', sans-serif;
    color: var(--corn);
    font-size: 0.95rem;
    letter-spacing: 0.05em;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
}
#bet-display .chip-dot {
    display: inline-block;
    width: 0.9rem; height: 0.9rem;
    margin-right: 0.3rem;
    border-radius: 50%;
    background: radial-gradient(circle at 40% 30%, #ffe486, #ffd23f 55%, #c8930a);
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.35), 0 2px 4px rgba(0, 0, 0, 0.5);
    vertical-align: -2px;
}

/* Round-result overlay */
#overlay {
    position: absolute;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 0.8rem;
    background: rgba(6, 16, 10, 0.82);
    border-radius: 26px;
    z-index: 5;
    text-align: center;
    padding: 1rem;
}
#overlay.show { display: flex; }
#overlay h2 { font-family: 'Titan One', 'Arial Black', sans-serif; color: var(--corn); font-size: 1.9rem; letter-spacing: 0.02em; }
#overlay h2.win { color: var(--lime); }
#overlay h2.loss { color: var(--magenta); }
#overlay p { color: var(--text-dim); max-width: 320px; }
.overlay-btns { display: flex; gap: 0.6rem; flex-wrap: wrap; justify-content: center; }
.overlay-btns .btn { width: auto; margin-top: 0; padding: 0.25rem 1.6rem 0.4rem; }
.overlay-btns .btn[hidden] { display: none; }

/* Side panel */
.panel {
    display: flex;
    flex-direction: column;
    gap: 0.9rem;
    flex: 1 1 260px;
    min-width: 240px;
    max-width: 380px;
}
@media (max-width: 780px) { .panel { max-width: none; } }
.card {
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.16) 0%, rgba(255, 255, 255, 0.04) 55%),
        rgba(14, 30, 20, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.28);
    border-radius: 18px;
    padding: 0.95rem 1.05rem 1.05rem;
    box-shadow:
        0 8px 22px rgba(0, 0, 0, 0.4),
        inset 0 1px 0 rgba(255, 255, 255, 0.35),
        inset 0 -6px 14px rgba(0, 0, 0, 0.22);
    backdrop-filter: blur(7px);
    -webkit-backdrop-filter: blur(7px);
}
.card h3 {
    font-size: 0.78rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--corn);
    margin-bottom: 0.6rem;
    text-shadow: 0 0 10px rgba(255, 210, 63, 0.5);
}
#opponent .bot-row { display: flex; align-items: center; gap: 0.7rem; }
#opponent .bot-face {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    flex: 0 0 auto;
    /* Per-persona dealer portrait, framed head-and-shoulders in the disc. The
       image is set inline by selectBot(); --bot-color tints the ring. */
    background-position: top center;
    background-size: 125% auto;
    background-repeat: no-repeat;
    background-color: #0c1710;
    border: 2px solid var(--bot-color, rgba(255, 210, 63, 0.6));
    box-shadow: inset 0 2px 3px rgba(255, 255, 255, 0.2), 0 4px 12px rgba(0, 0, 0, 0.45), 0 0 12px -2px var(--bot-color, transparent);
}
#opponent .bot-face.react { animation: bot-jolt 0.42s cubic-bezier(0.36, 0.07, 0.19, 0.97); }
@keyframes bot-jolt {
    0%, 100% { transform: translateX(0) rotate(0); }
    20% { transform: translateX(-3px) rotate(-4deg) scale(1.06); }
    45% { transform: translateX(3px) rotate(4deg) scale(1.08); }
    70% { transform: translateX(-2px) rotate(-2deg) scale(1.03); }
}
#opponent .bot-name { font-weight: 800; color: var(--corn); font-size: 1.05rem; }
#opponent .bot-tier {
    font-size: 0.8rem;
    color: var(--text-dim);
    display: flex;
    align-items: center;
    gap: 0.3rem;
    margin-top: 0.15rem;
}
#opponent .bot-tier::before {
    content: '';
    width: 1.1rem;
    height: 1.1rem;
    background: url('/img/ui/star.png') center / contain no-repeat;
    filter: drop-shadow(0 0 4px rgba(255, 210, 63, 0.6));
}

/* Live dealer speech bubble - the trash-talk headline. Pops on every new line. */
#opponent .dealer-speech {
    position: relative;
    margin-top: 0.9rem;
    padding: 0.7rem 0.85rem;
    min-height: 2.6em;
    border-radius: 12px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.16) 0%, rgba(0, 0, 0, 0.28) 100%);
    border: 1px solid rgba(255, 255, 255, 0.22);
    color: #fff;
    font-size: 1.02rem;
    line-height: 1.4;
    font-style: italic;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25), 0 4px 12px rgba(0, 0, 0, 0.35);
}
#opponent .dealer-speech:empty { display: none; }
/* little tail pointing up at the avatar */
#opponent .dealer-speech::before {
    content: '';
    position: absolute;
    top: -8px; left: 22px;
    border: 8px solid transparent;
    border-top: 0;
    border-bottom: 8px solid rgba(255, 255, 255, 0.18);
}
#opponent .dealer-speech.spicy {
    border-color: var(--magenta);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25), 0 0 16px rgba(255, 71, 87, 0.4);
    color: #fff;
    font-style: normal;
    font-weight: 600;
}
#opponent .dealer-speech.pop { animation: speech-pop 0.34s cubic-bezier(0.34, 1.56, 0.64, 1); }
@keyframes speech-pop {
    0% { transform: scale(0.82) translateY(6px); opacity: 0; }
    60% { transform: scale(1.04); }
    100% { transform: scale(1) translateY(0); opacity: 1; }
}

/* Chips bank */
.chip-count {
    font-family: 'Titan One', sans-serif;
    font-size: 1.9rem;
    color: var(--corn);
    text-shadow: 0 0 14px rgba(255, 210, 63, 0.5);
    line-height: 1;
    margin-bottom: 0.6rem;
}
.chip-count::before {
    content: '';
    display: inline-block;
    width: 1.1rem; height: 1.1rem;
    margin-right: 0.4rem;
    border-radius: 50%;
    background: radial-gradient(circle at 40% 30%, #ffe486, #ffd23f 55%, #c8930a);
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.35);
    vertical-align: -1px;
}
.bet-amount { font-size: 0.9rem; color: var(--text-dim); margin-bottom: 0.5rem; }
.bet-amount span { color: var(--corn); font-weight: 800; }
.chip-tray { display: flex; gap: 0.4rem; flex-wrap: wrap; margin-bottom: 0.6rem; }
.chip {
    width: 48px; height: 48px;
    padding: 0;
    border: none;
    background: none;
    cursor: pointer;
    transition: transform 0.08s ease, filter 0.12s ease;
    filter: drop-shadow(0 3px 6px rgba(0, 0, 0, 0.45));
}
.chip img { width: 100%; height: 100%; display: block; }
.chip:hover { transform: translateY(-2px); filter: brightness(1.08) drop-shadow(0 5px 9px rgba(0, 0, 0, 0.5)); }
.chip:active { transform: translateY(1px); }

/* Glossy candy select. */
select {
    width: 100%;
    padding: 0.6rem 0.8rem;
    border-radius: 12px;
    border: 2px solid rgba(255, 255, 255, 0.35);
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.28) 0%, rgba(255, 255, 255, 0) 48%),
        linear-gradient(180deg, #1f503a 0%, #14291f 100%);
    color: var(--text);
    font-family: inherit;
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    box-shadow: inset 0 2px 3px rgba(255, 255, 255, 0.3), inset 0 -3px 6px rgba(0, 0, 0, 0.35), 0 4px 10px rgba(0, 0, 0, 0.35);
}

/* Buttons ARE the craftpix blank button art, drawn as a border-image 9-slice. */
button.btn {
    position: relative;
    display: block;
    width: 100%;
    min-height: 20px;
    padding: 0.2rem 0.7rem 0.35rem;
    border-style: solid;
    border-width: 18px 24px 26px 22px;
    border-image-source: url('/img/ui/btnbg-grey.png');
    border-image-slice: 40 48 52 44 fill;
    border-image-repeat: stretch;
    background: transparent;
    color: #2a1a08;
    font-family: inherit;
    font-weight: 800;
    font-size: 0.98rem;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    text-align: center;
    cursor: pointer;
    text-shadow: 0 1px 0 rgba(255, 255, 255, 0.45);
    filter: drop-shadow(0 4px 7px rgba(0, 0, 0, 0.4));
    transition: transform 0.07s ease, filter 0.12s ease;
}
button.btn:hover { filter: brightness(1.07) saturate(1.06) drop-shadow(0 5px 9px rgba(0, 0, 0, 0.45)); }
button.btn:active { transform: translateY(3px); filter: brightness(0.97) drop-shadow(0 2px 4px rgba(0, 0, 0, 0.4)); }
button.btn + button.btn, button.btn + select, select + button.btn, .action-row + button.btn { margin-top: 0.6rem; }
button.btn:disabled { filter: grayscale(0.6) brightness(0.85); opacity: 0.65; cursor: not-allowed; transform: none; }

/* Colour variants = swap in the matching kit button PNG. */
button.btn.primary { border-image-source: url('/img/ui/btnbg-gold.png'); color: #2a1600; }
button.btn.go      { border-image-source: url('/img/ui/btnbg-green.png'); color: #05331f; }
button.btn.danger  { border-image-source: url('/img/ui/btnbg-red.png');  color: #fff; text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4); }

/* HIT / STAND side by side. */
.action-row { display: flex; gap: 0.6rem; margin-top: 0.6rem; }
.action-row .btn { margin-top: 0; }

#status { font-size: 0.95rem; min-height: 1.4em; }
#status .thinking { color: var(--sky); }
#status .danger { color: var(--magenta); }
#status .good { color: var(--lime); }

/* Lingo feed (trash talk) - the running transcript under the live bubble. */
#events {
    max-height: 320px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    font-size: 0.9rem;
}
#events .ev {
    padding: 0.45rem 0.6rem;
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.3);
    color: var(--text-dim);
    animation: ev-in 0.3s ease both;
}
@keyframes ev-in {
    0% { transform: translateX(-14px); opacity: 0; }
    100% { transform: translateX(0); opacity: 1; }
}
#events .ev.spicy { border-left: 3px solid var(--magenta); color: var(--text); background: rgba(255, 71, 87, 0.12); }
#events .ev-who { color: var(--corn); font-weight: 700; }

/* ==========================================================================
   FULL-VIEWPORT TABLE LAYOUT (play page only)
   Scoped via .arena-table so the rogue page's single-panel layout is untouched.
   Three columns: the dealer HERO (big persona art) on the left, the table
   centered and tall, chips + controls on the right. The persona portraits are
   the product - so we frame one large instead of a 64px thumbnail. */
.arena-table {
    display: grid;
    grid-template-columns: minmax(240px, 300px) minmax(0, 1fr) minmax(250px, 330px);
    gap: clamp(0.8rem, 1.6vw, 1.5rem);
    align-items: stretch;
    max-width: 1680px;
    min-height: calc(100dvh - 92px);
    padding: clamp(0.8rem, 2vw, 1.4rem) clamp(0.8rem, 2.4vw, 2rem) 1.6rem;
}
.arena-table .rail {
    display: flex;
    flex-direction: column;
    gap: 0.9rem;
    min-width: 0;
}
/* Center column: the table fills the full height of the grid row. */
.arena-table .table-wrap {
    flex: none;
    max-width: none;
    margin: 0;
    display: flex;
    flex-direction: column;
}
.arena-table #felt { flex: 1 1 auto; min-height: min(70dvh, 620px); }

/* Dealer HERO - GO BIG on the persona art. */
.arena-table #opponent {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}
.arena-table #opponent .dealer-cap {
    align-self: stretch;
    text-align: left;
    font-size: 0.72rem;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--corn);
    text-shadow: 0 0 10px rgba(255, 210, 63, 0.5);
    margin-bottom: 0.75rem;
}
.arena-table #opponent .bot-face {
    width: 100%;
    height: auto;
    aspect-ratio: 1 / 1;
    border-radius: 18px;
    border: 3px solid var(--bot-color, rgba(255, 210, 63, 0.6));
    background-position: top center;
    background-size: cover;
    background-repeat: no-repeat;
    background-color: #0c1710;
    box-shadow:
        inset 0 2px 4px rgba(255, 255, 255, 0.18),
        0 10px 26px rgba(0, 0, 0, 0.5),
        0 0 26px -4px var(--bot-color, transparent);
    margin-bottom: 0.85rem;
}
.arena-table #opponent .bot-name {
    font-family: 'Titan One', 'Arial Black', sans-serif;
    font-size: 1.5rem;
    line-height: 1.1;
    color: var(--corn);
    text-shadow: 0 0 14px rgba(255, 210, 63, 0.4);
}
.arena-table #opponent .bot-tier { justify-content: center; margin-top: 0.25rem; }
.arena-table #opponent .dealer-speech {
    align-self: stretch;
    text-align: left;
    margin-top: 0.9rem;
    font-size: 1.05rem;
}
/* Speech tail points up at the big avatar, roughly centred. */
.arena-table #opponent .dealer-speech::before { left: 50%; margin-left: -8px; }

/* Lingo grows to fill the rest of the left rail. */
.arena-table .lingo-card { flex: 1 1 auto; display: flex; flex-direction: column; min-height: 0; }
.arena-table .lingo-card #events { flex: 1 1 auto; max-height: none; }

/* Stack on narrower screens: table first, then dealer (compact), then controls. */
@media (max-width: 1040px) {
    .arena-table { grid-template-columns: 1fr; min-height: 0; }
    .arena-table .table-wrap { order: -1; }
    .arena-table #felt { min-height: 420px; }
    .arena-table #opponent {
        flex-direction: row;
        flex-wrap: wrap;
        align-items: center;
        text-align: left;
        gap: 0.2rem 0.9rem;
    }
    .arena-table #opponent .dealer-cap { flex: 1 1 100%; margin-bottom: 0.2rem; }
    .arena-table #opponent .bot-face { width: 118px; margin-bottom: 0; }
    .arena-table #opponent .bot-name { font-size: 1.25rem; }
    .arena-table #opponent .bot-tier { justify-content: flex-start; }
    .arena-table #opponent .dealer-speech { flex: 1 1 100%; margin-top: 0.7rem; }
    .arena-table #opponent .dealer-speech::before { left: 22px; margin-left: 0; }
    .arena-table .lingo-card #events { max-height: 260px; }
}
