/* Big War — UI chrome. The world itself is painted by shaders; everything here
   is the marginalia: ledgers, plaques, commissions. Ink on paper, no chrome. */

:root {
  --ink: #2a2016;
  --ink-soft: #4a3a28;
  --ink-faint: #6b5a44;
  --paper: #e9dcbd;
  --paper-hi: #f2e8cf;
  --paper-lo: #d8c69f;
  --blood: #8e2f32;
  --brass: #a8863c;
  --shadow: 0 2px 6px rgba(20, 12, 4, .45), 0 12px 32px rgba(20, 12, 4, .35);
  --serif: 'Cormorant Garamond', 'Palatino Linotype', Georgia, serif;
  --display: 'IM Fell English SC', 'Cormorant Garamond', Georgia, serif;
  --body: 'IM Fell English', 'Cormorant Garamond', Georgia, serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;   /* no pull-to-refresh over the war table */
  background: #1b120a;
  font-family: var(--body);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

canvas#gl, canvas#overlay {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  height: 100dvh;   /* the true viewport, under a mobile browser's moving bars */
  display: block;
}
canvas#gl { touch-action: none; }   /* the game owns every gesture on the map */
canvas#overlay { pointer-events: none; }

/* ---------------------------------------------------------------- paper card */

.paper-card {
  background:
    radial-gradient(120% 90% at 30% 12%, rgba(255, 250, 230, .55), rgba(255, 250, 230, 0) 60%),
    linear-gradient(168deg, var(--paper-hi), var(--paper) 45%, var(--paper-lo));
  border: 1px solid rgba(64, 44, 20, .55);
  outline: 1px solid rgba(240, 228, 190, .5);
  outline-offset: -4px;
  box-shadow: var(--shadow);
  position: relative;
}
.paper-card::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: .5;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' seed='7'/%3E%3CfeColorMatrix values='0 0 0 0 0.42 0 0 0 0 0.35 0 0 0 0 0.24 0 0 0 0.16 0'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ---------------------------------------------------------------- HUD */

#hud { position: fixed; inset: 0; pointer-events: none; z-index: 10; }
#hud > * { pointer-events: auto; }
/* a long finger-press must not summon the text magnifier */
#hud, canvas#gl {
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

#plaque {
  position: absolute;
  top: 18px;
  left: 22px;
  padding: 10px 22px 12px;
  text-align: center;
  background: linear-gradient(165deg, #3d2c1a, #241708 60%, #2e2010);
  border: 1px solid #140c04;
  outline: 1px solid rgba(198, 160, 92, .6);
  outline-offset: -4px;
  box-shadow: var(--shadow), inset 0 1px 0 rgba(220, 180, 110, .25);
  color: #cfa860;
  pointer-events: none;
  user-select: none;
}
#plaque h1 {
  font-family: var(--display);
  font-size: 26px;
  letter-spacing: .22em;
  font-weight: 400;
  text-shadow: 0 1px 0 rgba(0,0,0,.8), 0 0 18px rgba(255,190,90,.18);
}
#plaque .sub {
  font-family: var(--serif);
  font-style: italic;
  font-size: 13px;
  letter-spacing: .14em;
  color: #9b7d48;
  margin-top: 1px;
}

/* ---------------------------------------------------------------- ledger */

