/* 星垒前哨 — holographic HUD theme */
:root { --cy: #4be8ff; --cy2: rgba(75, 232, 255, .35); --ink: #d8f6ff; --dim: #86a3c4; --panel: rgba(8, 18, 38, .9); --line: #27507a; }
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #050914; color: var(--ink);
  font: 600 14px/1.4 "SF Pro Display", -apple-system, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  letter-spacing: .03em; user-select: none; }
#bg, #gl, #cv { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
#cv { touch-action: none; }
.hidden { display: none !important; }

/* ---- the column at the top: the readouts (#top), then the banners #notice, #net, #stale, #toast under them, so the
   banners follow the readouts' rows at any width; a hidden banner takes no room. Not a stacking context (absolute, and
   no z-index, transform, opacity, filter, contain or will-change): #toast and #net are drawn above an open dialog by
   their own z-index, #stale and #notice under it. It takes no pointer events itself. An open dialog never makes it
   inert (the maintenance screen, which covers everything, does). Padded by the safe areas at the top and the sides,
   clear of a notch or a rounded corner ---- */
#head { position: absolute; top: 0; left: 0; right: 0; display: flex; flex-direction: column; align-items: center; gap: 8px;
  padding-top: env(safe-area-inset-top); padding-left: env(safe-area-inset-left); padding-right: env(safe-area-inset-right);
  pointer-events: none; }

/* ---- top resource readouts ---- */
#top { align-self: stretch; margin: 8px 8px 0; display: flex; flex-wrap: wrap; gap: 6px; pointer-events: none; }
.chip { background: linear-gradient(135deg, rgba(14, 30, 60, .88), rgba(6, 14, 30, .88)); border: 1px solid var(--cy2); border-left: 3px solid var(--cy);
  border-radius: 3px 10px 3px 10px; padding: 4px 12px 5px; min-width: 88px; box-shadow: 0 0 12px rgba(75, 232, 255, .18), inset 0 0 14px rgba(75, 232, 255, .07); }
