:root {
  --bg: #eef1f6;
  --bg-2: #e6eaf2;
  --surface: rgba(255, 255, 255, 0.72);
  --surface-strong: rgba(255, 255, 255, 0.88);
  --surface-solid: #ffffff;
  --surface-muted: #f6f8fb;
  --text: #14161c;
  --text-soft: #3c4250;
  --muted: #697188;
  --line: rgba(17, 24, 39, 0.08);
  --line-strong: rgba(17, 24, 39, 0.14);
  --hairline: rgba(255, 255, 255, 0.6);

  --blue: #0a6cf1;
  --blue-dark: #064fbd;
  --blue-soft: rgba(10, 108, 241, 0.1);
  --violet: #6d5cf0;
  --red: #e5484d;
  --green: #16a34a;
  --amber: #d9870a;

  --accent-grad: linear-gradient(135deg, #0a6cf1 0%, #4f7bf5 50%, #6d5cf0 100%);
  --accent-grad-soft: linear-gradient(135deg, rgba(10,108,241,0.12), rgba(109,92,240,0.12));

  /* Sistema di elevazione a piu livelli per profondita enterprise */
  --shadow-xs: 0 1px 2px rgba(17, 24, 39, 0.06), 0 1px 1px rgba(17, 24, 39, 0.04);
  --shadow-sm: 0 2px 8px rgba(17, 24, 39, 0.06), 0 1px 2px rgba(17, 24, 39, 0.05);
  --shadow-md: 0 10px 30px rgba(17, 24, 39, 0.08), 0 2px 8px rgba(17, 24, 39, 0.05);
  --shadow-lg: 0 24px 60px rgba(17, 24, 39, 0.12), 0 8px 20px rgba(17, 24, 39, 0.06);
  --shadow-xl: 0 40px 90px rgba(17, 24, 39, 0.18), 0 12px 28px rgba(17, 24, 39, 0.08);
  --shadow: var(--shadow-md);
  --ring: 0 0 0 3px rgba(10, 108, 241, 0.28);

  --radius-xs: 10px;
  --radius-sm: 14px;
  --radius: 20px;
  --radius-lg: 26px;
  --radius-pill: 999px;

  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --t-fast: 0.16s var(--ease);
  --t-med: 0.28s var(--ease);
}

* {
  box-sizing: border-box;
}

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

body {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", sans-serif;
  background:
    radial-gradient(900px 600px at 8% -5%, rgba(10, 108, 241, 0.10), transparent 55%),
    radial-gradient(900px 600px at 100% 0%, rgba(109, 92, 240, 0.10), transparent 55%),
    radial-gradient(700px 500px at 50% 110%, rgba(10, 108, 241, 0.06), transparent 60%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg-2) 100%);
  background-attachment: fixed;
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  letter-spacing: -0.01em;
}

a {
  color: inherit;
}

button,
textarea,
input,
select {
  font: inherit;
}

::selection {
  background: rgba(10, 108, 241, 0.22);
  color: var(--text);
}

:focus-visible {
  outline: none;
  box-shadow: var(--ring);
  border-radius: var(--radius-xs);
}

* {
  scrollbar-width: thin;
  scrollbar-color: rgba(17, 24, 39, 0.22) transparent;
}

*::-webkit-scrollbar {
  width: 11px;
  height: 11px;
}

*::-webkit-scrollbar-thumb {
  background: rgba(17, 24, 39, 0.18);
  border: 3px solid transparent;
  border-radius: 999px;
  background-clip: padding-box;
}

*::-webkit-scrollbar-thumb:hover {
  background: rgba(17, 24, 39, 0.32);
  background-clip: padding-box;
}

.surface {
  position: relative;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.55), rgba(255, 255, 255, 0.18)),
    var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  backdrop-filter: blur(28px) saturate(160%);
  -webkit-backdrop-filter: blur(28px) saturate(160%);
}

.surface::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  border-top: 1px solid var(--hairline);
  pointer-events: none;
  mask: linear-gradient(180deg, #000, transparent 40%);
}

.hidden {
  display: none !important;
}

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

.button-link {
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.app-shell {
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr);
  min-height: 100vh;
  gap: 18px;
  padding: 18px;
}

.sidebar {
  position: sticky;
  top: 18px;
  height: calc(100vh - 36px);
  overflow: auto;
  padding: 18px;
}

.main-content {
  min-width: 0;
  display: grid;
  gap: 18px;
}

.brand-block {
  display: grid;
  gap: 18px;
  margin-bottom: 18px;
}

.brand-link {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
}

.brand-logo {
  display: block;
  height: 36px;
  width: auto;
  max-width: 100%;
}

.brand-link span {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: var(--accent-grad);
  color: white;
  box-shadow: 0 8px 20px rgba(10, 108, 241, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.4);
  font-weight: 800;
}

.user-pill {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  border-radius: 18px;
  background: rgba(255,255,255,0.58);
  border: 1px solid var(--line);
}

.avatar,
.avatar-big {
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #111;
  color: white;
  font-weight: 800;
}

.avatar {
  width: 42px;
  height: 42px;
}

.avatar-big {
  width: 94px;
  height: 94px;
  font-size: 2.2rem;
}

.user-pill strong,
.user-pill small {
  display: block;
}

.user-pill small {
  color: var(--muted);
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.panel {
  padding: 16px 0;
  border-top: 1px solid var(--line);
}

.panel h2,
.info-card h2,
.story-section h2,
.card-header h2 {
  margin: 0 0 12px;
  font-size: 1rem;
  letter-spacing: -0.02em;
}

.panel-head-inline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.panel-head-inline h2 {
  margin: 0;
}

textarea {
  width: 100%;
  min-height: 128px;
  resize: vertical;
  padding: 14px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.82);
  color: var(--text);
}

textarea:focus,
input:focus {
  outline: 3px solid rgba(0,113,227,0.14);
  border-color: rgba(0,113,227,0.42);
}

.primary-btn,
.soft-btn,
.danger-btn,
.mini-btn {
  border: 0;
  border-radius: 999px;
  font-weight: 750;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 8px;
}

.primary-btn,
.soft-btn,
.danger-btn {
  width: 100%;
  min-height: 44px;
  margin-top: 10px;
}

.primary-btn {
  background: var(--blue);
  color: white;
}

.primary-btn:hover {
  background: var(--blue-dark);
}

.soft-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  text-decoration: none;
  background: rgba(255,255,255,0.7);
  border: 1px solid var(--line);
  color: var(--text);
}

.danger-btn {
  background: rgba(229,72,77,0.10);
  color: var(--red);
}

.mini-btn {
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.72);
  color: var(--text);
}

.button-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.meta-list {
  display: grid;
  gap: 10px;
}

.meta-list div {
  display: grid;
  gap: 3px;
}

.meta-list span {
  color: var(--muted);
  font-size: 0.82rem;
}

.meta-list strong {
  font-size: 0.92rem;
  overflow-wrap: anywhere;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.72);
  border-radius: 999px;
  padding: 8px 11px;
  cursor: pointer;
  color: var(--text);
}

.nav-panel {
  display: flex;
  gap: 12px;
}

.nav-panel a {
  color: var(--muted);
  font-weight: 700;
  text-decoration: none;
}

.topbar {
  padding: 22px;
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--blue);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 0.76rem;
}

.topbar h1 {
  margin: 0;
  font-size: clamp(1.8rem, 4vw, 3.8rem);
  letter-spacing: -0.06em;
}

.topbar p {
  margin: 8px 0 0;
  color: var(--muted);
}

.topbar-stats {
  display: flex;
  gap: 10px;
}

.topbar-stats div {
  min-width: 100px;
  padding: 13px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.62);
}

.topbar-stats span,
.topbar-stats strong {
  display: block;
}

.topbar-stats span {
  color: var(--muted);
  font-size: 0.82rem;
}

.topbar-stats strong {
  font-size: 1.5rem;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(320px, 0.65fr);
  gap: 18px;
}

.map-card,
.info-card,
.story-section {
  padding: 18px;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

#mapCanvasWrap {
  position: relative;
  width: 100%;
  min-height: 520px;
  height: 520px;
  border-radius: 20px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: #dfe7db;
}

