:root {
    --royal-bg: #080b0f;
    --royal-bg-soft: #0d1116;
    --royal-panel: #11161c;
    --royal-primary: #ff0b63;
    --royal-secondary: #c9184a;
    --royal-text: #f8f6ef;
    --royal-muted: #a6abb3;
    --royal-border: rgba(255,255,255,.12);
    --royal-shadow: 0 18px 55px rgba(0,0,0,.45);
}

html { min-height: 100%; background: var(--royal-bg); }

body {
    min-height: 100vh;
    margin: 0;
    display: flex;
    flex-direction: column;
    color: var(--royal-text);
    font-family: "Inter","Segoe UI",Arial,sans-serif;

    background-image:
        linear-gradient(rgba(5,8,12,.28), rgba(5,8,12,.38)),
        url("../images/backgrounds/royal-bg-dark.png");

    background-size: cover;
    background-position: center top;
    background-repeat: no-repeat;
    background-attachment: fixed;
    background-color: var(--royal-bg);
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    opacity: .22;
    background-image:
        linear-gradient(rgba(255,255,255,.012) 1px, transparent 1px),
        linear-gradient(90deg,rgba(255,255,255,.008) 1px, transparent 1px);
    background-size: 42px 42px;
}

.royal-main {
    flex: 1 0 auto;
}

.royal-heading,.royal-brand-title,.royal-hero-title,.royal-section-title,.royal-auth-title {
    font-family: "Cinzel",Georgia,"Times New Roman",serif;
}

.royal-eyebrow {
    color: var(--royal-muted);
    font-size: .75rem;
    font-weight: 600;
    letter-spacing: .30em;
    text-transform: uppercase;
}

.royal-navbar {
    background: rgba(7,10,14,.94);
    border-bottom: 1px solid var(--royal-border);
    backdrop-filter: blur(14px);
}

.royal-navbar .container { min-height: 74px; }

.royal-navbar-logo {
    width: 76px;
    height: 58px;
    object-fit: cover;
    border-radius: 6px;
}

.royal-brand-title {
    color: var(--royal-text);
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: .12em;
}

.royal-navbar .nav-link {
    position: relative;
    padding-left: .9rem !important;
    padding-right: .9rem !important;
    color: #d7d8da;
}

.royal-navbar .nav-link:hover,.royal-navbar .nav-link:focus { color: #fff; }

.royal-navbar .nav-link::after {
    content: "";
    position: absolute;
    left: .9rem;
    right: .9rem;
    bottom: .2rem;
    height: 2px;
    background: var(--royal-primary);
    transform: scaleX(0);
    transition: transform .2s ease;
}

.royal-navbar .nav-link:hover::after { transform: scaleX(1); }

.royal-navbar .nav-link.disabled {
    color: #666d76;
    opacity: .65;
}

.royal-navbar .nav-link.disabled::after { display: none; }

.royal-user-badge {
    color: #d7d8da;
    white-space: nowrap;
}

.btn-royal-primary {
    color: #fff;
    border: 1px solid rgba(255,64,128,.70);
    background: linear-gradient(135deg,var(--royal-primary),var(--royal-secondary));
    box-shadow: 0 10px 30px rgba(255,11,99,.20);
}

.btn-royal-primary:hover,.btn-royal-primary:focus {
    color: #fff;
    transform: translateY(-1px);
    filter: brightness(1.08);
    box-shadow: 0 14px 40px rgba(255,11,99,.32);
}

.btn-royal-secondary {
    color: var(--royal-text);
    border: 1px solid rgba(255,255,255,.24);
    background: rgba(255,255,255,.025);
}

.btn-royal-secondary:hover,.btn-royal-secondary:focus {
    color: #fff;
    border-color: rgba(255,11,99,.70);
    background: rgba(255,11,99,.08);
}

.royal-hero {
    position: relative;
    overflow: hidden;
    min-height: calc(100vh - 74px);
    display: flex;
    align-items: center;
    padding: 5rem 0 6rem;
}

.royal-hero::before {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    background: radial-gradient(circle at 72% 38%, rgba(255,11,99,.13), transparent 22rem);
}

.royal-hero-content { position: relative; z-index: 2; }

.royal-hero-logo {
    display: block;
    width: min(390px,80vw);
    margin: 0 auto 2rem;
    border-radius: 18px;
    box-shadow: 0 25px 80px rgba(0,0,0,.52);
}

.royal-hero-title {
    margin-bottom: 1rem;
    font-size: clamp(2.5rem,7vw,5.8rem);
    font-weight: 700;
    letter-spacing: .035em;
    line-height: .98;
    text-shadow: 0 5px 30px rgba(0,0,0,.55);
}

.royal-hero-subtitle {
    color: #dadbdd;
    max-width: 650px;
    margin: 0 auto;
    font-size: clamp(1rem,2vw,1.25rem);
    line-height: 1.75;
}

.royal-divider {
    display: flex;
    align-items: center;
    width: min(330px,75vw);
    margin: 1.4rem auto 1.8rem;
}

.royal-divider::before,.royal-divider::after {
    content: "";
    flex: 1;
    height: 1px;
    background: linear-gradient(90deg,transparent,rgba(255,11,99,.75));
}

.royal-divider::after {
    background: linear-gradient(90deg,rgba(255,11,99,.75),transparent);
}

.royal-divider span {
    width: 9px;
    height: 9px;
    margin: 0 12px;
    border: 1px solid var(--royal-primary);
    transform: rotate(45deg);
    box-shadow: 0 0 14px rgba(255,11,99,.5);
}

.royal-card {
    height: 100%;
    padding: 1.5rem;
    border: 1px solid var(--royal-border);
    border-radius: 10px;
    background: linear-gradient(145deg,rgba(25,31,38,.88),rgba(10,14,19,.96));
    box-shadow: var(--royal-shadow);
}

.royal-card:hover {
    transform: translateY(-3px);
    border-color: rgba(255,11,99,.35);
}

.royal-card-value {
    margin-bottom: .25rem;
    color: #fff;
    font-family: "Cinzel",Georgia,serif;
    font-size: 2rem;
    font-weight: 700;
}

.royal-card-label {
    margin: 0;
    color: var(--royal-muted);
    font-size: .88rem;
    letter-spacing: .10em;
    text-transform: uppercase;
}

.royal-section {
    position: relative;
    padding: 5rem 0;
    border-top: 1px solid rgba(255,255,255,.06);
}

.royal-section-title {
    margin-bottom: .5rem;
    font-size: clamp(1.7rem,4vw,2.5rem);
}

.royal-footer {
    height: 34px;
    min-height: 34px;
    padding: 0;
    flex-shrink: 0;

    display: flex;
    align-items: center;

    color: var(--royal-muted);
    background: rgba(255,255,255,.025);

    border: 0;
    box-shadow: none;

    font-size: .78rem;
    line-height: 1;
}

.royal-footer-credit {
    width: 100%;
    padding: 0 24px;

    display: flex;
    justify-content: flex-end;
    align-items: center;

    white-space: nowrap;
}

.royal-footer-mark {
    color: var(--royal-primary);
    font-weight: 700;
}

.royal-auth {
    min-height: calc(100vh - 150px);
    display: flex;
    align-items: center;
    padding: 4rem 0;
}

.royal-auth-card {
    padding: 2rem;
    border: 1px solid var(--royal-border);
    border-radius: 12px;
    background: linear-gradient(150deg,rgba(20,25,31,.97),rgba(7,10,14,.98));
    box-shadow: 0 30px 90px rgba(0,0,0,.55);
}

.royal-auth-logo {
    display: block;
    width: min(220px,70vw);
    margin: 0 auto 1.5rem;
    border-radius: 12px;
}

.royal-auth-title {
    margin: .5rem 0 0;
    text-align: center;
    font-weight: 700;
}

.royal-input {
    min-height: 48px;
    color: var(--royal-text);
    border: 1px solid rgba(255,255,255,.16);
    background: rgba(0,0,0,.25);
}

.royal-input:focus {
    color: #fff;
    border-color: var(--royal-primary);
    background: rgba(0,0,0,.35);
    box-shadow: 0 0 0 .2rem rgba(255,11,99,.12);
}

.royal-alert ul { margin-bottom: 0; }

@media (max-width: 991.98px) {
    .royal-navbar .container { min-height: 64px; }
    .royal-navbar-logo { width: 64px; height: 48px; }
    .navbar-collapse { padding: 1rem 0 1.25rem; }
    .royal-navbar .nav-link { min-height: 44px; display: flex; align-items: center; }
    .royal-navbar .nav-link::after { display: none; }
    .royal-hero { min-height: auto; padding: 4rem 0; }
    .royal-hero-logo { width: min(290px,78vw); }
    .royal-user-badge { margin-top: .6rem; margin-bottom: .8rem; }
}

@media (max-width: 575.98px) {
    .royal-hero { padding: 3rem 0 4rem; }
    .royal-card { padding: 1.25rem; }
    .royal-auth-card { padding: 1.4rem; }
}

/* === M3C MODULES === */

.royal-page-header {
    padding: 2.5rem 0 1.5rem;
}

.royal-page-title {
    margin: 0;
    font-family: "Cinzel", Georgia, serif;
    font-size: clamp(2rem, 5vw, 3.2rem);
    font-weight: 700;
}

.royal-main h1 {
    font-family: "Cinzel", Georgia, serif;
    font-weight: 700;
    letter-spacing: .015em;
    display: inline-block;
    background: linear-gradient(90deg, #ffffff 0%, #ffd6e4 38%, #ff8ab3 68%, var(--royal-primary) 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    color: transparent;
}

.royal-page-subtitle {
    color: var(--royal-muted);
    margin-top: .65rem;
    margin-bottom: 0;
}

.royal-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: .75rem;
    align-items: end;
    margin-bottom: 1.25rem;
}

.royal-panel {
    border: 1px solid var(--royal-border);
    border-radius: 12px;
    background: linear-gradient(145deg, rgba(25,31,38,.88), rgba(10,14,19,.96));
    box-shadow: var(--royal-shadow);
    padding: 1.25rem;
}

.royal-table-wrap {
    width: 100%;
    overflow-x: auto;
    border: 1px solid var(--royal-border);
    border-radius: 12px;
    background: rgba(8, 11, 15, .72);
}

.royal-table {
    margin: 0;
    min-width: 760px;
    color: var(--royal-text);
}

.royal-table > :not(caption) > * > * {
    padding: .95rem 1rem;
    background: transparent;
    color: inherit;
    border-color: rgba(255,255,255,.08);
}

.royal-table thead th {
    color: #dcdde0;
    font-size: .76rem;
    letter-spacing: .08em;
    text-transform: uppercase;
    white-space: nowrap;
}

.royal-table tbody tr:hover {
    background: rgba(255, 11, 99, .045);
}

.royal-link {
    color: #fff;
    text-decoration: none;
}

.royal-link:hover {
    color: var(--royal-primary);
}

.royal-badge {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    padding: .28rem .55rem;
    border: 1px solid rgba(255,255,255,.14);
    border-radius: 999px;
    color: #d7d8db;
    background: rgba(255,255,255,.035);
    font-size: .78rem;
    white-space: nowrap;
}

.royal-badge-danger {
    border-color: rgba(239,68,68,.4);
    color: #fca5a5;
    background: rgba(239,68,68,.08);
}

.royal-badge-warning {
    border-color: rgba(245,158,11,.4);
    color: #fcd34d;
    background: rgba(245,158,11,.08);
}

.royal-empty {
    padding: 3rem 1rem;
    text-align: center;
    color: var(--royal-muted);
}

.royal-form-control,
.royal-select {
    min-height: 46px;
    color: var(--royal-text);
    border: 1px solid rgba(255,255,255,.16);
    background: rgba(0,0,0,.28);
}

.royal-form-control:focus,
.royal-select:focus {
    color: #fff;
    border-color: var(--royal-primary);
    background: rgba(0,0,0,.36);
    box-shadow: 0 0 0 .2rem rgba(255,11,99,.12);
}

.royal-select option {
    color: #fff;
    background: #101419;
}

.royal-stat-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 1rem;
}

