/*
 * The game's shared look, loaded by game/layout.html.twig and admin/layout.html.twig after the legacy skin:
 * dark teal panels over the skin's background, as the overview, fleet, galaxy and chat pages drew it first.
 *
 * 1. Tokens: every modern page reads its colours here.
 * 2. Components (.ui-*) for new markup: page, panel, table, form fields, buttons, flashes, empty state.
 * 3. The bridge: the pages still in the legacy markup (tables with td.c title bars and th cells, plain
 *    inputs) take the same look without being rewritten. Pages drawn with their own styles (.ui, .overview,
 *    .fleet, .galaxy, .chat, .simulator) and the legacy top bar (.topnav) are left out.
 */

/* 1. Tokens */
:root {
    --ui-panel: rgb(6 30 36 / 86%);
    --ui-panel-strong: rgb(9 52 60 / 94%);
    --ui-line: rgb(95 179 200 / 22%);
    --ui-accent: #5fc4d8;
    --ui-text: #e3eef0;
    --ui-muted: #8aa6ab;
    --ui-good: #6fdc7a;
    --ui-warn: #f5c542;
    --ui-bad: #ff7a6b;
    --ui-hostile: #ff5b4d;
    --ui-ally: #5b9bff;
    --ui-field: rgb(0 0 0 / 35%);
    --ui-radius: 8px;
    --ui-font: 11px/1.45 Verdana, Tahoma, Helvetica, sans-serif;
}

/* The skin's background (1490 × 1050, not repeated) covers the whole window, whatever its size; the image
   stays the player's skin's. */
body { background-size: cover; background-position: center; }

/* 2. Components */
.ui-page { display: grid; gap: 10px; width: min(100%, 780px); margin: 12px auto; color: var(--ui-text); font: var(--ui-font); text-align: left; }
.ui-page.is-wide { width: min(100%, 1100px); }
/* A wide child (a table that scrolls in its panel) must not widen the page. */
.ui-page > * { min-width: 0; }
.ui-page a, .ui-panel a { color: var(--ui-accent); }
.ui-page :focus-visible { outline: 2px solid var(--ui-accent); outline-offset: 1px; }
.ui-title { margin: 14px 0 4px; color: var(--ui-text); font: bold 15px/1.3 Verdana, Tahoma, Helvetica, sans-serif; letter-spacing: .02em; text-align: center; }

.ui-panel { padding: 10px 12px; border: 1px solid var(--ui-line); border-radius: var(--ui-radius); background: var(--ui-panel); color: var(--ui-text); font: var(--ui-font); text-align: left; }
.ui-panel.is-strong { background: var(--ui-panel-strong); }
.ui-panel-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px; margin-bottom: 8px; }
.ui-panel h2, .ui-panel-head h2 { margin: 0 0 8px; color: var(--ui-accent); font-size: 12px; text-transform: uppercase; letter-spacing: .06em; }
.ui-panel-head h2 { margin: 0; }
.ui-empty { margin: 0; color: var(--ui-muted); text-align: center; }
.ui-muted { color: var(--ui-muted); }

.ui-table { width: 100%; border-collapse: collapse; font: var(--ui-font); }
.ui-table th, .ui-table td { padding: 5px 8px; border: 0; border-bottom: 1px solid var(--ui-line); background: none; color: inherit; text-align: left; vertical-align: middle; font-weight: normal; }
.ui-table thead th { color: var(--ui-muted); font-size: 10px; text-transform: uppercase; letter-spacing: .05em; }
.ui-table tbody tr:last-child > * { border-bottom: 0; }
.ui-table tbody tr:hover { background: rgb(95 196 216 / 6%); }
.ui-table .is-number { text-align: right; font-variant-numeric: tabular-nums; }

.ui-field { display: grid; gap: 3px; }
.ui-field > span { color: var(--ui-muted); font-size: 10px; text-transform: uppercase; letter-spacing: .05em; }
.ui-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }

