/* Selected by role rather than a class: the tab strip is emitted by NavigationContainerComponent at every nesting level. */
[role="tablist"] {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-1);
}

/* The original puts a strip under what it switches. Order rather than DOM order, which a tablist has to keep. */
[id^="navigation-container"] {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

[id^="navigation-container"] > [role="tablist"] {
    order: 2;
    margin-top: var(--space-3);
}

/* :not([hidden]) is load-bearing: any display of ours overrides the attribute's, un-hiding every visited tab at once. */
[id^="navigation-container"] > [role="tabpanel"]:not([hidden]) {
    order: 1;
    flex: 1;
    min-height: 0;
    /* The pane scrolls rather than the page, or a tall screen takes the bottom-edge tab strip off with it. */
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

/* Stands where the shell will, on the app surface the original leaves its loading screens on. */
#game-sync,
#game-sync-error {
    display: grid;
    justify-items: center;
    align-content: center;
    gap: var(--space-4);
    flex: 1;
}

#game-sync svg {
    display: block;
    width: 6rem;
    height: 6rem;
}

#game-sync-label,
#game-sync-failure {
    letter-spacing: var(--letter-spacing-wide);
}

/* Sized here or a canvas falls back to 300x150; touch-action none, or the browser pans the page instead of the map. */
#game-map {
    width: 100%;
    aspect-ratio: 1;
    max-width: var(--max-width-map);
    touch-action: none;
}

[role="tab"] {
    flex: 1 1 auto;
    background: var(--tab-background);
    color: var(--tab-text);
    font-size: var(--font-size-sm);
    letter-spacing: var(--letter-spacing-wide);
}

[role="tab"][aria-selected="true"] {
    background: var(--tab-selected-background);
    color: var(--tab-selected-text);
}

/* Selected by the ids the components already emit rather than by an invented class, as the tab strip is by its role. */
#game-chrome {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    margin-bottom: var(--space-3);
}

/* A screen owns its surface all the way to the bottom, which is what makes the depth colour read as the screen. */
[id^="moonbase-home-"],
[id^="upgrade-queue-"],
[id^="structure-group-"],
[id^="structure-detail-"],
[id^="unit-detail-"] {
    display: grid;
    gap: var(--space-5);
    padding: var(--space-5) var(--space-4);
    border-radius: var(--radius-md);
    flex: 1;
}

/* Resources at the top and the queues at the bottom, with the omitted movement and unit rows as the space between. */
[id^="moonbase-home-"] {
    align-content: space-between;
}

/* A group's members are centred rather than pinned to the top: four mines sit in the middle of the original's screen. */
[id^="upgrade-queue-"],
[id^="structure-group-"] {
    align-content: center;
}

/* Wrapping and centred, so four resources make a row on a wide screen and four mines make a block on a narrow one. */
[id^="moonbase-resources-"],
[id^="moonbase-queues-"],
[id^="moonbase-movements-"],
[id^="moonbase-units-"],
[id^="queue-structures-"],
[id^="queue-groups-"],
[id^="group-members-"],
[id^="structure-cost-"],
[id^="unit-cost-"] {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: var(--space-5);
}

[id^="moonbase-resources-"] > li,
[id^="moonbase-queues-"] > li,
[id^="moonbase-movements-"] > li,
[id^="moonbase-units-"] > li,
[id^="queue-structures-"] > li,
[id^="queue-groups-"] > li,
[id^="group-members-"] > li,
[id^="structure-cost-"] > li,
[id^="unit-cost-"] > li {
    flex-direction: column;
    gap: var(--space-1);
    background: transparent;
    font-size: var(--font-size-sm);
    font-variant-numeric: tabular-nums;
}

[id^="moonbase-units-"] > li {
    min-width: 5rem;
    text-align: center;
}

[id^="moonbase-units-"] button {
    display: grid;
    gap: var(--space-1);
    width: 100%;
    background: transparent;
    color: inherit;
    font-size: var(--font-size-sm);
    letter-spacing: var(--letter-spacing-wide);
}

[id^="unit-standing-"] {
    display: flex;
    justify-content: space-around;
    text-align: center;
    letter-spacing: var(--letter-spacing-wide);
}

