/* Driftwake, Phase 0. Layout: the map fills the screen; panels sit over it on
   phones and beside it on tablets and desktops. Each art style sets its own
   colours; there is no separate light or dark mode. */

:root {
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

html {
  box-sizing: border-box;
  height: 100%;
}

*,
*::before,
*::after {
  box-sizing: inherit;
}

body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  background: #0b1633;
  font: 14px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Noto Sans Arabic", sans-serif;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

[hidden] {
  display: none !important;
}

button {
  font: inherit;
  color: inherit;
}

/* ---------- Art styles ---------- */

#app {
  --font-ui: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Noto Sans Arabic", sans-serif;
  /* Numbers, counters and the title used a typewriter-style font until 28 November 2026.
     The game now uses one typeface everywhere, so this name gives the same font as the
     rest; digits keep equal widths so counters do not shift as they change. */
  --font-data: var(--font-ui);
  font-variant-numeric: tabular-nums;
}

#app[data-art="chart"] {
  --bg: #0b1633;
  --panel: rgba(9, 20, 48, 0.88);
  --panel-solid: #0d1b3f;
  --line: rgba(120, 160, 255, 0.24);
  --chip: rgba(92, 200, 255, 0.08);
  --text: #e6eeff;
  --muted: #9aaad0;
  --accent: #5cc8ff;
  --accent-text: #03111f;
  --danger: #ff7b7b;
  --good: #7be3a0;
  --team0: #5cc8ff;
  --team0-fill: #123259;
  --team1: #ffad5c;
  --team1-fill: #40250f;
  --s0: #5cc8ff; --s0f: #123259; --s1: #ffad5c; --s1f: #40250f; --s2: #7be37b; --s2f: #173d1f;
  --s3: #ff6b9a; --s3f: #45172b; --s4: #c9a2ff; --s4f: #2d1f4d; --s5: #ffe066; --s5f: #403812;
  --heat: #ff8a3d;
  --heat-track: rgba(255, 138, 61, 0.2);
  --focus: #ffd27a;
  --go-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
  color-scheme: dark;
}

#app[data-art="paper"] {
  --bg: #eef1f2;
  --panel: rgba(251, 252, 251, 0.94);
  --panel-solid: #fbfcfb;
  --line: rgba(31, 42, 54, 0.2);
  --chip: rgba(52, 110, 190, 0.08);
  --text: #1f2a36;
  --muted: #56626e;
  --accent: #1d3f73;
  --accent-text: #ffffff;
  --danger: #b8302d;
  --good: #2d7a4d;
  --team0: #1d3f73;
  --team0-fill: rgba(52, 110, 190, 0.32);
  --team1: #7a1f2c;
  --team1-fill: rgba(200, 60, 80, 0.3);
  --s0: #1d3f73; --s0f: rgba(52, 110, 190, 0.32); --s1: #7a1f2c; --s1f: rgba(200, 60, 80, 0.3); --s2: #245a35; --s2f: rgba(60, 150, 90, 0.3);
  --s3: #7a4508; --s3f: rgba(200, 130, 40, 0.32); --s4: #4b2478; --s4f: rgba(130, 80, 190, 0.3); --s5: #0f5f5f; --s5f: rgba(40, 150, 150, 0.3);
  --heat: #e0742c;
  --heat-track: rgba(224, 116, 44, 0.18);
  --focus: #c8322f;
  --go-shadow: 2px 2px 0 rgba(31, 42, 54, 0.85);
  color-scheme: light;
}

#app[data-art="neon"] {
  --bg: #030308;
  --panel: rgba(8, 8, 20, 0.86);
  --panel-solid: #08081a;
  --line: rgba(0, 240, 255, 0.3);
  --chip: rgba(0, 240, 255, 0.07);
  --text: #e8fbff;
  --muted: #a0a3d8;
  --accent: #00f0ff;
  --accent-text: #001216;
  --danger: #ff4d73;
  --good: #6bff9e;
  --team0: #00f0ff;
  --team0-fill: rgba(0, 240, 255, 0.12);
  --team1: #ff2bd6;
  --team1-fill: rgba(255, 43, 214, 0.12);
  --s0: #00f0ff; --s0f: rgba(0, 240, 255, 0.12); --s1: #ff2bd6; --s1f: rgba(255, 43, 214, 0.12); --s2: #6bff9e; --s2f: rgba(107, 255, 158, 0.12);
  --s3: #ffd23f; --s3f: rgba(255, 210, 63, 0.12); --s4: #ff6b3d; --s4f: rgba(255, 107, 61, 0.12); --s5: #9d7bff; --s5f: rgba(157, 123, 255, 0.14);
  --heat: #ff9a3c;
  --heat-track: rgba(255, 154, 60, 0.2);
  --focus: #fff36b;
  --go-shadow: 0 0 18px rgba(0, 240, 255, 0.55);
  color-scheme: dark;
}

/* ---------- Frame ---------- */

#app {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  user-select: none;
  -webkit-user-select: none;
}

#map {
  position: relative;
  grid-column: 1;
  grid-row: 1;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  container-type: inline-size;
}

#view {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  cursor: crosshair;
}

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

/* ---------- Top bar ---------- */

#topbar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 2;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas:
    "turn actions"
    "obj obj";
  align-items: center;
  column-gap: 10px;
  row-gap: 2px;
  padding-block: 6px 8px;
  padding-left: max(12px, env(safe-area-inset-left, 0px));
  padding-right: max(8px, env(safe-area-inset-right, 0px));
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}

.tb-turn {
  grid-area: turn;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  column-gap: 10px;
  min-width: 0;
}

.tb-turn strong {
  font-family: var(--font-data);
  font-size: 16px;
  white-space: nowrap;
  letter-spacing: 0.02em;
}

#phase-label {
  color: var(--muted);
  font-size: 13px;
}

.tb-objective {
  grid-area: obj;
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
  font-size: 12.5px;
}

.obj-label {
  flex: none;
  font-size: 10.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

#objective {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.score {
  flex: none;
  font-family: var(--font-data);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}

.tb-actions {
  grid-area: actions;
  display: flex;
  gap: 2px;
}

.icon-btn {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 12px;
  background: transparent;
  cursor: pointer;
}

.icon-btn:hover {
  background: var(--chip);
}

.icon-btn svg {
  width: 22px;
  height: 22px;
  fill: currentColor;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

@container (min-width: 900px) {
  #topbar {
    grid-template-columns: auto minmax(0, 1fr) auto;
    grid-template-areas: "turn obj actions";
  }
}

#toast {
  position: absolute;
  z-index: 3;
  top: 104px;
  left: 50%;
  transform: translateX(-50%);
  max-width: calc(100% - 32px);
  padding: 8px 16px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--panel-solid);
  font-weight: 650;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
}

#toast[data-tone="bad"] {
  border-color: var(--danger);
  color: var(--danger);
}

#toast[data-tone="good"] {
  border-color: var(--good);
  color: var(--good);
}

/* ---------- Side panel: bottom sheet on phones ---------- */