.ui-button { display: inline-block; padding: 4px 12px; border: 1px solid var(--ui-accent); border-radius: 4px; background: var(--ui-panel-strong); color: #fff; font: var(--ui-font); text-decoration: none; cursor: pointer; }
.ui-button:hover:not(:disabled) { background: rgb(95 196 216 / 25%); }
.ui-button:disabled { border-color: var(--ui-line); color: var(--ui-muted); cursor: not-allowed; }
.ui-button.is-danger { border-color: var(--ui-bad); }
.ui-button.is-danger:hover:not(:disabled) { background: rgb(255 122 107 / 20%); }

.ui-flash { display: block; width: fit-content; max-width: min(100%, 760px); margin: 8px auto; padding: 6px 14px; border: 1px solid; border-radius: var(--ui-radius); font: var(--ui-font); text-align: center; }
.ui-flash.is-success { border-color: rgb(111 220 122 / 45%); background: rgb(111 220 122 / 12%); color: var(--ui-good); }
.ui-flash.is-error { border-color: rgb(255 122 107 / 50%); background: rgb(255 122 107 / 12%); color: var(--ui-bad); }

/* 3. The bridge, for the legacy markup of the pages not redrawn yet */
.game-main :is(input:not([type="checkbox"], [type="radio"], [type="image"]), select, textarea):not(:is(.ui, .overview, .fleet, .galaxy, .chat, .simulator, .topnav) *) {
    padding: 3px 6px;
    border: 1px solid var(--ui-line);
    border-radius: 4px;
    background: var(--ui-field) none;
    color: var(--ui-text);
    font: var(--ui-font);
}
.game-main :is(input[type="submit"], input[type="button"], input[type="reset"], button:not(.link, .game-menu-toggle, .ui-button)):not(:is(.ui, .overview, .fleet, .galaxy, .chat, .simulator, .topnav) *) {
    padding: 4px 12px;
    border: 1px solid var(--ui-accent);
    background: var(--ui-panel-strong) none;
    color: #fff;
    cursor: pointer;
}
.game-main :is(input[type="submit"], input[type="button"], button:not(.link, .game-menu-toggle, .ui-button)):not(:disabled):hover { background: rgb(95 196 216 / 25%); }
.game-main :is(input[type="checkbox"], input[type="radio"]) { accent-color: var(--ui-accent); }

.game-main table:not(:is(.ui, .overview, .fleet, .galaxy, .chat, .simulator, .topnav) table, table table) {
    margin: 10px auto;
    max-width: 100%;
    border: 1px solid var(--ui-line);
    border-collapse: separate;
    border-spacing: 0;
    border-radius: var(--ui-radius);
    background: var(--ui-panel);
    overflow: hidden;
}
.game-main table:not(:is(.ui, .overview, .fleet, .galaxy, .chat, .simulator, .topnav) table) :is(th, td) {
    border: 0;
    border-bottom: 1px solid var(--ui-line);
    background: transparent none;
    color: var(--ui-text);
    font: var(--ui-font);
}
.game-main table:not(:is(.ui, .overview, .fleet, .galaxy, .chat, .simulator, .topnav) table) th { padding: 5px 8px; }
.game-main table:not(:is(.ui, .overview, .fleet, .galaxy, .chat, .simulator, .topnav) table) tr:last-child > :is(th, td) { border-bottom: 0; }
.game-main table:not(:is(.ui, .overview, .fleet, .galaxy, .chat, .simulator, .topnav) table) table :is(th, td) { border-bottom: 0; }
/* The title bars (td.c): the panel headings of the modern pages. */
.game-main table:not(:is(.ui, .overview, .fleet, .galaxy, .chat, .simulator, .topnav) table) td.c {
    height: auto;
    padding: 7px 10px;
    background: var(--ui-panel-strong) none;
    color: var(--ui-accent);
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: .06em;
}
.game-main table:not(:is(.ui, .overview, .fleet, .galaxy, .chat, .simulator, .topnav) table) td.c :is(a, font) { color: inherit; }
.game-main table:not(:is(.ui, .overview, .fleet, .galaxy, .chat, .simulator, .topnav) table) td.c :is(input, select, button) { text-transform: none; letter-spacing: normal; }
/* The row of column names under a title bar: muted, as the head of .ui-table. */
.game-main table:not(:is(.ui, .overview, .fleet, .galaxy, .chat, .simulator, .topnav) table) tr:has(> td.c) + tr:has(> th + th):not(:has(input, select, textarea, img, a)) > th {
    color: var(--ui-muted);
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: .05em;
}

/* The current body's bar on top of the pages (game/layout_with_top_bar.html.twig) */
.ui-topbar, .game-main div.topnav.ui-topbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px 22px; box-sizing: border-box; padding: 6px 12px; border-bottom: 1px solid var(--ui-line); background: rgb(3 16 20 / 88%); color: var(--ui-text); font: var(--ui-font); }
.ui-topbar-body { display: flex; align-items: center; gap: 8px; }
.ui-topbar-body img { border-radius: 50%; }
.ui-topbar select { padding: 3px 6px; border: 1px solid var(--ui-line); border-radius: 4px; background: var(--ui-field); color: var(--ui-text); font: var(--ui-font); }
.ui-topbar-resources { display: flex; flex-wrap: wrap; gap: 4px 18px; margin: 0; padding: 0; list-style: none; }
.ui-topbar-resource { display: grid; grid-template: "icon name" auto "icon value" auto / auto auto; align-items: center; column-gap: 6px; }
.ui-topbar-resource img { grid-area: icon; }
.ui-topbar-name { grid-area: name; color: var(--ui-muted); font-size: 10px; text-transform: uppercase; letter-spacing: .05em; }
.ui-topbar-value { grid-area: value; font-weight: bold; font-variant-numeric: tabular-nums; }
.ui-topbar-resource.is-metal .ui-topbar-value { color: #dddddd; }
.ui-topbar-resource.is-crystal .ui-topbar-value { color: #ffcc00; }
.ui-topbar-resource.is-deuterium .ui-topbar-value { color: #6cb0f7; }
.ui-topbar-resource.is-energy .ui-topbar-value { color: #b26be0; }
.ui-topbar-resource:is(.is-full, .is-short) .ui-topbar-value { color: var(--ui-hostile); }
@media (max-width: 720px) {
    .ui-topbar-resource img { display: none; }
}

.ui-announcement { width: fit-content; max-width: min(100% - 24px, 640px); margin: 10px auto 0; padding: 8px 14px; border: 1px solid rgb(245 197 66 / 45%); border-radius: var(--ui-radius); background: rgb(245 197 66 / 10%); color: var(--ui-text); font: var(--ui-font); text-align: center; }
.ui-announcement strong { display: block; margin-bottom: 2px; color: var(--ui-warn); text-transform: uppercase; letter-spacing: .05em; font-size: 10px; }

/* Settings rows (options, alliance settings…): label and help on the left, the field on the right. */
.ui-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); align-items: center; gap: 4px 14px; padding: 7px 0; border-top: 1px solid var(--ui-line); }
.ui-panel h2 + .ui-row, .ui-panel h2 + .ui-help + .ui-row { border-top: 0; }
.ui-row-label > label, .ui-row-name { color: var(--ui-text); font-weight: bold; }
.ui-row-control { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; overflow-wrap: anywhere; }
.ui-help { margin: 2px 0 0; color: var(--ui-muted); font-size: 10px; line-height: 1.4; }
.ui-panel > .ui-help { margin: -4px 0 6px; }
.ui :is(input:not([type="checkbox"], [type="radio"], [type="image"]), select, textarea) {
    box-sizing: border-box; max-width: 100%; padding: 4px 7px; border: 1px solid var(--ui-line); border-radius: 4px;
    background: var(--ui-field); color: var(--ui-text); font: var(--ui-font);
}
.ui-row-control :is(input:not([type="checkbox"], [type="radio"]), select) { width: 100%; }
.ui-row-control :is(input[type="number"], input[size="2"]) { width: 80px; }
.ui :is(input, select, textarea):focus-visible { outline: 2px solid var(--ui-accent); outline-offset: 0; }
.ui :is(input[type="checkbox"], input[type="radio"]) { accent-color: var(--ui-accent); }

/* A checkbox drawn as a switch. */
.ui-switch { appearance: none; position: relative; width: 34px; height: 18px; margin: 0; border: 1px solid var(--ui-line); border-radius: 9px; background: var(--ui-field); cursor: pointer; transition: background .15s; }
.ui-switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 12px; height: 12px; border-radius: 50%; background: var(--ui-muted); transition: transform .15s, background .15s; }
.ui-switch:checked { border-color: var(--ui-accent); background: rgb(95 196 216 / 35%); }
.ui-switch:checked::after { background: #fff; transform: translateX(16px); }

/* The save button of a long form stays in view at the bottom. */
.ui-savebar { position: sticky; bottom: 0; z-index: 5; display: flex; justify-content: center; margin-top: 10px; padding: 8px; border: 1px solid var(--ui-line); border-radius: var(--ui-radius); background: var(--ui-panel-strong); }
.ui-savebar .ui-button { padding: 6px 28px; font-weight: bold; }

@media (max-width: 720px) {
    .ui-row { grid-template-columns: 1fr; }
}

/* Text read by screen readers only (an icon column's name, for instance). */
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.ui textarea { width: 100%; text-align: left; min-height: 8em; resize: vertical; line-height: 1.4; }

/* Online status of a player (alliance members, friends): a coloured dot before the label. */
.ui-status::before { content: "●"; margin-right: 5px; }
.ui-status.is-online { color: var(--ui-good); }
.ui-status.is-recent { color: var(--ui-warn); }
.ui-status.is-offline { color: var(--ui-muted); }

/* Priority of a note: green, yellow, red as in the legacy list. */
.ui-priority.is-low { color: var(--ui-good); }
.ui-priority.is-normal { color: var(--ui-warn); }
.ui-priority.is-high { color: var(--ui-bad); }

/* A short message box (refusal, vacation mode…), centred under its title. */
.ui-notice { display: grid; justify-items: center; gap: 10px; text-align: center; }
.ui-notice p { margin: 0; line-height: 1.5; }
.ui-notice.is-warning { border-color: rgb(245 197 66 / 45%); }
/* A list header: title on the left, actions on the right. */
.ui-toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; }
.ui-scroll { position: relative; overflow-x: auto; }
/* A form panel: its rows and fields stacked, the buttons at the end. */
.ui-form { display: grid; gap: 10px; }
.ui-form > .ui-row:first-of-type { border-top: 0; }
.ui-actions.is-end { justify-content: flex-end; }
.ui-button.is-current { background: rgb(95 196 216 / 25%); font-weight: bold; }
.ui-actions form { margin: 0; }
/* A search or filter bar: fields and button on one line, wrapping on a phone. */
.ui-search { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.ui-search input[type="search"] { flex: 1 1 200px; }
.ui-search label { display: inline-flex; align-items: center; gap: 6px; }
.ui-icons { white-space: nowrap; }
.ui-icons a + a { margin-left: 6px; }
/* Tables side by side, one per category. */
.ui-columns { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr)); gap: 6px 18px; align-items: start; }
/* A state word coloured by its meaning. */
.ui-tone.is-good { color: var(--ui-good); }
.ui-tone.is-warn { color: var(--ui-warn); }
.ui-tone.is-bad { color: var(--ui-bad); }
.ui-table tr.is-me > * { background: rgb(255 122 107 / 10%); }
.ui-table form { margin: 0; }
.ui-back { margin: 0; text-align: center; }

/* The bar shown while a team member inspects a player (admin/_inspection_banner.html.twig). */
.inspection-banner { position: fixed; right: 0; bottom: 0; left: 0; z-index: 1000; display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 6px 12px; padding: 6px 10px; border-top: 1px solid var(--ui-bad); background: rgb(122 16 16 / 95%); color: #fff; font: bold 12px Verdana, Tahoma, sans-serif; }
.inspection-banner form { margin: 0; }