.map-hover-card {
  position: absolute;
  z-index: 12;
  width: min(320px, 78%);
  padding: 14px 16px 13px;
  border-radius: 16px;
  background: linear-gradient(155deg, rgba(255, 255, 255, 0.96), rgba(247, 250, 255, 0.92));
  border: 1px solid rgba(255, 255, 255, 0.7);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.9) inset,
    0 18px 46px -18px rgba(15, 30, 60, 0.5),
    0 4px 14px -6px rgba(15, 30, 60, 0.28);
  -webkit-backdrop-filter: blur(14px) saturate(135%);
  backdrop-filter: blur(14px) saturate(135%);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.16s var(--ease, ease), transform 0.18s var(--ease, ease);
  will-change: transform, opacity;
}

.map-hover-card[data-place="above"] {
  transform: translate(-50%, calc(-100% - 16px)) scale(0.96);
  transform-origin: center bottom;
}

.map-hover-card[data-place="below"] {
  transform: translate(-50%, 16px) scale(0.96);
  transform-origin: center top;
}

.map-hover-card.is-visible {
  opacity: 1;
}

.map-hover-card.is-visible[data-place="above"] {
  transform: translate(-50%, calc(-100% - 16px)) scale(1);
}

.map-hover-card.is-visible[data-place="below"] {
  transform: translate(-50%, 16px) scale(1);
}

.map-hover-card::after {
  content: "";
  position: absolute;
  left: 50%;
  width: 14px;
  height: 14px;
  background: inherit;
  border: 1px solid rgba(255, 255, 255, 0.7);
  transform: translateX(-50%) rotate(45deg);
}

.map-hover-card[data-place="above"]::after {
  bottom: -7px;
  border-top: none;
  border-left: none;
}

.map-hover-card[data-place="below"]::after {
  top: -7px;
  border-bottom: none;
  border-right: none;
}

.map-hover-eyebrow {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent, #0a6cf1);
  margin-bottom: 3px;
}

.map-hover-head h4 {
  margin: 0 0 8px;
  font-size: 16px;
  font-weight: 700;
  line-height: 1.25;
  color: #15233d;
  letter-spacing: -0.01em;
}

.map-hover-desc {
  margin: 0 0 11px;
  font-size: 12.5px;
  line-height: 1.5;
  color: rgba(34, 48, 70, 0.82);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.map-hover-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}

.map-hover-pills span {
  display: inline-flex;
  flex-direction: column;
  gap: 1px;
  padding: 5px 9px;
  border-radius: 10px;
  background: rgba(10, 108, 241, 0.07);
  border: 1px solid rgba(10, 108, 241, 0.12);
  font-size: 11.5px;
  font-weight: 600;
  color: #1c2c47;
}

.map-hover-pills span em,
.map-hover-event em {
  font-style: normal;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(34, 48, 70, 0.5);
}

.map-hover-event {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding-top: 9px;
  border-top: 1px solid rgba(15, 30, 60, 0.08);
  font-size: 11.5px;
  line-height: 1.45;
  color: rgba(34, 48, 70, 0.82);
}

.map-label-layer {
  position: absolute;
  inset: 0;
  z-index: 8;
  pointer-events: none;
}

.map-region-label {
  position: absolute;
  transform: translate(-50%, 0) scale(0.94);
  transform-origin: top center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  max-width: min(200px, 42vw);
  padding: 6px 12px 7px;
  border-radius: 12px;
  background: linear-gradient(165deg, rgba(255, 255, 255, 0.94), rgba(248, 244, 232, 0.88));
  border: 1px solid rgba(255, 255, 255, 0.65);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.85) inset,
    0 8px 22px -10px rgba(15, 30, 60, 0.38),
    0 2px 6px -2px rgba(15, 30, 60, 0.18);
  -webkit-backdrop-filter: blur(10px) saturate(130%);
  backdrop-filter: blur(10px) saturate(130%);
  text-align: center;
  transition: transform 0.18s var(--ease, ease), box-shadow 0.18s var(--ease, ease), border-color 0.18s var(--ease, ease);
}

.map-region-label.is-hovered {
  transform: translate(-50%, -2px) scale(1.02);
  border-color: rgba(10, 108, 241, 0.42);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.9) inset,
    0 14px 32px -12px rgba(10, 108, 241, 0.32),
    0 4px 10px -4px rgba(15, 30, 60, 0.22);
}

.map-region-label-type {
  display: block;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(10, 108, 241, 0.78);
  line-height: 1.2;
}

.map-region-label-name {
  display: block;
  font-size: 12.5px;
  font-weight: 750;
  letter-spacing: -0.01em;
  line-height: 1.25;
  color: #1a2438;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.map-stage {
  position: relative;
  min-height: inherit;
}

.map-stage > #worldMap,
.map-stage > .world-map-image,
.map-stage > .world-map-overlay,
.map-stage > .world-map-vignette {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

#worldMap {
  z-index: 3;
}

.world-map-image {
  z-index: 1;
  object-fit: cover;
  opacity: 0;
  transform: scale(1.04);
  transition: opacity 1.1s ease, transform 6s ease;
  filter: saturate(1.02);
}

.world-map-image.is-visible {
  opacity: 1;
  transform: scale(1);
}

.world-map-vignette {
  z-index: 2;
  pointer-events: none;
  background:
    radial-gradient(circle at 50% 42%, transparent 52%, rgba(28, 20, 8, 0.20) 100%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.05), rgba(28, 20, 8, 0.14));
}

.world-map-overlay {
  z-index: 4;
  pointer-events: none;
}

.world-map-status {
  position: absolute;
  z-index: 5;
  left: 16px;
  top: 16px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.86);
  border: 1px solid var(--line);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.12);
  backdrop-filter: blur(14px);
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text);
  animation: ws-fade-in 0.4s ease both;
}

.world-map-status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--blue);
  box-shadow: 0 0 0 0 rgba(0, 113, 227, 0.45);
  animation: ws-pulse-dot 1.4s ease-out infinite;
}

.info-column {
  display: grid;
  gap: 18px;
}

.list-block {
  display: grid;
  gap: 10px;
  max-height: 250px;
  overflow: auto;
  padding-right: 4px;
}

.item-card {
  padding: 12px;
  border-radius: 16px;
  background: rgba(255,255,255,0.64);
  border: 1px solid var(--line);
}

.item-card h4 {
  margin: 0;
}

.item-card p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.45;
}

.item-link-card {
  text-decoration: none;
  color: inherit;
  display: block;
}

button.item-link-card,
button.character-open-btn {
  width: 100%;
  text-align: left;
  cursor: pointer;
  font: inherit;
  appearance: none;
  -webkit-appearance: none;
}

button.item-link-card:focus-visible,
button.character-open-btn:focus-visible {
  outline: 2px solid var(--ring, rgba(10, 108, 241, 0.45));
  outline-offset: 2px;
}

.item-card-locked {
  opacity: 0.88;
  background: rgba(255,255,255,0.5);
}

.item-card-lock-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.badge-pro {
  background: rgba(109, 92, 240, 0.12);
  color: #5b4ae8;
  border: 1px solid rgba(109, 92, 240, 0.22);
}

.muted-badge {
  color: var(--muted);
  background: rgba(148, 163, 184, 0.12);
}

.item-link-card:hover {
  border-color: rgba(0,113,227,0.28);
  background: rgba(0,113,227,0.05);
}

.row {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 8px;
}

.badge {
  padding: 5px 8px;
  border-radius: 999px;
  background: rgba(0,0,0,0.05);
  color: var(--muted);
  font-size: 0.78rem;
}

.story-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(280px, 0.65fr);
  gap: 18px;
}

.feed {
  max-height: 440px;
  overflow: auto;
  display: grid;
  gap: 12px;
}

.feed-item {
  padding: 14px;
  border-radius: 18px;
  background: rgba(255,255,255,0.68);
  border: 1px solid var(--line);
  line-height: 1.55;
}

.feed-item.system {
  border-left: 4px solid var(--blue);
}

.feed-item.user {
  border-left: 4px solid #7c3aed;
}

.feed-role {
  margin-bottom: 7px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 0.74rem;
  font-weight: 800;
}

.action-panel textarea {
  min-height: 160px;
}

.mini-panel {
  margin-top: 18px;
}

.compact {
  max-height: 190px;
}