#ledger {
  position: absolute;
  top: 18px;
  right: 22px;
  width: 236px;
  padding: 14px 16px 12px;
  user-select: none;
}
#ledger {
  background:
    radial-gradient(120% 90% at 30% 12%, rgba(255, 250, 230, .55), rgba(255, 250, 230, 0) 60%),
    linear-gradient(168deg, var(--paper-hi), var(--paper) 45%, var(--paper-lo));
  border: 1px solid rgba(64, 44, 20, .55);
  outline: 1px solid rgba(140, 110, 60, .35);
  outline-offset: -5px;
  box-shadow: var(--shadow);
}
#ledger h2 {
  font-family: var(--display);
  font-weight: 400;
  font-size: 15px;
  letter-spacing: .18em;
  text-align: center;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(64, 44, 20, .4);
  margin-bottom: 8px;
}
#ledger ol { list-style: none; }
#ledger li {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-family: var(--serif);
  font-size: 15.5px;
  padding: 2.5px 0;
  border-bottom: 1px dotted rgba(64, 44, 20, .25);
}
#ledger li:last-child { border-bottom: none; }
#ledger li .dot {
  width: 11px; height: 11px;
  border-radius: 50%;
  align-self: center;
  flex: none;
  box-shadow: inset 0 -2px 3px rgba(0,0,0,.45), inset 0 1px 1px rgba(255,255,255,.3), 0 0 0 1px rgba(40,25,10,.5);
}
#ledger li .lname {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
#ledger li .lname .bot { font-style: italic; opacity: .55; font-size: .8em; margin-left: 3px; }
#ledger li .share { font-variant-numeric: tabular-nums; color: var(--ink-soft); }
#ledger li .vmark {
  width: 12px; height: 12px;
  flex: none;
  align-self: center;
  fill: currentColor;
  color: #8a6a26;
  opacity: .9;
}
#ledger li.dead { opacity: .45; }
#ledger li.dead .lname { text-decoration: line-through; }
#ledger li.me .lname { font-weight: 600; }

/* the war council — voice chat, one button beneath the order of battle */
#council-btn {
  display: block;
  width: 100%;
  margin-top: 9px;
  padding: 6px 0 7px;
  font-family: var(--display);
  font-size: 12px;
  letter-spacing: .12em;
  cursor: pointer;
  color: var(--ink-soft);
  background: transparent;
  border: 1px solid rgba(64, 44, 20, .4);
}
#council-btn:hover { color: var(--ink); border-color: rgba(64, 44, 20, .7); }
#council-btn:disabled { opacity: .5; cursor: default; }
#council-btn.in {
  color: #6e5420;
  border-color: rgba(138, 106, 38, .8);
  background: rgba(176, 141, 62, .14);
}

/* ---------------------------------------------------------------- dispatch bar */

#dispatch {
  position: absolute;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  pointer-events: none;
  user-select: none;
}
#me {
  pointer-events: auto;   /* the dispatch container is inert; the bar is not */
  display: flex;
  align-items: center;
  white-space: nowrap;
  flex-wrap: nowrap;
  gap: 10px;
  padding: 7px 20px;
  font-family: var(--serif);
  font-size: 17px;
  background:
    linear-gradient(168deg, var(--paper-hi), var(--paper) 45%, var(--paper-lo));
  border: 1px solid rgba(64, 44, 20, .55);
  box-shadow: var(--shadow);
}
#me-seal {
  width: 15px; height: 15px;
  border-radius: 50%;
  box-shadow: inset 0 -2px 3px rgba(0,0,0,.5), inset 0 1px 1px rgba(255,255,255,.3), 0 0 0 1px rgba(40,25,10,.5);
}
#me-name { font-weight: 600; letter-spacing: .02em; }
#me-stats { color: var(--ink-soft); font-variant-numeric: tabular-nums; }

#me-progress {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-left: 6px;
  padding-left: 12px;
  border-left: 1px solid rgba(64, 44, 20, .3);
}
#me-progress i {
  display: block;
  width: 110px;
  height: 7px;
  background: rgba(64, 44, 20, .18);
  box-shadow: inset 0 1px 1px rgba(40, 25, 10, .3);
  position: relative;
  overflow: hidden;
}
#me-progress i::after {
  content: '';
  position: absolute;
  inset: 0;
  width: var(--p, 0%);
  background: linear-gradient(to bottom, #b08d3e, #8a6a26);
  transition: width .4s ease;
}
#me-progress b {
  font-size: 13px;
  font-weight: 500;
  font-style: italic;
  color: var(--ink-faint);
  white-space: nowrap;
}

