.app-shell {
    position: relative;
}

.desktop-sidebar {
    /* Alta quanto lo schermo e non quanto la pagina: lingua, casa ed Esci
       restano in basso mentre il contenuto scorre. */
    position: sticky;
    top: 0;
    align-self: flex-start;
    height: 100vh;
    height: 100dvh;
    overflow-y: auto;
    background: linear-gradient(180deg, rgba(8, 9, 12, 0.96) 0%, rgba(20, 22, 28, 0.9) 62%, rgba(24, 50, 45, 0.8) 100%);
    border-right: 1px solid var(--border-soft);
    box-shadow: 6px 0 30px rgba(0, 0, 0, 0.42);
}

.sidebar-nav .nav-link {
    color: rgba(230, 223, 210, 0.85);
    border: 1px solid transparent;
    border-radius: 0.8rem;
    padding: 0.6rem 0.85rem;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: .55rem;
}

.sidebar-nav .nav-link:hover,
.sidebar-nav .nav-link.active {
    background: linear-gradient(120deg, rgba(75, 30, 42, 0.35), rgba(24, 50, 45, 0.35));
    border-color: rgba(194, 164, 109, 0.4);
    color: #fff4dd;
    box-shadow: 0 0 0.65rem rgba(194, 164, 109, 0.16);
}

.menu-unread-badge {
    min-width: 1.35rem;
    height: 1.35rem;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-left: auto;
    padding: 0 .35rem;
    background: #dc3545;
    color: #fff;
    font-size: .72rem;
    font-weight: 700;
    line-height: 1;
    box-shadow: 0 0 0 .15rem rgba(220, 53, 69, .28);
}

.main-content {
    padding: 1.1rem 1.25rem 2rem;
}

.game-version-badge {
    position: fixed;
    right: 0.85rem;
    bottom: 0.65rem;
    z-index: 3;
    font-size: 0.7rem;
    color: rgba(230, 223, 210, 0.6);
    background-color: rgba(8, 9, 12, 0.38);
    border: 1px solid rgba(194, 164, 109, 0.18);
    border-radius: 999px;
    padding: 0.15rem 0.45rem;
    pointer-events: none;
    user-select: none;
}

.content-header {
    padding: 1rem 1.1rem;
}

/* Cambio casa nell'intestazione: frecce e scelta diretta. */
.house-switcher {
    display: flex;
    align-items: center;
    gap: .35rem;
    margin-top: .35rem;
}

.house-switcher .form-select {
    width: auto;
    max-width: 16rem;
    min-width: 0;
}

.house-switcher .btn {
    min-width: 2.25rem;
    min-height: 2.25rem;
}

/* Nome della casa nel titolo: si preme per rinominarla. */
.house-name-button {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0 0.15rem;
    border: 0;
    border-bottom: 1px dashed currentColor;
    background: none;
    color: inherit;
    font: inherit;
    letter-spacing: inherit;
    text-transform: inherit;
    text-align: start;
    overflow-wrap: anywhere;
    cursor: pointer;
}

.house-name-button i {
    font-size: 0.8em;
    opacity: 0.75;
}

.house-name-button:hover,
.house-name-button:focus-visible {
    color: var(--aged-gold-bright);
}

.house-name-button:focus-visible {
    outline: 2px solid var(--aged-gold);
    outline-offset: 2px;
}

.route-title {
    color: var(--aged-gold);
    margin: 0;
    font-size: 1.15rem;
}

.route-pane {
    display: none;
    animation: fadeIn 0.22s ease;
}

.route-pane.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(3px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 0.8rem;
}

.stats-card {
    padding: .85rem;
    border-radius: .9rem;
    border: 1px solid rgba(194, 164, 109, 0.22);
    background: rgba(8, 9, 12, 0.45);
}

.stats-label {
    font-size: .78rem;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: rgba(230, 223, 210, 0.75);
}

.stats-value {
    font-size: 1.35rem;
    font-weight: 700;
    color: #f5e9d0;
    line-height: 1.15;
}

.notifications-messages-pane .section-subtitle {
    color: var(--aged-gold);
    letter-spacing: .04em;
    text-transform: uppercase;
}

.notifications-messages-pane .list-group-item:hover,
.notifications-messages-pane .list-group-item:focus,
.notifications-messages-pane .list-group-item.active {
    background: linear-gradient(110deg, rgba(24, 50, 45, 0.56), rgba(75, 30, 42, 0.48));
    border-color: rgba(194, 164, 109, 0.4);
    color: #fff2d7;
}