/* What more would cost, on the highlight the original gives the whole construction block. */
[id^="unit-construct-"] {
    display: grid;
    justify-items: center;
    gap: var(--space-4);
    padding: var(--space-5) var(--space-4);
    border-radius: var(--radius-md);
}

[id^="unit-spinner-"] {
    display: grid;
    justify-items: center;
    gap: var(--space-1);
}

[id^="unit-order-quantity-"] {
    width: 6rem;
    text-align: center;
    font-variant-numeric: tabular-nums;
}

[id^="unit-statistics-"] {
    display: grid;
    gap: var(--space-3);
    text-align: center;
}

[id^="unit-statistics-"] button {
    justify-self: center;
    background: transparent;
    color: inherit;
    letter-spacing: var(--letter-spacing-wide);
}

[id^="unit-cost-"] svg {
    display: block;
    width: 6rem;
    height: 6rem;
}

/* Smaller than a resource disc, which is the proportion the original draws them at. */
[id^="queue-"] > svg,
[id^="group-"] > svg,
[id^="structure-"] > svg,
[id^="attacks-"] > svg,
[id^="technology-"] > svg {
    display: block;
    width: 4.5rem;
    height: 4.5rem;
}

[id^="moonbase-queues-"] button,
[id^="moonbase-movements-"] button,
[id^="queue-structures-"] button,
[id^="queue-groups-"] button,
[id^="group-members-"] button {
    padding: 0;
    min-height: 0;
    background: transparent;
    border-radius: 50%;
}

[id^="structure-cost-"] svg,
[id^="moonbase-resources-"] svg {
    display: block;
    width: 6rem;
    height: 6rem;
}

/* Centred as the original draws it, and after the size rules above, which this would otherwise lose to. */
[id^="structure-detail-"] > svg {
    justify-self: center;
    width: 6rem;
    height: 6rem;
}

#attacks-incoming,
#attacks-outgoing,
#launch-attack-screen {
    display: grid;
    gap: var(--space-5);
    padding: var(--space-5) var(--space-4);
    border-radius: var(--radius-md);
    align-content: start;
    flex: 1;
}

[id^="attack-list-"],
#attack-order {
    display: grid;
    gap: var(--space-1);
}

#attack-order > li {
    display: grid;
    grid-template-columns: 1fr auto 5rem;
    gap: var(--space-3);
    align-items: center;
    padding: var(--space-2) var(--space-3);
    background: var(--surface-raised);
    border-radius: var(--radius-sm);
    letter-spacing: var(--letter-spacing-wide);
}

/* One treatment for every action that commits: green as ActiveGreen10 means, filled so it reads on any screen's surface. */
#launch-attack,
#chat-send,
[id^="construct-units-"],
[id^="upgrade-structure-"] {
    justify-self: center;
    background: var(--moonbase-active-green-10);
    color: var(--on-surface-dark);
    letter-spacing: var(--letter-spacing-wide);
}

/* The other end, the type initial, what is aboard and when it lands, which is the original's own row. */
[id^="attack-list-"] > li {
    display: grid;
    grid-template-columns: 1fr auto auto auto;
    gap: var(--space-3);
    align-items: center;
    padding: var(--space-2) var(--space-3);
    background: var(--surface-raised);
    border-radius: var(--radius-sm);
    font-size: var(--font-size-sm);
    font-variant-numeric: tabular-nums;
    letter-spacing: var(--letter-spacing-wide);
}

#player-list-screen,
#player-screen {
    display: grid;
    gap: var(--space-5);
    padding: var(--space-5) var(--space-4);
    border-radius: var(--radius-md);
    align-content: start;
    flex: 1;
}

#player-list {
    display: grid;
    gap: var(--space-1);
}

/* The row is the button, so the generic list surface would show as a pale border around whatever tier it was painted. */
#player-list li,
#chat-list li {
    padding: 0;
    background: transparent;
}

#player-list button {
    display: flex;
    justify-content: space-between;
    width: 100%;
    letter-spacing: var(--letter-spacing-wide);
}

#player-standing {
    display: flex;
    justify-content: space-around;
    text-align: center;
}

