.bat-widget {
    --bat-bg: #0f1720;
    --bat-bg-2: #182434;
    --bat-panel: rgba(10, 17, 26, 0.92);
    --bat-border: rgba(178, 205, 232, 0.18);
    --bat-text: #e8f3ff;
    --bat-muted: #98a9bf;
    --bat-glow: rgba(58, 191, 255, 0.55);
    --bat-accent: #76d7ff;
    --bat-warning: #ffcf5c;
    --bat-danger: #ff7580;
    --bat-success: #71f6b0;
    --bat-cell-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06), inset 0 -10px 24px rgba(0, 0, 0, 0.28);
    color: var(--bat-text);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    margin: 1.5rem 0;
}

.bat-widget *,
.bat-widget *::before,
.bat-widget *::after {
    box-sizing: border-box;
}

.bat-shell {
    position: relative;
    overflow: hidden;
    border-radius: 24px;
    border: 1px solid var(--bat-border);
    background:
        radial-gradient(circle at top left, rgba(124, 224, 255, 0.16), transparent 34%),
        radial-gradient(circle at bottom right, rgba(118, 215, 255, 0.12), transparent 28%),
        linear-gradient(145deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.01) 30%, rgba(0, 0, 0, 0.12)),
        linear-gradient(180deg, var(--bat-bg-2), var(--bat-bg));
    box-shadow:
        0 24px 48px rgba(0, 0, 0, 0.32),
        inset 0 1px 0 rgba(255, 255, 255, 0.08),
        inset 0 -18px 48px rgba(0, 0, 0, 0.22);
    padding: 1.5rem;
}

.bat-shell::before {
    content: "";
    position: absolute;
    inset: 0;
    background:
        linear-gradient(115deg, rgba(255, 255, 255, 0.08), transparent 35%),
        repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.01), rgba(255, 255, 255, 0.01) 2px, transparent 2px, transparent 8px);
    pointer-events: none;
}

.bat-header,
.bat-footer-panel {
    position: relative;
    z-index: 1;
}

.bat-header {
    display: flex;
    gap: 1.25rem;
    align-items: flex-start;
    justify-content: space-between;
    flex-wrap: wrap;
    margin-bottom: 1.25rem;
}

.bat-kicker {
    margin: 0 0 0.35rem;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    font-size: 0.72rem;
    color: var(--bat-accent);
}

.bat-title {
    margin: 0;
    font-size: clamp(1.45rem, 2vw, 2rem);
    line-height: 1.1;
}

.bat-subtitle {
    margin: 0.45rem 0 0;
    max-width: 56ch;
    color: var(--bat-muted);
}

.bat-display-cluster {
    display: grid;
    grid-template-columns: repeat(3, minmax(110px, 1fr));
    gap: 0.75rem;
    min-width: min(100%, 420px);
}

.bat-display-card {
    position: relative;
    overflow: hidden;
    border-radius: 16px;
    padding: 0.85rem 1rem;
    border: 1px solid rgba(118, 215, 255, 0.16);
    background:
        linear-gradient(180deg, rgba(10, 18, 30, 0.9), rgba(4, 9, 16, 0.96));
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.04),
        inset 0 -18px 28px rgba(0, 0, 0, 0.28);
}

.bat-display-card::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.08), transparent 45%);
    pointer-events: none;
}

.bat-display-card strong {
    display: block;
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
    font-size: 1.2rem;
    color: #dff7ff;
    text-shadow: 0 0 14px rgba(118, 215, 255, 0.24);
}

.bat-display-card--accent strong {
    color: #feecad;
    text-shadow: 0 0 14px rgba(255, 207, 92, 0.24);
}

.bat-display-label {
    display: inline-block;
    margin-bottom: 0.4rem;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    font-size: 0.72rem;
    color: var(--bat-muted);
}

.bat-board-wrap {
    position: relative;
    z-index: 1;
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.03), transparent 18%),
        linear-gradient(180deg, rgba(9, 16, 26, 0.88), rgba(4, 8, 14, 0.96));
    padding: 1rem;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04), inset 0 -24px 36px rgba(0, 0, 0, 0.24);
}

.bat-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 0.55rem;
    margin-bottom: 0.9rem;
}