#side {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 2;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas:
    "squad"
    "card"
    "actions";
  gap: 8px;
  padding-block: 8px 10px;
  padding-left: max(10px, env(safe-area-inset-left, 0px));
  padding-right: max(10px, env(safe-area-inset-right, 0px));
  background: var(--panel);
  border-top: 1px solid var(--line);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}

#squad {
  grid-area: squad;
  display: flex;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
}

#card {
  grid-area: card;
  min-width: 0;
}

#log {
  display: none;
}

/* Phone: Fire and Reset on the left, the big GO button bottom right. */
#actions {
  grid-area: actions;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas:
    "progress progress"
    "orders main";
  gap: 6px 10px;
  min-width: 0;
}

#actions .progress {
  grid-area: progress;
}

#order-actions {
  grid-area: orders;
  display: flex;
  gap: 8px;
  min-width: 0;
}

#order-actions > button {
  flex: 1 1 auto;
  min-width: 0;
  justify-content: center;
}

#plan-actions,
#play-actions,
#over-actions {
  grid-area: main;
}

#order-actions[hidden] ~ #plan-actions,
#order-actions[hidden] ~ #play-actions,
#order-actions[hidden] ~ #over-actions {
  grid-column: 1 / -1;
}

/* ---------- Squadron chips ---------- */

.chip {
  flex: 1 1 0;
  min-width: 0;
  min-height: 48px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--chip);
  text-align: start;
  cursor: pointer;
}

.chip.is-selected {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
}

.chip.is-dead {
  opacity: 0.45;
  cursor: default;
}

.chip-text {
  display: grid;
  min-width: 0;
}

.chip-name {
  font-weight: 650;
  font-size: 13px;
}

.chip-status {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hull-icon {
  width: 22px;
  height: 28px;
  flex: none;
}

.hull-icon polygon {
  stroke-width: 0.12;
  stroke-linejoin: round;
}

.hull-icon.slot-0 polygon { fill: var(--s0f); stroke: var(--s0); }
.hull-icon.slot-1 polygon { fill: var(--s1f); stroke: var(--s1); }
.hull-icon.slot-2 polygon { fill: var(--s2f); stroke: var(--s2); }
.hull-icon.slot-3 polygon { fill: var(--s3f); stroke: var(--s3); }
.hull-icon.slot-4 polygon { fill: var(--s4f); stroke: var(--s4); }
.hull-icon.slot-5 polygon { fill: var(--s5f); stroke: var(--s5); }

/* ---------- Ship card ---------- */

.card-hint {
  margin: 4px 0;
  color: var(--muted);
}

.card-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
}

.card-head .hull-icon {
  width: 24px;
  height: 30px;
}

.card-titles {
  flex: 1;
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
}

.card-title {
  flex: none;
  font-weight: 700;
  font-size: 15px;
}

.card-role {
  min-width: 0;
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(108px, 1fr));
  gap: 4px 12px;
  margin: 0;
}

.stats div {
  min-width: 0;
}

.stats dt {
  font-size: 10.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.stats dd {
  margin: 0;
  font-family: var(--font-data);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stats small {
  margin-left: 4px;
  font-family: var(--font-ui);
  font-size: 10px;
  color: var(--muted);
}

.heat {
  display: inline-flex;
  gap: 3px;
  vertical-align: middle;
}

.heat i {
  width: 14px;
  height: 8px;
  border-radius: 2px;
  background: linear-gradient(to right, var(--heat) 0 calc(var(--f) * 100%), var(--heat-track) 0);
}

.shields {
  display: flex;
  gap: 7px;
}

.shield {
  font-size: 10px;
  color: var(--muted);
}

.shield b {
  margin-left: 2px;
  font-size: 13px;
  color: var(--text);
}

.shield.is-empty b {
  color: var(--danger);
}

.hull {
  display: inline-flex;
  gap: 3px;
  vertical-align: middle;
}

.hull i {
  width: 9px;
  height: 9px;
  border-radius: 2px;
  border: 1px solid var(--text);
  opacity: 0.45;
}

.hull i.on {
  background: var(--text);
  opacity: 1;
}

.warn {
  margin: 6px 0 0;
  color: var(--danger);
  font-size: 12.5px;
  font-weight: 600;
}

.toggle,
.ghost-btn {
  min-height: 48px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--chip);
  font-weight: 650;
  cursor: pointer;
}

.toggle {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  line-height: 1.15;
}

.toggle[aria-pressed="true"] {
  background: var(--heat);
  border-color: transparent;
  color: #1a0d00;
}

.ghost-btn {
  background: transparent;
}

.toggle:disabled,
.ghost-btn:disabled {
  opacity: 0.45;
  cursor: default;
}

.count {
  font-family: var(--font-data);
  font-size: 11px;
  opacity: 0.8;
}

/* ---------- Weapon and defence buttons ---------- */

.wchip {
  min-height: 56px;
  min-width: 0;
  padding: 4px 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--chip);
  line-height: 1.15;
  text-align: center;
  cursor: pointer;
}

.wchip b {
  font-size: 12px;
  font-weight: 700;
}

.wchip > span {
  font-size: 11.5px;
  color: var(--muted);
}

.wchip[data-mode="now"] {
  background: var(--heat);
  border-color: transparent;
  color: #1a0d00;
}

.wchip[data-mode="now"] > span {
  color: inherit;
}

.wchip[data-mode="auto"] {
  border-color: var(--heat);
  box-shadow: inset 0 0 0 1px var(--heat);
}

.wchip[data-mode="auto"] > span {
  color: var(--heat);
  font-weight: 700;
}

.wchip.def[data-mode="brace"],
.wchip.def[data-mode="flares"],
.wchip.def[data-mode="patch"] {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
}

.wchip.def[data-mode="brace"] > span,
.wchip.def[data-mode="flares"] > span,
.wchip.def[data-mode="patch"] > span {
  color: var(--accent);
  font-weight: 700;
}

.wchip:disabled {
  opacity: 0.45;
  cursor: default;
}

.mode-btn {
  flex: none;
  min-height: 36px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  font-size: 12px;
  font-weight: 650;
  cursor: pointer;
}

.mode-btn[aria-pressed="true"] {
  border-color: var(--accent);
  color: var(--accent);
}

/* Taps on the small autopilot switch still get a 48px target. */
.mode-btn {
  position: relative;
}

.mode-btn::after {
  content: "";
  position: absolute;
  inset: -6px -2px;
}

.parts {
  display: flex;
  gap: 8px;
}

.part {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  font-size: 10px;
  color: var(--muted);
}

.part i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  border: 1px solid var(--danger);
}

.part i.on {
  border-color: var(--text);
  background: var(--text);
}

#phase-label.is-warning {
  color: var(--danger);
  font-weight: 650;
}

/* ---------- First-battle hint ---------- */

#hint {
  position: absolute;
  z-index: 3;
  top: 96px;
  left: max(10px, env(safe-area-inset-left, 0px));
  right: 118px;
  max-width: 440px;
  display: flex;
  align-items: flex-start;
  gap: 4px;
  padding: 8px 4px 8px 12px;
  border: 1px solid var(--accent);
  border-radius: 12px;
  background: var(--panel-solid);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.3);
}

