/* Age of Egos. The island is the picture. Everything else is dark glass with brass fittings and
   parchment lettering laid over it, so the interface reads as part of the game and not as a page. */

:root {
  color-scheme: dark;
  --ink: #f4ecd9; /* lettering */
  --ink-2: #bcbaab; /* quieter lettering */
  --ink-3: #8b8e86; /* quietest */
  --ink-dark: #1c1508; /* lettering on brass and parchment */
  --paper: #162231; /* a panel where glass is not wanted */
  --paper-2: rgba(255, 241, 208, 0.07); /* a raised patch on a panel */
  --paper-3: rgba(255, 241, 208, 0.14); /* wells for icons */
  --parchment: #f1e6c8;
  --line: rgba(232, 197, 118, 0.22); /* hairlines */
  --line-2: rgba(232, 197, 118, 0.5);
  --sea: #17566f;
  --sea-deep: #06202e;
  --accent: #e8683c;
  --accent-2: #b9461f;
  --gold: #efc66b;
  --gold-2: #c1902f;
  --good: #8ad873;
  --bad: #ff7a66;
  --glass: linear-gradient(180deg, rgba(27, 40, 58, 0.84), rgba(11, 19, 30, 0.88));
  --glass-solid: linear-gradient(180deg, rgba(29, 43, 62, 0.96), rgba(13, 22, 34, 0.97));
  --brass: linear-gradient(180deg, #f6dc98, #dcab48);
  --serif: 'Iowan Old Style', 'Palatino Linotype', Palatino, 'Book Antiqua', Georgia, serif;
  --sans: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --radius: 14px;
  --shadow: 0 16px 38px rgba(1, 9, 16, 0.55);
  --edge: inset 0 1px 0 rgba(255, 255, 255, 0.08);
  --blur: blur(12px) saturate(1.25);
}

* { box-sizing: border-box; }
* { scrollbar-width: thin; scrollbar-color: rgba(232, 197, 118, 0.35) transparent; }

html, body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--sea-deep);
  color: var(--ink);
  font: 14px/1.4 var(--sans);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

[hidden] { display: none !important; }

h1, h2, h3, p { margin: 0; }
h2 { font: 600 19px/1.2 var(--serif); letter-spacing: 0.01em; color: #fff7e2; }
h3 {
  display: flex;
  align-items: center;
  gap: 10px;
  font: 700 11px/1 var(--sans);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--gold);
  margin: 18px 0 9px;
}
h3::after { content: ''; flex: 1; height: 1px; background: linear-gradient(90deg, var(--line-2), transparent); }
small { font-size: 12px; color: var(--ink-2); }
.muted { color: var(--ink-2); }
b, strong, output { font-variant-numeric: tabular-nums; }
code, pre { font: 13px/1.4 ui-monospace, 'SF Mono', Menlo, Consolas, monospace; }
pre { background: rgba(0, 0, 0, 0.32); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; margin: 10px 0; }

#stage {
  position: fixed;
  inset: 0;
  /* (Not 100vh: on a tablet that is the height the page would have with the browser's bars put
     away, which is more than there is, and the island would be drawn stretched to fill it.) */
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  outline: none;
}
/* The view is being turned or slid: say so, whatever the pointer is over. */
#stage.dragging { cursor: grabbing !important; }

.screen { position: fixed; inset: 0; z-index: 1; }
.screen.center {
  display: grid;
  place-items: center;
  padding: 16px;
  overflow: auto;
  background: radial-gradient(ellipse at center, rgba(4, 18, 30, 0.35), rgba(2, 12, 20, 0.78));
}

/* ---------------------------------------------------------------- over the island */

