:root {
  --bg: #1a1208;
  --bg-2: #2b1a10;
  --panel: rgba(37, 24, 14, 0.9);
  --panel-border: rgba(232, 213, 163, 0.2);
  --text: #e8d5a3;
  --muted: #c7ab72;
  --accent: #8b3a1e;
  --accent-soft: #a55a33;
  --good: #73ba7a;
  --bad: #d37b61;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  font-family: Georgia, serif;
  color: var(--text);
  background: var(--bg);
  position: relative;
}

.page-bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(1300px 420px at 10% -10%, rgba(118, 76, 43, 0.28), transparent 60%),
    radial-gradient(900px 300px at 90% -10%, rgba(122, 58, 31, 0.22), transparent 60%),
    linear-gradient(165deg, var(--bg), var(--bg-2));
}

.page-bg::before,
.page-bg::after {
  content: "";
  position: fixed;
  top: 0;
  bottom: 0;
  width: min(20vw, 280px);
  background-image:
    linear-gradient(to var(--fade-dir), rgba(26, 18, 8, 0.15), rgba(26, 18, 8, 0.92)),
    url("assets/backgrounds/image-1714164009Ngu.jpg");
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  opacity: 0;
  pointer-events: none;
  filter: sepia(0.62) saturate(0.72) contrast(0.96);
}

.page-bg::before {
  left: 0;
  --fade-dir: right;
  transform: translateX(-24px);
  animation: sideFadeInLeft 1200ms ease-out 240ms forwards;
}

.page-bg::after {
  right: 0;
  --fade-dir: left;
  transform: translateX(24px);
  animation: sideFadeInRight 1200ms ease-out 240ms forwards;
}

h1,
h2,
h3 {
  margin: 0;
  font-family: "Playfair Display", Georgia, serif;
}

.app-shell {
  max-width: 1280px;
  margin: 0 auto;
  padding: 14px;
}

[data-tooltip],
[data-tip] {
  position: relative;
}

[data-tooltip]::before,
[data-tip]::before {
  content: "";
  position: absolute;
  left: 50%;
  bottom: calc(100% + 10px);
  transform: translateX(-50%) translateY(4px);
  border-width: 7px 7px 0 7px;
  border-style: solid;
  border-color: rgba(18, 12, 7, 0.95) transparent transparent transparent;
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease, transform 220ms ease;
  z-index: 60;
}

[data-tooltip]::after,
[data-tip]::after {
  content: attr(data-tooltip);
  position: absolute;
  left: 50%;
  bottom: calc(100% + 16px);
  transform: translateX(-50%) translateY(4px);
  width: min(420px, 92vw);
  padding: 11px 13px;
  border-radius: 10px;
  border: 1px solid rgba(232, 213, 163, 0.3);
  background:
    linear-gradient(180deg, rgba(44, 31, 19, 0.98), rgba(20, 14, 9, 0.98));
  color: #f2dfb4;
  font-size: 0.97rem;
  line-height: 1.45;
  text-align: left;
  letter-spacing: 0.01em;
  white-space: normal;
  box-shadow: 0 14px 32px rgba(0, 0, 0, 0.42);
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease, transform 220ms ease;
  z-index: 60;
}

[data-tip]::after {
  content: attr(data-tip);
}

[data-tooltip]:hover::before,
[data-tooltip]:hover::after,
[data-tooltip]:focus-visible::before,
[data-tooltip]:focus-visible::after,
[data-tip]:hover::before,
[data-tip]:hover::after,
[data-tip]:focus-visible::before,
[data-tip]:focus-visible::after {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 12px;
  margin-bottom: 10px;
}

.subtitle {
  margin-top: 4px;
  color: var(--muted);
}

.time-controls {
  display: grid;
  gap: 8px;
  justify-items: end;
}

