:root {
  --bg: #dce6e8;
  --panel: #f6f2e7;
  --ink: #1b2b36;
  --muted: #5a6f7c;
  --line: #c9d3d6;
  --soft: #e9e1cc;
  --gold: #d9a22b;
  --warn: #b8432b;
  --deep: #2f6b8e;
  --mid: #5e9dbb;
  --shallow: #a4d0db;
  --isle: #e0cc98;
  --port: #f6f2e7;
  --hexline: rgba(20, 40, 55, 0.14);
  /* пергамент стартовой карты — одинаковый в светлой и тёмной теме, это «предмет», а не интерфейс */
  --parch: #ead7a8;
  --parch-2: #d2b176;
  --parch-3: #b88e52;
  --parch-ink: #3a2814;
  --parch-red: #9b2f1f;
  /* кубик — тоже «предмет»: костяной в обеих темах */
  --die: #fbf7ee;
  --pip: #2a1d10;
  box-sizing: border-box;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --bg: #0f1c24;
    --panel: #172630;
    --ink: #e5ecef;
    --muted: #94a9b5;
    --line: #2a3e4a;
    --soft: #21333e;
    --deep: #173f57;
    --mid: #285e7c;
    --shallow: #3e7a8f;
    --isle: #8a7850;
    --port: #d9d3c2;
    --hexline: rgba(0, 0, 0, 0.3);
  }
}
:root[data-theme='dark'] {
  --bg: #0f1c24;
  --panel: #172630;
  --ink: #e5ecef;
  --muted: #94a9b5;
  --line: #2a3e4a;
  --soft: #21333e;
  --deep: #173f57;
  --mid: #285e7c;
  --shallow: #3e7a8f;
  --isle: #8a7850;
  --port: #d9d3c2;
  --hexline: rgba(0, 0, 0, 0.3);
}
* {
  box-sizing: border-box;
}
html {
  scroll-padding-top: env(safe-area-inset-top, 0px);
}
html,
body {
  height: 100%;
  margin: 0;
}
body {
  background: var(--bg);
  color: var(--ink);
  font:
    15px/1.4 Barlow,
    'Segoe UI',
    system-ui,
    sans-serif;
  display: flex;
  flex-direction: column;
}
h1,
h2 {
  font-family: 'PT Serif', 'Arial Narrow', sans-serif;
}
button,
input,
select {
  font: inherit;
  color: inherit;
}
button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}
small {
  display: block;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.25;
}
.top {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 5px 14px;
  flex-wrap: nowrap;
  white-space: nowrap;
  min-height: 44px;
}
.top > div:first-child {
  display: flex;
  align-items: baseline;
  gap: 10px;
  min-width: 0;
  flex-shrink: 1;
  overflow: hidden;
}
.top h1 {
  margin: 0;
  font-size: 22px;
  line-height: 1;
  flex: none;
}
.top h1 span {
  font-weight: 500;
  color: var(--muted);
}
#badge {
  font-size: 12px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
#round {
  font-family: 'PT Serif', sans-serif;
  flex: none;
}
#round b {
  font-size: 20px;
}
#round small {
  display: inline;
  margin-left: 6px;
}
#wx {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-left: auto;
  min-width: 0;
  flex-shrink: 0;
  max-width: 46vw;
}
#wx > div {
  min-width: 0;
  overflow: hidden;
  line-height: 1.15;
}
#wx b {
  font-family: 'PT Serif', sans-serif;
  font-size: 17px;
  line-height: 1.1;
}
#wx small {
  display: inline;
  margin-left: 6px;
}
#wx small.fc {
  display: block;
  margin-left: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}
#wx svg {
  width: 26px;
  height: 26px;
  flex: none;
}
.wdial {
  fill: var(--panel);
  stroke: var(--line);
}
.warrow {
  fill: none;
  stroke: var(--ink);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
main {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  min-height: 0;
  border-top: 1px solid var(--line);
}
/* в партии: журнал слева, карта, панель целей справа */
body.hasgame main {
  grid-template-columns: 270px minmax(0, 1fr) 340px;
}
.tools {
  display: flex;
  gap: 6px;
  flex: none;
}
.tools button {
  padding: 4px 9px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--panel);
  cursor: pointer;
  font-size: 13px;
}
.tools button[aria-pressed='true'] {
  background: var(--ink);
  color: var(--panel);
  border-color: var(--ink);
}
/* полоса капитанов */
#pbar {
  display: none;
  gap: 6px;
  padding: 5px 14px;
  overflow-x: auto;
  border-top: 1px solid var(--line);
}
body.hasgame #pbar {
  display: flex;
}
.pc {
  flex: 0 0 auto;
  min-width: 0;
  text-align: left;
  border: 1px solid var(--line);
  border-left: 5px solid var(--pc);
  border-radius: 9px;
  background: var(--panel);
  padding: 4px 9px;
  cursor: pointer;
  line-height: 1.2;
}
.pc.act {
  box-shadow: 0 0 0 2px var(--pc);
}
.pc .pn {
  display: flex;
  gap: 6px;
  align-items: baseline;
  font:
    700 16px 'PT Serif',
    sans-serif;
  white-space: nowrap;
  overflow: hidden;
}
.pc .pn .flag {
  font:
    600 12px Barlow,
    sans-serif;
}
.pc .pn small {
  display: inline;
  font:
    500 12px Barlow,
    sans-serif;
}
.pc .pl {
  display: flex;
  gap: 8px;
  align-items: center;
  font-size: 12px;
  color: var(--muted);
  margin-top: 3px;
  white-space: nowrap;
  overflow: hidden;
}
.pips {
  display: inline-flex;
  gap: 2px;
  vertical-align: -1px;
}
.pips i {
  width: 9px;
  height: 9px;
  border-radius: 2px;
  border: 1.5px solid var(--ink);
}
.pips i.on {
  background: var(--ink);
}
.pips.low i.on {
  background: var(--warn);
  border-color: var(--warn);
}
.bar {
  display: inline-block;
  width: 34px;
  height: 7px;
  border-radius: 4px;
  background: var(--line);
  overflow: hidden;
  vertical-align: 0;
}
.bar i {
  display: block;
  height: 100%;
  background: var(--mid);
}
.pp {
  display: inline-flex;
  gap: 2px;
}
.pp b {
  font:
    700 11px 'PT Serif',
    sans-serif;
  padding: 0 3px;
  border-radius: 3px;
  border: 1px dashed var(--line);
}
.pp b.on {
  background: var(--gold);
  border: 1px solid #10222e;
  color: #10222e;
}
.flag {
  font-weight: 600;
  color: var(--ink);
}
.flag.warn {
  color: var(--warn);
}
/* судовой журнал */
#logcol {
  display: none;
  overflow: auto;
  background: var(--panel);
  border-right: 1px solid var(--line);
  padding: 12px 14px;
}
body.hasgame #logcol {
  display: block;
}
#logcol h3 {
  margin: 2px 0 8px;
  font:
    700 20px 'PT Serif',
    sans-serif;
}
#logcol ol {
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: 13px;
}
#logcol li {
  padding: 5px 0;
  border-bottom: 1px solid var(--soft);
}
#logcol li.rnd {
  font-weight: 600;
  color: var(--ink);
  padding-top: 9px;
}
#logcol li:not(.rnd) {
  color: var(--muted);
}
#logcol li:first-child {
  color: var(--ink);
}
/* панель действий внизу */
/* стартовая страница: легенда и правила на карте сокровищ */
#intro {
  position: fixed;
  inset: 0;
  z-index: 11;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: radial-gradient(ellipse at 50% 40%, rgba(47, 107, 142, 0.55), rgba(8, 22, 32, 0.92)), var(--deep);
}
#intro.on {
  display: flex;
}
.tmap {
  position: relative;
  width: min(780px, 100%);
  color: var(--parch-ink);
  /* шрифт растёт с экраном, чтобы приветствие помещалось без прокрутки */
  font:
    clamp(12px, min(2.05vh, 1.1vh + 0.75vw), 16px) / 1.45 'PT Serif',
    Georgia,
    serif;
  background: radial-gradient(ellipse at 18% 12%, rgba(255, 250, 228, 0.75), transparent 42%),
    radial-gradient(ellipse at 85% 90%, rgba(120, 78, 30, 0.3), transparent 48%),
    radial-gradient(ellipse at 90% 10%, rgba(140, 90, 40, 0.2), transparent 35%),
    linear-gradient(135deg, var(--parch), var(--parch-2) 60%, var(--parch-3));
  box-shadow:
    inset 0 0 70px rgba(90, 55, 20, 0.6),
    inset 0 0 14px rgba(60, 35, 10, 0.7);
  clip-path: polygon(
    0% 2%,
    5% 0%,
    12% 1.6%,
    20% 0.2%,
    29% 1.2%,
    38% 0%,
    47% 1.5%,
    56% 0.3%,
    65% 1.4%,
    74% 0%,
    83% 1.3%,
    91% 0.1%,
    97% 1.1%,
    100% 3%,
    99% 13%,
    100% 24%,
    98.9% 36%,
    100% 48%,
    99.1% 60%,
    100% 72%,
    98.8% 84%,
    100% 96%,
    95% 100%,
    86% 98.7%,
    76% 100%,
    66% 98.8%,
    55% 100%,
    45% 98.6%,
    35% 100%,
    25% 98.8%,
    15% 100%,
    6% 98.9%,
    0% 97%,
    1.2% 85%,
    0% 73%,
    1% 61%,
    0% 49%,
    1.3% 37%,
    0% 25%,
    1% 13%
  );
}
.tmap-in {
  max-height: calc(100vh - 32px);
  max-height: calc(100dvh - 32px);
  overflow: auto;
  padding: clamp(18px, 4vh, 38px) clamp(18px, 5vw, 46px) clamp(12px, 2.5vh, 30px);
  scrollbar-width: thin;
  scrollbar-color: rgba(58, 40, 20, 0.45) transparent;
}
.tmap h2 {
  margin: 0;
  font:
    700 clamp(32px, 6.5vh, 56px) / 1 Caveat,
    cursive;
  color: var(--parch-red);
  text-align: center;
}
.tmap h3 {
  margin: 0.9em 0 0.3em;
  font:
    700 clamp(20px, 3.6vh, 30px) / 1 Caveat,
    cursive;
  color: var(--parch-ink);
  border-bottom: 1.5px dashed rgba(58, 40, 20, 0.4);
  padding-bottom: 3px;
}
.tmap p {
  margin: 0.45em 0;
}
.tm-kicker {
  text-align: center;
  font:
    600 clamp(17px, 2.8vh, 22px) Caveat,
    cursive;
  margin: 0 0 4px !important;
  color: rgba(58, 40, 20, 0.75);
}
.tm-lead {
  text-align: center;
  font-style: italic;
}
.tm-steps {
  padding-left: 22px;
}
.tm-steps li {
  margin: 0.25em 0;
}
.tm-steps b {
  color: var(--parch-red);
}
.tm-rules summary {
  font:
    700 clamp(19px, 3vh, 26px) Caveat,
    cursive;
  margin-top: 0.6em;
  cursor: pointer;
}
.tm-rules ul,
.tm-rules ol {
  font-size: 14.5px;
  padding-left: 20px;
}
.tm-rules li {
  margin: 5px 0;
}
.tm-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
  margin: clamp(10px, 2.2vh, 24px) 0 6px;
}
.tm-actions button {
  font:
    700 clamp(19px, 3vh, 24px) / 1 Caveat,
    cursive;
  padding: clamp(6px, 1.2vh, 10px) clamp(14px, 2.5vw, 22px);
  border-radius: 10px;
  border: 2px solid var(--parch-ink);
  background: transparent;
  color: var(--parch-ink);
  cursor: pointer;
}
.tm-actions .tm-go {
  background: var(--parch-red);
  border-color: var(--parch-red);
  color: var(--parch);
}
.tm-actions button:focus-visible {
  outline: 3px solid var(--parch-red);
  outline-offset: 3px;
}
.tm-rose {
  position: absolute;
  right: 26px;
  top: 22px;
  width: clamp(54px, 11vh, 92px);
  height: clamp(54px, 11vh, 92px);
  opacity: 0.55;
  pointer-events: none;
}
.tm-route {
  display: block;
  width: 100%;
  height: clamp(20px, 6vh, 70px);
  margin-top: 6px;
}
/* низкий экран: дорожка к кресту только мешает тексту */
@media (max-height: 640px) {
  .tm-route {
    display: none;
  }
}
.tm-route path {
  fill: none;
  stroke: var(--parch-red);
  stroke-width: 2.5;
  stroke-dasharray: 7 6;
  stroke-linecap: round;
}
.tm-route .x {
  stroke-dasharray: none;
  stroke-width: 4;
}
.mapwrap {
  position: relative;
  min-height: 0;
  min-width: 0;
  overflow: hidden;
}
#map {
  width: 100%;
  height: 100%;
  display: block;
  user-select: none;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
