:root {
  --bg: #f6f5f1; --surface: #ffffff; --surface-2: #efede6; --text: #1f2421; --muted: #5f665f;
  --line: #d9d6cc; --accent: #2f5d50; --accent-text: #ffffff; --danger: #a33a2c; --warn-bg: #fff3d6;
  --infantry: #4a6fa5; --team_weapons: #8a6d3b; --vehicles: #5b7a3a; --building: #6b5b8a; --upgrade: #2f7f86; --choice: #a35a2c; --note: #5d6670;
  --fork: #343a40;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161917; --surface: #1f2421; --surface-2: #2a302c; --text: #e8eae6; --muted: #a3aaa3;
    --line: #3a423d; --accent: #7fb8a4; --accent-text: #10201a; --danger: #e07a6a; --warn-bg: #3d3420;
    --fork: #4b535b;
  }
}
* { box-sizing: border-box; }
body { margin: 0; font: 15px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif; background: var(--bg); color: var(--text); }
a { color: var(--accent); }
button, select, input, textarea { font: inherit; color: inherit; }
.top { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 20px; background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 2; }
.brand { font-weight: 700; font-size: 18px; text-decoration: none; color: var(--text); }
.top nav { display: flex; gap: 14px; align-items: center; }
.primary-link { background: var(--accent); color: var(--accent-text); padding: 6px 12px; border-radius: 6px; text-decoration: none; }
main { max-width: 1180px; margin: 0 auto; padding: 20px; }
.foot { max-width: 1180px; margin: 0 auto; padding: 8px 20px 24px; color: var(--muted); font-size: 12px; }
.muted { color: var(--muted); }
.error { color: var(--danger); }
.notice { background: var(--warn-bg); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; margin-bottom: 14px; }
h1 { font-size: 24px; margin: 0 0 4px; }
h2 { font-size: 17px; margin: 18px 0 8px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }

.btn { text-decoration: none; display: inline-block; border: 1px solid var(--line); background: var(--surface); padding: 6px 12px; border-radius: 6px; cursor: pointer; }
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.btn.danger { color: var(--danger); }
.btn.big { padding: 10px 20px; font-size: 17px; font-weight: 600; }
.btn:disabled { opacity: .5; cursor: default; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { border: 1px solid var(--line); background: var(--surface); padding: 4px 12px; border-radius: 999px; cursor: pointer; }
.chip.on { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
select, input[type=text], input[type=number], input[type=email], textarea { background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; }
label.field { display: flex; flex-direction: column; gap: 3px; font-size: 13px; color: var(--muted); }
label.field > * { color: var(--text); font-size: 15px; }

.filters { display: flex; flex-direction: column; gap: 12px; margin: 12px 0 18px; }
.filter-main, .filter-rest { display: flex; gap: 18px; flex-wrap: wrap; align-items: flex-end; }
.filter-main { padding-bottom: 12px; border-bottom: 1px solid var(--line); }
/* The mode is the filter that matters most: bigger chips. */
.filters .mode-filter { font-weight: 650; }
.filters .mode-filter .chip { font-size: 16px; padding: 6px 16px; }
.search-field { flex: 1 1 240px; }
input.search { background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 7px 10px; width: 100%; }
.tag.map { border-style: dashed; }

/* The header's voice check: a small panel under its button. */
.voice-check { position: relative; }
.voice-btn { border: 1px solid var(--line); background: var(--surface); border-radius: 6px; padding: 5px 10px; cursor: pointer; white-space: nowrap; }
.voice-btn:hover, .voice-btn[aria-expanded="true"] { background: var(--surface-2); }
.voice-panel { position: absolute; right: 0; top: calc(100% + 8px); width: min(320px, calc(100vw - 24px)); background: var(--surface);
  border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 8px 24px rgb(0 0 0 / 18%); padding: 12px; display: flex;
  flex-direction: column; gap: 10px; z-index: 5; }
.voice-panel-head { display: flex; align-items: center; justify-content: space-between; }
.voice-panel input[type=range] { width: 100%; accent-color: var(--accent); }
.volume-value { font-variant-numeric: tabular-nums; }
@media (max-width: 560px) { .voice-btn .label { display: none; } .top nav { gap: 10px; } }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 12px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; text-decoration: none; color: var(--text); display: flex; flex-direction: column; gap: 6px; }
.card:hover { border-color: var(--accent); }
/* The title's link covers the card; links and tooltips inside it sit above that cover. */
.card { position: relative; }
.card-link { color: inherit; text-decoration: none; }
.card-link::after { content: ""; position: absolute; inset: 0; border-radius: 10px; }
.card-link:focus-visible { outline: none; }
.card:focus-within { outline: 2px solid var(--accent); outline-offset: 1px; }
.card .meta a, .card .tag[title], .card .badge-base, .card .uses { position: relative; z-index: 1; }
.meta .source { font-style: italic; }
.card .title { font-weight: 650; }
.meta { color: var(--muted); font-size: 13px; }
.badge-base { font-size: 11px; font-weight: 650; background: var(--surface-2); border: 1px solid var(--accent); border-radius: 4px; padding: 0 6px; margin-left: 6px; color: var(--accent); cursor: help; vertical-align: middle; }
.strip { display: flex; gap: 4px; flex-wrap: wrap; }

.icon { width: 40px; height: 40px; border-radius: 6px; flex: none; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px; color: #fff; overflow: hidden; background: var(--muted); }
.icon.small { width: 30px; height: 30px; font-size: 11px; }
.icon img { width: 100%; height: 100%; object-fit: cover; background: #2b2f2c; }
.icon.infantry { background: var(--infantry); } .icon.team_weapons { background: var(--team_weapons); } .icon.vehicles { background: var(--vehicles); }
.icon.building { background: var(--building); } .icon.upgrade { background: var(--upgrade); }
/* A choice ("if you see X, do Y") is an "if" in a neutral dark color, never the warning-like orange. */
.icon.choice { background: var(--fork); font-size: 15px; font-style: italic; letter-spacing: .02em; }
.icon.choice.small { font-size: 13px; }

.build-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 20px; align-items: start; }
@media (max-width: 860px) { .build-layout { grid-template-columns: 1fr; } .player { order: -1; } }
.steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.step { display: flex; align-items: center; gap: 10px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; }
.step .time { font-variant-numeric: tabular-nums; font-weight: 650; width: 46px; }
.step.done { opacity: .45; }
.step.next { border-color: var(--accent); box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 35%, transparent); }
.player { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 14px; position: sticky; top: 70px; display: flex; flex-direction: column; gap: 10px; }
.clock { font-size: 48px; font-weight: 700; font-variant-numeric: tabular-nums; text-align: center; line-height: 1; }
.next-line { text-align: center; min-height: 2.6em; }
.delay { font-size: 12px; color: var(--muted); text-align: center; }

.editor { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; align-items: start; }
@media (max-width: 900px) { .editor { grid-template-columns: 1fr; } }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.form-grid .wide { grid-column: 1 / -1; }
.edit-step { display: grid; grid-template-columns: 64px 34px minmax(0, 1fr) 56px 30px; gap: 8px; align-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 4px 8px; }
.edit-step.invalid { border-color: var(--danger); }
.edit-step input.time { width: 64px; text-align: center; font-variant-numeric: tabular-nums; }
.edit-step input.qty { width: 56px; }
/* Late-game loop: the steps that repeat get a left bar and a mark. */
.step.in-loop, .edit-step.in-loop { border-left: 4px solid var(--accent); }
.loop-mark { margin-left: auto; color: var(--accent); font-weight: 700; }
.loop-note { color: var(--muted); font-size: 13px; margin-top: 8px; }
.loop-box { margin: 12px 0; padding: 10px 12px; background: var(--surface); border: 1px dashed var(--line); border-radius: 8px; display: flex; flex-direction: column; gap: 8px; }
.loop-box label.check { display: flex; align-items: center; gap: 6px; font-weight: 600; }
.player label.check { display: flex; align-items: center; gap: 6px; font-size: 14px; }
.loop-box input.time { width: 64px; text-align: center; font-variant-numeric: tabular-nums; }
.loop-box p { margin: 0; font-size: 13px; }
.x { border: none; background: none; cursor: pointer; color: var(--muted); font-size: 18px; }
.palette { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px; position: sticky; top: 70px; max-height: calc(100vh - 90px); overflow: auto; }
.tabs { display: flex; gap: 6px; margin-bottom: 10px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px; }
.tile { display: flex; align-items: center; gap: 8px; text-align: left; border: 1px solid var(--line); background: var(--bg); border-radius: 8px; padding: 5px; cursor: pointer; }
.tile:hover { border-color: var(--accent); }
.tile .name { font-size: 13px; line-height: 1.2; }
.tile .cost { font-size: 11px; color: var(--muted); }
.icon.pic { position: relative; background: #2b2f2c; }
.icon.pic.building::after, .icon.pic.upgrade::after { position: absolute; right: 0; bottom: 0; width: 13px; height: 13px; border-top-left-radius: 4px; font-size: 9px; line-height: 13px; text-align: center; color: #fff; }
.icon.pic.building::after { content: "⌂"; background: var(--building); }
.icon.pic.upgrade::after { content: "▲"; background: var(--upgrade); }
/* One column: the panel goes above the steps and scrolls with them instead of covering them. */
@media (max-width: 860px) { .player { position: static; } }
/* Likes: the most liked builds of a list stand out. */
.card-head { display: flex; align-items: flex-start; gap: 8px; }
.card-head .title { flex: 1; }
.likes { font-size: 13px; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.likes.some { color: var(--danger); font-weight: 600; }
.badge-top { font-size: 11px; font-weight: 700; white-space: nowrap; background: var(--accent); color: var(--accent-text); border-radius: 4px; padding: 1px 6px; }
.card.most-liked { border: 2px solid var(--accent); background: color-mix(in srgb, var(--accent) 7%, var(--surface)); }
.btn.like.on { color: var(--danger); border-color: var(--danger); font-weight: 600; }
/* Text steps and choices in the editor. */
.icon.note { background: var(--note); font-size: 16px; }
.icon.note.small { font-size: 14px; }
.note-text { flex: 1; min-width: 0; width: 100%; }
.choice-box { grid-column: 1 / -1; display: flex; flex-direction: column; gap: 6px; padding: 6px 0 4px 42px; }
.option-row { display: grid; grid-template-columns: 100px minmax(0, 1fr) minmax(0, 1.3fr) 64px 30px; gap: 6px; align-items: center; padding: 4px; border-radius: 6px; border: 1px dashed var(--line); }
.option-row.invalid { border: 1px solid var(--danger); }
.option-row select { min-width: 0; width: 100%; }
.btn.small { padding: 3px 10px; font-size: 13px; align-self: flex-start; }
@media (max-width: 700px) { .option-row { grid-template-columns: 1fr 1fr; } .choice-box { padding-left: 0; } }
/* An option that answers with text: the text gets a line of its own under the selects. */
.note-inputs { display: flex; flex-direction: column; gap: 4px; flex: 1; min-width: 0; }
.note-text.pt { font-size: 13px; }
.option-row .note-inputs { grid-column: 1 / -2; }
@media (max-width: 700px) { .option-row .note-inputs { grid-column: 1 / -1; } }
p.muted.small { font-size: 12px; margin: 2px 0 0; }

/* The alarm on a phone: advice shown on computers. */
.phone-tip { border: 1px dashed var(--accent); border-radius: 8px; padding: 8px 12px; margin: 12px 0 0; font-size: 13px; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; }
.phone-tip p { margin: 0; color: var(--muted); flex: 1 1 380px; }
.phone-tip .row { flex: 1 1 320px; }
.phone-tip input { flex: 1; min-width: 0; font-size: 12px; }

/* Accounts: login/sign-up forms, profile pages and the menu. */
.account-nav { display: flex; gap: 12px; align-items: center; }
.me-link { font-weight: 600; }
input[type=password] { background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; }
form.account-form { display: flex; flex-direction: column; gap: 12px; max-width: 460px; margin-top: 12px; }
form.account-form p { margin: 0; }
label.field .hint { font-size: 12px; color: var(--muted); }
label.field .as { font-weight: 600; padding: 6px 0; }
.profile-head { margin-bottom: 10px; }
.email-state { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; overflow-wrap: anywhere; }
.email-state .ok { color: var(--accent); font-weight: 600; }
.email-state .pending { color: var(--danger); }
.settings { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 24px; margin-top: 18px; }
.btn.save.on { color: var(--accent); border-color: var(--accent); font-weight: 600; }

/* Import from a replay */
label.field.file input { padding: 8px 0; }
.import-results { display: flex; flex-direction: column; gap: 12px; margin-top: 12px; }
.import-player { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; display: flex; flex-direction: column; gap: 8px; }
.import-player .title { font-weight: 650; }
.timeline { list-style: none; margin: 8px 0 0; padding: 0; max-height: 360px; overflow: auto; font-size: 13px; }
.timeline .ev { display: grid; grid-template-columns: 52px 92px minmax(0, 1fr); gap: 8px; padding: 2px 0; border-bottom: 1px solid var(--line); }
.timeline .time { font-variant-numeric: tabular-nums; font-weight: 600; }
.timeline .kind { color: var(--muted); }
.timeline .ev.unit .kind { color: var(--infantry); } .timeline .ev.building .kind { color: var(--building); }
.timeline .ev.upgrade .kind { color: var(--upgrade); } .timeline .ev.unlock .kind, .timeline .ev.battlegroup .kind { color: var(--choice); }

/* Footer and contact form */
.foot p { margin: 0 0 4px; }
.foot .made { font-size: 13px; }
form.contact { display: flex; flex-direction: column; gap: 12px; max-width: 620px; margin-top: 12px; }
form.contact textarea { resize: vertical; }
form.contact .actions { display: flex; gap: 8px; }
form.contact .small { font-size: 13px; margin: 0; }
/* The bot trap: out of sight, out of the tab order. */
label.trap { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }

/* Tags: what a build is for (mode, faction, battlegroup, opponent...), so its title only names the strategy. */
.tags { display: flex; gap: 4px; flex-wrap: wrap; }
.tag { font-size: 12px; line-height: 18px; border: 1px solid var(--line); border-radius: 999px; padding: 0 8px; background: var(--surface-2); color: var(--text); white-space: nowrap; }
.tag.mode { background: var(--accent); color: var(--accent-text); border-color: var(--accent); font-weight: 650; }
.tag.any { background: transparent; color: var(--muted); }
.tag.patch { font-variant-numeric: tabular-nums; }
/* Steps the current game data does not know (a patch renamed the unit...). */
.incomplete { font-size: 13px; color: var(--danger); font-weight: 600; }
h2 + .incomplete { margin: -4px 0 8px; }
.card .incomplete { position: relative; z-index: 1; cursor: help; align-self: flex-start; }
.icon.unknown { outline: 2px dashed var(--danger); outline-offset: -2px; }
.step.unknown { border-color: var(--danger); border-style: dashed; }
.unknown-mark { color: var(--danger); font-weight: 700; cursor: help; }
.tag.outdated { background: var(--warn-bg); color: var(--text); border-color: color-mix(in srgb, var(--danger) 45%, var(--line)); cursor: help; }
h1 + .tags { margin: 4px 0 6px; }