.loading-overlay {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(245,245,247,0.72);
  z-index: 99;
}

.loader-card {
  padding: 28px;
  width: 280px;
  text-align: center;
}

.loader-ring {
  width: 48px;
  height: 48px;
  margin: 0 auto 14px;
  border-radius: 50%;
  border: 4px solid rgba(0,0,0,0.08);
  border-top-color: var(--blue);
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.profile-page {
  max-width: 1080px;
  margin: 0 auto;
  padding: 22px;
  display: grid;
  gap: 18px;
}

.app-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.nav-actions {
  display: flex;
  gap: 12px;
  align-items: center;
}

.nav-actions a {
  text-decoration: none;
  font-weight: 700;
  color: var(--muted);
}

.profile-hero {
  padding: 28px;
  display: flex;
  align-items: center;
  gap: 22px;
}

.profile-hero h1 {
  margin: 0;
  font-size: clamp(2rem, 5vw, 4rem);
  letter-spacing: -0.06em;
}

.profile-hero p {
  margin: 8px 0 0;
  color: var(--muted);
}

.profile-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.profile-badges span {
  padding: 7px 10px;
  border-radius: 999px;
  background: rgba(0,0,0,0.05);
  color: var(--muted);
}

.profile-section {
  padding: 24px;
}

.world-list {
  display: grid;
  gap: 12px;
}

.world-row {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  padding: 16px;
  border-radius: 18px;
  background: rgba(255,255,255,0.65);
  border: 1px solid var(--line);
}

.world-row h3 {
  margin: 0;
}

.world-row p {
  margin: 6px 0 0;
  color: var(--muted);
}

.world-row span {
  color: var(--muted);
  font-size: 0.86rem;
  white-space: nowrap;
}

.detail-page {
  max-width: 1280px;
  margin: 0 auto;
  padding: clamp(16px, 3vw, 28px);
  display: grid;
  gap: 16px;
}

.detail-hero {
  padding: clamp(22px, 4vw, 36px);
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.94), rgba(246, 249, 255, 0.88));
  border: 1px solid rgba(255, 255, 255, 0.7);
  position: relative;
  overflow: hidden;
}

.detail-hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(600px 200px at 0% 0%, rgba(10, 108, 241, 0.08), transparent 60%);
  pointer-events: none;
}

.detail-hero-copy {
  position: relative;
}

.detail-hero-copy h1 {
  margin: 0;
  font-size: clamp(2rem, 5vw, 3.6rem);
  letter-spacing: -0.05em;
}

.detail-hero-badge {
  display: inline-flex;
  margin-top: 10px;
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #1a4a8a;
  background: rgba(10, 108, 241, 0.1);
  border: 1px solid rgba(10, 108, 241, 0.16);
}

.detail-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr);
  gap: 16px;
}

.detail-image-panel,
.detail-text-panel,
.detail-list-panel {
  padding: clamp(18px, 3vw, 26px);
}

.detail-text-panel h2,
.detail-list-panel h2 {
  margin: 0 0 12px;
  font-size: 1rem;
  font-weight: 750;
  display: flex;
  align-items: center;
  gap: 8px;
}

.detail-text-panel h2::before,
.detail-list-panel h2::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-grad, linear-gradient(135deg, #0a6cf1, #2f9bff));
  flex-shrink: 0;
}

.detail-city-image {
  width: 100%;
  min-height: 320px;
  display: block;
  border-radius: 18px;
  background: linear-gradient(135deg, #f4ead2, #ccb98e);
  object-fit: cover;
  box-shadow: inset 0 0 0 1px var(--line), var(--shadow-md);
}

.detail-text-panel p,
.detail-list-panel li {
  color: rgba(34, 48, 70, 0.82);
  line-height: 1.75;
  font-size: 0.94rem;
}

.detail-list-panel ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.detail-list-panel li {
  display: inline-flex;
  padding: 7px 12px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 600;
  background: rgba(10, 108, 241, 0.07);
  border: 1px solid rgba(10, 108, 241, 0.12);
}

.detail-text-panel > h2:not(:first-child) {
  margin-top: 22px;
}

.detail-text-panel .legal-bullet-list {
  margin: 0 0 18px;
  padding-left: 22px;
  list-style: disc;
}

.detail-text-panel .legal-bullet-list li {
  display: list-item;
  margin-bottom: 8px;
  padding: 0;
  background: none;
  border: none;
  border-radius: 0;
  font-size: 0.94rem;
  font-weight: 400;
  color: rgba(34, 48, 70, 0.82);
}

.legal-detail-aside {
  align-self: start;
}

.legal-link-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.legal-link-list a,
.legal-link-current {
  display: inline-flex;
  align-items: center;
  padding: 7px 12px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 600;
  text-decoration: none;
  color: rgba(34, 48, 70, 0.86);
  background: rgba(10, 108, 241, 0.07);
  border: 1px solid rgba(10, 108, 241, 0.12);
  transition: background var(--t-fast), border-color var(--t-fast), transform var(--t-fast);
}

.legal-link-list a:hover {
  background: rgba(10, 108, 241, 0.12);
  border-color: rgba(10, 108, 241, 0.22);
  transform: translateY(-1px);
}

.legal-link-current {
  color: #0a4a9a;
  background: rgba(10, 108, 241, 0.14);
  border-color: rgba(10, 108, 241, 0.28);
}

.legal-link-btn {
  display: inline-flex;
  align-items: center;
  padding: 7px 12px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 600;
  text-decoration: none;
  color: rgba(34, 48, 70, 0.86);
  background: rgba(10, 108, 241, 0.07);
  border: 1px solid rgba(10, 108, 241, 0.12);
  cursor: pointer;
  transition: background var(--t-fast), border-color var(--t-fast), transform var(--t-fast);
}

.legal-link-btn:hover {
  background: rgba(10, 108, 241, 0.12);
  border-color: rgba(10, 108, 241, 0.22);
  transform: translateY(-1px);
}

.legal-link-btn.is-active {
  color: #0a4a9a;
  background: rgba(10, 108, 241, 0.14);
  border-color: rgba(10, 108, 241, 0.28);
}

.inline-loader-wrap {
  display: grid;
  place-items: center;
  min-height: 240px;
}

.inline-loader-card {
  width: min(360px, 100%);
  padding: 24px;
  border-radius: 24px;
  background: rgba(255,255,255,0.86);
  border: 1px solid rgba(0,0,0,0.08);
  box-shadow: 0 18px 60px rgba(0,0,0,0.08);
  text-align: center;
}

.inline-loader-ring {
  width: 46px;
  height: 46px;
  margin: 0 auto 14px;
  border-radius: 50%;
  border: 4px solid rgba(0,0,0,0.08);
  border-top-color: var(--blue);
  animation: spin 0.8s linear infinite;
}

.inline-loader-card p {
  margin: 0;
  color: var(--muted);
}

.session-sidebar-list {
  display: grid;
  gap: 8px;
  max-height: 280px;
  overflow: auto;
}

.session-item {
  width: 100%;
  text-align: left;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.66);
  border-radius: 16px;
  padding: 12px;
  cursor: pointer;
  color: inherit;
}

.session-item strong,
.session-item span,
.session-item small {
  display: block;
}

.session-item strong {
  color: var(--text);
  margin-bottom: 4px;
}

.session-item span {
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.4;
}

.session-item small {
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.76rem;
}

.session-item.active {
  border-color: rgba(0,113,227,0.32);
  background: rgba(0,113,227,0.08);
}

.session-item:hover {
  background: rgba(255,255,255,0.9);
}

.profile-main-info {
  min-width: 0;
}

.profile-email-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.profile-email-row p {
  margin: 8px 0 0;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.profile-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.profile-section-head h2,
.profile-section-head p {
  margin: 0;
}

.profile-section-head p {
  margin-top: 6px;
}

.profile-search-wrap {
  min-width: 260px;
}

.profile-search {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 16px;
  background: rgba(255,255,255,0.8);
  color: var(--text);
}

.share-inline-box {
  margin-top: 12px;
  padding: 14px;
  border-radius: 18px;
  background: rgba(255,255,255,0.72);
  border: 1px solid var(--line);
}

.share-inline-box label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 750;
}

.share-inline-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