button {
  touch-action: manipulation;
}
.legend {
  position: absolute;
  left: 10px;
  bottom: 10px;
  background: color-mix(in srgb, var(--panel) 92%, transparent);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 8px;
  font-size: 12px;
  display: grid;
  gap: 3px;
}
.legend i {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  margin-right: 5px;
  vertical-align: -1px;
}
.t-deep {
  fill: var(--deep);
}
.t-mid {
  fill: var(--mid);
}
.t-shallow {
  fill: var(--shallow);
}
.t-isle {
  fill: var(--isle);
}
.t-port {
  fill: var(--port);
}
#terrain path {
  stroke: var(--hexline);
  stroke-width: 0.6;
}
.hl-bg {
  fill: none;
  stroke: #10222e;
  stroke-width: 2.6;
  stroke-linejoin: round;
  opacity: 0.55;
  pointer-events: none;
}
.hl {
  fill: transparent;
  stroke-width: 1.3;
  stroke-linejoin: round;
}
.hl.mine {
  cursor: pointer;
}
.tgt {
  fill: rgba(184, 67, 43, 0.3);
  stroke: var(--warn);
  stroke-width: 1.2;
  cursor: pointer;
}
.sel {
  fill: none;
  stroke: var(--ink);
  stroke-width: 1.5;
  stroke-dasharray: 2.5 2;
}
.route {
  fill: none;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 4 2.5;
  pointer-events: none;
}
.route-end {
  fill: none;
  stroke-width: 2.4;
  pointer-events: none;
}
.cost {
  font:
    600 6px Barlow,
    sans-serif;
  text-anchor: middle;
  fill: #10222e;
  pointer-events: none;
}
.nm {
  font:
    700 5px Barlow,
    sans-serif;
  text-anchor: middle;
  fill: #fff;
  paint-order: stroke;
  stroke: #10222e;
  stroke-width: 1.5px;
  pointer-events: none;
}
.pin {
  stroke: #10222e;
  stroke-width: 1;
}
.pintx {
  font:
    700 6.5px 'PT Serif',
    sans-serif;
  text-anchor: middle;
  fill: #10222e;
  pointer-events: none;
}
.ring {
  fill: none;
  stroke: var(--gold);
  stroke-width: 2;
  stroke-dasharray: 3 2;
}
.ship circle {
  stroke: #10222e;
  stroke-width: 1.2;
}
.ship text {
  font:
    700 7px Barlow,
    sans-serif;
  text-anchor: middle;
  fill: #10222e;
  pointer-events: none;
}
.ship.act circle {
  stroke: #fff;
  stroke-width: 2.2;
}
.anchor {
  fill: none;
  stroke: #10222e;
  stroke-width: 1.2;
}
.upm rect {
  fill: #10222e;
  stroke: var(--gold);
  stroke-width: 0.6;
}
.upm text {
  font:
    700 4.6px 'PT Serif',
    sans-serif;
  text-anchor: middle;
  fill: var(--gold);
  pointer-events: none;
}
.upm.open rect {
  fill: var(--gold);
  stroke: #10222e;
}
.upm.open text {
  fill: #10222e;
}
.chest circle {
  fill: var(--gold);
  stroke: #10222e;
  stroke-width: 0.8;
}
.chest path {
  fill: #10222e;
  fill-opacity: 0.35;
  stroke: #10222e;
  stroke-width: 0.7;
}
.chest .loop {
  fill: none;
}
#panel {
  overflow: auto;
  background: var(--panel);
  border-left: 1px solid var(--line);
  padding: 14px 16px 24px;
}
#panel h2 {
  margin: 4px 0 10px;
  font-size: 22px;
}
.note {
  color: var(--muted);
  font-size: 13.5px;
}
.turn {
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--soft);
  border-left: 5px solid var(--pc);
}
.turn b {
  font-family: 'PT Serif', sans-serif;
  font-size: 20px;
}
.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin: 10px 0;
}
.stat {
  background: var(--bg);
  border-radius: 8px;
  padding: 6px 8px;
}
.stat b {
  font-family: 'PT Serif', sans-serif;
  font-size: 20px;
  display: block;
}
.ship {
  border-left: 5px solid var(--pc);
}
.ship .stat {
  background: var(--panel);
}
.ship .stat .bar {
  width: 100%;
}
.sl {
  margin: 4px 0;
  font-size: 13.5px;
}
.gh {
  margin: 8px 0 2px;
  font-weight: 600;
  font-size: 13px;
  color: var(--muted);
}
.gear {
  margin: 0;
  padding-left: 18px;
  font-size: 13px;
}
.gear li {
  margin: 2px 0;
}
.acts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 10px 0;
}
.acts button,
.row button {
  text-align: left;
  padding: 9px 10px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: var(--bg);
  cursor: pointer;
  line-height: 1.2;
}
.acts button:hover:not(:disabled) {
  border-color: var(--ink);
}
.acts button.on {
  background: var(--gold);
  color: #10222e;
  border-color: #10222e;
}
.pk > b {
  display: block;
  margin-top: 8px;
  font-size: 14px;
}
.pk .acts {
  margin: 6px 0;
}
.pk .note {
  margin: 6px 0;
  font-size: 14px;
}
.pkx button {
  margin-top: 6px;
  background: transparent;
  color: var(--ink);
}
.evcard button:disabled {
  opacity: 0.55;
  cursor: default;
}
.evcard .stakes {
  margin: 8px 0 0;
  padding-left: 18px;
  font-size: 13.5px;
}
.evcard .stakes li {
  margin: 3px 0;
}
.outcome {
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--soft);
  font-size: 14px;
}
.outcome ul {
  margin: 6px 0 10px;
  padding-left: 18px;
}
.outcome li {
  margin: 4px 0;
}
.outcome .primary {
  width: 100%;
}
button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 8px 0;
}
.primary {
  background: var(--ink) !important;
  color: var(--panel) !important;
  border-color: var(--ink) !important;
  font-weight: 600;
}
.hint {
  font-weight: 600;
  margin: 6px 0;
}
.box {
  margin: 12px 0;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--bg);
}
.box > b {
  font-family: 'PT Serif', sans-serif;
  font-size: 18px;
}
.parts {
  display: flex;
  gap: 6px;
  margin: 8px 0;
}
.parts span {
  flex: 1;
  text-align: center;
  padding: 5px 0;
  border-radius: 6px;
  border: 1.5px dashed var(--line);
  font-size: 13px;
}
.parts span.on {
  background: var(--gold);
  border: 1.5px solid #10222e;
  color: #10222e;
  font-weight: 700;
}
.dest {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  border-top: 1px solid var(--line);
}
.dest div {
  flex: 1;
}
.dest button {
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--panel);
  cursor: pointer;
}
.players {
  list-style: none;
  padding: 0;
  margin: 12px 0;
}
.players li {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 7px 4px;
  border-bottom: 1px solid var(--line);
}
.players li.act {
  background: var(--soft);
  border-radius: 8px;
}
.players li > div {
  flex: 1;
  min-width: 0;
}
.players select {
  display: block;
  width: 100%;
  margin-top: 4px;
  padding: 5px 8px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--ink);
}
.dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  flex: none;
  border: 2px solid var(--ink);
  display: inline-block;
}
label {
  display: grid;
  gap: 4px;
  font-size: 13px;
  color: var(--muted);
}
input {
  width: 100%;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--ink);
}
.hexinfo {
  margin: 10px 0;
  padding: 8px 10px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  font-size: 13.5px;
}
details summary {
  cursor: pointer;
  font-weight: 600;
  margin-top: 10px;
}
.log ol {
  list-style: none;
  padding: 0;
  margin: 6px 0;
  font-size: 13px;
  color: var(--muted);
  max-height: 240px;
  overflow: auto;
}
.log li {
  padding: 3px 0;
  border-bottom: 1px solid var(--soft);
}
.rules ul {
  padding-left: 18px;
  font-size: 13.5px;
}
.rules li {
  margin: 4px 0;
}
.confirm {
  padding: 10px 12px;
  border: 1px solid var(--warn);
  border-radius: 10px;
  margin-top: 10px;
}
#toast {
  position: fixed;
  left: 50%;
  bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  transform: translate(-50%, 20px);
  background: var(--ink);
  color: var(--panel);
  padding: 10px 14px;
  border-radius: 10px;
  opacity: 0;
  pointer-events: none;
  transition: 0.2s;
  max-width: 90vw;
  z-index: 9;
}
#toast.on {
  opacity: 1;
  transform: translate(-50%, 0);
}
#evpop {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(10, 20, 28, 0.45);
  z-index: 10;
}
#evpop.on {
  display: flex;
}
.evcard .last {
  margin: 2px 0 8px;
  padding: 6px 9px;
  border-radius: 8px;
  background: var(--bg);
  font-size: 13.5px;
}
.evcard .rl {
  margin-top: 4px;
  font-size: 14px;
}
.evcard small.odds {
  margin-top: 3px;
  font-weight: 600;
  color: var(--ink);
}
.evcard .hs {
  margin-top: 6px;
  font-size: 13px;
}
.evcard .hs summary {
  margin: 0;
  font-weight: 600;
}
#latepop {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(10, 20, 28, 0.6);
  z-index: 12;
}
#latepop.on {
  display: flex;
}
#latepop .row {
  display: grid;
  grid-template-columns: 1fr 1fr;
}
#latepop .row button {
  width: 100%;
}
body.outsider [data-a='new'] {
  display: none !important;
}
/* трансляция на экран (?tv=комната): страница только показывает партию — без меню, кнопок хода и окон, которые надо закрывать */
.tools .tvb {
  display: none;
}
body.api:not(.tv) .tools .tvb {
  display: inline-block;
}
body.tv .tools button:not(#sndbtn),
body.tv .tools .more {
  display: none !important;
}
.tvqr {
  display: grid;
  justify-items: center;
  gap: 4px;
  margin: 12px 0;
  padding: 14px;
  border-radius: 12px;
  background: var(--bg);
  border: 1.5px dashed var(--line);
  text-align: center;
}
.tvqr small {
  color: var(--muted);
}
.tvqr .qr {
  width: min(230px, 100%);
  height: auto;
  border-radius: 6px;
}
.tvqr b {
  font:
    600 18px 'PT Serif',
    sans-serif;
  word-break: break-all;
}
.tvqr.sm .qr {
  width: 120px;
}
.tvqr.sm b {
  font-size: 15px;
}
.tvevs .ev {
  padding: 8px 11px;
  margin: 0 0 8px;
  border-radius: 9px;
  background: rgba(255, 250, 235, 0.45);
  border-left: 5px solid var(--pc);
}
.tvevs .ev h3 {
  margin: 2px 0;
  font-size: 17px;
}
.tvevs .ev .res {
  margin-top: 4px;
  font-size: 13px;
  font-weight: 600;
}
#cardpop .tvpop .row {
  display: grid;
  grid-template-columns: 1fr 1fr;
}
#cardpop .tvpop .row button {
  width: 100%;
}
#cardpop .tvlink {
  font:
    600 22px 'PT Serif',
    sans-serif;
  word-break: break-all;
  text-align: center;
  margin: 6px 0;
}
.evcard {
  background: var(--panel);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px 18px;
  width: min(420px, 100%);
  max-height: 85vh;
  overflow: auto;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.3);
}
.evcard .ev {
  padding: 10px 12px;
  margin-bottom: 10px;
  border-radius: 10px;
  background: var(--soft);
  border-left: 5px solid var(--pc);
}
.evcard .ev small {
  font-size: 13px;
}
.evcard h3 {
  margin: 2px 0 4px;
  font:
    700 24px/1.1 'PT Serif',
    sans-serif;
}
.evcard .res {
  font-weight: 600;
  margin-top: 6px;
}
.evcard .res::first-letter {
  text-transform: uppercase;
}
.evcard button {
  width: 100%;
  padding: 10px;
  border-radius: 9px;
  border: 1px solid var(--ink);
  cursor: pointer;
}
/* нападение: защитник решает, уйти или принять бой */
#duelpop {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(10, 20, 28, 0.55);
  z-index: 9;
}
#duelpop.on {
  display: flex;
}
#duelpop .row {
  display: grid;
  grid-template-columns: 1fr 1fr;
}
#duelpop .row button {
  width: 100%;
}
/* кубик: грани точками; toss — бросок в окне итога, idle — ждёт броска, shake — трясётся в руке после нажатия */
.die {
  display: inline-grid;
  grid-template: repeat(3, 1fr) / repeat(3, 1fr);
  gap: 2px;
  width: 48px;
  height: 48px;
  padding: 7px;
  border-radius: 11px;
  background: var(--die);
  border: 2px solid var(--dc, var(--parch-ink));
  box-shadow:
    inset 0 -4px 0 rgba(0, 0, 0, 0.12),
    0 4px 10px rgba(0, 0, 0, 0.28);
  vertical-align: middle;
}
.die i {
  border-radius: 50%;
}
.die i.on {
  background: var(--pip);
}
.dice {
  display: flex;
  gap: 18px;
  justify-content: center;
  align-items: flex-end;
  margin: 10px 0 4px;
}
.dice figure {
  margin: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.dice figcaption {
  font-size: 12.5px;
  color: var(--muted);
}
.dice.sm {
  justify-content: flex-start;
  gap: 10px;
  margin: 4px 0 0;
}
.dice.sm .die {
  width: 28px;
  height: 28px;
  padding: 4px;
  gap: 1px;
  border-radius: 7px;
  border-width: 1.5px;
}
#waitbox .die {
  width: 30px;
  height: 30px;
  padding: 4px;
  gap: 1px;
  border-radius: 7px;
  border-width: 1.5px;
}
.die.toss {
  animation: toss 0.9s cubic-bezier(0.2, 0.7, 0.3, 1) both;
}
.dice figure:nth-child(2) .die.toss {
  animation-delay: 0.15s;
}
@keyframes toss {
  0% {
    transform: translate(-70px, -40px) rotate(-560deg) scale(0.55);
    opacity: 0;
  }
  55% {
    transform: translate(8px, 5px) rotate(25deg) scale(1.1);
    opacity: 1;
  }
  78% {
    transform: rotate(-9deg);
  }
  100% {
    transform: none;
  }
}
.die.idle {
  animation: wob 1.6s ease-in-out infinite;
}
@keyframes wob {
  0%,
  100% {
    transform: rotate(-7deg);
  }
  50% {
    transform: rotate(7deg) translateY(-4px);
  }
}
.die.shake {
  animation: shake 0.12s linear infinite;
}
@keyframes shake {
  0% {
    transform: rotate(-14deg) translate(-3px, 1px);
  }
  50% {
    transform: rotate(12deg) translate(3px, -2px);
  }
  100% {
    transform: rotate(-14deg) translate(-3px, 1px);
  }
}
.evcard .ev.rolled .res {
  animation: fadein 0.4s 1s both;
}
@keyframes fadein {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}
.evcard .need {
  margin-top: 6px;
  font-size: 14px;
}
.evcard details.more {
  margin-top: 8px;
  font-size: 14px;
}
.evcard details.more summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--muted);
}
.evcard details.more p {
  margin: 6px 0;
}
.evcard .morebtn {
  width: auto;
  margin-top: 8px;
  padding: 4px 10px;
  font-size: 13.5px;
  background: transparent;
  color: var(--ink);
}
@media (prefers-reduced-motion: reduce) {
  .die.toss,
  .die.idle,
  .die.shake,
  .evcard .ev.rolled .res {
    animation: none;
  }
}
/* итоги партии: поверх всего, в цвете победителя */
#winpop {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(10, 20, 28, 0.6);
  z-index: 11;
}
#winpop.on {
  display: flex;
}
.wincard {
  background: var(--panel);
  color: var(--ink);
  border: 1px solid var(--line);
  border-top: 8px solid var(--pc);
  border-radius: 16px;
  padding: 18px 20px 16px;
  width: min(440px, 100%);
  max-height: 90vh;
  overflow: auto;
  text-align: center;
  box-shadow: 0 16px 50px rgba(0, 0, 0, 0.4);
}
.wincard h2 {
  margin: 6px 0 4px;
  font:
    700 40px/1.05 'PT Serif',
    'Arial Narrow',
    sans-serif;
}
.wincard .sub {
  color: var(--muted);
  margin: 0 0 12px;
}
.wincard .row {
  justify-content: center;
}
.crestx {
  font:
    700 18px 'PT Serif',
    sans-serif;
  text-anchor: middle;
  fill: #10222e;
}
.spin {
  transform-box: fill-box;
  transform-origin: center;
  animation: spin 14s linear infinite;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
.final {
  list-style: none;
  padding: 0;
  margin: 10px 0 14px;
  text-align: left;
}
.final li {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 7px 8px;
  border-bottom: 1px solid var(--line);
}
.final li.win {
  background: var(--soft);
  border-radius: 8px;
  border-bottom-color: transparent;
}
.final li > div {
  flex: 1;
  min-width: 0;
}
.place {
  font:
    700 20px 'PT Serif',
    sans-serif;
  width: 18px;
  text-align: center;
  color: var(--muted);
}
.final li.win .place {
  color: var(--gold);
}
/* телефон: карта сверху по ширине экрана (пропорции как у viewBox поля), под ней панель; страница прокручивается целиком */
@media (max-width: 820px) {
  body {
    height: auto;
    min-height: 100%;
  }
  .top {
    gap: 4px 12px;
    padding: 6px 12px;
    flex-wrap: wrap;
    white-space: normal;
  }
  .top > div:first-child {
    flex-basis: 100%;
  }
  #badge {
    white-space: nowrap;
  }
  .tools {
    flex: 1 1 0;
    min-width: 0;
    margin-left: auto;
    flex-wrap: wrap;
    justify-content: flex-end;
  }
  /* телефон: строка 1 — название, строка 2 — круг и кнопки, строка 3 — погода */
  #wx {
    order: 5;
    flex: 1 1 100%;
    max-width: none;
    margin-left: 0;
    min-width: 0;
  }
  #wx > div {
    white-space: normal;
  }
  .top h1 {
    font-size: 20px;
    white-space: nowrap;
  }
  #round b {
    font-size: 20px;
  }
  #wx b {
    font-size: 17px;
  }
  #wx svg {
    width: 26px;
    height: 26px;
  }
  main {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto auto;
  }
  #map {
    height: auto;
    aspect-ratio: var(--ar);
    max-height: 75vh;
  }
  .legend {
    position: static;
    border: 0;
    border-radius: 0;
    background: none;
    padding: 4px 12px 8px;
    font-size: 11px;
    grid-template-columns: repeat(2, auto);
    gap: 3px 12px;
  }
  #panel {
    border-left: 0;
    border-top: 1px solid var(--line);
    padding: 12px 12px 24px;
  }
  /* в партии: карта (действия — кнопками на ней), панель корабля, журнал — друг под другом */
  body.hasgame main {
    grid-template-columns: minmax(0, 1fr);
  }
  .mapwrap {
    order: 1;
  }
  #panel {
    order: 2;
  }
  #logcol {
    order: 3;
    border-right: 0;
    border-top: 1px solid var(--line);
    max-height: 45vh;
  }
  #pbar {
    padding: 8px 12px;
  }
  .tmap-in {
    padding: 22px 16px 12px;
  }
  .tm-rose {
    width: 58px;
    height: 58px;
    right: 14px;
    top: 14px;
  }
}
/* узкий ноутбук: колонки поуже */
@media (min-width: 821px) and (max-width: 1180px) {
  body.hasgame main {
    grid-template-columns: 210px minmax(0, 1fr) 300px;
  }
  #badge,
  .top h1 span {
    display: none;
  }
  .top > div:first-child {
    flex-shrink: 0;
  }
  #wx {
    flex-shrink: 1;
    max-width: none;
  }
  #wx > div {
    text-overflow: ellipsis;
  }
}
/* телефон боком: экономим высоту на шапке */
@media (max-height: 520px) and (min-width: 821px) {
  .top {
    gap: 4px 16px;
    padding: 4px 12px;
  }
  .top h1 {
    font-size: 19px;
  }
  #badge {
    font-size: 11px;
  }
  #round b {
    font-size: 18px;
  }
  #wx b {
    font-size: 15px;
  }
  #wx svg {
    width: 24px;
    height: 24px;
  }
  main {
    grid-template-columns: minmax(0, 1fr) 340px;
  }
  body.hasgame main {
    grid-template-columns: 200px minmax(0, 1fr) 290px;
  }
  #pbar {
    padding: 4px 12px;
  }
  .pc {
    padding: 3px 8px;
  }
  .legend {
    display: none;
  }
}
/* боковые панели — листы пергамента, как стартовая карта; внутри свои токены цвета: тёмные чернила на бумаге в любой теме */
#panel,
#logcol {
  --ink: var(--parch-ink);
  --muted: #6e5634;
  --line: rgba(58, 40, 20, 0.3);
  --bg: rgba(255, 248, 225, 0.42);
  --soft: rgba(120, 80, 30, 0.14);
  --panel: rgba(255, 250, 232, 0.6);
  --gold: #d39a22;
  color: var(--ink);
  border: 0;
  scrollbar-width: thin;
  scrollbar-color: rgba(58, 40, 20, 0.45) transparent;
  background: radial-gradient(ellipse at 22% 6%, rgba(255, 250, 228, 0.75), transparent 38%),
    radial-gradient(ellipse at 78% 96%, rgba(120, 78, 30, 0.3), transparent 45%),
    radial-gradient(ellipse at 95% 45%, rgba(140, 90, 40, 0.16), transparent 30%),
    linear-gradient(165deg, var(--parch), var(--parch-2) 62%, var(--parch-3));
  box-shadow:
    inset 0 0 55px rgba(90, 55, 20, 0.5),
    inset 0 0 10px rgba(60, 35, 10, 0.55);
}
#logcol {
  clip-path: polygon(
    0 0,
    98.7% 0%,
    98.6% 3.8%,
    99.4% 7.7%,
    99.2% 11.5%,
    98.8% 15.4%,
    98.7% 19.2%,
    99.5% 23.1%,
    98% 26.9%,
    98.5% 30.8%,
    98.9% 34.6%,
    99.1% 38.5%,
    98.2% 42.3%,
    98.4% 46.2%,
    99.5% 50%,
    98.7% 53.8%,
    99.2% 57.7%,
    98.4% 61.5%,
    99.3% 65.4%,
    98.6% 69.2%,
    98.7% 73.1%,
    99.3% 76.9%,
    99.5% 80.8%,
    97.9% 84.6%,
    97.9% 88.5%,
    99.4% 92.3%,
    98.8% 96.2%,
    97.9% 100%,
    0 100%
  );
  padding-right: 22px;
}
#panel {
  clip-path: polygon(
    100% 0,
    100% 100%,
    1.7% 100%,
    1.4% 96.2%,
    2% 92.3%,
    1.4% 88.5%,
    0.6% 84.6%,
    2% 80.8%,
    0.9% 76.9%,
    0.5% 73.1%,
    1.1% 69.2%,
    0.9% 65.4%,
    1.8% 61.5%,
    2% 57.7%,
    0.6% 53.8%,
    1.7% 50%,
    1.7% 46.2%,
    0.5% 42.3%,
    1% 38.5%,
    0.9% 34.6%,
    1.5% 30.8%,
    2.2% 26.9%,
    0.6% 23.1%,
    0.7% 19.2%,
    0.6% 15.4%,
    1.3% 11.5%,
    0.6% 7.7%,
    0.6% 3.8%,
    2% 0%
  );
  padding-left: 24px;
}
#logcol h3,
#panel h2 {
  font:
    700 30px/1 Caveat,
    cursive;
  color: var(--parch-ink);
}
#panel .box {
  border: 1.5px dashed var(--line);
  background: rgba(255, 250, 235, 0.32);
}
#panel .box > b {
  font:
    700 26px/1.05 Caveat,
    cursive;
}
#panel .ship {
  border-left: 5px solid var(--pc);
}
#logcol ol {
  font:
    13.5px/1.4 'PT Serif',
    Georgia,
    serif;
}
#logcol li {
  border-bottom: 1px dashed var(--line);
}
#logcol li.rnd {
  color: var(--parch-red);
}
#panel details summary {
  font:
    700 22px Caveat,
    cursive;
}
#panel .hexinfo {
  border-color: var(--line);
  background: rgba(255, 250, 235, 0.3);
}
/* карточки преимуществ: сундук капитана и мини-карточки в полосе капитанов */
.c-perm {
  --ct: #2f6b8e;
}
.c-once {
  --ct: #b07a12;
}
.c-fight {
  --ct: #9b2f1f;
}
.hold > small {
  margin-top: 3px;
}
.cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-top: 7px;
}
.card {
  position: relative;
  display: grid;
  grid-template-columns: 26px minmax(0, 1fr);
  align-items: center;
  gap: 3px 7px;
  min-height: 44px;
  padding: 5px 7px 5px 11px;
  border-radius: 7px;
  background: #fbf4e2;
  color: #3a2814;
  border: 1px solid rgba(58, 40, 20, 0.35);
  box-shadow: 0 1px 3px rgba(60, 35, 10, 0.25);
  text-align: left;
  overflow: hidden;
}
.card::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 5px;
  background: var(--ct);
}
.card .cg {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2px solid var(--ct);
  color: var(--ct);
  font:
    700 15px/22px 'PT Serif',
    sans-serif;
  text-align: center;
}
.card b {
  display: block;
  font:
    700 13.5px/1.1 'PT Serif',
    sans-serif;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.card .ctp {
  display: block;
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ct);
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.card small {
  display: none;
  grid-column: 1/-1;
  font-size: 11px;
  line-height: 1.2;
  color: #5a4428;
}
button.card {
  font: inherit;
  cursor: pointer;
}
button.card:hover {
  background: #fff9ea;
}
.card.use {
  box-shadow:
    0 0 0 2px var(--ct),
    0 2px 6px rgba(60, 35, 10, 0.35);
}
.card.use .ctp {
  font-weight: 700;
}
#cardpop {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(10, 20, 28, 0.5);
  z-index: 10;
}
#cardpop.on {
  display: flex;
}
.bigcard {
  position: relative;
  text-align: center;
  padding: 16px 14px 12px;
  margin-bottom: 10px;
  border-radius: 12px;
  background: #fbf4e2;
  color: #3a2814;
  border: 1px solid rgba(58, 40, 20, 0.35);
  border-top: 8px solid var(--ct);
}
.bigcard .cg {
  display: inline-block;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 3px solid var(--ct);
  color: var(--ct);
  font:
    700 26px/38px 'PT Serif',
    sans-serif;
}
.bigcard h3 {
  margin: 6px 0 2px;
  color: #3a2814;
}
.bigcard .ctp {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ct);
  font-weight: 700;
}
.bigcard p {
  margin: 8px 0 0;
  font-size: 15px;
}
.card.empty {
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  box-shadow: none;
  border: 1.5px dashed rgba(58, 40, 20, 0.35);
  color: rgba(58, 40, 20, 0.5);
  font:
    600 17px Caveat,
    cursive;
}
.card.empty::before {
  display: none;
}
/* всё на одном экране: плотнее блок корабля и отступы панели */
#panel .box {
  margin: 0 0 8px;
  padding: 8px 11px;
}
.ship .stats {
  margin: 6px 0;
  grid-template-columns: repeat(2, 1fr);
}
.ship .stat {
  padding: 4px 7px;
}
.ship .stat b {
  font-size: 18px;
}
.ship .stat small {
  font-size: 11px;
}
.sl {
  margin: 2px 0 !important;
  font-size: 13px !important;
}
/* карта лапита — справа в полосе капитанов */
.lapita {
  margin-left: auto;
  flex: none;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: var(--panel);
}
.lapita .lh {
  display: flex;
  gap: 10px;
  align-items: baseline;
  white-space: nowrap;
}
.lapita .lh b {
  font:
    700 16px 'PT Serif',
    sans-serif;
}
.lt {
  font: inherit;
  font-size: 12px;
  color: var(--muted);
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  white-space: nowrap;
}
.lt.hot {
  color: var(--ink);
  font-weight: 600;
}
.lt.warn {
  color: var(--warn);
  font-weight: 600;
}
.lps {
  display: flex;
  gap: 5px;
}
.lp {
  display: inline-flex;
  gap: 4px;
  align-items: baseline;
  padding: 2px 7px;
  border-radius: 6px;
  border: 1px dashed var(--line);
  background: var(--bg);
  cursor: pointer;
  font-size: 12.5px;
  white-space: nowrap;
  color: var(--ink);
}
.lp b {
  font:
    700 12px 'PT Serif',
    sans-serif;
}
.lp small {
  display: inline;
  font-size: 11px;
}
.lp.on {
  background: var(--gold);
  border: 1px solid #10222e;
  color: #10222e;
}
.lp.on small {
  color: #10222e;
}
/* описание выбранной клетки — плашкой поверх карты */
#hexbox {
  position: relative;
}
#hexbox:empty {
  display: none;
}
#hexbox .hexinfo {
  margin: 0;
  padding-right: 30px;
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
}
#hexbox .hx {
  position: absolute;
  top: 4px;
  right: 6px;
  border: 0;
  background: none;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  color: var(--muted);
}
/* кнопки на поле: «Плыть» у выбранной клетки, «Завершить ход» у своего корабля */
.mapbtn {
  position: absolute;
  z-index: 3;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1px;
  padding: 5px 12px 6px;
  border-radius: 9px;
  border: 2px solid #10222e;
  background: var(--gold);
  color: #10222e;
  font:
    700 17px/1.05 'PT Serif',
    sans-serif;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
  cursor: pointer;
  white-space: nowrap;
}
.mapbtn[hidden] {
  display: none;
}
.mapbtn small {
  color: #10222e;
  font:
    500 11.5px Barlow,
    sans-serif;
}
.mapbtn:hover {
  filter: brightness(1.06);
}
/* у своего корабля: находки, которые можно применить сейчас, защита талисмана и «Завершить ход» */
.mapgrp {
  position: absolute;
  z-index: 3;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
#shipbtns {
  right: 10px;
  bottom: 10px;
  align-items: stretch;
  padding: 6px;
  border-radius: 11px;
  background: color-mix(in srgb, var(--panel) 80%, transparent);
  border-left: 4px solid var(--pc);
}
#shipbtns .gh2 {
  font:
    700 14px 'PT Serif',
    sans-serif;
  padding: 0 4px 2px;
  color: var(--ink);
}
#shipbtns .mapbtn {
  font-size: 15px;
  padding: 4px 10px;
  border-width: 1.5px;
}
#shipbtns .mapbtn.cardb {
  padding: 3px 10px 3px 5px;
}
#shipbtns .cg {
  width: 21px;
  height: 21px;
  font-size: 12.5px;
  line-height: 17px;
}
.mapgrp.h {
  flex-direction: row;
  align-items: stretch;
}
.mapbtn.x {
  padding: 5px 11px;
  background: var(--panel);
  color: var(--ink);
  border-color: var(--ink);
  font-size: 18px;
  justify-content: center;
}
.mapbtn.act {
  background: var(--panel);
  color: var(--ink);
  border-color: var(--gold);
}
.mapbtn.act small {
  color: var(--muted);
}
/* плашка подсказки вверху карты */
/* левый верхний угол поля: подсказка хода и описание клетки */
#mapinfo {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 3;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  max-width: min(430px, calc(100% - 16px));
}
#maphint:empty {
  display: none;
}
#maphint .mh {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 6px 12px;
  border-radius: 9px;
  background: color-mix(in srgb, var(--panel) 94%, transparent);
  border: 1px solid var(--line);
  border-left: 5px solid var(--pc);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
  font-size: 13.5px;
}
#maphint button {
  flex: none;
  padding: 4px 10px;
  border-radius: 7px;
  border: 1px solid var(--ink);
  background: var(--bg);
  cursor: pointer;
  font-size: 13px;
}
.mapgrp[hidden] {
  display: none;
}
.mapgrp .mapbtn {
  position: static;
}
#endbtn {
  margin: 0;
}
/* ожидание соперника в бою — окном посреди поля */
#waitbox {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 4;
  width: min(400px, calc(100% - 24px));
}
#waitbox:empty {
  display: none;
}
#waitbox .evcard {
  width: 100%;
}
#waitbox h3 .dots::after {
  content: '';
  animation: dots 1.4s steps(4) infinite;
}
@keyframes dots {
  0% {
    content: '';
  }
  25% {
    content: '.';
  }
  50% {
    content: '..';
  }
  75% {
    content: '...';
  }
}
#waitbox .row {
  margin-top: 10px;
}
@media (prefers-reduced-motion: reduce) {
  #waitbox h3 .dots::after {
    animation: none;
    content: '…';
  }
}
#atkbtns {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 3;
}
#atkbtns .mapbtn {
  pointer-events: auto;
  align-items: center;
}
/* «Напасть» над своим кораблём: одна кнопка или список целей */
.atkgrp {
  position: absolute;
  display: flex;
  flex-direction: column;
  gap: 4px;
  pointer-events: auto;
}
.atkgrp .mapbtn {
  position: static;
}
.atkgrp .gh2 {
  padding: 3px 8px;
  border-radius: 7px;
  background: var(--panel);
  color: var(--ink);
  font:
    700 14px 'PT Serif',
    sans-serif;
  text-align: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}