.bat-legend-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.42rem 0.75rem;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.04);
    color: var(--bat-muted);
    font-size: 0.85rem;
}

.bat-legend-pill--ready {
    color: #dff7ff;
    border-color: rgba(118, 215, 255, 0.16);
    box-shadow: inset 0 0 0 1px rgba(118, 215, 255, 0.04), 0 0 18px rgba(58, 191, 255, 0.08);
}

.bat-board {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.bat-row {
    display: grid;
    grid-template-columns: minmax(78px, 96px) repeat(var(--bat-columns), minmax(44px, 1fr));
    gap: 0.6rem;
    align-items: stretch;
}

.bat-row--operandB {
    padding-bottom: 0.7rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    margin-bottom: 0.05rem;
}

.bat-row--result {
    margin-top: 0.1rem;
}

.bat-row--carry {
    margin-top: 0.15rem;
    padding-top: 0.7rem;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.bat-row-label {
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 14px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.035);
    color: var(--bat-muted);
    font-size: 0.85rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.bat-cell {
    position: relative;
    min-height: 66px;
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.06), transparent 30%),
        linear-gradient(180deg, rgba(19, 30, 45, 0.92), rgba(10, 16, 24, 0.96));
    box-shadow: var(--bat-cell-shadow);
}

.bat-cell--weight {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.14rem;
    min-height: 54px;
    color: var(--bat-muted);
}

.bat-weight-power {
    font-size: 0.83rem;
    font-weight: 700;
}

.bat-weight-value {
    font-size: 0.72rem;
    opacity: 0.9;
}

.bat-cell--static {
    display: flex;
    align-items: center;
    justify-content: center;
}

.bat-bit {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 0;
    cursor: default;
    appearance: none;
    color: inherit;
    font: inherit;
}

.bat-bit--interactive {
    cursor: pointer;
    transition: transform 0.14s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.bat-bit--interactive:hover,
.bat-bit--interactive:focus-visible {
    transform: translateY(-1px);
    border-color: rgba(118, 215, 255, 0.28);
    outline: none;
    box-shadow:
        var(--bat-cell-shadow),
        0 0 0 1px rgba(118, 215, 255, 0.12),
        0 0 22px rgba(58, 191, 255, 0.12);
}

.bat-bit:disabled {
    opacity: 0.88;
}

.bat-bezel,
.bat-glow {
    position: absolute;
    inset: 10px;
    border-radius: 13px;
    pointer-events: none;
}

.bat-bezel {
    border: 1px solid rgba(255, 255, 255, 0.05);
    background:
        linear-gradient(180deg, rgba(0, 0, 0, 0.18), rgba(255, 255, 255, 0.02)),
        radial-gradient(circle at 50% 18%, rgba(255, 255, 255, 0.08), transparent 42%);
}

.bat-glow {
    inset: 18px;
    background: radial-gradient(circle, rgba(118, 215, 255, 0.18), transparent 62%);
    opacity: 0.25;
}

.bat-digit {
    position: relative;
    z-index: 1;
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
    font-size: clamp(1.18rem, 2vw, 1.5rem);
    font-weight: 700;
    letter-spacing: 0.05em;
    text-shadow: 0 0 12px rgba(118, 215, 255, 0.18);
}

.bat-bit[data-value="1"] .bat-digit,
.bat-cell--static .bat-digit {
    color: #dff7ff;
}

.bat-bit[data-value="0"] .bat-digit {
    color: #95a6bc;
}

.bat-bit[data-value="1"] .bat-glow {
    opacity: 0.82;
    background: radial-gradient(circle, rgba(118, 215, 255, 0.55), rgba(118, 215, 255, 0.14) 45%, transparent 68%);
}

.bat-bit--locked {
    border-style: dashed;
}

.bat-cell--current {
    border-color: rgba(255, 207, 92, 0.35);
    box-shadow:
        var(--bat-cell-shadow),
        0 0 0 1px rgba(255, 207, 92, 0.12),
        0 0 18px rgba(255, 207, 92, 0.14);
}

.bat-cell--correct {
    border-color: rgba(113, 246, 176, 0.4) !important;
    box-shadow:
        var(--bat-cell-shadow),
        0 0 0 1px rgba(113, 246, 176, 0.12),
        0 0 22px rgba(113, 246, 176, 0.12);
}

.bat-cell--correct .bat-glow {
    opacity: 0.8;
    background: radial-gradient(circle, rgba(113, 246, 176, 0.44), rgba(113, 246, 176, 0.12) 42%, transparent 68%);
}

.bat-cell--incorrect {
    border-color: rgba(255, 117, 128, 0.42) !important;
    box-shadow:
        var(--bat-cell-shadow),
        0 0 0 1px rgba(255, 117, 128, 0.12),
        0 0 22px rgba(255, 117, 128, 0.12);
}

.bat-cell--incorrect .bat-glow {
    opacity: 0.55;
    background: radial-gradient(circle, rgba(255, 117, 128, 0.36), rgba(255, 117, 128, 0.08) 44%, transparent 68%);
}

.bat-footer-panel {
    display: grid;
    grid-template-columns: 1.1fr minmax(260px, 0.9fr);
    gap: 1rem;
    margin-top: 1.1rem;
}

.bat-status-box {
    border-radius: 18px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.04);
    padding: 1rem 1rem 1.05rem;
}

