@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@400;500&family=EB+Garamond:wght@400;500&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
 --font-display: 'Cinzel', Georgia, serif;
 --font-body: 'EB Garamond', Georgia, serif;
 --font-mono: 'JetBrains Mono', ui-monospace, monospace;
 --parchment: #f3ead0;
 --parchment-light: #faf4e2;
 --ink: #2e2417;
 --ink-soft: #52432d;
 --ink-faint: #66563b;
 --maroon: #6b1c1c;
 --maroon-dark: #4a1010;
 --gold: #9e7a30;
 --gold-light: #d4a85a;
 --gold-pale: #e8d5a0;
 --wood: #7a5a35;
 --border-subtle: rgba(158, 122, 48, 0.25);
 --border-frame: rgba(158, 122, 48, 0.4);
 --status-success: #276339;
 --status-warn: #9e7a30;
 --status-danger: #6b1c1c;
 --ease-out: cubic-bezier(.33, 1, .68, 1);
}

@media (prefers-color-scheme: dark) {
 :root {
  color-scheme: dark;
  --parchment: #1a1510;
  --parchment-light: #241c15;
  --ink: #efe2c4;
  --ink-soft: #cbb692;
  --ink-faint: #b09e80;
  --maroon: #d46a61;
  --maroon-dark: #4a1414;
  --gold: #c99c48;
  --gold-light: #e8c878;
  --gold-pale: #f0d99f;
  --wood: #8f6a40;
  --border-subtle: rgba(201, 156, 72, 0.2);
  --border-frame: rgba(201, 156, 72, 0.35);
  --status-success: #6ebb84;
  --status-warn: #e8c878;
  --status-danger: #e2756c;
 }
}

*, *::before, *::after {
 box-sizing: border-box;
}

[hidden] {
 display: none !important;
}

html {
 font-size: 100%;
 -webkit-text-size-adjust: 100%;
 scroll-behavior: smooth;
}

body {
 display: grid;
 grid-template-rows: auto 1fr auto;
 min-height: 100vh;
 min-height: 100svh;
 margin: 0;
 background: var(--parchment);
 color: var(--ink);
 font-family: var(--font-body);
 font-size: 1.0625rem;
 line-height: 1.65;
 text-wrap: pretty;
 -webkit-font-smoothing: antialiased;
 -moz-osx-font-smoothing: grayscale;
}

::selection {
 background: var(--gold-pale);
 color: var(--maroon-dark);
}

@media (prefers-color-scheme: dark) {
 ::selection {
  background: var(--maroon-dark);
  color: var(--gold-pale);
 }
}

a:focus-visible,
button:focus-visible,
input:focus-visible {
 outline: 2px solid var(--maroon);
 outline-offset: 4px;
}

.sr-only {
 position: absolute;
 width: 1px;
 height: 1px;
 padding: 0;
 margin: -1px;
 overflow: hidden;
 clip-path: inset(50%);
 white-space: nowrap;
}

.rule {
 display: flex;
 align-items: center;
 justify-content: center;
 gap: 1rem;
 min-height: 2.75rem;
 padding: .65rem 1.25rem;
 background: var(--maroon-dark);
 border-bottom: 1px solid var(--gold);
}

.rule span {
 color: var(--gold-pale);
 font-family: var(--font-display);
 font-size: .75rem;
 font-weight: 500;
 letter-spacing: .28em;
 text-indent: .28em;
}

.rule-line {
 display: block;
 width: clamp(28px, 10vw, 72px);
 height: 1px;
 background: var(--gold);
 opacity: .75;
}

main {
 display: grid;
 place-items: center;
 padding: clamp(2rem, 6vw, 4.5rem) clamp(1rem, 4vw, 2rem);
}

.gate {
 position: relative;
 width: min(100%, 35rem);
 padding: clamp(2.25rem, 5vw, 3.5rem) clamp(1.5rem, 5vw, 3rem);
 background: var(--parchment-light);
 border: 1px solid var(--gold);
 text-align: center;
}