.share-inline-row input {
  min-width: 0;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0 10px;
  background: rgba(255,255,255,0.95);
  color: var(--text);
  font-size: 0.86rem;
}

.share-inline-status {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.4;
}

.cookie-panel {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: 16px;
  z-index: 999;
  opacity: 0;
  transform: translateY(18px);
  transition: opacity .2s ease, transform .2s ease;
}

.cookie-panel.cookie-visible {
  opacity: 1;
  transform: translateY(0);
}

.cookie-card {
  max-width: 980px;
  margin: 0 auto;
  position: relative;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 16px;
  align-items: center;
  padding: 20px 22px;
  border-radius: 26px;
  background: rgba(255,255,255,0.96);
  border: 1px solid rgba(0,0,0,0.08);
  box-shadow: 0 24px 80px rgba(0,0,0,0.14);
  backdrop-filter: blur(20px);
}

.cookie-icon {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  background: #111;
  color: #fff;
  font-weight: 800;
}

.cookie-content strong {
  display: block;
  margin-bottom: 6px;
  color: var(--text);
}

.cookie-content p {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.cookie-buttons {
  display: flex;
  gap: 10px;
  align-items: center;
}

.cookie-secondary,
.cookie-primary {
  min-height: 42px;
  border-radius: 999px;
  padding: 0 16px;
  border: 0;
  font-weight: 750;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.cookie-secondary {
  background: rgba(0,0,0,0.06);
  color: var(--text);
}

.cookie-primary {
  background: var(--blue);
  color: white;
}

.cookie-close {
  position: absolute;
  top: 10px;
  right: 12px;
  border: 0;
  background: transparent;
  font-size: 22px;
  cursor: pointer;
  color: var(--muted);
}

.cookie-floating {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 998;
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid rgba(0,0,0,0.08);
  border-radius: 999px;
  background: rgba(255,255,255,0.96);
  color: var(--text);
  box-shadow: 0 14px 40px rgba(0,0,0,0.12);
  cursor: pointer;
}

@media (max-width: 1180px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: relative;
    top: auto;
    height: auto;
  }

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

  .info-column {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 1024px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: relative;
    top: auto;
    height: auto;
    order: 2;
  }

  .main-content {
    order: 1;
  }

  .workspace,
  .story-layout,
  .detail-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 860px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar-stats {
    width: 100%;
  }

  .topbar-stats div {
    flex: 1;
    min-width: 0;
  }

  .info-column {
    grid-template-columns: 1fr;
  }

  #mapCanvasWrap {
    min-height: 420px;
  }

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

  .world-row {
    flex-direction: column;
  }
}

@media (max-width: 760px) {
  .app-shell,
  .profile-page,
  .detail-page {
    padding: 10px;
    gap: 12px;
  }

  .surface {
    border-radius: 18px;
  }

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

  .topbar-stats {
    width: 100%;
    flex-direction: column;
  }

  .topbar-stats div {
    width: 100%;
  }

  .panel-head-inline {
    flex-direction: column;
    align-items: stretch;
  }

  .nav-panel {
    flex-direction: column;
  }

  .brand-block {
    gap: 12px;
  }

  .user-pill {
    align-items: flex-start;
  }

  #mapCanvasWrap {
    min-height: 320px;
  }

  .detail-city-image {
    min-height: 220px;
  }

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

  .cookie-card {
    grid-template-columns: 1fr;
    padding: 18px;
  }

  .cookie-buttons {
    flex-direction: column;
    align-items: stretch;
  }

  .cookie-buttons button {
    width: 100%;
  }

  .cookie-floating {
    right: 12px;
    bottom: 12px;
  }

  .share-inline-row {
    grid-template-columns: 1fr;
  }

  .profile-section-head {
    align-items: stretch;
    flex-direction: column;
  }

  .profile-search-wrap {
    min-width: 0;
  }
}

.legal-page {
  max-width: 1120px;
  margin: 0 auto;
  padding: 24px;
  display: grid;
  gap: 18px;
}

.legal-hero {
  padding: 28px;
}

.legal-hero h1 {
  margin: 0;
  font-size: clamp(2.2rem, 5vw, 4.4rem);
  letter-spacing: -0.06em;
}

.legal-section {
  padding: 24px;
}

.legal-section h2 {
  margin-top: 0;
  font-size: 1.2rem;
  letter-spacing: -0.02em;
}

.legal-section p,
.legal-section li {
  color: var(--muted);
  line-height: 1.75;
}

.legal-section ul {
  margin: 0;
  padding-left: 22px;
}

.legal-page {
  max-width: 1120px;
  margin: 0 auto;
  padding: 24px;
  display: grid;
  gap: 18px;
}

.legal-hero {
  padding: 28px;
}

.legal-hero h1 {
  margin: 0;
  font-size: clamp(2.2rem, 5vw, 4.4rem);
  letter-spacing: -0.06em;
}

.legal-section {
  padding: 24px;
}

.legal-section h2 {
  margin-top: 0;
  font-size: 1.2rem;
  letter-spacing: -0.02em;
}

.legal-section p,
.legal-section li {
  color: var(--muted);
  line-height: 1.75;
}

.legal-section ul {
  margin: 0;
  padding-left: 22px;
}

.city-experience {
  position: fixed;
  inset: 0;
  z-index: 1600;
  display: grid;
  place-items: center;
  padding: clamp(10px, 2vw, 22px);
}

.city-experience.hidden {
  display: none;
}

.city-experience-backdrop {
  position: absolute;
  inset: 0;
}

.city-experience-shell {
  position: relative;
  z-index: 1;
  width: min(1480px, 100%);
  height: min(90vh, 980px);
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 12px;
  min-height: 0;
}

.city-experience-topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 22px;
  border-radius: 22px;
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.94), rgba(246, 249, 255, 0.88));
  border: 1px solid rgba(255, 255, 255, 0.75);
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
}

.city-topbar-main {
  min-width: 0;
}

.city-topbar-title-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
}

.city-experience-topbar h2 {
  margin: 0;
  font-size: clamp(1.5rem, 2.8vw, 2.4rem);
  letter-spacing: -0.04em;
  line-height: 1.1;
}

.city-topbar-sub {
  margin: 8px 0 0;
  max-width: 56ch;
}

.city-type-badge {
  display: inline-flex;
  align-items: center;
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #1a4a8a;
  background: rgba(10, 108, 241, 0.1);
  border: 1px solid rgba(10, 108, 241, 0.18);
}

.city-close-btn {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.city-experience-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(300px, 0.72fr);
  gap: 12px;
  min-height: 0;
}

.city-scene-panel,
.city-side-panel {
  min-height: 0;
  border-radius: var(--radius-lg);
}

.city-scene-panel {
  padding: 12px;
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 10px;
  overflow: hidden;
}

.city-scene-panel-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 6px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.02em;
}

.city-scene-live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.5);
  animation: ws-live-pulse 2s ease-out infinite;
}

@keyframes ws-live-pulse {
  0% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.45); }
  70% { box-shadow: 0 0 0 8px rgba(34, 197, 94, 0); }
  100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0); }
}

.city-scene-canvas-wrap {
  width: 100%;
  height: 100%;
  min-height: 480px;
  border-radius: 18px;
  overflow: hidden;
  background: linear-gradient(180deg, #e9dcc1, #ccb98e);
}

.city-scene-fallback {
  position: relative;
  width: 100%;
  height: 100%;
}

.city-scene-fallback img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.city-scene-fallback-overlay {
  position: absolute;
  left: 18px;
  bottom: 18px;
  padding: 16px 18px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(14px);
  box-shadow: var(--shadow-md);
}

.city-scene-fallback-overlay h3 {
  margin: 0 0 6px;
}

.city-scene-fallback-overlay p {
  margin: 0;
  color: var(--muted);
}

.city-side-panel {
  padding: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.city-side-scroll {
  flex: 1;
  overflow: auto;
  padding: 16px;
  display: grid;
  gap: 12px;
  align-content: start;
  scrollbar-width: thin;
  scrollbar-color: rgba(10, 108, 241, 0.35) transparent;
}

.city-side-scroll::-webkit-scrollbar {
  width: 6px;
}

.city-side-scroll::-webkit-scrollbar-thumb {
  background: rgba(10, 108, 241, 0.28);
  border-radius: 999px;
}

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

.city-stat-card {
  display: grid;
  gap: 4px;
  padding: 12px 10px;
  border-radius: 14px;
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.92), rgba(244, 247, 252, 0.85));
  border: 1px solid rgba(15, 30, 60, 0.08);
  box-shadow: var(--shadow-sm);
  transition: transform var(--t-fast), box-shadow var(--t-med), border-color var(--t-med);
}

