:root {
    --chain-green: #74ff42;
    --chain-cyan: #41e9ff;
    --chain-purple: #a64dff;
    --chain-red: #ff4f72;
    --chain-yellow: #ffe65c;
}

.chain-status-bar {
    position: relative;
    z-index: 5;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    margin-top: 12px;
    overflow: hidden;
    border: 1px solid rgba(77, 255, 104, .26);
    border-radius: 13px;
    background:
        linear-gradient(
            180deg,
            rgba(4, 14, 9, .94),
            rgba(1, 7, 4, .97)
        );
    box-shadow:
        0 22px 65px rgba(0, 0, 0, .43),
        0 0 30px rgba(69, 255, 105, .07),
        inset 0 1px rgba(255, 255, 255, .035);
}

.chain-stat {
    min-height: 70px;
    padding: 13px 16px;
    border-right: 1px solid rgba(77, 255, 104, .13);
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.chain-stat:last-child {
    border-right: 0;
}

.chain-stat span {
    color: #718179;
    font-size: 7px;
    font-weight: 950;
    letter-spacing: .14em;
    text-transform: uppercase;
}

.chain-stat strong {
    display: block;
    margin-top: 6px;
    overflow: hidden;
    color: white;
    font-size: 12px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chain-stat strong.green {
    color: var(--chain-green);
    text-shadow: 0 0 12px rgba(76, 255, 96, .24);
}

.chain-stat strong.cyan {
    color: var(--chain-cyan);
}

.chain-action {
    min-height: 34px;
    margin-top: 7px;
    padding: 0 10px;
    border: 1px solid rgba(76, 255, 99, .38);
    border-radius: 6px;
    color: var(--chain-green);
    background: rgba(69, 255, 95, .035);
    font-size: 8px;
    font-weight: 950;
    text-transform: uppercase;
}

.chain-modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 3000;
    padding: 18px;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(0, 1, 4, .80);
    backdrop-filter: blur(16px);
}

.chain-modal-backdrop.open {
    display: flex;
}

.chain-modal {
    width: min(520px, 100%);
    max-height: min(760px, calc(100vh - 36px));
    overflow-y: auto;
    border: 1px solid rgba(90, 255, 111, .32);
    border-radius: 18px;
    background:
        radial-gradient(
            circle at 90% 5%,
            rgba(113, 47, 255, .15),
            transparent 35%
        ),
        linear-gradient(
            180deg,
            rgba(7, 12, 24, .99),
            rgba(2, 7, 10, .99)
        );
    box-shadow:
        0 45px 140px rgba(0, 0, 0, .72),
        0 0 44px rgba(79, 255, 103, .10),
        inset 0 1px rgba(255, 255, 255, .04);
}

.chain-modal-head {
    min-height: 72px;
    padding: 17px 19px;
    border-bottom: 1px solid rgba(82, 255, 103, .15);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 15px;
}

.chain-modal-head span {
    color: var(--chain-green);
    font-size: 8px;
    font-weight: 950;
    letter-spacing: .15em;
    text-transform: uppercase;
}

.chain-modal-head h2 {
    margin: 5px 0 0;
    font-size: 21px;
    font-style: italic;
    text-transform: uppercase;
}

.chain-modal-close {
    width: 37px;
    height: 37px;
    border: 1px solid rgba(255, 255, 255, .10);
    border-radius: 8px;
    color: white;
    background: rgba(255, 255, 255, .025);
}

.chain-modal-body {
    padding: 19px;
}

.chain-field {
    margin-top: 17px;
}

.chain-field:first-child {
    margin-top: 0;
}

.chain-field label {
    display: block;
    margin-bottom: 8px;
    color: #7e8a9e;
    font-size: 8px;
    font-weight: 950;
    letter-spacing: .12em;
    text-transform: uppercase;
}

.stake-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.stake-option {
    min-height: 51px;
    padding: 7px;
    border: 1px solid rgba(126, 71, 255, .25);
    border-radius: 8px;
    color: #b7bfd0;
    background: rgba(255, 255, 255, .018);
    font-size: 10px;
    font-weight: 950;
}

.stake-option:hover,
.stake-option.active {
    border-color: rgba(74, 255, 96, .61);
    color: var(--chain-green);
    background: rgba(67, 255, 93, .055);
    box-shadow:
        0 0 19px rgba(71, 255, 95, .10);
}

.chain-summary {
    margin-top: 17px;
    padding: 14px;
    border: 1px solid rgba(64, 224, 255, .16);
    border-radius: 9px;
    background: rgba(53, 212, 244, .025);
}

.chain-summary-row {
    min-height: 31px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    color: #8690a6;
    font-size: 9px;
    text-transform: uppercase;
}

.chain-summary-row strong {
    color: white;
}

.chain-modal-actions {
    display: flex;
    gap: 9px;
    margin-top: 19px;
}

.chain-submit,
.chain-secondary {
    min-height: 47px;
    padding: 0 17px;
    border-radius: 8px;
    font-size: 9px;
    font-weight: 950;
    letter-spacing: .05em;
    text-transform: uppercase;
}

.chain-submit {
    flex: 1;
    border: 1px solid rgba(78, 255, 99, .64);
    color: var(--chain-green);
    background: rgba(72, 255, 95, .055);
    box-shadow:
        0 0 24px rgba(72, 255, 95, .10);
}

.chain-submit:disabled {
    cursor: wait;
    opacity: .46;
}

.chain-secondary {
    border: 1px solid rgba(144, 78, 255, .35);
    color: #cea6ff;
    background: rgba(144, 78, 255, .035);
}

.chain-transaction {
    display: none;
    margin-top: 16px;
    padding: 13px;
    border: 1px solid rgba(71, 225, 255, .18);
    border-radius: 8px;
    background: rgba(57, 215, 245, .025);
    color: #90a3ad;
    font-size: 9px;
    line-height: 1.6;
    word-break: break-word;
}

.chain-transaction.visible {
    display: block;
}

.chain-transaction.error {
    border-color: rgba(255, 76, 109, .25);
    color: #ff91a5;
    background: rgba(255, 76, 109, .035);
}

.chain-transaction.success {
    border-color: rgba(75, 255, 101, .26);
    color: var(--chain-green);
    background: rgba(75, 255, 101, .035);
}

.real-match-row {
    min-height: 66px;
    display: grid;
    grid-template-columns:
        minmax(95px, .72fr)
        minmax(100px, .75fr)
        minmax(120px, 1fr)
        minmax(82px, .6fr)
        auto;
    gap: 11px;
    align-items: center;
    padding: 10px 8px;
    border-bottom: 1px solid rgba(126, 68, 255, .12);
}

.real-match-row:last-child {
    border-bottom: 0;
}

.real-match-row strong {
    display: block;
    font-size: 11px;
}

.real-match-row span {
    display: block;
    margin-top: 3px;
    color: #626b81;
    font-size: 7px;
    font-weight: 850;
    letter-spacing: .05em;
    text-transform: uppercase;
}

.real-match-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    justify-content: flex-end;
}