#hint-text {
  flex: 1;
  margin: 0;
  font-size: 13px;
  line-height: 1.4;
}

.hint-close {
  flex: none;
  width: 44px;
  height: 44px;
  margin: -6px 0;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
}

.hint-close svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
}

/* ---------- Battle setup ---------- */

.budget {
  margin: 0 0 8px;
  font-family: var(--font-data);
  font-size: 13px;
}

.setup-squad {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 6px;
}

.squad-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 12px;
}

.squad-text,
.hull-text {
  display: grid;
  min-width: 0;
}

.squad-text span,
.hull-text span {
  font-size: 12px;
  color: var(--muted);
}

.ghost-btn.small {
  min-height: 48px;
  padding: 0 10px;
  font-size: 12.5px;
}

.setup-hulls {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 6px;
}

.hull-opt {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  min-height: 56px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: transparent;
  text-align: start;
  cursor: pointer;
}

.hull-opt:disabled {
  opacity: 0.4;
  cursor: default;
}

.cost {
  min-width: 28px;
  padding: 2px 6px;
  border-radius: 999px;
  background: var(--chip);
  border: 1px solid var(--line);
  font-family: var(--font-data);
  font-size: 13px;
  text-align: center;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.segmented button {
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: transparent;
  font-weight: 650;
  cursor: pointer;
}

.segmented button[aria-checked="true"] {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
  color: var(--accent);
}

.setup-actions {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 8px;
  margin-top: 18px;
}

.setup-panel {
  width: min(640px, 100%);
}

@media (max-width: 420px) {
  .squad-row {
    grid-template-columns: auto minmax(0, 1fr) auto;
  }

  .squad-row [data-act="loadout"] {
    grid-column: 2 / 4;
    grid-row: 2;
  }
}

/* ---------- Main buttons ---------- */

.go {
  min-width: 96px;
  min-height: 72px;
  padding: 8px 16px;
  display: grid;
  place-items: center;
  line-height: 1.1;
  border: 0;
  border-radius: 16px;
  background: var(--accent);
  color: var(--accent-text);
  font-weight: 800;
  font-size: 22px;
  letter-spacing: 0.12em;
  box-shadow: var(--go-shadow);
  cursor: pointer;
}

.go small {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.06em;
  opacity: 0.75;
}

.go:active {
  transform: translateY(1px);
}

.go.wide {
  width: 100%;
  min-height: 52px;
  font-size: 16px;
  letter-spacing: 0.04em;
}

#plan-actions,
#over-actions {
  display: flex;
}

#plan-actions .go,
#over-actions .go {
  flex: 1;
}

#over-actions .go {
  font-size: 15px;
  letter-spacing: 0.04em;
}

#play-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.progress {
  height: 4px;
  border-radius: 2px;
  background: var(--line);
  overflow: hidden;
}

#progress-fill {
  height: 100%;
  background: var(--accent);
  transform-origin: left center;
  transform: scaleX(0);
}

#app:not([data-phase="playback"]) .progress {
  visibility: hidden;
}

/* ---------- Battle log ---------- */

#log h2 {
  margin: 0 0 6px;
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

#log-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  align-content: start;
  gap: 5px;
  font-size: 12.5px;
  overflow-y: auto;
  user-select: text;
}

#log-list li {
  display: flex;
  gap: 8px;
  line-height: 1.35;
}

.log-turn {
  flex: none;
  width: 28px;
  font-family: var(--font-data);
  color: var(--muted);
}

#log-list li[data-tone="bad"] {
  color: var(--danger);
}

#log-list li[data-tone="good"] {
  color: var(--good);
}

/* ---------- Dialogs ---------- */

.dialog {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding-block: 16px;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  background: rgba(0, 0, 0, 0.45);
}

.dialog-panel {
  width: min(520px, 100%);
  max-height: 100%;
  overflow-y: auto;
  padding: 18px 18px 20px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel-solid);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
  user-select: text;
}

.dialog h2 {
  margin: 0 0 12px;
  font-size: 20px;
  text-wrap: balance;
}

.dialog h3 {
  margin: 18px 0 8px;
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

.dialog-head {
  position: sticky;
  top: -18px;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: -18px -18px 0;
  padding: 12px 18px;
  background: var(--panel-solid);
  border-bottom: 1px solid var(--line);
}

.dialog-head h2 {
  margin: 0;
}

.drawer {
  place-items: stretch end;
  padding: 0;
}

.drawer .dialog-panel {
  width: min(420px, 100%);
  height: 100%;
  max-height: none;
  border-width: 0 0 0 1px;
  border-radius: 0;
}

@media (max-width: 600px) {
  .drawer {
    place-items: end stretch;
  }

  .drawer .dialog-panel {
    width: 100%;
    height: auto;
    max-height: 92%;
    border-width: 1px 0 0;
    border-radius: 18px 18px 0 0;
  }
}

.steps {
  display: grid;
  gap: 10px;
  margin: 0 0 12px;
  padding-left: 22px;
}

.steps li {
  line-height: 1.45;
}

.keys {
  font-size: 12.5px;
}

.muted {
  color: var(--muted);
}

.foot {
  margin-top: 20px;
  font-size: 12px;
}

.style-list {
  display: grid;
  gap: 8px;
}

.style-opt {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 64px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: transparent;
  text-align: start;
  cursor: pointer;
}

.style-opt[aria-pressed="true"] {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
}

.swatch {
  flex: none;
  width: 52px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 10px;
}

.swatch i {
  display: block;
  width: 12px;
  height: 12px;
  border-radius: 50%;
}

.swatch i + i {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  transform: rotate(45deg);
}

.style-text {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.style-text span {
  font-size: 12.5px;
  color: var(--muted);
}

.slider {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 0 8px;
  margin-bottom: 8px;
}

.slider input {
  grid-column: 1 / -1;
  width: 100%;
  min-height: 32px;
  accent-color: var(--accent);
}

.slider output {
  font-family: var(--font-data);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.switch {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
}

.switch input {
  width: 20px;
  height: 20px;
  accent-color: var(--accent);
}

.result-panel {
  text-align: center;
}

#result-title {
  font-size: 34px;
  letter-spacing: 0.06em;
}

#result[data-outcome="win"] #result-title {
  color: var(--good);
}

#result[data-outcome="loss"] #result-title {
  color: var(--danger);
}

.result-actions {
  display: grid;
  gap: 8px;
  margin-top: 16px;
}

/* ---------- Phone held sideways: panel on the right ---------- */

