:root {
    color-scheme: dark;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: #101010;
    color: #f7f7f7;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-width: 320px;
    background: #101010;
}

button,
input {
    font: inherit;
}

.app {
    min-height: 100vh;
    display: grid;
    grid-template-rows: auto 1fr auto auto;
}

.topbar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    background: #171717;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.brand,
.total {
    color: #ffd54f;
    font-weight: 800;
}

.brand {
    font-size: 1.55rem;
    margin-right: auto;
}

.shell {
    display: grid;
    grid-template-columns: 280px 1fr;
    min-height: 0;
}

.sidebar {
    padding: 18px;
    border-right: 1px solid rgba(255, 255, 255, 0.08);
    background: #121212;
}

h1,
h2 {
    margin: 0 0 12px;
}

h1 {
    font-size: 1.25rem;
}

h2 {
    font-size: 1rem;
}

.dice-buttons {
    display: grid;
    grid-template-columns: repeat(3, minmax(64px, 1fr));
    gap: 10px;
}

.dice-buttons .button {
    width: 100%;
    min-width: 0;
    padding-inline: 10px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chip-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.modifier-list,
.option-list {
    display: grid;
    gap: 10px;
}

.modifier-toggle {
    width: 100%;
    min-height: 44px;
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.08);
    color: #f7f7f7;
    font-weight: 800;
    cursor: pointer;
    transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease, color 160ms ease;
}

.modifier-toggle.modifier-active {
    border-color: #ffd54f;
    background: rgba(255, 213, 79, 0.16);
    color: #ffd54f;
    box-shadow: 0 0 0 2px rgba(255, 213, 79, 0.18), 0 0 22px rgba(255, 213, 79, 0.32);
    animation: modifier-glow 1.2s ease-in-out infinite alternate;
}

.modifier-toggle.blessed.modifier-active {
    border-color: #9be15d;
    background: rgba(155, 225, 93, 0.16);
    color: #d6ff9e;
    box-shadow: 0 0 0 2px rgba(155, 225, 93, 0.18), 0 0 22px rgba(155, 225, 93, 0.32);
    animation-name: blessed-glow;
}

.modifier-toggle.cursed.modifier-active {
    border-color: #ff6b6b;
    background: rgba(255, 107, 107, 0.14);
    color: #ffb3b3;
    box-shadow: 0 0 0 2px rgba(255, 107, 107, 0.18), 0 0 22px rgba(255, 107, 107, 0.32);
    animation-name: cursed-glow;
}

.modifier-toggle.critical.modifier-active {
    border-color: #78dce8;
    background: rgba(120, 220, 232, 0.14);
    color: #c9fbff;
    box-shadow: 0 0 0 2px rgba(120, 220, 232, 0.18), 0 0 22px rgba(120, 220, 232, 0.3);
    animation-name: critical-glow;
}

.modifier-toggle.exploding.modifier-active {
    border-color: #ff9f43;
    background: rgba(255, 159, 67, 0.15);
    color: #ffd3a0;
    box-shadow: 0 0 0 2px rgba(255, 159, 67, 0.18), 0 0 22px rgba(255, 159, 67, 0.32);
    animation-name: exploding-glow;
}

.option-field {
    display: grid;
    gap: 8px;
    color: rgba(255, 255, 255, 0.72);
    font-size: 0.92rem;
    font-weight: 700;
}

.option-select {
    min-height: 42px;
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 8px;
    background: #202020;
    color: #f7f7f7;
    padding: 9px 10px;
}

.option-select.positive {
    border-color: rgba(155, 225, 93, 0.5);
    color: #d6ff9e;
}

.option-select.negative {
    border-color: rgba(255, 107, 107, 0.5);
    color: #ffb3b3;
}

.option-select option.positive-option {
    color: #2f7d32;
}

.option-select option.negative-option {
    color: #b3261e;
}

.option-select option.neutral-option {
    color: #202020;
}

.board {
    padding: 24px;
    min-width: 0;
    display: grid;
    grid-template-rows: auto auto auto 1fr;
    align-content: start;
}

.dice-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
    gap: 12px;
    align-content: start;
    margin-top: 18px;
}

.die-card {
    min-height: 96px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.06);
    border-radius: 8px;
    display: grid;
    place-items: center;
    cursor: pointer;
}