.gate::before {
 content: '';
 position: absolute;
 inset: 6px;
 border: 1px solid var(--gold);
 opacity: .4;
 pointer-events: none;
}

.brand-logo {
 display: block;
 width: clamp(230px, 48vw, 340px);
 max-width: 100%;
 height: auto;
 margin: -1rem auto clamp(.75rem, 2vw, 1.25rem);
 filter: drop-shadow(0 8px 10px rgba(46, 36, 23, .2));
}

.brand-logo-compact {
 width: clamp(180px, 42vw, 240px);
 margin-top: -1.5rem;
}

@media (prefers-color-scheme: dark) {
 .brand-logo {
  filter: drop-shadow(0 8px 12px rgba(0, 0, 0, .5));
 }
}

.tag {
 margin: 0 0 .75rem;
 color: var(--maroon);
 font-family: var(--font-mono);
 font-size: .75rem;
 font-weight: 500;
 letter-spacing: .36em;
 text-indent: .36em;
}

h1 {
 margin: 0;
 color: var(--ink);
 font-family: var(--font-display);
 font-size: clamp(1.875rem, 1.2rem + 3vw, 3.25rem);
 font-weight: 500;
 line-height: 1.12;
 letter-spacing: .03em;
 text-wrap: balance;
}

h1 .name {
 display: inline-block;
 padding-bottom: .22em;
 border-bottom: 1px solid var(--gold);
 color: var(--maroon);
}

.lede {
 max-width: 32ch;
 margin: 1.5rem auto 2rem;
 color: var(--ink-soft);
 font-size: clamp(1.0625rem, .98rem + .25vw, 1.1875rem);
 line-height: 1.65;
 text-wrap: pretty;
}

.btn {
 position: relative;
 display: inline-flex;
 align-items: center;
 justify-content: center;
 gap: .75rem;
 min-height: 48px;
 max-width: 100%;
 padding: .85rem 2rem;
 border: 1px solid var(--maroon-dark);
 border-radius: 0;
 background: var(--gold-light);
 color: var(--maroon-dark);
 font-family: var(--font-display);
 font-size: .9375rem;
 font-weight: 500;
 letter-spacing: .05em;
 line-height: 1.2;
 text-decoration: none;
 cursor: pointer;
 -webkit-tap-highlight-color: transparent;
 transition:
  background-color 200ms var(--ease-out),
  border-color 200ms var(--ease-out),
  color 200ms var(--ease-out),
  transform 100ms var(--ease-out);
}

.btn::before {
 content: '';
 position: absolute;
 inset: 3px;
 border: 1px solid var(--maroon-dark);
 opacity: .35;
 pointer-events: none;
}

.btn:hover {
 background: var(--gold-pale);
 border-color: var(--maroon);
}

.btn:active {
 transform: scale(.985);
}

.btn::after {
 display: inline-block;
 width: 0;
 height: 0;
 border-top: 4px solid transparent;
 border-bottom: 4px solid transparent;
 border-left: 5px solid currentColor;
 content: '';
 opacity: .8;
}

.btn-secondary {
 background: var(--parchment);
 color: var(--ink);
 border: 1px solid var(--gold);
}

.btn-secondary::before {
 border: 1px solid var(--gold);
 opacity: .5;
}

.btn-secondary:hover {
 background: var(--parchment-light);
 border-color: var(--maroon);
 color: var(--maroon);
}

.btn-secondary:hover::before {
 border-color: var(--maroon);
}

.meta {
 margin: 1.5rem 0 0;
 color: var(--ink-faint);
 font-family: var(--font-mono);
 font-size: .75rem;
 letter-spacing: .08em;
}

footer {
 padding: .85rem clamp(1.25rem, 4vw, 2rem);
 border-top: 1px solid var(--gold);
 background: var(--maroon-dark);
}

