/* ── Balance Scale Widget ──────────────────────────────────────────── */
.ama-balance-scale-widget {
    --abs-primary:  #c2410c;
    --abs-dark:     #9a3412;
    --abs-light:    #fff7ed;
    --abs-green:    #16a34a;
    --abs-red:      #dc2626;
    --abs-known:    #2563eb;
    --abs-unknown:  #7c3aed;
    --abs-beam:     #78350f;
    --abs-radius:   14px;
    font-family: 'Segoe UI', Arial, sans-serif;
    position: relative;
    background: #fff;
    border-radius: var(--abs-radius);
    box-shadow: 0 4px 24px rgba(0,0,0,.10);
    overflow: hidden;
    max-width: 860px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
}

/* ── Header ───────────────────────────────────────────────────────── */
.abs-header {
    background: var(--abs-primary);
    color: #fff;
    padding: 12px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
}
.abs-title { font-size: 1.1rem; font-weight: 700; white-space: nowrap; }
.abs-controls { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; flex: 1; justify-content: flex-end; }

.abs-ctrl-label {
    font-size: .78rem;
    color: rgba(255,255,255,.85);
    display: flex;
    align-items: center;
    gap: 5px;
}
.abs-diff-sel {
    background: rgba(255,255,255,.2);
    color: #fff;
    border: 1px solid rgba(255,255,255,.35);
    border-radius: 6px;
    padding: 4px 6px;
    font-size: .78rem;
    cursor: pointer;
}
.abs-diff-sel option { background: var(--abs-dark); }

.abs-btn {
    background: #fddd54;
    color: #5a3e00;
    border: none;
    border-radius: 8px;
    padding: 7px 14px;
    font-size: .82rem;
    font-weight: 700;
    cursor: pointer;
    transition: filter .15s;
}
.abs-btn:hover { filter: brightness(1.08); }
.abs-btn-new { padding: 5px 10px; font-size: .78rem; }