.die-card:disabled {
    cursor: wait;
}

.die-shape {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    color: #101010;
    font-weight: 800;
    user-select: none;
}

.die-rolling {
    border-color: rgba(255, 213, 79, 0.85);
    box-shadow: 0 0 0 2px rgba(255, 213, 79, 0.18);
}

.die-rolling .die-shape {
    animation: dramatic-pulse 0.48s ease-in-out infinite alternate;
}

.die-critical-high {
    border-color: rgba(255, 213, 79, 0.95);
    box-shadow: 0 0 0 2px rgba(255, 213, 79, 0.18), 0 0 24px rgba(255, 213, 79, 0.22);
}

.die-critical-high .die-shape {
    box-shadow: 0 0 0 3px rgba(255, 213, 79, 0.35);
}

.die-critical-low {
    border-color: rgba(255, 107, 107, 0.95);
    box-shadow: 0 0 0 2px rgba(255, 107, 107, 0.18), 0 0 24px rgba(255, 107, 107, 0.22);
}

.die-critical-low .die-shape {
    box-shadow: 0 0 0 3px rgba(255, 107, 107, 0.35);
}

.die-d6 {
    border-radius: 8px;
}

.die-frozen {
    opacity: 0.55;
    outline: 2px solid #ffd54f;
}

.hint {
    color: rgba(255, 255, 255, 0.62);
}

.button,
.chip {
    border: 1px solid rgba(255, 255, 255, 0.16);
    background: rgba(255, 255, 255, 0.08);
    color: #f7f7f7;
    border-radius: 999px;
    padding: 9px 14px;
    cursor: pointer;
}

.button {
    border-radius: 8px;
    min-height: 42px;
    font-weight: 700;
}

.button.primary {
    background: #ffd54f;
    color: #101010;
    border-color: #ffd54f;
}

.button:disabled,
.chip:disabled,
.modifier-toggle:disabled,
.option-select:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.panel {
    margin-top: 18px;
    padding-top: 18px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.history {
    max-height: min(62vh, 520px);
    overflow: auto;
    display: grid;
    gap: 8px;
}

.record {
    padding: 10px;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 8px;
}

.record strong {
    color: #ffd54f;
}

.field-row {
    display: flex;
    gap: 8px;
}

.field-row input {
    min-width: 0;
    flex: 1;
    background: #202020;
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 8px;
    padding: 10px 12px;
}

.roll-summary {
    flex: 1;
}

.roll-panel {
    margin-top: 12px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.06);
    border-radius: 10px;
    padding: 16px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 16px;
    align-items: center;
}

.roll-panel .total {
    font-size: clamp(1.5rem, 4vw, 3.25rem);
    line-height: 1;
    letter-spacing: 0;
}

.roll-actions {
    display: flex;
    gap: 10px;
    align-items: center;
}

.effects-bar {
    padding: 10px 20px;
    background: #161616;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 14px;
    align-items: center;
}

.effects-head {
    display: flex;
    align-items: center;
    gap: 10px;
}

.effects-head h2 {
    margin: 0;
    white-space: nowrap;
}

.effects-list {
    min-width: 0;
    display: flex;
    gap: 8px;
    align-items: center;
    overflow-x: auto;
    padding-bottom: 2px;
}

.effect-empty {
    color: rgba(255, 255, 255, 0.58);
}

.effect-pill {
    flex: 0 0 auto;
    max-width: min(320px, 72vw);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.06);
    padding: 8px 10px;
    display: grid;
    gap: 2px;
}

.effect-pill strong,
.effect-info strong {
    color: #ffd54f;
}

.effect-pill span,
.effect-info p {
    margin: 0;
    color: rgba(255, 255, 255, 0.66);
    font-size: 0.88rem;
    line-height: 1.25;
}

.effect-pill.blessed strong,
.effect-info.blessed strong {
    color: #d6ff9e;
}

.effect-pill.cursed strong,
.effect-info.cursed strong {
    color: #ffb3b3;
}

.effect-pill.critical strong,
.effect-info.critical strong {
    color: #c9fbff;
}

.effect-pill.exploding strong,
.effect-info.exploding strong {
    color: #ffd3a0;
}

.effect-pill.flat strong,
.effect-info.flat strong {
    color: #f5f5f5;
}

