/* Presentation only. The plugin owns game state, geometry and interactions. */
:root {
  --terra-surface: var(--wp--preset--color--base, #f6f3eb);
  --terra-ink: var(--wp--preset--color--contrast, #202a27);
  --terra-panel: color-mix(in srgb, var(--terra-surface) 96%, var(--terra-ink));
  --terra-line: color-mix(in srgb, var(--terra-ink) 22%, transparent);
  --terra-muted: color-mix(in srgb, var(--terra-ink) 76%, var(--terra-surface));
  --terra-accent: var(--terra-ink);
  --wp--preset--color--background: var(--terra-surface);
  --wp--preset--color--foreground: var(--terra-ink);
  --wp--preset--color--primary: var(--terra-ink);
  --wp--preset--font-family--body: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --wp--preset--font-size--medium: 1rem;
  --terra-radius: 12px;
  --terra-feedback-ok: #116329;
  --terra-feedback-warning: #7c4b00;
  --terra-feedback-error: #b00020;
}
:root[data-terra-mode="dark"] {
  color-scheme: dark;
  --wp--preset--color--base: #000000;
  --wp--preset--color--contrast: #e9eee8;
  --wp--preset--color--accent-6: #242424;
  --terra-feedback-ok: #88d498;
  --terra-feedback-warning: #ffd166;
  --terra-feedback-error: #ff7b86;
}
.terra-shell .terra-mode-toggle { display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; padding: 8px; flex-shrink: 0; border: 0; background: transparent; color: inherit; }
.terra-shell button.terra-mode-toggle[aria-pressed] { background: transparent; color: inherit; }
.terra-mode-icon { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.terra-mode-icon--sun, :root[data-terra-mode="dark"] .terra-mode-icon--moon { display: none; }
:root[data-terra-mode="dark"] .terra-mode-icon--sun { display: block; }
*, *::before, *::after { box-sizing: border-box; }
html { scroll-padding-top: 1rem; }
body.terra-shell { margin: 0; background: var(--terra-surface); color: var(--terra-ink); font: 16px/1.55 var(--wp--preset--font-family--body); font-variant-numeric: tabular-nums; }
.terra-shell [hidden] { display: none !important; }
.terra-shell a { color: inherit; text-underline-offset: .2em; }
.terra-shell :is(button, input, select, textarea) { font: inherit; }
.terra-shell :is(button, input, select, textarea, summary, a):focus-visible { outline: 3px solid var(--terra-ink); outline-offset: 3px; }
.terra-shell :is(button, .button, input[type="submit"]) { border: 1px solid var(--terra-line); border-radius: 7px; background: var(--terra-panel); color: var(--terra-ink); min-height: 40px; padding: .45rem .75rem; cursor: pointer; text-decoration: none; }
.terra-shell :is(button, .button):disabled { cursor: default; opacity: .6; }
.terra-shell :is(button, .button):hover:not(:disabled) { border-color: var(--terra-ink); }
.terra-shell :is(.button-primary, .terra-cta, button[aria-pressed="true"], [role="tab"][aria-selected="true"]) { background: var(--terra-ink); color: var(--terra-surface); border-color: var(--terra-ink); }
.terra-shell :is(input:not([type="checkbox"]):not([type="radio"]):not([type="color"]):not([type="submit"]), select, textarea) { max-width: 100%; padding: .55rem .65rem; border: 1px solid var(--terra-line); border-radius: 6px; background: var(--terra-surface); color: var(--terra-ink); }
.terra-shell input:is([type="checkbox"], [type="radio"]) { accent-color: var(--terra-ink); }
.terra-shell :is(h1, h2, h3, h4) { line-height: 1.2; letter-spacing: -.025em; font-weight: 650; }
.terra-shell h1 { font-size: clamp(1.7rem, 3vw, 2.5rem); }
.terra-shell h2 { font-size: 1.45rem; }
.terra-shell h3 { font-size: 1.2rem; }
.terra-shell h4 { font-size: 1rem; }
.terra-prose img { max-width: 100%; height: auto; }
.terra-skip { position: fixed; top: -100px; left: 12px; z-index: 100001; padding: 12px; background: var(--terra-ink); color: var(--terra-surface) !important; }
.terra-skip:focus { top: 40px; }
.terra-header { border-bottom: 1px solid var(--terra-line); background: var(--terra-surface); }
.terra-header__inner { max-width: 1520px; margin: auto; padding: 17px 28px; display: flex; align-items: center; gap: 28px; }
.terra-brand { display: flex; align-items: center; gap: 10px; text-decoration: none; line-height: 1.05; font-family: Georgia, serif; font-size: 1.5rem; white-space: nowrap; }
.terra-brand__mark { font-size: 2.5rem; color: #947138; }
.terra-brand small { display: block; margin-top: 6px; font: .65rem/1.2 var(--wp--preset--font-family--body); text-transform: uppercase; letter-spacing: .09em; color: var(--terra-muted); }
.terra-site-nav, .terra-account-nav { display: flex; align-items: center; gap: 20px; }
.terra-site-nav { margin-left: auto; }
.terra-site-nav > a, .terra-profile { text-decoration: none; font-size: .9rem; font-weight: 600; }
.terra-site-nav > a:hover, .terra-profile:hover { text-decoration: underline; }
.terra-account-nav { gap: 16px; }
.terra-account-nav p { margin: 0; }
.terra-more { position: relative; }
.terra-more > summary { cursor: pointer; font-size: .9rem; font-weight: 600; padding: 8px 0; }
.terra-more__panel { position: absolute; right: 0; top: 100%; z-index: 10001; min-width: 190px; padding: 8px; border: 1px solid var(--terra-line); border-radius: 10px; background: var(--terra-surface); box-shadow: 0 12px 32px #0002; }
.terra-more__panel a { display: block; padding: 9px; font-size: .9rem; text-decoration: none; }
.terra-more__panel a:hover { background: var(--terra-panel); }
.terra-more__panel .td-auth-links { display: flex; flex-wrap: wrap; align-items: center; }
.terra-game-nav { max-width: 1464px; margin: auto; padding: 0 24px; }
.terra-game-nav:empty { display: none; }
.terra-shell .terra-game-nav .td-quick-nav { width: 100%; margin: 12px 0 0; justify-content: flex-start; gap: 5px; padding: 6px; border: 1px solid var(--terra-line); border-radius: 10px; background: var(--terra-panel); }
.terra-shell .terra-game-nav .td-quick-nav__item { padding: 10px 12px; border-radius: 6px; font-size: .9rem; font-weight: 550; opacity: 1; }
.terra-shell .terra-game-nav .td-quick-nav__item[aria-current="page"] { background: var(--terra-ink); color: var(--terra-surface); text-decoration: none; }
.terra-main { max-width: 1464px; min-height: 65vh; padding: 24px; margin: auto; }
.terra-page-heading { display: flex; flex-direction: column; gap: 4px; margin: 0 0 20px; }
.terra-page-heading h1, .terra-page-heading h2 { margin: 0; }
.terra-eyebrow { margin: 0; color: var(--terra-muted); font-size: .7rem; font-weight: 650; text-transform: uppercase; letter-spacing: .12em; }
.terra-prose { max-width: 980px; margin-inline: auto; }
.terra-prose > :is(p, ul, ol, blockquote) { max-width: 75ch; }
.terra-prose .wp-block-columns { gap: 24px; }
.terra-content > :first-child { margin-top: 0; }
.terra-shell .wp-block-group { max-width: 100%; }
.terra-shell .wp-block-columns { flex-wrap: wrap; }
.terra-shell .wp-block-column { min-width: 0; }
.terra-shell .wp-block-spacer:empty { max-height: 32px; }
.terra-welcome { padding: clamp(28px, 6vw, 72px); margin-bottom: 36px; border: 1px solid var(--terra-line); border-radius: 18px; background: radial-gradient(ellipse at 90% 0%, #9e793522, transparent 60%), var(--terra-panel); }
.terra-welcome h1 { max-width: 16ch; font: 600 clamp(2.5rem, 5vw, 4.75rem)/1.04 Georgia, serif; margin: 18px 0; letter-spacing: -.04em; }
.terra-welcome > p:not(.terra-eyebrow) { max-width: 52ch; font-size: 1.1rem; color: var(--terra-muted); }
.terra-welcome__description { white-space: pre-line; }
.terra-welcome__actions { display: flex; flex-wrap: wrap; align-items: center; gap: 24px; margin: 24px 0; }
.terra-cta { display: inline-flex; padding: 12px 20px; border-radius: 8px; text-decoration: none; font-weight: 650; }
.terra-alpha { display: inline-block; color: var(--terra-muted); font-size: .75rem; }
.terra-footer { max-width: 1416px; padding: 22px 0; margin: 24px auto 0; display: flex; flex-wrap: wrap; justify-content: space-between; gap: 20px; border-top: 1px solid var(--terra-line); font-size: .8rem; color: var(--terra-muted); }
.terra-footer nav { display: flex; gap: 20px; }
.terra-shell .td-toolbar, .terra-shell .td-screen-panel { border: 1px solid var(--terra-line); border-radius: var(--terra-radius); background: var(--terra-panel); color: var(--terra-ink); }
.td-screen-panel { padding: 20px; margin-block: 18px; }
.td-screen-panel > h2:first-child { margin-top: 0; }
.td-screen-panel summary { cursor: pointer; font-weight: 650; }
.terra-shell .td-turn-timer-wrap { display: flex; justify-content: flex-start; margin: 0 0 16px; padding: 10px 14px; border-left: 3px solid #947138; border-radius: 0 6px 6px 0; background: var(--terra-panel); font-size: .9rem; }
.terra-shell .td-turn-timer { margin-inline: 0; text-align: left; }
.terra-shell .td-map-scroll.alignfull { width: 100%; max-width: 100%; margin-inline: 0 !important; left: auto; right: auto; }
.td-game-screen--land .td-land-units-jump { display: none; }
.terra-shell .td-end-turn-wrap { display: flex; flex-direction: row; flex-wrap: wrap; align-items: center; justify-content: flex-start; gap: 10px; margin: 20px 0; padding: 14px; border: 1px solid var(--terra-line); border-radius: 10px; background: var(--terra-panel); text-align: left; }
.terra-shell .td-end-turn-wrap .td-end-turn-msg { font-size: .85rem; color: var(--terra-muted); }
.terra-shell .td-end-turn-wrap .td-end-turn-votes { flex-basis: 100%; }
.terra-shell .td-end-turn-leaderboard { font-size: .85rem; }
.td-screen-jumps { display: flex; gap: 10px; margin-bottom: 18px; }
.td-screen-jumps:not([role="tablist"]) a { padding: 8px 14px; border: 1px solid var(--terra-line); border-radius: 7px; font-size: .9rem; text-decoration: none; }

.terra-shell #td-layer-options > .td-map-zoom-controls { margin: 0; justify-content: flex-end; }
.terra-map-layers { min-width: 0; width: 100%; }
.terra-map-layers > summary { cursor: pointer; padding: 8px 4px; font-size: .85rem; font-weight: 650; text-align: left; }
.terra-map-layers[open] > summary { margin-bottom: 8px; border-bottom: 1px solid var(--terra-line); }
.terra-map-layers .td-map-toolbar__row { justify-content: flex-start; margin-block: 6px; }
@media (min-width: 1000px) {
  .terra-shell .td-map-land-popup-viewport { justify-content: flex-end; align-items: stretch; padding: 16px; }
  .terra-shell .td-map-land-popup { width: min(560px, 45vw); height: 100%; max-height: calc(100dvh - 32px); }
}
@media (max-width: 700px) {
  .terra-shell #td-layer-options { display: flex; flex-direction: column; gap: 0; }
  .terra-shell #td-layer-options > .td-map-zoom-controls { justify-content: flex-start; }
  .terra-shell .td-map-land-popup-viewport { align-items: flex-end; padding: 8px; }
  .terra-shell .td-map-land-popup { width: 100%; max-height: calc(90dvh - 16px); }
}
.terra-shell .td-land-title-block { margin-block: 16px; }
.terra-shell .td-land-sections .td-card { border-color: var(--terra-line); border-radius: 10px; background: var(--terra-surface); }
.terra-shell .td-land-sections .td-card:not(.collapsed) { flex-direction: column; }
.terra-shell .td-land-sections .td-card:not(.collapsed) > .td-card-toggle { width: 100%; min-height: 40px; border: 0; border-bottom: 1px solid var(--terra-line); border-radius: 10px 10px 0 0; background: var(--terra-panel); display: flex; flex-direction: row; justify-content: flex-start; gap: 8px; padding: 8px 12px; }
.terra-shell .td-land-sections .td-card:not(.collapsed) > .td-card-toggle .td-card-symbol { position: static; }
.terra-shell .td-land-sections .td-card:not(.collapsed) > .td-card-toggle .td-card-title { writing-mode: horizontal-tb; padding: 0; }
.terra-shell .td-land-sections .td-card:not(.collapsed) > .td-card-toggle .td-card-title > span { transform: none; }
.terra-shell .td-land-sections .td-card .td-card-content { padding: 14px; }
.terra-shell .td-action-area, .terra-shell .td-map-land-popup { border: 1px solid var(--terra-line); box-shadow: 0 18px 70px #0004; border-radius: 14px; }
.terra-shell .td-game-card { border-color: var(--terra-line); border-radius: 12px; }
.terra-shell .td-game-card__summary-title { font-size: 1.1rem; }
.terra-shell .td-game-card__meta-table { font-size: .85rem; }
.terra-shell .td-game-card__summary-row--pills { display: flex; flex-flow: row wrap; align-items: center; gap: 14px; }
.terra-shell .td-game-card__summary-row--pills .td-game-card__summary-text { flex: 1 1 360px; width: auto; }
.terra-shell .td-game-card__summary-row--pills .td-game-card__summary-action { flex: 0 0 auto; align-self: center; min-height: 44px; }
.terra-shell .td-game-card__summary-objective { color: var(--terra-muted); font-size: .85rem; }
.terra-shell .td-game-card__summary-pill { border-color: var(--terra-line); border-radius: 6px; font-size: .8rem; }
.terra-nav-group { flex: 0 0 auto; align-self: start; }
.terra-nav-group > summary { cursor: pointer; padding: 10px 12px; min-height: 40px; font-size: .9rem; font-weight: 550; border-radius: 6px; }
.terra-nav-group.is-current > summary { box-shadow: inset 0 -2px var(--terra-ink); }
.terra-nav-group__current { font-size: .8rem; }
.terra-nav-group__links { display: flex; flex-wrap: wrap; gap: 4px; padding: 4px; }
.terra-shell .td-game-screen--all-games .td-games-directory-list { max-width: 1200px; margin-inline: auto; }
.terra-shell .td-form { font-family: inherit; }
.terra-shell .td-land-store, .terra-shell .td-resources { font-variant-numeric: tabular-nums; }
@media (max-width: 900px) {
  .terra-header__inner { padding: 14px 18px; gap: 18px; flex-wrap: wrap; }
  .terra-brand { font-size: 1.25rem; }
  .terra-brand small { display: none; }
  .terra-site-nav { order: 3; width: 100%; justify-content: flex-start; gap: 24px; }
  .terra-account-nav { margin-left: auto; }
  .terra-main { padding: 20px 16px; }
  .terra-game-nav { padding-inline: 16px; }
  .terra-footer { margin-inline: 16px; }
}
@media (max-width: 520px) {
  .terra-header__inner { gap: 10px; }
  .terra-brand__mark { font-size: 1.8rem; }
  .terra-brand { font-size: 1.08rem; gap: 6px; }
  .terra-account-nav { gap: 10px; }
  .terra-profile { display: none; }
  .terra-more > summary { font-size: .8rem; }
  .terra-session .terra-more__panel::before { content: none; }
  .terra-shell .terra-game-nav .td-quick-nav.td-quick-nav--contextual.td-quick-nav--icon { flex-flow: row nowrap !important; overflow-x: auto; justify-content: flex-start !important; gap: 4px; scrollbar-width: thin; }
  .terra-shell .terra-game-nav .td-quick-nav.td-quick-nav--contextual.td-quick-nav--icon > .td-quick-nav__item { flex: 0 0 auto !important; width: auto !important; max-width: none !important; padding: 10px; min-height: 44px; font-size: .85rem; white-space: nowrap; }
  .terra-page-heading { margin-bottom: 14px; }
  .terra-eyebrow { font-size: .65rem; }
  .terra-shell :is(button, .button, input[type="submit"]) { min-height: 44px; }
  .td-screen-panel { padding: 14px; }
  .terra-welcome { padding: 24px; }
}
@media (prefers-reduced-motion: reduce) { .terra-shell *, .terra-shell *::before, .terra-shell *::after { transition-duration: 0s !important; animation-duration: 0s !important; } }

.terra-guide-contents { margin-block: 0 2rem; padding: 1rem 1.25rem; border: 1px solid var(--terra-line); border-radius: var(--terra-radius); background: var(--terra-panel); }
.terra-guide-contents summary { cursor: pointer; font-weight: 700; }
.terra-guide-contents ul { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 16rem), 1fr)); gap: .35rem 1.5rem; margin-bottom: 0; padding-left: 1.25rem; }
.terra-guide-contents a { display: inline-block; padding-block: .25rem; overflow-wrap: anywhere; }
.terra-content h2[id] { scroll-margin-top: 4rem; }


.terra-task-help { margin-block: 0 1.25rem; padding: .75rem 1rem; border: 1px solid var(--terra-line); border-radius: var(--terra-radius); background: var(--terra-panel); }
.terra-task-help summary { cursor: pointer; font-weight: 600; }
.terra-task-help p { max-width: 80ch; color: var(--terra-muted); }

/* Selected type buttons use light ink as their dark-mode background. */
:root[data-terra-mode="dark"] .terra-shell .td-type-btn.td-type-selected .td-unit-icon { filter: brightness(0); }


@media (max-width: 700px) {
  .terra-shell .td-action-area { width: 100%; max-width: 100%; }
}

.terra-shell .td-claim-map-grid [role="button"]:focus-visible { outline: 3px solid var(--terra-ink); outline-offset: -6px; filter: brightness(1.15); }

.terra-shell .td-units-msg-box { background: var(--terra-panel); color: var(--terra-ink); border: 1px solid var(--terra-line); }
.terra-shell .td-units-msg-box .td-units-close { color: var(--terra-muted); }

/* The plugin primary button uses an ID selector; pair its foreground with the theme fill. */
.terra-shell #td-end-turn-btn { background: var(--terra-ink); border-color: var(--terra-ink); color: var(--terra-surface); }

/* Desktop workspaces keep navigation and map controls close to the board. */
@media (min-width: 1000px) {
  .terra-shell--game .terra-game-nav { display: flex; align-items: center; gap: 12px; padding-top: 10px; }
  .terra-shell--game .terra-game-nav .td-quick-nav { width: auto; flex: 0 1 auto; flex-wrap: wrap; margin: 0; }
  .terra-shell--game .terra-main { padding-top: 14px; }
  .terra-shell--game .terra-page:has(.td-game-screen--map) > .terra-page-heading { flex-direction: row; flex-wrap: wrap; align-items: baseline; gap: 6px 14px; margin-bottom: 10px; }
  .terra-shell--game .terra-page:has(.td-game-screen--map) > .terra-page-heading h1 { font-size: 1.75rem; }
  .terra-shell--game .terra-page:has(.td-game-screen--map) > .terra-page-heading .terra-eyebrow { order: 1; }
  .terra-shell .td-game-screen--map .td-turn-timer-wrap { flex-direction: row; margin-bottom: 8px; padding-block: 6px; }
  .terra-shell .td-map-toolbar { width: fit-content; max-width: 100%; padding: 8px 12px; }
  .terra-shell #td-layer-options { position: relative; display: block; }
  .terra-shell #td-layer-options > .td-map-zoom-controls { position: absolute; right: 0; top: 0; }
  .terra-map-layers > summary { box-sizing: border-box; min-height: 40px; padding-right: 240px; }
  .terra-shell .terra-page:has(.td-game-screen--map) .td-end-turn-wrap { width: fit-content; max-width: 100%; margin: 10px auto; padding: 8px 12px; }
  .terra-shell .terra-page:has(.td-game-screen--map) .td-map-help { margin: 10px auto; padding: 10px 14px; }
  .terra-shell .terra-page:has(.td-game-screen--map) .td-map-help:not([open]) { width: fit-content; }
}

/* Group labels remain above their own wrapping controls at every width. */
.terra-map-filter-groups { display: flex; flex-wrap: wrap; gap: 10px; }
.terra-shell .terra-map-filter-groups .td-map-toolbar__row {
  display: flex; flex: 1 1 24rem; flex-wrap: wrap; align-content: flex-start;
  justify-content: flex-start; gap: 5px; min-width: 0; margin: 0;
  padding: 10px; border: 1px solid var(--terra-line); border-radius: 8px;
  background: var(--terra-surface);
}
.terra-map-filter-groups .td-toolbar__label { flex: 0 0 100%; margin-bottom: 3px; color: var(--terra-muted); font-size: .75rem; font-weight: 700; }
.terra-shell .terra-map-heading > .td-turn-timer-wrap { margin: 0; padding: 4px 10px; flex-direction: row; text-align: left; }
@media (min-width: 1000px) {
  .terra-shell .terra-map-heading > .td-turn-timer-wrap { order: 2; margin-left: 8px; align-self: center; }
}
@media (max-width: 999px) {
  .terra-shell .terra-map-heading { flex-direction: row; flex-wrap: wrap; align-items: baseline; gap: 6px 12px; }
  .terra-shell .terra-map-heading > .td-turn-timer-wrap { flex-basis: 100%; }
}
.terra-shell .terra-map-filter-groups .td-map-toolbar__row--view { flex-grow: 1.2; }

/* Reuse the compact workspace heading across Games, Land and Orders. */
.terra-shell .terra-workspace-heading { flex-direction: row; flex-wrap: wrap; align-items: center; gap: 8px 14px; margin-bottom: 12px; }
.terra-workspace-heading h1 { font-size: 1.75rem; }
.terra-workspace-heading > .terra-eyebrow { order: 1; }
.terra-shell .terra-workspace-heading > .td-turn-timer-wrap { order: 2; flex-direction: row; margin: 0; padding: 4px 10px; }
.terra-workspace-heading > .terra-task-help { order: 3; margin: 0 0 0 auto; padding: 8px 12px; font-size: .9rem; }
.terra-workspace-heading > .terra-task-help[open] { flex-basis: 100%; }
.terra-shell .terra-directory-controls { display: grid; gap: 10px; margin-bottom: 12px; }
.terra-shell .terra-directory-controls > .td-toolbar { box-sizing: border-box; width: 100%; max-width: none; margin: 0; padding: 10px; align-items: flex-start; }
.terra-shell .terra-directory-controls .td-games-filter-options { justify-content: flex-start; gap: 6px; }
.terra-directory-controls .td-games-filter-options > .td-toolbar__label { flex-basis: 100%; }
.terra-shell .terra-directory-controls .td-games-sort { justify-content: flex-start; align-items: flex-end; gap: 10px; flex-wrap: wrap; }
.terra-directory-controls .td-games-sort > label { flex-direction: column; align-items: flex-start; gap: 4px; }
.terra-shell .td-game-screen--all-games .td-games-directory-list { max-width: none; }
@media (min-width: 1000px) {
  .terra-shell .terra-game-nav { display: flex; align-items: center; gap: 12px; padding-top: 10px; }
  .terra-shell .terra-game-nav .td-quick-nav { flex: 0 1 auto; width: auto; margin: 0; }
  .terra-shell:has(.td-game-screen) .terra-main { padding-top: 14px; }
  .terra-shell .terra-directory-controls { grid-template-columns: minmax(0, 1.65fr) minmax(0, 1fr); }
  .terra-shell .td-screen-panel { padding: 14px; margin-block: 12px; }
}
@media (max-width: 700px) {
  .terra-workspace-heading > .terra-task-help, .terra-shell .terra-workspace-heading > .td-turn-timer-wrap { flex-basis: 100%; margin-left: 0; }
}

/* Action colours supplement the existing labels and icons. */
.terra-shell .button.td-game-action-button { --terra-action-fill: #1e40af; --terra-action-hover: #1e3a8a; background: var(--terra-action-fill); border-color: var(--terra-action-fill); color: #fff; font-weight: 600; }
.terra-shell .button.td-game-action-button:hover:not(:disabled) { background: var(--terra-action-hover); border-color: var(--terra-action-hover); color: #fff; }
.terra-shell .td-game-action-button.td-game-action-enter { --terra-action-fill: #166534; --terra-action-hover: #14532d; }
.terra-shell .td-game-action-button.td-game-action-join { --terra-action-fill: #075985; --terra-action-hover: #0c4a6e; }
.terra-shell .td-game-action-button.td-game-action-map { --terra-action-fill: #0f766e; --terra-action-hover: #115e59; }
.terra-shell .td-game-action-button.td-game-action-leaderboard { --terra-action-fill: #854d0e; --terra-action-hover: #713f12; }
.terra-shell .td-game-action-button.td-game-action-stats { --terra-action-fill: #6b21a8; --terra-action-hover: #581c87; }
.terra-shell .td-game-action-button.td-game-action-template { --terra-action-fill: #374151; --terra-action-hover: #1f2937; }
.terra-shell .td-game-card .button-danger { background: #991b1b; border-color: #991b1b; color: #fff; }
.terra-shell .td-game-card button:is([name="td_start_game_now"], [name="td_game_pause_action"][value="resume"]) { background: #166534; border-color: #166534; color: #fff; }
.terra-shell .td-game-card button:is([name="td_cancel_game_start"], [name="td_game_pause_action"][value="pause"], [name="td_game_pause_action"][value="cancel_resume"]) { background: #854d0e; border-color: #854d0e; color: #fff; }

/* Each policy is one editor, with its scope, settings and save kept together. */
.terra-shell .td-polity-shared-policy-cards { grid-template-columns: repeat(auto-fit, minmax(min(100%, 22rem), 1fr)); align-items: start; gap: 12px; }
.terra-shell .td-polity-shared-policy-card { padding: 0; border: 1px solid var(--terra-line); border-radius: 10px; background: var(--terra-surface); }
.terra-policy-editor > summary { padding: 14px; cursor: pointer; font-weight: 700; }
.terra-policy-editor > summary h4 { display: inline; margin: 0; font-size: 1rem; }
.terra-policy-editor[open] > summary { border-bottom: 1px solid var(--terra-line); background: var(--terra-panel); }
.terra-policy-editor > :is(p, form) { margin: 12px; }
.terra-shell .td-polity-shared-policy-card fieldset { min-width: 0; padding: 12px; margin: 12px 0; border: 1px solid var(--terra-line); border-radius: 8px; }
.terra-shell .td-polity-shared-policy-card legend { padding: 0 5px; font-weight: 650; font-size: .9rem; }
.terra-shell .td-polity-shared-policy-card fieldset > label:has(input[type="checkbox"]) { grid-template-columns: 20px minmax(0, 1fr); gap: 6px; padding: 6px 0; align-items: start; }
.terra-shell .td-polity-shared-policy-card label > small { grid-column: 2; margin: 0; color: var(--terra-muted); opacity: 1; }
.terra-shell .td-polity-shared-policy-card .td-polity-shared-policy-scope { border-left: 3px solid #947138; background: var(--terra-panel); }
.terra-policy-editor details { padding: 10px; border: 1px solid var(--terra-line); border-radius: 8px; }
.terra-policy-editor details > summary { cursor: pointer; font-weight: 600; }
.terra-shell .td-polity-shared-policy-actions { padding-top: 10px; border-top: 1px solid var(--terra-line); }
.terra-shell .td-polity-policies { margin-top: 16px; border: 1px solid var(--terra-line); border-radius: 10px; padding: 16px; background: var(--terra-panel); }
.terra-shell .td-polity-local-override-group { padding: 12px; border: 1px solid var(--terra-line); border-radius: 8px; margin-top: 12px; }
.terra-shell .td-polity-own-bulk-reset { border: 1px solid #b45309; border-radius: 8px; padding: 12px; }
.terra-shell .td-polity-shared-policies-header > :first-child, .terra-shell .td-polity-policies > :first-child { margin-top: 0; }

.terra-shell .td-polity { max-width: none; width: 100%; }
.terra-shell .td-polity-kicker { display: none; }
.terra-shell .td-polity-shared-policies { border: 1px solid var(--terra-line); border-radius: 10px; padding: 14px; }
.terra-shell .td-polity-shared-policy-card:has(> .terra-policy-editor[open]) { grid-column: 1 / -1; }
@media (min-width: 1000px) {
  .terra-policy-editor > form { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); gap: 12px; align-items: start; }
  .terra-shell .terra-policy-editor > form > fieldset { margin: 0; }
  .terra-policy-editor > form > :is(details, .td-polity-shared-policy-actions) { grid-column: 1 / -1; }
  .terra-shell .terra-policy-editor > form > fieldset:not(.td-polity-shared-policy-scope) { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .terra-policy-editor fieldset > .td-form-note { grid-column: 1 / -1; }
}
.terra-shell .terra-content .wp-block-columns:has(:is(.td-polity, .td-messages)) { width: 100%; max-width: none; }
.terra-policy-editor fieldset > p:has(label) { display: flex; flex-wrap: wrap; gap: 8px 14px; }
.terra-policy-editor fieldset > p:has(label) > strong { flex-basis: 100%; }
.terra-policy-editor fieldset > p > label { display: inline-flex; align-items: baseline; gap: 6px; }
.terra-shell .td-polity-nav { justify-content: flex-start; width: fit-content; max-width: 100%; flex-wrap: wrap; }

/* Buttons retain a stable light surface; artwork fills its transparent icon area. */
.terra-shell .td-action-choice-grid .td-action-choice { background: #e5e7eb; color: #111827; border-color: #9ca3af; }
.terra-shell .td-action-choice-grid .td-action-choice:hover,
.terra-shell .td-action-choice-grid .td-action-choice:focus-visible { background: #d1d5db; color: #111827; border-color: #4b5563; }
.terra-shell .td-action-choice-grid .td-action-choice .td-action-choice-icon { width: 3rem; height: 3rem; background: transparent; color: #111827; padding: 0; border: 0; border-radius: 0; box-sizing: border-box; }
.terra-shell .td-action-choice-grid .td-action-choice .td-action-choice-icon .td-action-icon__image { filter: none; }
.td-screen-jumps a > svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.terra-shell .td-land-target-cancel { margin: 0 0 12px; border-color: #947138; }
.td-land-target-cancel[hidden] { display: none; }

.terra-shell .terra-workspace-heading > .td-screen-jumps[role="tablist"] { order: 3; margin: 0 0 0 auto; }
@media (max-width: 700px) {
  .terra-shell .terra-workspace-heading > .td-screen-jumps[role="tablist"] { flex-basis: 100%; margin-left: 0; }
}
.terra-shell .terra-workspace-heading > .td-land-target-cancel { order: 4; margin: 0; }

/* Collapsed diplomatic scan cards use the same desktop footprint as other units. */
.terra-shell .td-unit-group--scan .td-unit-owner-group-card.td-unit-card--diplomatic:not(.td-actions-open):not(.td-scan-card-open):not(.td-unit-card--expanded) { flex: 0 0 150px; width: 150px; max-width: 150px; }

/* Message folders share the page heading; sorting stays with its game section. */
.terra-shell .terra-workspace-heading > .terra-mail-controls { order: 3; width: auto; max-width: 100%; margin: 0 0 0 auto; padding: 5px; }
.terra-mail-controls .td-mail-title { display: none; }
.terra-shell .terra-mail-controls .td-mail-toolbar-main { flex-wrap: wrap; }
.terra-shell .td-message-mailbox-link.is-active { background: #1e40af; border-color: #1e40af; color: #fff; }
.terra-shell .td-messages-game { border-color: var(--terra-line); border-radius: 10px; background: var(--terra-panel); padding: 14px; }
.terra-shell .td-messages-game-header { align-items: center; margin-bottom: 10px; }
.terra-shell .td-messages-game-header .td-messages-sort { margin: 0 0 0 auto; }
.td-messages-game-header .td-messages-sort form { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.terra-shell .td-thread { border-color: var(--terra-line); border-radius: 8px; background: var(--terra-surface); }
.terra-shell .td-thread-header { color: var(--terra-ink); }
.terra-shell .td-thread-body { padding: 12px; }
@media (max-width: 700px) {
  .terra-shell .terra-workspace-heading > .terra-mail-controls { flex-basis: 100%; margin-left: 0; }
}