.city-stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: rgba(10, 108, 241, 0.22);
}

.city-stat-icon {
  font-size: 0.85rem;
  opacity: 0.65;
}

.city-stat-label {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: rgba(34, 48, 70, 0.55);
}

.city-stat-value {
  font-size: 0.82rem;
  font-weight: 750;
  line-height: 1.25;
  color: #15233d;
  word-break: break-word;
}

.city-stat-card--prosperity .city-stat-icon { color: #16a34a; }
.city-stat-card--government .city-stat-icon { color: #2563eb; }
.city-stat-card--tension .city-stat-icon { color: #d97706; }

.city-side-block {
  padding: 14px 15px;
  border-radius: 16px;
  background: linear-gradient(165deg, rgba(255, 255, 255, 0.88), rgba(248, 250, 255, 0.78));
  border: 1px solid rgba(15, 30, 60, 0.07);
  box-shadow: var(--shadow-sm);
}

.city-block-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.city-block-icon {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 9px;
  font-size: 0.82rem;
  color: #0a6cf1;
  background: rgba(10, 108, 241, 0.1);
  border: 1px solid rgba(10, 108, 241, 0.14);
  flex-shrink: 0;
}

.city-side-block h3 {
  margin: 0;
  font-size: 0.92rem;
  font-weight: 750;
  letter-spacing: -0.01em;
}

.city-block-count {
  margin-left: auto;
  font-size: 0.72rem;
  font-weight: 650;
  color: var(--muted);
}

.city-lead-text,
.city-event-text {
  margin: 0;
  color: rgba(34, 48, 70, 0.82);
  line-height: 1.72;
  font-size: 0.92rem;
}

.city-side-block--event {
  background: linear-gradient(155deg, rgba(255, 251, 240, 0.95), rgba(255, 255, 255, 0.88));
  border-color: rgba(217, 119, 6, 0.15);
}

.city-side-block--event .city-block-icon {
  color: #b45309;
  background: rgba(217, 119, 6, 0.1);
  border-color: rgba(217, 119, 6, 0.18);
}

.city-chip-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.city-chip {
  display: inline-flex;
  align-items: center;
  padding: 6px 11px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  color: #1c2c47;
  background: rgba(10, 108, 241, 0.07);
  border: 1px solid rgba(10, 108, 241, 0.12);
  transition: transform var(--t-fast), background var(--t-fast), border-color var(--t-fast);
}

.city-chip:hover {
  transform: translateY(-1px);
  background: rgba(10, 108, 241, 0.12);
  border-color: rgba(10, 108, 241, 0.22);
}

.city-chip--empty {
  opacity: 0.65;
  font-style: italic;
}

.city-npc-grid {
  display: grid;
  gap: 8px;
}

.city-npc-card {
  padding: 12px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(15, 30, 60, 0.08);
  border-left: 3px solid var(--npc-accent, #8a8f98);
  box-shadow: var(--shadow-sm);
  transition: transform var(--t-fast), box-shadow var(--t-med), border-color var(--t-med);
}

.city-npc-card:hover {
  transform: translateX(3px);
  box-shadow: var(--shadow-md);
}

.city-npc-card.accent-warm { --npc-accent: #d99a52; }
.city-npc-card.accent-cold { --npc-accent: #6f8aa8; }
.city-npc-card.accent-royal { --npc-accent: #8a6fb0; }
.city-npc-card.accent-danger { --npc-accent: #c4584f; }
.city-npc-card.accent-neutral { --npc-accent: #8a8f98; }

.city-npc-card-top {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  align-items: center;
}

.city-npc-avatar {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 12px;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  color: #fff;
  background: linear-gradient(145deg, var(--npc-accent), color-mix(in srgb, var(--npc-accent) 70%, #000));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

.city-npc-meta {
  min-width: 0;
}

.city-npc-meta strong {
  display: block;
  font-size: 0.88rem;
  font-weight: 750;
  color: #15233d;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.city-npc-meta span {
  display: block;
  margin-top: 2px;
  font-size: 0.76rem;
  color: var(--muted);
}

.city-npc-tag {
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--npc-accent);
  background: color-mix(in srgb, var(--npc-accent) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--npc-accent) 28%, transparent);
}

.city-npc-hint {
  margin: 8px 0 0;
  font-size: 0.72rem;
  color: rgba(34, 48, 70, 0.55);
}

.city-npc-empty {
  margin: 0;
  font-size: 0.85rem;
  color: var(--muted);
  font-style: italic;
}

.city-experience.is-open .city-stats-grid,
.city-experience.is-open .city-side-block,
.city-experience.is-open .city-npc-card {
  animation: ws-city-panel-in 0.55s var(--ease) both;
  animation-delay: var(--stagger, 0s);
}

.city-experience.is-open .city-stats-grid { --stagger: 0.04s; }
.city-experience.is-open .city-side-block:nth-of-type(2) { --stagger: 0.08s; }
.city-experience.is-open .city-side-block:nth-of-type(3) { --stagger: 0.12s; }
.city-experience.is-open .city-side-block:nth-of-type(4) { --stagger: 0.16s; }
.city-experience.is-open .city-side-block:nth-of-type(5) { --stagger: 0.2s; }
.city-experience.is-open .city-side-block:nth-of-type(6) { --stagger: 0.24s; }

@keyframes ws-city-panel-in {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* --- Scheda personaggio (modal come city experience) --- */
.character-experience-shell {
  width: min(760px, 100%);
  height: min(90vh, 920px);
  max-height: min(90vh, 920px);
  min-height: 0;
}

.character-experience-body {
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  border-radius: var(--radius-lg);
  padding: 0;
}

.character-experience-body .city-side-scroll {
  flex: 1;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.character-hero-strip {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px;
  border-radius: 16px;
  background: linear-gradient(145deg, rgba(10, 108, 241, 0.08), rgba(255, 255, 255, 0.72));
  border: 1px solid rgba(10, 108, 241, 0.12);
}

.character-avatar-lg {
  flex-shrink: 0;
  width: 68px;
  height: 68px;
  border-radius: 18px;
  display: grid;
  place-items: center;
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  color: #fff;
  background: linear-gradient(145deg, #0a6cf1, #2f9bff);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.28), var(--shadow-md);
}

.character-hero-copy {
  min-width: 0;
}

.character-tagline {
  margin: 0 0 8px;
  font-size: 0.84rem;
  font-weight: 650;
  color: rgba(34, 48, 70, 0.72);
}

.character-trait-list {
  margin: 0;
}

.character-secrets-block {
  background: linear-gradient(155deg, rgba(255, 248, 248, 0.96), rgba(255, 255, 255, 0.9));
  border-color: rgba(196, 88, 79, 0.16);
}

.character-secrets-block .city-block-icon {
  color: #b45309;
  background: rgba(196, 88, 79, 0.1);
  border-color: rgba(196, 88, 79, 0.18);
}

.character-secret-chip {
  background: rgba(196, 88, 79, 0.08);
  border-color: rgba(196, 88, 79, 0.18);
  color: #7a2e28;
}

.character-experience.is-open .character-hero-strip,
.character-experience.is-open .city-side-block,
.character-experience.is-open .city-stats-grid {
  animation: ws-city-panel-in 0.55s var(--ease) both;
  animation-delay: var(--stagger, 0s);
}

.character-experience.is-open .character-hero-strip { --stagger: 0.04s; }
.character-experience.is-open .city-stats-grid { --stagger: 0.08s; }
.character-experience.is-open .city-side-block:nth-of-type(1) { --stagger: 0.12s; }
.character-experience.is-open .city-side-block:nth-of-type(2) { --stagger: 0.16s; }
.character-experience.is-open .city-side-block:nth-of-type(3) { --stagger: 0.2s; }
.character-experience.is-open .city-side-block:nth-of-type(4) { --stagger: 0.24s; }
.character-experience.is-open .city-side-block:nth-of-type(5) { --stagger: 0.28s; }
.character-experience.is-open .city-side-block:nth-of-type(6) { --stagger: 0.32s; }

.legal-experience-shell {
  width: min(1180px, 100%);
  height: min(88vh, 920px);
}

.legal-experience-body {
  min-height: 0;
  display: grid;
  overflow: hidden;
  padding: 0;
}

.legal-experience-scroll {
  min-height: 0;
  overflow: auto;
  padding: clamp(14px, 2vw, 20px);
}

.legal-experience-scroll .detail-text-panel h2:first-child {
  margin-top: 0;
}

.legal-experience.is-open .detail-text-panel,
.legal-experience.is-open .legal-detail-aside {
  animation: ws-modal-in 0.42s var(--ease) both;
}

body.modal-open {
  overflow: hidden;
}

@media (max-width: 1100px) {
  .city-experience-grid {
    grid-template-columns: 1fr;
  }

  .city-experience-shell {
    height: min(94vh, 1200px);
  }

  .city-scene-canvas-wrap {
    min-height: 340px;
  }

  .city-stats-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .city-experience {
    padding: 8px;
  }

  .city-experience-topbar {
    flex-direction: column;
    align-items: stretch;
  }

  .city-close-btn {
    align-self: flex-end;
  }

  .city-experience-shell {
    width: 100%;
    height: 94vh;
  }

  .character-experience-shell {
    max-height: 94vh;
  }

  .character-hero-strip {
    flex-direction: column;
    align-items: flex-start;
  }

  .city-npc-card-top {
    grid-template-columns: auto 1fr;
  }

  .city-npc-tag {
    grid-column: 1 / -1;
    justify-self: start;
  }
}

/* ============ City scene NPC layer ============ */

.city-scene-canvas-wrap {
  position: relative;
}

.city-scene-canvas-wrap canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.city-scene-overlay {
  position: absolute;
  inset: 0;
  z-index: 5;
  pointer-events: none;
  overflow: hidden;
}

.npc-label {
  position: absolute;
  transform: translateX(-50%);
  transform-origin: center bottom;
  padding: 5px 13px 6px;
  border-radius: var(--radius-pill);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.98) 0%, rgba(246, 248, 252, 0.94) 100%);
  color: #12141a;
  border: 1px solid rgba(255, 255, 255, 0.85);
  outline: 1px solid rgba(15, 23, 42, 0.1);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.95) inset,
    0 8px 22px rgba(15, 23, 42, 0.16),
    0 2px 6px rgba(15, 23, 42, 0.08);
  backdrop-filter: blur(12px) saturate(1.2);
  font-size: 0.73rem;
  font-weight: 700;
  white-space: nowrap;
  text-align: center;
  letter-spacing: 0.02em;
  opacity: 0;
  pointer-events: none;
  transition:
    opacity 0.22s var(--ease),
    transform 0.28s var(--ease),
    box-shadow 0.28s var(--ease),
    border-color 0.22s var(--ease);
}

.npc-label-shine {
  position: absolute;
  inset: 1px 8px auto;
  height: 42%;
  border-radius: var(--radius-pill);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.72), rgba(255, 255, 255, 0));
  pointer-events: none;
}

.npc-label-tail {
  position: absolute;
  left: 50%;
  bottom: -5px;
  width: 10px;
  height: 6px;
  transform: translateX(-50%);
  background: rgba(248, 250, 252, 0.96);
  clip-path: polygon(50% 100%, 0 0, 100% 0);
  filter: drop-shadow(0 2px 2px rgba(15, 23, 42, 0.12));
  pointer-events: none;
}

.npc-label--citizen {
  opacity: 1;
  transform: translateX(-50%);
}

.npc-label--citizen::before {
  content: "";
  position: absolute;
  left: 8px;
  top: 50%;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  transform: translateY(-50%);
  background: var(--label-accent, var(--blue));
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.85);
}

.npc-label-name {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding-left: 8px;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.65);
}

.npc-label[data-accent="warm"] { --label-accent: #c9852e; }
.npc-label[data-accent="cold"] { --label-accent: #5a82a8; }
.npc-label[data-accent="royal"] { --label-accent: #8a6fb0; }
.npc-label[data-accent="danger"] { --label-accent: #c4584f; }
.npc-label[data-accent="neutral"] { --label-accent: #6b7280; }

.npc-label.is-visible,
.npc-label.is-hover {
  opacity: 1;
  transform: translateX(-50%) translateY(-2px) scale(1.03);
}

.npc-label--citizen.is-hover {
  outline-color: color-mix(in srgb, var(--label-accent, var(--blue)) 35%, transparent);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.95) inset,
    0 12px 28px color-mix(in srgb, var(--label-accent, var(--blue)) 22%, transparent),
    0 4px 10px rgba(15, 23, 42, 0.12);
}

.npc-label--citizen.is-talking {
  outline-color: color-mix(in srgb, var(--label-accent, var(--blue)) 45%, transparent);
  animation: ws-label-talk 1.1s ease-in-out infinite;
}

.npc-label--citizen.is-talking::before {
  animation: ws-label-dot-pulse 1.1s ease-out infinite;
}

@keyframes ws-label-talk {
  0%, 100% { transform: translateX(-50%) translateY(0); }
  50% { transform: translateX(-50%) translateY(-3px); }
}

@keyframes ws-label-dot-pulse {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--label-accent, var(--blue)) 55%, transparent); }
  70% { box-shadow: 0 0 0 6px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}

.npc-label-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #2f9bff;
  flex-shrink: 0;
  animation: ws-talk-dot 1.8s ease-out infinite;
}

@keyframes ws-talk-dot {
  0% { box-shadow: 0 0 0 0 rgba(47, 155, 255, 0.55); }
  70% { box-shadow: 0 0 0 7px rgba(47, 155, 255, 0); }
  100% { box-shadow: 0 0 0 0 rgba(47, 155, 255, 0); }
}

.npc-label-role {
  display: block;
  font-size: 0.62rem;
  font-weight: 600;
  color: var(--blue-dark);
  opacity: 0.9;
  margin-top: 1px;
}

.npc-bubble {
  position: absolute;
  transform: translate(-50%, -100%) scale(0.9);
  max-width: 260px;
  padding: 12px 14px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.97);
  border: 1px solid rgba(0, 0, 0, 0.08);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.28);
  display: grid;
  gap: 4px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s cubic-bezier(0.18, 0.9, 0.32, 1.4);
  z-index: 6;
}

.npc-bubble[data-align="left"] {
  transform: translate(-12%, -100%) scale(0.9);
}

.npc-bubble[data-align="right"] {
  transform: translate(-88%, -100%) scale(0.9);
}

.npc-bubble.is-visible {
  opacity: 1;
  transform: translate(-50%, -110%) scale(1);
  pointer-events: auto;
}

.npc-bubble[data-align="left"].is-visible {
  transform: translate(-12%, -110%) scale(1);
}

.npc-bubble[data-align="right"].is-visible {
  transform: translate(-88%, -110%) scale(1);
}

.npc-bubble.is-popping {
  animation: ws-bubble-pop 0.45s ease;
}

.npc-bubble strong {
  font-size: 0.82rem;
  color: var(--blue-dark);
}

.npc-bubble span {
  font-size: 0.9rem;
  line-height: 1.45;
  color: var(--text);
}

.npc-bubble::after {
  content: "";
  position: absolute;
  bottom: -8px;
  left: 50%;
  transform: translateX(-50%);
  border-width: 9px 8px 0 8px;
  border-style: solid;
  border-color: rgba(255, 255, 255, 0.97) transparent transparent transparent;
  filter: drop-shadow(0 6px 4px rgba(0, 0, 0, 0.06));
}

.npc-bubble[data-align="left"]::after { left: 12%; }
.npc-bubble[data-align="right"]::after { left: 88%; }

.npc-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 8px;
}

.npc-action-btn {
  appearance: none;
  border: 1px solid rgba(0, 0, 0, 0.1);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.95), rgba(244, 236, 224, 0.9));
  color: var(--blue-dark);
  font-size: 0.82rem;
  font-weight: 600;
  padding: 7px 10px;
  border-radius: 10px;
  cursor: pointer;
  text-align: left;
  transition: transform 0.15s ease, box-shadow 0.2s ease, background 0.2s ease, border-color 0.2s ease;
}

.npc-action-btn::before {
  content: "\203A";
  margin-right: 8px;
  color: var(--accent, #b5483f);
  font-weight: 700;
}

.npc-action-btn:hover {
  transform: translateX(2px);
  border-color: var(--accent, #b5483f);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.14);
  background: linear-gradient(180deg, #fff, rgba(244, 236, 224, 0.98));
}

.npc-action-btn:active {
  transform: translateX(2px) scale(0.98);
}

.city-scene-error {
  position: absolute;
  left: 50%;
  bottom: 18px;
  transform: translate(-50%, 12px);
  max-width: 80%;
  padding: 10px 16px;
  border-radius: 12px;
  background: rgba(40, 24, 20, 0.86);
  color: #ffe9e2;
  font-size: 0.82rem;
  font-weight: 600;
  text-align: center;
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.4);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.3s ease;
  z-index: 8;
}

.city-scene-error.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.npc-fallback-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.npc-fallback-chip {
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid rgba(0, 113, 227, 0.2);
  background: rgba(0, 113, 227, 0.08);
  color: var(--blue-dark);
  font-weight: 700;
  font-size: 0.82rem;
  cursor: pointer;
  transition: transform 0.18s ease, background 0.18s ease;
}

.npc-fallback-chip:hover {
  transform: translateY(-2px);
  background: rgba(0, 113, 227, 0.16);
}

/* ============ Premium micro-animations ============ */

@keyframes ws-fade-in {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes ws-pulse-dot {
  0% { box-shadow: 0 0 0 0 rgba(0, 113, 227, 0.45); }
  70% { box-shadow: 0 0 0 9px rgba(0, 113, 227, 0); }
  100% { box-shadow: 0 0 0 0 rgba(0, 113, 227, 0); }
}

@keyframes ws-bubble-pop {
  0% { transform: translate(-50%, -100%) scale(0.7); }
  60% { transform: translate(-50%, -113%) scale(1.05); }
  100% { transform: translate(-50%, -110%) scale(1); }
}

@media (prefers-reduced-motion: no-preference) {
  .panel,
  .info-card,
  .map-card,
  .story-section,
  .topbar {
    animation: ws-fade-in 0.5s ease both;
  }

  .info-column .info-card:nth-child(2) { animation-delay: 0.06s; }
  .info-column .info-card:nth-child(3) { animation-delay: 0.12s; }

  .feed-item {
    animation: ws-fade-in 0.45s ease both;
  }
}

.primary-btn,
.soft-btn,
.mini-btn,
.danger-btn,
.button-link {
  transition: transform 0.16s ease, box-shadow 0.22s ease, background 0.2s ease, filter 0.2s ease;
  will-change: transform;
}

.primary-btn:hover,
.button-link:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 32px rgba(0, 113, 227, 0.28);
}

.soft-btn:hover,
.mini-btn:hover {
  transform: translateY(-1px);
  filter: brightness(1.03);
}

.danger-btn:hover {
  transform: translateY(-1px);
}

.primary-btn:active,
.soft-btn:active,
.mini-btn:active,
.danger-btn:active,
.button-link:active {
  transform: translateY(0) scale(0.98);
}

.item-card,
.item-link-card,
.session-item {
  transition: transform 0.2s ease, box-shadow 0.25s ease, border-color 0.2s ease;
}

.item-link-card:hover,
.session-item:hover {
  transform: translateY(-3px);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.1);
}

.chip {
  transition: transform 0.16s ease, background 0.18s ease, box-shadow 0.2s ease;
}

.chip:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 24px rgba(0, 113, 227, 0.18);
}

.badge {
  transition: transform 0.16s ease;
}

.item-card:hover .badge {
  transform: translateY(-1px);
}

.surface {
  transition: box-shadow 0.3s ease, transform 0.3s ease;
}

.city-meta-pill {
  transition: transform 0.18s ease, background 0.2s ease;
}

.city-meta-pill:hover {
  transform: translateY(-2px);
  background: rgba(0, 113, 227, 0.14);
}

.brand-link .brand-logo {
  transition: transform 0.35s ease, filter 0.35s ease;
}

.brand-link:hover .brand-logo {
  transform: scale(1.03);
}

.brand-link span {
  transition: transform 0.4s ease;
}

.brand-link:hover span {
  transform: rotate(18deg) scale(1.1);
}

.city-scene-generating {
  position: absolute;
  z-index: 7;
  top: 14px;
  right: 14px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid var(--line);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.18);
  backdrop-filter: blur(14px);
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text);
  animation: ws-fade-in 0.4s ease both;
}