@media (orientation: landscape) and (max-height: 540px) {
  #app {
    grid-template-columns: minmax(0, 1fr) min(44vw, 330px);
  }

  #side {
    position: relative;
    grid-column: 2;
    grid-row: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
    overflow-y: auto;
    padding-left: 10px;
    padding-right: max(10px, env(safe-area-inset-right, 0px));
    border-top: 0;
    border-left: 1px solid var(--line);
    background: var(--panel-solid);
  }

  #squad,
  #actions {
    flex: none;
  }

  #card {
    flex: 1 0 auto;
  }

  #actions {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "progress"
      "orders"
      "main";
  }

  #order-actions[hidden] ~ #plan-actions,
  #order-actions[hidden] ~ #play-actions,
  #order-actions[hidden] ~ #over-actions {
    grid-column: auto;
  }

  #topbar {
    padding-right: 8px;
  }
}

/* ---------- Tablet: panel beside the map, with the battle log ---------- */

@media (min-width: 760px) and (min-height: 560px) {
  #app {
    grid-template-columns: minmax(0, 1fr) 340px;
  }

  #side {
    position: relative;
    grid-column: 2;
    grid-row: 1;
    display: flex;
    flex-direction: column;
    gap: 10px;
    overflow: hidden;
    padding-block: 12px 14px;
    padding-left: 14px;
    padding-right: max(14px, env(safe-area-inset-right, 0px));
    border-top: 0;
    border-left: 1px solid var(--line);
    background: var(--panel-solid);
  }

  #topbar {
    padding-right: 8px;
  }

  #squad {
    flex: none;
    flex-direction: column;
    overflow: visible;
  }

  .chip {
    flex: none;
  }

  #card {
    flex: none;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 14px;
  }

  #log {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
  }

  .card-titles {
    display: block;
  }

  #actions {
    flex: none;
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "progress"
      "orders"
      "main";
  }

  #order-actions[hidden] ~ #plan-actions,
  #order-actions[hidden] ~ #play-actions,
  #order-actions[hidden] ~ #over-actions {
    grid-column: auto;
  }
}

/* ---------- Desktop: squadron on the left, card and log on the right ---------- */

@media (min-width: 1200px) and (min-height: 600px) {
  #app {
    grid-template-columns: 240px minmax(0, 1fr) 360px;
    grid-template-rows: auto minmax(0, 1fr) auto;
    background: var(--panel-solid);
  }

  #map {
    grid-column: 2;
    grid-row: 1 / 4;
    border-left: 1px solid var(--line);
    border-right: 1px solid var(--line);
  }

  #side {
    display: contents;
  }

  #squad {
    grid-column: 1;
    grid-row: 1 / 4;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 14px;
    padding-left: max(14px, env(safe-area-inset-left, 0px));
    overflow-y: auto;
  }

  #squad::before {
    /* The words come from the page, so they follow the language. */
    content: attr(aria-label);
    padding: 4px 2px 6px;
    font-size: 11px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--muted);
  }

  #card {
    grid-column: 3;
    grid-row: 1;
    margin: 14px 14px 0;
  }

  #log {
    grid-column: 3;
    grid-row: 2;
    padding: 14px 14px 0;
  }

  #actions {
    grid-column: 3;
    grid-row: 3;
    padding: 12px 14px 14px;
    padding-right: max(14px, env(safe-area-inset-right, 0px));
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
    animation: none !important;
  }
}

/* ---------- Home menu ---------- */

.home .home-panel {
  width: min(460px, 100%);
  text-align: center;
  padding-block: 28px 24px;
}

.brand {
  margin: 0 0 6px;
  font-family: var(--font-data);
  font-size: clamp(34px, 9vw, 52px);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
}

#app[data-art="neon"] .brand {
  text-shadow: 0 0 18px rgba(0, 240, 255, 0.55);
}

.tagline {
  margin: 0 auto 22px;
  max-width: 34ch;
  color: var(--muted);
  line-height: 1.5;
}

.home-actions {
  display: grid;
  gap: 10px;
}

.ghost-btn.wide {
  width: 100%;
  min-height: 52px;
  font-size: 15px;
}

.ghost-btn:not(:disabled):hover,
.toggle:not(:disabled):hover {
  border-color: var(--accent);
}

.note {
  margin: 16px 0 0;
  font-size: 13px;
  line-height: 1.45;
}

.small {
  font-size: 12px;
}

/* ---------- Forms ---------- */

.field {
  display: grid;
  gap: 6px;
  margin-bottom: 14px;
}

.field > span {
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

.field input {
  min-height: 48px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--chip);
  color: var(--text);
  font: inherit;
  font-size: 16px;
  user-select: text;
}

.field input:focus {
  outline: 2px solid var(--focus);
  outline-offset: 1px;
}

.segmented.wrap {
  grid-template-columns: repeat(auto-fit, minmax(92px, 1fr));
}

.segmented.six {
  grid-template-columns: repeat(5, 1fr);
}

.segmented button:disabled {
  opacity: 0.4;
  cursor: default;
}

.row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.row .go,
.row .ghost-btn {
  flex: 1 1 auto;
}

.row .go.wide {
  flex: 2 1 auto;
  width: auto;
}

.error {
  margin: 8px 0;
  color: var(--danger);
  font-weight: 600;
}

.saved {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.saved p {
  margin: 0;
}

/* ---------- Lobby ---------- */

.lobby-panel {
  width: min(680px, 100%);
}

.share {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  margin-top: 6px;
}

#lobby-qr {
  width: 140px;
  height: 140px;
  border-radius: 10px;
  image-rendering: pixelated;
  flex: none;
}

.share-text {
  flex: 1 1 220px;
  min-width: 0;
}

.share-text p {
  margin: 0 0 8px;
}

.link {
  font-family: var(--font-data);
  font-size: 13px;
  word-break: break-all;
  user-select: all;
}

.lobby-settings p {
  margin: 0 0 8px;
}

.lobby-settings .segmented {
  margin-bottom: 8px;
}

.lobby-seats {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 6px;
}

.seat-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  grid-template-areas:
    "mark text ships"
    "mark actions actions";
  align-items: center;
  gap: 4px 10px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
}

.seat-row.is-away {
  opacity: 0.6;
}

.seat-mark {
  grid-area: mark;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--s1);
}

.seat-row.slot-0 .seat-mark { background: var(--s0); }
.seat-row.slot-2 .seat-mark { background: var(--s2); }
.seat-row.slot-3 .seat-mark { background: var(--s3); }
.seat-row.slot-4 .seat-mark { background: var(--s4); }
.seat-row.slot-5 .seat-mark { background: var(--s5); }

.seat-text {
  grid-area: text;
  min-width: 0;
}

.seat-status {
  display: block;
  font-size: 12px;
  color: var(--muted);
}

.seat-ships {
  grid-area: ships;
  display: flex;
  gap: 2px;
}

.seat-ships .hull-icon {
  width: 18px;
  height: 22px;
}

.seat-actions {
  grid-area: actions;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.seat-actions:empty {
  display: none;
}

.tag {
  display: inline-block;
  margin-left: 4px;
  padding: 1px 6px;
  border-radius: 999px;
  border: 1px solid var(--line);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--muted);
  vertical-align: middle;
}

#lobby-you .row,
#lobby-host .row {
  margin-bottom: 8px;
}

