:root {
  --canvas: #0c1216;
  --panel: #182129;
  --ink: #ecede6;
  --muted: #a4b1b6;
  --steel: #384650;
  --brass: #e2b66c;
  --mint: #98cbb8;
  --display: "Bahnschrift", "Arial Narrow", "Roboto Condensed", system-ui, sans-serif;
  --mono: "Cascadia Mono", Consolas, monospace;
  background: var(--canvas);
  color: var(--ink);
}

body {
  background: radial-gradient(ellipse at 50% 0, #202d35, transparent 56rem), var(--canvas);
}

button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible {
  outline: 2px solid #ffdda0;
  outline-offset: 3px;
}

.topbar {
  height: 66px;
  padding-inline: max(22px, calc((100vw - 1460px) / 2));
  border-color: var(--steel);
  background: linear-gradient(#10181df0, #10181df0), url("/art/brushed-steel.png") center / 320px;
  box-shadow: 0 4px 16px #0005, inset 0 -2px #0005;
}
.brand { gap: 10px; font-family: var(--display); letter-spacing: .14em; }
.brand small { color: var(--brass); }
.brandmark {
  display: block;
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  object-fit: contain;
  background: none;
  border: 0;
  clip-path: none;
}
.topright { gap: 15px; }
.social-nav { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.social-nav a { padding: 7px 8px; border-radius: 3px; color: var(--mint); font-size: .88rem; font-weight: 650; white-space: nowrap; }
.social-nav a:hover, .social-nav a[aria-current="page"] { color: #ffe1a8; background: #34332a; }
.unread-count { display: inline-block; padding: 2px 5px; border-radius: 3px; border: 1px solid #8f7144; color: #ffe0a2; background: #443726; font: 600 .72rem var(--mono); }
.social-nav .unread-count { margin-left: 2px; }
.pilot { font-family: var(--mono); overflow-wrap: anywhere; }
.textbutton, .backlink { color: var(--mint); }
.textbutton:hover, .backlink:hover { color: #d2ede1; }
.topright .textbutton { padding: 7px 11px; border: 1px solid var(--steel); border-radius: 3px; }
.commander-avatar { display: block; object-fit: cover; border: 1px solid #708477; border-radius: 3px; }
.profile-link { display: flex; min-width: 0; align-items: center; gap: 8px; padding: 3px; border-radius: 4px; }
.profile-link:hover { background: #2a3b38; }
.profile-link .pilot { max-width: 16ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.match-avatar { flex: 0 0 56px; }
.opponent-profile {
  display: inline-flex; align-items: center; gap: 6px; margin-top: 5px; color: #c6d7cd;
  font-size: .8rem;
}
a.opponent-profile:hover { color: #f1d099; }
.game-sign-in { display: block; margin-block-start: 4px; color: var(--muted); font-size: .75rem; }
.social-grid { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.social-stack { display: grid; gap: 12px; }
.social-panel { padding: 16px 18px; min-width: 0; }
.social-row { display: flex; gap: 9px; align-items: center; padding: 10px 0; border-top: 1px solid var(--desk-line); }
.social-row .commander-avatar { flex-shrink: 0; }
.social-person { flex: 1 1 auto; min-width: 0; display: grid; gap: 4px; overflow-wrap: anywhere; }
.social-person small, .social-muted { color: var(--muted); font-size: .86rem; }
.social-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.social-page .social-row .primary, .social-page .social-row .secondary { padding: 6px 10px; font-size: .82rem; min-height: 35px; }
.social-search { display: flex; gap: 8px; align-items: end; margin: 12px 0; }
.social-search label { flex: 1; min-width: 0; margin: 0; }
.social-search input { min-width: 0; }
.thread-pages { margin: 0 0 10px; }
.thread-log { display: flex; flex-direction: column; gap: 10px; margin: 0 0 14px; padding: 0 4px 4px 0; max-height: 50dvh; overflow: auto; list-style: none; }
.message-bubble { align-self: flex-start; min-width: 0; max-width: 90%; padding: 9px 11px; border: 1px solid #637a6e; border-radius: 4px; background: #223a34; }
.message-bubble.sent { align-self: flex-end; border-color: #8b7449; background: #403724; }
.message-meta { display: flex; flex-wrap: wrap; gap: 4px 10px; color: #c2d4ce; font-size: .78rem; }
.message-meta time { color: var(--muted); }
.message-bubble p { margin: 5px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.message-compose { border-top: 1px solid var(--desk-line); padding-top: 12px; }
.message-compose textarea { display: block; width: 100%; margin-top: 5px; padding: 9px 11px; resize: vertical; color: var(--ink); background: #10191f; border: 1px solid #596a74; border-radius: 3px; font: inherit; }

.profile-page { max-width: 1100px; padding-top: 28px; }
.profile-page h1 { color: #f3ebd9; font: 750 clamp(1.65rem, 3vw, 2.65rem)/1.1 var(--display); margin: 9px 0; overflow-wrap: anywhere; }
.profile-intro { margin: 0 0 22px; color: #b9c6c5; }
.profile-form { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr); gap: 16px; align-items: start; }
.profile-fields, .avatar-picker { padding: 18px; }
.profile-actions { grid-column: 1 / -1; }
.profile-fields label { margin: 0 0 6px; }
.profile-fields label span { color: #a6b6b7; font-size: .76rem; font-weight: 400; margin-left: 5px; }
.profile-fields input, .profile-fields textarea { margin: 0 0 14px; }
.profile-fields textarea {
  width: 100%; min-height: 96px; padding: 10px 12px; resize: vertical;
  color: var(--ink); background: #10191f; border: 1px solid #4b5963; border-radius: 3px; font: inherit;
}
.profile-fields textarea:focus-visible { outline: 2px solid #ffdda0; outline-offset: 2px; }
.avatar-picker { min-inline-size: 0; margin: 0; }
.avatar-picker legend { padding: 0 6px; font: 750 1.05rem var(--display); color: var(--ink); }
.avatar-options { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
@media (min-width: 950px) {
  .avatar-options { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
.avatar-option { position: relative; margin: 0; cursor: pointer; }
.avatar-option input { position: absolute; top: 5px; left: 5px; width: 15px; height: 15px; margin: 0; accent-color: var(--brass); z-index: 1; }
.avatar-tile {
  display: flex; flex-direction: column; height: 100%; overflow: hidden;
  border: 2px solid #495b59; border-radius: 4px; background: #21302d;
}
.avatar-tile img { width: 100%; height: auto; aspect-ratio: 1; object-fit: cover; }
.avatar-tile > span { padding: 6px; line-height: 1.25; font-size: .79rem; text-align: center; }
.avatar-option input:checked + .avatar-tile { border-color: var(--brass); background: #4a3a26; color: #ffe6b2; }
.avatar-option input:focus-visible + .avatar-tile { outline: 2px solid #ffdda0; outline-offset: 2px; }
.avatar-option:hover .avatar-tile { box-shadow: 0 0 0 1px #c9c7a2; }
.commander-card { display: flex; align-items: flex-start; gap: 20px; margin-top: 15px; padding: 20px; }
.commander-portrait { width: clamp(80px, 20vw, 180px); height: auto; aspect-ratio: 1; }
.commander-card-details { min-width: 0; }
.commander-card .eyebrow { margin: 2px 0; }
.commander-card blockquote { color: #ebcc91; border-left: 2px solid var(--brass); padding-left: 10px; margin: 10px 0; overflow-wrap: anywhere; }
.commander-bio { color: #d6e0de; white-space: pre-wrap; overflow-wrap: anywhere; }
@media (max-width: 700px) {
  .profile-page { padding: 20px 14px 30px; }
  .profile-form { grid-template-columns: 1fr; }
  .profile-fields, .avatar-picker, .commander-card { padding: 13px; }
  .avatar-options { gap: 6px; }
  .match-avatar { flex-basis: 34px; height: 34px; width: 34px; }
}

.panel, .game-dialog {
  border: 1px solid var(--steel);
  border-radius: 5px;
  background: linear-gradient(145deg, #1b252dec, #131b22f7), url("/art/brushed-steel.png") center / 320px;
  box-shadow: inset 0 1px #ffffff0d, 0 10px 22px #0003;
}
.panel h2, .game-dialog h2 {
  color: var(--ink);
  font-family: var(--display);
  font-weight: 750;
}
.section-head { align-items: baseline; }
.section-head span, .eyebrow {
  color: var(--muted);
  font-family: var(--mono);
  font-size: .76rem;
}
.eyebrow { color: #edc688; text-transform: uppercase; letter-spacing: .15em; }
.primary, .secondary {
  border-radius: 4px;
  box-shadow: inset 0 1px #fff3, 0 2px 0 #080d10;
  font-family: var(--display);
  letter-spacing: .025em;
  transition: background-color .15s, border-color .15s, box-shadow .15s;
}
.primary {
  color: #211a11;
  border: 1px solid #f3c985;
  background: linear-gradient(#f0ca89, #c99148);
}
.primary:hover:not(:disabled) { background: linear-gradient(#ffe1aa, #e4b16a); }
.secondary {
  color: #d7e8df;
  border: 1px solid #53776e;
  background: linear-gradient(#293b3b, #192b2d);
}
.secondary:hover:not(:disabled) { background: #334c49; }
.primary:active:not(:disabled), .secondary:active:not(:disabled) { box-shadow: inset 0 2px 3px #0005; }
label { color: #c9d1d1; }
input, select {
  border: 1px solid #4b5963;
  border-radius: 3px;
  background: #10191f;
  color: var(--ink);
}
input:focus, select:focus { border-color: var(--brass); box-shadow: 0 0 0 2px #e2b66c25; }

.command-hero {
  position: relative;
  display: grid;
  align-items: end;
  overflow: hidden;
  isolation: isolate;
  border: 1px solid #53676b;
  border-radius: 5px;
  background: linear-gradient(90deg, #0b141aee, #101a2260 70%, #10191c12),
    url("/art/frontier-coast.png") center 51% / cover;
  box-shadow: 0 12px 35px #0006, inset 0 0 45px #0610155c;
}
.command-hero::before, .command-hero::after {
  content: "";
  pointer-events: none;
  position: absolute;
  inset: 12px;
  border: 1px solid #d5e2dd35;
}
.command-hero::after {
  border: 0;
  background:
    linear-gradient(#edc688, #edc688) top left / 24px 2px no-repeat,
    linear-gradient(#edc688, #edc688) top left / 2px 24px no-repeat,
    linear-gradient(#edc688, #edc688) bottom right / 24px 2px no-repeat,
    linear-gradient(#edc688, #edc688) bottom right / 2px 24px no-repeat;
}
.hero-copy { position: relative; padding: clamp(24px, 4vw, 56px); }
.hero-copy h1 {
  color: #f5f0de;
  font: 800 clamp(2.3rem, 5.4vw, 5.8rem)/.94 var(--display);
  letter-spacing: -.035em;
  text-transform: uppercase;
  text-shadow: 0 3px 15px #070c11cc;
  margin: 9px 0 16px;
}
.hero-copy p:last-child {
  margin: 0;
  max-width: 34rem;
  color: #e0e6e2;
  line-height: 1.55;
  text-shadow: 0 1px 5px #000;
}

.auth-shell {
  max-width: 1480px;
  grid-template-columns: minmax(0, 1fr) minmax(310px, 400px);
  align-items: start;
  gap: 18px;
  padding: 26px 22px 48px;
}
.auth-copy {
  display: block;
  padding: 0;
  background: #122022;
}
.auth-copy::before, .auth-copy::after { content: none; }
.auth-copy .auth-title { max-width: none; margin: 0; }
.auth-title img { display: block; width: 100%; height: auto; border-bottom: 1px solid #5b6b5f; }
.auth-pitch { padding: clamp(14px, 2.9vw, 30px); }
.auth-pitch .eyebrow { margin: 0 0 6px; }
.auth-pitch p:last-child { margin: 0; max-width: 42rem; color: var(--ink); line-height: 1.55; }
.auth-forms { align-content: start; gap: 13px; }
.auth-forms .panel { padding: 20px 23px; }
.auth-forms .alert { margin: 0; }
.auth-forms label { margin-bottom: 12px; }

.lobby { max-width: 1500px; padding-top: 24px; }
.lobby .command-hero { min-height: 244px; margin-bottom: 18px; }
.lobby .hero-copy h1 { font-size: clamp(2rem, 5vw, 4.3rem); }
.lobby-create { margin-top: 12px; }
.create-game-dialog { width: min(560px, calc(100% - 24px)); max-height: 90dvh; overflow-y: auto; }
.create-game-dialog form .dialog-actions button { width: auto; }
.create-game-dialog #mapCodeHelp { display: block; margin-top: 5px; color: var(--muted); }
.seat-picker { display: grid; gap: 7px; padding: 9px 12px 12px; margin: 0; border: 1px solid var(--steel); border-radius: 3px; }
.seat-picker legend { padding-inline: 4px; font-weight: 700; }
.seat-picker-row { display: grid; grid-template-columns: minmax(90px, .6fr) minmax(0, 1fr); align-items: center; gap: 8px; min-height: 35px; }
.seat-picker-row label, .seat-picker-row select { margin: 0; }
.seat-picker-row select { padding: 8px; }
.seat-emblem {
  display: inline-grid;
  place-items: center;
  width: 1.2em;
  height: 1.2em;
  vertical-align: middle;
  color: var(--seat-color, #d9ded5);
  font: 700 1em/1 "Segoe UI Symbol", Arial, sans-serif;
}
.campaign-players { display: flex; gap: 5px; flex-wrap: wrap; list-style: none; padding: 0; margin: 7px 0 0; }
.campaign-players li { display: flex; align-items: center; flex-wrap: wrap; gap: 3px; padding: 3px 6px; border: 1px solid var(--steel); border-radius: 3px; font-size: .77rem; overflow-wrap: anywhere; }
.campaign-players .current-player { border-color: var(--seat-color); }
.campaign-players .eliminated-label { color: var(--muted); }
.lobby-grid { margin-top: 0; gap: 16px; align-items: start; }
.lobby-side { gap: 14px; }
.lobby .panel { padding: 21px; }
.match-card { padding: 13px 10px; gap: 14px; border-top-color: #35434b; }
.match-card:hover { background: #26363c; }
.match-entry { border-top: 1px solid #35434b; }
.match-entry .match-card { border-top: 0; }
.match-invite { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: center; padding: 0 10px 9px; }
.match-invite .copy-invite { font-size: .8rem; padding: 4px 8px; }
.match-archive { justify-content: flex-end; }
.lobby .match-archive .archive-button { min-height: 32px; padding: 4px 10px; font-size: .8rem; }
.archive-confirm { width: min(460px, calc(100% - 28px)); padding: 20px; color: var(--ink); }
.archive-confirm::backdrop { background: #07121bbd; }
.archive-confirm h2 { margin-top: 0; }
.archive-confirm p { line-height: 1.5; }
.archive-confirm .dialog-actions { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 8px; }
.match-join-code { font: .77rem var(--mono); color: #eabd77; }
.match-icon {
  flex: 0 0 56px;
  width: 56px;
  height: 43px;
  border: 1px solid #678074;
  border-radius: 3px;
  background: url("/art/hill.png") 40% 43% / 185px;
  box-shadow: inset 0 0 12px #0006;
}
.match-card:nth-of-type(3n + 2) .match-icon { background-image: url("/art/forest.png"); }
.match-card:nth-of-type(3n) .match-icon { background-image: url("/art/water.png"); }
.match-main strong { overflow-wrap: anywhere; }
.match-main span { color: var(--muted); }
.match-ready { border-left: 2px solid var(--brass); background: #2a2e28; }
.match-turn { flex: 0 0 auto; min-width: 0; display: grid; justify-items: end; gap: 4px; text-align: right; }
.match-turn small { color: #e5c78e; font-size: .76rem; }
.match-main .opponent-sign-in { color: #c3cbc6; font-size: .77rem; }
.match-status { border-radius: 3px; font: 600 .72rem var(--mono); }
.match-status.active { color: #c2d1d4; border-color: #557074; background: #26383e; }
.match-status.ready { color: #f5d598; border-color: #8f7144; background: #443726; }
.match-status.waiting { color: #dad0a7; border-color: #746e55; background: #322f25; }
.lobby-boards { display: grid; gap: 16px; min-width: 0; }
.lobby [hidden] { display: none !important; }
.queue-filters { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.queue-filters a, .simple-pages a {
  padding: 6px 10px;
  border: 1px solid var(--steel);
  border-radius: 3px;
  color: var(--muted);
  text-decoration: none;
}
.queue-filters a[aria-current="page"], .queue-filters a:hover, .simple-pages a:hover {
  border-color: var(--brass);
  background: #39372f;
  color: #f7d69e;
}
.open-game {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-top: 1px solid #35434b;
}
.open-game-title { display: grid; gap: 4px; overflow-wrap: anywhere; }
.open-game-title small { color: var(--muted); }
.match-mode {
  width: fit-content;
  padding: 3px 7px;
  border: 1px solid #536970;
  border-radius: 3px;
  background: #25353d;
  color: #d5e0e1;
  font: 600 .72rem var(--mono);
  white-space: nowrap;
}
.match-mode.ranked { border-color: #8f7144; color: #f5d598; background: #443726; }
.match-status.cancelled { color: #c2c7c8; border-color: #536067; }
.rating-number { margin: 10px 0 4px; color: #f4dfb8; font: 700 2rem var(--display); }
.rating-number span { color: var(--muted); font: 600 .82rem var(--mono); }
.rating-panel a { margin-top: 8px; }
.campaign-rule { color: #ead6aa; font-size: .87rem; }
.simple-pages { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.leaderboard-page { max-width: 950px; padding-top: 26px; }
.leaderboard-page > p { color: var(--muted); }
.leaderboard-panel { margin-top: 16px; }
.leaderboard-scroll { overflow-x: auto; }
.leaderboard-panel table { width: 100%; border-collapse: collapse; }
.leaderboard-panel th, .leaderboard-panel td { padding: 10px; text-align: left; border-bottom: 1px solid var(--steel); }
.leaderboard-panel thead { color: #f4dfb8; }
.leaderboard-panel td { font-variant-numeric: tabular-nums; }
.ranked-commander { display: flex; align-items: center; gap: 8px; overflow-wrap: anywhere; }
.own-standing { background: #34352d; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.operation-state { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }

.game-shell { padding-top: 15px; }
.game-heading {
  gap: 14px;
  padding: 13px 17px;
  margin-bottom: 12px;
  border: 1px solid var(--steel);
  border-left: 3px solid var(--brass);
  border-radius: 4px;
  background: linear-gradient(90deg, #1a252cf2 20%, #17212ae5 70%, #17212aef),
    url("/art/frontier-coast.png") 50% 53% / cover;
}
.game-heading h1 {
  margin: 5px 0 3px;
  font: 750 clamp(1.35rem, 3vw, 2.25rem)/1.05 var(--display);
  color: #f3efe1;
  overflow-wrap: anywhere;
}
.game-heading p, .turn-badge, .invite, #mapDimensions, #mapLocation, .map-controls output {
  font-family: var(--mono);
}
.turn-badge, .invite { border-radius: 3px; background: #253b37; border-color: #668377; color: #d0ebdf; }
.turn-badge[data-state="ready"] { background: #4a3924; color: #ffd995; border-color: #9d7745; }
.turn-badge[data-state="waiting"], .invite { background: #293740; color: #c4d9e0; border-color: #526974; }
.map-wrap { align-self: start; }
.map-toolbar, .map-footer {
  background: linear-gradient(120deg, #26333ce8, #1a232be8), url("/art/brushed-steel.png") center / 320px;
  border-color: #485762;
}
.map-toolbar { padding: 10px 12px; }
.map-toolbar strong { color: #f4dfb8; font-family: var(--display); }
.map-toolbar span, .map-footer { color: #b4c0c4; }
.map-scroller { border-inline: 2px solid #202d35; box-shadow: inset 0 0 0 1px #0c141a; }
.map-controls button, .map-controls label, .order-buttons button, .roster-controls button {
  background: linear-gradient(#2c3941, #202d34);
  color: #e4e8e2;
  border-color: #586a72;
  border-radius: 3px;
  box-shadow: inset 0 1px #fff1, 0 1px 0 #0d161b;
}
.map-controls button:hover, .order-buttons button:hover:not(:disabled), .roster-controls button[aria-pressed="true"] {
  color: #f7d69e;
  background: #39372f;
  border-color: #ae8753;
}
.game-layout, .game-sidebar { gap: 12px; }
.game-sidebar .panel { padding: 14px; }
.game-sidebar .section-head h2 { margin-bottom: 12px; }
.stat { background: #26343d; border-color: #4b5b62; color: #e0e6e2; border-radius: 3px; }
.unit-row { background: #202d34; border-radius: 3px; color: #e3e9e6; }
.unit-row:hover, .unit-row.active { background: #34443e; border-color: #8aaa96; }
.unit-glyph { border-radius: 3px; background: #45544c; }
.production-list button { background: #26383b; border-color: #56716e; border-radius: 3px; }
.production-list button { display: flex; align-items: center; gap: 6px; }
.production-list button img { width: 23px; height: 23px; flex: 0 0 23px; object-fit: contain; }
.production-list button:hover:not(:disabled) { background: #344d4a; }
.selection-portrait {
  display: grid; place-items: center; float: right;
  width: 52px; height: 52px; margin: 0 0 5px 9px;
  background: radial-gradient(#43584d, #222e30);
  border: 1px solid #677970; border-radius: 3px;
}
.selection-portrait img { width: 43px; height: 43px; object-fit: contain; }
.selection-stats, .production-list { clear: both; }
.log-line { border-color: #3e4b54; }

@media (max-width: 780px) {
  .auth-shell { grid-template-columns: 1fr; padding: 15px 14px 30px; }
  .lobby { padding: 15px 14px 30px; }
  .lobby .command-hero { min-height: 175px; }
  .match-card { gap: 8px; padding-inline: 2px; }
  .match-icon { flex-basis: 34px; height: 34px; }
  .match-status { font-size: .65rem; padding: 5px; }
  .game-shell { padding: 12px; }
  .game-heading { padding: 10px 12px; }
}
@media (prefers-reduced-motion: reduce) {
  .primary, .secondary { transition: none; }
}
@media (max-width: 520px) {
  .topbar { min-height: 62px; height: auto; padding: 8px 10px; gap: 5px; }
  .topright { gap: 4px; flex-wrap: wrap; justify-content: flex-end; }
  .topright .textbutton, .social-nav a { font-size: .76rem; padding: 5px; }
  .topright .commander-avatar { width: 27px; height: 27px; }
  .brand { gap: 5px; font-size: 10px; }
  .brand small { font-size: 9px; }
  .brandmark { width: 26px; height: 26px; }
  .social-grid { grid-template-columns: 1fr; }
  .social-panel { padding: 12px; }
  .social-row { flex-wrap: wrap; }
  .match-turn small { max-width: 11ch; }
  .open-game { grid-template-columns: auto minmax(0, 1fr) auto; gap: 8px; }
  .open-game form { grid-column: 2 / -1; justify-self: end; }
  .leaderboard-panel th, .leaderboard-panel td { padding: 8px 5px; }
}