.city-scene-generating-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--blue);
  animation: ws-pulse-dot 1.4s ease-out infinite;
}

.detail-city-image.is-loading-image {
  filter: blur(8px);
  opacity: 0.7;
}

.detail-city-image {
  transition: filter 0.6s ease, opacity 0.6s ease;
}

.legal-links {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 14px;
}

.legal-links a {
  color: var(--muted);
  font-size: 0.82rem;
  text-decoration: none;
  transition: color 0.2s ease, transform 0.2s ease;
}

.legal-links a:hover {
  color: var(--blue);
  transform: translateY(-1px);
}

.sidebar-legal {
  justify-content: flex-start;
}

/* =====================================================================
   ENTERPRISE UI LAYER — rifinitura avanzata e coerente di tutto il sito
   (mantiene palette blu/bianco, eleva profondita, tipografia e micro-UX)
   ===================================================================== */

/* Tipografia titoli piu definita */
.topbar h1,
.profile-hero h1,
.detail-hero-copy h1,
.legal-hero h1 {
  letter-spacing: -0.03em;
  font-weight: 800;
}

.eyebrow {
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-weight: 700;
  font-size: 0.72rem;
  color: var(--blue-dark);
}

/* --- Pannelli e card: profondita e bordo hairline --- */
.panel,
.map-card,
.info-card,
.story-section,
.profile-section,
.detail-image-panel,
.detail-text-panel,
.detail-list-panel,
.cookie-card,
.loader-card {
  border-radius: var(--radius-lg);
  transition: box-shadow var(--t-med), transform var(--t-med), border-color var(--t-med);
}