.chip b { display: block; font-size: 16px; font-weight: 800; font-variant-numeric: tabular-nums; text-shadow: 0 0 8px currentColor; }
.chip small { color: var(--dim); font-size: 11px; font-weight: 700; }
.chip .bar { height: 3px; background: #0c1830; margin-top: 4px; overflow: hidden; }
.chip .bar i { display: block; height: 100%; box-shadow: 0 0 6px currentColor; }
.c-crystal b { color: #6ff0ff; } .c-crystal .bar i { background: #4be8ff; color: #4be8ff; }
.c-energy b { color: #ffd24a; } .c-energy .bar i { background: #ffd24a; color: #ffd24a; }
.chip.wide { min-width: 124px; }
.stars { letter-spacing: 2px; color: rgba(160, 190, 230, .22); text-shadow: none; }
.stars .on { color: #ffd23c; text-shadow: 0 0 10px #ffb400; }

/* ---- the column at the bottom: the selected building's panel above the button bar, so a bar of several rows never
   covers the panel. It takes no pointer events itself. Padded by the safe areas at the bottom and the sides ---- */
#dock { position: fixed; left: 0; right: 0; bottom: 0; display: flex; flex-direction: column; align-items: center; gap: 20px;
  padding-bottom: env(safe-area-inset-bottom); padding-left: env(safe-area-inset-left); padding-right: env(safe-area-inset-right);
  pointer-events: none; }

/* ---- buttons ---- */
#bottom { align-self: stretch; margin-bottom: 12px; display: flex; justify-content: center; gap: 8px;
  flex-wrap: wrap; padding: 0 8px; pointer-events: none; }
#bottom > * { pointer-events: auto; }
button { font: inherit; font-weight: 800; color: var(--ink); background: linear-gradient(#17345e, #0b1a34); border: 1px solid var(--cy);
  border-radius: 3px 10px 3px 10px; padding: 9px 16px; cursor: pointer; box-shadow: 0 0 10px rgba(75, 232, 255, .3), inset 0 1px 0 rgba(255, 255, 255, .16);
  text-shadow: 0 0 6px rgba(75, 232, 255, .6); transition: transform .05s, filter .1s, box-shadow .1s; }
/* hover styles only where the device hovers: on a touch screen they would stay on the tapped element */
@media (hover: hover) { button:hover { filter: brightness(1.25); box-shadow: 0 0 16px rgba(75, 232, 255, .55), inset 0 1px 0 rgba(255, 255, 255, .2); } }
button:active { transform: translateY(2px); filter: brightness(1.4); }
button:disabled { background: linear-gradient(#1a2233, #121826); color: #5b6b86; border-color: #34425c; box-shadow: none; text-shadow: none;
  cursor: not-allowed; filter: none; transform: none; }
button.primary { background: linear-gradient(#ff8a3c, #d6342c); border-color: #ffc09a; color: #fff; box-shadow: 0 0 16px rgba(255, 110, 60, .6), inset 0 1px 0 rgba(255, 255, 255, .35);
  text-shadow: 0 1px 0 rgba(0, 0, 0, .4); font-size: 16px; padding: 9px 22px; }
@media (hover: hover) { button.primary:hover { box-shadow: 0 0 22px rgba(255, 110, 60, .85), inset 0 1px 0 rgba(255, 255, 255, .35); } }
button.good { background: linear-gradient(#22b07a, #0d6a4a); border-color: #7dffc0; color: #fff; box-shadow: 0 0 12px rgba(80, 255, 170, .4), inset 0 1px 0 rgba(255, 255, 255, .3);
  text-shadow: 0 1px 0 rgba(0, 0, 0, .35); }
@media (hover: hover) { button.good:hover { box-shadow: 0 0 18px rgba(80, 255, 170, .65), inset 0 1px 0 rgba(255, 255, 255, .3); } }
button.sm { padding: 5px 10px; font-size: 13px; }
button.primary:disabled, button.good:disabled { background: linear-gradient(#1a2233, #121826); color: #5b6b86; border-color: #34425c; box-shadow: none; text-shadow: none; }

.ubtn { min-width: 78px; padding: 4px 8px 6px; text-align: center; font-size: 15px; }
.ubtn.sel { background: linear-gradient(#2a78b8, #134a80); border-color: #fff; box-shadow: 0 0 18px rgba(120, 240, 255, .9), inset 0 1px 0 rgba(255, 255, 255, .4); transform: translateY(-4px); }
.ubtn b { display: block; font-size: 12px; }
.ubtn .thumb { width: 44px; height: 44px; display: block; margin: -4px auto -6px; }
.ubtn:disabled .thumb { filter: grayscale(1) opacity(.5); }
.thumb { pointer-events: none; }

/* ---- selected building panel ---- */
/* at most half the window wide, as when it stood alone from the window's middle: its buttons wrap where they did. The
   narrow layout lets it take the window's width */
#panel { max-width: 50%; pointer-events: auto;
  background: linear-gradient(var(--panel), rgba(5, 12, 26, .92)); color: var(--ink); border: 1px solid var(--cy); border-radius: 4px 14px 4px 14px; padding: 8px 14px 12px;
  display: none; text-align: center; box-shadow: 0 0 18px rgba(75, 232, 255, .3), inset 0 0 20px rgba(75, 232, 255, .06); }
#panel.show { display: block; }
#panel h3 { margin: 0 0 2px; font-size: 16px; font-weight: 800; color: #9df3ff; text-shadow: 0 0 8px rgba(75, 232, 255, .6); }
#panel p { margin: 0 0 8px; color: var(--dim); font-size: 12px; }
#panel .row { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }

/* above an open dialog (#modal has no z-index), below the login and maintenance screens (10). As wide as its sentence on
   one line, at most 92% of the screen: a longer sentence wraps onto further lines, centred, and is never cut */
#toast { position: relative; z-index: 9; background: rgba(6, 16, 34, .94);
  border: 1px solid var(--cy); border-radius: 3px 12px 3px 12px; padding: 6px 18px; opacity: 0; transition: opacity .25s; box-shadow: 0 0 14px rgba(75, 232, 255, .4);
  pointer-events: none; width: max-content; max-width: 92%; text-align: center; overflow-wrap: anywhere; }
#toast.show { opacity: 1; }
#net { position: relative; z-index: 6; padding: 5px 14px; border: 1px solid #ff8a3c;
  border-radius: 3px 10px 3px 10px; background: rgba(40, 14, 6, .94); color: #ffd2b0; font-size: 13px; pointer-events: none; white-space: nowrap; }

/* ---- modal ---- */
#modal { position: fixed; inset: 0; background: rgba(2, 6, 16, .7); display: flex; align-items: center;
  justify-content: center; padding: 12px; }
#modal .box { color: var(--ink); border: 1px solid var(--cy); border-radius: 6px 20px 6px 20px; width: 680px; max-width: 100%;
  max-height: 88vh; max-height: 88dvh; overflow: auto; padding: 16px; box-shadow: 0 0 30px rgba(75, 232, 255, .35), inset 0 0 40px rgba(75, 232, 255, .05);
  background: repeating-linear-gradient(0deg, rgba(75, 232, 255, .025) 0 1px, transparent 1px 4px), linear-gradient(rgba(10, 22, 46, .97), rgba(4, 10, 24, .97));
  scrollbar-color: var(--cy) transparent; }
.box h2 { margin: 0 0 4px; font-size: 20px; font-weight: 800; display: flex; justify-content: space-between; align-items: center;
  color: #9df3ff; text-shadow: 0 0 10px rgba(75, 232, 255, .6); letter-spacing: .08em; }
.box .sub { color: var(--dim); margin: 0 0 12px; font-size: 13px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); gap: 10px; }
.card { background: linear-gradient(rgba(22, 42, 78, .75), rgba(10, 22, 44, .75)); border: 1px solid var(--line); border-top: 2px solid var(--cy2);
  border-radius: 3px 10px 3px 10px; padding: 8px 10px 12px; display: flex; flex-direction: column; gap: 4px; }
.card .thumb { width: 96px; height: 96px; margin: -4px auto -2px; filter: drop-shadow(0 0 8px rgba(75, 232, 255, .35)); }
.card h4 { margin: 0; font-size: 14px; font-weight: 800; display: flex; justify-content: space-between; color: #eaffff; }
.card h4 span { color: var(--dim); font-weight: 700; font-size: 12px; }
.card p { margin: 0; color: var(--dim); font-size: 12px; font-weight: 600; flex: 1; }
.card .row { display: flex; gap: 6px; flex-wrap: wrap; }
.card .row button { flex: 1; white-space: nowrap; padding-left: 6px; padding-right: 6px; }
.cost-crystal { color: #6ff0ff; } .cost-energy { color: #ffd24a; }
button.primary .cost-crystal, button.primary .cost-energy, button.good .cost-crystal, button.good .cost-energy { color: #fff; }
.result { text-align: center; }
.result .stars { font-size: 56px; }
.result h2 { justify-content: center; font-size: 26px; }
.result p { margin: 6px 0; font-size: 16px; }
.help li { margin: 5px 0; font-weight: 600; color: #b9d3ee; }
.help li b { color: #9df3ff; }

/* ---- abilities, campaign, quests ---- */
.ubtn i.abil { display: block; width: 34px; height: 34px; border-radius: 50%; margin: 2px auto 2px; border: 2px solid #fff; box-shadow: 0 0 12px currentColor, inset 0 0 8px rgba(255, 255, 255, .6); }
.ubtn:disabled i.abil { filter: grayscale(1) opacity(.5); }
.card.wide { margin-bottom: 4px; }
.card.done { opacity: .5; }
.grid.small { grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); }
.card .stars { font-size: 20px; }
.tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.tabs button.on { background: linear-gradient(#2a78b8, #134a80); border-color: #fff; }
#modal .box.wide { width: 1180px; }
.grid.codex { grid-template-columns: repeat(5, 1fr); }
.grid.codex .card .thumb { width: 100%; height: auto; aspect-ratio: 1; margin: 0; }
.grid.codex .card p b { color: #eaffff; }
.card.t1 { border-top-color: #4f8cff; } .card.t2 { border-top-color: #ffc93c; } .card.t3 { border-top-color: #e0a8ff; box-shadow: 0 0 14px rgba(224, 168, 255, .35); }
@media (max-width: 700px) { .grid.codex { grid-template-columns: repeat(2, 1fr); } }
.pbar { height: 6px; background: #0c1830; overflow: hidden; }
.pbar i { display: block; height: 100%; background: linear-gradient(90deg, #2aa6ff, #4be8ff); box-shadow: 0 0 8px #4be8ff; }

/* ---- login screens ---- */
#login { position: fixed; inset: 0; z-index: 10; display: flex; align-items: center; justify-content: center; padding: 16px;
  background: radial-gradient(circle at 50% 40%, rgba(20, 44, 88, .9), #050914 70%); user-select: text; }
#login .box { color: var(--ink); border: 1px solid var(--cy); border-radius: 6px 20px 6px 20px; width: 380px; max-width: 100%; padding: 20px;
  box-shadow: 0 0 30px rgba(75, 232, 255, .35), inset 0 0 40px rgba(75, 232, 255, .05);
  background: repeating-linear-gradient(0deg, rgba(75, 232, 255, .025) 0 1px, transparent 1px 4px), linear-gradient(rgba(10, 22, 46, .97), rgba(4, 10, 24, .97)); }
#login .box h2 { justify-content: center; }
#login .sub { text-align: center; }
#login .step { display: flex; flex-direction: column; gap: 10px; }
#login input { font: inherit; color: var(--ink); background: rgba(4, 12, 28, .9); border: 1px solid var(--line); border-radius: 3px 10px 3px 10px;
  padding: 9px 12px; outline: none; }
#login input:focus { border-color: var(--cy); box-shadow: 0 0 10px rgba(75, 232, 255, .35); }
#login .dev { margin: 0; color: #ffd24a; font-size: 12px; text-align: center; }
#login .err { min-height: 1.4em; margin: 10px 0 0; color: #ff7a6a; font-size: 13px; text-align: center; }
#login-export { display: block; margin: 6px auto 0; }

/* ---- real-player raids: shield, stakes, inbox ---- */
.c-shield b { color: #9dffcf; }
.stake b { color: #ffd23c; }
#bottom .warn-shield { flex-basis: 100%; text-align: center; color: #ffd2b0; font-size: 13px; text-shadow: 0 0 6px rgba(255, 110, 60, .7); pointer-events: none; }
button .badge { display: inline-block; min-width: 18px; margin-left: 4px; padding: 0 5px; border-radius: 9px; background: #ff4a5a; color: #fff;
  font-size: 12px; line-height: 18px; text-align: center; text-shadow: none; box-shadow: 0 0 8px rgba(255, 74, 90, .8); }
.grid.mails { grid-template-columns: 1fr; }
.card.mail .stars { font-size: 16px; }
.card.mail p.text { white-space: pre-wrap; overflow-wrap: anywhere; } /* an operator's text keeps its line breaks */
/* maintenance: over everything, like the login screen; the notice as plain text, a long one scrolls */
#maint { position: fixed; inset: 0; z-index: 10; display: flex; align-items: center; justify-content: center; padding: 16px;
  background: radial-gradient(circle at 50% 40%, rgba(20, 44, 88, .9), #050914 70%); }
#maint .box { border: 1px solid var(--cy); border-radius: 6px 20px 6px 20px; width: 420px; max-width: 100%; padding: 20px; text-align: center;
  background: linear-gradient(rgba(10, 22, 46, .97), rgba(4, 10, 24, .97)); box-shadow: 0 0 30px rgba(75, 232, 255, .35); }
#maint h2 { justify-content: center; margin: 0 0 10px; }
#maint .sub { margin: 0 0 16px; max-height: 50vh; overflow-y: auto; color: var(--ink); font-size: 15px; line-height: 1.5;
  white-space: pre-wrap; overflow-wrap: anywhere; user-select: text; scrollbar-color: var(--cy) transparent; }
#maint .err { min-height: 1.4em; margin: 10px 0 0; color: #ff7a6a; font-size: 13px; }

/* ---- star gems: the balance, the chips that open a purchase, the confirmations ---- */
.c-gems b { color: #b9a8ff; }
#top .chip[data-act] { pointer-events: auto; cursor: pointer; }
@media (hover: hover) { #top .chip[data-act]:hover { filter: brightness(1.25); } }
#modal .box > .row { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }

/* ---- the new-version banner, the leaderboard ---- */
/* no z-index: in the column at the top, which comes after the canvases and before #modal in the page, so it is drawn
   over the base and an open dialog covers it */
#stale { padding: 6px 16px; border: 1px solid #ffd24a; pointer-events: auto;
  border-radius: 3px 10px 3px 10px; background: rgba(40, 30, 6, .95); color: #ffe9a8; font-size: 14px; cursor: pointer; white-space: nowrap;
  box-shadow: 0 0 14px rgba(255, 210, 74, .5); }
@media (hover: hover) { #stale:hover { filter: brightness(1.2); } }
/* the operator's notice: no z-index and in the column at the top, like #stale, so an open dialog covers it. First under
   the chips, which wrap onto more rows on a narrow screen: the new-version banner showing below it does not move it. A
   long notice wraps; past five lines it scrolls inside the banner. */
#notice { width: max-content; pointer-events: auto;
  max-width: min(560px, calc(100% - 32px)); max-height: calc(5 * 1.45em + 14px); overflow-y: auto; padding: 6px 14px;
  border: 1px solid var(--cy); border-radius: 3px 10px 3px 10px; background: rgba(6, 22, 44, .95); color: var(--ink);
  font-size: 13px; line-height: 1.45; overflow-wrap: anywhere; cursor: pointer; box-shadow: 0 0 14px rgba(75, 232, 255, .4);
  scrollbar-color: var(--cy) transparent; }
@media (hover: hover) { #notice:hover { filter: brightness(1.15); } }
.rank-me { margin: 0 0 10px; font-size: 16px; color: #ffd23c; }
table.rank { width: 100%; border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums; }
table.rank th, table.rank td { padding: 4px 8px; text-align: left; border-bottom: 1px solid var(--line); }
table.rank th { color: var(--dim); font-weight: 700; }
table.rank tr.me td { color: #ffd23c; background: rgba(255, 210, 60, .08); }

/* ---- one markup, two layouts (4.1): the page writes the same HTML at every width, and up to 700 px wide the narrow
   layout below decides what is shown and how. .only-wide is left out of the narrow layout, .only-narrow shown only in
   it; the wrappers of the navigation row and of a battle's unit row and controls row have no box of their own on a
   wide screen ---- */
#bottom .nav, #bottom .units, #bottom .ctl { display: contents; }
/* the guide (4.7): its card, its ring and its pulse are drawn only in the narrow layout; the page writes them at every
   width. Under reduced motion the ring and the pulse stay lit and still */
#guide, #guide-ring { display: none; }
@keyframes guide-pulse { 50% { opacity: .35; scale: 1.08; } }
@media (prefers-reduced-motion: reduce) { #guide-ring, #bottom .nav button.pulse::after { animation: none !important; } }
@media (max-width: 700px) { .only-wide { display: none !important; } }
@media not all and (max-width: 700px) { .only-narrow { display: none !important; } }
@media (max-width: 700px) {
  /* the base's resource row (#top with the status row; the battle screen's chips are not restyled here): the three chips
     side by side, an icon and a number each, the capacity bar along the chip's foot. A chip is never narrower than its
     number: a row too narrow for them wraps, it does not overlap. The numbers' type goes from 14 px down to 12 px near
     320 px wide, where eight-digit resources must still share the row */
  #top:has(> .status) { margin: 4px 4px 0; gap: 2px 4px; }
  #top:has(> .status) .chip { flex: 1 1 auto; min-width: auto; position: relative; display: flex; align-items: baseline; justify-content: center;
    gap: 2px; padding: 2px 4px 5px; white-space: nowrap; letter-spacing: 0; }
  #top:has(> .status) .chip b, #top:has(> .status) .chip small { font-size: clamp(12px, 3.9vw, 14px); line-height: 18px; }
  #top:has(> .status) .chip small { font-size: 11px; }
  #top:has(> .status) .chip .bar { position: absolute; left: 4px; right: 4px; bottom: 1px; margin: 0; }
  /* the status row: trophies, shield, builders, army in small type, an icon and a number each; the shield opens its dialog */
  #top .status { flex: 1 0 100%; display: flex; justify-content: space-around; align-items: stretch; gap: 4px;
    border-radius: 3px 10px 3px 10px; background: rgba(6, 14, 30, .72); color: var(--dim); font-size: 12px; line-height: 16px; }
  #top .status .st { display: flex; align-items: center; gap: 3px; white-space: nowrap; }
  #top .status .st b { color: var(--ink); font-weight: 800; font-variant-numeric: tabular-nums; }
  #top .status button.st { padding: 0 8px; font: inherit; color: inherit; background: none; border: 0; border-radius: 0; box-shadow: none;
    text-shadow: none; pointer-events: auto; cursor: pointer; }
  #top .status button.st b { color: #9dffcf; }
  /* the navigation row: five items, the icon over the label, 出击 in the middle in the primary colours, the badges at a
     corner; at the foot of the screen, its background reaching down through the safe area */
  #bottom:has(> .nav) { margin-bottom: 0; padding: 0; }
  #bottom .nav { flex: 1 1 auto; display: flex; gap: 4px; height: calc(60px + env(safe-area-inset-bottom, 0px));
    margin-bottom: calc(-1 * env(safe-area-inset-bottom, 0px)); padding: 4px 6px calc(4px + env(safe-area-inset-bottom, 0px));
    background: linear-gradient(rgba(8, 18, 38, .94), rgba(4, 10, 24, .97)); border-top: 1px solid var(--cy2); }
  #bottom .nav button { flex: 1 1 0; position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 2px; padding: 2px; font-size: 12px; line-height: 14px; white-space: nowrap; }
  #bottom .nav button:not(.primary) { background: none; border-color: transparent; box-shadow: none; }
  #bottom .nav .ic { font-size: 20px; line-height: 22px; }
  #bottom .nav .badge { position: absolute; top: 2px; left: 50%; margin-left: 8px; }
  /* the selected building's panel: its name, level and one statistic on the first line, its buttons on the second */
  #dock { gap: 8px; }
  #panel { max-width: calc(100% - 16px); }
  #panel.show { display: flex; flex-wrap: wrap; justify-content: center; align-items: baseline; gap: 0 8px; padding: 6px 10px 8px; }
  #panel h3 { margin: 0; font-size: 15px; }
  #panel p { margin: 0; }
  #panel .row { flex: 1 0 100%; margin-top: 6px; gap: 6px; }
  /* the guide (4.7): a card in the column at the bottom, above the panel and the navigation row, so it covers no control:
     the hint and 跳过引导 of 44 px at any pointer. The ring on the ground round a collector and the rim of the row's item
     pulse, and take no tap */
  #guide:not(:empty) { display: flex; align-items: center; gap: 8px; max-width: calc(100% - 16px); padding: 4px 4px 4px 12px; pointer-events: auto;
    background: linear-gradient(var(--panel), rgba(5, 12, 26, .92)); border: 1px solid var(--cy); border-radius: 4px 14px 4px 14px;
    box-shadow: 0 0 14px rgba(75, 232, 255, .35); }
  #guide p { margin: 0; color: #bff6ff; font-size: 13px; line-height: 18px; text-shadow: 0 0 6px rgba(75, 232, 255, .6); }
  #guide button { flex: 0 0 auto; min-width: 44px; min-height: 44px; }
  #guide-ring.on { display: block; position: fixed; border: 2px solid #9df3ff; border-radius: 50%; pointer-events: none;
    box-shadow: 0 0 12px rgba(75, 232, 255, .9), inset 0 0 12px rgba(75, 232, 255, .6); animation: guide-pulse 1.2s ease-in-out infinite; }
  #bottom .nav button.pulse::after { content: ''; position: absolute; inset: 1px; border: 2px solid #9df3ff; border-radius: inherit; pointer-events: none;
    box-shadow: 0 0 10px rgba(75, 232, 255, .9); animation: guide-pulse 1.2s ease-in-out infinite; }
  /* placing (4.4): what to do, on a row of its own above the two buttons */
  #bottom .hint { flex-basis: 100%; text-align: center; color: #bff6ff; font-size: 13px; text-shadow: 0 0 6px rgba(75, 232, 255, .7); pointer-events: none; }
  /* a reason (an upgrade refused) drawn as a line of text, not as a grey button: no target, so not raised to the touch
     floor of 44 px either */
  button.plain:disabled { background: none; border: 0; box-shadow: none; color: #ffb38a; padding-left: 4px; padding-right: 4px; cursor: default; min-width: 0; min-height: 0; }
  /* the tiles of 更多: two columns, the icon over the label, at least 64 px high */
  .grid.more { grid-template-columns: repeat(2, 1fr); }
  .grid.more button { min-height: 64px; position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; }
  .grid.more .ic { font-size: 22px; line-height: 26px; }
  .grid.more .badge { position: absolute; top: 6px; right: 8px; margin: 0; }
  /* the list dialogs as sheets (4.5): flush with the bottom and both sides, at most 85 % of the dynamic viewport's height,
     the two top corners round, the safe areas inside the box's padding. The box stays the scroller (a redraw keeps its
     scroll), and a list scrolled to its end does not drag the page behind. The title, the box's first h2, stays at the
     top with the close button of 44 px at any pointer; a later h2 (the raid sheet's 战役) scrolls with the rest. A drag
     down on the title closes the sheet: touch-action none, or the browser takes the gesture and cancels the pointer (the
     script starts that drag only on a title that has it). The short bar on the title says it can be pulled */
  #modal.sheet { align-items: flex-end; padding: 0; }
  #modal.sheet .box { --pl: calc(12px + env(safe-area-inset-left, 0px)); --pr: calc(12px + env(safe-area-inset-right, 0px));
    width: 100%; max-width: 100%; max-height: 85vh; max-height: 85dvh; border-bottom: 0; border-radius: 18px 18px 0 0;
    padding: 0 var(--pr) calc(12px + env(safe-area-inset-bottom, 0px)) var(--pl); overscroll-behavior: contain; }
  #modal.sheet .box > h2:first-of-type { position: sticky; top: 0; z-index: 1; margin: 0 calc(-1 * var(--pr)) 8px calc(-1 * var(--pl));
    padding: 12px var(--pr) 6px var(--pl); background: linear-gradient(rgb(16, 34, 66), rgb(10, 22, 46)); border-bottom: 1px solid var(--cy2);
    touch-action: none; }
  #modal.sheet .box > h2:first-of-type::before { content: ''; position: absolute; top: 5px; left: 50%; width: 36px; height: 4px; margin-left: -18px;
    border-radius: 2px; background: var(--cy2); }
  #modal.sheet .box > h2:first-of-type [data-act=close] { min-width: 44px; min-height: 44px; }
  /* the contents of the inbox, leaderboard, codex and help sheets at 320 px: the table's cells and the help list wrap
     their text rather than pass the box's sides */
  #modal.sheet table.rank th, #modal.sheet table.rank td { padding: 4px 6px; overflow-wrap: anywhere; }
  #modal.sheet .help { padding-left: 20px; }
  /* the build, army and quest lists as compact rows (4.5), one to a line; a refused build and a locked unit dimmed */
  .grid.shop, .grid.army, .grid.quests { grid-template-columns: 1fr; gap: 4px; }
  .grid.shop .card, .grid.army .card, .grid.quests .card { display: grid; align-items: center; gap: 2px 8px; padding: 4px 8px; }
  .grid.shop h4, .grid.army h4, .grid.quests h4 { grid-area: h4; align-self: end; }
  .grid.shop p, .grid.army p, .grid.quests p { grid-area: p; align-self: start; }
  .grid.shop .row, .grid.army .row, .grid.quests .row { grid-area: row; }
  .grid.shop .row button, .grid.quests .row button { max-width: 96px; white-space: normal; }
  /* a row that cannot be built or trained is dimmed but for its reason, which is what the row is there to say */
  .card.off .thumb, .card.off h4, .card.off p { opacity: .6; }
  /* the build list: the thumbnail of 56 px at the left; the name, the count and the limit, and the description in the
     middle; the price at the right, or the reason a build is refused */
  .grid.shop .card { grid-template-columns: 56px minmax(0, 1fr) auto; grid-template-areas: "th h4 row" "th p row"; }
  .grid.shop .thumb { grid-area: th; width: 56px; height: 56px; margin: 0; }
  .grid.shop .row button span { white-space: nowrap; } /* the price wraps between its parts, never inside one */
  /* the army list: an unlocked unit in two rows, the thumbnail, name, count and statistics, then −1, +1 with its price and
     +5 in three equal columns, the first empty while none is owned; a locked unit in one row, its condition at the right */
  .grid.army .card { grid-template-columns: 40px minmax(0, 1fr); grid-template-areas: "th h4" "th p" "row row"; padding-bottom: 6px; }
  .grid.army .thumb { grid-area: th; width: 40px; height: 40px; margin: 0; }
  .grid.army .row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; margin-top: 2px; }
  .grid.army .row .dec { grid-area: 1 / 1; }
  .grid.army .row .inc { grid-area: 1 / 2; }
  .grid.army .row .inc5 { grid-area: 1 / 3; }
  .grid.army .card.off { grid-template-columns: 40px minmax(0, 1fr) auto; grid-template-areas: "th h4 row"; padding-bottom: 4px; }
  .grid.army .card.off h4 { align-self: center; }
  .grid.army .card.off p { display: none; }
  .grid.army .card.off .row { display: block; margin: 0; }
  /* the army list's summary stays under the title while the list scrolls: the title is 63 px high (12 px, the close
     button's 44, 6 px and its 1 px border), and the summary starts where the title ends */
  #modal.sheet .box > .pin { position: sticky; top: 63px; z-index: 1; margin: -8px calc(-1 * var(--pr)) 6px calc(-1 * var(--pl));
    padding: 4px var(--pr) 6px var(--pl); background: rgb(10, 22, 46); }
  /* the quest list: the name and its numbers, the description and the bar; at the right the claim button, or the reward
     as text */
  .grid.quests .card { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "h4 row" "p row" "bar row"; padding: 6px 8px; }
  .grid.quests .pbar { grid-area: bar; }
  .grid.quests button.plain:disabled { color: var(--dim); }
  /* the raid list's campaign: three stages to a row, each its number, its stars and its button */
  .grid.small { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
  .grid.small .card { padding: 4px 6px 6px; }
  .grid.small .card h4 { flex-wrap: wrap; gap: 0 4px; }
  .grid.small .card .row button { white-space: normal; }
  /* the battle screen (4.6), a replay's and a drill's too. The readouts: one bar of at most 60 px, the chips filling
     rows of one line each, a label and its number; a word the bar has no room for is .only-wide, with an icon or nothing
     in .only-narrow. The numbers' type goes from 13 px down to 11 px near 369 px wide. Who is fought and the stake come
     first, the destruction and the two loots after them: the widest of each of the two rows (a 12-character name with
     the time left and the stake; the loots at the rules' cap) fits one row at 369 px, so the bar is two rows there */
  #top:not(:has(> .status)) { margin: 4px 4px 0; gap: 3px 2px; }
  #top:not(:has(> .status)) .chip { order: 1; flex: 1 1 auto; min-width: auto; display: flex; align-items: baseline; justify-content: center; gap: 2px;
    padding: 2px; white-space: nowrap; letter-spacing: 0; }
  #top:not(:has(> .status)) .chip:first-child, #top:not(:has(> .status)) .chip.stake { order: 0; }
  #top:not(:has(> .status)) .chip b { font-size: clamp(11px, 3vw, 13px); line-height: 16px; }
  #top:not(:has(> .status)) .chip small { line-height: 16px; }
  #top:not(:has(> .status)) .stars { letter-spacing: 1px; }
  /* the unit and ability buttons at their size in one row that never wraps and scrolls sideways, as wide as its buttons
     up to the screen's width (a short row leaves the map beside it to the map), with room above for the chosen one's
     lift; the other controls a centred row under it, where only the buttons take a tap */
  #bottom:has(> .ctl) { flex-direction: column; flex-wrap: nowrap; gap: 6px; margin-bottom: 8px; padding: 0; }
  #bottom .units { align-self: center; max-width: 100%; display: flex; gap: 6px; padding: 6px 8px 4px; overflow-x: auto; overflow-y: hidden;
    overscroll-behavior-x: contain; scrollbar-width: thin; scrollbar-color: var(--cy) transparent; }
  #bottom .units:empty { display: none; }
  #bottom .units > .ubtn { flex: 0 0 auto; }
  /* the controls: one row of their own (the shield warning on a line above them); tight enough that the three of a
     search (the countdown, another opponent, back to base) share it down to about 320 px, and they wrap rather than
     leave the screen if they cannot */
  #bottom .ctl { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px; padding: 0 4px; pointer-events: none; }
  #bottom .ctl > button { pointer-events: auto; padding-left: 8px; padding-right: 8px; letter-spacing: 0; }
}

/* ---- touch screens (4.8): every button and everything with data-act at least 44 by 44, whatever the width. A floor of
   no specificity: a larger minimum of the element's own (a unit button's 78 px, a chip's 88) stays ---- */
@media (pointer: coarse) { :where(button, [data-act]) { min-width: 44px; min-height: 44px; } }
/* the two banners a tap acts on (the new-version banner reloads the page, the notice is put away) are no buttons: on a
   touch screen they are 44 px high as well, a line of text centred in them (44 less the border and one line, halved).
   A notice of two lines is taller already; it is still capped at five lines, with that padding */
@media (pointer: coarse) {
  #stale, #notice { min-height: 44px; }
  #stale { padding-block: calc((44px - 2px - 1.4em) / 2); }
  #notice { padding-block: calc((44px - 2px - 1.45em) / 2); max-height: calc(4 * 1.45em + 44px); }
}
