/* ==========================================================================
   Digital-Würfel – 100 % lokal, Touch-freundlich (>= 44px) & Tafel-Modus
   ========================================================================== */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

[hidden] {
    display: none !important;
}

html,
body {
    min-height: 100%;
    font-family: var(--le-font-sans);
    background: var(--le-bg);
    color: var(--le-ink);
    -webkit-tap-highlight-color: transparent;
}

button,
input {
    font-family: inherit;
}

button {
    cursor: pointer;
    border: none;
    background: none;
    color: inherit;
    transition: transform 0.1s ease, background-color 0.14s ease, border-color 0.14s ease, box-shadow 0.14s ease;
}

button:active:not(:disabled) {
    transform: scale(0.96);
}

.mono {
    font-family: var(--le-font-mono);
    font-variant-numeric: tabular-nums;
}

.app-shell {
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
}

/* ==========================================================================
   KOPFLEISTE
   ========================================================================== */
.top-bar {
    position: sticky;
    top: 0;
    z-index: 30;
    background: rgba(255, 255, 255, 0.96);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--le-border);
    padding: 8px 12px;
}

.top-bar-inner {
    max-width: 1220px;
    margin: 0 auto;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.brand-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
}

.brand-icon {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    overflow: hidden;
    flex-shrink: 0;
}

.brand-title {
    font-size: 1.04rem;
    font-weight: 900;
}

.dice-badge {
    padding: 3px 10px;
    border-radius: 999px;
    background: var(--le-teal-soft);
    color: #0f766e;
    font-size: 0.76rem;
    font-weight: 800;
}

.top-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
}