footer p {
 margin: 0;
 color: var(--gold-pale);
 font-family: var(--font-body);
 font-size: .875rem;
 letter-spacing: .05em;
 text-align: center;
}

.gate > * {
 animation: rise 540ms var(--ease-out) both;
}

.gate > *:nth-child(1) { animation-delay: 0ms; }
.gate > *:nth-child(2) { animation-delay: 70ms; }
.gate > *:nth-child(3) { animation-delay: 140ms; }
.gate > *:nth-child(4) { animation-delay: 210ms; }
.gate > *:nth-child(5) { animation-delay: 280ms; }
.gate > *:nth-child(6) { animation-delay: 350ms; }

@keyframes rise {
 from {
  transform: translateY(10px);
  opacity: 0;
 }
}

.auth-gate {
 max-width: 32rem;
 padding-top: clamp(2rem, 4vw, 2.75rem);
}

.auth-header .lede {
 margin: .75rem auto 1.5rem;
}

.auth-tabs {
 display: grid;
 grid-template-columns: 1fr 1fr;
 margin: 0 0 1.75rem;
 border-bottom: 1px solid var(--gold);
}

.auth-tab {
 padding: .75rem 1rem;
 border: 0;
 background: transparent;
 color: var(--ink-faint);
 font-family: var(--font-display);
 font-size: .8125rem;
 font-weight: 500;
 letter-spacing: .08em;
 cursor: pointer;
 border-bottom: 2px solid transparent;
 margin-bottom: -1px;
 transition:
  color 150ms var(--ease-out),
  border-color 150ms var(--ease-out);
}

.auth-tab:hover {
 color: var(--ink);
}

.auth-tab.is-active {
 color: var(--maroon);
 border-bottom-color: var(--maroon);
}

.auth-tab:focus-visible {
 outline: 2px solid var(--maroon);
 outline-offset: -2px;
}

.form-flow {
 display: flex;
 flex-direction: column;
 gap: 1.15rem;
 text-align: left;
}

.field {
 display: flex;
 flex-direction: column;
 gap: .4rem;
}

.field label {
 color: var(--ink);
 font-family: var(--font-display);
 font-size: .75rem;
 font-weight: 500;
 letter-spacing: .06em;
}

.field input {
 width: 100%;
 min-height: 46px;
 padding: .7rem .9rem;
 border: 1px solid var(--gold);
 border-radius: 0;
 background: var(--parchment);
 color: var(--ink);
 font-family: var(--font-body);
 font-size: 1.0625rem;
 transition:
  border-color 150ms var(--ease-out),
  background-color 150ms var(--ease-out);
}

.field input::placeholder {
 color: var(--ink-faint);
 opacity: .65;
}

.field input:hover {
 border-color: var(--gold-light);
}

.field input:focus-visible {
 outline: 2px solid var(--maroon);
 outline-offset: 1px;
 border-color: var(--maroon);
 background: var(--parchment-light);
}

.field input:user-invalid {
 border-color: var(--status-danger);
}

.field-actions {
 display: flex;
 flex-direction: column;
 align-items: center;
 gap: 1rem;
 margin-top: .75rem;
}

.field-actions .btn {
 width: 100%;
}

.link-subtle {
 display: inline-flex;
 align-items: center;
 gap: .4rem;
 color: var(--ink-faint);
 font-family: var(--font-mono);
 font-size: .75rem;
 letter-spacing: .05em;
 text-decoration: none;
 border-bottom: 1px solid transparent;
 padding-bottom: 1px;
 transition:
  color 150ms var(--ease-out),
  border-color 150ms var(--ease-out);
}

.link-subtle::before {
 content: '←';
 font-family: var(--font-body);
}

.link-subtle:hover {
 color: var(--maroon);
 border-bottom-color: var(--maroon);
}