.map-card:hover,
.info-card:hover,
.story-section:hover,
.profile-section:hover {
  box-shadow: var(--shadow-lg);
}

/* --- Bottoni enterprise --- */
.primary-btn,
.soft-btn,
.danger-btn,
.mini-btn,
.button-link {
  border-radius: var(--radius-sm);
  font-weight: 650;
  letter-spacing: -0.01em;
  transition: transform var(--t-fast), box-shadow var(--t-med), background var(--t-med), filter var(--t-fast);
  will-change: transform;
}

.primary-btn {
  position: relative;
  overflow: hidden;
  background: var(--accent-grad);
  color: #fff;
  border: none;
  box-shadow: 0 10px 26px rgba(10, 108, 241, 0.34), inset 0 1px 0 rgba(255, 255, 255, 0.35);
  z-index: 0;
}

.primary-btn > *,
.soft-btn > *,
.danger-btn > *,
.mini-btn > * {
  position: relative;
  z-index: 1;
}

.primary-btn::after {
  content: "";
  position: absolute;
  top: 0;
  left: -120%;
  width: 60%;
  height: 100%;
  background: linear-gradient(100deg, transparent, rgba(255, 255, 255, 0.45), transparent);
  transform: skewX(-18deg);
  transition: left 0.6s var(--ease);
}

.primary-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 16px 36px rgba(10, 108, 241, 0.42), inset 0 1px 0 rgba(255, 255, 255, 0.4);
  filter: saturate(1.05);
}

.primary-btn:hover::after {
  left: 130%;
}

.primary-btn:active,
.soft-btn:active,
.danger-btn:active,
.mini-btn:active {
  transform: translateY(0) scale(0.985);
}

.soft-btn,
.mini-btn {
  background: var(--surface-strong);
  border: 1px solid var(--line-strong);
  color: var(--text);
  box-shadow: var(--shadow-xs);
}

.soft-btn:hover,
.mini-btn:hover {
  transform: translateY(-2px);
  border-color: rgba(10, 108, 241, 0.4);
  box-shadow: var(--shadow-md);
  color: var(--blue-dark);
}