.bat-status,
.bat-explanation {
    margin: 0;
}

.bat-status {
    font-weight: 700;
}

.bat-status[data-tone="neutral"] {
    color: var(--bat-text);
}

.bat-status[data-tone="success"] {
    color: var(--bat-success);
}

.bat-status[data-tone="error"] {
    color: var(--bat-danger);
}

.bat-explanation {
    margin-top: 0.55rem;
    color: var(--bat-muted);
}

.bat-controls {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.65rem;
}

.bat-button {
    appearance: none;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 14px;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.07), rgba(255, 255, 255, 0.02)),
        linear-gradient(180deg, rgba(17, 28, 42, 0.95), rgba(9, 14, 22, 0.95));
    color: var(--bat-text);
    padding: 0.82rem 0.95rem;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05), 0 8px 18px rgba(0, 0, 0, 0.18);
    transition: transform 0.14s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.bat-button:hover,
.bat-button:focus-visible {
    transform: translateY(-1px);
    border-color: rgba(118, 215, 255, 0.3);
    outline: none;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05), 0 10px 22px rgba(0, 0, 0, 0.22), 0 0 22px rgba(58, 191, 255, 0.08);
}

.bat-button--accent {
    border-color: rgba(255, 207, 92, 0.24);
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.07), rgba(255, 255, 255, 0.02)),
        linear-gradient(180deg, rgba(43, 34, 13, 0.95), rgba(30, 24, 8, 0.95));
}

.bat-widget--solved .bat-shell {
    box-shadow:
        0 24px 48px rgba(0, 0, 0, 0.32),
        inset 0 1px 0 rgba(255, 255, 255, 0.08),
        inset 0 -18px 48px rgba(0, 0, 0, 0.22),
        0 0 0 1px rgba(113, 246, 176, 0.12),
        0 0 28px rgba(113, 246, 176, 0.12);
}

@media (max-width: 920px) {
    .bat-footer-panel {
        grid-template-columns: 1fr;
    }

    .bat-controls {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (max-width: 760px) {
    .bat-shell {
        padding: 1rem;
        border-radius: 18px;
    }

    .bat-display-cluster {
        grid-template-columns: 1fr;
        min-width: 0;
        width: 100%;
    }

    .bat-row {
        grid-template-columns: 68px repeat(var(--bat-columns), minmax(38px, 1fr));
        gap: 0.4rem;
    }

    .bat-cell {
        min-height: 56px;
        border-radius: 13px;
    }

    .bat-row-label {
        font-size: 0.75rem;
        letter-spacing: 0.05em;
    }

    .bat-weight-value {
        display: none;
    }

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

@media (max-width: 520px) {
    .bat-board-wrap {
        padding: 0.75rem;
    }

    .bat-row {
        grid-template-columns: 58px repeat(var(--bat-columns), minmax(30px, 1fr));
        gap: 0.32rem;
    }

    .bat-cell {
        min-height: 48px;
        border-radius: 11px;
    }

    .bat-bezel {
        inset: 6px;
    }

    .bat-glow {
        inset: 12px;
    }

    .bat-button {
        padding: 0.72rem 0.75rem;
        font-size: 0.95rem;
    }
}