.mapbtn.atk .dot {
  width: 11px;
  height: 11px;
  margin-right: 5px;
  vertical-align: -1px;
  border-color: #10222e;
}
/* таблица боя по залпам: её видят все */
.ftab {
  width: 100%;
  border-collapse: collapse;
  margin: 8px 0 2px;
  font-size: 13px;
  line-height: 1.25;
}
.ftab th,
.ftab td {
  padding: 4px 5px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}
.ftab th {
  font:
    700 15px 'PT Serif',
    sans-serif;
  border-bottom: 3px solid var(--pc, var(--line));
}
.ftab th small {
  font:
    500 11px Barlow,
    sans-serif;
}
.ftab td:first-child {
  width: 34px;
  text-align: center;
  color: var(--muted);
}
.ftab td small {
  font-size: 11.5px;
}
.ftab .hit {
  color: var(--warn);
  font-weight: 700;
  white-space: nowrap;
}
.ftab .miss {
  color: var(--muted);
  white-space: nowrap;
}
.ftab tr.now td {
  background: var(--bg);
  font-weight: 600;
}
.ftab td.wt {
  color: var(--muted);
}
.ftab tr.later td {
  color: var(--muted);
}
.ftab tfoot td {
  font-weight: 700;
  border-bottom: 0;
}
body.tv #waitbox {
  width: min(560px, calc(100% - 24px));
}
body.tv .ftab {
  font-size: 16px;
}
body.tv .ftab th {
  font-size: 19px;
}
/* общий экран: что делает капитан в этот ход */
.turn .doing {
  margin-top: 6px;
  font-weight: 600;
}
.tvdone {
  margin: 6px 0 0;
  padding-left: 18px;
  font-size: 13px;
  color: var(--muted);
}
.tvdone li {
  margin: 2px 0;
}
/* управление комнатой и возвращение за свой корабль */
.manage {
  margin-top: 10px;
}
.manage .players li {
  align-items: flex-start;
}
.mrow {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 5px;
}
.mrow button {
  padding: 4px 9px;
  border-radius: 7px;
  border: 1px solid var(--line);
  background: var(--bg);
  cursor: pointer;
  font-size: 12.5px;
}
.mrow .confirm {
  flex-basis: 100%;
  margin-top: 4px;
}
.claims {
  display: grid;
  gap: 6px;
  margin: 8px 0;
}
.claims button {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 9px 10px;
  border-radius: 9px;
  border: 1px solid var(--ink);
  background: var(--bg);
  cursor: pointer;
  text-align: left;
}
#latepop .claims button {
  width: 100%;
}
.mapbtn.atk {
  background: var(--warn);
  color: #fff;
  border-color: #10222e;
}
.mapbtn.atk small {
  color: #fff;
  opacity: 0.85;
}
.mapbtn.end {
  margin-top: 4px;
  background: var(--panel);
  color: var(--ink);
  border-color: var(--ink);
}
.mapbtn.end small {
  color: var(--muted);
}
.mapbtn.cardb {
  flex-direction: row;
  align-items: center;
  gap: 8px;
  padding: 4px 10px 4px 6px;
  background: #fbf4e2;
  color: #3a2814;
  border-color: var(--ct);
  font-size: 15.5px;
}
.mapbtn.cardb .cg {
  flex: none;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid var(--ct);
  color: var(--ct);
  font:
    700 14px/20px 'PT Serif',
    sans-serif;
  text-align: center;
}
.mapbtn.cardb > span:last-child {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}
.mapbtn.cardb small {
  color: #5a4428;
  white-space: normal;
  max-width: 190px;
  text-align: left;
}
.mapbtn.shield {
  background: var(--ink);
  color: var(--panel);
  border-color: var(--gold);
}
.mapbtn.shield small {
  color: var(--panel);
  opacity: 0.8;
}
.tools .ng {
  display: none;
}
body.hasgame .tools .ng {
  display: inline-block;
}
.minis {
  display: inline-flex;
  gap: 2px;
}
.mc {
  display: inline-block;
  width: 13px;
  height: 17px;
  border-radius: 2px;
  background: var(--ct);
  color: #fff;
  font:
    700 10px/17px 'PT Serif',
    sans-serif;
  font-style: normal;
  text-align: center;
}
@media (max-width: 820px) {
  .card small {
    display: block;
  }
  .lapita {
    margin-left: 0;
  }
  #shipbtns {
    position: static;
    flex-direction: row;
    flex-wrap: wrap;
    margin: 6px 12px 0;
    background: var(--panel);
  }
  #shipbtns .gh2 {
    flex-basis: 100%;
  }
  #shipbtns .mapbtn,
  #gobtn .mapbtn {
    font-size: 13px;
    padding: 3px 8px;
  }
  #gobtn small {
    display: none;
  }
  #maphint .mh {
    font-size: 12px;
    padding: 4px 8px;
  }
}
@media (max-width: 820px) {
  #panel,
  #logcol {
    clip-path: none;
    padding-left: 14px;
    padding-right: 14px;
  }
}
@media (prefers-reduced-motion: reduce) {
  #toast {
    transition: none;
  }
  .spin {
    animation: none;
  }
}
/* обучение: затемнение с «окном» на цель, боцман с пергаментным пузырём */
#tour {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: none;
}
#tour.on {
  display: block;
}
.tspot {
  position: fixed;
  border-radius: 12px;
  box-shadow: 0 0 0 200vmax rgba(8, 22, 32, 0.62);
  outline: 2px solid var(--gold);
  outline-offset: 2px;
  pointer-events: none;
  transition:
    left 0.45s ease,
    top 0.45s ease,
    width 0.45s ease,
    height 0.45s ease;
}
.tspot.none {
  outline: none;
}
.tguide {
  position: fixed;
  display: flex;
  align-items: flex-end;
  gap: 2px;
  width: min(470px, calc(100vw - 24px));
  transition:
    left 0.45s ease,
    top 0.45s ease;
}
.tguide .pir {
  flex: none;
  width: 112px;
  height: 128px;
  filter: drop-shadow(0 6px 10px rgba(0, 0, 0, 0.35));
  animation: pbob 3.4s ease-in-out infinite;
}
.pir .eye {
  transform-box: fill-box;
  transform-origin: center;
  animation: pblink 4.6s infinite;
}
.pir.talk .mouth {
  transform-box: fill-box;
  transform-origin: center;
  animation: ptalk 0.2s ease-in-out infinite alternate;
}
.pir .parrot {
  transform-box: fill-box;
  transform-origin: 50% 90%;
  animation: pparrot 5.2s ease-in-out infinite;
}
@keyframes pbob {
  50% {
    transform: translateY(-4px);
  }
}
@keyframes pblink {
  0%,
  46%,
  50%,
  100% {
    transform: scaleY(1);
  }
  48% {
    transform: scaleY(0.1);
  }
}
@keyframes ptalk {
  from {
    transform: scaleY(0.35);
  }
  to {
    transform: scaleY(1.5);
  }
}
@keyframes pparrot {
  0%,
  70%,
  100% {
    transform: rotate(0);
  }
  76% {
    transform: rotate(-9deg);
  }
  84% {
    transform: rotate(5deg);
  }
}
.tbub {
  position: relative;
  flex: 1;
  min-width: 0;
  margin-bottom: 34px;
  padding: 12px 16px 8px;
  border-radius: 14px;
  background: var(--parch);
  color: var(--parch-ink);
  border: 2px solid var(--parch-3);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  font:
    15px/1.45 'PT Serif',
    Georgia,
    serif;
}
.tbub::before {
  content: '';
  position: absolute;
  left: -11px;
  bottom: 26px;
  border: 10px solid transparent;
  border-right-color: var(--parch-3);
  border-left: 0;
}
.tbub .tn {
  color: rgba(58, 40, 20, 0.7);
  font:
    600 12px Barlow,
    sans-serif;
}
.tbub h3 {
  margin: 0 0 4px;
  font:
    700 28px/1 Caveat,
    cursive;
  color: var(--parch-red);
}
.tbub .ttx {
  min-height: 6.2em;
}
.tbub .row {
  align-items: center;
  margin: 8px 0 2px;
}
.tbub .row span {
  flex: 1;
}
.tbub button {
  padding: 5px 11px;
  border-radius: 8px;
  border: 1px solid var(--parch-3);
  background: transparent;
  color: var(--parch-ink);
  cursor: pointer;
  font:
    500 14px Barlow,
    sans-serif;
}
.tbub button:disabled {
  opacity: 0.4;
  cursor: default;
}
.tbub button.primary {
  background: var(--parch-red) !important;
  border-color: var(--parch-red) !important;
  color: var(--parch) !important;
}
@media (max-width: 520px) {
  .tguide .pir {
    width: 80px;
    height: 92px;
  }
  .tbub .row {
    flex-wrap: nowrap;
    gap: 6px;
  }
  .tbub button {
    padding: 5px 8px;
    font-size: 13px;
    white-space: nowrap;
  }
  .tbub {
    font-size: 14px;
    padding: 10px 12px 6px;
  }
  .tbub .ttx {
    min-height: 7.5em;
  }
}
@media (prefers-reduced-motion: reduce) {
  .tspot,
  .tguide {
    transition: none;
  }
  .pir,
  .pir * {
    animation: none !important;
  }
}
#hello {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: radial-gradient(ellipse at 50% 45%, rgba(30, 70, 96, 0.82), rgba(8, 22, 32, 0.94));
}
#hello.on {
  display: flex;
}
.hguide {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  width: min(560px, 100%);
}
.hguide .pir {
  flex: none;
  width: 150px;
  height: 171px;
  filter: drop-shadow(0 6px 10px rgba(0, 0, 0, 0.35));
  animation: pbob 3.4s ease-in-out infinite;
}
.hguide .tbub {
  font-size: 16px;
  padding: 14px 18px 10px;
}
.hguide .tbub h3 {
  font-size: 32px;
}
.hguide .tbub .row {
  flex-wrap: wrap;
  gap: 8px;
}
.hguide .tbub button.primary {
  font-size: 16px;
  padding: 8px 16px;
}
.hguide .hsplit {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed rgba(58, 40, 20, 0.3);
  align-items: center;
}
.hguide .hsplit small {
  flex: 1 1 220px;
  font-size: 13.5px;
  line-height: 1.35;
  color: inherit;
  opacity: 0.8;
}
/* пульт капитана в партии «за столом»: общая карта и журнал на большом экране, на телефоне — кусок карты у корабля, действия и карточки */
body.ctl #logcol,
body.ctl #pbar .pc,
body.ctl .legend,
body.ctl .tools .ng,
body.ctl .tools .tvb {
  display: none !important;
}
@media (min-width: 821px) {
  body.ctl.hasgame main {
    grid-template-columns: minmax(0, 1fr) 340px;
  }
}
@media (max-width: 520px) {
  .hguide {
    flex-direction: column;
    align-items: center;
  }
  .hguide .pir {
    width: 96px;
    height: 110px;
  }
  .hguide .tbub {
    margin-bottom: 0;
    width: 100%;
    font-size: 15px;
  }
  .hguide .tbub::before {
    left: 50%;
    top: -11px;
    bottom: auto;
    margin-left: -10px;
    border: 10px solid transparent;
    border-bottom-color: var(--parch-3);
    border-top: 0;
  }
  .hguide .tbub h3 {
    font-size: 27px;
  }
}
@media (prefers-reduced-motion: reduce) {
  .hguide .pir,
  .hguide .pir * {
    animation: none !important;
  }
}
/* телефон в партии: всё на одном экране — карта у своего корабля с компасом ветра, внизу меню; вкладки выезжают поверх
   карты (renderMob) */