.real-match-action {
    min-height: 31px;
    padding: 0 10px;
    border: 1px solid rgba(75, 255, 99, .40);
    border-radius: 5px;
    color: var(--chain-green);
    background: rgba(70, 255, 94, .035);
    font-size: 7px;
    font-weight: 950;
    text-transform: uppercase;
}

.real-match-action.cyan {
    border-color: rgba(65, 229, 255, .42);
    color: var(--chain-cyan);
    background: rgba(60, 225, 255, .035);
}

.real-match-action.purple {
    border-color: rgba(160, 74, 255, .43);
    color: #d19bff;
    background: rgba(151, 69, 255, .035);
}

.real-match-action.red {
    border-color: rgba(255, 77, 110, .43);
    color: #ff839b;
    background: rgba(255, 73, 108, .035);
}

.real-match-action:disabled {
    cursor: wait;
    opacity: .42;
}

.chain-empty {
    min-height: 180px;
    padding: 30px 18px;
    display: grid;
    place-items: center;
    text-align: center;
}

.chain-empty strong {
    display: block;
    color: white;
    font-size: 16px;
    font-style: italic;
    text-transform: uppercase;
}

.chain-empty p {
    max-width: 410px;
    margin: 8px auto 0;
    color: #717b91;
    font-size: 8px;
    line-height: 1.7;
    text-transform: uppercase;
}

.chain-loading {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--chain-cyan);
    font-size: 8px;
    font-weight: 950;
    text-transform: uppercase;
}

.chain-loading::before {
    content: "";
    width: 11px;
    height: 11px;
    border: 2px solid rgba(64, 226, 255, .20);
    border-top-color: var(--chain-cyan);
    border-radius: 50%;
    animation: chainSpin .8s linear infinite;
}

@keyframes chainSpin {
    to {
        transform: rotate(360deg);
    }
}