/* Actions in table rows: reset UA button chrome, tint in runic palette. */
button.link-subtle {
 min-height: 0;
 padding: .3rem .7rem;
 border: 1px solid var(--border-subtle);
 background: transparent;
 color: var(--ink-soft);
 line-height: 1.3;
 cursor: pointer;
 -webkit-tap-highlight-color: transparent;
 transition:
  color 150ms var(--ease-out),
  border-color 150ms var(--ease-out),
  background-color 150ms var(--ease-out),
  transform 100ms var(--ease-out);
}

button.link-subtle::before {
 content: none;
}

button.link-subtle:hover {
 border-color: var(--gold);
 background: var(--parchment-light);
 color: var(--maroon);
}

button.link-subtle:active {
 transform: scale(.97);
}

button.link-subtle:focus-visible {
 outline: 2px solid var(--gold);
 outline-offset: 1px;
}

button.link-subtle[data-approve]:hover {
 border-color: var(--status-success);
 color: var(--status-success);
}

button.link-subtle[data-reject]:hover {
 border-color: var(--status-danger);
 color: var(--status-danger);
}

.board-main {
 display: block;
 padding: clamp(1.5rem, 4vw, 3rem) clamp(1rem, 3vw, 2.5rem);
}

.board-shell {
 max-width: 74rem;
 margin: 0 auto;
 width: 100%;
 display: flex;
 flex-direction: column;
 gap: 2rem;
}

.board-masthead {
 display: flex;
 justify-content: space-between;
 align-items: flex-end;
 gap: 1.5rem;
 flex-wrap: wrap;
 padding-bottom: 1.25rem;
 border-bottom: 1px solid var(--gold);
}

.board-branding {
 display: flex;
 align-items: center;
 gap: .9rem;
 margin-bottom: .45rem;
}

.board-branding .tag {
 margin: 0;
}

.board-logo {
 width: 4.5rem;
 height: auto;
 filter: drop-shadow(0 3px 4px rgba(46, 36, 23, .2));
}

@media (max-width: 34rem) {
 .board-logo {
  width: 3.75rem;
 }
}

.board-title {
 margin: 0;
 font-family: var(--font-display);
 font-size: clamp(1.75rem, 1.2rem + 1.8vw, 2.5rem);
 font-weight: 500;
 line-height: 1.15;
 color: var(--ink);
 letter-spacing: .02em;
}

.stat-deck {
 display: grid;
 grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
 gap: 1rem;
}

.stat-pod {
 padding: 1.15rem 1.25rem;
 background: var(--parchment-light);
 border: 1px solid var(--gold);
 border-left: 3px solid var(--gold);
 display: flex;
 flex-direction: column;
 gap: .25rem;
}

.stat-label {
 color: var(--ink-faint);
 font-family: var(--font-mono);
 font-size: .75rem;
 letter-spacing: .08em;
}

.stat-val {
 font-family: var(--font-display);
 font-size: 2.125rem;
 line-height: 1.1;
 font-weight: 500;
 color: var(--ink);
 font-variant-numeric: tabular-nums;
}

.stat-val-alert {
 color: var(--maroon);
}

.stat-note {
 color: var(--ink-soft);
 font-size: .875rem;
 line-height: 1.4;
}

.board-grid {
 display: grid;
 grid-template-columns: 2fr 1fr;
 gap: 1.5rem;
 align-items: start;
}

.module-nav { display: flex; flex-direction: column; gap: .35rem; }
.module-nav .sheet-title { margin-bottom: .5rem; }
.module-link { border: 0; border-left: 2px solid transparent; padding: .55rem .75rem; background: transparent; color: var(--ink-soft); text-align: left; font: 500 .85rem var(--font-display); cursor: pointer; }
.module-link:hover, .module-link:focus-visible { border-left-color: var(--maroon); color: var(--maroon); background: var(--parchment); }
.form-status { min-height: 1.5em; margin: 1rem 0 0; color: var(--status-success); font-family: var(--font-mono); font-size: .75rem; }
.form-status.is-error { color: var(--status-danger); }