#mnav,
#mwind {
  display: none;
}
body.mob {
  --mnav: calc(54px + env(safe-area-inset-bottom, 0px));
  height: 100dvh;
  min-height: 0;
  overflow: hidden;
}
body.mob .top > div:first-child,
body.mob #wx,
body.mob #pbar,
body.mob #logcol,
body.mob .legend {
  display: none !important;
}
body.mob .top {
  flex-wrap: nowrap;
  padding: 4px 10px;
  min-height: 0;
}
body.mob #round {
  flex: 1 1 auto;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
body.mob #round b {
  font-size: 17px;
  line-height: 1.1;
}
body.mob #round small {
  font-size: 11px;
}
body.mob .tools .ng,
body.mob .tools .tvb {
  display: none !important;
}
body.mob .tools {
  flex: none;
  flex-wrap: nowrap;
  gap: 4px;
}
body.mob .tools button {
  font-size: 12px;
  padding: 3px 6px;
}
body.mob main {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
body.mob .mapwrap {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
body.mob #map {
  flex: 1;
  min-height: 0;
  height: auto;
  max-height: none;
  aspect-ratio: auto;
}
body.mob #shipbtns {
  flex: none;
  margin: 4px 8px 6px;
}
body.mob #panel {
  display: none;
}
/* компас ветра в правом верхнем углу карты: нажатие открывает вкладку «Ветер» */
body.mob #mwind {
  display: block;
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 3;
}
#mwind button {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px 9px 3px 4px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--panel) 94%, transparent);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
  text-align: left;
  cursor: pointer;
}
#mwind b {
  font-size: 14px;
  line-height: 1.1;
}
#mwind small {
  font-size: 11px;
}
body.mob #mapinfo {
  max-width: calc(100% - 150px);
}
#mwind button {
  max-width: 130px;
}
/* нижнее меню */
body.mob #mnav {
  display: flex;
  flex: none;
  height: var(--mnav);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  border-top: 1px solid var(--line);
  background: var(--panel);
}
#mnav button {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  border: 0;
  border-top: 3px solid transparent;
  background: none;
  cursor: pointer;
  font:
    600 16px 'PT Serif',
    sans-serif;
}
#mnav button[hidden] {
  display: none;
}
#mnav button[aria-pressed='true'] {
  border-top-color: var(--gold);
  background: var(--soft);
}
#mnav svg {
  width: 22px;
  height: 22px;
  flex: none;
}
/* вкладка — лист снизу над меню; «Сундук» — это сама панель корабля, «Игроки» и «Ветер» рисуются в #msheet */
#msheet {
  display: none;
}
body.mob.mt-chest #panel,
body.mob #msheet.on {
  display: block;
  position: fixed;
  left: 0;
  right: 0;
  bottom: var(--mnav);
  z-index: 6;
  max-height: calc(100dvh - var(--mnav) - 56px);
  overflow: auto;
  padding: 14px 14px 18px;
  border-radius: 14px 14px 0 0;
  box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.35);
  clip-path: none;
}
#msheet {
  --ink: var(--parch-ink);
  --muted: #6e5634;
  --line: rgba(58, 40, 20, 0.3);
  --panel: rgba(255, 250, 232, 0.6);
  --soft: rgba(120, 80, 30, 0.14);
  --bg: rgba(255, 248, 225, 0.42);
  --gold: #d39a22;
  color: var(--ink);
  background: linear-gradient(165deg, var(--parch), var(--parch-2) 62%, var(--parch-3));
}
#msheet h2 {
  margin: 0 0 10px;
  font-size: 22px;
}
#msheet h3 {
  margin: 14px 0 6px;
  font:
    700 18px 'PT Serif',
    sans-serif;
}
#msheet ol {
  margin: 0;
  padding-left: 20px;
  font-size: 14px;
}
#msheet li.rnd {
  font-weight: 600;
  list-style: none;
  margin: 8px 0 2px -20px;
}
.mx {
  float: right;
  width: 34px;
  height: 34px;
  margin: -6px -4px 0 8px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--panel);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}