#lobby-ready[aria-pressed="true"] {
  background: var(--good);
}

/* ---------- Quick messages ---------- */

.popover {
  position: fixed;
  z-index: 12;
  width: min(320px, calc(100vw - 16px));
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel-solid);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.4);
}

.phrase-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.phrase-grid .ghost-btn {
  min-height: 44px;
  font-size: 13px;
}

.popover .small {
  margin: 8px 2px 0;
}

#wait-actions,
#watch-actions {
  grid-area: main;
  grid-column: 1 / -1;
  display: flex;
}

#wait-actions .ghost-btn,
#watch-actions .ghost-btn {
  flex: 1;
  min-height: 56px;
}

#watch-actions {
  align-items: center;
  gap: 10px;
}

#watch-actions .watch-note {
  flex: 1.4;
}

.watch-note {
  margin: 0;
  padding: 14px 4px;
}

/* Score chips: each side's name in its colour, with ships left in bold. */
.score .sc {
  color: var(--c, var(--muted));
  white-space: nowrap;
}

.score .sc + .sc::before {
  content: '·';
  margin: 0 5px;
  color: var(--muted);
}

.score .sc b {
  color: var(--text);
  font-weight: 700;
}

/* ---------- Workshop, defence menu, squad tools ---------- */

.squad-row {
  grid-template-columns: auto minmax(0, 1fr) auto;
}

.squad-tools {
  grid-column: 1 / -1;
  display: flex;
  gap: 6px;
}

.squad-tools .ghost-btn {
  flex: 1;
}

@media (max-width: 420px) {
  .squad-row [data-act="loadout"] {
    grid-column: auto;
    grid-row: auto;
  }
}

.small-note {
  margin: 4px 0 0;
  font-size: 12.5px;
}

.workshop {
  z-index: 60;
}

.ws-count {
  float: right;
  font-weight: 600;
  font-size: 12px;
  color: var(--muted);
  text-transform: none;
  letter-spacing: 0;
}

.ws-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 6px;
}

.ws-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 6px 8px 6px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
}

.ws-row.is-on {
  border-color: var(--accent);
}

.ws-name {
  display: grid;
  min-width: 0;
}

.ws-name small {
  font-size: 12px;
  color: var(--muted);
}

.stepper {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.stepper button {
  width: 48px;
  height: 48px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}

.stepper button:disabled {
  opacity: 0.35;
  cursor: default;
}

.stepper output {
  min-width: 26px;
  text-align: center;
  font-family: var(--font-data);
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}

.defmenu {
  position: fixed;
  z-index: 70;
  width: min(330px, calc(100vw - 16px));
  display: grid;
  gap: 4px;
  padding: 8px;
}

.defmenu-title {
  margin: 2px 6px 4px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.def-opt {
  display: grid;
  gap: 2px;
  min-height: 52px;
  padding: 7px 10px;
  text-align: start;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: transparent;
  color: var(--text);
  font: inherit;
  cursor: pointer;
}

.def-opt small {
  font-size: 12px;
  color: var(--muted);
}

.def-opt[aria-pressed="true"] {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
}

.budget.is-over {
  color: var(--danger, #ff6b6b);
}

.segmented.role {
  margin-top: 6px;
}

/* More than four ships (missions add freighters): chips keep a readable width and the row scrolls. */
#squad.is-crowded .chip {
  flex: none;
  min-width: 104px;
}

/* Replay controls */
#replay-actions {
  grid-area: main;
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* The bar reads left to right in every language, like the controls of a film: back, play, forward. */
#replay-actions .ghost-btn {
  flex: 1 1 0;
  min-height: 52px;
  min-width: 48px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

#replay-actions .ghost-btn .ico {
  width: 24px;
  height: 24px;
}

.rp-label {
  flex: 1.3 0 auto;
  text-align: center;
  white-space: nowrap;
  font-family: var(--font-data);
  font-size: 16px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}

#over-actions {
  display: flex;
  gap: 8px;
}

#over-actions .go {
  flex: 1;
}

/* ---------- Career ---------- */

.cr-card {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
}

.cr-head {
  display: flex;
  align-items: center;
  gap: 12px;
}

.cr-head .tag {
  margin-inline-start: auto;
}

.insignia {
  width: 40px;
  height: 40px;
  flex: none;
  fill: var(--accent);
  stroke: var(--accent);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.insignia path[d^="M4"] {
  fill: none;
}

.cr-rank {
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.cr-name {
  font-size: 20px;
  font-weight: 700;
}

.cr-bar {
  height: 6px;
  border-radius: 3px;
  background: var(--line);
  overflow: hidden;
}

.cr-bar i {
  display: block;
  height: 100%;
  background: var(--accent);
}

.cr-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin: 0;
}

.cr-stats dt {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

.cr-stats dd {
  margin: 0;
  font-family: var(--font-data);
  font-size: 18px;
  font-weight: 700;
}

.cr-medals {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.cr-medals li {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px 4px 6px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 12.5px;
}

.cr-medals.big {
  display: grid;
}

.cr-medals.big li {
  border-radius: 12px;
  align-items: flex-start;
  padding: 8px 10px;
}

.medal {
  width: 14px;
  height: 14px;
  flex: none;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #fff3b0, #e0a72e 60%, #8a5a12);
  box-shadow: 0 0 0 2px rgba(224, 167, 46, 0.25);
}

.cr-brief h3 {
  margin: 14px 0 4px;
  text-transform: none;
  letter-spacing: 0;
  font-size: 17px;
  color: var(--text);
}

.cr-brief p {
  margin: 4px 0;
}

.cr-line {
  font-size: 17px;
  font-weight: 600;
}

.cr-promo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 16px;
}

.cr-footer {
  margin-top: 10px;
  display: flex;
  justify-content: center;
}

.cr-roll {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 6px;
}

.cr-roll-row {
  display: grid;
  grid-template-columns: 32px 1fr;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
}

.cr-pos {
  font-family: var(--font-data);
  font-weight: 700;
  font-size: 18px;
  color: var(--accent);
}

.check {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  margin: 10px 0;
  font-size: 14px;
}

.check input {
  width: 22px;
  height: 22px;
  flex: none;
  margin-top: 2px;
}

select {
  min-height: 48px;
  font: inherit;
  color: var(--text);
  background: var(--chip);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0 10px;
}

.hint-next {
  align-self: flex-end;
  min-height: 44px;
}

#hint {
  flex-wrap: wrap;
}

#hint p {
  flex: 1 1 220px;
}

.hint-next {
  margin-inline-start: auto;
}

/* The main menu's list of online wars */
.home-wars {
  margin-top: 14px;
  text-align: start;
}

.home-wars ul {
  list-style: none;
  margin: 6px 0 0;
  padding: 0;
  display: grid;
  gap: 6px;
}

.war-row {
  display: grid;
  gap: 2px;
  min-height: 48px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--text);
  text-decoration: none;
}

.war-row span {
  font-size: 12.5px;
  color: var(--muted);
}

.war-row.is-mine {
  border-color: var(--accent);
}