.royal-stat {
    padding: 1.2rem;
    border: 1px solid var(--royal-border);
    border-radius: 10px;
    background: rgba(255,255,255,.025);
}

.royal-stat-value {
    font-family: "Cinzel", Georgia, serif;
    font-size: 1.8rem;
    font-weight: 700;
}

.royal-stat-label {
    color: var(--royal-muted);
    font-size: .76rem;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.royal-character-row {
    display: flex;
    gap: 1rem;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 0;
    border-bottom: 1px solid rgba(255,255,255,.08);
}

.royal-character-row:last-child {
    border-bottom: 0;
}

.royal-menu-dropdown .dropdown-menu {
    border: 1px solid var(--royal-border);
    background: #0c1015;
    box-shadow: var(--royal-shadow);
}

.royal-menu-dropdown .dropdown-item {
    color: #d9dadd;
}

.royal-menu-dropdown .dropdown-item:hover,
.royal-menu-dropdown .dropdown-item:focus {
    color: #fff;
    background: rgba(255,11,99,.09);
}

.royal-pagination .page-link {
    color: #e6e6e7;
    border-color: rgba(255,255,255,.12);
    background: rgba(255,255,255,.025);
}

.royal-pagination .page-item.active .page-link {
    border-color: var(--royal-primary);
    background: var(--royal-secondary);
}

.royal-pagination .page-item.disabled .page-link {
    color: #666;
    background: rgba(255,255,255,.015);
}

@media (max-width: 991.98px) {
    .royal-stat-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 575.98px) {
    .royal-stat-grid {
        grid-template-columns: 1fr;
    }

    .royal-character-row {
        align-items: flex-start;
        flex-direction: column;
    }

    .royal-character-actions {
        width: 100%;
        display: flex;
        gap: .5rem;
    }

    .royal-character-actions .btn {
        flex: 1;
        min-height: 44px;
    }
}

/* === M3D USER MANAGEMENT === */

.royal-badge-success {
    border-color: rgba(34,197,94,.42);
    color: #86efac;
    background: rgba(34,197,94,.08);
}

.royal-temp-password {
    min-height: 52px;
    color: #fff;
    border: 1px solid rgba(255,11,99,.48);
    background: rgba(0,0,0,.42);
    font-family: Consolas, "Courier New", monospace;
    font-size: 1.08rem;
    letter-spacing: .035em;
}

.royal-temp-password:focus {
    color: #fff;
    border-color: var(--royal-primary);
    background: rgba(0,0,0,.42);
    box-shadow: 0 0 0 .2rem rgba(255,11,99,.12);
}

.royal-menu-dropdown .dropdown-item.disabled {
    color: #6f747c;
    background: transparent;
    cursor: default;
}

@media (max-width: 991.98px) {
    .royal-menu-dropdown .dropdown-menu {
        margin-bottom: .5rem;
    }

    .royal-menu-dropdown .dropdown-item {
        min-height: 44px;
        display: flex;
        align-items: center;
    }
}

/* === M3E EVENT MANAGEMENT === */

.royal-player-picker {
    max-height: 480px;
    overflow-y: auto;
    border: 1px solid rgba(255,255,255,.10);
    border-radius: 10px;
    background: rgba(0,0,0,.18);
}

.royal-player-choice {
    display: flex;
    gap: .8rem;
    align-items: flex-start;
    padding: .8rem 1rem;
    margin: 0;
    border-bottom: 1px solid rgba(255,255,255,.07);
    cursor: pointer;
}

.royal-player-choice:last-child {
    border-bottom: 0;
}

.royal-player-choice:hover {
    background: rgba(255,11,99,.055);
}

.royal-player-choice .form-check-input {
    margin-top: .22rem;
    flex: 0 0 auto;
}

.royal-player-choice[hidden] {
    display: none !important;
}

.royal-participant-search {
    width: min(100%, 320px);
}

.royal-participant-badges {
    display: flex;
    flex-wrap: wrap;
    gap: .3rem;
    min-width: 220px;
}

.royal-name-preview {
    padding: 1rem;
    border: 1px solid rgba(34,197,94,.22);
    border-radius: 10px;
    background: rgba(34,197,94,.035);
}

.royal-sticky-action {
    position: sticky;
    bottom: 0;
    z-index: 50;
    display: flex;
    justify-content: flex-end;
    gap: .75rem;
    padding: 1rem;
    border: 1px solid var(--royal-border);
    border-radius: 12px 12px 0 0;
    background: rgba(8,11,15,.94);
    backdrop-filter: blur(12px);
    box-shadow: 0 -12px 38px rgba(0,0,0,.35);
}

@media (max-width: 575.98px) {
    .royal-sticky-action {
        flex-direction: column-reverse;
    }

    .royal-sticky-action .btn {
        min-height: 48px;
        width: 100%;
    }

    .royal-participant-search {
        width: 100%;
    }
}

/* === M3G: light theme + mobile polish === */
html[data-royal-theme="light"] {
    --royal-bg: #f5f2ec;
    --royal-bg-soft: #ece7df;
    --royal-panel: #ffffff;
    --royal-panel-2: #f7f3ee;
    --royal-text: #17191d;
    --royal-muted: #626973;
    --royal-border: rgba(17, 24, 39, .14);
}

html[data-royal-theme="light"] body {
    color: var(--royal-text);

    background-image:
        linear-gradient(rgba(255,255,255,.08), rgba(255,255,255,.18)),
        url("../images/backgrounds/royal-bg-light.png");

    background-size: cover;
    background-position: center top;
    background-repeat: no-repeat;
    background-attachment: fixed;
    background-color: var(--royal-bg);
}

html[data-royal-theme="light"] .navbar,
html[data-royal-theme="light"] .royal-navbar,
html[data-royal-theme="light"] .dropdown-menu {
    background: rgba(255,255,255,.96) !important;
    color: var(--royal-text);
    border-color: var(--royal-border);
}

html[data-royal-theme="light"] .navbar a,
html[data-royal-theme="light"] .dropdown-item,
html[data-royal-theme="light"] .navbar-brand {
    color: var(--royal-text);
}

html[data-royal-theme="light"] .dropdown-item:hover,
html[data-royal-theme="light"] .dropdown-item:focus {
    background: rgba(255, 11, 99, .08);
}

html[data-royal-theme="light"] .royal-panel,
html[data-royal-theme="light"] .royal-card,
html[data-royal-theme="light"] .royal-table-wrap {
    background: var(--royal-panel);
    color: var(--royal-text);
    border-color: var(--royal-border);
    box-shadow: 0 12px 30px rgba(31, 41, 55, .08);
}

html[data-royal-theme="light"] .royal-table,
html[data-royal-theme="light"] .table {
    --bs-table-color: var(--royal-text);
    --bs-table-bg: transparent;
    --bs-table-border-color: var(--royal-border);
}

html[data-royal-theme="light"] .royal-form-control,
html[data-royal-theme="light"] .royal-select,
html[data-royal-theme="light"] .form-control,
html[data-royal-theme="light"] .form-select {
    color: var(--royal-text);
    background-color: #fff;
    border-color: rgba(17,24,39,.18);
}

html[data-royal-theme="light"] .text-secondary,
html[data-royal-theme="light"] .royal-page-subtitle,
html[data-royal-theme="light"] .text-muted {
    color: var(--royal-muted) !important;
}

.royal-theme-toggle {
    position: fixed;
    right: 14px;
    bottom: 14px;
    z-index: 1080;
    min-width: 48px;
    min-height: 48px;
    padding: .6rem .85rem;
    border: 1px solid var(--royal-border);
    border-radius: 999px;
    color: var(--royal-text);
    background: var(--royal-panel);
    box-shadow: 0 8px 28px rgba(0,0,0,.22);
}

.royal-theme-toggle:hover,
.royal-theme-toggle:focus-visible {
    border-color: var(--royal-primary);
    outline: 3px solid rgba(255,11,99,.18);
}

.royal-secret-box {
    padding: .9rem 1rem;
    overflow-wrap: anywhere;
    border: 1px dashed var(--royal-border);
    background: var(--royal-bg-soft);
}

.royal-code-input {
    letter-spacing: .16em;
    font-size: 1.15rem;
    font-variant-numeric: tabular-nums;
}

.royal-recovery-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: .65rem;
}

