:root {
  --ink: #1d1a17;
  --paper: #fffaf2;
  --line: #e4dccd;
  --muted: #7a7166;
  --you: #ff7a1a;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; font-family: 'Rubik', system-ui, sans-serif; color: var(--ink); background: #dfe6e9; overflow: hidden; }
[hidden] { display: none !important; }
#map { position: fixed; inset: 0; }
#fx { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; }
#share { display: flex; width: min(420px, 70vw); height: 16px; border-radius: 8px; overflow: hidden; background: rgba(255, 250, 242, 0.9); box-shadow: 0 3px 12px rgba(0, 0, 0, 0.2); position: relative; }
#share i { display: block; height: 100%; transition: width 0.4s; }
#share::after { content: ''; position: absolute; left: var(--goal, 50%); top: 0; bottom: 0; width: 2px; background: #1d1a17; }
button { font: inherit; cursor: pointer; border: 2px solid var(--line); background: #fff; color: var(--ink); border-radius: 10px; padding: 6px 12px; }
button:hover { border-color: var(--you); }
small { color: var(--muted); }

.panel { position: fixed; left: 16px; top: 16px; width: min(380px, calc(100vw - 32px)); max-height: calc(100vh - 32px); overflow: auto;
  background: var(--paper); border-radius: 16px; padding: 18px; box-shadow: 0 10px 40px rgba(0, 0, 0, 0.25); }
.panel h1 { margin: 0; font-weight: 800; font-size: 30px; letter-spacing: -0.5px; }
.sub { margin: 4px 0 12px; color: var(--muted); }
.row { display: flex; gap: 6px; margin: 8px 0; align-items: center; }
.srch { position: relative; flex: 1; min-width: 0; display: flex; }
#sugg { position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 30; background: #fff; border: 2px solid var(--line); border-radius: 10px; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18); max-height: 300px; overflow-y: auto; }
#sugg .sg { padding: 6px 10px; cursor: pointer; display: flex; align-items: center; gap: 8px; line-height: 1.25; }
#sugg .sg div { min-width: 0; }
#sugg .sg b { display: block; font-weight: 600; font-size: 14px; }
#sugg .sg span { display: block; font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#sugg .sg .pi { flex: none; width: 17px; height: 17px; margin: 0; opacity: 0.65; }
#sugg .sg.on, #sugg .sg:hover { background: #fff3d6; }
#placeLabel { flex: 1; min-width: 0; }
button.mini { flex: none; font-size: 12.5px; padding: 3px 9px; border-radius: 12px; border-width: 1.5px; }
button.mini.ok { border-color: #3a9d5d; color: #2a7a46; }
input[type=text] { flex: 1; min-width: 0; font: inherit; padding: 7px 10px; border: 2px solid var(--line); border-radius: 10px; background: #fff; }
.seg button { flex: 1; padding: 6px 4px; font-weight: 600; font-size: 14px; }
.seg button small { display: block; font-weight: 400; }
.seg button.on { border-color: var(--you); background: #fff1e4; }
.hint { color: var(--muted); font-size: 14px; margin: 8px 0 0; }
.big { width: 100%; background: var(--you); border-color: #d95f00; color: #fff; font-weight: 800; font-size: 20px; padding: 12px; border-radius: 14px; }
.big:hover { border-color: #b34e00; }
.big:disabled { opacity: 0.6; cursor: wait; }
#progress { font: inherit; font-size: 14px; color: #b34e00; white-space: pre-wrap; margin: 8px 0 0; min-height: 1em; }

/* HUD */
#top { position: fixed; top: 10px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 6px; max-width: calc(100vw - 140px); pointer-events: none; }
#stock, #tribes { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; }
.chip { background: var(--paper); border-radius: 12px; padding: 3px 10px; display: flex; align-items: baseline; gap: 6px; box-shadow: 0 3px 12px rgba(0, 0, 0, 0.2); font-weight: 600; font-size: 14px; white-space: nowrap; border-left: 8px solid var(--line); }
.chip b { font-size: 18px; font-weight: 800; }
.chip.dead { opacity: 0.45; text-decoration: line-through; }
.chip small { font-weight: 400; }
#tribes .chip { font-size: 13px; padding: 2px 8px; }
#quitBtn { position: fixed; top: 10px; right: 10px; font-size: 14px; }
#tip { position: fixed; bottom: 108px; left: 50%; transform: translateX(-50%); background: rgba(29, 26, 23, 0.85); color: #fff; padding: 6px 14px; border-radius: 20px; font-size: 15px; pointer-events: none; text-align: center; max-width: 92vw; }
#tip:empty { display: none; }
#bottom { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); display: flex; align-items: stretch; gap: 8px; width: max-content; max-width: calc(100vw - 20px); } /* max-content: from left 50% the bar would otherwise get only half the screen and wrap */
#build { display: flex; gap: 6px; }
#build button, #resBtn { background: var(--paper); border: 2px solid var(--line); border-radius: 14px; padding: 6px 12px; box-shadow: 0 3px 12px rgba(0, 0, 0, 0.2); text-align: center; min-width: 86px; }
#build button b { display: block; font-size: 16px; font-weight: 800; white-space: nowrap; }
#build button small { display: block; font-size: 12px; }
#build button.on { border-color: var(--you); background: #fff1e4; }
#build button.poor { opacity: 0.55; }
#resBtn { min-width: 0; font-weight: 600; font-size: 14px; }
#resBtn.on { border-color: var(--you); background: #fff1e4; }
#toasts { position: fixed; left: 12px; bottom: 150px; display: flex; flex-direction: column; gap: 4px; pointer-events: none; }
.toast { background: var(--paper); border-left: 6px solid; border-radius: 8px; padding: 3px 10px; font-size: 14px; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2); animation: fade 5s forwards; }
@keyframes fade { 0%, 80% { opacity: 1; } 100% { opacity: 0; } }

/* map markers */
.tgt { width: 26px; height: 26px; border: 4px solid var(--you); border-radius: 50%; background: rgba(255, 122, 26, 0.25); animation: pulse 0.9s infinite alternate; pointer-events: none; }
@keyframes pulse { from { transform: scale(0.7); } to { transform: scale(1.15); } }

#modal { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.45); display: flex; align-items: center; justify-content: center; padding: 16px; }
#modal .box { background: var(--paper); border-radius: 18px; padding: 22px; width: min(360px, 100%); text-align: center; display: flex; flex-direction: column; gap: 8px; }
#modal h2 { margin: 0; font-size: 34px; font-weight: 800; }
#modal p { margin: 0 0 6px; color: var(--muted); }

#choice { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.45); display: flex; align-items: center; justify-content: center; padding: 16px; }
#choice .box { background: var(--paper); border-radius: 18px; padding: 20px; width: min(560px, 100%); text-align: center; }
#choice h2 { margin: 0 0 4px; font-size: 26px; font-weight: 800; }
#choice p { margin: 0 0 12px; color: var(--muted); font-size: 14px; }
#choiceOpts { display: flex; gap: 8px; flex-wrap: wrap; }
#choiceOpts button { flex: 1 1 150px; padding: 12px 10px; border-radius: 14px; border: 2px solid var(--line); background: #fff; }
#choiceOpts button:hover { border-color: var(--you); background: #fff1e4; }
#choiceOpts b { display: block; font-size: 17px; font-weight: 800; margin-bottom: 4px; }
#choiceOpts small { display: block; font-size: 13px; }

#presets { display: flex; flex-wrap: wrap; gap: 4px; margin: 8px 0; max-height: 132px; overflow: auto; }
#presets button { font-size: 12.5px; padding: 3px 8px; border-radius: 12px; border-width: 1.5px; }
#presets button.city { background: #eef4ff; }
#presets button.region { background: #eefaf0; }


/* HUD as a panel on the left, one row per thing with an icon */
#top { left: 12px; top: 12px; transform: none; align-items: stretch; gap: 8px; width: 216px; max-width: 60vw; background: rgba(255, 250, 242, 0.94);
  border-radius: 14px; padding: 10px 12px; box-shadow: 0 4px 16px rgba(0, 0, 0, 0.22); }
#stock, #tribes { flex-direction: column; gap: 3px; flex-wrap: nowrap; justify-content: flex-start; }
.stat { display: flex; align-items: center; gap: 8px; font-size: 14px; white-space: nowrap; }
.stat .ic { width: 24px; height: 24px; flex: none; display: flex; align-items: center; justify-content: center; }
.stat .ic svg, .stat .ic img { width: 24px; height: 24px; display: block; }
.stat .lb { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; color: #4a433b; }
.stat b { font-size: 17px; font-weight: 800; }
.stat small { font-size: 12px; min-width: 44px; }
.stat.tribe { font-size: 13px; }
.stat.tribe b { font-size: 14px; }
.stat.tribe .ic, .stat.tribe .ic svg { width: 20px; height: 20px; }
.stat.dead { opacity: 0.45; text-decoration: line-through; }
#share { width: 100%; height: 12px; box-shadow: none; background: #e9e2d3; }
#tribes { border-top: 1px solid var(--line); padding-top: 6px; }
#toasts { left: 12px; bottom: 120px; }

/* squads above the build bar */
#bottom { flex-direction: column; align-items: center; gap: 6px; }
#build { flex-wrap: wrap; justify-content: center; }
#build button { min-width: 74px; padding: 5px 9px; }
#build button b { font-size: 14px; }
#squads { display: flex; gap: 5px; align-items: center; flex-wrap: wrap; justify-content: center; }
#squads:empty { display: none; }
#squads button { display: flex; align-items: center; gap: 4px; background: var(--paper); border: 2px solid var(--line); border-radius: 12px; padding: 2px 9px 2px 5px; box-shadow: 0 3px 10px rgba(0, 0, 0, 0.2); }
#squads button img { width: 26px; height: 26px; }
#squads button b { font-size: 14px; padding-left: 4px; }
#squads button small { font-size: 13px; color: var(--ink); }
#squads button.on { border-color: var(--you); background: #fff1e4; }
#squads .hungry { background: #e02d2d; color: #fff; border-radius: 10px; padding: 2px 8px; font-size: 13px; font-weight: 600; }

/* build buttons: a picture and a name; the barracks choices open above the bar */
#build button { display: flex; flex-direction: column; align-items: center; min-width: 84px; padding: 5px 10px 4px; }
#build .bi { width: 34px; height: 34px; display: block; }
#build .bi svg { width: 34px; height: 34px; display: block; }
#build button b { font-size: 14px; line-height: 1.15; }
#build button small { font-size: 11.5px; }
#halls { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; }
#halls button { display: flex; flex-direction: column; align-items: center; min-width: 118px; background: var(--paper); border: 2px solid var(--you); border-radius: 14px; padding: 5px 10px 4px; box-shadow: 0 3px 12px rgba(0, 0, 0, 0.25); }
#halls button img { width: 40px; height: 40px; }
#halls button b { font-size: 14px; font-weight: 800; }
#halls button small { font-size: 11.5px; }
#halls button em { font-style: normal; font-size: 11.5px; color: var(--muted); }
#halls button.on { background: #fff1e4; }
#halls button.poor { opacity: 0.55; }

/* explanations sit at the top, clear of the squad and build bars */
/* centred between the stats panel and the speed / pause / new place buttons (about 400 px on the right) */
#tip { top: 12px; bottom: auto; width: max-content; max-width: min(620px, calc(100vw - 820px)); font-size: 14px; }
@media (max-width: 1180px) { #tip { top: auto; bottom: 200px; max-width: 92vw; } }

/* where supplies come from and go to, per second */
#flow { position: fixed; right: 12px; top: 52px; width: 176px; background: rgba(255, 250, 242, 0.94); border-radius: 12px; padding: 8px 10px; box-shadow: 0 4px 16px rgba(0, 0, 0, 0.22); font-size: 13px; pointer-events: none; }
#flow:empty { display: none; }
#flow h4 { margin: 0 0 4px; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.4px; }
#flow table { width: 100%; border-collapse: collapse; }
#flow td { padding: 1px 0; }
#flow td:last-child { text-align: right; font-weight: 800; font-variant-numeric: tabular-nums; }
#flow .pos td:last-child { color: #2e8b4e; }
#flow .neg td:last-child { color: #c0392b; }
#flow .net td { border-top: 1px solid var(--line); padding-top: 3px; font-weight: 800; }

/* how good the chosen place is */
#rating { margin: 6px 0 10px; font-size: 14px; min-height: 20px; }
#rating .st { color: #e0a100; letter-spacing: 1px; font-size: 17px; }
#rating .muted { color: var(--muted); font-size: 13px; }
#rating button { margin-top: 6px; font-size: 13px; padding: 3px 10px; border-radius: 10px; }
#presets button.small { background: #fff; }
#presets button.medium { background: #eef4ff; }
#presets button.large { background: #eefaf0; }

/* continue a saved match */
.cont { width: 100%; margin-bottom: 8px; background: #2f3b2a; border-color: #1f281c; color: #fff; font-size: 16px; padding: 9px 12px; border-radius: 14px; text-align: left; }
.cont:hover { border-color: #5d7a4a; }
.cont b { font-weight: 800; }
.cont small { display: block; color: #cfe0c4; font-size: 12.5px; }
.cont:disabled { opacity: 0.6; cursor: wait; }

/* right column: supply table, then the production switches */
#right { position: fixed; right: 12px; top: 52px; width: 190px; display: flex; flex-direction: column; gap: 8px; }
#flow { position: static; width: auto; }
#prod { background: rgba(255, 250, 242, 0.94); border-radius: 12px; padding: 8px 10px; box-shadow: 0 4px 16px rgba(0, 0, 0, 0.22); font-size: 13px; }
#prod:empty { display: none; }
#prod h4 { margin: 0 0 4px; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.4px; }
#prod .pr { display: flex; align-items: center; gap: 6px; padding: 2px 0; }
#prod .pr img { width: 24px; height: 24px; flex: none; }
#prod .pr span { flex: 1; min-width: 0; font-weight: 600; line-height: 1.1; }
#prod .pr small { display: block; font-weight: 400; font-size: 11.5px; }
#prod .sw { flex: none; width: 44px; padding: 2px 0; border-radius: 10px; font-size: 11.5px; font-weight: 800; border: 2px solid #c9bfae; background: #e9e2d3; color: #7a7166; }
#prod .sw.on { background: #2e8b4e; border-color: #226b3b; color: #fff; }

/* your colour: a small row of swatches */
#colors { display: flex; align-items: center; gap: 7px; margin: 10px 0 2px; font-size: 13px; color: var(--muted); }
#colors span { margin-right: 2px; }
#colors em { font-style: normal; font-weight: 600; color: var(--ink, #1d1a17); margin-left: 2px; }
#colors button { width: 20px; height: 20px; padding: 0; border-radius: 50%; border: 0; background: var(--c); box-shadow: inset 0 0 0 1.5px rgba(0, 0, 0, 0.18); transition: transform 0.12s, box-shadow 0.12s; }
#colors button:hover { transform: scale(1.15); }
#colors button.on { transform: scale(1.15); box-shadow: 0 0 0 2px var(--paper, #fffaf2), 0 0 0 4px var(--c); }
.seg button.on, #build button.on, #squads button.on { background: color-mix(in srgb, var(--you) 14%, #fff); }
.big { border-color: color-mix(in srgb, var(--you) 75%, #000); }
/* the Wonder: who holds it, and how long until that wins */
#wonder { position: fixed; top: 10px; left: 50%; transform: translateX(-50%); min-width: 260px; background: rgba(255, 250, 242, 0.96); border-radius: 14px; padding: 5px 18px 9px; box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25); text-align: center; cursor: pointer; overflow: hidden; z-index: 5; }
#wonder[hidden] { display: none; }
#wonder span { display: block; font-size: 13px; font-weight: 600; white-space: nowrap; }
#wonder b { display: block; font-size: 22px; line-height: 1.05; font-weight: 800; color: var(--muted); font-variant-numeric: tabular-nums; }
#wonder.held b { font-size: 30px; }
#wonder i { position: absolute; left: 0; bottom: 0; height: 5px; transition: width 0.5s; }
body.haswonder #tip { top: 84px; }
@media (max-width: 1180px) { body.haswonder #tip { top: auto; } } /* the narrow-screen tip sits at the bottom: a top as well stretched it to fill the screen */
#share.nogoal::after { display: none; }
.toast.go { pointer-events: auto; cursor: pointer; }
.toast.bad { background: #fff0ec; font-weight: 600; animation-duration: 9s; }

#colors span, #colors em { white-space: nowrap; }

#colors { gap: 6px; flex-wrap: nowrap; }
#colors button { width: 18px; height: 18px; flex: none; }
#colors em { min-width: 54px; }
#presets button.wonder { background: #fff8e1; }
#presets button.wonder.on { border-color: var(--you); }

/* suggestions sit on the map itself, along the bottom */
@media (min-width: 900px) {
  #presets { position: fixed; left: 420px; right: 64px; bottom: 30px; max-height: none; overflow: visible; margin: 0; justify-content: center; gap: 6px; z-index: 3; }
  #presets button { font-size: 13.5px; padding: 6px 12px; border-radius: 16px; background: rgba(255, 250, 242, 0.96); box-shadow: 0 3px 10px rgba(0, 0, 0, 0.22); }
  #presets button.wonder { background: #fff6d8; }
}

/* locked buildings say which age opens them */
#build button, #halls button { position: relative; }
#build button.locked, #halls button.locked { filter: grayscale(1); opacity: 0.6; }
#build button[data-lock]::after, #halls button[data-lock]::after { content: '\1F512  ' attr(data-lock); position: absolute; top: -10px; left: 50%; transform: translateX(-50%); white-space: nowrap;
  background: #1d1a17; color: #fff; font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 9px; }
/* ages box */
#ages { background: rgba(255, 250, 242, 0.94); border-radius: 12px; padding: 8px 10px; box-shadow: 0 4px 16px rgba(0, 0, 0, 0.22); font-size: 13px; }
#ages:empty { display: none; }
#ages h4 { margin: 0 0 4px; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.4px; }
#ages .ag { display: flex; align-items: center; justify-content: space-between; gap: 6px; padding: 2px 0; }
#ages .nm { font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#ages .pips { display: flex; gap: 3px; flex: none; }
#ages .pips i { font-style: normal; font-size: 10.5px; font-weight: 800; min-width: 20px; text-align: center; padding: 1px 0; border-radius: 6px; border: 1.5px solid #c9bfae; color: #a39a8a; }
#ages .nx { font-size: 11.5px; color: var(--muted); margin: 1px 0 3px; }
#ages .need { margin: 0 0 4px; font-size: 11.5px; }
#ages .need u { display: block; height: 5px; border-radius: 3px; background: #e2d9c6; overflow: hidden; text-decoration: none; margin-top: 1px; }
#ages .need u i { display: block; height: 100%; }
#prod .wi { width: 24px; height: 14px; flex: none; background: #a79f8e; border: 1.5px solid #1d1a17; border-radius: 2px; }
#presets button.dice { background: var(--you); color: #fff; border-color: transparent; font-weight: 700; }

/* pause */
#pauseBtn { position: fixed; top: 10px; right: 104px; font-size: 14px; }
#pause { position: fixed; inset: 0; background: rgba(20, 17, 14, 0.55); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 20; }
#pause .box { background: var(--paper); border-radius: 18px; padding: 22px; width: min(400px, 100%); text-align: center; display: flex; flex-direction: column; gap: 8px; box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4); }
#pause h2 { margin: 0; font-size: 32px; font-weight: 800; }
#pause p { margin: 0; color: var(--muted); font-size: 13.5px; }
#pauseOpts { display: flex; flex-direction: column; gap: 6px; margin: 8px 0; text-align: left; }
#pauseOpts .ps { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 14px; font-weight: 600; }
#pauseOpts .seg { display: flex; gap: 4px; flex: none; }
#pauseOpts .seg button { flex: none; min-width: 46px; padding: 4px 8px; font-size: 13px; }
#pause .keys { font-size: 12px; }
#choiceOpts em { display: block; font-style: normal; font-weight: 800; font-size: 14.5px; color: #2e8b4e; margin-bottom: 3px; }

#ages .goal { font-weight: 800; font-size: 13px; margin: 4px 0 3px; }
#ages .need { font-size: 12.5px; margin: 0 0 5px; }
#ages .need span { display: flex; align-items: baseline; gap: 4px; font-weight: 600; }
#ages .need span b { flex: none; width: 13px; color: #a39a8a; }
#ages .need.ok span b { color: #2e8b4e; }
#ages .need em { margin-left: auto; font-style: normal; font-weight: 800; font-variant-numeric: tabular-nums; }
#ages .need u { height: 6px; margin-top: 2px; }
#ages .nx { font-size: 12px; }
#ages .need em { white-space: nowrap; flex: none; }

/* orders */
.selbox { position: fixed; z-index: 30; pointer-events: none; border: 1.5px solid #fff; background: rgba(255, 255, 255, 0.14); box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.35); border-radius: 3px; }
#squads button.det { border-style: dashed; }
#squads button.grp { padding: 2px 9px; min-width: 30px; justify-content: center; }
#squads .pinfo { display: flex; align-items: center; gap: 3px; font-size: 13px; font-weight: 600; background: var(--paper); border-radius: 10px; padding: 1px 8px; }
#squads .pinfo img { width: 20px; height: 20px; }
#squads .pinfo i { font-style: normal; color: #2e8b4e; margin-left: 4px; }
#squads button.pk b { padding-left: 2px; }
#squads .sep { width: 1px; align-self: stretch; background: #c9bfae; margin: 0 4px; }
#squads button.st { min-width: 58px; }
#squads button.st b { display: block; font-size: 13px; }
#squads button.st.on { border-color: var(--you); background: color-mix(in srgb, var(--you) 14%, #fff); }
/* match summary */
#modal .box { width: min(760px, 100%); }
#modalStats { overflow-x: auto; margin: 4px 0 8px; }
#modalStats table { width: 100%; border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums; }
#modalStats th { font-weight: 600; color: var(--muted); font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.3px; padding: 3px 6px; text-align: right; }
#modalStats td { padding: 4px 6px; text-align: right; border-top: 1px solid #e2d9c6; }
#modalStats td:first-child, #modalStats th:first-child { text-align: left; font-weight: 600; white-space: nowrap; }
#modalStats td i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; }
#modalStats tr.win td { font-weight: 800; }

/* the light of the day: a faint wash over the map, under the creatures and the panels */
#tint { position: fixed; inset: 0; pointer-events: none; opacity: 0; mix-blend-mode: soft-light; transition: opacity 2s linear, background 2s linear; }

/* priority list */
#prod h4.ph { margin-top: 8px; }
#prod .pq { display: flex; align-items: center; gap: 6px; padding: 2px 0; font-size: 13px; }
#prod .pq > b { flex: none; width: 18px; height: 18px; line-height: 18px; text-align: center; border-radius: 50%; background: var(--you); color: #fff; font-size: 11.5px; }
#prod .pq span { flex: 1; font-weight: 600; }
#prod .pq small { font-weight: 400; margin-left: 5px; color: var(--muted); }
#prod .pq.wait span { color: var(--muted); }
#prod .pq button { flex: none; width: 22px; height: 20px; padding: 0; font-size: 10px; line-height: 1; border-radius: 6px; border: 1.5px solid #c9bfae; background: #fff; }
#prod .pq button:disabled { opacity: 0.3; }

#prod h4.ph { display: flex; align-items: center; justify-content: space-between; }
#prod h4.ph .sw { width: 62px; font-size: 10.5px; letter-spacing: 0; }
#prod .pwhy { font-size: 11.5px; color: var(--muted); margin: 0 0 3px; }

/* developer box (temporary) */
#dev { margin-top: 10px; padding: 8px 10px; border: 1.5px dashed #c9bfae; border-radius: 12px; font-size: 13px; display: flex; flex-direction: column; gap: 4px; }
#dev b { font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.4px; color: var(--muted); }
#dev label { display: flex; align-items: center; gap: 6px; cursor: pointer; }
#dev button { margin-top: 3px; font-size: 13px; padding: 5px 8px; }

/* game speed, next to Pause */
#speedBar { position: fixed; top: 10px; right: 236px; display: flex; gap: 3px; z-index: 5; }
#speedBar button { font-size: 13px; padding: 5px 7px; min-width: 34px; font-weight: 600; }
#speedBar button.on { border-color: var(--you); background: color-mix(in srgb, var(--you) 14%, #fff); }

/* standings */
#ages h4.st { margin-top: 8px; }
#ages .ag .rk { flex: none; width: 17px; height: 17px; line-height: 17px; text-align: center; border-radius: 50%; color: #fff; font-size: 11px; margin-right: 5px; }
#ages .ag .pt { flex: none; font-style: normal; font-weight: 700; font-size: 12.5px; margin: 0 6px; font-variant-numeric: tabular-nums; }
#ages .ag.me .nm { font-weight: 800; }
#ages .ag .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* sound volume */
#pauseOpts input[type=range] { flex: 1; max-width: 170px; accent-color: var(--you); }
#pauseOpts em { font-style: normal; font-weight: 700; font-size: 13px; width: 30px; text-align: right; }

/* start panel: daily map, guided match, replay file */
#dailyBtn { margin-top: 6px; }
.row.two { display: flex; gap: 6px; margin-top: 6px; }
.row.two button { flex: 1; font-size: 13px; padding: 6px 6px; }
#tutBtn.hl { border-color: var(--you); background: color-mix(in srgb, var(--you) 12%, #fff); font-weight: 700; }

/* mini-map: bottom left; the messages sit above it */
#miniBox { position: fixed; left: 12px; bottom: 12px; width: 216px; border-radius: 12px; overflow: hidden; background: var(--paper); box-shadow: 0 3px 12px rgba(0, 0, 0, 0.3); border: 2px solid #fff; line-height: 0; z-index: 4; }
#mini { width: 100%; height: auto; display: block; cursor: crosshair; touch-action: none; }
#miniTog { position: absolute; right: 3px; top: 3px; width: 20px; height: 20px; padding: 0; line-height: 1; font-size: 13px; border-radius: 6px; border: 1px solid #c9bfae; background: rgba(255, 250, 242, 0.9); }
#miniBox.shut { width: auto; border: none; background: none; box-shadow: none; overflow: visible; }
#miniBox.shut #mini { display: none; }
#miniBox.shut #miniTog { position: static; width: auto; height: auto; padding: 5px 10px; font-size: 13px; line-height: 1.2; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2); }
body.hasmini #toasts { bottom: 176px; }
@media (max-width: 760px) { #miniBox { width: 150px; } body.hasmini #toasts { bottom: 130px; } }

/* guided first match */
#tut { position: fixed; top: 56px; left: 50%; transform: translateX(-50%); width: min(430px, calc(100vw - 470px)); min-width: 300px; background: var(--paper); border-radius: 14px; padding: 10px 14px 12px; box-shadow: 0 4px 16px rgba(0, 0, 0, 0.28); border-left: 6px solid var(--you); z-index: 5; }
#tut h3 { margin: 4px 0 2px; font-size: 17px; }
#tut p { margin: 0 0 8px; font-size: 14px; line-height: 1.35; }
#tut .tq { display: flex; justify-content: space-between; align-items: center; font-size: 11.5px; color: var(--muted); }
#tut .tq i { display: inline-block; width: 16px; height: 5px; border-radius: 3px; background: #e2dacb; margin-right: 3px; }
#tut .tq i.done { background: var(--you); opacity: 0.45; }
#tut .tq i.now { background: var(--you); }
#tut .tq em { font-style: normal; }
#tut .tb { display: flex; gap: 6px; justify-content: flex-end; }
#tut .tb button { font-size: 12.5px; padding: 4px 9px; }
@media (max-width: 1000px) { #tut { top: auto; bottom: 250px; width: min(430px, 94vw); } }

/* end screen extras and the replay window */
#dailyLine { font-size: 14px; background: #fff8e1; border-radius: 10px; padding: 7px 10px; }
#dailyLine button { font-size: 12.5px; padding: 3px 8px; margin-left: 6px; }
#replayBox { position: fixed; inset: 0; background: rgba(29, 26, 23, 0.55); display: flex; align-items: center; justify-content: center; padding: 14px; z-index: 30; }
#replayBox[hidden] { display: none; }
#replayBox .box { background: var(--paper); border-radius: 18px; padding: 16px 18px; width: min(700px, 100%); max-height: calc(100vh - 28px); overflow: auto; display: flex; flex-direction: column; gap: 8px; }
#replayBox h2 { margin: 0; font-size: 19px; text-align: center; }
#rpMap { width: 100%; height: auto; border-radius: 10px; background: #ddd; }
#rpChart { width: 100%; height: 110px; background: #fff; border-radius: 10px; cursor: pointer; }
#rpLegend { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 12.5px; justify-content: center; }
#rpLegend i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 4px; }
.rpc { display: flex; align-items: center; gap: 8px; }
.rpc input[type=range] { flex: 1; accent-color: var(--you); }
.rpc em { font-style: normal; font-size: 13px; font-variant-numeric: tabular-nums; min-width: 92px; text-align: right; }
#rpPlay { width: 42px; }
.rpc #rpSave, .rpc #rpClose { flex: 1; }

/* mini-map zoom buttons */
#miniZoom { position: absolute; right: 3px; bottom: 3px; display: flex; flex-direction: column; gap: 2px; }
#miniZoom button { width: 20px; height: 20px; padding: 0; line-height: 1; font-size: 13px; font-weight: 700; border-radius: 6px; border: 1px solid #c9bfae; background: rgba(255, 250, 242, 0.9); }
#miniBox.shut #miniZoom { display: none; }

#bandCard { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); width: min(520px, calc(100vw - 32px)); display: flex; gap: 12px; align-items: center; background: var(--paper); border-radius: 14px; padding: 10px 14px; box-shadow: 0 4px 16px rgba(0, 0, 0, 0.28); border-left: 6px solid #d6a014; z-index: 5; }
#bandCard svg { width: 96px; height: 96px; flex: none; }
#bandCard h3 { margin: 0 0 4px; font-size: 16px; }
#bandCard p { margin: 0 0 5px; font-size: 13px; line-height: 1.35; }
#bandCard p.muted { color: var(--muted); font-size: 12px; margin: 0; }

#fbBox { position: fixed; inset: 0; background: rgba(20, 16, 12, 0.45); display: flex; align-items: center; justify-content: center; z-index: 30; }
#fbBox[hidden] { display: none; }
#fbBox .box { background: var(--paper); border-radius: 16px; padding: 16px 18px; width: min(460px, calc(100vw - 32px)); box-shadow: 0 8px 30px rgba(0, 0, 0, 0.35); }
#fbBox h2 { margin: 0 0 6px; }
#fbBox p { margin: 0 0 10px; font-size: 14px; }
#fbBox .fbKinds { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-bottom: 8px; font-size: 13.5px; }
#fbBox textarea { width: 100%; box-sizing: border-box; font: inherit; padding: 8px; border-radius: 10px; border: 1px solid #cfc6b4; resize: vertical; }
.fbOpen.linkish { background: none; border: none; text-decoration: underline; color: var(--muted); padding: 4px 0; cursor: pointer; }
.links a.linkish, #pause .privacy a { color: var(--muted); text-decoration: underline; padding: 4px 0; font-size: 13px; }
.links a.linkish { align-self: center; }
#pause .privacy { margin: 8px 0 0; font-size: 13px; text-align: center; }
/* the bar that asks for play data once, on the start screen: the two answers look alike, neither is pushed */
#consent { position: fixed; right: 16px; top: 16px; z-index: 45; width: min(420px, calc(100vw - 32px)); background: var(--paper); border-radius: 14px;
  padding: 12px 14px; box-shadow: 0 8px 30px rgba(0, 0, 0, 0.3); font-size: 14px; line-height: 1.4; }
#consent p { margin: 0 0 10px; }
#consent a { color: var(--ink); }
#consent .cb { display: flex; gap: 8px; }
#consent .cb button { flex: 1; font-weight: 600; }
@media (max-width: 760px), (max-height: 520px) {
  #consent { top: max(8px, env(safe-area-inset-top)); bottom: auto; left: 8px; right: 8px; width: auto; font-size: 13px; padding: 10px 12px; }
}

#ages .ag .ab { flex: none; font-style: normal; font-size: 10.5px; font-weight: 800; color: #fff; min-width: 22px; text-align: center; padding: 1px 3px; border-radius: 6px; }
#ages .ag .ab.unk { background: #b9b0a2; }
#ages .ag .pt { margin: 0 5px 0 4px; }
#ages .ag .nm { white-space: normal; font-size: 12px; line-height: 1.15; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow-wrap: anywhere; }
#ages .ag { align-items: center; padding: 3px 0; }

/* ===== One look for every panel (UI pass) =====
   Panels share one surface: warm paper, a little see-through with the map blurred behind, one shadow, one edge. */
:root {
  --panel: rgba(255, 250, 242, 0.9);
  --edge: rgba(255, 255, 255, 0.75);
  --shadow: 0 6px 20px rgba(45, 30, 12, 0.16), 0 1px 3px rgba(45, 30, 12, 0.12);
}
#top, #right .box, #miniBox, #tut, #wonder, .toast, #bandCard {
  background: var(--panel); -webkit-backdrop-filter: blur(8px) saturate(1.15); backdrop-filter: blur(8px) saturate(1.15);
  box-shadow: var(--shadow); border: 1px solid var(--edge);
}
/* (no blur on the start panel: a backdrop filter would trap the place chips, which are fixed to the screen, inside it) */
.panel { border: 1px solid var(--edge); }
.toast { border-left: 6px solid; }
#tut { border-left: 6px solid var(--you); }
#bandCard { border-left: 6px solid #d6a014; }
button { transition: border-color 0.12s, background-color 0.12s, transform 0.08s; }
button:active { transform: translateY(1px); }
#build button, #squads button, #halls button { box-shadow: var(--shadow); }

/* left panel: your tribe only (the other tribes are in the standings) */
#tribes { display: none; }
#top { gap: 6px; }

/* right column: never runs off the screen, every box folds to its heading */
#right { top: 52px; right: 8px; width: 198px; max-height: calc(100vh - 64px); overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; padding: 0 4px 8px; }
#right .box { border-radius: 12px; padding: 8px 10px; font-size: 13px; }
#right .box:empty { display: none; }
#right h4[data-fold] { display: flex; align-items: center; gap: 4px; margin: 0 0 4px; cursor: pointer; user-select: none; }
#right h4[data-fold]::before { content: ''; flex: none; width: 0; height: 0; border-left: 4px solid transparent; border-right: 4px solid transparent; border-top: 5px solid currentColor; transition: transform 0.15s; }
#right h4[data-fold]:hover { color: var(--ink); }
#right .sum { margin-left: auto; font-size: 12px; font-weight: 800; color: var(--ink); text-transform: none; letter-spacing: 0; white-space: nowrap; }
#right .sum.pos { color: #2e8b4e; }
#right .sum.neg { color: #c0392b; }
#right .fold h4[data-fold] { margin-bottom: 0; }
#right .fold h4[data-fold]::before { transform: rotate(-90deg); }
#right .fold .fb { display: none; }

/* standings: rank, name, land, score, age */
#stand .ag { display: flex; align-items: center; gap: 4px; padding: 3px 0; }
#stand .ag .nm { flex: 1; min-width: 0; font-weight: 600; font-size: 12px; line-height: 1.15; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow-wrap: anywhere; }
#stand .ag.me .nm { font-weight: 800; }
#stand .ag .rk { flex: none; width: 17px; height: 17px; line-height: 17px; text-align: center; border-radius: 50%; color: #fff; font-size: 11px; margin-right: 3px; }
#stand .ag .ld { flex: none; font-style: normal; font-weight: 800; font-size: 13px; font-variant-numeric: tabular-nums; }
#stand .ag .pt { flex: none; font-style: normal; font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; min-width: 26px; text-align: right; }
#stand .ag .ab { flex: none; font-style: normal; font-size: 10.5px; font-weight: 800; color: #fff; min-width: 22px; text-align: center; padding: 1px 3px; border-radius: 6px; }
#stand .ag .ab.unk { background: #b9b0a2; }
#stand .ag.dead { opacity: 0.45; }
#stand .ag.dead .nm { text-decoration: line-through; }

/* top right: speed, pause and new place as one row of equal buttons */
#speedBar button, #pauseBtn, #quitBtn { height: 32px; display: inline-flex; align-items: center; justify-content: center; background: var(--panel); border: 1px solid var(--line); box-shadow: var(--shadow); font-weight: 600; font-size: 13px; }
#speedBar { gap: 2px; }
#speedBar button { padding: 0 7px; min-width: 34px; border-radius: 8px; }
#speedBar button.on { border: 2px solid var(--you); }
#pauseBtn, #quitBtn { padding: 0 11px; border-radius: 10px; }

/* the hint at the top: softer, easier to read */
#tip { background: rgba(29, 26, 23, 0.82); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); border-radius: 14px; line-height: 1.35; padding: 7px 14px; box-shadow: var(--shadow); }

/* start panel: a small caption over each choice, one main button, the daily map lighter */
.panel .cap { margin: 10px 0 -3px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; color: var(--muted); }
.panel .row.seg { margin-top: 6px; }
#dailyBtn { background: #fff8e1; border-color: #ecd9a0; color: var(--ink); }
#dailyBtn:hover { border-color: #d6a014; }
#dailyBtn small { color: var(--muted); }
.big { box-shadow: 0 4px 14px color-mix(in srgb, var(--you) 35%, transparent); }
#flow { pointer-events: auto; } /* its heading folds it */
.panel .seg button small { font-size: 10.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#right h4 { margin: 0 0 4px; font-size: 11.5px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.4px; white-space: nowrap; }
#prod .pr small { overflow-wrap: anywhere; }
.stat small { line-height: 1.15; }
/* place chips: an outline icon (Tabler Icons, MIT) drawn in the text colour */
#presets .pi, #sugg .pi { display: inline-block; width: 15px; height: 15px; margin: 0 6px -2px 0; background: currentColor; -webkit-mask: var(--ic) center / contain no-repeat; mask: var(--ic) center / contain no-repeat; }
#presets button.wonder .pi { color: #8a5a00; }

/* welcome (first visit) and How to play (a small wiki, open any time) */
#welcome, #helpBox { position: fixed; inset: 0; background: rgba(20, 16, 12, 0.5); display: flex; align-items: center; justify-content: center; z-index: 40; }
#welcome[hidden], #helpBox[hidden] { display: none; }
#welcome .box { background: var(--paper); border-radius: 18px; padding: 20px 22px; width: min(500px, calc(100vw - 32px)); max-height: calc(100vh - 32px); overflow-y: auto; box-shadow: 0 10px 34px rgba(0, 0, 0, 0.4); border-top: 6px solid var(--you); }
#welcome h2 { margin: 0 0 6px; font-size: 24px; }
#welcome .lead { font-size: 15px; margin: 0 0 10px; }
#welcome .wl { margin: 0 0 12px; padding-left: 18px; font-size: 14px; line-height: 1.4; }
#welcome .wl li { margin-bottom: 5px; }
#welcome .big { width: 100%; margin: 4px 0 8px; }
#helpBox .box { background: var(--paper); border-radius: 18px; width: min(860px, calc(100vw - 24px)); height: min(640px, calc(100vh - 24px)); display: flex; flex-direction: column; box-shadow: 0 10px 34px rgba(0, 0, 0, 0.4); overflow: hidden; }
#helpBox .hhead { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid #e4dccd; }
#helpBox .hhead h2 { margin: 0; }
#helpBox .hbody { flex: 1; display: flex; min-height: 0; }
#helpNav { width: 190px; flex: none; overflow-y: auto; padding: 8px; border-right: 1px solid #e4dccd; display: flex; flex-direction: column; gap: 2px; }
#helpNav button { text-align: left; border: 0; background: none; border-radius: 8px; padding: 7px 10px; font-size: 14px; box-shadow: none; }
#helpNav button.on { background: color-mix(in srgb, var(--you) 16%, #fff); font-weight: 700; }
#helpText { flex: 1; overflow-y: auto; padding: 12px 18px 18px; font-size: 14px; line-height: 1.45; }
#helpText h3 { margin: 4px 0 6px; font-size: 18px; }
#helpText h4 { margin: 12px 0 4px; font-size: 15px; }
#helpText p { margin: 0 0 8px; }
#helpText ul { margin: 0 0 8px; padding-left: 18px; }
#helpText table { border-collapse: collapse; width: 100%; margin: 4px 0 10px; font-size: 13.5px; }
#helpText th, #helpText td { text-align: left; padding: 5px 8px; border-bottom: 1px solid #ece4d6; vertical-align: top; }
#helpText th { font-size: 12px; color: var(--muted); font-weight: 600; }
#helpText kbd { display: inline-block; min-width: 18px; padding: 0 5px; border: 1px solid #cfc6b4; border-bottom-width: 2px; border-radius: 5px; background: #fff; font: 600 12px/18px ui-monospace, monospace; text-align: center; }
#helpBtn { position: fixed; top: 10px; right: 196px; height: 32px; min-width: 34px; padding: 0 8px; border-radius: 10px; background: var(--panel); border: 1px solid var(--line); box-shadow: var(--shadow); font-weight: 800; font-size: 15px; }
@media (max-width: 640px) {
  #helpBox .hbody { flex-direction: column; }
  #helpNav { width: auto; flex-direction: row; overflow-x: auto; overflow-y: hidden; border-right: 0; border-bottom: 1px solid #e4dccd; flex: none; }
  #helpNav button { white-space: nowrap; }
}

/* ===== Phones and tablets =====
   A finger is the pointer: no page zoom on a double tap, no grey flash, nothing selected by a long press. */
html, body { overscroll-behavior: none; -webkit-text-size-adjust: 100%; }
button, #mini, .toast { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
#hud, #start .seg, #presets { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
@media (hover: none) { /* a tapped button does not stay lit as if the pointer rested on it */
  button:hover { border-color: var(--line); }
  .seg button.on:hover, #build button.on:hover, #squads button.on:hover, #halls button:hover, #speedBar button.on:hover { border-color: var(--you); }
  .big:hover { border-color: color-mix(in srgb, var(--you) 75%, #000); }
}
body.coarse #pause .keys { display: none; }
#infoBtn, #sheetTog { display: none; }
#squads button.lg { min-width: 34px; justify-content: center; }
/* panels never taller than what the browser really shows (the address bar of a phone comes and goes) */
@supports (height: 100dvh) {
  .panel { max-height: calc(100dvh - 32px); }
  #right { max-height: calc(100dvh - 64px); }
  #welcome .box { max-height: calc(100dvh - 32px); }
  #replayBox .box { max-height: calc(100dvh - 28px); }
  #helpBox .box { height: min(640px, calc(100dvh - 24px)); }
}
#modal .box, #choice .box, #pause .box, #fbBox .box { max-height: calc(100vh - 32px); max-height: calc(100dvh - 32px); overflow-y: auto; }

/* --- the start screen on a phone: a sheet at the bottom, the map above it; the handle folds it away --- */
@media (max-width: 760px) {
  .panel { left: 0; right: 0; top: auto; bottom: 0; width: 100%; max-height: 58vh; max-height: 58dvh; border-radius: 18px 18px 0 0; padding: 0 14px calc(10px + env(safe-area-inset-bottom)); overscroll-behavior: contain; }
  #sheetTog { display: block; position: sticky; top: 0; z-index: 4; width: 100%; height: 22px; padding: 0; margin: 0; border: 0; border-radius: 0; background: var(--paper); }
  #sheetTog::before { content: ''; display: block; width: 44px; height: 5px; margin: 0 auto; border-radius: 3px; background: #cfc6b4; }
  .panel h1 { font-size: 24px; }
  .panel .sub { display: none; }
  .panel input[type=text], #fbBox textarea { font-size: 16px; } /* smaller, and an iPhone zooms the page when you type */
  #presets { flex-wrap: nowrap; overflow-x: auto; overflow-y: hidden; max-height: none; padding-bottom: 4px; scrollbar-width: none; }
  #presets::-webkit-scrollbar { display: none; }
  #presets button { flex: none; font-size: 13.5px; padding: 6px 11px; white-space: nowrap; }
  .seg button { padding: 8px 4px; }
  .row.two button, #rating button, button.mini { padding-top: 8px; padding-bottom: 8px; }
  #colors { gap: 9px; flex-wrap: wrap; }
  #colors button { width: 26px; height: 26px; }
  #goBtn { position: sticky; bottom: 0; z-index: 3; margin: 4px 0; box-shadow: 0 0 0 10px var(--paper); } /* the paper round it hides what scrolls under */
  #progress:not(:empty) { position: sticky; bottom: 62px; z-index: 3; background: var(--paper); margin: 0; padding: 6px 0; }
  .panel.low { max-height: 150px; overflow: hidden; }
  .panel.low > :not(#sheetTog):not(h1):not(.row:nth-of-type(1)):not(#goBtn):not(#progress) { display: none; }
  #sugg { max-height: 34vh; }
  #welcome .box { padding: 16px; }
  #welcome .wl { font-size: 13.5px; }
  #modal .box, #choice .box, #pause .box { padding: 16px; }
  #modal h2 { font-size: 28px; }
  #choiceOpts button { flex: 1 1 100%; padding: 10px; }
  #pauseOpts .ps { flex-wrap: wrap; }
  #helpBox .box { width: 100vw; height: 100vh; height: 100dvh; border-radius: 0; }
  #helpText { padding: 10px 12px 18px; }
  #helpText table { font-size: 13px; }
  #helpNav button { padding: 9px 12px; }
}

/* --- a match on a small screen (a phone, either way up): the map is the screen ---
   Top: your numbers in one strip, and two buttons (the info sheet, pause). Bottom: soldiers and orders, then the
   buildings, one row each. The hint, the guide and the Wonder sit under the strip; messages over the bar. */
@media (max-width: 760px), (max-height: 520px) {
  :root { --sl: max(6px, env(safe-area-inset-left)); --sr: max(6px, env(safe-area-inset-right)); --st: max(6px, env(safe-area-inset-top)); --sb: max(6px, env(safe-area-inset-bottom)); }
  #top { left: var(--sl); top: var(--st); right: calc(var(--sr) + 88px); width: auto; max-width: 420px; padding: 5px 8px 6px; gap: 4px; border-radius: 12px; }
  #stock { flex-direction: row; flex-wrap: wrap; gap: 2px 10px; }
  .stat { gap: 3px; font-size: 12px; }
  .stat .lb { display: none; }
  .stat .ic, .stat .ic svg, .stat .ic img { width: 18px; height: 18px; }
  .stat b { font-size: 14.5px; }
  .stat small { min-width: 0; font-size: 11px; }
  .stat:last-child small { display: none; } /* the land goal: the mark on the line under the numbers, and the standings */
  #share { height: 6px; }
  #speedBar, #helpBtn, #quitBtn { display: none; }
  #infoBtn, #pauseBtn { display: inline-flex; align-items: center; justify-content: center; position: fixed; top: var(--st); width: 40px; height: 40px; padding: 0; border-radius: 12px; font-size: 17px; font-weight: 700; background: var(--panel); border: 1px solid var(--line); box-shadow: var(--shadow); z-index: 6; }
  #pauseBtn { right: var(--sr); font-size: 14px; }
  #pauseBtn span { display: none; }
  #infoBtn { right: calc(var(--sr) + 44px); }
  body.info #infoBtn { border: 2px solid var(--you); }
  #right { display: none; top: calc(var(--st) + 46px); right: var(--sr); width: min(250px, calc(100vw - 16px)); max-height: calc(100vh - var(--bh, 0px) - 70px); max-height: calc(100dvh - var(--bh, 0px) - 70px); z-index: 7; padding: 0 0 8px; }
  body.info #right { display: flex; }
  #right h4[data-fold] { padding: 4px 0; }
  #prod .sw { width: 52px; padding: 6px 0; }
  #prod .pq button { width: 34px; height: 30px; font-size: 12px; }

  #mid { position: fixed; z-index: 5; top: calc(var(--st) + var(--th, 44px) + 6px); left: var(--sl); right: var(--sr); display: flex; flex-direction: column; align-items: center; gap: 6px; pointer-events: none; }
  #mid > * { position: static; transform: none; pointer-events: auto; margin: 0; }
  #mid > #tip, body.haswonder #mid > #tip { top: auto; bottom: auto; width: auto; max-width: 100%; font-size: 13px; line-height: 1.3; padding: 6px 11px; pointer-events: none; }
  #wonder { min-width: 0; width: min(300px, 100%); padding: 3px 12px 8px; }
  #wonder b { font-size: 18px; }
  #wonder.held b { font-size: 22px; }
  #mid > #tut { width: min(430px, 100%); min-width: 0; padding: 7px 11px 9px; max-height: 40vh; overflow-y: auto; }
  #tut h3 { font-size: 15px; margin: 2px 0; }
  #tut p { font-size: 13px; line-height: 1.3; margin-bottom: 6px; }
  #tut .tb button { padding: 7px 11px; }

  #bottom { z-index: 3; left: 0; right: 0; bottom: 0; transform: none; width: auto; max-width: none; padding: 0 var(--sr) var(--sb) var(--sl); gap: 5px; align-items: stretch; pointer-events: none; }
  #bottom > * { pointer-events: auto; }
  #build, #halls { flex-wrap: nowrap; gap: 4px; justify-content: center; }
  #build button, #halls button { flex: 1 1 0; min-width: 0; max-width: 96px; padding: 4px 2px 3px; border-radius: 12px; overflow: visible; }
  #build .bi, #build .bi svg { width: 26px; height: 26px; }
  #build button b, #halls button b { font-size: 10.5px; letter-spacing: -0.2px; white-space: nowrap; }
  #build button small, #halls button small { font-size: 11px; white-space: nowrap; }
  #halls button { max-width: 120px; }
  #halls button img { width: 30px; height: 30px; }
  #halls button em { display: none; }
  #build button[data-lock]::after, #halls button[data-lock]::after { font-size: 9.5px; padding: 0 5px; top: -8px; }
  #squads { flex-wrap: nowrap; justify-content: flex-start; overflow-x: auto; gap: 3px; padding: 6px 0 2px; scrollbar-width: none; }
  #squads::-webkit-scrollbar { display: none; }
  #squads > :first-child { margin-left: auto; } /* centred while it fits, scrolls when it does not */
  #squads > :last-child { margin-right: auto; }
  #squads button { flex: none; min-height: 38px; padding: 2px 7px 2px 4px; border-radius: 11px; }
  #squads button.pk, #squads button.st, #squads button.grp { padding: 2px 7px; min-width: 0; }
  #squads button b, #squads button.st b { font-size: 12.5px; padding: 0; }
  #squads button img { width: 24px; height: 24px; }
  #squads .sep { flex: none; margin: 0 1px; }
  #squads .hungry { flex: none; }
  #resBtn { display: none; }

  #toasts, body.hasmini #toasts { left: auto; right: var(--sr); bottom: calc(var(--bh, 0px) + 8px); align-items: flex-end; max-width: 72vw; z-index: 4; }
  .toast { font-size: 12.5px; padding: 4px 9px; }
  .toast.go { padding: 8px 10px; }
  #miniBox { left: var(--sl); bottom: calc(var(--bh, 0px) + 8px); width: min(150px, 40vw); }
  #miniBox.shut #miniTog { padding: 9px 12px; }
  #miniBox:not(.shut) #miniTog, #miniZoom button { width: 28px; height: 28px; font-size: 15px; }
  #miniZoom { gap: 3px; }
  #bandCard { bottom: var(--sb); padding: 8px 10px; gap: 8px; }
  #bandCard svg { width: 60px; height: 60px; }
  #bandCard h3 { font-size: 14px; }
  #bandCard p { font-size: 12px; line-height: 1.25; margin-bottom: 3px; }
  #bandCard p.muted { display: none; }
  /* the map's own buttons: pinching zooms, so only the compass stays, clear of the bar */
  .maplibregl-ctrl-bottom-right, .maplibregl-ctrl-bottom-left { bottom: var(--bh, 0px); }
  .maplibregl-ctrl-zoom-in, .maplibregl-ctrl-zoom-out { display: none !important; }
}
/* a phone on its side: little height, so the bar is one row (soldiers left, buildings right) */
@media (max-height: 520px) and (min-width: 600px) {
  #bottom { flex-direction: row; align-items: flex-end; justify-content: center; gap: 10px; }
  #squads { flex: 0 1 auto; min-width: 0; }
  #squads > :first-child, #squads > :last-child { margin: 0; }
  #build, #halls { flex: 0 1 auto; }
  #build button, #halls button { flex: 0 0 62px; }
  #halls { position: absolute; right: var(--sr); bottom: calc(100% + 4px); }
  #mid { left: calc(var(--sl) + 10%); right: calc(var(--sr) + 10%); }
  #mid > #tut { max-height: 48vh; }
}

/* ---------- the start screen: the logo on a tinted head, the place as a card, choices as switches, one big button ---------- */
.panel { width: min(396px, calc(100vw - 32px)); padding: 0 18px 16px; border-radius: 22px; box-shadow: 0 18px 50px rgba(45, 30, 12, 0.28), 0 2px 6px rgba(45, 30, 12, 0.14); scrollbar-width: thin; scrollbar-color: #d8cfbd transparent; }
.panel::-webkit-scrollbar { width: 8px; }
.panel::-webkit-scrollbar-thumb { background: #d8cfbd; border-radius: 4px; border: 2px solid var(--paper); }
.panel h1 { display: flex; align-items: center; gap: 13px; margin: 0 -18px; padding: 18px 18px 0; font-size: 31px; line-height: 1; letter-spacing: -0.8px;
  background: linear-gradient(180deg, color-mix(in srgb, var(--you) 16%, var(--paper)), var(--paper)); }
.panel h1 span { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.panel h1 small { font-size: 13px; font-weight: 600; letter-spacing: 0; color: color-mix(in srgb, var(--you) 60%, #1d1a17); }
.logo { flex: none; width: 58px; height: 58px; border-radius: 15px; box-shadow: 0 4px 12px rgba(45, 30, 12, 0.22), 0 0 0 1.5px rgba(29, 26, 23, 0.9); }
.logo .body { fill: var(--you); transition: fill 0.25s; }
.logo .eye { animation: look 7s infinite; }
@keyframes look { 0%, 44%, 100% { transform: none; } 50%, 72% { transform: translateX(-17px); } 78%, 92% { transform: translate(-8px, -9px); } }
@media (prefers-reduced-motion: reduce) { .logo .eye { animation: none; } }
.panel .sub { margin: 12px 0 14px; font-size: 14px; line-height: 1.4; }

/* search: one field with the button inside it */
#start > .row:nth-of-type(1) { position: relative; margin: 0 0 10px; }
#start .srch input { height: 44px; padding: 0 84px 0 38px; border-radius: 14px; border-color: #d8cfbd; font-size: 15px;
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%237a7166' stroke-width='2.4' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='6.5'/%3E%3Cpath d='M16 16l4.5 4.5'/%3E%3C/svg%3E") 12px center / 18px no-repeat; }
#start .srch input:focus { outline: none; border-color: var(--you); box-shadow: 0 0 0 4px color-mix(in srgb, var(--you) 18%, transparent); }
#searchBtn { position: absolute; right: 5px; top: 5px; height: 34px; padding: 0 13px; border: 0; border-radius: 10px; background: #1d1a17; color: #fff; font-weight: 600; font-size: 14px; }
#searchBtn:hover { background: #3a342d; }

/* the place: its name, where it is, how good it is */
#place { background: #fff; border: 1.5px solid var(--line); border-radius: 16px; padding: 11px 12px 10px; margin: 0 0 4px; }
#place .row { margin: 0; gap: 10px; align-items: center; }
#place .pin { flex: none; width: 34px; height: 34px; border-radius: 11px; background: color-mix(in srgb, var(--you) 16%, #fff)
  url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%231d1a17' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 21s-6.5-5.6-6.5-11a6.5 6.5 0 0113 0c0 5.4-6.5 11-6.5 11z'/%3E%3Ccircle cx='12' cy='10' r='2.3'/%3E%3C/svg%3E") center / 20px no-repeat; }
#place .pl { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.2; }
#placeLabel { font-size: 17px; font-weight: 800; letter-spacing: -0.2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#placeAt { font-size: 12px; font-variant-numeric: tabular-nums; }
#place #rating { margin: 9px 0 0; padding-top: 8px; border-top: 1px dashed var(--line); min-height: 0; }
#place #rating:empty { display: none; }
#place #rating button { border-radius: 999px; padding: 4px 12px; font-weight: 600; }
#place .hint { font-size: 12.5px; margin: 7px 0 0; }
button.mini { border-radius: 999px; padding: 5px 11px; font-weight: 600; }

/* each choice is one switch: a soft trough, the chosen part lifted out of it */
.panel .cap { margin: 13px 2px 0; }
.panel .row.seg { margin: 5px 0 0; gap: 3px; padding: 3px; background: #efe8da; border-radius: 13px; }
.panel .seg button { border: 0; background: transparent; border-radius: 10px; padding: 7px 4px; color: #5d554b; min-width: 0; }
.panel .seg button:hover { background: rgba(255, 255, 255, 0.55); }
.panel .seg button.on, .panel .seg button.on:hover { background: #fff; color: var(--ink); box-shadow: 0 1px 4px rgba(45, 30, 12, 0.2), inset 0 0 0 2px var(--you); }
#colors { margin: 14px 2px 4px; gap: 8px; }
#colors span { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; margin-right: 4px; }
#colors button { width: 22px; height: 22px; }
#colors em { margin-left: 4px; }

/* play: always in sight at the foot of the panel */
#continueBtn { margin: 14px 0 0; }
#goBtn { position: sticky; bottom: 12px; z-index: 3; margin: 14px 0 10px; height: 56px; padding: 0; font-size: 21px; letter-spacing: -0.2px; border: 0; border-radius: 16px;
  background: linear-gradient(180deg, color-mix(in srgb, var(--you) 88%, #fff), var(--you) 55%, color-mix(in srgb, var(--you) 88%, #000));
  box-shadow: 0 0 0 12px var(--paper), 0 6px 16px color-mix(in srgb, var(--you) 45%, transparent), inset 0 -3px 0 rgba(0, 0, 0, 0.18), inset 0 1.5px 0 rgba(255, 255, 255, 0.35); text-shadow: 0 1px 0 rgba(0, 0, 0, 0.18); }
#goBtn span { display: inline-flex; align-items: center; gap: 10px; }
#goBtn span::before { content: ''; width: 0; height: 0; border: 9px solid transparent; border-left: 14px solid #fff; border-right: 0; filter: drop-shadow(0 1px 0 rgba(0, 0, 0, 0.18)); }
#goBtn:hover { filter: brightness(1.05); }
#goBtn:active { transform: translateY(2px); }

/* the rest: the daily map as a card, two quiet buttons, two links */
#dailyBtn { border-radius: 16px; padding: 10px 13px; margin-top: 0; }
.cont { border-radius: 16px; }
.row.two button { background: transparent; border: 1.5px solid #d8cfbd; border-radius: 12px; padding: 8px 6px; font-weight: 600; }
.row.two button:hover { background: #fff; border-color: var(--you); }
.links { display: flex; justify-content: center; gap: 18px; margin-top: 6px; }
.linkish, .fbOpen.linkish { background: none; border: 0; padding: 4px 0; font-size: 13px; color: var(--muted); text-decoration: underline; text-underline-offset: 2px; }
.linkish:hover { color: var(--ink); }

/* place chips along the bottom of the map */
@media (min-width: 900px) {
  #presets { left: 436px; }
  #presets button { border: 0; padding: 7px 13px; border-radius: 999px; font-weight: 600; background: rgba(255, 250, 242, 0.97); box-shadow: 0 3px 10px rgba(45, 30, 12, 0.22), 0 0 0 1px rgba(45, 30, 12, 0.06); }
  #presets button:hover { transform: translateY(-2px); box-shadow: 0 6px 14px rgba(45, 30, 12, 0.26), 0 0 0 2px var(--you); }
  #presets button.dice { background: var(--you); color: #fff; }
}

#welcome h2 { display: flex; align-items: center; gap: 12px; }
#welcome .logo { width: 46px; height: 46px; border-radius: 12px; }

@media (max-width: 760px) {
  .panel { width: 100%; padding: 0 14px calc(10px + env(safe-area-inset-bottom)); border-radius: 22px 22px 0 0; }
  .panel h1 { margin: 0; padding: 0 0 10px; background: none; font-size: 24px; gap: 10px; }
  .panel h1 small { font-size: 12px; }
  .logo { width: 44px; height: 44px; border-radius: 12px; }
  #goBtn { bottom: 0; margin: 10px 0 6px; height: 52px; }
  #progress:not(:empty) { bottom: 64px; }
  .panel.low { max-height: 212px; } /* the handle, the name, the search, Play */
}

#pauseBtn { gap: 5px; } /* the bars and the word (a flex box swallows the space between them) */
/* a low, wide screen (a phone on its side): the head of the start panel is small, so the place and Play here fit */
@media (max-height: 520px) and (min-width: 761px) {
  .panel { width: min(340px, calc(100vw - 32px)); top: 8px; left: 8px; max-height: calc(100vh - 16px); max-height: calc(100dvh - 16px); padding: 0 12px 10px; border-radius: 18px; }
  .panel h1 { margin: 0 -12px; padding: 10px 12px 0; font-size: 22px; gap: 9px; }
  .panel h1 small { font-size: 11.5px; }
  .logo { width: 38px; height: 38px; border-radius: 10px; }
  .panel .sub { display: none; }
  #start > .row:nth-of-type(1) { margin: 8px 0 6px; }
  #start .srch input { height: 38px; }
  #searchBtn { height: 28px; top: 5px; }
  #presets { flex-wrap: nowrap; overflow-x: auto; max-height: none; margin: 6px 0; scrollbar-width: none; }
  #presets button { flex: none; white-space: nowrap; }
  #place { padding: 8px 10px; }
  #place .hint { display: none; }
  #goBtn { height: 46px; font-size: 18px; margin: 10px 0 8px; bottom: 6px; }
}

/* ---------- the match screen, tidied: a rounder face for names and numbers, numbers as tiles, a bar that reads at a glance ---------- */
:root { --display: 'Fredoka', 'Rubik', system-ui, sans-serif; }
.panel h1, #placeLabel, .big, #modal h2, #welcome h2, #helpBox h2, #pause h2, #choice h2, #fbBox h2, #replayBox h2, #tut h3, #bandCard h3,
.stat b, #wonder b, #build button b, #halls button b, #squads button b, #stand .ld, #ages .goal, #right h4, .cont b, #modalKpis b, #presets button.dice { font-family: var(--display); }
.panel h1 { font-weight: 700; letter-spacing: -0.3px; font-size: 33px; }
.big, #goBtn { font-weight: 700; letter-spacing: 0; }
.stat b, #build button b, #halls button b, #stand .ld, #modal h2 { font-weight: 700; }
#right h4 { font-weight: 600; letter-spacing: 0.6px; }

/* messages: a round mark, the words, a count when the same thing happens again */
.toast { display: flex; align-items: center; gap: 8px; border-left: 0; border-radius: 12px; padding: 5px 11px 5px 6px; font-weight: 600; max-width: 340px; }
.toast i { flex: none; width: 22px; height: 22px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-style: normal; font-size: 13px; font-weight: 800; color: #fff; box-shadow: inset 0 0 0 1.5px rgba(29, 26, 23, 0.25); }
.toast i:empty { width: 12px; height: 12px; margin: 0 5px; }
.toast span { min-width: 0; }
.toast em { flex: none; margin-left: auto; font-style: normal; font-size: 12px; font-weight: 800; border-radius: 999px; padding: 0 7px; background: rgba(29, 26, 23, 0.1); }
.toast.bad { background: #fde9e6; color: #7a1c14; box-shadow: var(--shadow), inset 0 0 0 1.5px #f0a79d; }
.toast.bad i { background: #d8402f; box-shadow: none; }
.toast.bad em { background: #d8402f; color: #fff; }

/* standings: the name on one line, a line of land under it with the goal marked, a crown on the leader */
#stand .ag { display: block; padding: 4px 0 5px; }
#stand .ag .l1 { display: flex; align-items: center; gap: 5px; }
#stand .ag .nm { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 12.5px; line-height: 1.3; }
#stand .ag.top .nm::before { content: '\265B'; color: #c99a14; margin-right: 3px; }
#stand .ag u { display: block; position: relative; height: 5px; margin-top: 4px; border-radius: 3px; background: #e9e2d3; text-decoration: none; }
#stand .ag u i { display: block; height: 100%; border-radius: 3px; transition: width 0.6s; }
#stand .ag u s { position: absolute; left: 75%; top: -2px; bottom: -2px; width: 2px; border-radius: 1px; background: var(--ink); }

/* the build bar: every building on its own tint; what you cannot pay for says so on its price */
#build .bi { border-radius: 11px; background: #f1eadc; }
#build button[data-kind=camp] .bi { background: #ffe1c9; }
#build button[data-kind=house] .bi { background: #dcedd3; }
#build button[data-kind=barracks] .bi { background: #f7d6d3; }
#build button[data-kind=tower] .bi { background: #dde2f0; }
#build button[data-kind=infirmary] .bi { background: #fbdfe8; }
#build button[data-kind=dock] .bi { background: #d5e9f4; }
#build button small { border-radius: 999px; padding: 0 8px; background: #f3e6cf; color: #5a4630; font-weight: 600; font-variant-numeric: tabular-nums; }
#build button.poor { opacity: 1; }
#build button.poor small { background: #f9d3ce; color: #8a2016; }
#build button.poor .bi { filter: grayscale(0.7); opacity: 0.65; }
#build kbd { position: absolute; top: 4px; right: 7px; font: 600 10.5px 'Rubik', sans-serif; color: var(--muted); }

/* the end of a match */
#modal .box { width: min(520px, 100%); gap: 10px; padding: 24px 22px 20px; border-radius: 22px; }
#modalFace { height: 92px; }
#modalFace .logo { width: 92px; height: 92px; border-radius: 24px; }
#modalFace .logo.glad { animation: hop 0.9s 0.15s cubic-bezier(0.3, 1.6, 0.5, 1) both; }
#modalFace .logo.sad { filter: saturate(0.6); animation: droop 0.9s 0.15s ease-out both; }
#modalFace .logo .eye { animation: none; }
#modalFace .logo.sad .eye { transform: translateY(9px); }
@keyframes hop { 0% { transform: translateY(26px) scale(0.6); opacity: 0; } 60% { transform: translateY(-10px) scale(1.06); opacity: 1; } 100% { transform: none; opacity: 1; } }
@keyframes droop { 0% { transform: translateY(-14px); opacity: 0; } 100% { transform: rotate(-4deg); opacity: 1; } }
#modal h2 { font-size: 36px; line-height: 1.05; letter-spacing: -0.3px; }
#modal p { margin: 0; font-size: 14.5px; line-height: 1.4; }
#modalKpis { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin: 4px 0 2px; }
#modalKpis span { min-width: 92px; padding: 8px 10px 7px; border-radius: 14px; background: color-mix(in srgb, var(--you) 13%, #fff); font-size: 12px; color: var(--muted); display: flex; flex-direction: column; gap: 1px; }
#modalKpis b { font-size: 24px; font-weight: 700; line-height: 1.1; color: var(--ink); font-variant-numeric: tabular-nums; }
#modalMore { text-align: left; border: 1.5px solid var(--line); border-radius: 12px; padding: 0 10px; background: #fff; }
#modalMore summary { cursor: pointer; padding: 7px 0; font-size: 13px; font-weight: 600; color: var(--muted); list-style-position: inside; }
#modalMore[open] summary { border-bottom: 1px solid var(--line); }
#modal .box > button { border-radius: 12px; padding: 8px 12px; font-weight: 600; }
#modal .box > button.big { padding: 12px; border-radius: 16px; font-weight: 700; }
#shareEnd { border-color: var(--you); background: color-mix(in srgb, var(--you) 10%, #fff); }
@media (prefers-reduced-motion: reduce) { #modalFace .logo { animation: none !important; } }

/* a full-size screen: your numbers as tiles, two by two, the land across the foot; bigger pictures in the build bar */
@media (min-width: 761px) and (min-height: 521px) {
  #top { width: 236px; padding: 10px; gap: 9px; border-radius: 18px; }
  #stock { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
  .stat { gap: 7px; padding: 4px 8px 4px 4px; border-radius: 12px; background: #fff; box-shadow: inset 0 0 0 1.5px var(--line); }
  .stat .lb { display: none; }
  .stat .ic { width: 30px; height: 30px; border-radius: 9px; background: #f1eadc; }
  .stat .ic svg, .stat .ic img { width: 22px; height: 22px; }
  .stat b { font-size: 18px; line-height: 1; }
  .stat small { min-width: 0; margin-left: -3px; font-size: 12px; }
  .s-sup .ic { background: #f6e2c6; }
  .s-wk .ic { background: color-mix(in srgb, var(--you) 22%, #fff); }
  .s-sol .ic { background: #f7d6d3; }
  .s-lm .ic { background: #fbeab0; }
  .s-land { grid-column: 1 / -1; }
  .s-land .ic { background: color-mix(in srgb, var(--you) 18%, #fff); }
  .s-land .lb { display: block; font-weight: 600; }
  .s-land small { margin-left: 4px; text-align: right; line-height: 1.15; font-size: 11px; }
  #share { height: 10px; border-radius: 5px; }
  #build { gap: 7px; }
  #build button { min-width: 84px; padding: 8px 10px 7px; border-radius: 18px; gap: 2px; border-width: 1.5px; }
  #build .bi { width: 44px; height: 44px; padding: 5px; border-radius: 13px; }
  #build .bi svg { width: 34px; height: 34px; }
  #build button b { font-size: 14.5px; }
  #build button small { font-size: 12px; margin-top: 1px; }
}
@media (max-width: 760px), (max-height: 520px) {
  #modalFace, #modalFace .logo { width: 68px; height: 68px; border-radius: 18px; margin: 0 auto; }
  #modalFace { width: auto; }
  #modal h2 { font-size: 27px; }
  #modalKpis span { min-width: 70px; padding: 6px 8px; }
  #modalKpis b { font-size: 19px; }
  .toast { padding: 4px 9px 4px 5px; gap: 6px; max-width: 72vw; }
  .toast i { width: 18px; height: 18px; font-size: 11px; }
}

/* ---------- your own campaign: the card, the screen, the chapter in a match, its end ---------- */
#campBtn { display: flex; align-items: center; gap: 11px; text-align: left; border-radius: 16px; padding: 8px 13px 8px 8px; margin-top: 0; background: color-mix(in srgb, var(--you) 9%, #fff); border-color: color-mix(in srgb, var(--you) 45%, #fff); color: var(--ink); }
#campBtn:hover { border-color: var(--you); }
#campBtn b { display: block; font-family: var(--display); font-weight: 600; font-size: 15.5px; }
#campBtn small { display: block; color: var(--muted); line-height: 1.3; }
#campBtn.fresh { box-shadow: 0 0 0 3px color-mix(in srgb, var(--you) 22%, transparent); }
.cf { flex: none; display: inline-flex; width: 46px; height: 46px; border-radius: 13px; background: color-mix(in srgb, var(--you) 16%, #fff); align-items: center; justify-content: center; }
.cf img { width: 88%; height: 88%; }
.cf.big { width: 96px; height: 96px; border-radius: 24px; }
#camp { position: fixed; inset: 0; z-index: 45; display: flex; align-items: center; justify-content: center; padding: 16px; background: rgba(20, 16, 12, 0.55); }
#camp[hidden] { display: none; }
#camp .box { position: relative; width: min(980px, 100%); max-height: calc(100dvh - 32px); overflow-y: auto; background: var(--paper); border-radius: 22px; padding: 22px 24px; box-shadow: 0 10px 34px rgba(0, 0, 0, 0.4); border-top: 6px solid var(--you); }
#camp h2 { margin: 0 0 4px; font-family: var(--display); font-weight: 700; font-size: 27px; letter-spacing: -0.2px; }
#camp p { margin: 0 0 8px; font-size: 14.5px; line-height: 1.45; }
#camp .cx { position: absolute; top: 12px; right: 12px; width: 34px; height: 34px; border-radius: 50%; padding: 0; font-size: 15px; }
#camp .cap { margin: 12px 0 5px; }
#camp .chead { display: flex; gap: 16px; align-items: center; margin-right: 34px; }
#camp .cnote { margin: 14px 0 10px; padding: 9px 12px; border-radius: 12px; background: #fff8e1; border: 1.5px solid #ecd9a0; font-size: 13.5px; }
.cqs { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 16px; }
.cq label { display: flex; align-items: center; gap: 7px; font-weight: 600; font-size: 14px; margin-bottom: 4px; }
.cq label i, .chs .ch > i { flex: none; width: 22px; height: 22px; border-radius: 50%; background: var(--ink); color: #fff; font-style: normal; font-size: 12px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; }
.cq .row { display: flex; gap: 6px; }
.cq input { flex: 1; min-width: 0; }
.cq .cr { min-height: 22px; margin-top: 3px; font-size: 13px; display: flex; gap: 8px; align-items: center; color: var(--muted); }
.cq .ok { color: #1f7a45; font-weight: 600; }
.cq .no { color: #a3271a; }
.cfoot { display: flex; align-items: center; gap: 14px; margin-top: 16px; font-size: 13px; color: var(--muted); }
.cfoot span { flex: 1; }
.cfoot .big { width: auto; flex: none; padding: 11px 26px; }
.cgrid { display: grid; grid-template-columns: 250px 1fr; gap: 26px; }
.chero { display: flex; flex-direction: column; align-items: stretch; }
.chero .cf.big { width: 132px; height: 132px; border-radius: 32px; align-self: center; margin-bottom: 10px; }
#campName { text-align: center; font-family: var(--display); font-weight: 600; font-size: 17px; }
.cols { display: flex; gap: 6px; flex-wrap: wrap; }
.cols button { width: 26px; height: 26px; padding: 0; border-radius: 50%; background: var(--c); border: 2.5px solid #fff; box-shadow: 0 0 0 1.5px var(--line); }
.cols button.on { box-shadow: 0 0 0 2.5px var(--ink); }
.hats { display: flex; gap: 6px; }
.hats button { flex: 1; padding: 3px; border-radius: 12px; }
.hats img { width: 100%; max-width: 44px; display: block; margin: 0 auto; }
.hats button.on, .nats button.on, .pows button.on { border-color: var(--you); background: color-mix(in srgb, var(--you) 12%, #fff); box-shadow: inset 0 0 0 1px var(--you); }
.nats, .pows { display: flex; flex-direction: column; gap: 5px; }
.nats button, .pows button, .pows span { text-align: left; padding: 6px 10px; border-radius: 11px; }
.nats b, .pows b { display: block; font-size: 13.5px; }
.nats small, .pows small { display: block; color: var(--muted); font-size: 12px; line-height: 1.3; }
.pows span { border: 1.5px dashed var(--line); }
.pows em { font-size: 12.5px; color: var(--muted); line-height: 1.4; }
.cway h2 { display: flex; align-items: baseline; gap: 12px; margin-right: 34px; }
.cway h2 small { font-family: 'Rubik', sans-serif; font-weight: 600; font-size: 14px; color: #c99a14; }
.cmap { display: block; width: 100%; height: auto; max-height: 190px; margin: 4px 0 8px; border-radius: 16px; background: #efe8d8; }
.cmap .now circle { animation: cpulse 1.6s ease-in-out infinite; }
@keyframes cpulse { 50% { stroke-width: 6; stroke: var(--you); } }
.chs { display: flex; flex-direction: column; gap: 6px; }
.chs .ch { display: flex; gap: 10px; align-items: flex-start; padding: 8px 10px; border-radius: 14px; background: #fff; border: 1.5px solid var(--line); }
.chs .ch.cur { border-color: var(--you); box-shadow: 0 0 0 3px color-mix(in srgb, var(--you) 16%, transparent); }
.chs .ch.lock { opacity: 0.55; }
.chs .ch.won > i { background: var(--you); }
.chs .ch > div { flex: 1; min-width: 0; }
.chs .ch b { font-family: var(--display); font-weight: 600; font-size: 15.5px; }
.chs .ch small { display: block; color: var(--muted); font-size: 12.5px; }
.chs .ch p { margin: 5px 0 0; font-size: 13.5px; }
.chs .cr2 { flex: none; display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.chs .cr2 button { padding: 5px 14px; border-radius: 10px; }
.chs .cr2 button.big { padding: 8px 22px; }
.stars i { font-style: normal; color: #d9d0bd; font-size: 17px; }
.stars i.on { color: #e0a81a; }
.souv { display: inline-block; margin-top: 4px; padding: 1px 9px; border-radius: 999px; background: #f1eadc; font-style: normal; font-size: 12px; font-weight: 600; color: #6a5a3c; }
.souv.gold { background: #fbeab0; color: #7a5a06; box-shadow: inset 0 0 0 1.5px #e0b93a; }
.clinks { display: flex; flex-wrap: wrap; gap: 4px 16px; margin-top: 12px; }
.cload { text-align: center; padding: 18px 8px; max-width: 520px; margin: 0 auto; }
.cload .pl { font-weight: 600; color: var(--muted); }
.cload pre { min-height: 3.6em; margin: 12px 0; font: 12.5px/1.4 'Rubik', sans-serif; color: var(--muted); white-space: pre-wrap; }
/* in a match */
#campGoal { position: fixed; z-index: 5; left: 12px; top: 190px; width: 236px; box-sizing: border-box; padding: 6px 12px 7px; border-radius: 14px; background: var(--paper); box-shadow: var(--shadow); font-size: 13px; line-height: 1.3; border: 1.5px solid var(--you); }
#campGoal b, #campGoal span { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#campGoal span { color: var(--muted); font-variant-numeric: tabular-nums; }
#campGoal[hidden] { display: none; }
#campGoal b { font-family: var(--display); }
#campPow { position: fixed; left: 12px; top: 250px; z-index: 6; display: flex; flex-direction: column; align-items: center; min-width: 92px; padding: 8px 12px; border-radius: 16px; border: 2px solid var(--you); background: color-mix(in srgb, var(--you) 14%, #fff); box-shadow: var(--shadow); }
#campPow[hidden] { display: none; }
#campPow b { font-family: var(--display); font-weight: 600; font-size: 14px; }
#campPow small { color: var(--muted); font-size: 11.5px; }
#campPow:disabled { opacity: 0.6; border-color: var(--line); background: #f1eadc; }
#squads button.hero { border-color: var(--you); background: color-mix(in srgb, var(--you) 12%, #fff); }
.chest { width: 30px; height: 30px; pointer-events: none; }
.chest i { display: block; width: 26px; height: 20px; margin: 6px 2px 0; border-radius: 5px 5px 4px 4px; background: linear-gradient(#f2c94c 0 38%, #1d1a17 38% 46%, #c98a1c 46%); border: 2px solid #1d1a17; box-shadow: 0 0 0 4px rgba(242, 201, 76, 0.35), 0 3px 6px rgba(0, 0, 0, 0.3); animation: chest 1.4s ease-in-out infinite; }
.chest.got { display: none; }
@keyframes chest { 50% { transform: translateY(-4px); box-shadow: 0 0 0 8px rgba(242, 201, 76, 0.18), 0 7px 8px rgba(0, 0, 0, 0.22); } }
/* the end of a chapter */
#modal.camp #shareEnd, #modal.camp #againBtn, #modal.camp #otherBtn, #modal.camp #watchBtn, #modal.camp #dailyLine { display: none; }
#campEnd { display: flex; flex-direction: column; gap: 8px; text-align: center; }
#campEnd[hidden], #campPitch[hidden] { display: none; }
#campEnd .ce1 small { display: flex; flex-wrap: wrap; justify-content: center; gap: 2px 12px; color: var(--muted); font-size: 12.5px; line-height: 1.35; }
#campEnd .ce1 small .ok { color: #1f7a45; font-weight: 600; }
#modalFace .cf.big { width: 92px; height: 92px; }
#modalFace .cf.glad { animation: hop 0.9s 0.15s cubic-bezier(0.3, 1.6, 0.5, 1) both; }
#modalFace .cf.sad { filter: saturate(0.55); animation: droop 0.9s 0.15s ease-out both; }
#campEnd .ce1 .stars i { font-size: 30px; }
#campEnd .souv { align-self: center; font-size: 13px; padding: 3px 12px; }
#campEnd .cap { margin: 4px 0 0; }
.offers { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; }
.offers button { text-align: left; padding: 9px 10px; border-radius: 14px; display: flex; flex-direction: column; gap: 3px; border-color: color-mix(in srgb, var(--you) 45%, #fff); }
.offers button:hover { border-color: var(--you); background: color-mix(in srgb, var(--you) 9%, #fff); }
.offers b { font-family: var(--display); font-weight: 600; font-size: 15px; }
.offers small { font-size: 12.5px; line-height: 1.3; }
.offers em { font-style: normal; font-size: 11px; color: var(--muted); line-height: 1.3; }
#campEnd .took, #campEnd .fin { font-size: 13.5px; margin: 0; }
#campPitch { display: flex; flex-direction: column; gap: 1px; border-radius: 14px; border-color: color-mix(in srgb, var(--you) 45%, #fff); background: color-mix(in srgb, var(--you) 9%, #fff); }
#campPitch small { color: var(--muted); }
@media (max-width: 760px), (max-height: 520px) {
  #camp { padding: 8px; }
  #camp .box { padding: 16px 14px; max-height: calc(100dvh - 16px); border-radius: 18px; }
  #camp h2 { font-size: 22px; }
  .cqs { grid-template-columns: 1fr; }
  .cgrid { grid-template-columns: 1fr; gap: 14px; }
  .chero .cf.big { width: 96px; height: 96px; border-radius: 24px; }
  .nats, .pows { flex-direction: row; flex-wrap: wrap; }
  .nats button, .pows button, .pows span { flex: 1 1 140px; }
  .cfoot { flex-direction: column; align-items: stretch; }
  .cfoot .big { margin-left: 0; }
  .cf.big { width: 72px; height: 72px; border-radius: 18px; }
  .offers { grid-template-columns: 1fr; }
  #campGoal { position: static; width: auto; font-size: 11.5px; padding: 2px 10px; border-radius: 999px; }
  #campGoal b, #campGoal span { display: inline; }
  #campGoal span::before { content: ' \00b7 '; }
  #modalFace .cf.big { width: 68px; height: 68px; }
  #campPow { left: auto; right: 8px; bottom: auto; top: 50%; min-width: 0; padding: 6px 9px; }
}

/* night (one chapter of the campaign): a dark sheet over the map, under the creatures, with holes where yours see */
#night { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; mix-blend-mode: multiply; }
#night[hidden] { display: none; }

/* the start panel in a low window (.tight, set by fitStart): the same things, closer together */
.cards { display: flex; flex-direction: column; }
.panel.tight .sub, .panel.tight #place .hint, .panel.tight .seg button small, .panel.tight .cards small { display: none; }
.panel.tight h1 { padding-top: 13px; }
.panel.tight > .row:nth-of-type(1) { margin: 10px 0 8px; }
.panel.tight .cap { margin-top: 8px; }
.panel.tight .seg button { padding: 6px 4px; }
.panel.tight #goBtn { height: 50px; margin: 10px 0 8px; }
.panel.tight .cards { flex-direction: row; gap: 6px; }
.panel.tight .cards .cont { flex: 1 1 0; min-width: 0; margin: 0 0 6px; padding: 6px 9px; font-size: 13.5px; line-height: 1.25; }
.panel.tight #campBtn b { font-size: 13.5px; }
.panel.tight #campBtn .cf { width: 34px; height: 34px; border-radius: 10px; }
.panel.tight .row.two { margin-top: 0; }
.panel.tight .links { margin-top: 4px; }
.panel.tight .opts { display: grid; grid-template-columns: 1fr 1fr; grid-template-rows: repeat(4, auto); grid-auto-flow: column; column-gap: 8px; }
.panel.tight .opts .seg button { font-size: 12.5px; padding: 6px 1px; white-space: nowrap; }
.panel.tight #campBtn small, .panel.tight #dailyBtn small { display: none; }
.panel.tight .cards .cont { display: flex; align-items: center; }
.panel.tight #dailyBtn { display: block; }
.panel.tight #modes button { font-size: 11.5px; }
.panel.tight #modes button { font-size: 11px; letter-spacing: -0.2px; }

/* the campaign's five places: a short name, and under it what is asked */
.cq label span { display: flex; flex-direction: column; font-weight: 400; font-size: 12.5px; color: var(--muted); line-height: 1.25; }
.cq label span b { font-family: var(--display); font-weight: 600; font-size: 15.5px; color: var(--ink); }
.cq label i { align-self: flex-start; margin-top: 1px; }

/* the briefing before a chapter */
.cload .brief { list-style: none; margin: 12px auto; padding: 10px 14px; max-width: 440px; text-align: left; border-radius: 14px; background: #fff; border: 1.5px solid var(--line); font-size: 13.5px; line-height: 1.5; }
.cload button.big { width: auto; padding: 11px 44px; margin: 4px auto 10px; display: block; }
.cload .linkish { display: block; margin: 0 auto; }

/* the place card: one line for what the place is like */
#rating .rt { display: flex; align-items: center; gap: 8px; }
#rating .rt span { flex: 1; min-width: 0; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#place #rating .rt button { flex: none; margin: 0; padding: 3px 11px; font-size: 12.5px; }
#rating .st { font-size: 15px; letter-spacing: 0; }
/* the campaign's own buttons under the chapters */
.clinks { gap: 6px; }
.clinks button { padding: 5px 12px; border-radius: 999px; font-size: 13px; font-weight: 600; background: transparent; }
.clinks button:hover { background: #fff; border-color: var(--you); }
#campName { flex: none; height: 42px; }

/* the campaign's places on a real map (the drawing stays under it until the map is there) */
.cmapbox { position: relative; height: 210px; margin: 4px 0 8px; border-radius: 16px; overflow: hidden; background: #efe8d8; }
.cmapbox .cmap { height: 100%; max-height: none; margin: 0; }
.cmapbox .cmapgl.cmapgl { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; transition: opacity 0.4s; } /* MapLibre's own class would make it relative, and so of no height */
.cmapbox .cmapgl.cmapgl.on { opacity: 1; }
.cpin b { display: block; min-width: 26px; height: 26px; padding: 0 7px; box-sizing: border-box; border-radius: 13px; border: 2.2px solid #1d1a17; background: #fff; color: #1d1a17; font: 700 13px/21.6px 'Rubik', sans-serif; text-align: center; white-space: nowrap; box-shadow: 0 2px 6px rgba(0,0,0,0.3); }
.cpin.won b { background: var(--you); color: #fff; }
.cpin.gold b { border-color: #c99a14; border-width: 3px; line-height: 20px; }
.cpin.now b { animation: cpin 1.6s ease-in-out infinite; }
@keyframes cpin { 0%, 100% { box-shadow: 0 2px 6px rgba(0,0,0,0.3), 0 0 0 0 rgba(29,26,23,0.45); } 50% { box-shadow: 0 2px 6px rgba(0,0,0,0.3), 0 0 0 9px rgba(29,26,23,0); } }
@media (max-width: 760px), (max-height: 520px) { .cmapbox { height: 160px; } }
/* the chosen map size says its length and time beside the heading, in the low panel only */
#scaleHint { display: none; margin-left: 6px; font-weight: 600; text-transform: none; letter-spacing: 0; }
.panel.tight #scaleHint { display: inline; }