/* Readouts pinned to things in the 3D scene. The renderer moves them; this only dresses them. */
.labels { position: fixed; inset: 0; z-index: 0; overflow: hidden; pointer-events: none; contain: strict; --lab-scale: 1; }
.lab { position: absolute; left: 0; top: 0; width: 0; height: 0; will-change: transform; }
.lab-in {
  position: absolute;
  left: 0;
  bottom: 0;
  display: grid;
  justify-items: center;
  gap: 3px;
  transform: translateX(-50%) scale(var(--lab-scale));
  transform-origin: 50% 100%;
}
.lab-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 2px 9px;
  border-radius: 999px;
  font: 700 12px/1.35 var(--sans);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  box-shadow: 0 0 0 1.5px rgba(8, 14, 22, 0.88), 0 3px 9px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.35);
}
/* A plate that has been stepped up clear of another keeps a thread down to what it belongs to. */
.lab-stem { position: absolute; left: -1px; top: -1px; width: 2px; border-radius: 1px; background: linear-gradient(rgba(255, 255, 255, 0.9), rgba(255, 255, 255, 0.3)); box-shadow: 0 0 0 0.5px rgba(8, 14, 22, 0.7); }
/* Where room is short the plates are drawn tighter. */
.labels.tight .lab-pill { padding: 1px 6px; gap: 4px; }
.labels.tight .lab-party .lab-pill { padding: 0 5px; }
.labels.tight .lab-pill svg { width: 10px; height: 10px; }
.labels.tight .lab-bar { width: 34px; height: 4px; }
.labels.tight .lab-in { gap: 2px; }
.lab-pill em { font-style: normal; display: inline-flex; align-items: center; gap: 2px; }
.lab-pill svg { width: 12px; height: 12px; flex: none; fill: none; stroke: currentColor; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }
.lab-pill .pact svg { width: 15px; }
.lab-party .lab-pill { padding: 1px 7px; font-size: 11px; }
.lab-bar { display: block; width: 48px; height: 5px; border-radius: 3px; background: rgba(8, 14, 22, 0.85); box-shadow: 0 0 0 1.5px rgba(8, 14, 22, 0.88); overflow: hidden; }
.lab-bar b { display: block; height: 100%; border-radius: 3px; background: #7fd66b; }
.lab-bar.mid b { background: #f2c14e; }
.lab-bar.low b { background: #ff6352; }
.lab-bar.work b { background: linear-gradient(90deg, #f2c14e, #ffe39a); }
/* A monument going up: a bar nobody can overlook. */
.lab-bar.work.claim { width: 64px; height: 8px; box-shadow: 0 0 0 1.5px rgba(8, 14, 22, 0.88), 0 0 10px rgba(255, 214, 110, 0.9); }
.lab-bar.work.claim b { background: linear-gradient(90deg, #ffb347, #fff1c4); }
.lab-in.alarm .lab-pill { animation: lab-alarm 0.6s ease-in-out infinite alternate; }
@keyframes lab-alarm { to { box-shadow: 0 0 0 2px #ff6352, 0 0 16px 4px rgba(255, 99, 82, 0.8); } }
.lab-dep img {
  width: 22px;
  height: 22px;
  display: block;
  padding: 2px;
  border-radius: 50%;
  background: var(--parchment);
  box-shadow: 0 0 0 1.5px rgba(8, 14, 22, 0.85), 0 3px 8px rgba(0, 0, 0, 0.45);
}
.lab-pips { display: flex; gap: 2px; }
.lab-pips i { width: 4px; height: 4px; border-radius: 50%; background: #fff1c9; box-shadow: 0 0 0 1px rgba(8, 14, 22, 0.85); }
.lab-in.small { gap: 0; }
.lab-in.small img { width: 14px; height: 14px; padding: 1px; box-shadow: 0 0 0 1px rgba(8, 14, 22, 0.8), 0 2px 4px rgba(0, 0, 0, 0.4); }
.lab-in.small .lab-pips { display: none; }
.lab-in.locked { opacity: 0.55; }
.lab-in.locked img { filter: grayscale(0.85); }
.lab-in.spent img { filter: grayscale(1) brightness(0.55); }
.lab-in.spent .lab-pips i { background: #6b6f73; }

/* The corners of the picture fall away into shadow, as through a lens. */
.vignette { position: fixed; inset: 0; z-index: 0; pointer-events: none; background: radial-gradient(ellipse at 50% 45%, rgba(2, 12, 22, 0) 58%, rgba(2, 12, 22, 0.38) 100%); }

/* A strike weapon going off, and the curtain that lifts on a new island. */
.screen-flash, .screen-veil { position: fixed; inset: 0; z-index: 0; pointer-events: none; opacity: 0; }
.screen-flash { background: #fff4d6; }
.screen-flash.go { animation: screen-flash 1.1s ease-out; }
@keyframes screen-flash { 0% { opacity: 0.9; } 100% { opacity: 0; } }
.screen-veil { background: var(--sea-deep); }
.screen-veil.go { animation: screen-veil 1.1s ease-out; }
@keyframes screen-veil { 0% { opacity: 1; } 100% { opacity: 0; } }

/* ---------------------------------------------------------------- buttons */

button { font: inherit; color: inherit; cursor: pointer; }
button:disabled { cursor: default; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

.btn {
  appearance: none;
  border: 1px solid rgba(232, 197, 118, 0.42);
  background: linear-gradient(180deg, rgba(255, 241, 208, 0.16), rgba(255, 241, 208, 0.05));
  color: var(--ink);
  padding: 7px 14px;
  border-radius: 10px;
  font-weight: 600;
  line-height: 1.2;
  box-shadow: var(--edge), 0 1px 2px rgba(0, 0, 0, 0.35);
  transition: transform 0.08s ease, background 0.12s ease, border-color 0.12s ease, box-shadow 0.12s ease;
}
.btn:hover:not(:disabled) { background: linear-gradient(180deg, rgba(255, 241, 208, 0.26), rgba(255, 241, 208, 0.1)); border-color: var(--gold); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: 0.4; }
.btn.primary {
  background: linear-gradient(180deg, #f58350, #cf4f23);
  border-color: rgba(255, 196, 160, 0.55);
  color: #fff8ec;
  text-shadow: 0 1px 0 rgba(90, 24, 0, 0.45);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35), 0 4px 16px rgba(232, 104, 60, 0.32);
}
.btn.primary:hover:not(:disabled) { background: linear-gradient(180deg, #ff9463, #dc5a2c); border-color: #ffd9c2; }
.btn.ghost { background: transparent; border-color: transparent; box-shadow: none; color: var(--ink-2); text-decoration: underline; text-underline-offset: 3px; }
.btn.ghost:hover:not(:disabled) { background: rgba(255, 241, 208, 0.1); border-color: transparent; color: var(--ink); }
.btn.small { padding: 5px 11px; font-size: 13px; border-radius: 8px; }
.btn.big { padding: 11px 22px; font-size: 16px; border-radius: 12px; }
.btn.on, .btn.on:hover:not(:disabled) { background: var(--brass); border-color: #fff1c4; color: var(--ink-dark); }

.icon-btn {
  appearance: none;
  width: 34px;
  height: 34px;
  flex: none;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.22);
  box-shadow: var(--edge);
}
.icon-btn:hover { background: rgba(255, 241, 208, 0.12); border-color: var(--gold); }

.ic { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.ic.fill { fill: currentColor; stroke: none; }

/* ---------------------------------------------------------------- title */

#screen-title {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: clamp(20px, 6vh, 64px) 20px clamp(22px, 7vh, 72px);
  /* The sky darkens towards the top and the sea towards the bottom, to carry the lettering. */
  background:
    linear-gradient(180deg, rgba(3, 20, 38, 0.56) 0%, rgba(3, 20, 38, 0.22) 20%, rgba(3, 20, 38, 0) 40%),
    linear-gradient(0deg, rgba(2, 14, 24, 0.82) 0%, rgba(2, 14, 24, 0.42) 18%, rgba(2, 14, 24, 0) 40%);
}
.title-card { text-align: center; color: #fff6dc; max-width: 100%; animation: title-in 1.4s cubic-bezier(0.2, 0.7, 0.2, 1) both; }
.game-logo { display: block; width: 100%; height: auto; filter: drop-shadow(0 6px 18px #0009); }
.title-card h1 {
  width: min(960px, 86vw, 96vh);
  max-width: 100%;
  margin: 0 auto;
  line-height: 1;
}
.title-foot { display: grid; justify-items: center; gap: 18px; max-width: 100%; animation: title-in 1.4s cubic-bezier(0.2, 0.7, 0.2, 1) 0.35s both; }
.title-actions { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; }
.title-actions .btn { backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur); min-width: 150px; }
.title-actions .btn:not(.primary):not(.ghost) { background: linear-gradient(180deg, rgba(27, 40, 58, 0.72), rgba(11, 19, 30, 0.78)); }
.title-actions .btn:not(.primary):not(.ghost):hover { background: linear-gradient(180deg, rgba(44, 61, 84, 0.8), rgba(20, 31, 46, 0.84)); }
.title-actions .btn.primary { padding-inline: 34px; font-size: 18px; box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.4), 0 6px 26px rgba(232, 104, 60, 0.55); }
.title-card .btn.ghost, .title-actions .btn.ghost { color: #f4ecd9; backdrop-filter: none; -webkit-backdrop-filter: none; min-width: 0; }
.title-card .btn.ghost:hover, .title-actions .btn.ghost:hover { background: rgba(246, 237, 216, 0.14); }
@keyframes title-in { from { opacity: 0; transform: translateY(14px); } }

/* ---------------------------------------------------------------- sheets (menus) */

.sheet {
  background: var(--glass-solid);
  border: 1px solid var(--line-2);
  border-radius: 18px;
  box-shadow: var(--shadow), 0 0 0 1px rgba(0, 0, 0, 0.5), var(--edge);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  width: min(1040px, 100%);
  max-height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.sheet-head {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(255, 241, 208, 0.07), transparent);
}
.sheet-head h2 { font-size: 24px; text-align: center; color: var(--gold); }
.sheet-head > :first-child { justify-self: start; }
.sheet-head > :last-child { justify-self: end; text-align: right; }

.chart-body { display: grid; grid-template-columns: 1fr 320px; min-height: 0; overflow: hidden; }
.voyages { list-style: none; margin: 0; padding: 14px 16px; display: grid; gap: 12px; overflow: auto; align-content: start; }
.voyage { border: 1px solid var(--line); border-radius: 14px; background: rgba(0, 0, 0, 0.2); padding: 10px 12px 12px; }
.voyage.current { border-color: var(--line-2); background: rgba(255, 241, 208, 0.05); }
.voyage.locked { opacity: 0.5; }
.voyage-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 12px; margin-bottom: 9px; }
.voyage-head h3 { display: block; margin: 0; padding: 0; border: 0; font: 600 17px/1.2 var(--serif); letter-spacing: 0; text-transform: none; color: #fff7e2; }
.voyage-head h3::after { display: none; }
.voyage-head .aboard { margin-left: auto; font-size: 13px; font-weight: 700; color: var(--gold); }
.isles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.voyages .foot { display: flex; justify-content: center; }
.chart-list {
  list-style: none;
  margin: 0;
  padding: 16px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
  gap: 12px;
  overflow: auto;
  align-content: start;
}
.isle {
  appearance: none;
  width: 100%;
  text-align: left;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--paper-2);
  display: grid;
  gap: 6px;
  transition: border-color 0.12s ease, transform 0.12s ease, box-shadow 0.12s ease;
}
.isle:hover:not(:disabled) { border-color: var(--gold); transform: translateY(-1px); }
.isle.sel { border-color: var(--gold); box-shadow: 0 0 0 2px var(--gold), 0 6px 22px rgba(239, 198, 107, 0.25); }
.isle:disabled { opacity: 0.45; }
.isle canvas { width: 100%; height: auto; aspect-ratio: 3 / 2; border-radius: 8px; display: block; background: var(--sea); box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.4); }
.isle-name { font: 600 16px/1.15 var(--serif); display: flex; justify-content: space-between; gap: 6px; color: #fff7e2; }
.isle-name i { font: 700 11px/1.5 var(--sans); color: var(--ink-3); font-style: normal; }
.isle-meta { display: flex; justify-content: space-between; align-items: center; font-size: 12px; color: var(--ink-2); }
.stars { display: inline-flex; gap: 1px; color: rgba(255, 241, 208, 0.2); }
.stars .ic { width: 14px; height: 14px; }
.stars .got { color: var(--gold); filter: drop-shadow(0 0 4px rgba(239, 198, 107, 0.6)); }

.brief { padding: 18px; border-left: 1px solid var(--line); background: rgba(0, 0, 0, 0.16); overflow: auto; display: flex; flex-direction: column; gap: 12px; }
.brief h3 { margin-top: 4px; }
.brief .blurb { font: italic 15px/1.45 var(--serif); color: #fdf3d8; }
.facts { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; font-size: 13px; }
.facts dt { color: var(--ink-2); }
.facts dd { margin: 0; font-weight: 600; }
.facts dd.climate { display: flex; align-items: center; gap: 6px; }
.facts dd.climate img { width: 22px; height: 22px; margin: -3px 0; }
.rival { display: grid; grid-template-columns: 44px 1fr; gap: 0 10px; align-items: center; }
.rival .face { width: 44px; height: 44px; grid-row: span 2; }
.rival b { align-self: end; }
.rival small { align-self: start; }
.brief .btn { margin-top: auto; align-self: stretch; }

.skirmish { width: min(760px, 100%); }
.skirmish-body { display: grid; grid-template-columns: 1fr 260px; gap: 20px; padding: 18px; overflow: auto; }
.fields { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 18px; align-content: start; }
.fields label { display: grid; grid-template-columns: 1fr auto; gap: 6px; font-weight: 600; font-size: 13px; align-items: baseline; color: var(--ink-2); }
.fields label > :not(output) { grid-column: 1 / -1; }
.fields output { font-weight: 700; font-size: 15px; color: var(--gold); }
.fields input[type='range'] { width: 100%; accent-color: var(--gold); }
.fields select, .fields input[type='number'] {
  font: inherit;
  width: 100%;
  padding: 7px 9px;
  border: 1px solid var(--line-2);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.32);
  color: var(--ink);
}
.seed-row { display: flex; gap: 8px; }
.preview { display: grid; gap: 12px; align-content: start; }
.preview canvas { width: 100%; height: auto; border-radius: 10px; background: var(--sea); border: 1px solid var(--line-2); box-shadow: 0 8px 22px rgba(0, 0, 0, 0.4); }

/* ---------------------------------------------------------------- game layout */

.game {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 344px;
  grid-template-rows: auto minmax(0, 1fr);
  grid-template-areas: 'top top' 'stage right';
  gap: 10px;
  padding: 10px;
  pointer-events: none;
}
.game > * { pointer-events: auto; }

.panel {
  background: var(--glass);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow), 0 0 0 1px rgba(0, 0, 0, 0.45), var(--edge);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
}
.side { overflow: auto; padding: 14px; overscroll-behavior: contain; }
#panel-right { grid-area: right; }
#stage-area { grid-area: stage; position: relative; pointer-events: none; min-height: 0; }

/* top bar */
#topbar { grid-area: top; display: flex; align-items: center; gap: 12px; padding: 6px 10px; min-width: 0; }
.where { display: flex; align-items: baseline; gap: 9px; white-space: nowrap; }
.where strong { font: 600 18px/1 var(--serif); color: #fff7e2; }
.pill { display: inline-block; padding: 3px 10px; border-radius: 999px; background: var(--brass); color: var(--ink-dark); font-size: 12px; font-weight: 700; box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.5), 0 1px 3px rgba(0, 0, 0, 0.4); }
.grow { flex: 1; }
.mats { display: flex; gap: 6px; min-width: 0; overflow: hidden; }
.mat {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px 3px 3px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--line);
  white-space: nowrap;
}
.mat img { width: 22px; height: 22px; display: block; padding: 2px; border-radius: 50%; background: var(--parchment); }
.mat b { min-width: 2ch; text-align: right; }
.mat small { font-size: 11px; color: var(--good); font-weight: 600; }
.mat.locked { opacity: 0.4; }
.stat { display: flex; align-items: center; gap: 5px; white-space: nowrap; }
.stat b { font-size: 15px; }
.speed { display: flex; border: 1px solid var(--line-2); border-radius: 10px; overflow: hidden; flex: none; background: rgba(0, 0, 0, 0.28); }
.speed button { appearance: none; border: 0; background: transparent; padding: 6px 10px; font-weight: 700; font-size: 13px; min-width: 36px; color: var(--ink-2); }
.speed button + button { border-left: 1px solid var(--line); }
.speed button:hover { background: rgba(255, 241, 208, 0.12); color: var(--ink); }
.speed button.on { background: var(--brass); color: var(--ink-dark); }

/* The little cluster of camera buttons at the edge of the map (only when the island is in 3D). */
.cam-pad { display: none; }
.gfx-3d .cam-pad { position: absolute; top: 52px; right: 0; display: grid; gap: 6px; pointer-events: auto; }
.cam-pad button {
  appearance: none;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--glass);
  color: var(--ink);
  box-shadow: 0 4px 12px rgba(1, 9, 16, 0.45), var(--edge);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  touch-action: manipulation;
}
.cam-pad button:hover { border-color: var(--gold); color: var(--gold); }
.cam-pad button:active { transform: translateY(1px); }

/* ---------------------------------------------------------------- research */

.r-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.r-sub { font-size: 12px; color: var(--ink-2); margin-top: 2px; }
.r-now { margin: 12px 0 4px; padding: 9px 10px; border-radius: 10px; background: var(--paper-2); border: 1px solid var(--line); }
.r-now b { display: block; }
.r-now.warn { background: rgba(255, 122, 102, 0.13); border-color: rgba(255, 122, 102, 0.5); }
.meter { height: 8px; border-radius: 999px; background: rgba(0, 0, 0, 0.42); box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.5); overflow: hidden; margin-top: 6px; }
.meter i { display: block; height: 100%; width: 0; border-radius: 999px; background: linear-gradient(180deg, #a7ea8f, #66b653); transition: width 0.2s linear; }
.meter.study i { background: linear-gradient(180deg, #ff9a6c, #e25c30); }
.meter.work i { background: linear-gradient(180deg, #ffe08f, #dba63c); }
.meter.hp.low i { background: linear-gradient(180deg, #ff9484, #e44a37); }

.r-list { display: grid; gap: 6px; }
.r-item {
  appearance: none;
  width: 100%;
  position: relative;
  display: grid;
  grid-template-columns: 30px 1fr auto;
  gap: 9px;
  align-items: center;
  text-align: left;
  padding: 8px 9px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: linear-gradient(180deg, rgba(255, 241, 208, 0.09), rgba(255, 241, 208, 0.03));
  overflow: hidden;
  transition: border-color 0.12s ease, background 0.12s ease;
}
.r-item:hover:not(:disabled) { border-color: var(--gold); background: linear-gradient(180deg, rgba(255, 241, 208, 0.15), rgba(255, 241, 208, 0.06)); }
.r-item b { display: block; line-height: 1.2; }
.r-item small { display: block; line-height: 1.3; margin-top: 1px; }
.r-ico { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; background: var(--paper-3); color: var(--ink); }
.r-tag { font-size: 11px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; color: var(--ink-3); display: grid; place-items: center; min-width: 22px; }
.r-bar { position: absolute; left: 0; bottom: 0; height: 4px; width: 0; background: linear-gradient(90deg, var(--accent), #ffb36c); transition: width 0.2s linear; }
.r-item.is-known { background: transparent; border-style: dashed; color: var(--ink-2); }
.r-item.is-known .r-tag { color: var(--good); }
.r-item.is-queued { border-color: var(--accent); background: linear-gradient(180deg, rgba(232, 104, 60, 0.24), rgba(232, 104, 60, 0.08)); box-shadow: 0 0 14px rgba(232, 104, 60, 0.22); }
.r-item.is-queued .r-tag { width: 22px; height: 22px; border-radius: 50%; background: var(--accent); color: #fff; }
.r-item.is-locked { opacity: 0.5; }
.r-item.is-age .r-ico { background: var(--brass); color: var(--ink-dark); }

.tribe { display: grid; grid-template-columns: 36px 1fr auto; gap: 9px; align-items: center; padding: 5px 6px; margin: 0 -6px; text-align: left; border-radius: 10px; }
button.tribe { appearance: none; border: 0; background: transparent; width: calc(100% + 12px); }
button.tribe:hover, .tribe-wrap.open button.tribe { background: var(--paper-2); }
.tribe.out { opacity: 0.45; }
.tribe.out b { text-decoration: line-through; }
.face { width: 36px; height: 36px; border-radius: 50%; display: block; box-shadow: 0 0 0 1.5px var(--line-2), 0 2px 6px rgba(0, 0, 0, 0.4); }
.face.flag { border: 2px solid var(--ink); box-shadow: inset 0 0 0 3px rgba(8, 14, 22, 0.75), 0 2px 6px rgba(0, 0, 0, 0.4); }
.tag { font: 700 10px/1 var(--sans); letter-spacing: 0.06em; text-transform: uppercase; background: #3f9a34; color: #fff; padding: 2px 6px; border-radius: 999px; margin-left: 6px; vertical-align: 2px; }
.tag.ending { background: #d04a37; }
.audience { display: grid; gap: 8px; justify-items: start; padding: 8px 10px 10px; margin: 2px -6px 6px; border-radius: 10px; background: var(--paper-2); border: 1px solid var(--line); }
.stack { display: grid; gap: 8px; justify-items: start; }
.tribe small { display: block; }
.tribe-n { font-weight: 700; text-align: right; }
.swatch { width: 14px; height: 14px; border-radius: 4px; border: 1.5px solid var(--ink); display: inline-block; flex: none; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.5); }

/* ---------------------------------------------------------------- selection panel */

.sel-name { display: flex; align-items: center; gap: 8px; }
.sel-sub { color: var(--ink-2); font-size: 13px; margin-top: 2px; }
.sel-quote { font: italic 14px/1.4 var(--serif); margin-top: 10px; color: #fdf3d8; }
.deps { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.dep { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px 2px 2px; border-radius: 999px; background: rgba(0, 0, 0, 0.3); border: 1px solid var(--line); font-size: 12px; font-weight: 600; }
.dep img { width: 20px; height: 20px; padding: 2px; border-radius: 50%; background: var(--parchment); }
.dep.locked { opacity: 0.45; }
.pips { letter-spacing: 1px; color: var(--gold); font-size: 9px; }
.popline { margin-top: 12px; display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; }
.popline b { font-size: 22px; font-family: var(--serif); color: #fff7e2; }
.popline .rate { margin-left: auto; font-size: 12px; font-weight: 700; color: var(--good); }
.popline .rate.flat { color: var(--ink-3); }

.roles { display: grid; gap: 4px; margin-top: 10px; }
.role { display: grid; grid-template-columns: 28px 1fr 30px 34px 30px; align-items: center; gap: 6px; padding: 5px 6px; border-radius: 10px; background: var(--paper-2); }
.role.rest { grid-template-columns: 28px 1fr 34px; background: transparent; border: 1px dashed var(--line); }
.role-ic { width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; background: var(--paper-3); }
.role-lab b { display: block; line-height: 1.15; }
.role-lab small { display: block; line-height: 1.2; }
.role-n { text-align: center; font-weight: 700; font-size: 16px; }
.step {
  appearance: none;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 1px solid var(--line-2);
  background: linear-gradient(180deg, rgba(255, 241, 208, 0.2), rgba(255, 241, 208, 0.06));
  box-shadow: var(--edge);
  font-weight: 700;
  font-size: 17px;
  line-height: 1;
  display: grid;
  place-items: center;
  padding: 0 0 2px;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}
.step:hover:not(:disabled) { border-color: var(--gold); background: linear-gradient(180deg, rgba(255, 241, 208, 0.32), rgba(255, 241, 208, 0.12)); }
.step:active:not(:disabled) { background: var(--brass); color: var(--ink-dark); }
.step:disabled { opacity: 0.28; }

.gear { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 8px; }
.chip { appearance: none; border: 1px solid var(--line); background: var(--paper-2); border-radius: 9px; padding: 4px 8px; text-align: left; line-height: 1.2; font-size: 12px; font-weight: 600; }
.chip:hover { border-color: var(--gold); }
.chip small { display: block; font-size: 11px; font-weight: 400; }
.chip.on { border-color: #fff1c4; background: var(--brass); color: var(--ink-dark); }
.chip.on small { color: #4d3c12; }
.chip.poor:not(.on) { opacity: 0.5; }
.garrison { font-size: 13px; color: var(--ink-2); margin-top: 8px; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }

.build { display: grid; gap: 6px; }
.b-opt { appearance: none; text-align: left; border: 1px solid var(--line); background: linear-gradient(180deg, rgba(255, 241, 208, 0.09), rgba(255, 241, 208, 0.03)); border-radius: 10px; padding: 7px 10px; display: grid; gap: 1px; }
.b-opt:hover:not(:disabled) { border-color: var(--gold); }
.b-opt:disabled { opacity: 0.45; }
.b-opt b { line-height: 1.2; }
.b-now { padding: 9px 10px; border-radius: 10px; background: var(--paper-2); border: 1px solid var(--line); display: grid; gap: 4px; }
.b-now .row { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.note { font-size: 12px; color: var(--ink-2); }
.note.warn { color: var(--bad); font-weight: 600; }

.orders { display: grid; gap: 7px; }
.order { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: center; }
.order .btn { text-align: center; }
.stepper { display: inline-grid; grid-template-columns: 30px 38px 30px; align-items: center; text-align: center; }
.party { display: grid; grid-template-columns: 14px 1fr auto; gap: 8px; align-items: center; padding: 7px 9px; border-radius: 10px; background: var(--paper-2); border: 1px solid var(--line); margin-top: 6px; font-size: 13px; }
.tips { display: grid; gap: 8px; padding-left: 18px; margin: 10px 0 0; }
.tips li::marker { color: var(--gold); }
.own-list { display: grid; gap: 6px; }
.own-item { appearance: none; display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: center; text-align: left; border: 1px solid var(--line); background: linear-gradient(180deg, rgba(255, 241, 208, 0.09), rgba(255, 241, 208, 0.03)); border-radius: 10px; padding: 7px 10px; }
.own-item:hover { border-color: var(--gold); }

/* ---------------------------------------------------------------- overlays on the map */

.banner {
  position: absolute;
  top: 6px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--glass);
  border: 1px solid var(--line-2);
  color: #fff7e2;
  padding: 8px 18px;
  border-radius: 999px;
  font-weight: 600;
  box-shadow: var(--shadow), var(--edge);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  white-space: nowrap;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
}
/* Notices stack up from the bottom of the map. If there are more than fit, the oldest slide out of
   sight at the top instead of spilling over the bar above. */
.stage-foot { position: absolute; left: 0; right: 0; bottom: 0; max-height: 100%; overflow: hidden; display: flex; flex-direction: column; justify-content: flex-end; gap: 8px; pointer-events: none; }
#toasts { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; max-width: min(430px, 100%); pointer-events: none; }

/* A leader has something to say. */
.speech {
  align-self: flex-end;
  width: min(390px, 100%);
  display: grid;
  grid-template-columns: 92px 1fr;
  gap: 12px;
  align-items: center;
  padding: 9px 14px 9px 9px;
  background: var(--glass-solid);
  border: 1px solid var(--line-2);
  border-left: 6px solid var(--who, var(--gold));
  border-radius: 14px;
  box-shadow: var(--shadow), var(--edge);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  pointer-events: auto;
  animation: toast-in 0.25s ease-out;
}
.speech canvas { width: 92px; height: 92px; display: block; border-radius: 10px; box-shadow: 0 0 0 1px var(--line-2); }
.speech-body b { font: 600 15px/1.2 var(--serif); color: var(--gold); }
.speech-body p { font: italic 15px/1.35 var(--serif); margin-top: 3px; color: #fdf3d8; }
.speech-actions { display: flex; gap: 8px; margin-top: 9px; }

/* A leader quoted on a pop-up sheet. */
.quote { display: grid; grid-template-columns: 72px 1fr; gap: 12px; align-items: center; margin: 14px 0 4px; padding: 9px 12px 9px 9px; background: var(--paper-2); border: 1px solid var(--line); border-radius: 12px; }
.quote img { width: 72px; height: 72px; display: block; border-radius: 10px; }
.modal-card .quote p { margin: 0; font: italic 16px/1.35 var(--serif); color: #fdf3d8; }
.quote b { display: block; font: 600 13px/1.3 var(--sans); font-style: normal; color: var(--gold); }
.toast {
  background: linear-gradient(180deg, rgba(27, 40, 58, 0.92), rgba(11, 19, 30, 0.94));
  border: 1px solid var(--line);
  border-left: 5px solid var(--ink-3);
  border-radius: 9px;
  padding: 7px 11px;
  box-shadow: 0 6px 16px rgba(1, 9, 16, 0.5);
  font-size: 13px;
  animation: toast-in 0.25s ease-out;
  transition: opacity 0.5s ease;
}
.toast.good { border-left-color: var(--good); }
.toast.bad { border-left-color: var(--bad); }
.toast.wx { border-left-color: #86bef0; }
.toast.wx.fair { border-left-color: #ffcf4a; }
.toast.say { font: italic 14px/1.35 var(--serif); }
.toast.fade { opacity: 0; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

.guide {
  position: absolute;
  top: 6px;
  left: 0;
  width: min(300px, 100%);
  background: var(--glass-solid);
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
  box-shadow: var(--shadow), var(--edge);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  padding: 12px 14px;
  pointer-events: auto;
}
.guide h3 { margin-top: 0; }
.guide p { font: 15px/1.4 var(--serif); }
.guide .row { display: flex; justify-content: space-between; align-items: center; margin-top: 8px; }

/* ---------------------------------------------------------------- modal */

.modal { position: fixed; inset: 0; z-index: 5; display: grid; place-items: center; padding: 16px; background: rgba(2, 12, 20, 0.66); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); overflow: auto; }
.modal-card { width: min(520px, 100%); padding: 22px 24px; display: block; overflow: auto; animation: modal-in 0.22s ease-out; }
.modal-card h2 { font-size: 26px; margin-bottom: 6px; color: var(--gold); }
.modal-card p { margin-top: 8px; }
.modal-card .actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 20px; }
.modal-card.wide { width: min(680px, 100%); }
@keyframes modal-in { from { opacity: 0; transform: translateY(10px) scale(0.985); } }
.result-stars { display: flex; gap: 4px; margin: 10px 0 4px; color: rgba(255, 241, 208, 0.2); }
.result-stars .ic { width: 34px; height: 34px; }
.result-stars .got { color: var(--gold); filter: drop-shadow(0 0 8px rgba(239, 198, 107, 0.65)); }
.tally { display: grid; grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); gap: 8px; margin-top: 14px; }
.tally div { background: var(--paper-2); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; }
.tally b { display: block; font: 600 20px/1.1 var(--serif); color: #fff7e2; }
.tally small { display: block; }
.help { display: grid; gap: 10px; margin-top: 12px; }
.help div { display: grid; grid-template-columns: 34px 1fr; gap: 10px; align-items: start; }
.help .role-ic { width: 34px; height: 34px; }
.keys { margin-top: 14px; font-size: 13px; color: var(--ink-2); }
kbd { font: 600 12px/1 var(--sans); padding: 2px 6px; border: 1px solid var(--line-2); border-bottom-width: 2px; border-radius: 5px; background: rgba(0, 0, 0, 0.35); color: var(--ink); }

/* ---------------------------------------------------------------- the later systems */

/* css/additions.css, loaded after this file, lays out the pieces that came with leaders, mines,
   emplacements, the strike weapon and the last stand. It was written for the old paper look, so
   the rules here give those pieces their colours in this one. Each starts with :root so that it
   wins over the plain class rule in that file whichever of the two is loaded last. */
:root .leader {
  background: linear-gradient(180deg, rgba(255, 241, 208, 0.1), rgba(255, 241, 208, 0.03));
  border: 1px solid var(--line);
  border-top: 6px solid var(--who, var(--gold));
  box-shadow: var(--edge);
}
:root .leader:hover { border-color: var(--gold); border-top-color: var(--who, var(--gold)); box-shadow: 0 12px 26px rgba(1, 9, 16, 0.55), var(--edge); }
:root .leader.sel { border-color: var(--who, var(--gold)); box-shadow: 0 0 0 2px var(--who, var(--gold)), 0 0 22px rgba(239, 198, 107, 0.25); }
:root .leader img { border-radius: 50%; box-shadow: 0 0 0 1.5px var(--line-2), 0 4px 12px rgba(0, 0, 0, 0.45); }
:root .leader b { color: #fff7e2; }
:root .leader i { color: var(--ink-2); }
:root .leader .perk { color: var(--gold); }
:root .leader-strip, :root .sk-leader {
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-left: 6px solid var(--who, var(--gold));
}
:root .leader-strip b { color: #fff7e2; }
:root .tag.you { background: var(--brass); color: var(--ink-dark); }
/* Your own leader reporting in: the same card as a rival's, but warmer and without the italics. */
:root .speech.own {
  background: linear-gradient(180deg, rgba(58, 47, 24, 0.96), rgba(29, 24, 12, 0.97));
  border: 1px solid var(--who, var(--gold));
  border-left: 6px solid var(--who, var(--gold));
}
:root .speech.own .speech-body b { color: var(--gold); }
:root .dep small { color: var(--ink-2); }
:root .dep.out { background: transparent; color: var(--ink-2); border-style: dashed; }
:root .dep.deep { border-color: var(--gold); }
:root .btn.danger { background: linear-gradient(180deg, #6d1f1a, #451310); border-color: var(--bad); color: #ffe1d6; text-shadow: none; }
:root .btn.danger:hover:not(:disabled) { background: linear-gradient(180deg, #8a2a23, #5a1915); border-color: #ffb3a6; }
:root .btn.danger.on, :root .btn.danger.on:hover:not(:disabled) { background: linear-gradient(180deg, #ff6f5c, #d63b2a); border-color: #ffd0c8; color: #fff; }
:root .b-opt.is-strike { border-color: var(--bad); background: linear-gradient(180deg, rgba(255, 122, 102, 0.2), rgba(255, 122, 102, 0.07)); }
:root .r-item.is-strike .r-ico { background: linear-gradient(180deg, #ff6f5c, #c93626); color: #fff; }
#research .tips li::marker { color: var(--gold); }

/* A deposit that lies too deep to work without a mine wears a dashed gold ring on the map. */
.lab-in.deep img { outline: 1.5px dashed var(--gold); outline-offset: 1.5px; }
.lab-in.small.deep img { outline-width: 1px; outline-offset: 1px; }

/* ---------------------------------------------------------------- smaller windows */

/* Mid-sized windows: the same, a little tighter. */
@media (max-width: 1099px) {
  .game {
    grid-template-columns: minmax(0, 1fr) 316px;
    gap: 8px;
    padding: 8px;
  }
  #topbar { flex-wrap: wrap; gap: 6px 10px; }
  .mat small { display: none; }
  .where strong { font-size: 16px; }
  .guide { width: min(270px, 100%); }
  .chart-body { grid-template-columns: 1fr 280px; }
}

/* Phones and narrow windows: everything stacked, panel as a sheet at the bottom. */
@media (max-width: 640px) {
  .game {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr) min(46vh, 400px);
    grid-template-areas: 'top' 'stage' 'right';
    gap: 6px;
    padding: 6px;
  }
  .mats { order: 5; width: 100%; overflow-x: auto; }
  .chart-body { grid-template-columns: 1fr; overflow: auto; }
  .chart-list, .voyages { overflow: visible; }
  .voyages { padding: 10px; }
  .isles { gap: 6px; }
  .speech { grid-template-columns: 64px 1fr; }
  .speech canvas { width: 64px; height: 64px; }
  .brief { border-left: 0; border-top: 1px solid var(--line); }
  .skirmish-body { grid-template-columns: 1fr; }
  .fields { grid-template-columns: 1fr; }
  .sheet-head h2 { font-size: 20px; }
  .title-actions { flex-direction: column; align-items: stretch; width: min(320px, 100%); }
  /* Fingers do the turning and zooming here; one button to put the view back is enough. */
  .gfx-3d .cam-pad { top: 46px; }
  .cam-pad button:not([data-cam='home']) { display: none; }
}

/* Short windows: do not let the title crowd the island out. */
@media (max-height: 520px) {
  .title-card h1 { width: min(620px, 78vw, 100vh); }
}

@media (pointer: coarse) {
  .step { width: 36px; height: 36px; }
  .role { grid-template-columns: 28px 1fr 36px 34px 36px; }
  .stepper { grid-template-columns: 36px 38px 36px; }
  .cam-pad button { width: 40px; height: 40px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* A notice that leads somewhere: click it to go there. */
.toast.go { pointer-events: auto; cursor: pointer; }
.toast.go:hover { border-color: var(--gold); }

/* A tribe's shield: its god's colour and device. Wherever a thing belongs to somebody, this says whom. */
.shield { width: 15px; height: 18px; flex: none; display: inline-block; vertical-align: -3px; filter: drop-shadow(0 1px 1.5px rgba(0, 0, 0, 0.55)); }
.shield.big { width: 22px; height: 26px; vertical-align: -5px; }
.face-wrap { position: relative; display: block; flex: none; }
.face-wrap .shield { position: absolute; right: -5px; bottom: -4px; }
.lab-shield { width: 11px; height: 13px; flex: none; display: block; margin: 0 -2px 0 -3px; filter: drop-shadow(0 0.5px 1px rgba(0, 0, 0, 0.6)); }
.labels.tight .lab-shield { width: 9px; height: 11px; }

/* The gods are paintings now: square, wherever they hang. */
img.face { object-fit: cover; }
.quote img { object-fit: cover; }

/* The premise, under the name on the title screen. */
.premise {
  position: relative;
  isolation: isolate;
  max-width: 54ch;
  margin: 8px auto 0;
  padding: 10px 18px;
  font: 500 clamp(18px, 1.65vw, 23px)/1.45 var(--serif);
  color: #fff4dc;
  text-shadow: 0 2px 3px #000;
}
.premise::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  border-radius: 50%;
  background: #03101edb;
  filter: blur(14px);
}
.premise span { display: block; }

/* Your own warriors and parties can be picked up by their plates on the island. */
.lab [data-army], .lab [data-guards] { pointer-events: auto; cursor: grab; }
.lab [data-army]:hover, .lab em[data-guards]:hover { filter: brightness(1.18); outline: 2px solid #fff1c4; outline-offset: 1px; border-radius: 999px; }