#qm-toggle {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-left: 6px;
  padding-left: 12px;
  border-left: 1px solid rgba(64, 44, 20, .3);
  font-size: 13.5px;
  font-style: italic;
  color: var(--ink-faint);
  cursor: pointer;
  user-select: none;
}
#qm-toggle:hover { color: var(--ink); }
#qm-toggle input { accent-color: #8a6a26; cursor: pointer; }

/* ---------------------------------------------------------------- first orders */

#orders-card {
  position: absolute;
  top: 108px;
  left: 22px;
  width: 264px;
  padding: 14px 16px 14px;
  background:
    radial-gradient(120% 90% at 30% 12%, rgba(255, 250, 230, .55), rgba(255, 250, 230, 0) 60%),
    linear-gradient(168deg, var(--paper-hi), var(--paper) 45%, var(--paper-lo));
  border: 1px solid rgba(64, 44, 20, .55);
  outline: 1px solid rgba(140, 110, 60, .35);
  outline-offset: -5px;
  box-shadow: var(--shadow);
  font-family: var(--serif);
  animation: folio-in .5s cubic-bezier(.2, .9, .25, 1.1);
}
#orders-card h3 {
  font-family: var(--display);
  font-weight: 400;
  font-size: 14px;
  letter-spacing: .18em;
  text-align: center;
  padding-bottom: 6px;
  border-bottom: 1px solid rgba(64, 44, 20, .4);
  margin-bottom: 8px;
}
#orders-card ol {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 7px;
  font-size: 14.5px;
  line-height: 1.35;
  color: var(--ink-soft);
}
#orders-card ol b { color: var(--ink); }
#orders-card .key {
  font-style: italic;
  white-space: nowrap;
}
#orders-card .key::before {
  content: '';
  display: inline-block;
  width: 9px; height: 9px;
  border-radius: 50%;
  margin: 0 3px -1px 1px;
  border: 1.5px dashed currentColor;
}
#orders-card .key.green { color: #2d5c37; }
#orders-card .key.red { color: #7a2b2b; }
#orders-card button {
  display: block;
  margin: 10px auto 0;
  font-family: var(--display);
  font-size: 12px;
  letter-spacing: .12em;
  padding: 6px 18px;
  cursor: pointer;
  color: var(--ink-soft);
  background: transparent;
  border: 1px solid rgba(64, 44, 20, .4);
}
#orders-card button:hover { color: var(--ink); border-color: rgba(64, 44, 20, .7); }
#hint {
  font-family: var(--serif);
  font-style: italic;
  font-size: 14.5px;
  color: rgba(240, 228, 198, .95);
  background: rgba(28, 18, 8, .55);
  padding: 3px 14px 4px;
  border: 1px solid rgba(198, 160, 92, .25);
  text-shadow: 0 1px 3px rgba(10, 5, 0, .9);
  letter-spacing: .03em;
}

/* ---------------------------------------------------------------- toasts */

#toasts {
  position: absolute;
  left: 22px;
  bottom: 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  pointer-events: none;
}
.toast {
  font-family: var(--serif);
  font-style: italic;
  font-size: 15px;
  color: rgba(233, 220, 189, .9);
  text-shadow: 0 1px 3px rgba(10, 5, 0, .95);
  animation: toast-in .35s ease-out, toast-out .8s ease-in 4.2s forwards;
  max-width: 340px;
}
.toast b { font-style: normal; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }
@keyframes toast-out { to { opacity: 0; } }

/* ---------------------------------------------------------------- veils & folios */

.veil {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  background: radial-gradient(90% 90% at 50% 42%, rgba(28, 17, 6, .62), rgba(12, 6, 1, .88));
  backdrop-filter: blur(2px) sepia(.3);
}
.veil[hidden] { display: none; }