body:not(.mob) .mx {
  display: none;
}
.mpl {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.mpl .pc,
.mpl .lapita {
  width: 100%;
  margin-left: 0;
}
.mpl .lh,
.mpl .lps {
  flex-wrap: wrap;
  white-space: normal;
}
.mpl .lt {
  white-space: normal;
  text-align: left;
}
.mwx {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}
.mwx svg {
  width: 64px;
  height: 64px;
  flex: none;
}
.mwx b {
  font-size: 20px;
}
.mwx p {
  margin: 2px 0 0;
}
#msheet .sl {
  margin: 6px 0;
}
.mleg {
  display: grid;
  gap: 4px;
  margin-top: 12px;
  font-size: 13px;
}
.mleg i {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 2px;
  margin-right: 6px;
  vertical-align: -1px;
}
/* «Плыть ▸» на телефоне — крупная полоса над нижним меню, а не маленькая кнопка у клетки */
body.mob #gobtn:not([hidden]) {
  position: static;
  flex: none;
  display: flex;
  gap: 8px;
  margin: 6px 8px;
}
body.mob #gobtn .mapbtn {
  flex: 1 1 auto;
  flex-direction: row;
  align-items: baseline;
  justify-content: center;
  gap: 10px;
  padding: 12px 16px;
  font-size: 22px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
}
body.mob #gobtn .mapbtn.x {
  flex: none;
  align-items: center;
  min-width: 56px;
}
body.mob #gobtn small {
  display: inline;
  font-size: 15px;
  color: inherit;
  opacity: 0.75;
}
/* голосовой чат комнаты (voice.js): кнопка в шапке — только в онлайн-игре и не на общем экране; пока ты в голосе,
   в левом нижнем углу — кто в чате (говорящий подсвечен) и кнопка микрофона */
