.tow-theater-context {
    --tow-context-accent: #e9a61a;
    position: relative;
    width: 100vw;
    margin: 0 0 34px calc(50% - 50vw);
    overflow: hidden;
    border-top: 1px solid rgba(233, 166, 26, .38);
    border-bottom: 1px solid rgba(233, 166, 26, .34);
    background: #03102a;
    color: #e8edf4;
}

.tow-theater-context__art {
    position: absolute;
    inset: 0;
    background-position: center;
    background-size: cover;
    opacity: .52;
    pointer-events: none;
}

.tow-theater-context--air .tow-theater-context__art {
    background-image: linear-gradient(90deg, #020817 4%, rgba(2, 8, 23, .90) 42%, rgba(2, 8, 23, .32) 78%, rgba(2, 8, 23, .72) 100%), url('/assets/images/tow-home-air.jpg');
}

.tow-theater-context--land .tow-theater-context__art {
    background-image: linear-gradient(90deg, #020817 4%, rgba(2, 8, 23, .90) 42%, rgba(2, 8, 23, .32) 78%, rgba(2, 8, 23, .72) 100%), url('/assets/images/tow-home-land.jpg');
}

.tow-theater-context--sea .tow-theater-context__art {
    background-image: linear-gradient(90deg, #020817 4%, rgba(2, 8, 23, .90) 42%, rgba(2, 8, 23, .32) 78%, rgba(2, 8, 23, .72) 100%), url('/assets/images/tow-home-sea.jpg');
}

.tow-theater-context--space .tow-theater-context__art {
    background-image: linear-gradient(90deg, #020817 4%, rgba(2, 8, 23, .90) 42%, rgba(2, 8, 23, .32) 78%, rgba(2, 8, 23, .72) 100%), url('/assets/images/tow-home-space.jpg');
}

.tow-theater-context--fantasy .tow-theater-context__art {
    background-image: linear-gradient(90deg, #020817 4%, rgba(2, 8, 23, .90) 42%, rgba(2, 8, 23, .32) 78%, rgba(2, 8, 23, .72) 100%), url('/assets/images/tow-home-fantasy.jpg');
}

.tow-theater-context__inner {
    position: relative;
    z-index: 1;
    width: min(1180px, calc(100% - 40px));
    min-height: 205px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 34px;
    padding: 36px 0;
}

.tow-theater-context__identity {
    min-width: 0;
    flex: 1 1 auto;
}

.tow-theater-context__kicker {
    margin: 0 0 8px;
    color: var(--tow-context-accent);
    font-size: 10px;
    font-weight: 800;
    letter-spacing: .15em;
    text-transform: uppercase;
}

.tow-theater-context__title-row {
    display: flex;
    align-items: end;
    gap: 28px;
}

.tow-theater-context__title-row > div {
    display: grid;
    gap: 4px;
}

.tow-theater-context__division {
    color: #f4f5f7;
    font-family: Georgia, 'Times New Roman', serif;
    font-size: clamp(42px, 5vw, 66px);
    font-weight: 700;
    line-height: .88;
    letter-spacing: -.04em;
    text-transform: uppercase;
}

.tow-theater-context__command {
    color: #b8c2d0;
    font-size: 10px;
    font-weight: 800;
    letter-spacing: .12em;
    text-transform: uppercase;
}

.tow-theater-context__forum {
    min-width: 0;
    max-width: 500px;
    padding: 2px 0 5px 26px;
    border-left: 1px solid rgba(154, 170, 193, .34);
    color: #eef1f5;
    font-size: clamp(15px, 1.5vw, 20px);
    font-weight: 700;
    line-height: 1.25;
}

.tow-theater-context__actions {
    flex: 0 0 auto;
}

.tow-theater-context__return {
    display: inline-flex;
    min-height: 42px;
    align-items: center;
    justify-content: center;
    padding: 0 17px;
    border: 1px solid rgba(233, 166, 26, .72);
    background: rgba(2, 8, 23, .72);
    color: #f0f2f5 !important;
    font-size: 10px;
    font-weight: 800;
    letter-spacing: .07em;
    text-decoration: none !important;
    text-transform: uppercase;
    transition: background .15s ease, border-color .15s ease, color .15s ease;
}

.tow-theater-context__return:hover,
.tow-theater-context__return:focus {
    border-color: var(--tow-context-accent);
    background: var(--tow-context-accent);
    color: #06102a !important;
}

/*
 * Theater pages should feel like one continuous destination. These rules are
 * deliberately scoped to pages that actually contain the extension component,
 * so the normal board index, UCP, ACP, search, and non-theater forums remain
 * untouched. Existing viewforum/viewtopic markup is preserved.
 */
body:has(.tow-theater-context) {
    background: #020817;
}

body:has(.tow-theater-context) #page-body {
    background:
        radial-gradient(circle at 50% 0, rgba(20, 55, 129, .20), transparent 42rem),
        #02091e;
}

body:has(.tow-theater-context) #page-body > .wrap {
    position: relative;
    padding-bottom: 38px;
}

body:has(.tow-theater-context) .tow-breadcrumbs {
    margin-bottom: 0;
}

body:has(.tow-theater-context) .tow-forum-header {
    margin-top: 0;
    padding-top: 4px;
    border-bottom-color: rgba(154, 170, 193, .28);
}

body:has(.tow-theater-context) .tow-forum-heading h1,
body:has(.tow-theater-context) .tow-topic-info h3 a,
body:has(.tow-theater-context) .tow-topic-lastpost a {
    color: #eef1f5;
}

body:has(.tow-theater-context) .tow-forum-intro,
body:has(.tow-theater-context) .tow-topic-meta,
body:has(.tow-theater-context) .tow-topic-lastpost,
body:has(.tow-theater-context) .tow-forum-online p {
    color: #9eabbd;
}

body:has(.tow-theater-context) .tow-topic-directory,
body:has(.tow-theater-context) .tow-forum-online {
    border-color: rgba(154, 170, 193, .28);
    background: linear-gradient(145deg, #08193d, #04102a);
    box-shadow: 0 18px 45px rgba(0, 0, 0, .16);
}

body:has(.tow-theater-context) .tow-topic-directory-header {
    border-bottom-color: rgba(154, 170, 193, .28);
    background: linear-gradient(90deg, rgba(19, 48, 105, .72), rgba(6, 20, 50, .92));
    box-shadow: inset 3px 0 var(--tow-context-accent);
}

body:has(.tow-theater-context) .tow-topic-entry {
    border-top-color: rgba(154, 170, 193, .18);
    background: linear-gradient(135deg, rgba(9, 26, 64, .90), rgba(7, 22, 53, .88));
}

body:has(.tow-theater-context) .tow-topic-entry:nth-of-type(odd) {
    background: linear-gradient(135deg, rgba(11, 31, 75, .92), rgba(7, 22, 53, .90));
}

body:has(.tow-theater-context) .tow-topic-entry:hover {
    background: linear-gradient(90deg, rgba(19, 48, 105, .72), rgba(7, 22, 53, .90));
}

body:has(.tow-theater-context) .tow-topic-state,
body:has(.tow-theater-context) .tow-topic-lastpost {
    border-color: rgba(154, 170, 193, .18);
    background: rgba(2, 8, 23, .24);
}

body:has(.tow-theater-context) .tow-topic-stats {
    border-left-color: rgba(154, 170, 193, .18);
}

body:has(.tow-theater-context) .tow-topic-stats span + span {
    border-left-color: rgba(154, 170, 193, .18);
}

body:has(.tow-theater-context) .tow-topic-kicker,
body:has(.tow-theater-context) .tow-topic-entry.unread .tow-topic-kicker {
    color: var(--tow-context-accent);
}

body:has(.tow-theater-context) .tow-topic-entry.unread {
    box-shadow: inset 3px 0 var(--tow-context-accent);
}

body:has(.tow-theater-context) .button-primary,
body:has(.tow-theater-context) input.button-primary {
    border-color: var(--tow-context-accent);
    background: var(--tow-context-accent);
    color: #07112a;
}

body:has(.tow-theater-context) .button-primary:hover,
body:has(.tow-theater-context) .button-primary:focus,
body:has(.tow-theater-context) input.button-primary:hover,
body:has(.tow-theater-context) input.button-primary:focus {
    filter: brightness(1.06);
}

body:has(.tow-theater-context) .tow-site-footer {
    border-top-color: rgba(154, 170, 193, .24);
}

/* Theater-wide From the Front rail. The rail is injected by the extension and
 * the existing forum/topic template remains untouched. */
.tow-theater-context-activity {
    position: absolute;
    z-index: 2;
    top: 273px;
    right: 0;
    width: 286px;
    padding: 20px;
    border: 1px solid rgba(154, 170, 193, .28);
    border-top: 3px solid var(--tow-context-accent);
    border-radius: 3px;
    background: linear-gradient(145deg, #08193d, #04102a);
    color: #e8edf4;
    box-shadow: 0 18px 45px rgba(0, 0, 0, .15);
}

.tow-theater-context-activity__kicker {
    margin: 0 0 3px;
    color: var(--tow-context-accent);
    font-size: 9px;
    font-weight: 800;
    letter-spacing: .12em;
    text-transform: uppercase;
}

.tow-theater-context-activity h2 {
    margin: 0 0 8px;
    color: #f0f2f5;
    font-family: Georgia, 'Times New Roman', serif;
    font-size: 24px;
    line-height: 1;
}

.tow-theater-context-activity__list {
    display: grid;
}

.tow-theater-context-activity__item {
    display: grid;
    gap: 3px;
    padding: 11px 0;
    border-top: 1px solid rgba(154, 170, 193, .18);
    text-decoration: none !important;
}

.tow-theater-context-activity__item:first-child {
    border-top: 0;
}

.tow-theater-context-activity__item strong {
    color: #eef1f5;
    font-size: 12px;
    line-height: 1.3;
}

.tow-theater-context-activity__item:hover strong,
.tow-theater-context-activity__item:focus strong {
    color: var(--tow-context-accent);
}

.tow-theater-context-activity__item span {
    color: var(--tow-context-accent);
    font-size: 9px;
    font-weight: 800;
    letter-spacing: .05em;
    text-transform: uppercase;
}

.tow-theater-context-activity__item small {
    color: #8492a7;
    font-size: 9px;
    line-height: 1.3;
}

.tow-theater-context-activity__empty {
    margin: 0;
    padding: 12px 0;
    color: #9eabbd;
    font-size: 11px;
    line-height: 1.45;
}

.tow-theater-context-activity__more {
    display: flex;
    min-height: 36px;
    align-items: center;
    justify-content: center;
    margin-top: 10px;
    padding: 0 10px;
    border: 1px solid rgba(233, 166, 26, .55);
    color: #eef1f5 !important;
    font-size: 9px;
    font-weight: 800;
    letter-spacing: .05em;
    text-align: center;
    text-decoration: none !important;
    text-transform: uppercase;
}

.tow-theater-context-activity__more:hover,
.tow-theater-context-activity__more:focus {
    border-color: var(--tow-context-accent);
    background: var(--tow-context-accent);
    color: #07112a !important;
}

body.section-viewforum:has(.tow-theater-context) #page-body > .wrap > :not(.tow-breadcrumbs):not(.tow-theater-context):not(.tow-theater-context-activity),
body.section-viewtopic:has(.tow-theater-context) #page-body > .wrap > :not(.tow-breadcrumbs):not(.tow-theater-context):not(.tow-theater-context-activity) {
    width: calc(100% - 316px);
}

@media (max-width: 980px) {
    .tow-theater-context-activity {
        position: static;
        width: 100%;
        margin: -8px 0 26px;
    }

    body.section-viewforum:has(.tow-theater-context) #page-body > .wrap > :not(.tow-breadcrumbs):not(.tow-theater-context):not(.tow-theater-context-activity),
    body.section-viewtopic:has(.tow-theater-context) #page-body > .wrap > :not(.tow-breadcrumbs):not(.tow-theater-context):not(.tow-theater-context-activity) {
        width: 100%;
    }
}

@media (max-width: 800px) {
    .tow-theater-context {
        margin-bottom: 26px;
    }

    .tow-theater-context__inner {
        width: min(100% - 30px, 1180px);
        min-height: 0;
        display: grid;
        gap: 18px;
        padding: 28px 0;
    }

    .tow-theater-context__title-row {
        display: grid;
        gap: 14px;
    }

    .tow-theater-context__forum {
        max-width: none;
        padding: 11px 0 0;
        border-top: 1px solid rgba(154, 170, 193, .28);
        border-left: 0;
    }

    .tow-theater-context__return {
        width: 100%;
    }
}
