:root { --bg: #e8dcae; --ink: #ffffff; --font: "Archivo", system-ui, sans-serif, "Noto Color Emoji"; --head: "Alfa Slab One", Georgia, serif, "Noto Color Emoji"; --head-weight: 400;
  --bar: #111111; --bar-edge: #000000; --title: #ffcc00; --accent: #ffcc00; --label: #1f4fd0ee; --radius: 4px;
  --chip: #1f4fd0; --chip-edge: #111111; --chip-ink: #fff; --sel: #c89a00; --ctl: #222222; --ctl-edge: #ffcc00; --ctl-ink: #ffffff;
  --card: #fffdf5; --card-ink: #111111; --card-edge: #111111; --heading: #e0201a;
  --btn: #1f4fd0; --btn-ink: #ffffff; --btn-edge: #111111; --cta: #e0201a; --cta-edge: #111111; --cta-ink: #ffffff; }   /* Heraldry, the default look (looks.js sets these again) */
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--ink);
  font: 15px/1.35 var(--font); -webkit-user-select: none; user-select: none;
  -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent; overscroll-behavior: none; touch-action: none; }
* { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
button { touch-action: manipulation; }
.card { touch-action: pan-y; }
#app { position: fixed; inset: 0; display: flex; flex-direction: column; }
#top { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: calc(env(safe-area-inset-top) + 6px) 12px 6px;
  background: var(--bar); border-bottom: 2px solid var(--bar-edge); font-size: 14px; white-space: nowrap; }
#title b { color: var(--title); font: var(--head-weight) 17px var(--head); }
#dayname { opacity: .8; overflow: hidden; text-overflow: ellipsis; }
#title { overflow: hidden; text-overflow: ellipsis; min-width: 0; }
#stats { font-variant-numeric: lining-nums tabular-nums; }
.sq { font-variant-numeric: lining-nums; }
#stage { position: relative; flex: 1; min-height: 0; }
#view { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; outline: none; }
#labels { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.lbl { position: absolute; transform: translate(-50%, -100%); font: 700 11px var(--font); color: #fff; background: var(--label);
  border: 1.5px solid #fff8; border-radius: 9px; padding: 0 5px; line-height: 15px; white-space: nowrap; }