#vcbtn {
  display: none;
}
body.api:not(.tv) #vcbtn {
  display: inline-block;
}
#vcbar {
  position: fixed;
  left: 12px;
  bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  z-index: 8;
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-width: 240px;
  padding: 8px 10px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--panel) 95%, transparent);
  color: var(--ink);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
  font-size: 13px;
}
#vcbar[hidden] {
  display: none;
}
#vcbar ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
#vcbar li {
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#vcbar li.wait {
  opacity: 0.55;
}
#vcbar .dot {
  flex: none;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  transition: box-shadow 0.15s;
}
#vcbar li.talk .dot {
  box-shadow:
    0 0 0 3px color-mix(in srgb, var(--gold) 70%, transparent),
    0 0 10px var(--gold);
}
#vcbar li.talk {
  font-weight: 600;
}
#vcbar button {
  padding: 4px 8px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  cursor: pointer;
  font-size: 12px;
}
#vcbar button[aria-pressed='true'] {
  background: var(--warn);
  border-color: var(--warn);
  color: #fff;
}
/* телефон: узкая полоска у левого края карты — только кружки капитанов и микрофон */
body.mob #vcbar {
  top: 50%;
  bottom: auto;
  left: 6px;
  transform: translateY(-50%);
  padding: 6px;
  max-width: none;
  align-items: center;
}
body.mob #vcbar li {
  font-size: 0;
  gap: 0;
}
body.mob #vcbar .vm {
  display: none;
}
body.mob #vcbar .dot {
  width: 18px;
  height: 18px;
}
body.mob #vcbar button {
  font-size: 0;
  width: 30px;
  height: 30px;
  padding: 0;
}
body.mob #vcbar button::before {
  content: '🎙';
  font-size: 15px;
}
body.mob #vcbar button[aria-pressed='true']::before {
  content: '🔇';
}