.abs-stats { display: flex; align-items: center; gap: 4px; font-size: .88rem; color: #fff; font-weight: 700; }
.abs-sep { opacity: .5; margin: 0 2px; }

/* ── Body ─────────────────────────────────────────────────────────── */
.abs-body { flex: 1; overflow-y: auto; min-height: 0; }

/* Equation text */
.abs-eq-display {
    text-align: center;
    font-size: 1.7rem;
    font-weight: 800;
    color: var(--abs-dark);
    padding: 18px 24px 10px;
    letter-spacing: .5px;
    font-variant-numeric: tabular-nums;
}

/* ── Scale visual ─────────────────────────────────────────────────── */
.abs-scale-wrap {
    padding: 0 16px 8px;
}

.abs-beam-area {
    position: relative;
    height: 40px;
}

.abs-beam-bar {
    position: absolute;
    left: 5%;
    right: 5%;
    top: calc(50% - 6px);
    height: 12px;
    background: linear-gradient(to bottom, #a16207, var(--abs-beam));
    border-radius: 6px;
    transform-origin: center center;
    transform: rotate(0deg);
    transition: transform 0.55s cubic-bezier(0.34, 1.56, 0.64, 1);
    box-shadow: 0 3px 7px rgba(0,0,0,.25);
}

/* Small pegs hanging from each beam end */
.abs-hook {
    position: absolute;
    bottom: -12px;
    width: 3px;
    height: 12px;
    background: #888;
    border-radius: 0 0 2px 2px;
}
.abs-hook-l { left: 4px; }
.abs-hook-r { right: 4px; }

/* Pivot dot at center */
.abs-pivot-dot {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 16px;
    height: 16px;
    background: #3f3f46;
    border-radius: 50%;
    z-index: 2;
    border: 2.5px solid #fff;
    box-shadow: 0 1px 4px rgba(0,0,0,.3);
}

/* Pans row — margin-top must be large enough that tilted beam ends
   never overlap the pan boxes (beam ends swing into this buffer space) */
.abs-pans-area {
    display: flex;
    align-items: flex-start;
    gap: 0;
    margin-top: 72px;
}

.abs-pan-wrap {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

/* Fulcrum post + triangle */
.abs-fulcrum-col {
    flex-shrink: 0;
    width: 36px;
    display: flex;
    flex-direction: column;
    align-items: center;
}
.abs-post {
    width: 8px;
    height: 100px;    /* 92px gap + 8px anchor below */
    margin-top: -92px; /* pull top up to pivot dot level */
    background: #888;
    border-radius: 3px;
}
.abs-base-tri {
    font-size: 1.8rem;
    color: #666;
    line-height: 1;
    margin-top: -6px;
}

/* Pan containers */
.abs-pan {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    justify-content: center;
    align-content: flex-start;
    padding: 10px 8px;
    background: var(--abs-light);
    border: 2.5px solid #e2c5a5;
    border-radius: 12px;
    min-height: 72px;
    width: 100%;
}

.abs-pan-label {
    font-size: .78rem;
    font-weight: 700;
    color: #a86030;
    letter-spacing: .3px;
}

/* ── Blocks ───────────────────────────────────────────────────────── */
.abs-block {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .95rem;
    font-weight: 900;
    flex-shrink: 0;
    box-sizing: border-box;
}

/* Known block: solid blue */
.abs-known {
    background: var(--abs-known);
    border: 2px solid #1d4ed8;
    box-shadow: 0 2px 0 #1d4ed8;
}

/* Unknown/mystery block: purple with ? */
.abs-unknown {
    background: var(--abs-unknown);
    border: 2px solid #6d28d9;
    box-shadow: 0 2px 0 #6d28d9;
    color: #fff;
    font-size: 1rem;
}

/* Weight bag for counts > 12 */
.abs-weight-bag {
    background: #f3f4f6;
    border: 2.5px dashed #9ca3af;
    border-radius: 10px;
    width: 56px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.15rem;
    font-weight: 900;
    color: #374151;
    flex-shrink: 0;
}

.abs-pan-empty {
    color: #ccc;
    font-size: 1.2rem;
    align-self: center;
    width: 100%;
    text-align: center;
}

/* ── Input row ────────────────────────────────────────────────────── */
.abs-input-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 18px 24px 10px;
}

.abs-x-label {
    font-size: 1.35rem;
    font-weight: 800;
    color: var(--abs-dark);
}

.abs-answer-inp {
    width: 88px;
    padding: 8px 12px;
    font-size: 1.25rem;
    font-weight: 700;
    text-align: center;
    border: 2px solid #ccc;
    border-radius: 8px;
    outline: none;
    transition: border-color .15s;
}
.abs-answer-inp:focus { border-color: var(--abs-primary); }
.abs-answer-inp.abs-inp-correct { border-color: var(--abs-green); background: #f0fdf4; }
.abs-answer-inp.abs-inp-wrong   { border-color: var(--abs-red);   background: #fef2f2; animation: abs-shake .3s; }
@keyframes abs-shake {
    0%,100% { transform: translateX(0); }
    25%      { transform: translateX(-6px); }
    75%      { transform: translateX(6px); }
}

.abs-check-btn { flex-shrink: 0; }

/* ── Hint row ─────────────────────────────────────────────────────── */
.abs-hint-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 20px 14px;
    border-top: 1px solid #f0f0f0;
    flex-shrink: 0;
}
.abs-hint-cost { font-size: .72em; opacity: .7; }
.abs-btn-hint { background: #fff8dc; color: #5a3e00; border: 1.5px solid #fddd54; }
.abs-btn-hint:hover { background: #fddd54; filter: none; }
.abs-btn-hint:disabled { opacity: .45; cursor: default; }

.abs-feedback { min-height: 22px; font-size: .9rem; font-weight: 600; }
.abs-feedback-success { color: var(--abs-green); }
.abs-feedback-error   { color: var(--abs-red); }

/* ── Victory overlay ──────────────────────────────────────────────── */
.abs-victory {
    position: absolute;
    inset: 0;
    background: rgba(255,255,255,.92);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity .35s;
    z-index: 10;
}
.abs-victory.abs-show { opacity: 1; pointer-events: auto; }

.abs-victory-box {
    background: #fff;
    border-radius: 18px;
    box-shadow: 0 8px 40px rgba(0,0,0,.16);
    padding: 32px 40px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}
.abs-v-emoji { font-size: 2.8rem; }
.abs-v-title { font-size: 1.5rem; font-weight: 800; color: var(--abs-dark); }

.abs-star     { font-size: 2rem; }
.abs-star-on  { color: #fddd54; }
.abs-star-off { color: #ddd; }

.abs-scorecard { display: flex; flex-direction: column; gap: 4px; width: 100%; margin: 4px 0; }
.abs-sc-row { display: flex; justify-content: space-between; gap: 24px; font-size: .92rem; }
.abs-sc-lbl { color: #888; }
.abs-sc-val { font-weight: 700; color: var(--abs-dark); }

/* Confetti */
.abs-confetti {
    position: absolute;
    top: -12px;
    animation: abs-fall linear forwards;
    pointer-events: none;
    z-index: 20;
}
@keyframes abs-fall {
    to { transform: translateY(calc(100% + 20px)) rotate(360deg); opacity: 0; }
}

/* New button — bright green, consistent across all widgets */
.abs-btn-new {
    background: #16a34a !important;
    color: #fff !important;
    border: none !important;
    font-weight: 700;
}
.abs-btn-new:hover { background: #15803d !important; filter: none !important; }