@media (max-width: 900px) {
    .chain-status-bar {
        grid-template-columns: 1fr 1fr;
    }

    .chain-stat:nth-child(2) {
        border-right: 0;
    }

    .chain-stat:nth-child(n+3) {
        border-top: 1px solid rgba(77, 255, 104, .13);
    }

    .real-match-row {
        grid-template-columns: 1fr auto;
    }

    .real-match-row > div:nth-child(2),
    .real-match-row > div:nth-child(3),
    .real-match-row > div:nth-child(4) {
        display: none;
    }
}

@media (max-width: 620px) {
    .stake-grid {
        grid-template-columns: 1fr 1fr;
    }

    .chain-status-bar {
        grid-template-columns: 1fr;
    }

    .chain-stat {
        border-right: 0;
        border-top: 1px solid rgba(77, 255, 104, .13);
    }

    .chain-stat:first-child {
        border-top: 0;
    }

    .chain-modal-actions {
        flex-direction: column;
    }
}

/* =========================================================
   CHAIN INTEGRATION — VISIBILITY AND FAILURE STATES
   ========================================================= */

.chain-boot-error {
    margin-top: 10px;
    padding: 13px 15px;
    border: 1px solid rgba(255, 78, 110, .34);
    border-radius: 9px;
    color: #ff9aae;
    background: rgba(255, 73, 108, .055);
    font-size: 9px;
    font-weight: 850;
    line-height: 1.6;
    text-transform: uppercase;
}

.chain-boot-error strong {
    display: block;
    margin-bottom: 4px;
    color: white;
}

#chainStatusBar {
    animation: chainStatusEnter .35s ease both;
}

@keyframes chainStatusEnter {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.wallet-button.wallet-busy {
    cursor: wait;
    color: var(--chain-cyan);
    border-color: rgba(65, 229, 255, .58);
    box-shadow:
        0 0 23px rgba(65, 229, 255, .17),
        inset 0 0 18px rgba(65, 229, 255, .035);
}

.wallet-button.wallet-connected {
    color: var(--chain-green);
}

.wallet-button.wallet-error {
    color: #ff8da3;
    border-color: rgba(255, 75, 108, .54);
}

@media (max-width: 620px) {
    .chain-status-bar {
        border-radius: 10px;
    }

    .chain-stat {
        min-height: 59px;
        padding: 10px 12px;
    }
}

/* =========================================================
   LIVE FLOOR — MANUAL AND AUTOMATIC MATCH REFRESH
   ========================================================= */

.chain-lobby-controls {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 8px;
}

.chain-refresh-button {
    min-height: 47px;
    padding: 0 16px;
    border: 1px solid rgba(61, 226, 255, .48);
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    color: var(--chain-cyan);
    background:
        linear-gradient(
            180deg,
            rgba(55, 221, 255, .075),
            rgba(45, 126, 153, .025)
        );
    box-shadow:
        0 0 22px rgba(57, 220, 255, .10),
        inset 0 0 18px rgba(57, 220, 255, .025);
    font-size: 8px;
    font-weight: 950;
    letter-spacing: .055em;
    text-transform: uppercase;
    transition: .18s ease;
}

.chain-refresh-button:hover {
    transform: translateY(-1px);
    border-color: rgba(61, 226, 255, .75);
    box-shadow:
        0 0 28px rgba(57, 220, 255, .17),
        inset 0 0 18px rgba(57, 220, 255, .035);
}

.chain-refresh-button:disabled {
    cursor: wait;
    opacity: .68;
}

.refresh-symbol {
    display: inline-block;
    color: var(--chain-cyan);
    font-size: 16px;
    line-height: 1;
    text-shadow:
        0 0 10px rgba(65, 229, 255, .75);
}

.chain-refresh-button.refreshing .refresh-symbol {
    animation: chainRefreshSpin .75s linear infinite;
}

.chain-last-updated {
    min-height: 27px;
    padding: 7px 15px 5px;
    color: #69768a;
    background: rgba(1, 7, 4, .67);
    font-size: 7px;
    font-weight: 850;
    letter-spacing: .08em;
    text-align: right;
    text-transform: uppercase;
}

@keyframes chainRefreshSpin {
    to {
        transform: rotate(360deg);
    }
}

@media (max-width: 680px) {
    .chain-lobby-controls {
        width: 100%;
        justify-content: stretch;
    }

    .chain-lobby-controls > button {
        flex: 1;
    }

    .chain-last-updated {
        text-align: left;
    }
}
