/* Crash Rocket — what only Crash needs on top of Kit/kit.css: the dock. */

.crash-dock {
    flex: none;
    position: relative;
    z-index: 10;
    display: grid;
    /* Rows never shrink: on a phone the dock scrolls instead (see below). */
    grid-auto-rows: max-content;
    gap: 10px;
    padding: 10px 16px calc(12px + env(safe-area-inset-bottom));
    border-top: 2px solid var(--line);
    background: var(--bg);
}

.arcade-app[data-mode="attract"] .crash-dock {
    display: none;
}

/* History: one pill per round, newest first. */

.crash-history {
    display: flex;
    gap: 6px;
    overflow: hidden;
    mask-image: linear-gradient(to right, #000 85%, transparent);
    -webkit-mask-image: linear-gradient(to right, #000 85%, transparent);
}

.crash-pill {
    flex: none;
    padding: 4px 8px;
    border: 2px solid var(--line);
    font-family: var(--pixel);
    font-size: 9px;
    line-height: 1.2;
    white-space: nowrap;
}

.crash-pill.is-low { color: var(--bad); }
.crash-pill.is-good { color: var(--good); }
.crash-pill.is-hot { color: var(--wild); border-color: var(--wild); box-shadow: 0 0 8px var(--glow); }
.crash-pill.is-cashed { background: color-mix(in srgb, var(--good) 14%, transparent); }
.crash-pill.is-empty { color: var(--dim); }

/* The fairness check: quiet, so it never reads as "won". */
.crash-pill i {
    margin-left: 4px;
    font-style: normal;
    color: var(--dim);
}

/* Pilots in a lobby. */

.crash-pilots {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 6px;
}

.crash-pilots[hidden] {
    display: none;
}

.crash-pilot {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    column-gap: 4px;
    padding: 5px 8px;
    border: 2px solid var(--line);
    font-size: 18px;
    line-height: 1.1;
    min-width: 0;
}

.crash-pilot.is-you {
    border-color: var(--fg);
    box-shadow: 0 0 8px var(--glow);
}

.crash-pilot.is-away {
    opacity: 0.5;
}

.crash-pilot.is-empty {
    color: var(--dim);
    border-style: dashed;
    grid-template-columns: 1fr;
}

.crash-pilot-name {
    font-family: var(--pixel);
    font-size: 9px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.crash-pilot-balance,
.crash-pilot-status {
    grid-column: 1 / -1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.crash-pilot-balance {
    color: var(--dim);
}

.crash-pilot-status.is-placed { color: var(--fg); }
.crash-pilot-status.is-cashed { color: var(--good); }
.crash-pilot-status.is-lost { color: var(--bad); }
.crash-pilot-status.is-none { color: var(--dim); }

/* The controls. */

.crash-controls {
    display: grid;
    grid-template-columns: minmax(150px, 1fr) minmax(190px, 1.2fr) minmax(220px, 1.4fr) minmax(190px, 1.2fr);
    gap: 10px 16px;
    align-items: stretch;
}

.crash-cell {
    display: grid;
    align-content: start;
    gap: 6px;
    min-width: 0;
}

.crash-label {
    font-family: var(--pixel);
    font-size: 9px;
    color: var(--dim);
    text-transform: uppercase;
}

.crash-balance {
    font-family: var(--pixel);
    font-weight: 400;
    font-size: 16px;
    line-height: 1.3;
    text-shadow: 0 0 8px var(--glow);
    white-space: nowrap;
}

.crash-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
}

.crash-row .arcade-seg-btn {
    min-height: 32px;
    padding: 6px 9px;
    font-size: 9px;
}

.crash-auto-row .crash-number {
    flex: 1;
    min-width: 0;
}

.crash-number {
    min-height: 36px;
    font-size: 13px;
}

.crash-number.is-off {
    color: var(--dim);
}

.crash-number:disabled,
.crash-dock.is-locked .crash-cell .arcade-seg-btn:not([data-do="refuel"]):not([data-do="copy"]):not([data-do="leave"]):not([data-do="autobet"]):not([data-do="autorefuel"]) {
    opacity: 0.45;
}

.crash-lobby-chip {
    display: inline-flex;
    gap: 6px;
}

.crash-lobby-chip[hidden] {
    display: none;
}

.crash-lobby-chip [data-code] {
    letter-spacing: 0.15em;
    color: var(--wild);
}

.crash-refuel:not(:disabled) {
    border-color: var(--good);
    color: var(--good);
    animation: arcade-blink 1s steps(1) infinite;
}

.crash-refuel:disabled {
    opacity: 0.35;
    cursor: var(--cur-arrow, not-allowed);
}

/* The big button. */

.crash-action-cell {
    align-content: stretch;
}

.crash-action {
    display: grid;
    place-content: center;
    gap: 6px;
    min-height: 72px;
    height: 100%;
    font-size: 15px;
}

.crash-action small {
    font-family: var(--text);
    font-size: 20px;
    text-transform: none;
    letter-spacing: 0;
}

.crash-action small:empty {
    display: none;
}

.crash-action[data-kind="cashout"] {
    border-color: var(--good);
    color: var(--bg);
    background: var(--good);
    box-shadow: 0 0 18px var(--good);
    animation: crash-pulse 0.6s ease-in-out infinite alternate;
}

.crash-action[data-kind="cancel"] {
    border-color: var(--bad);
    color: var(--bad);
}

.crash-action[data-kind="done"] {
    border-color: var(--good);
    color: var(--good);
}

.crash-action:disabled,
.crash-action:disabled:hover {
    opacity: 0.6;
    background: rgba(0, 0, 0, 0.45);
    color: var(--dim);
    cursor: var(--cur-arrow, default);
    box-shadow: none;
}

.crash-action[data-kind="done"]:disabled {
    color: var(--good);
    opacity: 1;
}

@keyframes crash-pulse {
    from { box-shadow: 0 0 8px var(--good); }
    to { box-shadow: 0 0 26px var(--good); }
}

.crash-hint {
    text-align: center;
    font-family: var(--pixel);
    font-size: 8px;
    color: var(--dim);
}

.crash-hint:empty {
    display: none;
}

/* Smaller screens: two columns, the button on its own row. */

@media (max-width: 900px) {
    .crash-controls {
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    }

    .crash-action-cell {
        grid-column: 1 / -1;
        order: -1;
    }

    .crash-action {
        min-height: 58px;
    }

    .crash-pilots {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

/* Phones: the scene keeps at least ~44% of the height; the dock scrolls
   instead, with the big button near its top. */
@media (max-width: 560px) {
    .crash-dock {
        max-height: 56vh;
        max-height: 56dvh;
        overflow-y: auto;
        overscroll-behavior: contain;
        padding: 8px 10px calc(10px + env(safe-area-inset-bottom));
        gap: 8px;
    }

    .crash-pilot {
        padding: 3px 6px;
        font-size: 16px;
    }

    .crash-pilot.is-empty {
        display: none;
    }

    .crash-action {
        min-height: 52px;
        gap: 3px;
        font-size: 13px;
    }

    .crash-action small {
        font-size: 17px;
    }

    .crash-controls {
        gap: 8px 10px;
    }

    .crash-cell:nth-child(3) {
        grid-column: 1 / -1;
    }

    .crash-balance {
        font-size: 13px;
    }

    .crash-hint {
        display: none;
    }
}

@media (max-height: 520px) and (orientation: landscape) {
    .crash-history {
        display: none;
    }

    .crash-action {
        min-height: 48px;
    }
}
