/* Local visual refinement: game-style resource rail, real server-rendered values.
   Selectors stay inside the home header; no wallet/gameplay behavior is changed. */
/* Both rows share an intrinsic column: the controls define its width, never
   the balance. This keeps both edges aligned without JS or fixed guesses. */
.app-header:has(.balance-pill) {
    display: grid;
    grid-template-columns: minmax(0, 1fr) max-content;
    column-gap: 14px;
    row-gap: 0;
    align-items: center;
}

.app-header:has(.balance-pill) .header-topline {
    display: contents;
}

.app-header:has(.balance-pill) .brand {
    grid-column: 1;
    grid-row: 1 / 3;
}

.app-header:has(.balance-pill) .header-actions {
    grid-column: 2;
    grid-row: 1;
    align-self: end;
}

.app-header .balance-pill {
    grid-column: 2;
    grid-row: 2;
    align-self: start;
    min-width: 0;
    contain: inline-size;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: nowrap;
    gap: 4px;
    width: 100%;
    margin: 20px 0 0;
    padding: 0;
}

.app-header .balance-pill__item {
    position: relative;
    container-type: inline-size;
    display: flex !important;
    align-items: center;
    gap: 2px;
    min-width: 0;
    min-height: 24px;
    height: 24px;
    padding: 0 2px;
    border: 2px solid #51647a;
    border-radius: 5px;
    background: linear-gradient(180deg, #374157 0%, #30364f 45%, #252b44 100%);
    box-shadow:
        inset 0 2px 0 #708a9c,
        inset 0 -2px 0 #1b2039,
        0 2px 0 #162037;
    color: #fff !important;
    text-align: left;
    text-transform: none;
}

.app-header .balance-pill__item--boards {
    order: 1;
    flex: 0 0 26%;
}

.app-header .balance-pill__item--coins {
    order: 2;
    flex: 1 1 0;
    padding-right: 24px;
}

.app-header .balance-pill__item em {
    display: block;
    flex: 1 1 auto;
    min-width: 0;
    font-family: "Lilita One Local", sans-serif;
    font-weight: 400;
    font-style: normal;
    font-size: 16px;
    line-height: 1;
    letter-spacing: 0;
    white-space: nowrap;
    color: #fff;
    text-shadow: 0 2px 0 #192137, 1px 0 0 #192137, -1px 0 0 #192137;
    -webkit-font-smoothing: antialiased;
}

/* Only typography shrinks for unusually long balances; never abbreviate money
   or hide digits. The character count is derived from the same formatted value. */
.app-header .balance-pill__item--coins em {
    font-size: min(16px, calc((100cqi - 16px) / var(--hud-characters, 7) * 1.62));
}

.app-header .balance-pill__item--boards em {
    font-size: min(16px, calc((100cqi - 16px) / var(--hud-characters, 1) * 1.62));
    text-align: center;
}

/* Pixel coordinates from play/assets/ui/ui.webp.json, reused without drawing
   substitute emoji or downloading an external icon/font. */
.app-header .resource-hud__icon {
    display: block;
    flex: 0 0 auto;
    background-image: url("../play/assets/ui/ui.webp");
    background-repeat: no-repeat;
    filter: drop-shadow(0 1px 0 #18213b);
}

.app-header .resource-hud__icon--coin {
    width: 14.5px;
    height: 14.5px;
    background-size: 437.75px 437px;
    background-position: -421.5px -82px;
}

.app-header .resource-hud__icon--board {
    width: 14px;
    height: 18px;
    background-image: none;
}

.app-header .resource-hud__icon--board svg {
    display: block;
    width: 100%;
    height: 100%;
}

/* Opt-in game-button finish, shared by the +, deposit and game card controls.
   Future buttons can reuse this class without changing any action handlers. */
.app-header .game-bevel-button,
.game-card--quick-actions .game-bevel-button {
    border: 2px solid #345a31;
    background: linear-gradient(180deg, #9cd957 0%, #7fc440 40%, #62a52e 45%, #508e24 100%);
    box-shadow: inset 0 2px 0 #c3ed83, inset 0 -3px 0 #3b711d, 0 2px 0 #172c2f;
    color: #fff;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.app-header .game-bevel-button--deposit {
    position: relative;
    padding: 6px 11px;
    border-radius: 8px;
    text-shadow: 0 2px 0 #426d30;
    transition: transform 120ms ease;
}

.app-header .game-bevel-button--deposit:active {
    transform: translateY(2px);
    box-shadow: inset 0 1px 2px #4a8028, 0 1px 0 #172c2f;
}

.app-header .resource-hud__add {
    position: absolute;
    right: -2px;
    top: 50%;
    transform: translateY(-50%);
    display: grid;
    place-items: center;
    width: 24px;
    height: 30px;
    padding: 2px;
    border-radius: 6px;
}

.app-header .game-bevel-button::before,
.game-card--quick-actions .game-bevel-button::before {
    content: "";
    position: absolute;
    top: 3px;
    left: 5px;
    width: 7px;
    height: 3px;
    border-radius: 50%;
    background: #e3f9b6;
    opacity: .9;
    transform: rotate(-25deg);
    pointer-events: none;
}

.app-header .game-bevel-button--deposit::before {
    top: 4px;
    left: 7px;
    width: 12px;
    height: 4px;
}

.app-header .resource-hud__add svg {
    width: 17px;
    height: 17px;
    fill: none;
    stroke: currentColor;
    stroke-width: 4;
    stroke-linecap: round;
    filter: drop-shadow(0 2px 0 #426d30);
}

.app-header .resource-hud__add:active {
    transform: translateY(calc(-50% + 2px));
    box-shadow: inset 0 1px 2px #4a8028, 0 1px 0 #172c2f;
}

.app-header .game-bevel-button:focus-visible,
.game-card--quick-actions .game-bevel-button:focus-visible {
    outline: 3px solid #fff;
    outline-offset: 3px;
}

.app-header .resource-hud__label {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0;
}

@media (min-width: 992px) {
    .app-header .game-bevel-button--deposit {
        padding: 8px 18px;
        border-radius: 10px;
    }
}