.royal-recovery-grid code {
    display: block;
    padding: .7rem .85rem;
    text-align: center;
    border: 1px solid var(--royal-border);
    background: var(--royal-bg-soft);
}

@media (max-width: 767.98px) {
    .btn,
    .form-control,
    .form-select,
    .dropdown-item,
    .nav-link {
        min-height: 44px;
    }

    .royal-section {
        padding-top: 1.25rem;
        padding-bottom: 4.5rem;
    }

    .royal-panel {
        padding: 1rem;
    }

    .royal-page-title {
        line-height: 1.12;
    }

    .royal-table-wrap {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .royal-table {
        min-width: 720px;
    }

    .royal-recovery-grid {
        grid-template-columns: 1fr;
    }

    .royal-theme-toggle {
        right: 10px;
        bottom: 10px;
    }

    form .btn-royal-primary[type="submit"] {
        min-height: 48px;
    }
}

/* === M3H NOTES + CUBE === */
.cube-number-list { display: grid; gap: .65rem; }
.cube-number-row { display: grid; grid-template-columns: minmax(0, 1fr) 110px; gap: 1rem; align-items: center; padding: .65rem .75rem; border: 1px solid var(--royal-border); border-radius: 8px; background: rgba(255,255,255,.02); }
.cube-number-input { text-align: center; font-variant-numeric: tabular-nums; }
@media (max-width: 575.98px) { .cube-number-row { grid-template-columns: 1fr; gap: .4rem; } .cube-number-input { max-width: 100%; } }
/* === FINAL-B B3 THEME / RESPONSIVE POLISH ===
   Global polish only. The manually tuned disabled Cube Dungeon rules stay
   in templates/cube/run_form.html and are intentionally not moved/changed.
*/

html[data-royal-theme="dark"] { color-scheme: dark; }
html[data-royal-theme="light"] { color-scheme: light; }

/* Generic Bootstrap/Django controls used outside the royal-* form widgets. */
html[data-royal-theme="dark"] .form-control,
html[data-royal-theme="dark"] .form-select,
html[data-royal-theme="dark"] textarea.form-control {
    color: #f8f6ef;
    background-color: #11161c;
    border-color: rgba(255,255,255,.18);
}

html[data-royal-theme="dark"] .form-control:focus,
html[data-royal-theme="dark"] .form-select:focus,
html[data-royal-theme="dark"] textarea.form-control:focus {
    color: #fff;
    background-color: #0d1116;
    border-color: var(--royal-primary);
    box-shadow: 0 0 0 .2rem rgba(255,11,99,.12);
}

html[data-royal-theme="dark"] .form-control::placeholder,
html[data-royal-theme="dark"] textarea.form-control::placeholder {
    color: #8d949d;
    opacity: 1;
}

html[data-royal-theme="dark"] .form-control:disabled,
html[data-royal-theme="dark"] .form-select:disabled,
html[data-royal-theme="dark"] .form-control[readonly],
html[data-royal-theme="dark"] textarea.form-control:disabled,
html[data-royal-theme="dark"] textarea.form-control[readonly] {
    opacity: 1;
    color: #d7dadd;
    -webkit-text-fill-color: #d7dadd;
    background-color: #171b21;
    border-color: rgba(255,255,255,.15);
}

html[data-royal-theme="dark"] .form-select option {
    color: #f8f6ef;
    background: #101419;
}

html[data-royal-theme="light"] .form-control:disabled,
html[data-royal-theme="light"] .form-select:disabled,
html[data-royal-theme="light"] .form-control[readonly],
html[data-royal-theme="light"] textarea.form-control:disabled,
html[data-royal-theme="light"] textarea.form-control[readonly] {
    opacity: 1;
    color: #4b5563;
    -webkit-text-fill-color: #4b5563;
    background-color: #ece8e1;
    border-color: rgba(17,24,39,.16);
}

html[data-royal-theme="light"] .form-control::placeholder,
html[data-royal-theme="light"] textarea.form-control::placeholder {
    color: #7a8088;
    opacity: 1;
}

html[data-royal-theme="light"] .form-select option {
    color: #17191d;
    background: #fff;
}

.form-control,
.form-select,
textarea {
    max-width: 100%;
}

textarea.form-control {
    min-height: 7rem;
    resize: vertical;
}

input[type="datetime-local"],
input[type="date"],
input[type="time"] {
    color-scheme: inherit;
}

/* Checkbox/switch contrast in both themes. */
.form-check-input {
    width: 1.08em;
    height: 1.08em;
    border-width: 1px;
    border-color: rgba(255,255,255,.36);
    background-color: rgba(0,0,0,.28);
    box-shadow: none;
}

.form-check-input:checked {
    border-color: var(--royal-primary);
    background-color: var(--royal-primary);
}

.form-check-input:focus {
    border-color: var(--royal-primary);
    box-shadow: 0 0 0 .2rem rgba(255,11,99,.14);
}

.form-check-input:disabled {
    opacity: .68;
}

html[data-royal-theme="light"] .form-check-input {
    border-color: rgba(17,24,39,.34);
    background-color: #fff;
}

html[data-royal-theme="light"] .form-check-input:checked {
    border-color: var(--royal-primary);
    background-color: var(--royal-primary);
}

.form-check-label,
.royal-panel label {
    overflow-wrap: anywhere;
}

/* Light-theme contrast fixes for components that had fixed dark-theme colors. */
html[data-royal-theme="light"] .royal-auth-card {
    color: var(--royal-text);
    background: #fff;
    border-color: var(--royal-border);
    box-shadow: 0 18px 50px rgba(31,41,55,.12);
}

html[data-royal-theme="light"] .royal-hero-subtitle {
    color: #555d68;
}

html[data-royal-theme="light"] .royal-card-value {
    color: #17191d;
}

html[data-royal-theme="light"] .royal-link {
    color: #7d143d;
}

html[data-royal-theme="light"] .royal-link:hover,
html[data-royal-theme="light"] .royal-link:focus {
    color: #b01650;
}

html[data-royal-theme="light"] .royal-table thead th {
    color: #3f4650;
}

html[data-royal-theme="light"] .royal-table tbody tr:hover {
    background: rgba(255,11,99,.045);
}

html[data-royal-theme="light"] .royal-badge {
    color: #343a40;
    background: #f3efe9;
    border-color: rgba(17,24,39,.16);
}

html[data-royal-theme="light"] .royal-badge-success {
    color: #166534;
    background: #ecfdf3;
    border-color: rgba(22,101,52,.24);
}

html[data-royal-theme="light"] .royal-badge-warning {
    color: #854d0e;
    background: #fffbeb;
    border-color: rgba(133,77,14,.24);
}

html[data-royal-theme="light"] .royal-badge-danger {
    color: #991b1b;
    background: #fef2f2;
    border-color: rgba(153,27,27,.22);
}

html[data-royal-theme="light"] .btn-royal-secondary {
    color: #25282d;
    border-color: rgba(17,24,39,.22);
    background: rgba(17,24,39,.025);
}

html[data-royal-theme="light"] .btn-royal-secondary:hover,
html[data-royal-theme="light"] .btn-royal-secondary:focus {
    color: #17191d;
    border-color: rgba(176,22,80,.52);
    background: rgba(255,11,99,.07);
}

html[data-royal-theme="light"] .royal-sticky-action {
    color: var(--royal-text);
    background: rgba(255,255,255,.96);
    border-color: var(--royal-border);
    box-shadow: 0 -10px 28px rgba(31,41,55,.10);
}

html[data-royal-theme="light"] .royal-player-picker,
html[data-royal-theme="light"] .cube-number-row {
    color: var(--royal-text);
    background: #fff;
    border-color: var(--royal-border);
}

html[data-royal-theme="light"] .royal-player-choice:hover {
    background: rgba(255,11,99,.045);
}

html[data-royal-theme="light"] .royal-footer {
    color: var(--royal-muted);
    background: rgba(255,255,255,.025);
    border: 0;
    box-shadow: none;
}

/* Alerts/messages and approval UI need readable contrast in dark mode. */
html[data-royal-theme="dark"] .alert-secondary {
    color: #e5e7eb;
    background: rgba(148,163,184,.10);
    border-color: rgba(148,163,184,.28);
}

html[data-royal-theme="dark"] .alert-info {
    color: #bae6fd;
    background: rgba(14,165,233,.10);
    border-color: rgba(14,165,233,.28);
}

html[data-royal-theme="dark"] .alert-success {
    color: #bbf7d0;
    background: rgba(34,197,94,.10);
    border-color: rgba(34,197,94,.28);
}

html[data-royal-theme="dark"] .alert-warning {
    color: #fde68a;
    background: rgba(245,158,11,.10);
    border-color: rgba(245,158,11,.30);
}

html[data-royal-theme="dark"] .alert-danger {
    color: #fecaca;
    background: rgba(239,68,68,.10);
    border-color: rgba(239,68,68,.30);
}

.alert a {
    color: inherit;
    font-weight: 600;
    text-decoration: underline;
}

details > summary {
    color: inherit;
    cursor: pointer;
}

/* Pagination and dropdowns in light theme. */
html[data-royal-theme="light"] .royal-pagination .page-link {
    color: #343a40;
    background: #fff;
    border-color: rgba(17,24,39,.16);
}

html[data-royal-theme="light"] .royal-pagination .page-item.active .page-link {
    color: #fff;
    background: var(--royal-secondary);
    border-color: var(--royal-secondary);
}

html[data-royal-theme="light"] .royal-pagination .page-item.disabled .page-link {
    color: #8b929b;
    background: #f1eee9;
}

.royal-pagination {
    flex-wrap: wrap;
    gap: .2rem;
}

.royal-menu-dropdown .dropdown-menu {
    max-width: min(92vw, 30rem);
}

/* MFA QR stays scannable and never overflows narrow screens. */
.royal-secret-box img {
    display: block;
    max-width: 100%;
    height: auto;
}

/* Tables keep desktop density but scroll safely on narrow screens. */
.royal-table-wrap {
    overscroll-behavior-x: contain;
    scrollbar-gutter: stable;
}

.royal-table td,
.royal-table th {
    vertical-align: middle;
}

.royal-table td.d-flex,
.royal-table td .d-flex {
    flex-wrap: wrap;
}

.royal-table td form {
    margin-bottom: 0;
}

.royal-player-choice,
.royal-player-choice > span {
    min-width: 0;
}

.royal-player-choice > span {
    overflow-wrap: anywhere;
}

.btn {
    white-space: normal;
}

@media (max-width: 767.98px) {
    .royal-page-header {
        padding-top: 1.5rem;
    }

    .royal-page-header > .btn,
    .royal-page-header > form > .btn {
        min-height: 44px;
    }

    .royal-toolbar,
    .royal-panel .d-flex {
        min-width: 0;
    }

    .royal-menu-dropdown .dropdown-menu {
        width: 100%;
        max-width: 100%;
    }

    .royal-pagination .page-link {
        min-height: 44px;
        display: flex;
        align-items: center;
    }

    .royal-secret-box {
        max-width: 100%;
    }

    .royal-table {
        min-width: 680px;
    }
}

@media (max-width: 575.98px) {
    .royal-panel {
        min-width: 0;
    }

    .royal-page-header .d-flex,
    .royal-sticky-action {
        width: 100%;
    }

    .royal-table {
        min-width: 640px;
    }

    .royal-participant-badges {
        min-width: 0;
    }
}
/* === DUNGEON UNIFIED D2 === */
.royal-inline-field {
    min-width: 10rem;
}
.royal-dungeon-picker {
    position: relative;
}
.royal-dungeon-results {
    position: absolute;
    z-index: 1080;
    width: 100%;
    max-height: 19rem;
    overflow-y: auto;
    margin-top: .25rem;
    padding: .35rem;
    border: 1px solid var(--royal-border);
    border-radius: 8px;
    background: var(--royal-panel);
    box-shadow: var(--royal-shadow);
}
.royal-dungeon-result,
.royal-dungeon-result-empty {
    display: block;
    width: 100%;
    padding: .65rem .75rem;
    border: 0;
    border-radius: 6px;
    color: var(--royal-text);
    background: transparent;
    text-align: left;
}
.royal-dungeon-result:hover,
.royal-dungeon-result:focus,
.royal-dungeon-result.active {
    color: #fff;
    background: rgba(255,11,99,.14);
    outline: none;
}
.royal-dungeon-result-empty {
    color: var(--royal-muted);
}
html[data-royal-theme="light"] .royal-dungeon-results {
    background: #fff;
}
html[data-royal-theme="light"] .royal-dungeon-result,
html[data-royal-theme="light"] .royal-dungeon-result-empty {
    color: var(--royal-text);
}
html[data-royal-theme="light"] .royal-dungeon-result:hover,
html[data-royal-theme="light"] .royal-dungeon-result:focus,
html[data-royal-theme="light"] .royal-dungeon-result.active {
    color: var(--royal-text);
    background: rgba(255,11,99,.07);
}
.royal-header-sort {
    border: 0;
    padding: 0;
    color: inherit;
    background: transparent;
    font: inherit;
    font-weight: 700;
    text-align: left;
}
.royal-header-sort:hover,
.royal-header-sort:focus {
    color: var(--royal-primary);
}
.royal-dungeon-table th {
    min-width: 7.5rem;
    vertical-align: top;
}
.royal-dungeon-table th:nth-child(2) {
    min-width: 13rem;
}
.royal-dungeon-table th input,
.royal-dungeon-table th select {
    min-width: 7rem;
}


/* A6: compact column sorting/filtering inside table headers. */
.royal-filter-table thead th {
    vertical-align: top;
    min-width: 7.5rem;
}
.royal-header-sort {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    min-height: 1.8rem;
}
.royal-header-sort.is-active {
    color: var(--royal-primary);
}
.royal-sort-indicator {
    display: inline-block;
    min-width: 1rem;
    text-align: center;
    font-size: .82em;
    opacity: .82;
}
.royal-column-filter {
    position: relative;
    margin-top: .45rem;
}
.royal-column-filter .form-control,
.royal-column-filter .form-select {
    min-width: 6.75rem;
    font-size: .82rem;
    padding-top: .3rem;
    padding-bottom: .3rem;
}
.royal-column-filter.is-active .form-control,
.royal-column-filter.is-active .form-select {
    border-color: var(--royal-primary);
    box-shadow: 0 0 0 .12rem rgba(255, 11, 99, .14);
}
.royal-filter-clear {
    margin-top: .3rem;
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--royal-primary);
    font-size: .76rem;
    text-decoration: underline;
    text-underline-offset: .15rem;
}
.royal-filter-actions {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
    margin-top: .75rem;
}
.royal-filter-global {
    display: flex;
    flex-wrap: wrap;
    gap: .75rem;
    align-items: end;
    margin-bottom: 1rem;
}
.royal-filter-global > * {
    min-width: min(100%, 12rem);
}
@media (max-width: 767.98px) {
    .royal-filter-table thead th {
        min-width: 8.25rem;
    }
    .royal-column-filter .form-control,
    .royal-column-filter .form-select {
        font-size: .78rem;
    }
}