.folio {
  width: min(430px, calc(100vw - 48px));
  padding: 40px 44px 34px;
  text-align: center;
  background:
    radial-gradient(120% 90% at 30% 12%, rgba(255, 250, 230, .6), rgba(255, 250, 230, 0) 60%),
    linear-gradient(168deg, var(--paper-hi), var(--paper) 45%, var(--paper-lo));
  border: 1px solid rgba(64, 44, 20, .6);
  outline: 1px solid rgba(140, 110, 60, .4);
  outline-offset: -7px;
  box-shadow: 0 8px 20px rgba(8, 4, 0, .6), 0 30px 80px rgba(8, 4, 0, .55);
  position: relative;
  animation: folio-in .5s cubic-bezier(.2, .9, .25, 1.15);
}
.folio.narrow { width: min(360px, calc(100vw - 48px)); }
@keyframes folio-in { from { opacity: 0; transform: translateY(14px) rotate(-.4deg); } }

.folio::before {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: .45;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='2' seed='11'/%3E%3CfeColorMatrix values='0 0 0 0 0.4 0 0 0 0 0.33 0 0 0 0 0.22 0 0 0 0.15 0'/%3E%3C/filter%3E%3Crect width='180' height='180' filter='url(%23n)'/%3E%3C/svg%3E");
}

.folio h1 {
  font-family: var(--display);
  font-weight: 400;
  font-size: 44px;
  letter-spacing: .16em;
  color: var(--ink);
}
.folio .tagline {
  font-family: var(--serif);
  font-style: italic;
  font-size: 16px;
  color: var(--ink-faint);
  margin-top: 2px;
}
.folio .rule {
  border: none;
  height: 13px;
  margin: 16px auto 18px;
  width: 70%;
  background:
    radial-gradient(circle at 50% 50%, var(--ink-soft) 1.6px, transparent 2px) center / 13px 13px no-repeat,
    linear-gradient(to right, transparent, var(--ink-soft) 18%, var(--ink-soft) 40%, transparent 46%) center / 100% 1px no-repeat,
    linear-gradient(to left, transparent, var(--ink-soft) 18%, var(--ink-soft) 40%, transparent 46%) center / 100% 1px no-repeat;
}
.folio label {
  display: block;
  font-family: var(--serif);
  font-size: 14px;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin-bottom: 8px;
}
.folio input {
  width: 100%;
  font-family: var(--body);
  font-size: 22px;
  text-align: center;
  color: var(--ink);
  background: transparent;
  border: none;
  border-bottom: 1px solid rgba(64, 44, 20, .55);
  padding: 4px 8px 6px;
  outline: none;
}
.folio input::placeholder { color: rgba(74, 58, 40, .4); font-style: italic; }
.folio input:focus { border-bottom-color: var(--blood); }