.danger-btn {
  background: linear-gradient(135deg, #ff5a5f, #e5484d);
  color: #fff;
  border: none;
  box-shadow: 0 10px 24px rgba(229, 72, 77, 0.32);
}

.danger-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 16px 34px rgba(229, 72, 77, 0.42);
}

/* --- Campi: input, textarea, select --- */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="search"],
input[type="url"],
textarea,
select,
.action-panel textarea,
.profile-search,
.share-inline-row input {
  background: var(--surface-solid);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  color: var(--text);
  transition: border-color var(--t-fast), box-shadow var(--t-fast), background var(--t-fast);
  box-shadow: var(--shadow-xs);
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
input[type="search"]:focus,
input[type="url"]:focus,
textarea:focus,
select:focus,
.action-panel textarea:focus,
.profile-search:focus,
.share-inline-row input:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: var(--ring);
}

input::placeholder,
textarea::placeholder {
  color: var(--muted);
  opacity: 0.7;
}

/* --- Sidebar e user pill --- */
.sidebar {
  border-radius: var(--radius-lg);
}

.user-pill {
  border-radius: var(--radius);
  background: var(--accent-grad-soft);
  border: 1px solid var(--line);
  transition: box-shadow var(--t-med), transform var(--t-med);
}

.user-pill:hover {
  box-shadow: var(--shadow-sm);
}

.avatar,
.avatar-big {
  background: var(--accent-grad);
  box-shadow: 0 8px 20px rgba(10, 108, 241, 0.32), inset 0 1px 0 rgba(255, 255, 255, 0.4);
}

/* --- Navigazione laterale --- */
.nav-panel a,
.nav-actions a {
  border-radius: var(--radius-sm);
  transition: background var(--t-fast), color var(--t-fast), transform var(--t-fast);
}

.nav-panel a:hover,
.nav-actions a:hover {
  background: var(--blue-soft);
  color: var(--blue-dark);
  transform: translateX(2px);
}

/* --- Sessioni in sidebar --- */
.session-item {
  border-radius: var(--radius-sm);
  transition: background var(--t-fast), border-color var(--t-fast), transform var(--t-fast), box-shadow var(--t-med);
}

.session-item:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.session-item.active {
  background: var(--blue-soft);
  border-color: rgba(10, 108, 241, 0.4);
  box-shadow: inset 3px 0 0 var(--blue);
}

/* --- Topbar stats --- */
.topbar-stats div {
  border-radius: var(--radius-sm);
  background: var(--surface-strong);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-xs);
  transition: transform var(--t-fast), box-shadow var(--t-med);
}

.topbar-stats div:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

/* --- Feed / storyline --- */
.feed-item {
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  transition: transform var(--t-fast), box-shadow var(--t-med);
}

.feed-item:hover {
  transform: translateX(2px);
  box-shadow: var(--shadow-sm);
}

.feed-item.user {
  background: var(--accent-grad-soft);
  border-color: rgba(10, 108, 241, 0.18);
}

.feed-role {
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-size: 0.68rem;
  font-weight: 700;
}

/* --- Chips & badges --- */
.chip,
.badge,
.profile-badges span {
  border-radius: var(--radius-pill);
  border: 1px solid var(--line-strong);
  background: var(--surface-strong);
  backdrop-filter: blur(8px);
}

/* --- Item cards (liste regioni/elementi) --- */
.item-card,
.item-link-card,
.world-row {
  border-radius: var(--radius-sm);
  transition: transform var(--t-fast), box-shadow var(--t-med), border-color var(--t-med);
}

.item-link-card:hover,
.world-row:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: rgba(10, 108, 241, 0.35);
}

/* --- Modale citta & overlay --- */
.city-experience-backdrop,
.loading-overlay {
  background: radial-gradient(1200px 800px at 50% 0%, rgba(10, 108, 241, 0.12), transparent 60%), rgba(12, 16, 28, 0.55);
  backdrop-filter: blur(10px) saturate(140%);
  -webkit-backdrop-filter: blur(10px) saturate(140%);
}

.city-experience-shell {
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  animation: ws-modal-in 0.42s var(--ease) both;
}

.city-scene-canvas-wrap {
  border-radius: var(--radius);
  box-shadow: inset 0 0 0 1px var(--line), var(--shadow-md);
}

.city-side-block {
  border-radius: var(--radius-sm);
  transition: box-shadow var(--t-med), transform var(--t-med);
}

.city-side-block:hover {
  box-shadow: var(--shadow-sm);
}

.loader-card {
  box-shadow: var(--shadow-xl);
  animation: ws-modal-in 0.4s var(--ease) both;
}

/* --- Pagine legali / dettaglio --- */
.legal-section,
.detail-text-panel,
.detail-list-panel {
  border-radius: var(--radius-lg);
}

.legal-section:hover {
  box-shadow: var(--shadow-md);
}

@keyframes ws-modal-in {
  from { opacity: 0; transform: translateY(18px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.app-toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 2200;
  transform: translateX(-50%) translateY(0);
  max-width: min(520px, calc(100vw - 32px));
  padding: 12px 18px;
  border-radius: 999px;
  font-size: 0.92rem;
  font-weight: 600;
  line-height: 1.4;
  text-align: center;
  color: #142033;
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid rgba(17, 24, 39, 0.1);
  box-shadow: 0 18px 48px rgba(15, 30, 60, 0.22);
  backdrop-filter: blur(12px);
  animation: ws-fade-in 0.28s var(--ease, ease) both;
}

.app-toast.hidden {
  display: none;
}

.app-toast--error {
  color: #7a1a12;
  background: rgba(255, 236, 232, 0.98);
  border-color: rgba(180, 48, 32, 0.18);
}

.app-toast--info {
  color: #1a3f72;
  background: rgba(240, 246, 255, 0.98);
  border-color: rgba(10, 108, 241, 0.16);
}

/* Rispetto delle preferenze di riduzione movimento */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
}

/* ============================================================
   Anti-overflow del testo: i testi non devono uscire dai box
   ============================================================ */

/* Bottoni e link-bottone: il testo va a capo e non sborda mai */
.primary-btn,
.soft-btn,
.danger-btn,
.mini-btn,
.button-link,
.chip {
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
  min-width: 0;
  max-width: 100%;
  line-height: 1.25;
}

.soft-btn,
.danger-btn,
.primary-btn {
  padding: 10px 16px;
  height: auto;
}

.mini-btn {
  padding: 6px 12px;
  height: auto;
}

/* Link di navigazione tipo "Torna all'app": padding per non toccare i bordi */
.nav-actions a,
.nav-panel a {
  display: inline-flex;
  align-items: center;
  padding: 7px 12px;
  white-space: nowrap;
}

/* Azioni suggerite: lista verticale di pulsanti che mandano a capo le frasi */
#suggestedActions.chips {
  flex-direction: column;
  align-items: stretch;
}

#suggestedActions .chip {
  width: 100%;
  text-align: left;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
  border-radius: 14px;
  padding: 10px 14px;
  line-height: 1.35;
}

/* Card e pannelli: contenuti che non sfondano orizzontalmente */
.panel,
.surface,
.item-card,
.item-link-card,
.session-item {
  min-width: 0;
}

.panel p,
.surface p,
.item-card p,
.item-link-card p {
  overflow-wrap: anywhere;
  word-break: break-word;
}

/* ============================================================
   Label citta sulla mappa: colore diverso se visitate o meno
   ============================================================ */

/* Non visitate (default): accento blu, gia' definito sopra. */

/* Visitate: accento verde + spunta */
.map-region-label.is-visited {
  border-color: rgba(22, 163, 74, 0.42);
  background: linear-gradient(165deg, rgba(240, 253, 244, 0.96), rgba(228, 245, 233, 0.9));
}

.map-region-label.is-visited .map-region-label-type {
  color: rgba(21, 128, 61, 0.9);
}

.map-region-label.is-visited .map-region-label-type::before {
  content: "\2713\00a0";
}

.map-region-label.is-visited .map-region-label-name {
  color: #133d27;
}

.map-region-label.is-visited.is-hovered {
  border-color: rgba(22, 163, 74, 0.55);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.9) inset,
    0 14px 32px -12px rgba(22, 163, 74, 0.3),
    0 4px 10px -4px rgba(15, 30, 60, 0.22);
}