#player-standing dt {
    font-size: var(--font-size-sm);
    letter-spacing: var(--letter-spacing-wide);
}

#player-bases {
    display: grid;
    gap: var(--space-3);
}

#player-bases li {
    display: flex;
    justify-content: space-between;
    font-size: var(--font-size-sm);
}

/* Right end of the toolbar as the original hangs it, and above the panel it opens, which covers that corner. */
#score-toggle {
    margin-left: auto;
    position: relative;
    z-index: 2;
    display: grid;
    justify-items: center;
    gap: var(--space-1);
    padding: 0 var(--space-2);
    background: transparent;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
}

#score-toggle-overall {
    font-size: var(--font-size-xs);
}

#score-panel {
    position: fixed;
    top: 0;
    right: 0;
    z-index: 1;
    width: min(18rem, 80vw);
    height: 100vh;
    padding: var(--space-5) var(--space-4);
    display: grid;
    align-content: center;
    gap: var(--space-6);
    text-align: center;
    overflow-y: auto;
    transition: transform 200ms ease;
}

/* inert keeps it out of tab order while it is away, so the closed state needs no second attribute to style from. */
#score-panel[inert] {
    transform: translateX(100%);
}

#score-standing,
#score-components {
    display: grid;
    gap: var(--space-4);
    justify-content: center;
}

#score-standing dd {
    font-size: var(--font-size-xl);
}

#score-standing dt,
#score-components dt {
    font-size: var(--font-size-sm);
    letter-spacing: var(--letter-spacing-wide);
    color: inherit;
}

/* A label under its value is a caption rather than a term, so the global colon would read as a dangling one. */
#player-standing dt::after,
#score-standing dt::after,
#score-components dt::after {
    content: none;
}

/* Term then value is the only order assistive technology can pair, so the caption sits under its figure from here. */
#player-standing div,
#score-standing div,
#score-components div {
    display: flex;
    flex-direction: column-reverse;
}

@media (prefers-reduced-motion: reduce) {
    #score-panel {
        transition: none;
    }
}

#chat-list-screen,
[id^="chat-thread-"] {
    display: grid;
    gap: var(--space-4);
    padding: var(--space-5) var(--space-4);
    border-radius: var(--radius-md);
    align-content: start;
    flex: 1;
    min-height: 0;
}

#chat-list {
    display: grid;
    gap: var(--space-1);
}

#chat-list button {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 0 var(--space-3);
    width: 100%;
    padding: var(--space-2) var(--space-3);
    text-align: left;
    letter-spacing: var(--letter-spacing-wide);
}

/* Dimmed against whatever the row's tier gave it, since a fixed grey disappears on the pale end of the ramp. */
[id^="chat-summary-"] {
    font-size: var(--font-size-sm);
    opacity: 0.7;
}

[id^="chat-unread-"] {
    grid-row: span 2;
    align-self: center;
    font-variant-numeric: tabular-nums;
}

/* The thread scrolls and the composer does not, so a long conversation never pushes the input off the screen. */
#chat-messages {
    display: grid;
    gap: var(--space-2);
    overflow-y: auto;
    min-height: 0;
}

#chat-messages > li {
    display: grid;
    justify-items: end;
    max-width: 80%;
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius-md);
}

[id^="chat-message-own-"] {
    justify-self: end;
    background: var(--chat-own-background);
    color: var(--chat-own-text);
}

[id^="chat-message-other-"] {
    justify-self: start;
    background: var(--chat-other-background);
    color: var(--chat-other-text);
}

[id^="chat-time-"] {
    font-size: var(--font-size-xs);
}

#chat-compose {
    display: flex;
    gap: var(--space-2);
}

#chat-input {
    flex: 1;
}


/* What you have against what you could buy, which is the split the original makes with a colour rather than a heading. */
[id^="structure-next-"] {
    display: grid;
    gap: var(--space-4);
    padding: var(--space-5) var(--space-4);
    border-radius: var(--radius-md);
    text-align: center;
}

[id^="structure-current-"] {
    display: grid;
    justify-items: center;
    gap: var(--space-1);
}
