/* ===== PANELS & CARDS ===== */
.panel {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.2rem 1.6rem;
    margin-bottom: 1.2rem;
    transition: border-color 0.2s;
}

.panel:hover {
    border-color: var(--bg4);
}

.panel-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--gold);
    margin-bottom: 0.6rem;
}

/* ===== BUTTONS ===== */
.btn {
    background: var(--bg3);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 0.4rem 1rem;
    border-radius: var(--radius);
    cursor: pointer;
    font-family: var(--font);
    font-size: 0.9rem;
    transition: background 0.15s, border-color 0.15s;
}

.btn:hover {
    background: var(--bg4);
    border-color: var(--accent);
}

.btn-gold {
    background: var(--gold);
    color: #1a141a;
    border-color: var(--gold);
    font-weight: 600;
}

.btn-gold:hover {
    background: var(--gold-light);
    border-color: var(--gold-light);
}

.btn-danger {
    background: var(--red);
    color: white;
    border-color: var(--red);
}

.btn-danger:hover {
    background: #d46a6a;
    border-color: #d46a6a;
}

/* ===== MODALS - CRITICAL FIX ===== */
.modal-overlay {
    display: none !important;
    position: fixed;
    inset: 0;
    z-index: 2000;
    background: rgba(0, 0, 0, 0.7);
    justify-content: center;
    align-items: center;
    padding: 1.5rem;
    backdrop-filter: blur(4px);
}

.modal-overlay.open {
    display: flex !important;
}

.modal {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.2rem 1.6rem;
    max-width: 600px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.8);
}

.modal .close {
    position: absolute;
    top: 0.6rem;
    right: 0.8rem;
    background: none;
    border: none;
    color: var(--text2);
    font-size: 1.6rem;
    cursor: pointer;
    padding: 0 0.3rem;
    line-height: 1;
    transition: color 0.2s;
}

.modal .close:hover {
    color: var(--text);
}

.modal h2 {
    color: var(--gold);
    margin-bottom: 1rem;
    padding-right: 2rem;
}

/* Modal specific widths */
#wizardModal .modal {
    max-width: 800px;
}

#encounterModal .modal {
    max-width: 900px;
}

#npcModal .modal {
    max-width: 700px;
}

#combatModal .modal {
    max-width: 800px;
}

/* License modal */
.license-box {
    background: var(--bg3);
    border-radius: var(--radius);
    padding: 1rem;
    max-height: 400px;
    overflow-y: auto;
    font-family: monospace;
    font-size: 0.85rem;
    white-space: pre-wrap;
    color: var(--text2);
}

/* ===== GRID LAYOUTS ===== */
.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.grid-3 {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 1rem;
}

/* ===== FORMS ===== */
input, select, textarea {
    background: var(--bg3);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 0.4rem 0.6rem;
    border-radius: var(--radius);
    font-family: var(--font);
    font-size: 0.9rem;
    transition: border-color 0.2s;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--gold);
}

input[type="number"] {
    width: 70px;
}

/* ===== DICE ROLLER ===== */
.dice-result {
    font-size: 1.2rem;
    font-weight: 600;
    padding: 0.5rem 1rem;
    background: var(--bg3);
    border-radius: var(--radius);
    border-left: 4px solid var(--gold);
}

.dice-success {
    color: var(--green);
}

.dice-failure {
    color: var(--red);
}

/* ===== CHARACTER SHEET ===== */
.char-stat {
    display: flex;
    justify-content: space-between;
    padding: 0.2rem 0;
    border-bottom: 1px solid var(--border);
}

.char-stat .label {
    color: var(--text2);
}

.char-stat .value {
    font-weight: 600;
}

/* ===== TOASTS ===== */
#toast-container {
    position: fixed;
    bottom: 1rem;
    right: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    z-index: 3000;
    max-width: 340px;
    pointer-events: none;
}

.toast {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-left: 4px solid var(--gold);
    padding: 0.6rem 1rem;
    border-radius: var(--radius);
    color: var(--text);
    font-size: 0.9rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    animation: slideIn 0.3s ease;
    box-shadow: 0 4px 12px var(--shadow);
    pointer-events: auto;
}

.toast button {
    background: none;
    border: none;
    color: var(--text2);
    cursor: pointer;
    font-size: 1.2rem;
    padding: 0 0.2rem;
}

.toast button:hover {
    color: var(--text);
}

/* Story Beat highlighting */
.die.storybeat {
    background: var(--red) !important;
    color: white !important;
    font-weight: bold;
    animation: pulse 0.5s ease;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.2); }
}

/* Roll stats */
.roll-stats .storybeat-count {
    color: var(--red);
    font-weight: bold;
}

.outcome-tag.success-with-sb {
    background: var(--gold);
    color: #1a141a;
}

.outcome-tag.clean-success {
    background: var(--green);
    color: white;
}

.outcome-tag.partial {
    background: var(--blue);
    color: white;
}

.outcome-tag.miss {
    background: var(--red);
    color: white;
}