.folio button {
  margin-top: 22px;
  font-family: var(--display);
  font-size: 17px;
  letter-spacing: .14em;
  padding: 11px 34px;
  cursor: pointer;
  color: #f0e2c0;
  background: linear-gradient(170deg, #a13a3d, var(--blood) 50%, #6e2225);
  border: 1px solid #4c1517;
  box-shadow: 0 2px 5px rgba(20, 5, 5, .5), inset 0 1px 0 rgba(255, 200, 180, .25);
  transition: transform .12s ease, box-shadow .12s ease, filter .12s ease;
}
.folio button:hover { filter: brightness(1.1); transform: translateY(-1px); box-shadow: 0 4px 10px rgba(20, 5, 5, .55), inset 0 1px 0 rgba(255, 200, 180, .25); }
.folio button:active { transform: translateY(0); filter: brightness(.95); }

.folio button.ghost {
  display: block;
  margin: 12px auto 0;
  background: transparent;
  color: var(--ink-faint);
  border: 1px solid rgba(64, 44, 20, .35);
  box-shadow: none;
  font-size: 13px;
  padding: 7px 22px;
}
.folio button.ghost:hover { color: var(--ink); border-color: rgba(64, 44, 20, .6); transform: none; box-shadow: none; }

.folio .fine {
  margin-top: 22px;
  font-family: var(--serif);
  font-size: 14.5px;
  line-height: 1.5;
  color: var(--ink-soft);
  font-style: italic;
}

/* ---------------------------------------------------------------- the muster */

#lobby-share label {
  margin-top: 2px;
}
#lobby-share .share-row {
  display: flex;
  gap: 8px;
  margin: 2px 0 14px;
}
#lobby-share input {
  flex: 1;
  font-family: var(--serif);
  font-size: 14px;
  text-align: left;
  color: var(--ink-soft);
  background: rgba(255, 252, 240, .5);
  border: 1px solid rgba(64, 44, 20, .35);
  border-bottom: 1px solid rgba(64, 44, 20, .35);
  padding: 6px 10px;
}
#lobby-share button {
  margin: 0;
  font-family: var(--display);
  font-size: 12px;
  letter-spacing: .1em;
  padding: 6px 14px;
  cursor: pointer;
  color: var(--ink-soft);
  background: transparent;
  border: 1px solid rgba(64, 44, 20, .4);
  box-shadow: none;
}
#lobby-share button:hover { color: var(--ink); border-color: rgba(64, 44, 20, .7); transform: none; filter: none; }

#lobby-roll {
  list-style: none;
  margin: 4px auto 10px;
  max-width: 300px;
  text-align: left;
}
#lobby-roll li {
  display: flex;
  align-items: center;
  gap: 9px;
  font-family: var(--serif);
  font-size: 16px;
  padding: 3px 0;
  border-bottom: 1px dotted rgba(64, 44, 20, .25);
}
#lobby-roll li:last-child { border-bottom: none; }
#lobby-roll .dot {
  width: 11px; height: 11px;
  border-radius: 50%;
  flex: none;
  box-shadow: inset 0 -2px 3px rgba(0,0,0,.45), inset 0 1px 1px rgba(255,255,255,.3), 0 0 0 1px rgba(40,25,10,.5);
}
#lobby-roll .lname { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#lobby-roll .stands {
  font-variant: small-caps;
  letter-spacing: .08em;
  font-size: 13.5px;
  color: var(--ink-faint);
  font-style: italic;
}
#lobby-roll li.ready .stands { color: #2d5c37; font-style: normal; }
#lobby-roll li.me .lname { font-weight: 600; }

#lobby-status { margin-top: 4px; }
#lobby-roll .convener { flex: none; color: #8a6a26; font-size: 13px; }
#lobby-bots-row {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  width: 100%;
  margin-top: 12px;
  font-family: var(--serif);
  font-style: italic;
  font-size: 14.5px;
  color: var(--ink-soft);
  cursor: pointer;
  user-select: none;
}
#lobby-bots-row input { accent-color: #8a6a26; cursor: pointer; flex: none; }
#ready-btn.standing {
  background: linear-gradient(170deg, #3f6b49, #2d5c37 50%, #1e4227);
  border-color: #17301d;
}

/* province tooltip */
#prov-tip {
  position: fixed;
  z-index: 20;
  pointer-events: none;
  font-family: var(--serif);
  font-size: 14px;
  padding: 4px 12px 5px;
  color: var(--paper-hi);
  background: rgba(30, 20, 10, .88);
  border: 1px solid rgba(198, 160, 92, .4);
  box-shadow: 0 2px 8px rgba(0,0,0,.5);
  transform: translate(14px, 18px);
  white-space: nowrap;
  opacity: 0;
  transition: opacity .15s ease;
}
#prov-tip .tname { font-variant: small-caps; letter-spacing: .08em; }
#prov-tip .towner { font-style: italic; opacity: .75; }

