:root {
  --ink: #1b2219;
  --panel: #232c20;
  --panel-2: #2e3a2a;
  --line: #45543d;
  --text: #efe9d6;
  --quiet: #a9b29a;
  --amber: #f1b441;
  --amber-deep: #b97a1c;
  --sap: #8fd14f;
  --red: #e2553d;
  --r: 6px;
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #2b3a2a; color: var(--text);
  font: 15px/1.35 ui-rounded, "SF Pro Rounded", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-variant-numeric: tabular-nums; overscroll-behavior: none; user-select: none; -webkit-user-select: none; }
canvas#ground { position: fixed; inset: 0; width: 100%; height: 100%; touch-action: none; display: block; }
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; padding: 0; }
button:disabled { opacity: .4; cursor: default; }
small { color: var(--quiet); font-size: 12px; font-weight: 500; }
[hidden] { display: none !important; }

/* what you hold */
i.amber, i.sap, i.cup { display: inline-block; width: 11px; height: 11px; margin-right: 5px; vertical-align: -1px; }
i.amber { background: var(--amber); transform: rotate(45deg) scale(.85); box-shadow: inset -2px -2px 0 var(--amber-deep); }
i.sap { background: var(--sap); border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%; box-shadow: inset -2px -2px 0 #5d9a2b; }
i.cup { background: #e9e4d4; clip-path: polygon(50% 0, 62% 36%, 100% 38%, 70% 60%, 80% 100%, 50% 76%, 20% 100%, 30% 60%, 0 38%, 38% 36%); }

#top { position: fixed; top: 0; left: 0; right: 0; display: flex; justify-content: space-between; align-items: center; gap: var(--s2);
  padding: calc(var(--s2) + env(safe-area-inset-top)) var(--s3) var(--s2); pointer-events: none;
  background: linear-gradient(#1b2219cc, #1b221900); }
#who { pointer-events: auto; font-weight: 700; font-size: 16px; text-shadow: 0 1px 0 #0008; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#purse { display: flex; gap: var(--s2); font-weight: 700; }
#purse span { background: #1b2219d9; border: 1px solid var(--line); border-radius: var(--r); padding: 3px 9px; white-space: nowrap; }
#purse .stars, .stars { color: var(--amber); letter-spacing: 1px; }

#foot { position: fixed; left: 0; right: 0; bottom: 0; padding: var(--s2) var(--s3) calc(var(--s3) + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: var(--s2); background: linear-gradient(#1b221900, #1b2219e6 45%); pointer-events: none; }
#foot > * { pointer-events: auto; }
#row { display: flex; gap: var(--s2); overflow-x: auto; scrollbar-width: none; align-items: center; min-height: 36px; max-width: 720px; width: 100%; margin: 0 auto; }
#row::-webkit-scrollbar { display: none; }
#bar { display: flex; gap: var(--s2); max-width: 720px; width: 100%; margin: 0 auto; }

.big { flex: 1; height: 52px; border-radius: var(--r); background: var(--amber); color: #2a1c05; font-weight: 800; font-size: 18px;
  box-shadow: 0 4px 0 var(--amber-deep); transition: transform .06s; }
.big:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--amber-deep); }
.side { height: 52px; min-width: 64px; padding: 0 var(--s4); border-radius: var(--r); background: var(--panel-2); border: 1px solid var(--line);
  font-weight: 700; box-shadow: 0 4px 0 #161c14; }
.side:active { transform: translateY(3px); box-shadow: 0 1px 0 #161c14; }

.chip { flex: none; height: 36px; padding: 0 var(--s3); border-radius: var(--r); background: #1b2219e6; border: 1px solid var(--line); font-weight: 600; white-space: nowrap; }
.chip.go { border-color: var(--amber); color: var(--amber); }
.chip.go span { color: var(--text); margin-left: 4px; }
.chip.off { display: inline-flex; align-items: center; color: var(--quiet); }
.chip.quiet { border-color: transparent; color: var(--quiet); background: none; }
.label { flex: none; font-weight: 700; padding: 0 var(--s1); text-shadow: 0 1px 0 #000a; }

/* the shop and the troop bar: one row of cards */
#row.shop, #row.troops { align-items: stretch; }
.card { flex: none; width: 92px; padding: var(--s2) var(--s1) var(--s2); border-radius: var(--r); background: #1b2219f0; border: 1px solid var(--line);
  display: flex; flex-direction: column; align-items: center; gap: 2px; text-align: center; }
.card img { width: 56px; height: 56px; object-fit: contain; image-rendering: auto; }
.card b { font-size: 12px; font-weight: 700; white-space: nowrap; }
.card span { font-size: 13px; font-weight: 700; }
.card.on { border-color: var(--amber); background: #3a3320f0; box-shadow: inset 0 0 0 1px var(--amber); }
#row.troops .card { width: 68px; }
#row.troops .card img { width: 44px; height: 44px; }
#row.troops .card small { font-size: 13px; color: var(--text); font-weight: 700; }
.card.brush { justify-content: center; width: 56px !important; }
.card.brush b { font-size: 17px; }

#hint { position: fixed; left: 50%; bottom: calc(158px + env(safe-area-inset-bottom)); transform: translateX(-50%); padding: 5px 12px; border-radius: var(--r);
  background: #1b2219d9; font-weight: 600; font-size: 13px; pointer-events: none; white-space: nowrap; }
#row.shop ~ * { } /* keep */
body:has(#row.shop) #hint { bottom: calc(232px + env(safe-area-inset-bottom)); }
body:has(#row.troops) #hint { bottom: calc(196px + env(safe-area-inset-bottom)); }

#toast { position: fixed; top: calc(52px + env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); max-width: min(92vw, 520px);
  display: flex; gap: var(--s2); align-items: center; flex-wrap: wrap; justify-content: center;
  background: #1b2219f2; border: 1px solid var(--line); border-radius: var(--r); padding: var(--s2) var(--s3); font-weight: 600; z-index: 5; }

#sheet { position: fixed; inset: 0; background: #0b0f0a99; display: flex; align-items: flex-end; justify-content: center; z-index: 10; }
#sheet-in { position: relative; width: min(100%, 520px); max-height: 82vh; overflow-y: auto; background: var(--panel); border: 1px solid var(--line); border-bottom: 0;
  border-radius: 10px 10px 0 0; padding: var(--s5) var(--s4) calc(var(--s5) + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: var(--s2);
  user-select: text; -webkit-user-select: text; }
@media (min-width: 700px) { #sheet { align-items: center; } #sheet-in { border-radius: 10px; border-bottom: 1px solid var(--line); } }
#sheet-in h2, #result h2 { margin: 0 0 var(--s1); font-size: 20px; line-height: 1.2; }
#sheet-in p { margin: var(--s2) 0 0; color: var(--quiet); }
#sheet-in p.quiet { font-size: 13px; }
.close { position: absolute; top: 6px; right: 10px; width: 36px; height: 36px; font-size: 24px; color: var(--quiet); }
.line { display: flex; justify-content: space-between; align-items: center; gap: var(--s2); min-height: 48px; padding: var(--s1) 0; border-bottom: 1px solid var(--line);
  font-weight: 700; font-size: 16px; text-align: left; width: 100%; }
.line:last-child { border-bottom: 0; }
.line > span:last-child { display: flex; gap: var(--s1); }
.copy { display: flex; gap: var(--s2); align-items: center; }
.copy code { flex: 1; min-width: 0; background: var(--ink); border: 1px solid var(--line); border-radius: var(--r); padding: 8px 10px; font: 12px/1.4 ui-monospace, Menlo, monospace;
  overflow-x: auto; white-space: nowrap; scrollbar-width: none; }
.members { display: flex; flex-wrap: wrap; gap: var(--s1) var(--s3); font-weight: 700; }
.says { max-height: 34vh; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; padding: var(--s2) 0; border-top: 1px solid var(--line); margin-top: var(--s2); }
#sheet-in .says p { margin: 0; color: var(--text); }
.says b { color: var(--amber); }
.suggest { display: flex; gap: var(--s2); overflow-x: auto; scrollbar-width: none; }
.say { display: flex; gap: var(--s2); }
.say input { flex: 1; min-width: 0; height: 40px; background: var(--ink); color: var(--text); border: 1px solid var(--line); border-radius: var(--r); padding: 0 var(--s3); font: inherit; }
.say .chip { height: 40px; }

#result { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; background: #0b0f0a80; z-index: 8; padding: var(--s4); }
#result .card { width: min(100%, 360px); padding: var(--s5) var(--s4) var(--s4); gap: var(--s3); background: var(--panel); border-radius: 10px; }
#result .stars.huge { font-size: 46px; line-height: 1; letter-spacing: 4px; }
#result .stars.huge span { color: var(--line); }
#result .loot { margin: 0; display: flex; gap: var(--s4); font-size: 20px; font-weight: 800; }
#result .loot span { font-size: 20px; }
#result .big { width: 100%; flex: none; }
#result .under { display: flex; gap: var(--s2); flex-wrap: wrap; justify-content: center; }

h2.crest { display: flex; align-items: center; gap: var(--s2); }
h2.crest img { width: 44px; height: 44px; object-fit: contain; }
h2.crest small { margin-left: var(--s1); }
#sheet-in .says p.quiet { color: var(--quiet); }
#sheet-in h2 { padding-right: 36px; }
a.chip.link { display: inline-flex; align-items: center; text-decoration: none; align-self: flex-start; }