/* ROYAL ACCEPTANCE POLISH 2026-09-17 */
#speedrun-valid-inline[hidden] { display: none !important; }

html[data-royal-theme="light"] .navbar-toggler-icon { filter: invert(1) grayscale(1) contrast(1.35); }

html[data-royal-theme="light"] .navbar .navbar-text,
html[data-royal-theme="light"] .navbar .text-white-50,
html[data-royal-theme="light"] .navbar .text-light { color: #374151 !important; }

html[data-royal-theme="dark"] .form-text,
html[data-royal-theme="dark"] .text-secondary,
html[data-royal-theme="dark"] .text-muted { color: #cbd5e1 !important; }

html[data-royal-theme="dark"] .text-success,
html[data-royal-theme="dark"] .royal-selected-label { color: #86efac !important; }


/* ROYAL ACCEPTANCE FOLLOW-UP V3 2026-09-17 */
.royal-home-primary-cta,
.royal-home-primary-cta:visited { color:#fff !important; background:#ff0b63 !important; border-color:#ff0b63 !important; }
.royal-home-primary-cta:hover,
.royal-home-primary-cta:focus { color:#fff !important; background:#d90855 !important; border-color:#d90855 !important; }
html[data-royal-theme="light"] .navbar .navbar-text,
html[data-royal-theme="light"] .navbar .text-white-50,
html[data-royal-theme="light"] .navbar .text-light { color:#374151 !important; }
html[data-royal-theme="light"] .navbar .nav-link,
html[data-royal-theme="light"] .navbar .navbar-brand,
html[data-royal-theme="light"] .navbar .dropdown-toggle { color:#1f2937 !important; }
html[data-royal-theme="light"] .navbar .nav-link:hover,
html[data-royal-theme="light"] .navbar .nav-link:focus,
html[data-royal-theme="light"] .navbar .nav-link.active,
html[data-royal-theme="light"] .navbar .dropdown-toggle:hover,
html[data-royal-theme="light"] .navbar .dropdown-toggle:focus,
html[data-royal-theme="light"] .navbar .dropdown-toggle.show { color:#b00045 !important; background:rgba(255,11,99,.08) !important; }
.royal-entry-type-grid { display:grid; grid-template-columns:minmax(0,1fr) minmax(0,1fr); gap:1rem; align-items:stretch; }
.royal-entry-type-half { min-width:0; }
.royal-entry-type-half + .royal-entry-type-half { border-left:1px solid var(--royal-border); padding-left:1rem; }
@media (max-width:767.98px) {
  .royal-entry-type-grid { grid-template-columns:1fr; }
  .royal-entry-type-half + .royal-entry-type-half { border-left:0; border-top:1px solid var(--royal-border); padding-left:0; padding-top:1rem; }
}

/* UI POLISH AUDIT FIXES: scoped presentation only */
html[data-royal-theme="light"] .royal-menu-dropdown .dropdown-item:hover,
html[data-royal-theme="light"] .royal-menu-dropdown .dropdown-item:focus {
    color: #671334; background: #f8e5ec;
}
.royal-navbar .royal-theme-toggle {
    position: static; inset: auto; z-index: auto; flex: 0 0 auto;
    margin-left: .75rem; box-shadow: none; align-self: center;
}
.royal-main > .royal-section:first-child { padding-top: 2.5rem; }
.royal-main > .royal-section:first-child > .container > .royal-page-header:first-child { padding-top: 1.25rem; }
.royal-table.royal-dashboard-ranking { min-width: 0; width: 100%; table-layout: fixed; }
.royal-table.royal-dashboard-ranking th, .royal-table.royal-dashboard-ranking td { white-space: normal; overflow-wrap: anywhere; padding: .65rem .4rem; }
.royal-dashboard-ranking th:first-child { width: 10%; }
.royal-dashboard-ranking th:nth-child(2) { width: 42%; }
.royal-dungeon-table th.royal-dungeon-points, .royal-dungeon-table td.royal-dungeon-points { min-width: 9.5rem; width: 10rem; white-space: normal; }
.royal-dungeon-points > div { white-space: nowrap; }
.royal-dungeon-points > div > .small { display: block; white-space: normal; }
.royal-dungeon-type .royal-badge { margin: .15rem .2rem .15rem 0; }
.royal-table.royal-catalog-table thead th { min-width: 5rem; white-space: normal; }
.royal-table.royal-catalog-table th:first-child { min-width: 15rem; width: 32%; }
.royal-table.royal-catalog-table th:nth-child(2), .royal-table.royal-catalog-table th:nth-child(5) { min-width: 6.5rem; }
.royal-catalog-table .royal-column-filter { min-width: 0; }
.royal-catalog-table .royal-column-filter .form-control, .royal-catalog-table .royal-column-filter .form-select { min-width: 0; }
.royal-catalog-actions { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; }
.royal-catalog-actions form { margin: 0; }
.royal-cube-number-actions { align-items: center; justify-content: flex-end; gap: .4rem !important; }
.royal-cube-number-actions .btn { padding: .45rem .65rem; font-size: .875rem; white-space: nowrap; }
.royal-cube-number-actions form { margin: 0; }
.form-control.cube-number-input { width: calc(4ch + 1.5rem); min-width: 0; max-width: 100%; }
#audit-table-filter { padding: .75rem 1rem; }
#audit-table-filter .royal-filter-global { gap: .5rem; align-items: end; margin-bottom: 0; }
#audit-table-filter .royal-filter-global > button { min-width: 0; flex: 0 0 auto; }
#audit-table-filter .royal-filter-global > label { flex: 1 1 18rem; min-width: 0; max-width: 32rem; }
.audit-detail-cell { min-width: 14rem; max-width: 30rem; white-space: normal; overflow-wrap: anywhere; line-height: 1.35; }
.audit-detail-cell .mb-2 { margin-bottom: .2rem !important; }
.royal-audit-delete { font-size: .75rem; padding: .2rem .45rem; border-color: transparent; margin-top: .35rem; }
.royal-audit-delete:focus-visible { outline: 2px solid currentColor; outline-offset: 2px; }
.royal-season-blockers { max-width: 28rem; line-height: 1.35; }
.royal-season-blockers summary { cursor: pointer; font-weight: 500; }
.royal-season-blockers ul { margin-top: .35rem; }
@media (max-width: 991.98px) {
    .royal-navbar .royal-theme-toggle { align-self: flex-start; margin: .5rem 0 0; }
}
@media (max-width: 767.98px) {
    .royal-main > .royal-section:first-child { padding-top: .625rem; }
    .royal-main > .royal-section:first-child > .container > .royal-page-header:first-child { padding-top: .75rem; }
    .royal-cube-number-actions { justify-content: flex-start; }
}

/* UI POLISH V3 — manual acceptance corrections */
.royal-navbar-actions{display:flex;align-items:center;gap:.55rem;flex:0 0 auto;flex-wrap:nowrap;margin-left:.5rem}
.royal-navbar-actions .royal-navbar-logout{margin:0;flex:0 0 auto}
.royal-navbar-actions .royal-theme-toggle{position:static!important;inset:auto!important;margin:0!important;align-self:center!important;flex:0 0 auto}
html[data-royal-theme="light"] .royal-menu-dropdown .dropdown-item:hover,
html[data-royal-theme="light"] .royal-menu-dropdown .dropdown-item:focus,
html[data-royal-theme="light"] .royal-menu-dropdown .dropdown-item:focus-visible{color:#b00045!important;background:rgba(255,11,99,.10)!important}
.royal-main>.royal-section:first-child{padding-top:1rem!important}
.royal-main>.royal-section:first-child>.container>.royal-page-header:first-child{padding-top:.5rem!important}
.royal-dashboard-table-wrap{width:100%;overflow-x:visible}
.royal-dashboard-table-wrap .royal-dashboard-ranking{min-width:0!important;width:100%!important;table-layout:fixed;margin-bottom:0}
.royal-dashboard-ranking th,.royal-dashboard-ranking td{min-width:0!important;white-space:normal;overflow-wrap:anywhere}
.royal-dashboard-ranking th:first-child{width:10%}.royal-dashboard-ranking th:nth-child(2){width:42%}.royal-dashboard-ranking th:nth-child(3){width:24%}.royal-dashboard-ranking th:nth-child(4){width:24%}
.royal-dungeon-type{min-width:9rem!important}.royal-dungeon-type-stack{display:flex;flex-wrap:wrap;align-items:center;gap:.3rem}.royal-dungeon-type-stack .royal-badge{margin:0!important}
.royal-dungeon-table th.royal-dungeon-points,.royal-dungeon-table td.royal-dungeon-points{min-width:12rem!important;width:12rem;white-space:normal}
.royal-dungeon-points-stack{display:flex;flex-direction:column;gap:.2rem}.royal-dungeon-points-row{display:flex;align-items:baseline;gap:.3rem;white-space:nowrap}.royal-dungeon-points-label{font-weight:600}.royal-dungeon-points-note{font-size:.78rem;white-space:nowrap}
.royal-catalog-table{table-layout:fixed;width:100%}.royal-catalog-table col.royal-catalog-col-name{width:27%}.royal-catalog-table col.royal-catalog-col-category{width:13%}.royal-catalog-table col.royal-catalog-col-points{width:10%}.royal-catalog-table col.royal-catalog-col-usage{width:9%}.royal-catalog-table col.royal-catalog-col-state{width:11%}.royal-catalog-table col.royal-catalog-col-actions{width:30%}
.royal-catalog-table th,.royal-catalog-table td{min-width:0!important}.royal-catalog-actions-cell{white-space:nowrap}.royal-catalog-actions{display:flex;flex-wrap:nowrap!important;align-items:center;gap:.4rem;white-space:nowrap}.royal-catalog-actions form{margin:0;flex:0 0 auto}.royal-catalog-actions .btn{flex:0 0 auto}
.royal-cube-number-actions{display:flex!important;flex-wrap:nowrap!important;align-items:center;justify-content:flex-end;gap:.45rem!important}.royal-cube-number-actions form{margin:0;flex:0 0 auto}.royal-cube-number-actions .btn{white-space:nowrap}
.royal-cube-number-table{table-layout:fixed;width:100%}.royal-cube-number-table col.royal-cube-col-order{width:12%}.royal-cube-number-table col.royal-cube-col-name{width:34%}.royal-cube-number-table col.royal-cube-col-state{width:24%}.royal-cube-number-table col.royal-cube-col-value{width:30%}.royal-cube-number-cell{text-align:left}
.form-control.cube-number-input{display:inline-block;width:5.25rem!important;min-width:5.25rem!important;max-width:5.25rem!important;text-align:center}
.royal-audit-search{padding:.55rem .75rem!important}.royal-audit-search .royal-filter-global{display:flex;flex-wrap:nowrap;align-items:end;gap:.45rem;margin:0}.royal-audit-search .royal-filter-global>label{flex:0 1 26rem;max-width:26rem;min-width:14rem}.royal-audit-search .royal-filter-global>button{flex:0 0 auto;min-width:0}
.audit-detail-cell{min-width:11rem;max-width:22rem}.royal-audit-detail{font-size:.84rem}.royal-audit-detail>summary{cursor:pointer;color:var(--royal-muted);font-weight:600;white-space:nowrap}.royal-audit-detail-body{margin-top:.4rem;padding-left:.55rem;border-left:2px solid var(--royal-border)}.royal-audit-detail-heading{font-weight:700;margin:.35rem 0 .15rem}.royal-audit-detail-row{display:grid;grid-template-columns:minmax(5.5rem,auto) minmax(0,1fr);gap:.35rem;line-height:1.25;overflow-wrap:anywhere}.royal-audit-delete{font-size:.72rem!important;padding:.16rem .38rem!important;margin-top:.25rem}
.royal-season-blockers{display:inline-block;max-width:26rem}.royal-season-blockers>summary{display:inline-flex;align-items:center;gap:.4rem;cursor:pointer;list-style:none}.royal-season-blockers>summary::-webkit-details-marker{display:none}.royal-season-blockers-hint{font-size:.78rem;color:var(--royal-muted)}.royal-season-blockers-body{margin-top:.35rem;padding:.45rem .6rem;border:1px solid var(--royal-border);border-radius:8px;background:rgba(255,255,255,.02);font-size:.82rem;line-height:1.3}
@media(max-width:991.98px){.royal-navbar-actions{margin:.65rem 0 0;justify-content:flex-start;flex-wrap:wrap}.royal-dashboard-table-wrap{overflow-x:auto}.royal-dashboard-table-wrap .royal-dashboard-ranking{min-width:640px!important}.royal-catalog-table{min-width:980px}.royal-catalog-actions{flex-wrap:wrap!important;white-space:normal}.royal-cube-number-actions{flex-wrap:wrap!important;justify-content:flex-start}.royal-audit-search .royal-filter-global{flex-wrap:wrap}}
@media(max-width:767.98px){.royal-main>.royal-section:first-child{padding-top:.5rem!important}.royal-main>.royal-section:first-child>.container>.royal-page-header:first-child{padding-top:.25rem!important}}

/* UI FINAL POLISH — accepted follow-up */
@media (min-width: 992px) {
    .royal-stat-grid {
        grid-template-columns: repeat(5, minmax(0, 1fr));
        gap: .75rem;
    }
    .royal-stat {
        padding: 1rem;
    }
}
.royal-dungeon-table thead th,
.royal-dungeon-table thead .royal-header-sort {
    font-family: inherit;
    font-size: .78rem;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
}
.royal-dungeon-extras {
    min-width: 10.5rem;
}
.royal-dungeon-extra-filters {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: .35rem;
}
.royal-dungeon-extra-filters .form-select {
    min-width: 0;
}
.royal-dungeon-extra-badges {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .3rem;
    min-height: 1.8rem;
}
.royal-dungeon-extra-badges:empty {
    min-height: 0;
}

/* A13 review workspace: shared Royal theme tokens, no global overrides. */
.a13-ui .a13-nav{display:flex;gap:.5rem;flex-wrap:wrap;margin:0 0 1rem}
.a13-ui .a13-nav [aria-current="page"]{border-color:var(--royal-primary);box-shadow:inset 0 -2px var(--royal-primary)}
.a13-head{display:flex;align-items:center;justify-content:space-between;gap:1rem;margin-bottom:1rem}
.a13-head h1{margin-bottom:.4rem}
.a13-ui .royal-panel{padding:1rem;margin-bottom:1rem;background:var(--royal-panel);min-width:0}
.a13-meta>summary,.a13-slot>summary{cursor:pointer;padding:.3rem;font-weight:600}
.a13-meta-grid{display:grid;grid-template-columns:1fr 1fr;gap:1rem;margin-top:1rem}
.a13-workspace{display:grid;grid-template-columns:minmax(240px, .75fr) minmax(0,1.8fr);gap:1rem;align-items:start}
.a13-sources{position:sticky;top:1rem}
.a13-source{border:1px solid var(--royal-border);border-radius:.65rem;padding:.8rem;margin-bottom:.75rem;overflow-wrap:anywhere}
.a13-source img{display:block;width:100%;height:170px;object-fit:contain;background:var(--royal-bg-soft);border-radius:.35rem;margin:.5rem 0}
.a13-review{min-width:0}.a13-review-main{margin-top:0!important}
.a13-fields{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:.75rem;margin:1rem 0}
.a13-field{padding:.8rem;border:1px solid var(--royal-border);border-radius:.65rem;min-width:0}
.a13-field-values>div{width:100%;margin-bottom:.5rem}
.a13-ui pre{white-space:pre-wrap;overflow-wrap:anywhere;max-height:14rem;overflow:auto;font-size:.85rem}
.a13-ui .a13-slot{border:1px solid var(--royal-border);border-radius:.5rem;margin:.5rem 0;padding:.5rem}
.a13-ui .a13-slot summary:focus-visible,.a13-ui a:focus-visible{outline:2px solid var(--royal-primary);outline-offset:3px}
.a13-ui .a13-click-row{cursor:pointer}.a13-ui .a13-click-row:hover,.a13-ui .a13-click-row:focus-within{background:var(--royal-bg-soft);outline:1px solid var(--royal-primary);outline-offset:-1px}
.a13-ui .a13-click-row a[data-a13-link]{color:var(--royal-text);text-decoration:underline;text-underline-offset:3px}
.a13-ui button:disabled{opacity:.5;cursor:not-allowed}
.a13-ui label{max-width:100%}.a13-ui input:not([type=checkbox]):not([type=radio]),.a13-ui select,.a13-ui textarea{max-width:100%}
@media(max-width:1100px){.a13-fields{grid-template-columns:1fr}}
@media(max-width:767px){.a13-workspace,.a13-meta-grid{grid-template-columns:1fr}.a13-sources{position:static}.a13-source-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:.5rem}.a13-source img{height:120px}.a13-head{align-items:flex-start;flex-direction:column}.a13-ui .a13-nav{flex-wrap:nowrap;overflow-x:auto;padding-bottom:.4rem}.a13-nav a{white-space:nowrap}}
@media(max-width:420px){.a13-source-grid{grid-template-columns:1fr}}

.a13-reservation{display:flex;flex-wrap:wrap;gap:.5rem 1rem;align-items:center}.a13-reservation h2,.a13-reservation p{margin:0}.a13-reservation>p:last-child{flex-basis:100%;font-size:.85rem;color:var(--royal-muted)}
.a13-field>summary{cursor:pointer;font-size:.9rem;font-weight:600;line-height:1.5}.a13-field-state{display:block;font-size:.8rem;color:var(--royal-muted);font-weight:400}.a13-field-body{margin-top:.75rem}
.a13-decisions{display:grid;grid-template-columns:1fr 1fr;gap:1rem}.a13-decisions form{margin-top:0!important}.a13-decisions p{font-size:.85rem}.a13-decisions textarea{min-height:5rem;height:5rem}.a13-decisions button{margin-top:.5rem}
.a13-ui .a13-meta{font-size:.9rem}.a13-ui .a13-review p{margin-bottom:.65rem}.a13-review details{margin-bottom:.5rem!important}
@media(max-width:767px){.a13-decisions{grid-template-columns:1fr}.a13-source-grid{grid-template-columns:repeat(2,minmax(0,1fr))}.a13-source img{height:80px}.a13-source{padding:.5rem}.a13-source p{font-size:.7rem}.a13-sources>p{font-size:.8rem}}
/* === GLOBAL DISCLOSURE / ROZBALOVACI PRVKY === */

details > summary {
    display: flex;
    align-items: center;
    gap: .45rem;
    color: inherit;
    cursor: pointer;
    list-style: none;
    border-radius: 6px;
    transition:
        background-color .18s ease,
        color .18s ease;
}

details > summary::-webkit-details-marker {
    display: none;
}

details > summary::before {
    content: "▶";
    display: inline-block;
    flex: 0 0 auto;
    color: var(--royal-primary);
    font-size: .72em;
    line-height: 1;
    transform: rotate(0deg);
    transform-origin: center;
    transition: transform .18s ease;
}

details[open] > summary::before {
    transform: rotate(90deg);
}

details > summary:hover {
    background: rgba(255, 11, 99, .08);
}

details > summary:focus-visible {
    outline: 2px solid var(--royal-primary);
    outline-offset: 3px;
}

/* === GLOBAL RESPONSIVE PAGE WIDTH === */

.royal-main > .royal-section > .container {
    width: calc(100% - 3rem);
    max-width: 1600px;
    margin-left: auto;
    margin-right: auto;
}

/* Horní menu zůstává kompaktní a jednotné */
.royal-navbar > .container,
.royal-navbar .container {
    width: calc(100% - 3rem);
    max-width: 1320px;
    margin-left: auto;
    margin-right: auto;
}

@media (max-width: 1600px) {
    .royal-main > .royal-section > .container,
    .royal-navbar .container {
        width: calc(100% - 1.5rem);
        max-width: none;
    }
}

/* === DUNGEON WIDE LAYOUT === */

@media (min-width: 1200px) {
    .royal-main > .royal-section > .container.royal-dungeon-page {
        width: 94vw;
        max-width: 94vw;
        margin-left: auto;
        margin-right: auto;
    }
}

/* Shared content surfaces. Dashboard reference: .88/.96; target: .78/.86.
   Keep theme tokens used by navigation, controls and feedback unchanged. */
.royal-main {
    --royal-content-surface: linear-gradient(145deg, rgba(25,31,38,.78), rgba(10,14,19,.86));
}

html[data-royal-theme="light"] .royal-main {
    --royal-content-surface: rgba(255,255,255,.90);
    color: #11151b;
}

html[data-royal-theme] .royal-main :is(.royal-panel, .royal-card, .royal-stat, .royal-table-wrap,
    .evidence-upload-card, .evidence-note-wrap, .evidence-info-card,
    .royal-screenshot-settings .card):not(:where(.modal, .modal *, .alert, .alert *,
    .royal-sticky-action, .royal-sticky-action *, .a13-sources, .a13-sources *, .sticky-top, .fixed-top, .fixed-bottom)) {
    background: var(--royal-content-surface);
}

/* Nested table wrappers share their panel's surface instead of doubling opacity. */
html[data-royal-theme] .royal-main :is(.royal-panel, .royal-card) .royal-table-wrap:not(:where(
    .modal *, .alert *, .royal-sticky-action *, .a13-sources *)) {
    background: transparent;
}

html[data-royal-theme="light"] .royal-main :is(.royal-panel, .royal-card, .royal-stat,
    .royal-table-wrap, .royal-table):not(:where(.royal-link, .modal, .modal *, .alert, .alert *,
    .royal-sticky-action, .royal-sticky-action *, .a13-sources, .a13-sources *)) {
    color: #11151b;
}

html[data-royal-theme="light"] .royal-main :is(.text-secondary, .text-muted,
    .form-text, .royal-page-subtitle, .royal-eyebrow, .royal-card-label,
    .royal-stat-label, .royal-hero-subtitle):not(:where(.modal *, .alert *,
    .royal-sticky-action *, .a13-sources *)) {
    color: #4b535f !important;
}

html[data-royal-theme="light"] .royal-main .royal-table thead th {
    color: #343c47;
}