.effects-info-list {
    display: grid;
    gap: 10px;
    max-height: min(62vh, 520px);
    overflow: auto;
}

.effect-info {
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.055);
    padding: 11px 12px;
}

.effect-info.active {
    border-color: rgba(255, 213, 79, 0.45);
    background: rgba(255, 213, 79, 0.08);
}

.adbar {
    padding: 10px 20px 14px;
    background: #121212;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.ad-slot {
    width: min(728px, 100%);
    min-height: 72px;
    margin: 0 auto;
    border: 1px dashed rgba(255, 255, 255, 0.18);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.04);
    display: grid;
    place-items: center;
    overflow: hidden;
}

.ad-slot.configured {
    border-style: solid;
    background: transparent;
}

.ad-slot .adsbygoogle {
    display: block;
    width: 100%;
    min-height: 72px;
}

.modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 20;
    padding: 24px;
    background: rgba(0, 0, 0, 0.68);
    display: grid;
    place-items: center;
}

.modal-backdrop[hidden] {
    display: none;
}

.modal {
    width: min(620px, 100%);
    max-height: min(82vh, 720px);
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 12px;
    background: #171717;
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.42);
    padding: 18px;
    display: grid;
    gap: 14px;
}

#roomModal .modal {
    width: min(480px, 100%);
}

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

.modal-head h2 {
    margin: 0;
}

.simulation-results {
    display: grid;
    gap: 8px;
}

.simulation-row {
    display: grid;
    grid-template-columns: 72px 1fr;
    gap: 12px;
    padding: 10px;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 8px;
}

.simulation-row strong {
    color: #ffd54f;
}

@keyframes dramatic-pulse {
    from {
        transform: scale(0.94) rotate(-3deg);
    }

    to {
        transform: scale(1.08) rotate(3deg);
    }
}

@keyframes modifier-glow {
    from {
        box-shadow: 0 0 0 2px rgba(255, 213, 79, 0.14), 0 0 14px rgba(255, 213, 79, 0.22);
    }

    to {
        box-shadow: 0 0 0 2px rgba(255, 213, 79, 0.24), 0 0 28px rgba(255, 213, 79, 0.42);
    }
}

@keyframes blessed-glow {
    from {
        box-shadow: 0 0 0 2px rgba(155, 225, 93, 0.14), 0 0 14px rgba(155, 225, 93, 0.22);
    }

    to {
        box-shadow: 0 0 0 2px rgba(155, 225, 93, 0.24), 0 0 28px rgba(155, 225, 93, 0.42);
    }
}

@keyframes cursed-glow {
    from {
        box-shadow: 0 0 0 2px rgba(255, 107, 107, 0.14), 0 0 14px rgba(255, 107, 107, 0.22);
    }

    to {
        box-shadow: 0 0 0 2px rgba(255, 107, 107, 0.24), 0 0 28px rgba(255, 107, 107, 0.42);
    }
}

@keyframes critical-glow {
    from {
        box-shadow: 0 0 0 2px rgba(120, 220, 232, 0.14), 0 0 14px rgba(120, 220, 232, 0.2);
    }

    to {
        box-shadow: 0 0 0 2px rgba(120, 220, 232, 0.24), 0 0 28px rgba(120, 220, 232, 0.38);
    }
}

@keyframes exploding-glow {
    from {
        box-shadow: 0 0 0 2px rgba(255, 159, 67, 0.14), 0 0 14px rgba(255, 159, 67, 0.22);
    }

    to {
        box-shadow: 0 0 0 2px rgba(255, 159, 67, 0.24), 0 0 28px rgba(255, 159, 67, 0.42);
    }
}

@media (max-width: 760px) {
    .topbar {
        flex-wrap: wrap;
    }

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

    .sidebar {
        border-right: 0;
        border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    }

    .roll-panel {
        grid-template-columns: 1fr;
    }

    .roll-actions {
        width: 100%;
        flex-wrap: wrap;
    }

    .roll-actions .button {
        flex: 1 1 30%;
        padding-inline: 10px;
    }

    .effects-bar {
        grid-template-columns: 1fr;
        padding: 10px;
    }

    .effects-head {
        justify-content: space-between;
    }

    .adbar {
        padding: 8px 10px 10px;
    }

    .ad-slot {
        min-height: 64px;
    }
}