.lbl.sel { background: var(--accent); color: #231a05; border-color: #fff; }
#taps { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.tap { position: absolute; width: 0; height: 0; }
.tap i { position: absolute; left: -22px; top: -22px; width: 44px; height: 44px; border-radius: 50%; border: 3px solid var(--c);
  box-shadow: 0 0 0 2px #0008, inset 0 0 0 2px #0006; animation: tapring .55s ease-out forwards; }
.tap b { position: absolute; left: 0; top: -40px; transform: translateX(-50%); white-space: nowrap; font: 800 13px var(--font); color: var(--c);
  background: #000c; padding: 2px 8px; border-radius: 8px; animation: taplabel .9s ease-out forwards; }
@keyframes tapring { from { transform: scale(.35); opacity: 1; } to { transform: scale(1.25); opacity: 0; } }
@keyframes taplabel { 0%, 60% { opacity: 1; } 100% { opacity: 0; transform: translate(-50%, -8px); } }
#cursortag { position: absolute; pointer-events: none; font: 800 12px var(--font); background: #000c; padding: 2px 7px; border-radius: 7px; white-space: nowrap; }
#hint { position: absolute; left: 50%; top: 10px; transform: translateX(-50%); max-width: 92%; text-align: center;
  background: #000a; color: #fff; padding: 7px 12px; border-radius: 10px; font-weight: 600; pointer-events: none;
  transition: opacity .3s; }
#hint:empty { opacity: 0; }
#replaybar { position: absolute; left: 8px; right: 8px; bottom: 8px; background: #000b; padding: 8px 12px; border-radius: 10px; text-align: center; }
#replaybar a { color: var(--accent); margin-left: 8px; }
#bottom { background: var(--bar); border-top: 2px solid var(--bar-edge); padding: 6px 6px calc(env(safe-area-inset-bottom) + 6px); }
#squads { display: grid; grid-template-columns: repeat(5, 1fr); gap: 5px; padding-bottom: 5px; }
#squads::-webkit-scrollbar { display: none; }
.sq { min-width: 0; height: 46px; border-radius: var(--radius); border: 2px solid var(--chip-edge); background: var(--chip); color: var(--chip-ink);
  font: 600 12px var(--font); display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 0 6px; position: relative; }
.sq .ic { font-size: 18px; line-height: 20px; }
.sq .k { position: absolute; top: 2px; left: 5px; font-size: 10px; opacity: .7; }
.sq.sel { border-color: var(--accent); background: var(--sel); color: #fff; box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 35%, transparent); }
.sq.dead { opacity: .3; }
/* the type reads on the card as on the field: white crest for swords, green for archers, gold for the ram */
.sq[data-type] { --tc: var(--accent); }
.sq[data-type="sword"] { --tc: #f4f1e8; }
.sq[data-type="archer"] { --tc: #3fae4a; background: color-mix(in srgb, var(--chip) 72%, #3fae4a); }
.sq.sel[data-type] { background: var(--sel); }
.sq::after { content: ''; position: absolute; left: 5px; right: 5px; bottom: 3px; height: 4px; border-radius: 2px; background: var(--tc); }
.sq.pulse { animation: pulse 1s infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 5px color-mix(in srgb, var(--accent) 55%, transparent); } }
#controls { display: flex; gap: 6px; justify-content: center; }
#controls button, .sheet button { min-width: 48px; height: 44px; border-radius: var(--radius); border: 2px solid var(--ctl-edge); background: var(--ctl); color: var(--ctl-ink); font: 700 16px var(--font); }
#controls button:active, .sq:active { transform: scale(.96); }
#pause.paused { background: var(--sel); color: #fff; border-color: var(--accent); }
body:not(.touch) .touchonly { display: none; }
body.touch .how .d, body:not(.touch) .how .t { display: none; }
body.defend .how .atk, body:not(.defend) .how .def { display: none; }
#sides { margin: 0 0 10px; }
.sheet button.side { background: transparent; color: var(--card-ink); border-color: var(--card-edge); opacity: .6; }
.sheet button.side.on { background: var(--btn); color: var(--btn-ink); border-color: var(--btn-edge); opacity: 1; }
#pause.pulse, #oil.hot { animation: pulse 1s infinite; }
#oil { white-space: nowrap; padding: 0 8px; }
#oil.hot { border-color: var(--cta); background: var(--cta); color: var(--cta-ink); }
#oil.spent { opacity: .45; }
.sheet { position: fixed; inset: 0; background: #0b0d1499; display: flex; align-items: center; justify-content: center; padding: 14px; z-index: 5; }
.sheet[hidden] { display: none; }
.card { background: var(--card); color: var(--card-ink); border-radius: calc(var(--radius) + 6px); padding: 18px 18px 12px; width: min(420px, 100%); max-height: 100%; overflow: auto;
  box-shadow: 0 10px 40px #0008; border: 3px solid var(--card-edge); }
.card h1 { margin: 0; font: var(--head-weight) 34px/1.1 var(--head); color: var(--heading); letter-spacing: .5px; }
.card h2 { margin: 0 0 6px; font: var(--head-weight) 27px/1.15 var(--head); color: var(--heading); }
.tag { margin: 2px 0 10px; font-weight: 600; }
#castleline { margin: 0 0 8px; }
.drow { display: flex; align-items: center; gap: 8px; margin: 4px 0; }
.drow .nm { flex: 1; font-weight: 600; }
.drow .ct { width: 22px; text-align: center; font-weight: 800; font-size: 18px; }
.drow button { min-width: 44px; height: 40px; }
#goldline { margin: 6px 0 10px; font-weight: 600; }
.sheet button { background: var(--btn); color: var(--btn-ink); border-color: var(--btn-edge); }
.sheet button.big { width: 100%; height: 54px; font: var(--head-weight) 21px var(--head); background: var(--cta); color: var(--cta-ink); border-color: var(--cta-edge); }
.sheet button:disabled { opacity: .4; }
.how { padding-left: 18px; margin: 10px 0 6px; font-size: 14px; }
.how li { margin: 3px 0; }
.credit { font-size: 12px; opacity: .75; margin: 6px 0 0; }
.row { display: flex; gap: 8px; margin: 8px 0; }
.row button { flex: 1; }
#rline { font-size: 17px; font-weight: 600; margin: 4px 0; }
#rtip { font-size: 14px; margin: 4px 0; font-style: italic; }
#rtip:empty { display: none; }
#copied { color: #2a6b2a; font-weight: 700; margin: 4px 0; }
.more { font-size: 13px; text-align: center; margin: 8px 0 2px; }
.more a { color: var(--heading); }
#mark { display: block; font-size: 11px; margin: -6px 0 4px; opacity: .8; }
#more { margin: 8px -8px 0; }
/* The end-screen question and the locked teaser: small, under the buttons, above the studio row. The options sit on
   one line that scrolls sideways, so the row stays in reach. */
#ask { margin-top: 8px; padding-top: 6px; border-top: 2px dashed color-mix(in srgb, var(--card-ink) 30%, transparent); }
#ask .label { margin: 0 0 4px; font-size: 13px; font-weight: 800; }
#votes { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; margin: 0 -8px; padding: 0 8px 4px; }
#votes::-webkit-scrollbar { display: none; }
#votes button, #want { flex: none; white-space: nowrap; height: auto; min-height: 44px; padding: 6px 10px; border: 2px solid var(--card-edge); border-radius: var(--radius); background: #fff; color: var(--card-ink); font: 700 13px var(--font); cursor: pointer; }
#want { display: block; width: 100%; margin-top: 6px; border-style: dashed; text-align: left; white-space: normal; }
#want[hidden], #ask[hidden], #asknote[hidden] { display: none; }
#want u { text-decoration: none; font-size: 10px; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; padding: 1px 5px; border-radius: 4px; border: 1.5px solid var(--card-ink); margin-right: 4px; }
#asknote { font-size: 13px; margin: 6px 0 0; }
#asknote a { color: inherit; }
@media (min-width: 700px) { #result .card { width: min(600px, 100%); } }   /* the studio row's cards side by side */
/* desktop: squads and controls move to a side panel when there's room */
@media (min-width: 900px) and (min-aspect-ratio: 1/1) {
  #app { display: grid; grid-template-columns: 210px 1fr; grid-template-rows: auto 1fr; }
  #top { grid-column: 1 / 3; }
  #stage { grid-column: 2; grid-row: 2; }
  #bottom { grid-column: 1; grid-row: 2; border-top: 0; border-right: 2px solid var(--bar-edge); display: flex; flex-direction: column; gap: 10px; padding: 10px; }
  #squads { display: flex; flex-direction: column; overflow: visible; }
  .sq { flex-direction: row; justify-content: flex-start; gap: 8px; width: 100%; height: 44px; }
  .sq .k { position: static; font-size: 12px; }
  #controls { flex-wrap: wrap; justify-content: flex-start; }
}
#sides[hidden] { display: none; }

/* Grand Siege */
#grandrow[hidden], #grandany[hidden] { display: none; }
#grandrow { margin: 8px 0 0; }
.sheet button#grand.on { background: var(--btn); color: var(--btn-ink); border-color: var(--btn-edge); opacity: 1; }
#grandany { margin: 8px 0 0; font-size: 12px; opacity: .75; }
#grandany a { color: inherit; }
#box { position: absolute; border: 1.5px solid #8fc1ff; background: #8fc1ff22; pointer-events: none; }
#box[hidden] { display: none; }