/* the ledger toggle: a phone's door to the Order of Battle */
#ledger-toggle {
  display: none;
  position: absolute;
  top: 10px;
  right: 10px;
  padding: 6px 11px 7px;
  font-size: 17px;
  line-height: 1;
  cursor: pointer;
  color: #cfa860;
  background: linear-gradient(165deg, #3d2c1a, #241708 60%, #2e2010);
  border: 1px solid #140c04;
  outline: 1px solid rgba(198, 160, 92, .5);
  outline-offset: -3px;
  box-shadow: var(--shadow);
}
#center-btn { display: none; }



/* a fingertip needs more wood than a cursor */
@media (pointer: coarse) {
  #sound-btn, #still-btn, #center-btn, #parley-btn {
    padding: 8px 13px 9px;
    font-size: 17px;
  }
  #leave-btn, #field-btn { padding: 7px 14px 8px; }
  #ledger-toggle { padding: 10px 15px 11px; font-size: 19px; }
  #council-btn { padding: 10px 0 11px; }
  #qm-toggle input { transform: scale(1.3); margin-right: 2px; }
}

/* ---------------------------------------------------------------- parley */

#parley-btn {
  margin-left: 6px;
  padding: 2px 10px 3px;
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
  background: transparent;
  border: 1px solid rgba(64, 44, 20, .35);
  border-radius: 3px;
  filter: sepia(.6) saturate(.6);
}
#parley-btn:hover { border-color: rgba(64, 44, 20, .7); filter: none; }

#parley-fan {
  position: absolute;
  left: 50%;
  bottom: 92px;
  transform: translateX(-50%);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  padding: 16px 20px;
  background:
    radial-gradient(120% 90% at 30% 12%, rgba(255, 250, 230, .55), rgba(255, 250, 230, 0) 60%),
    linear-gradient(168deg, var(--paper-hi), var(--paper) 45%, var(--paper-lo));
  border: 1px solid rgba(64, 44, 20, .55);
  box-shadow: var(--shadow);
  animation: parley-in .22s ease-out;
  z-index: 15;
}
@keyframes parley-in {
  from { opacity: 0; transform: translateX(-50%) translateY(18px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}
#parley-fan[hidden] { display: none; }
#parley-fan { max-width: calc(100vw - 8px); }
#parley-fan .gchip {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  min-width: 130px;
  padding: 11px 12px 10px;
  cursor: pointer;
  background: rgba(255, 252, 240, .4);
  border: 1px solid rgba(64, 44, 20, .35);
  font-family: var(--serif);
}
#parley-fan .gchip:hover { border-color: var(--blood); background: rgba(255, 252, 240, .75); }
#parley-fan .gchip .gi { font-size: 24px; filter: sepia(.5) saturate(.7); }
#parley-fan .gchip .gl { font-variant: small-caps; letter-spacing: .06em; font-size: 16.5px; color: var(--ink); }
#parley-fan .gchip .gk { font-size: 12.5px; color: var(--ink-faint); }
#parley-fan.cooling .gchip { opacity: .45; pointer-events: none; }

.toast .pdot {
  display: inline-block;
  width: 10px; height: 10px;
  border-radius: 50%;
  margin-right: 6px;
  box-shadow: inset 0 -2px 3px rgba(0,0,0,.45), 0 0 0 1px rgba(40,25,10,.5);
}
.toast.parley i { font-style: italic; }

#leave-btn, #field-btn {
  margin-left: 6px;
  padding: 3px 12px 4px;
  font-family: var(--serif);
  font-style: italic;
  font-size: 13.5px;
  cursor: pointer;
  color: var(--ink-faint);
  background: transparent;
  border: 1px solid rgba(64, 44, 20, .35);
  border-radius: 3px;
}
#leave-btn:hover, #field-btn:hover { color: var(--ink); border-color: rgba(64, 44, 20, .7); }
#field-btn {
  font-style: normal;
  font-family: var(--display);
  font-size: 12.5px;
  letter-spacing: .1em;
  color: #f0e2c0;
  background: linear-gradient(170deg, #a13a3d, var(--blood) 50%, #6e2225);
  border-color: #4c1517;
}
#field-btn:hover { color: #fff; filter: brightness(1.1); }
#me.spectating #me-seal { background: #777 !important; }