.action-btn {
    min-height: 44px;
    padding: 0 12px;
    border-radius: 12px;
    border: 1px solid var(--le-border-strong);
    background: var(--le-surface);
    font-size: 0.85rem;
    font-weight: 800;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.action-btn[aria-pressed="true"] {
    background: var(--le-teal);
    color: #ffffff;
    border-color: var(--le-teal);
}

/* ==========================================================================
   WORKSPACE
   ========================================================================== */
.dice-workspace {
    width: 100%;
    max-width: 1220px;
    margin: 0 auto;
    padding: 16px 12px 28px;
    display: grid;
    grid-template-columns: minmax(0, 1.35fr) minmax(300px, 0.9fr);
    gap: 16px;
    align-items: start;
}

.card {
    background: var(--le-surface);
    border: 1px solid var(--le-border);
    border-radius: 20px;
    box-shadow: var(--le-shadow-sm);
}

.tray-card {
    padding: 18px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.tray-controls {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.control-group {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.ctrl-lbl,
.sub-lbl {
    font-size: 0.76rem;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--le-ink-muted);
    min-width: 72px;
}

.count-pills,
.preset-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.pill-opt {
    min-width: 44px;
    min-height: 44px;
    padding: 0 12px;
    border-radius: 12px;
    border: 1.5px solid var(--le-border);
    background: var(--le-surface-alt);
    font-size: 0.86rem;
    font-weight: 800;
    color: var(--le-ink-muted);
}

.pill-opt.active {
    background: var(--le-teal);
    border-color: var(--le-teal);
    color: #ffffff;
}

/* ==========================================================================
   WÜRFEL-TISCH & 3D-WÜRFEL-KARTEN
   ========================================================================== */
.dice-tray {
    min-height: 230px;
    padding: 20px 14px;
    border-radius: 18px;
    background: radial-gradient(circle at top, #ecfeff 0%, #f1f5f9 100%);
    border: 2px dashed rgba(13, 148, 136, 0.28);
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 16px;
}

.die-tile {
    position: relative;
    width: 112px;
    height: 112px;
    border-radius: 22px;
    border: 3px solid rgba(15, 23, 42, 0.16);
    box-shadow: 0 10px 20px rgba(15, 23, 42, 0.14), inset 0 -4px 0 rgba(0, 0, 0, 0.1);
    display: grid;
    place-items: center;
    padding: 10px;
    user-select: none;
}

.die-tile.is-rolling {
    animation: tumbleRoll 0.42s ease-in-out;
}

@keyframes tumbleRoll {
    0%   { transform: rotate(0deg) scale(1); }
    25%  { transform: rotate(-18deg) scale(1.08) translateY(-10px); }
    55%  { transform: rotate(15deg) scale(0.95) translateY(3px); }
    80%  { transform: rotate(-6deg) scale(1.03); }
    100% { transform: rotate(0deg) scale(1); }
}

.die-tile.is-locked {
    outline: 3px solid var(--le-amber);
    outline-offset: 3px;
}

.die-lock-badge {
    position: absolute;
    top: -9px;
    right: -8px;
    width: 28px;
    height: 28px;
    border-radius: 999px;
    background: var(--le-amber);
    color: #ffffff;
    font-size: 0.85rem;
    display: grid;
    place-items: center;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

.die-face-text {
    font-size: 2.1rem;
    font-weight: 900;
    line-height: 1.1;
    text-align: center;
    word-break: break-word;
}

.die-face-text.is-long {
    font-size: 1.15rem;
}

.die-face-text.is-sym {
    font-size: 2.8rem;
}

.tray-hint {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--le-ink-muted);
    text-align: center;
}

.tray-footer {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 12px;
}

.sum-pill {
    min-height: 50px;
    padding: 0 18px;
    border-radius: 14px;
    background: var(--le-amber-soft);
    border: 1.5px solid rgba(217, 119, 6, 0.35);
    color: #78350f;
    font-size: 1.15rem;
    font-weight: 900;
    display: inline-flex;
    align-items: center;
}

.roll-btn {
    min-height: 54px;
    min-width: 190px;
    padding: 0 28px;
    border-radius: 16px;
    background: linear-gradient(135deg, #0d9488 0%, #0284c7 100%);
    color: #ffffff;
    font-size: 1.15rem;
    font-weight: 900;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    box-shadow: 0 10px 22px rgba(2, 132, 199, 0.28);
}

/* ==========================================================================
   SEITENLEISTE: EIGENES DESIGN & VERLAUF
   ========================================================================== */
.side-col {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.side-card {
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.head-between {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.side-title {
    font-size: 0.98rem;
    font-weight: 900;
}

.die-sel-pill {
    padding: 3px 10px;
    border-radius: 999px;
    background: var(--le-indigo-soft);
    color: #3730a3;
    font-size: 0.75rem;
    font-weight: 800;
}

.edit-target-row {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}

.target-chip {
    min-height: 44px;
    padding: 0 12px;
    border-radius: 9px;
    border: 1px solid var(--le-border);
    background: var(--le-surface-alt);
    font-size: 0.8rem;
    font-weight: 800;
}

.target-chip.active {
    background: var(--le-indigo);
    border-color: var(--le-indigo);
    color: #ffffff;
}

.style-row {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.theme-swatches {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 6px;
}

.theme-dot {
    min-height: 44px;
    height: 44px;
    border-radius: 10px;
    border: 2px solid rgba(15, 23, 42, 0.18);
}

.theme-dot.active {
    border-color: var(--le-ink);
    box-shadow: 0 0 0 2px var(--le-teal);
}

.custom-faces-wrap {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--le-border);
}

.custom-faces-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
}

.custom-face-input {
    width: 100%;
    min-height: 44px;
    padding: 6px 8px;
    border-radius: 10px;
    border: 1.5px solid var(--le-border-strong);
    background: #ffffff;
    text-align: center;
    font-size: 0.92rem;
    font-weight: 800;
}

.custom-face-input:focus {
    outline: none;
    border-color: var(--le-teal);
}

.apply-custom-btn {
    min-height: 44px;
    padding: 0 14px;
    border-radius: 12px;
    background: var(--le-indigo);
    color: #ffffff;
    font-size: 0.85rem;
    font-weight: 800;
}

.text-link {
    min-height: 44px;
    padding: 0 6px;
    font-size: 0.78rem;
    font-weight: 800;
    color: var(--le-indigo);
}

.text-link.danger {
    color: var(--le-rose);
}

.history-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 200px;
    overflow-y: auto;
}

.history-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 7px 10px;
    border-radius: 10px;
    background: var(--le-bg);
    border: 1px solid var(--le-border);
    font-size: 0.84rem;
    font-weight: 700;
}

.history-empty {
    padding: 10px;
    text-align: center;
    font-size: 0.82rem;
    color: var(--le-ink-muted);
}

/* ==========================================================================
   TAFEL-MODUS (GROSS & OHNE ABLENKUNG)
   ========================================================================== */
body.board-mode .board-hide {
    display: none !important;
}

body.board-mode .dice-workspace {
    grid-template-columns: minmax(0, 880px);
    justify-content: center;
}

body.board-mode .die-tile {
    width: 142px;
    height: 142px;
}

body.board-mode .die-face-text {
    font-size: 2.7rem;
}

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

@media (max-width: 560px) {
    .hide-sm,
    .dice-badge {
        display: none;
    }

    .die-tile {
        width: 92px;
        height: 92px;
        border-radius: 18px;
    }

    .die-face-text {
        font-size: 1.7rem;
    }

    .die-face-text.is-sym {
        font-size: 2.2rem;
    }
}
