/* ── Percents Widget ───────────────────────────────────────────────── */
.ama-percents-widget {
    --apc-primary: #16a34a;
    --apc-dark:    #15803d;
    --apc-light:   #f0fdf4;
    --apc-green:   #16a34a;
    --apc-red:     #dc2626;
    --apc-radius:  14px;
    font-family: 'Segoe UI', Arial, sans-serif;
    position: relative;
    background: #fff;
    border-radius: var(--apc-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 ───────────────────────────────────────────────────────── */
.apc-header {
    background: var(--apc-primary);
    color: #fff;
    padding: 12px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
}
.apc-title { font-size: 1.1rem; font-weight: 700; white-space: nowrap; }
.apc-controls { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; flex: 1; justify-content: flex-end; }

.apc-mode-toggle { display: flex; gap: 4px; flex-wrap: wrap; }
.apc-mode-btn {
    background: rgba(255,255,255,.18);
    color: #fff;
    border: none;
    border-radius: 6px;
    padding: 5px 10px;
    font-size: .78rem;
    font-weight: 600;
    cursor: pointer;
    transition: background .15s;
}
.apc-mode-btn:hover { background: rgba(255,255,255,.28); }
.apc-mode-btn.apc-mode-active { background: #fff; color: var(--apc-primary); }

.apc-ctrl-label {
    font-size: .78rem;
    color: rgba(255,255,255,.85);
    display: flex;
    align-items: center;
    gap: 5px;
}
.apc-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;
}
.apc-diff-sel option { background: var(--apc-dark); }

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

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

/* ── Body ─────────────────────────────────────────────────────────── */
.apc-body { flex: 1; overflow-y: auto; min-height: 0; }
.apc-problem { padding: 24px 28px 8px; }

/* ── FIND mode ────────────────────────────────────────────────────── */
.apc-find-area { display: flex; flex-direction: column; align-items: center; gap: 22px; }

.apc-find-q {
    font-size: 1.25rem;
    font-weight: 700;
    color: #1a1a1a;
    text-align: center;
}

.apc-tokens {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    justify-content: center;
}
.apc-token {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    background: var(--apc-light);
    border: 2px solid var(--apc-primary);
    border-radius: 12px;
    padding: 12px 18px;
    min-width: 90px;
}
.apc-token-missing {
    background: #fffbea;
    border-color: #f59e0b;
    border-style: dashed;
}
.apc-token-label {
    font-size: .7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: var(--apc-dark);
    opacity: .7;
}
.apc-token-val {
    font-size: 1.7rem;
    font-weight: 800;
    color: var(--apc-dark);
}
.apc-token-op {
    font-size: 1.6rem;
    font-weight: 800;
    color: #aaa;
}
.apc-inp-token {
    width: 80px;
    padding: 4px 8px;
    font-size: 1.4rem;
    font-weight: 800;
    text-align: center;
    border: none;
    border-bottom: 2.5px solid var(--apc-primary);
    background: transparent;
    outline: none;
    color: var(--apc-dark);
}

/* ── REAL WORLD mode ──────────────────────────────────────────────── */
.apc-real-area { display: flex; flex-direction: column; gap: 16px; }
.apc-real-ctx {
    background: var(--apc-light);
    border-left: 4px solid var(--apc-primary);
    padding: 14px 16px;
    border-radius: 0 10px 10px 0;
    font-size: 1.05rem;
    color: var(--apc-dark);
    font-weight: 500;
}
.apc-real-q { font-size: 1.1rem; font-weight: 700; color: #1a1a1a; }
.apc-real-input-row { display: flex; align-items: center; gap: 6px; }
.apc-dollar { font-size: 1.3rem; font-weight: 700; color: var(--apc-dark); }

/* ── VISUAL BAR mode ──────────────────────────────────────────────── */
.apc-bar-area { display: flex; flex-direction: column; align-items: center; gap: 14px; }
.apc-bar-instruction { font-size: 1.05rem; font-weight: 700; color: #1a1a1a; text-align: center; }

.apc-bar-grid {
    display: grid;
    grid-template-columns: repeat(10, 1fr);
    gap: 3px;
    width: 100%;
    max-width: 290px;
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
}
.apc-bar-readonly { cursor: default; }

.apc-cell {
    aspect-ratio: 1;
    border-radius: 3px;
    background: #e5e7eb;
    border: 1px solid #d1d5db;
    transition: background .08s;
}
.apc-cell.apc-cell-on {
    background: var(--apc-primary);
    border-color: var(--apc-dark);
}
.apc-bar-grid:not(.apc-bar-readonly) .apc-cell:hover { background: #6ee7b7; border-color: var(--apc-dark); }
.apc-bar-grid:not(.apc-bar-readonly) .apc-cell.apc-cell-on:hover { background: #15803d; }

.apc-bar-count { font-size: .9rem; color: #666; font-weight: 600; }
.apc-bar-inp-row { display: flex; align-items: center; gap: 6px; }
.apc-pct-lbl { font-size: 1.2rem; font-weight: 700; color: var(--apc-dark); }

/* ── CHANGE mode ──────────────────────────────────────────────────── */
.apc-change-area { display: flex; flex-direction: column; gap: 18px; }
.apc-change-q {
    font-size: 1.1rem;
    color: #1a1a1a;
    line-height: 1.6;
    background: var(--apc-light);
    border-left: 4px solid var(--apc-primary);
    padding: 14px 16px;
    border-radius: 0 10px 10px 0;
}
.apc-change-input-row { display: flex; align-items: center; gap: 8px; }

/* ── Shared inputs ────────────────────────────────────────────────── */
.apc-answer-inp {
    width: 110px;
    padding: 8px 12px;
    font-size: 1.2rem;
    font-weight: 700;
    text-align: center;
    border: 2px solid #ccc;
    border-radius: 8px;
    outline: none;
    transition: border-color .15s;
}
.apc-answer-inp:focus { border-color: var(--apc-primary); }
.apc-answer-inp.apc-inp-correct { border-color: var(--apc-green); background: #f0fdf4; }
.apc-answer-inp.apc-inp-wrong   { border-color: var(--apc-red); background: #fef2f2; animation: apc-shake .3s; }
@keyframes apc-shake {
    0%,100% { transform: translateX(0); }
    25%      { transform: translateX(-6px); }
    75%      { transform: translateX(6px); }
}
.apc-check-btn { margin-top: 4px; }

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

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

/* ── Victory overlay ──────────────────────────────────────────────── */
.apc-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;
}
.apc-victory.apc-show { opacity: 1; pointer-events: auto; }

.apc-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;
}
.apc-v-emoji { font-size: 2.8rem; }
.apc-v-title { font-size: 1.5rem; font-weight: 800; color: var(--apc-dark); }

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

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

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

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