.parchment-sheet {
 position: relative;
 padding: clamp(1.25rem, 3vw, 1.75rem);
 background: var(--parchment-light);
 border: 1px solid var(--gold);
}

.parchment-sheet::before {
 content: '';
 position: absolute;
 inset: 4px;
 border: 1px solid var(--gold);
 opacity: .3;
 pointer-events: none;
}

.sheet-title {
 margin: 0 0 1.25rem;
 font-family: var(--font-display);
 font-size: 1.125rem;
 font-weight: 500;
 color: var(--maroon);
 border-bottom: 1px solid var(--gold);
 padding-bottom: .5rem;
 letter-spacing: .04em;
}

.table-frame {
 overflow-x: auto;
 scrollbar-width: thin;
 scrollbar-color: var(--gold) var(--parchment);
}

.table-frame::-webkit-scrollbar {
 height: 6px;
}

.table-frame::-webkit-scrollbar-track {
 background: var(--parchment);
}

.table-frame::-webkit-scrollbar-thumb {
 background: var(--gold);
}

.runic-table {
 width: 100%;
 border-collapse: collapse;
 text-align: left;
 font-size: .9375rem;
 font-variant-numeric: tabular-nums;
 white-space: nowrap;
}

.runic-table th {
 padding: .65rem .75rem;
 color: var(--ink-faint);
 font-family: var(--font-display);
 font-size: .75rem;
 font-weight: 500;
 letter-spacing: .08em;
 border-bottom: 1px solid var(--gold);
}

.runic-table td {
 padding: .85rem .75rem;
 border-bottom: 1px solid var(--border-subtle);
 color: var(--ink);
 vertical-align: middle;
}

.runic-table tr:last-child td {
 border-bottom: 0;
}

.runic-table code {
 font-family: var(--font-mono);
 font-size: .8125rem;
 color: var(--maroon);
 background: var(--parchment);
 padding: .15em .4em;
 border: 1px solid var(--border-subtle);
}

.tag-status {
 display: inline-block;
 padding: .2rem .55rem;
 font-family: var(--font-mono);
 font-size: .75rem;
 letter-spacing: .04em;
 border: 1px solid currentColor;
}

.tag-status.is-success {
 color: var(--status-success);
}

.tag-status.is-warn {
 color: var(--status-warn);
}

.tag-status.is-danger {
 color: var(--status-danger);
}

.decree-list {
 list-style: none;
 padding: 0;
 margin: 0;
 display: flex;
 flex-direction: column;
 gap: 1.25rem;
}

.decree-item {
 display: flex;
 flex-direction: column;
 gap: .3rem;
 border-left: 2px solid var(--gold);
 padding-left: .95rem;
}

.decree-head {
 font-family: var(--font-display);
 font-size: .9375rem;
 font-weight: 500;
 color: var(--ink);
 letter-spacing: .03em;
}

.decree-body {
 margin: 0;
 font-size: .9375rem;
 color: var(--ink-soft);
 line-height: 1.5;
 text-wrap: pretty;
}

@media (max-width: 58rem) {
 .board-grid {
  grid-template-columns: 1fr;
 }
}

@media (max-width: 30rem) {
 .rule {
  gap: .65rem;
 }

 .gate {
  padding: 2rem 1.25rem;
 }

 .btn {
  width: 100%;
 }

 .board-masthead {
  flex-direction: column;
  align-items: flex-start;
 }

 .board-actions {
  width: 100%;
 }

 .board-actions .btn {
  width: 100%;
 }
}

@media (max-height: 38rem) {
 main {
  padding-block: 1.5rem;
 }

 .gate {
  padding-block: 1.75rem;
 }

 .crest {
  width: 72px;
  margin-bottom: 1rem;
 }

 .lede {
  margin-block: 1rem 1.25rem;
 }
}

@media (prefers-reduced-motion: reduce) {
 *, *::before, *::after {
  animation-duration: .01ms !important;
  transition-duration: .01ms !important;
 }
}