/* the hidden attribute must always win, even over explicit display rules */
[hidden] { display: none !important; }

#sound-btn, #still-btn, #center-btn {
  margin-left: 6px;
  padding: 2px 10px 3px;
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
  background: transparent;
  color: var(--ink-faint);
  border: 1px solid rgba(64, 44, 20, .35);
  border-radius: 3px;
  opacity: .55;
}
#sound-btn.on, #still-btn.on { opacity: 1; color: var(--ink); border-color: rgba(138, 106, 38, .8); background: rgba(176, 141, 62, .12); }
#sound-btn:hover, #still-btn:hover, #center-btn:hover { border-color: rgba(64, 44, 20, .7); opacity: 1; }

/* compact mode: narrow phones AND short ones (a phone held sideways) */
@media (max-width: 760px), (max-height: 520px) {
  #plaque { top: 8px; left: 8px; padding: 5px 12px 6px; }
  #plaque h1 { font-size: 16px; }
  #plaque .sub { font-size: 10px; }

  /* the Order of Battle folds away behind its toggle */
  #ledger { display: none; }
  #ledger-toggle { display: block; }
  body.show-ledger #ledger {
    display: block;
    top: 52px;
    right: 8px;
    width: min(236px, 76vw);
    max-height: 62vh;
    overflow-y: auto;
    z-index: 30;
  }

  /* the dispatch bar folds to fit a hand */
  #me {
    flex-wrap: wrap;
    justify-content: center;
    gap: 6px 8px;
    padding: 5px 10px;
    font-size: 14px;
    max-width: calc(100vw - 12px);
  }
  #me-stats { display: none; }
  #me-progress { margin-left: 2px; padding-left: 8px; }
  #me-progress i { width: 56px; }
  #me-progress b { font-size: 11px; }
  #qm-toggle { font-size: 11.5px; margin-left: 2px; padding-left: 8px; }
  #center-btn { display: inline-block; }
  #leave-btn, #field-btn { font-size: 11.5px; padding: 2px 8px 3px; }
  #dispatch { bottom: max(8px, env(safe-area-inset-bottom)); width: 100vw; }
  #hint { font-size: 12px; max-width: 94vw; text-align: center; }

  /* toasts sit above the dispatch bar, never under the hint */
  #toasts { left: 8px; bottom: 152px; }
  .toast { font-size: 13px; max-width: 70vw; }

  #parley-fan {
    grid-template-columns: repeat(2, 1fr);
    bottom: 104px;
    max-width: 94vw;
    gap: 7px;
    padding: 10px 12px;
  }
  #parley-fan .gchip { min-width: 0; padding: 8px 8px 7px; }
  #parley-fan .gchip .gl { font-size: 14px; }
  #parley-fan .gchip .gk { font-size: 11px; }

  #orders-card { left: 8px; top: 84px; width: min(264px, calc(100vw - 16px)); }
  .folio { padding: 28px 22px 24px; }
  .folio h1 { font-size: 34px; }
}

/* held sideways: spend the scarce height on the map */
@media (max-height: 520px) {
  #plaque .sub { display: none; }
  #dispatch { bottom: 4px; }
  #me { padding: 4px 10px; }
  #hint { font-size: 11.5px; padding: 2px 10px 3px; }
  #toasts { bottom: 8px; left: 8px; max-width: 30vw; }
  .toast { font-size: 12px; max-width: 30vw; }
  body.show-ledger #ledger { max-height: calc(100vh - 64px); }
  .folio { max-height: 92vh; overflow-y: auto; }
}