/* ===== Деревянный корабль: палуба из досок, латунь, пергамент. Это «предмет», как карта и кубик, поэтому одинаково
   в светлой и тёмной теме; меняется только цвет моря (--deep, --mid, --shallow: ночью вода темнее) ===== */
:root,
:root:not([data-theme='light']),
:root[data-theme='dark'] {
  --bg: #eadbb4;
  --panel: #f7edd3;
  --ink: #2e1f10;
  --muted: #6e5634;
  --line: #c4ac7f;
  --soft: #ecdcb3;
  --gold: #d39a22;
  --warn: #a8361f;
  --port: #f3e8cc;
  /* дерево и латунь */
  --wood: #5a3a20;
  --wood-d: #3a2311;
  --wood-l: #7a5232;
  --seam: #1f1108;
  --brass: #c9973a;
  --brass-hi: #f1d48c;
  --brass-lo: #7e5718;
  --onwood: #f4e4bd;
  --onwood-2: #cdb48a;
  --sea-out: #12354a;
  --planks:
    repeating-linear-gradient(0deg, transparent 0 44px, rgba(0, 0, 0, 0.45) 44px 46px, rgba(255, 220, 170, 0.06) 46px 47px),
    repeating-linear-gradient(
      90deg,
      rgba(255, 230, 190, 0.035) 0 2px,
      transparent 2px 9px,
      rgba(0, 0, 0, 0.05) 9px 11px,
      transparent 11px 23px
    ),
    linear-gradient(180deg, #62402a, #4c2f19 60%, #42280f);
  --brass-plate: linear-gradient(180deg, #f0d391, #cf9f45 48%, #a97a2a);
}
body {
  background: var(--planks);
  background-attachment: fixed;
}
/* шапка — тёмный брус с латунной полосой */
.top {
  --ink: var(--onwood);
  --muted: var(--onwood-2);
  --panel: rgba(0, 0, 0, 0.28);
  --line: var(--brass);
  color: var(--ink);
  background:
    repeating-linear-gradient(90deg, rgba(255, 230, 190, 0.03) 0 2px, transparent 2px 12px),
    linear-gradient(180deg, #4b2e17, #2e1b0c);
  border-bottom: 3px solid var(--brass-lo);
  box-shadow:
    inset 0 -1px 0 var(--brass-hi),
    0 3px 10px rgba(0, 0, 0, 0.45);
  position: relative;
  z-index: 4;
}
.top h1 {
  font:
    700 27px/1 'Cormorant Garamond',
    'PT Serif',
    serif;
  color: var(--brass-hi);
  text-shadow: 0 1px 0 #000;
  letter-spacing: 0.3px;
}
.top h1 span {
  font-size: 15px;
  color: var(--onwood-2);
}
#round b,
#wx b {
  color: var(--brass-hi);
}
/* латунные таблички-кнопки */
.tools button,
.mapbtn,
#maphint button {
  background: var(--brass-plate);
  color: #2a1906;
  border: 1px solid var(--brass-lo);
  border-radius: 6px;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.55),
    inset 0 -1px 0 rgba(0, 0, 0, 0.2),
    0 2px 0 var(--seam),
    0 3px 8px rgba(0, 0, 0, 0.35);
  font-family: 'PT Serif', Georgia, serif;
  font-weight: 700;
  text-shadow: 0 1px 0 rgba(255, 240, 200, 0.5);
}
.tools button:hover,
.mapbtn:hover {
  filter: brightness(1.08);
}
.tools button:active,
.mapbtn:active {
  transform: translateY(1px);
  box-shadow:
    inset 0 1px 3px rgba(0, 0, 0, 0.35),
    0 1px 0 var(--seam);
}
.tools button[aria-pressed='true'] {
  background: linear-gradient(180deg, #8a5f22, #b98a3a);
  color: #fff3d4;
  border-color: var(--brass-lo);
  text-shadow: 0 1px 0 #000;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.45);
}
.mapbtn small,
.mapbtn.act small,
.mapbtn.end small {
  color: #4a3316;
  text-shadow: none;
}
/* «Завершить ход», стоянка, рыбалка — светлые таблички из пергамента в латунной оправе */
.mapbtn.act,
.mapbtn.end,
.mapbtn.x {
  background: linear-gradient(180deg, #fbf3dc, #ead7a8);
  color: var(--ink);
  border: 2px solid var(--brass);
}
.mapbtn.atk {
  background: linear-gradient(180deg, #c4462c, #8e2a17);
  color: #fff4dc;
  border-color: #4a120a;
  text-shadow: 0 1px 0 #000;
}
.mapbtn.atk small {
  color: #ffe6c2;
}
/* полоса капитанов — бирки на палубе */
#pbar {
  border-top: 0;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.32), rgba(0, 0, 0, 0.12));
  padding-top: 7px;
  padding-bottom: 7px;
}
.pc,
.lapita {
  background: linear-gradient(180deg, #fbf3dc, #eedcae);
  border: 1px solid #8a6a3c;
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.4);
}
.pc {
  border-left: 6px solid var(--pc);
}
.pc.act {
  box-shadow:
    0 0 0 2px var(--pc),
    0 0 14px 2px color-mix(in srgb, var(--pc) 60%, transparent);
}
.pc .plab {
  font-size: 11px;
  color: var(--muted);
}
.lp.on {
  background: var(--brass-plate);
  border-color: var(--brass-lo);
  color: #2a1906;
}
/* карта — морская карта в деревянной раме с латунным кантом */
.mapwrap {
  background: radial-gradient(ellipse at 50% 45%, #1e5270, var(--sea-out) 72%, #0b2231);
}
.mapwrap::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 2;
  box-shadow:
    inset 0 0 0 7px var(--wood-d),
    inset 0 0 0 9px var(--brass-lo),
    inset 0 0 0 10px var(--brass-hi),
    inset 0 0 40px rgba(0, 0, 0, 0.55);
}
body.mob .mapwrap::after {
  box-shadow:
    inset 0 0 0 3px var(--brass-lo),
    inset 0 0 24px rgba(0, 0, 0, 0.5);
}
.nm {
  font-family: 'PT Serif', Georgia, serif;
}
/* подсказка хода — записка на пергаменте */
#maphint .mh,
#hexbox .hexinfo,
.legend,
#mwind button {
  background: linear-gradient(180deg, #fbf3dc, #efe0b6);
  border: 1px solid #8a6a3c;
  color: var(--ink);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.4);
}
#maphint .mh {
  border-left: 6px solid var(--pc);
  font:
    14.5px/1.35 'PT Serif',
    Georgia,
    serif;
}
#mapinfo,
.legend {
  margin: 6px;
}
/* действия хода — дощечка с латунными кнопками */
#shipbtns {
  background: linear-gradient(180deg, var(--wood-l), var(--wood-d));
  border: 1px solid var(--seam);
  border-left: 5px solid var(--pc);
  box-shadow:
    inset 0 1px 0 rgba(255, 220, 170, 0.2),
    0 6px 16px rgba(0, 0, 0, 0.5);
  margin: 6px;
}
#shipbtns .gh2 {
  color: var(--brass-hi);
}
/* окна событий, боя, карточек — пергамент в раме */
.evcard,
.wincard {
  border: 3px solid var(--wood);
  box-shadow:
    0 0 0 1px var(--brass),
    0 14px 44px rgba(0, 0, 0, 0.55);
}
.evcard h3 {
  font-family: 'Cormorant Garamond', 'PT Serif', serif;
  font-size: 28px;
}
.primary {
  background: linear-gradient(180deg, #5a3a20, #3a2311) !important;
  color: var(--brass-hi) !important;
  border-color: var(--seam) !important;
}
/* телефон: нижнее меню — тоже брус */
body.mob #mnav {
  --ink: var(--onwood);
  background: linear-gradient(180deg, #4b2e17, #2e1b0c);
  border-top: 3px solid var(--brass-lo);
  color: var(--onwood);
}
#mnav button[aria-pressed='true'] {
  background: rgba(255, 220, 160, 0.12);
  color: var(--brass-hi);
}
/* меню «Ещё» в шапке */
.more {
  position: relative;
}
.more > summary {
  list-style: none;
  padding: 4px 10px;
  border-radius: 6px;
  cursor: pointer;
  color: var(--onwood);
  border: 1px solid var(--brass-lo);
  background: rgba(0, 0, 0, 0.25);
  font:
    700 13px 'PT Serif',
    Georgia,
    serif;
}
.more > summary::-webkit-details-marker {
  display: none;
}
.more[open] > summary {
  background: rgba(255, 220, 160, 0.15);
}
.more .menu {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  z-index: 20;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 230px;
  padding: 10px;
  border-radius: 8px;
  background: linear-gradient(180deg, #4b2e17, #2e1b0c);
  border: 1px solid var(--brass-lo);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.55);
}
.more .menu button {
  text-align: left;
  white-space: normal;
}
.more .menu small {
  display: block;
  font:
    400 11.5px/1.25 Barlow,
    sans-serif;
  color: #4a3316;
  text-shadow: none;
}
/* легенда и приветствие лежат на столе в капитанской каюте; прочие окна затемняют палубу тёплой тенью */
#intro,
#hello {
  background:
    radial-gradient(ellipse at 50% 40%, rgba(255, 200, 120, 0.12), rgba(10, 5, 2, 0.72) 85%),
    var(--planks);
}
#evpop,
#latepop,
#duelpop,
#winpop,
#cardpop {
  background: rgba(24, 13, 5, 0.58);
}
.tools button {
  white-space: nowrap;
}