/* ================= Mapa świata (moduł) ================= */
.map-toolbar {
 display: flex;
 flex-wrap: wrap;
 align-items: center;
 gap: .6rem;
 margin: 0 0 1rem;
}
.map-toolbar .sheet-title { flex: 1 1 auto; }
.map-toolbar .input,
.map-measure .input {
 background: var(--parchment-light);
 color: var(--ink);
 border: 1px solid var(--border-frame);
 border-radius: 4px;
 padding: .35rem .5rem;
 font-family: var(--font-mono);
 font-size: .78rem;
 min-width: 0;
}
.map-toolbar #m-search { flex: 0 1 260px; }
.map-toolbar .btn.is-active { border-color: var(--maroon); color: var(--maroon); }

.map-layout {
 display: grid;
 grid-template-columns: minmax(0, 1fr) 250px;
 gap: .9rem;
 align-items: start;
}
@media (max-width: 860px) {
 .map-layout { grid-template-columns: minmax(0, 1fr); }
 .map-canvas-wrap { height: 62vh !important; }
}

.map-canvas-wrap {
 position: relative;
 height: 68vh;
 min-height: 320px;
 border: 2px solid var(--border-frame);
 border-radius: 6px;
 background: var(--parchment);
 overflow: hidden;
 box-shadow: inset 0 0 24px rgba(0, 0, 0, .06);
}
.map-canvas {
 display: block;
 width: 100%;
 height: 100%;
 touch-action: none;
 cursor: grab;
}

.map-side {
 display: flex;
 flex-direction: column;
 gap: .6rem;
 max-height: 68vh;
}
.map-legend-head {
 display: flex;
 justify-content: space-between;
 align-items: baseline;
 gap: .5rem;
 font-family: var(--font-display);
 font-size: .8rem;
 letter-spacing: .06em;
 color: var(--ink-soft);
 border-bottom: 1px solid var(--border-subtle);
 padding-bottom: .3rem;
}
.map-legend-head span {
 font-family: var(--font-mono);
 font-size: .68rem;
 color: var(--ink-faint);
 letter-spacing: .02em;
}
.map-legend {
 display: flex;
 flex-direction: column;
 gap: 2px;
 overflow: auto;
 min-height: 0;
 flex: 1 1 auto;
 padding-right: 2px;
}
.map-legend-item {
 display: flex;
 align-items: center;
 gap: .45rem;
 width: 100%;
 padding: .28rem .35rem;
 border: 1px solid transparent;
 border-radius: 3px;
 background: transparent;
 color: var(--ink-soft);
 font-family: var(--font-body);
 font-size: .82rem;
 text-align: left;
 cursor: pointer;
}
.map-legend-item:hover { background: var(--parchment-light); border-color: var(--border-subtle); }
.map-legend-item.is-active { background: var(--gold-pale); border-color: var(--gold); color: var(--ink); }
.map-swatch {
 width: 10px;
 height: 10px;
 flex: none;
 border-radius: 2px;
 box-shadow: 0 0 0 1px rgba(46, 36, 23, .35);
}
.map-legend-name {
 flex: 1 1 auto;
 overflow: hidden;
 text-overflow: ellipsis;
 white-space: nowrap;
}
.map-legend-count {
 font-family: var(--font-mono);
 font-size: .68rem;
 color: var(--ink-faint);
}

.map-measure {
 display: flex;
 flex-direction: column;
 gap: .3rem;
 padding: .55rem .6rem;
 border: 1px solid var(--border-frame);
 border-radius: 5px;
 background: var(--parchment-light);
}
.map-measure-row {
 display: flex;
 justify-content: space-between;
 align-items: center;
 gap: .6rem;
 font-family: var(--font-mono);
 font-size: .72rem;
 color: var(--ink-soft);
}
.map-measure-row strong { color: var(--ink); }
.map-measure-row label { font-size: .7rem; }
.map-measure .input { max-width: 108px; }