.message-list-shell {
    height: 360px;
    overflow-y: auto;
    overflow-x: hidden;
    word-break: break-word;
    border: 1px solid rgba(194, 164, 109, 0.24);
    border-radius: .65rem;
    background: rgba(8, 9, 12, 0.72);
    padding: .7rem;
    margin-bottom: .5rem;
    display: flex;
    flex-direction: column;
    gap: .5rem;
}

/* Messaggi a bolle: i propri a destra, quelli ricevuti a sinistra. */
.message-bubble {
    max-width: min(80%, 34rem);
    padding: .45rem .7rem .5rem;
    border-radius: .9rem;
    border: 1px solid rgba(194, 164, 109, 0.2);
}

.message-bubble.theirs {
    align-self: flex-start;
    background: rgba(35, 38, 46, 0.95);
    border-bottom-left-radius: .25rem;
}

.message-bubble.mine {
    align-self: flex-end;
    background: linear-gradient(135deg, rgba(24, 50, 45, 0.95), rgba(36, 81, 70, 0.9));
    border-color: rgba(194, 164, 109, 0.35);
    border-bottom-right-radius: .25rem;
}

.message-meta {
    font-size: .7rem;
    color: rgba(230, 223, 210, 0.6);
    margin-bottom: .15rem;
}

.message-text {
    white-space: pre-wrap;
}

/* Notifiche: tipo e data in alto, le non lette evidenziate. */
.notification-item.unread {
    border-left: 3px solid var(--aged-gold);
}

/* Conversazioni: chi ha scritto messaggi non ancora letti si illumina. */
.conversation-item {
    display: flex;
    align-items: center;
    gap: .5rem;
}

.conversation-item .conversation-name {
    flex-grow: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.conversation-item.has-unread {
    border-left: 3px solid var(--aged-gold);
    background-color: rgba(194, 164, 109, 0.18);
    font-weight: 600;
}

.notification-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .5rem;
    margin-bottom: .25rem;
}

/* Rapporto di battaglia dentro la notifica, chiuso di default. */
.battle-report summary {
    cursor: pointer;
    color: var(--aged-gold);
    font-size: .85rem;
}

.battle-report-turn,
.battle-report-result {
    margin-top: .5rem;
}

.battle-report-table {
    font-size: .78rem;
    caption-side: top;
}

.battle-report-table caption {
    padding: 0 0 .15rem;
    color: rgba(230, 223, 210, 0.75);
}

.notification-type {
    font-weight: 700;
    color: var(--aged-gold);
    text-transform: uppercase;
    letter-spacing: .04em;
    font-size: .78rem;
}

.notification-time {
    margin-left: auto;
    font-size: .75rem;
    color: rgba(230, 223, 210, 0.55);
}

.form-inline-grid {
    display: grid;
    gap: .75rem;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    align-items: end;
}

.expedition-step {
    min-width: 0;
}

.expedition-step-target {
    grid-column: 1 / -1;
}

.expedition-step-full {
    grid-column: 1 / -1;
}

.henchman-count-card {
    min-width: 140px;
}

.expedition-unit-cell {
    min-width: 170px;
}

.expedition-unit-cell .btn {
    border-radius: 0 999px 999px 0;
    font-size: .7rem;
}

.capacity-progress {
    height: .5rem;
    max-width: 28rem;
}

.capacity-progress .progress-bar {
    width: 0;
    background: linear-gradient(90deg, #245146, #3b7969);
    transition: width .2s ease;
}

.capacity-progress .progress-bar.over-capacity {
    background: linear-gradient(90deg, #7d2e45, #c2455a);
}

.expedition-form-feedback {
    color: #e6b872;
}

.expedition-form-feedback:empty {
    display: none;
}

@media (min-width: 1200px) {
    .form-inline-grid {
        grid-template-columns: repeat(2, minmax(220px, 1fr));
    }
}

.mobile-topbar {
    position: sticky;
    top: 0;
    z-index: 1040;
    backdrop-filter: blur(2px);
    background: rgba(8, 9, 12, 0.85);
    border-bottom: 1px solid var(--border-soft);
}

/* Panoramica: una scheda per casa, quella aperta evidenziata. */
.house-overview-card.is-current {
    border-color: var(--aged-gold);
}

.house-overview-card .panel-header .btn,
.house-overview-card .panel-header .badge {
    flex-shrink: 0;
}

/* −1 / +1 accanto alle quantita' delle spedizioni: comodi da toccare. */
.input-group .step-button {
    min-width: 2.25rem;
    font-weight: 600;
}

/* Pannello admin dei bot: campo compatto per "Aggiungi/Togli N". */
.admin-bot-delta {
    max-width: 6rem;
}