.audio-row {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.music-status {
  min-height: 20px;
  font-size: 0.8rem;
  color: var(--muted);
  text-align: right;
}

.pending-stack {
  min-height: 28px;
  min-width: 170px;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 6px;
}

.pending-stack-label {
  font-size: 0.78rem;
  color: var(--muted);
}

.pending-stack-items {
  display: inline-flex;
  gap: 3px;
}

.pending-stack-chip {
  width: 15px;
  height: 18px;
  border-radius: 3px;
  border: 1px solid rgba(232, 213, 163, 0.35);
  background: linear-gradient(180deg, rgba(90, 66, 41, 0.85), rgba(39, 27, 16, 0.9));
}

.pending-stack-chip.overload {
  border-color: rgba(207, 95, 73, 0.55);
  background: linear-gradient(180deg, rgba(140, 66, 49, 0.92), rgba(58, 26, 18, 0.95));
}

.pending-stack-count {
  margin-left: 2px;
  font-size: 0.78rem;
  color: #d2b684;
}

.date-label {
  color: var(--muted);
}

.resource-panel {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.resource {
  border: 1px solid var(--panel-border);
  background: rgba(12, 8, 5, 0.6);
  border-radius: 8px;
  padding: 8px 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.resource span {
  color: var(--muted);
  font-size: 0.9rem;
}

.resource strong {
  transition: color 180ms ease;
}

.resource strong.up {
  color: var(--good);
}

.resource strong.down {
  color: var(--bad);
}

.economy-overview {
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  background: rgba(17, 12, 7, 0.7);
  padding: 10px 12px;
  margin-bottom: 12px;
}

.economy-overview h2 {
  font-size: 1rem;
  margin-bottom: 8px;
}

.economy-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.economy-item {
  border: 1px solid rgba(232, 213, 163, 0.16);
  border-radius: 8px;
  padding: 7px 9px;
  background: rgba(0, 0, 0, 0.2);
  display: grid;
  gap: 4px;
}

.economy-item span {
  font-size: 0.78rem;
  color: var(--muted);
}

.economy-item strong {
  font-size: 0.95rem;
}

.economy-item strong.good {
  color: var(--good);
}

.economy-item strong.bad {
  color: var(--bad);
}

.economy-warning {
  margin: 8px 0 0;
  border: 1px solid rgba(211, 123, 97, 0.5);
  border-radius: 6px;
  background: rgba(88, 30, 18, 0.36);
  color: #ffd0c4;
  padding: 6px 8px;
  font-size: 0.85rem;
}

.economy-stamps-wrap {
  margin-top: 10px;
}

.economy-stamps-wrap h3 {
  margin: 0 0 6px;
  font-size: 0.86rem;
  color: var(--muted);
}

.economy-stamps {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.building-stamp {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid rgba(232, 213, 163, 0.2);
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.24);
  padding: 4px 8px;
  color: var(--text);
  font-size: 0.78rem;
}

.building-stamp-code {
  display: inline-flex;
  min-width: 24px;
  justify-content: center;
  border-radius: 999px;
  background: rgba(139, 58, 30, 0.5);
  color: #f3e1b8;
  font-size: 0.72rem;
  padding: 2px 5px;
}

.plot-stamp {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  border-radius: 999px;
  border: 1px solid rgba(232, 213, 163, 0.22);
  background: rgba(139, 58, 30, 0.35);
  color: #f1dbac;
  font-size: 0.72rem;
  padding: 2px 6px;
  margin-bottom: 6px;
}

.economy-breakdown-wrap {
  margin-top: 10px;
}

.economy-breakdown-wrap h3 {
  margin: 0 0 6px;
  font-size: 0.86rem;
  color: var(--muted);
}

.economy-breakdown {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.economy-breakdown li {
  border: 1px solid rgba(232, 213, 163, 0.16);
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 0.8rem;
  color: var(--muted);
  background: rgba(0, 0, 0, 0.24);
}

.economy-breakdown li.good {
  color: #bce0ad;
}

.economy-breakdown li.bad {
  color: #e3ae9f;
}

.economy-forecast-wrap {
  margin-top: 10px;
}

.economy-forecast-wrap h3 {
  margin: 0 0 6px;
  font-size: 0.86rem;
  color: var(--muted);
}

.economy-forecast {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}

.economy-forecast li {
  border: 1px solid rgba(232, 213, 163, 0.16);
  border-radius: 8px;
  padding: 6px 8px;
  background: rgba(0, 0, 0, 0.22);
  display: grid;
  gap: 3px;
}

.economy-forecast .month {
  font-size: 0.74rem;
  color: var(--muted);
}

.economy-forecast .net {
  font-size: 0.85rem;
}

.economy-forecast .net.good {
  color: var(--good);
}

.economy-forecast .net.bad {
  color: var(--bad);
}

.economy-forecast .capital {
  font-size: 0.76rem;
  color: #d6bc8c;
}

.layout {
  display: grid;
  grid-template-columns: 1.1fr 1fr 0.9fr;
  gap: 12px;
}

.panel {
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  background: var(--panel);
  padding: 12px;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.desk-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}

.map-grid {
  margin-top: 12px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.plot {
  min-height: 92px;
  text-align: left;
  border: 1px dashed rgba(232, 213, 163, 0.35);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(28, 20, 12, 0.84), rgba(15, 10, 6, 0.88));
  color: var(--text);
  font-family: Georgia, serif;
  position: relative;
  overflow: hidden;
}

.plot::after {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0.5;
  pointer-events: none;
}

.plot.plot-sentrum {
  background:
    linear-gradient(180deg, rgba(54, 34, 19, 0.88), rgba(22, 14, 8, 0.92));
}

.plot.plot-sentrum::after {
  background:
    radial-gradient(circle at 50% 15%, rgba(226, 195, 140, 0.18), transparent 32%),
    repeating-linear-gradient(90deg, rgba(232, 213, 163, 0.04), rgba(232, 213, 163, 0.04) 9px, transparent 9px, transparent 18px);
}

.plot.plot-nord {
  background:
    linear-gradient(180deg, rgba(42, 52, 27, 0.86), rgba(18, 22, 12, 0.92));
}

.plot.plot-nord::after {
  background:
    linear-gradient(135deg, rgba(170, 150, 92, 0.08), transparent 45%),
    repeating-linear-gradient(45deg, rgba(198, 176, 118, 0.05), rgba(198, 176, 118, 0.05) 7px, transparent 7px, transparent 15px);
}

.plot.plot-aust {
  background:
    linear-gradient(180deg, rgba(24, 42, 33, 0.88), rgba(11, 22, 18, 0.94));
}

.plot.plot-aust::after {
  background:
    radial-gradient(circle at 15% 22%, rgba(182, 215, 189, 0.08), transparent 18%),
    repeating-linear-gradient(90deg, rgba(134, 166, 142, 0.05), rgba(134, 166, 142, 0.05) 4px, transparent 4px, transparent 14px);
}

.plot.plot-sor {
  background:
    linear-gradient(180deg, rgba(25, 40, 54, 0.88), rgba(11, 18, 25, 0.94));
}

.plot.plot-sor::after {
  background:
    linear-gradient(180deg, rgba(145, 188, 220, 0.06), transparent 30%),
    repeating-linear-gradient(0deg, rgba(159, 198, 228, 0.05), rgba(159, 198, 228, 0.05) 6px, transparent 6px, transparent 14px);
}

.plot.selected {
  border-color: var(--accent-soft);
}

.plot small {
  display: block;
  margin-top: 6px;
  color: var(--muted);
}

.build-controls {
  margin-top: 12px;
}

.build-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.btn {
  border: 1px solid #9f6f47;
  background: #4f2d1a;
  color: var(--text);
  border-radius: 7px;
  padding: 6px 10px;
  cursor: pointer;
  font-family: inherit;
}

.btn:hover:not(:disabled) {
  background: #6a3b22;
}

.btn-primary {
  background: var(--accent);
}

.btn-ghost {
  background: rgba(46, 31, 19, 0.55);
  border-color: rgba(232, 213, 163, 0.35);
  color: var(--muted);
  font-size: 0.82rem;
  padding: 4px 8px;
}

.btn-ghost[aria-pressed="false"] {
  color: #a48b62;
  border-color: rgba(164, 139, 98, 0.45);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.crisis {
  margin-top: 10px;
  border: 1px solid rgba(211, 123, 97, 0.5);
  background: rgba(88, 30, 18, 0.45);
  border-radius: 6px;
  padding: 8px;
  color: #ffd0c4;
}

.event-card {
  margin-top: 10px;
  border: 1px solid rgba(232, 213, 163, 0.2);
  border-radius: 8px;
  background: rgba(15, 10, 6, 0.72);
  padding: 10px;
}

.event-card.type-brev {
  border-color: rgba(141, 113, 70, 0.55);
}

.event-card.type-person {
  border-color: rgba(129, 79, 49, 0.6);
}

.event-card.type-krise {
  border-color: rgba(178, 84, 64, 0.68);
  box-shadow: inset 0 0 0 1px rgba(178, 84, 64, 0.22);
}

.event-card.type-rapport {
  border-color: rgba(104, 128, 94, 0.6);
}

.event-card.event-enter {
  animation: eventCardReveal 360ms ease-out;
}

.event-card.event-enter-brev {
  box-shadow: 0 0 0 1px rgba(169, 129, 79, 0.2), 0 10px 20px rgba(79, 51, 23, 0.25);
}

.event-card.event-enter-person {
  box-shadow: 0 0 0 1px rgba(163, 94, 58, 0.24), 0 10px 20px rgba(95, 46, 26, 0.28);
}

.event-card.event-enter-krise {
  box-shadow: 0 0 0 1px rgba(199, 90, 67, 0.28), 0 10px 24px rgba(99, 34, 23, 0.35);
}

.event-card.event-enter-rapport {
  box-shadow: 0 0 0 1px rgba(111, 146, 101, 0.22), 0 10px 18px rgba(38, 54, 31, 0.25);
}

.event-meta {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}

.event-badge {
  display: inline-flex;
  align-items: center;
  border: 1px solid rgba(232, 213, 163, 0.25);
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 0.78rem;
  color: var(--muted);
  background: rgba(0, 0, 0, 0.22);
}

.event-badge-muted {
  border-color: rgba(232, 213, 163, 0.18);
  color: #bda274;
}

.event-badge.kind-brev {
  border-color: rgba(169, 129, 79, 0.4);
  color: #d3b683;
}

.event-badge.kind-person {
  border-color: rgba(163, 94, 58, 0.42);
  color: #d6aa86;
}

.event-badge.kind-krise {
  border-color: rgba(199, 90, 67, 0.5);
  color: #efb5a7;
}

.event-badge.kind-rapport {
  border-color: rgba(111, 146, 101, 0.42);
  color: #b7d4a8;
}

.event-media-wrap {
  margin-bottom: 12px;
}

.event-image {
  width: 100%;
  max-height: 280px;
  object-fit: cover;
  object-position: center 18%;
  display: block;
  border-radius: 6px;
  border: 1px solid rgba(232, 213, 163, 0.25);
  filter: sepia(0.68) contrast(1.02) saturate(0.85);
}

.event-caption {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.88rem;
  font-style: italic;
}

.event-choices {
  display: grid;
  gap: 6px;
  margin-top: 10px;
}

.log-wrap {
  margin-top: 12px;
}

.log-list {
  margin: 10px 0 0;
  padding: 0;
  list-style: none;
  max-height: 290px;
  overflow: auto;
  display: grid;
  gap: 5px;
}

.log-list li {
  border-left: 2px solid rgba(232, 213, 163, 0.2);
  padding-left: 8px;
  color: #dec693;
}

.bars {
  margin-top: 10px;
  display: grid;
  gap: 8px;
}

.bar-row .meta {
  display: flex;
  justify-content: space-between;
  font-size: 0.9rem;
  color: var(--muted);
}

.bar-track {
  margin-top: 4px;
  height: 10px;
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid rgba(232, 213, 163, 0.2);
  background: rgba(0, 0, 0, 0.35);
}

.bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #9d4f2a, #d4a46d);
}

.character-section {
  margin-top: 14px;
}

.character-list {
  margin-top: 10px;
  display: grid;
  gap: 8px;
}

.character-card {
  border: 1px solid rgba(232, 213, 163, 0.2);
  border-radius: 8px;
  padding: 10px;
  background: rgba(0, 0, 0, 0.2);
}

.character-head {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
}

.portrait {
  width: 42px;
  height: 42px;
  border-radius: 999px;
  border: 1px solid rgba(232, 213, 163, 0.35);
  object-fit: cover;
  display: block;
  filter: sepia(0.65);
  background: linear-gradient(145deg, #6f5038, #2e2117);
}

.status {
  font-size: 0.78rem;
  color: var(--muted);
}

.status.active {
  color: #90d88b;
}

.character-card.active {
  animation: pulse 2s ease-in-out infinite;
}

.stats {
  margin: 8px 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.hidden {
  display: none;
}

@keyframes pulse {
  0% {
    box-shadow: 0 0 0 rgba(144, 216, 139, 0);
  }
  50% {
    box-shadow: 0 0 10px rgba(144, 216, 139, 0.2);
  }
  100% {
    box-shadow: 0 0 0 rgba(144, 216, 139, 0);
  }
}

@keyframes eventCardReveal {
  0% {
    opacity: 0;
    transform: translateY(6px) scale(0.995);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes sideFadeInLeft {
  from {
    opacity: 0;
    transform: translateX(-24px);
  }
  to {
    opacity: 0.82;
    transform: translateX(0);
  }
}

@keyframes sideFadeInRight {
  from {
    opacity: 0;
    transform: translateX(24px);
  }
  to {
    opacity: 0.82;
    transform: translateX(0);
  }
}

@media (max-width: 1100px) {
  .resource-panel {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .economy-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .economy-forecast {
    grid-template-columns: 1fr;
  }

  .layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 680px) {
  .resource-panel {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

  .time-controls {
    justify-items: start;
  }

  .page-bg::before,
  .page-bg::after {
    width: 18vw;
    opacity: 0.55;
  }

  [data-tooltip]::after,
  [data-tip]::after {
    font-size: 0.93rem;
    width: min(360px, 90vw);
  }
}