.war-row.is-mine span {
  color: var(--accent);
}

#lobby-alerts {
  margin-top: 8px;
}

/* Right-to-left (Arabic): text reads from the right; numbers and codes stay left-to-right. */
[dir="rtl"] body {
  font-family: system-ui, -apple-system, 'Segoe UI', Tahoma, 'Noto Sans Arabic', sans-serif;
}

[dir="rtl"] .ws-count {
  float: left;
}

[dir="rtl"] #lobby-link,
[dir="rtl"] .war-row b,
[dir="rtl"] #join-code {
  direction: ltr;
  unicode-bidi: isolate;
}

/* ---------- Pictures in place of words (28 November 2026) ---------- */

.ico {
  width: 18px;
  height: 18px;
  flex: none;
  fill: currentColor;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.ico path:not([fill="none"]),
.ico circle:not([fill="none"]) {
  stroke: none;
}

.msl {
  width: 7px;
  height: 11px;
  flex: none;
  fill: currentColor;
  transition: transform 0.12s;
}

.msl.w-seeker { color: #ffd84a; }
.msl.w-rocket { color: #ff9a3d; }
.msl.w-swarm { color: #c79bff; }
.msl.w-torpedo { color: #ff6b8a; }
.msl.w-mine { color: #9fb4c8; }
.msl.w-scrambler { color: #5fd0ff; }
.msl.w-flak { color: #7fe3a1; }
[data-art="paper"] .msl.w-seeker { color: #b98a00; }
[data-art="paper"] .msl.w-rocket { color: #c8601a; }
[data-art="paper"] .msl.w-swarm { color: #7a4fc4; }
[data-art="paper"] .msl.w-torpedo { color: #c22f52; }
[data-art="paper"] .msl.w-mine { color: #55677a; }
[data-art="paper"] .msl.w-scrambler { color: #1b7fb0; }
[data-art="paper"] .msl.w-flak { color: #2a8a4c; }

.msl.up {
  transform: translateY(-5px) scale(1.25);
  filter: drop-shadow(0 0 3px currentColor);
}

.msl.spent {
  opacity: 0.25;
}

.msl-row {
  display: inline-flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 2px 1px;
  max-width: 100%;
}

.msl-more {
  font-size: 10px;
  margin-left: 2px;
}

/* The ship card: a drawing on the left, gauges on the right. */
.card2 {
  display: flex;
  gap: 10px;
  align-items: center;
  min-width: 0;
}

.card-pic {
  flex: none;
  width: 96px;
  display: grid;
  justify-items: center;
  gap: 2px;
}

.shipview {
  width: 96px;
  height: 96px;
}

.sv-hull {
  stroke-width: 2;
  stroke-linejoin: round;
}

.shipview.slot-0 .sv-hull { fill: var(--s0f); stroke: var(--s0); }
.shipview.slot-1 .sv-hull { fill: var(--s1f); stroke: var(--s1); }
.shipview.slot-2 .sv-hull { fill: var(--s2f); stroke: var(--s2); }
.shipview.slot-3 .sv-hull { fill: var(--s3f); stroke: var(--s3); }
.shipview.slot-4 .sv-hull { fill: var(--s4f); stroke: var(--s4); }
.shipview.slot-5 .sv-hull { fill: var(--s5f); stroke: var(--s5); }
.shipview.slot-0 { color: var(--s0); }
.shipview.slot-1 { color: var(--s1); }
.shipview.slot-2 { color: var(--s2); }
.shipview.slot-3 { color: var(--s3); }
.shipview.slot-4 { color: var(--s4); }
.shipview.slot-5 { color: var(--s5); }

.shipview.is-dark .sv-hull {
  opacity: 0.45;
  stroke-dasharray: 4 3;
}

.sb {
  fill: currentColor;
}

.sb-lost {
  fill: var(--danger);
}

.sb-brace {
  fill: none;
  stroke: currentColor;
  stroke-width: 2.5;
  stroke-linecap: round;
}

.hearts {
  display: flex;
  gap: 1px;
}

.heart .ico {
  width: 13px;
  height: 13px;
  color: var(--danger);
  opacity: 0.25;
}

.heart.on .ico {
  opacity: 1;
}

.card-info {
  flex: 1;
  min-width: 0;
  display: grid;
  gap: 4px;
}

.card2 .card-head {
  margin: 0;
}

.card2 .card-titles {
  display: grid;
  gap: 0;
}

.gauges {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 12px;
}

.gauges.nums {
  font-family: var(--font-data);
  font-size: 13px;
  color: var(--muted);
}

.gauges.nums span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.gauges.nums .ico {
  width: 13px;
  height: 13px;
}

.g-heat {
  display: inline-flex;
}

.flame .ico {
  width: 17px;
  height: 17px;
  color: var(--heat);
  opacity: calc(0.22 + 0.78 * var(--f));
}

.g-parts {
  display: inline-flex;
  gap: 8px;
}

.g-parts .part {
  gap: 3px;
  color: var(--text);
}

.g-parts .part.is-hurt {
  color: var(--danger);
}

.g-parts .part.is-out .ico {
  opacity: 0.45;
}

.card-arms,
.squad-arms {
  display: flex;
  flex-wrap: wrap;
  gap: 3px 8px;
}

.warn {
  display: flex;
  align-items: center;
  gap: 6px;
}

.warn .ico {
  width: 16px;
  height: 16px;
}

/* Round autopilot switch */
.mode-btn {
  width: 40px;
  min-height: 40px;
  padding: 0;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: var(--muted);
}

.mode-btn .ico {
  width: 22px;
  height: 22px;
}

/* Weapon buttons: a row of missiles, no words on phones */
.wchip {
  position: relative;
  min-height: 60px;
  padding: 6px 6px 4px;
  gap: 3px;
}

.wchip .wrow {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 4px;
  min-height: 24px;
}

.wchip .wmode {
  position: absolute;
  top: 2px;
  right: 3px;
  opacity: 0.55;
}

.wchip .wmode .ico {
  width: 12px;
  height: 12px;
}

.wchip[data-mode="now"] .wmode,
.wchip[data-mode="auto"] .wmode {
  opacity: 1;
}

.wchip[data-mode="auto"] .wmode {
  color: var(--heat);
}

.wchip[data-mode="now"] {
  background: color-mix(in srgb, var(--heat) 30%, var(--chip));
  border-color: var(--heat);
  box-shadow: inset 0 0 0 1px var(--heat);
  color: var(--text);
}

.wchip .state {
  font-size: 11.5px;
}

.wchip[data-mode="auto"] .state {
  color: var(--accent);
}

.wchip.def .ico {
  width: 28px;
  height: 28px;
}

.wchip.def:not([data-mode="none"]) {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
  color: var(--accent);
}

.dpips {
  display: inline-flex;
  gap: 2px;
}

.dpips i,
.chip-hearts i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  border: 1px solid currentColor;
}

.dpips i.on {
  background: currentColor;
}

/* Squadron chips */
.chip-marks {
  display: flex;
  gap: 3px;
  min-height: 14px;
  color: var(--muted);
}

.chip-marks .ico {
  width: 13px;
  height: 13px;
}

.mk-fire { color: var(--heat); display: inline-flex; }
.mk-warn { color: var(--danger); display: inline-flex; }

.chip-hearts {
  display: flex;
  gap: 2px;
  color: var(--danger);
}

.chip-hearts i {
  width: 5px;
  height: 5px;
  opacity: 0.4;
}

.chip-hearts i.on {
  background: currentColor;
  opacity: 1;
}

.chip.is-dead .chip-marks {
  color: var(--danger);
}

/* Score chips */
.sc {
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.sc .hull-icon {
  width: 12px;
  height: 16px;
}

.sc-label {
  display: none;
}

/* Defence menu: picture tiles */
.def-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(64px, 1fr));
  gap: 6px;
}

.def-grid .def-opt {
  min-height: 68px;
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 4px;
  padding: 6px 4px;
  text-align: center;
}

.def-grid .def-opt .ico {
  width: 28px;
  height: 28px;
}

.def-grid .def-opt b {
  font-size: 12.5px;
  font-weight: 700;
  line-height: 1.15;
}

/* Setup: ships by picture */
.squad-pic {
  flex: none;
  width: 56px;
}

.squad-pic .shipview {
  width: 56px;
  height: 56px;
}

.squad-row {
  align-items: center;
}

.squad-row .squad-tools {
  display: flex;
  gap: 4px;
}

.ghost-btn.ib {
  width: 48px;
  min-height: 48px;
  padding: 0;
  display: grid;
  place-items: center;
}

.hull-bars {
  display: flex;
  gap: 10px;
  color: var(--muted);
}

.hull-bars > span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.hull-bars .ico {
  width: 12px;
  height: 12px;
}

.bar {
  display: inline-block;
  width: 44px;
  height: 5px;
  border-radius: 3px;
  background: var(--heat-track);
  overflow: hidden;
}

.bar i {
  display: block;
  height: 100%;
  background: var(--accent);
}

.hull-text {
  display: grid;
  gap: 3px;
}

/* Wider screens have room for the words as well */
@media (min-width: 700px) {
  .sc-label {
    display: inline;
    margin-inline: 2px 4px;
  }
}

@media (max-width: 699px) {
  .wchip .state {
    display: none;
  }
}

.wchip .msl {
  width: 9px;
  height: 14px;
}

.card-pic,
.card-pic .shipview {
  width: 112px;
}

.card-pic .shipview {
  height: 112px;
}

/* Pictures on menu and choice buttons */
.home-actions button,
.segmented button,
#btn-quick {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.home-actions .ico {
  width: 24px;
  height: 24px;
}

.segmented.wrap button {
  flex-direction: column;
  gap: 3px;
  padding-block: 6px;
}

.segmented.wrap .ico {
  width: 24px;
  height: 24px;
}

/* ---------- Second picture pass (28 November 2026) ---------- */

.ico rect:not([fill="none"]) {
  stroke: none;
}

/* Missiles are drawn in a 12 by 20 box */
.msl {
  width: 8px;
  height: 13px;
}

.wchip .msl {
  width: 11px;
  height: 18px;
}

.msl.up {
  transform: translateY(-6px) scale(1.3);
}

/* Who flies this ship: the robot (autopilot) or you (the controller) */
.pilot {
  flex: none;
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  background: var(--chip);
}

.pilot button {
  width: 48px;
  min-height: 48px;
  padding: 0;
  display: grid;
  place-items: center;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  opacity: 0.55;
}

.pilot button .ico {
  width: 26px;
  height: 26px;
}

.pilot button[aria-pressed="true"] {
  background: var(--accent);
  color: var(--accent-text);
  opacity: 1;
}

.mk-you {
  display: inline-flex;
  color: var(--accent);
}

/* The mark in the corner of a weapon button */
.wchip .wmode {
  top: 3px;
  right: 4px;
  opacity: 1;
}

.wchip .wmode .ico {
  width: 16px;
  height: 16px;
}

.wchip[data-mode="auto"] {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
}

.wchip[data-mode="auto"] .wmode {
  color: var(--accent);
}

.wchip[data-mode="now"] .wmode {
  color: var(--heat);
}

/* Speed as a bar: filled to the speed now, with a mark at the speed planned */
.g-speed,
.g-turn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.sbar {
  position: relative;
  display: inline-block;
  width: 64px;
  height: 8px;
  border-radius: 4px;
  background: var(--heat-track);
}

.sbar > i {
  display: block;
  height: 100%;
  border-radius: 4px;
  background: var(--accent);
  opacity: 0.55;
}

.sbar > b {
  position: absolute;
  top: -3px;
  width: 4px;
  height: 14px;
  margin-inline-start: -2px;
  border-radius: 2px;
  background: var(--text);
}

/* The turn planned, as a pointer on a dial */
.dial {
  width: 22px;
  height: 22px;
  flex: none;
}

.dial circle {
  stroke: var(--line);
  stroke-width: 1.5;
}

.dial path {
  fill: var(--accent);
  stroke: var(--accent);
  stroke-width: 1.6;
  stroke-linecap: round;
}

.gauges.nums .ico {
  width: 16px;
  height: 16px;
}

/* On phones the pictures say it; the words and numbers come back on wider screens */
@media (max-width: 699px) {
  .card2 .card-role,
  .gauges.nums .num {
    display: none;
  }
}

/* Buttons that carry a picture beside their words */
#btn-start,
#btn-skip,
#btn-result-replay,
#btn-over-replay,
.workshop .setup-actions button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.segmented button .ico {
  width: 20px;
  height: 20px;
}

/* Credits and ships left, as pictures with numbers */
.budget {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 16px;
}

.budget .bud {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--muted);
}

.budget .bud b {
  color: var(--text);
  font-size: 15px;
}

.budget .ico {
  width: 16px;
  height: 16px;
}

.budget .bud-note {
  flex-basis: 100%;
  font-family: var(--font-ui);
  font-size: 12.5px;
}

.cost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

.cost .ico {
  width: 13px;
  height: 13px;
}

.obj-label {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.obj-label .ico {
  width: 14px;
  height: 14px;
}

@media (max-width: 1499px) {
  .obj-label {
    font-size: 0;
    gap: 0;
  }
}

.result-pic {
  display: grid;
  place-items: center;
  margin-bottom: 6px;
}

.result-pic .ico {
  width: 64px;
  height: 64px;
  color: var(--muted);
}

[data-outcome="win"] .result-pic .ico {
  color: var(--good);
}

[data-outcome="loss"] .result-pic .ico {
  color: var(--danger);
}

/* ---------- Workshop in pictures ---------- */

.ws-canvas {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 32 / 15;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg);
}

.ws-about {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 6px 12px;
  margin-top: 8px;
}

.ws-about b {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
}

.ws-about b .msl {
  width: 12px;
  height: 20px;
}

.ws-stats {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 12px;
  color: var(--muted);
}

.st {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.st .ico {
  width: 17px;
  height: 17px;
}

.st-dmg {
  gap: 1px;
  color: var(--danger);
}

.st-zap {
  gap: 0;
  color: var(--accent);
}

.st-zap .ico + .ico {
  width: 12px;
  height: 12px;
  color: var(--danger);
}

.ws-count {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-family: var(--font-data);
}

.ws-count .ico {
  width: 15px;
  height: 15px;
}

#ws-pool .ico {
  color: var(--good);
}

.ws-loose {
  display: inline-flex;
  gap: 3px;
}

.ws-loose i {
  width: 16px;
  height: 6px;
  border-radius: 2px;
  background: var(--accent);
}

.ws-tiles {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
}

.ws-tile {
  position: relative;
  min-height: 92px;
  min-width: 0;
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 3px;
  padding: 10px 2px 6px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--chip);
  cursor: pointer;
}

.ws-tile .msl {
  width: 20px;
  height: 33px;
}

.ws-tile-name {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  font-weight: 650;
}

.ws-tile-cost {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-family: var(--font-data);
  font-size: 11px;
  color: var(--muted);
}

.ws-tile-cost .ico {
  width: 11px;
  height: 11px;
}

.ws-tile-n {
  position: absolute;
  top: 4px;
  inset-inline-end: 7px;
  font-family: var(--font-data);
  font-weight: 700;
  font-size: 13px;
  color: var(--accent);
}

.ws-tile.is-on {
  border-color: var(--accent);
}

.ws-tile[aria-checked="true"] {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 2px var(--accent);
}

.ws-tile.is-shut {
  opacity: 0.45;
}

.ws-step {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) 48px;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
}

.ws-step-row {
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px;
  border: 1px dashed var(--line);
  border-radius: 12px;
}

.ws-step-row .msl {
  width: 10px;
  height: 17px;
}

.ws-btn {
  width: 48px;
  height: 48px;
  padding: 0;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
}

.ws-btn:disabled {
  opacity: 0.35;
  cursor: default;
}

.ws-btn .ico {
  width: 22px;
  height: 22px;
}

/* The ship with a pair of buttons on each side. It keeps its own left and right in every language. */
.ws-shields {
  direction: ltr;
  display: grid;
  grid-template-columns: 48px minmax(0, 170px) 48px;
  grid-template-areas:
    ". front ."
    "left ship right"
    ". rear .";
  justify-content: center;
  align-items: center;
  gap: 6px;
}

.sh {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.sh output {
  min-width: 18px;
  text-align: center;
  font-family: var(--font-data);
  font-weight: 700;
}

.sh-front { grid-area: front; }
.sh-rear { grid-area: rear; }
.sh-left { grid-area: left; flex-direction: column-reverse; }
.sh-right { grid-area: right; flex-direction: column-reverse; }
.sh-ship { grid-area: ship; }

.sh-ship .shipview {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 1;
}

/* A key to the pictures, at the top of How to play */
.legend {
  list-style: none;
  margin: 0 0 12px;
  padding: 10px 12px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  font-size: 12.5px;
}

.legend li {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.legend .ico {
  width: 22px;
  height: 22px;
  color: var(--accent);
}

.legend .lg-msl {
  flex: none;
  display: inline-flex;
  align-items: flex-end;
  gap: 1px;
  padding-top: 6px;
}

/* ---------- Shields as curved arcs, and the view lock (28 November 2026) ---------- */

/* One arc for each shield point, curved round the ship the way the map draws shields */
.sa {
  fill: none;
  stroke: currentColor;
  stroke-width: 3.2;
  stroke-linecap: round;
}

/* A point that has been shot away: a broken red arc */
.sa-lost {
  stroke: var(--danger);
  stroke-width: 2.2;
  stroke-dasharray: 0.1 5;
}

.sb-brace {
  stroke-width: 5;
}

/* The view lock in the top bar: lit while the view stays with the selected ship */
#btn-lock[aria-pressed="true"] {
  color: var(--accent);
}

#btn-lock[aria-pressed="false"] {
  color: var(--muted);
}

/* ---------- Online: map, credits and friendly fire; moving to another device; leaving a battle ---------- */

.lobby-settings .set-label {
  display: block;
  margin: 10px 0 4px;
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

.field > .small-note {
  margin: 0;
}

.battle-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

#btn-surrender {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--danger);
}

#btn-surrender[data-armed="1"] {
  border-color: var(--danger);
  background: color-mix(in srgb, var(--danger) 16%, transparent);
}

.movebox .small-note {
  margin-top: 12px;
}

#lobby-move {
  margin-top: 8px;
}

/* ---------- Narrow top bar in an online war ---------- */

/* An online war adds the quick-message button, which leaves too little room beside the buttons
   for "Plan your moves · 0:59" on a phone. There the status line gets a row of its own. */
@container (max-width: 520px) {
  #topbar:has(#btn-say:not([hidden])) {
    grid-template-areas:
      "turn actions"
      "phase phase"
      "obj obj";
  }

  #topbar:has(#btn-say:not([hidden])) .tb-turn {
    display: contents;
  }

  #topbar:has(#btn-say:not([hidden])) .tb-turn strong {
    grid-area: turn;
  }

  #topbar:has(#btn-say:not([hidden])) #phase-label {
    grid-area: phase;
  }
}

/* ---------- Replay: the switch between its two ways of playing ---------- */

#btn-rp-mode[aria-pressed="true"] {
  color: var(--accent);
  border-color: var(--accent);
}

/* The defence button keeps a thumb-sized width even when two weapon buttons share its row. */
#side [data-action="defence"] {
  min-width: 48px;
}

/* ---------- Key hints: the key that presses a button, shown on it where a keyboard is in use ---------- */

.key {
  display: none;
}

.has-keys .key {
  position: absolute;
  top: 3px;
  inset-inline-end: 3px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 17px;
  height: 17px;
  padding: 0 4px;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 5px;
  background: var(--panel-solid);
  color: var(--muted);
  font: 650 10px/1 var(--font-data);
  letter-spacing: 0;
  text-transform: none;
  pointer-events: none;
}

.go,
.chip,
.pilot button,
#btn-skip,
#replay-actions .ghost-btn {
  position: relative;
}

/* On the GO button the hint sits on the accent colour. */
.has-keys .go .key {
  top: 5px;
  inset-inline-end: 5px;
  border-color: color-mix(in srgb, var(--accent-text) 35%, transparent);
  background: color-mix(in srgb, var(--accent-text) 12%, transparent);
  color: var(--accent-text);
}

/* Beside the speed and turn numbers the hint stands in the row. */
.has-keys .gauges .key {
  position: static;
  margin-inline-start: 2px;
  letter-spacing: 1px;
}

/* In the replay bar the pictures sit a little lower, so a key hint never covers one. */
.has-keys #replay-actions .ghost-btn {
  padding-top: 12px;
}

/* A speed such as "224 ← 239" stays on one line. */
.gauges.nums .num {
  white-space: nowrap;
}
