.hero {
    padding: 28px 0 36px;
    text-align: center;
}

.hero h1 {
    font-size: clamp(1.9rem, 5vw, 3rem);
    margin: 0 0 14px;
    line-height: 1.1;
}

.hero p {
    font-size: 1.1rem;
    color: var(--text-muted);
    max-width: 720px;
    margin: 0 auto 22px;
}

.hero-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
}

.hero-note {
    margin-top: 16px;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.section-cta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.dice-workspace {
    display: grid;
    grid-template-columns: 280px minmax(0, 1fr);
    gap: 20px;
    align-items: start;
}

.dice-sidebar {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
}

.dice-main {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    min-width: 0;
}

.dice-pad {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    margin-bottom: 14px;
}

.dice-pad .button {
    min-height: 52px;
    font-size: 1rem;
}

.dice-input-row {
    display: flex;
    gap: 8px;
    margin-bottom: 14px;
}

.dice-input-row input {
    flex: 1;
    min-width: 0;
    background: var(--bg-input);
    color: #fff;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.dice-input-row .button {
    flex: 0 0 auto;
}

.roll-animation {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
    padding: 20px 0;
    min-height: 96px;
}

.anim-die {
    width: 56px;
    height: 56px;
    display: grid;
    place-items: center;
    font-size: 1.35rem;
    font-weight: 800;
    color: var(--accent);
    background: var(--bg-panel);
    border: 2px solid var(--border-strong);
    border-radius: var(--radius-sm);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
    animation: dieRoll 650ms ease-in-out;
}

.anim-die.dropped {
    color: var(--text-muted);
    border-color: var(--border);
    opacity: 0.55;
    text-decoration: line-through;
}

.anim-die.exploded {
    border-color: var(--warning);
    color: var(--warning);
}

@keyframes dieRoll {
    0% { transform: rotate(-12deg) scale(0.75); }
    20% { transform: rotate(10deg) scale(1.08); }
    40% { transform: rotate(-8deg) scale(0.95); }
    60% { transform: rotate(6deg) scale(1.04); }
    80% { transform: rotate(-3deg) scale(0.98); }
    100% { transform: rotate(0deg) scale(1); }
}

.result-card {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 14px;
}

.result-card .result-total {
    font-size: clamp(1.6rem, 4vw, 2.6rem);
    font-weight: 800;
    color: var(--accent);
    margin: 0 0 6px;
}

.result-card .result-meta {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin: 0 0 10px;
}

.result-card .result-breakdown {
    color: var(--text-secondary);
    line-height: 1.5;
}

.result-card .result-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
    flex-wrap: wrap;
}

.dice-history {
    display: grid;
    gap: 8px;
}

.history-item {
    padding: 10px 12px;
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}

.history-item .history-total {
    font-weight: 800;
    color: var(--accent);
    white-space: nowrap;
}

.history-item .history-detail {
    color: var(--text-muted);
    font-size: 0.9rem;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.modifier-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.modifier-toggle {
    width: 100%;
    min-height: 44px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.08);
    color: var(--text);
    font-weight: 800;
    cursor: pointer;
    transition: border-color 160ms ease, background 160ms ease, color 160ms ease;
}

.modifier-toggle.modifier-active {
    border-color: var(--accent);
    background: rgba(var(--accent-rgb), 0.16);
    color: var(--accent);
    box-shadow: 0 0 0 2px rgba(var(--accent-rgb), 0.18);
}

.modifier-toggle.blessed.modifier-active {
    border-color: var(--success);
    background: rgba(155, 225, 93, 0.16);
    color: #d6ff9e;
}

.modifier-toggle.cursed.modifier-active {
    border-color: var(--danger);
    background: rgba(255, 107, 107, 0.14);
    color: #ffb3b3;
}

.modifier-toggle.critical.modifier-active {
    border-color: var(--info);
    background: rgba(120, 220, 232, 0.14);
    color: #c9fbff;
}

.modifier-toggle.exploding.modifier-active {
    border-color: var(--warning);
    background: rgba(255, 159, 67, 0.15);
    color: #ffd3a0;
}

.notation-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 12px;
}

.notation-card {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px;
}

.notation-card code {
    display: inline-block;
    padding: 4px 8px;
    background: var(--bg-input);
    border-radius: 5px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    color: var(--accent);
    font-weight: 700;
    margin-bottom: 8px;
}

.notation-card p {
    margin: 0;
    color: var(--text-muted);
    font-size: 0.92rem;
}

.notation-card .button {
    margin-top: 10px;
}

.probability-chart {
    width: 100%;
    height: auto;
    max-height: 320px;
}

.probability-stats {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 10px;
    margin-bottom: 16px;
}

.stat-box {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px;
    text-align: center;
}

.stat-box .stat-value {
    font-size: 1.3rem;
    font-weight: 800;
    color: var(--accent);
}

.stat-box .stat-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.table-editor {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 320px;
    gap: 20px;
    align-items: start;
}

.table-entries {
    display: grid;
    gap: 8px;
}

.table-entry-row {
    display: grid;
    grid-template-columns: 1fr auto auto auto;
    gap: 8px;
    align-items: center;
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px;
}

.table-entry-row input {
    background: var(--bg-input);
    color: #fff;
    border: 1px solid var(--border-strong);
    border-radius: 5px;
    padding: 8px 10px;
    min-width: 0;
}

.table-entry-row .entry-prob {
    color: var(--text-muted);
    font-size: 0.85rem;
    white-space: nowrap;
}

.result-list,
.prob-list {
    list-style: none;
    margin: 14px 0 0;
    padding: 0;
    display: grid;
    gap: 8px;
}

.result-list li,
.prob-list li {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    padding: 8px 10px;
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}

.result-list li strong {
    color: var(--accent);
}

@media (max-width: 980px) {
    .dice-workspace,
    .table-editor {
        grid-template-columns: 1fr;
    }

    .dice-pad {
        grid-template-columns: repeat(4, 1fr);
    }
}

@media (max-width: 760px) {
    .dice-pad {
        grid-template-columns: repeat(3, 1fr);
    }

    .modifier-grid {
        grid-template-columns: 1fr;
    }

    .table-entry-row {
        grid-template-columns: 1fr;
    }

    .history-item {
        flex-direction: column;
        align-items: flex-start;
    }

    .history-item .history-detail {
        white-space: normal;
    }
}
